From aee1412d57a40f569d5f22b709f17946679440be Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 3 Jun 2024 15:49:56 -0400 Subject: [PATCH] Chad package refactoring... --- source/chad.adb | 106 ------------------------------------------------------- source/chad.ads | 9 ----- source/world.adb | 58 ++++++++++++++++++++++++++++-- 3 files changed, 55 insertions(+), 118 deletions(-) diff --git a/source/chad.adb b/source/chad.adb index 3f9b25d..d6123f2 100644 --- a/source/chad.adb +++ b/source/chad.adb @@ -14,18 +14,12 @@ package body chad is sprite : array (enumeration) of core.sprite; view : array (enumeration) of core.sprite; - pepe_the_frog : core.sprite; - alice_the_mad : core.sprite; - ------------------------------------------------------------------------------------------ procedure configure is begin core.echo (core.comment, "Configuring chad components..."); -- - pepe_the_frog := core.import_sprite (core.folder & "/game/unit/pepe_the_frog.png", 4, 6); - alice_the_mad := core.import_sprite (core.folder & "/game/unit/alice_the_mad.png", 4, 6); - -- for index in enumeration loop sprite (index) := core.import_sprite (core.folder & "/game/chad/" & core.lowercase (enumeration'image (index)) & ".png", 4, 6); view (index) := core.import_sprite (core.folder & "/view/chad/" & core.lowercase (enumeration'image (index)) & ".png", 1, 1); @@ -115,106 +109,6 @@ package body chad is end; end draw_data; - ------------------------------------------------------------------------------------------ - - procedure draw_menu (player : in information; x, y : in integer) is - begin - null; - end draw_menu; - - ------------------------------------------------------------------------------------------ - - function take_equipment_item (player : in out information; item : in equipment.enumeration) return boolean is - use type equipment.enumeration; - begin - if player.item_count = item_limit or item = equipment.none then - return false; - end if; - -- - player.items (player.item_count) := item; - -- - core.increment (player.item_count); - -- - return true; - end take_equipment_item; - - ------------------------------------------------------------------------------------------ - - procedure draw_pepe is - begin - core.draw (pepe_the_frog, (core.window_width - core.base) / 2, (core.window_height - core.base) / 2); - end draw_pepe; - - ------------------------------------------------------------------------------------------ - - procedure draw_alice is - begin - core.draw (alice_the_mad, (core.window_width - core.base) / 2, (core.window_height - core.base) / 2); - end draw_alice; - - ------------------------------------------------------------------------------------------ - - procedure save_value (here : in core.io.file_type; data : in information) is - begin - core.io.write (here, enumeration'pos (data.index)); - core.io.write (here, core.animation'pos (data.state)); - core.io.write (here, data.x); - core.io.write (here, data.y); - -- - core.save_point (here, data.health); - core.save_point (here, data.mana); - core.save_point (here, data.movement); - -- - for index in attribute.enumeration loop core.save_point (here, data.attributes (index)); end loop; - for index in skill.enumeration loop core.save_point (here, data.skills (index)); end loop; - for index in resource.enumeration loop core.save_point (here, data.resources (index)); end loop; - for index in material.enumeration loop core.save_point (here, data.materials (index)); end loop; - -- - for index in equipment.slot loop - core.io.write (here, equipment.enumeration'pos (data.equipments (index))); - end loop; - -- - core.io.write (here, data.item_count); - -- - if data.item_count > 0 then - for index in 0 .. data.item_count - 1 loop - core.io.write (here, equipment.enumeration'pos (data.items (index))); - end loop; - end if; - end save_value; - - ------------------------------------------------------------------------------------------ - - procedure load_value (here : in core.io.file_type; data : out information) is - this : integer; - begin - core.io.read (here, this); data.index := enumeration'val (this); - core.io.read (here, this); data.state := core.animation'val (this); - core.io.read (here, data.x); - core.io.read (here, data.y); - -- - core.load_point (here, data.health); - core.load_point (here, data.mana); - core.load_point (here, data.movement); - -- - for index in attribute.enumeration loop core.load_point (here, data.attributes (index)); end loop; - for index in skill.enumeration loop core.load_point (here, data.skills (index)); end loop; - for index in resource.enumeration loop core.load_point (here, data.resources (index)); end loop; - for index in material.enumeration loop core.load_point (here, data.materials (index)); end loop; - -- - for index in equipment.slot loop - core.io.read (here, this); data.equipments (index) := equipment.enumeration'val (this); - end loop; - -- - core.io.read (here, data.item_count); - -- - if data.item_count > 0 then - for index in 0 .. data.item_count - 1 loop - core.io.read (here, this); data.items (index) := equipment.enumeration'val (this); - end loop; - end if; - end load_value; - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ end chad; diff --git a/source/chad.ads b/source/chad.ads index 2325ff0..bbdcd8f 100644 --- a/source/chad.ads +++ b/source/chad.ads @@ -66,15 +66,6 @@ package chad is procedure draw (player : in information; x, y : in integer); procedure draw_data (player : in information; x, y : in integer); - procedure draw_menu (player : in information; x, y : in integer); - - function take_equipment_item (player : in out information; item : in equipment.enumeration) return boolean; - - procedure draw_pepe; - procedure draw_alice; - - procedure save_value (here : in core.io.file_type; data : in information); - procedure load_value (here : in core.io.file_type; data : out information); ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/world.adb b/source/world.adb index 4d3eb89..39a3528 100644 --- a/source/world.adb +++ b/source/world.adb @@ -363,7 +363,11 @@ package body world is if map.equipments (index).x = core.camera.x and map.equipments (index).y = core.camera.y and core.signal_code'pos (core.signal_mode) = core.signal_code'pos (core.signal_e) then - if chad.take_equipment_item (map.chads (1), equipment.enumeration'val (map.equipments (index).index)) then + if map.chads (1).item_count < chad.item_limit and map.equipments (index).index /= equipment.enumeration'pos (equipment.none) then + map.chads (1).items (map.chads (1).item_count) := equipment.enumeration'val (map.equipments (index).index); + -- + core.increment (map.chads (1).item_count); + -- map.equipments (index).index := equipment.enumeration'pos (equipment.none); end if; end if; @@ -695,7 +699,31 @@ package body world is for index in 1 .. equipment_limit loop save_entity (file, map.equipments (index)); end loop; for index in 1 .. unit_limit loop save_entity (file, map.units (index)); end loop; -- - chad.save_value (file, map.chads (1)); + core.io.write (file, chad.enumeration'pos (map.chads (1).index)); + core.io.write (file, core.animation'pos (map.chads (1).state)); + core.io.write (file, map.chads (1).x); + core.io.write (file, map.chads (1).y); + -- + core.save_point (file, map.chads (1).health); + core.save_point (file, map.chads (1).mana); + core.save_point (file, map.chads (1).movement); + -- + for index in attribute.enumeration loop core.save_point (file, map.chads (1).attributes (index)); end loop; + for index in skill.enumeration loop core.save_point (file, map.chads (1).skills (index)); end loop; + for index in resource.enumeration loop core.save_point (file, map.chads (1).resources (index)); end loop; + for index in material.enumeration loop core.save_point (file, map.chads (1).materials (index)); end loop; + -- + for index in equipment.slot loop + core.io.write (file, equipment.enumeration'pos (map.chads (1).equipments (index))); + end loop; + -- + core.io.write (file, map.chads (1).item_count); + -- + if map.chads (1).item_count > 0 then + for index in 0 .. map.chads (1).item_count - 1 loop + core.io.write (file, equipment.enumeration'pos (map.chads (1).items (index))); + end loop; + end if; -- core.io.close (file); -- @@ -740,7 +768,31 @@ package body world is for index in 1 .. equipment_limit loop load_entity (file, map.equipments (index)); end loop; for index in 1 .. unit_limit loop load_entity (file, map.units (index)); end loop; -- - chad.load_value (file, map.chads (1)); + core.io.read (file, this); map.chads (1).index := chad.enumeration'val (this); + core.io.read (file, this); map.chads (1).state := core.animation'val (this); + core.io.read (file, map.chads (1).x); + core.io.read (file, map.chads (1).y); + -- + core.load_point (file, map.chads (1).health); + core.load_point (file, map.chads (1).mana); + core.load_point (file, map.chads (1).movement); + -- + for index in attribute.enumeration loop core.load_point (file, map.chads (1).attributes (index)); end loop; + for index in skill.enumeration loop core.load_point (file, map.chads (1).skills (index)); end loop; + for index in resource.enumeration loop core.load_point (file, map.chads (1).resources (index)); end loop; + for index in material.enumeration loop core.load_point (file, map.chads (1).materials (index)); end loop; + -- + for index in equipment.slot loop + core.io.read (file, this); map.chads (1).equipments (index) := equipment.enumeration'val (this); + end loop; + -- + core.io.read (file, map.chads (1).item_count); + -- + if map.chads (1).item_count > 0 then + for index in 0 .. map.chads (1).item_count - 1 loop + core.io.read (file, this); map.chads (1).items (index) := equipment.enumeration'val (this); + end loop; + end if; -- core.io.close (file); --