From 0fc1c9001937de02c032758ff150b2a6c12b602e Mon Sep 17 00:00:00 2001 From: xolatile Date: Fri, 14 Jun 2024 11:02:53 -0400 Subject: [PATCH] Changed materials and inventory... --- icon/material/none.png | Bin 0 -> 111 bytes source/chad.ads | 9 +---- source/main.adb | 35 ++++++++++--------- source/material.ads | 19 ++++++++--- source/skill.ads | 4 +-- source/world.adb | 91 +++++++++++++++++++++++++------------------------ 6 files changed, 82 insertions(+), 76 deletions(-) create mode 100644 icon/material/none.png diff --git a/icon/material/none.png b/icon/material/none.png new file mode 100644 index 0000000000000000000000000000000000000000..01ea0e23a9a24d61dd78d6d8874be9d1333bff02 GIT binary patch literal 111 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE0wix1Z>k4UoCO|{#S9F3${@^GvDCf{D5&V^ z;uzv_Jo(Rg2g!sa3Dblt4S~#Vyii8lOhyLf4o3T`ZM_eGiWxjz{an^LB{Ts58zURr literal 0 HcmV?d00001 diff --git a/source/chad.ads b/source/chad.ads index d5383fa..935eff8 100644 --- a/source/chad.ads +++ b/source/chad.ads @@ -23,11 +23,6 @@ package chad is bonus_resource : resource.enumeration; end record; - item_limit : constant natural := 24; - skill_limit : constant natural := 8; - - type item_array is array (0 .. item_limit - 1) of equipment.enumeration; - type information is record index : enumeration := ada; state : core.animation := core.idle; @@ -40,10 +35,8 @@ package chad is attributes : attribute.points := attribute.default; skills : skill.points := (others => (others => <>)); resources : resource.points := resource.default; - materials : material.points := material.default; + materials : material.points := (others => (others => <>)); equipments : equipment.equip_array := equipment.default; - item_count : natural := 0; - items : item_array := (others => equipment.none); end record; type informations is array (natural range <>) of information; diff --git a/source/main.adb b/source/main.adb index 27514e0..0ae2673 100644 --- a/source/main.adb +++ b/source/main.adb @@ -104,11 +104,12 @@ procedure main is player : chad.information := ( skills => ((skill.archery, 1, 3), (skill.athletics, 1, 3), (skill.tactics, 1, 3), others => <>), -- - equipments => (equipment.chest => equipment.iron_chestplate, - equipment.head => equipment.iron_helmet, - equipment.hands => equipment.iron_gauntlets, - equipment.feet => equipment.iron_greaves, - equipment.main_hand => equipment.iron_sword, + equipments => (equipment.chest => equipment.crystal_chestplate, + equipment.head => equipment.crystal_helmet, + equipment.hands => equipment.crystal_gauntlets, + equipment.feet => equipment.crystal_greaves, + equipment.main_hand => equipment.crystal_greatsword, + equipment.full_body => equipment.cyan_robe, others => equipment.none), -- others => <> @@ -238,7 +239,7 @@ begin world.insert_chad (player); world.insert_chad (opponent); - world.load ("heyo"); + --~world.load ("heyo"); ui.active := ui.style'val (faction.enumeration'pos (chad.description (player.index).kind) + 1); @@ -295,17 +296,17 @@ begin (preview_width - 5 * core.icon * resource.count) / 2 + (5 * core.icon) * resource.enumeration'pos (index) + core.icon, core.base, 4 * core.icon, core.icon, 10); end loop; -- - declare move_x : integer := (preview_width - core.icon * material.count) / 2; - begin - for index in material.enumeration loop - if world.map.chads (1).materials (index).value > 0 then - ui.draw_icon (material.icon (index), material.description (index).name.all, move_x, core.base + core.icon); - ui.draw_text (world.map.chads (1).materials (index).value'image, move_x, core.base + 2 * core.icon, core.icon, core.icon, 10); - -- - move_x := move_x + core.icon; - end if; - end loop; - end; + --~declare move_x : integer := (preview_width - core.icon * material.count) / 2; + --~begin + --~for index in material.enumeration loop + --~if world.map.chads (1).materials (index).value > 0 then + --~ui.draw_icon (material.icon (index), material.description (index).name.all, move_x, core.base + core.icon); + --~ui.draw_text (world.map.chads (1).materials (index).value'image, move_x, core.base + 2 * core.icon, core.icon, core.icon, 10); + --~-- + --~move_x := move_x + core.icon; + --~end if; + --~end loop; + --~end; -- signal_list (core.signal_mode).all; -- diff --git a/source/material.ads b/source/material.ads index fc3234e..897d99e 100644 --- a/source/material.ads +++ b/source/material.ads @@ -9,6 +9,7 @@ package material is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ type enumeration is ( + none, sulphur, mercury, mint, cinnamon, apple, peach, pear, banana, orange, plum, cherry, lemon, potato, wheat, carrot, cucumber, onion, garlic, @@ -19,19 +20,27 @@ package material is ------------------------------------------------------------------------------------------ type definition is record - name : access string; - cost : natural; + name : access string := new string'("--"); + cost : natural := 0; end record; - type points is array (enumeration) of core.point; + type point is record + index : enumeration := none; + value : natural := 0; + limit : natural := 0; + end record; + + subtype limit is natural range 0 .. 31; + + type points is array (limit) of point; ------------------------------------------------------------------------------------------ count : constant natural := enumeration'pos (enumeration'last) + 1; - default : constant points := (others => (1, 12)); - description : constant array (enumeration) of definition := ( + none => (others => <>), + -- sulphur => (new string'("Sulphur"), 11), mercury => (new string'("Mercury"), 13), mint => (new string'("Mint"), 3), diff --git a/source/skill.ads b/source/skill.ads index 2730461..99b20bd 100644 --- a/source/skill.ads +++ b/source/skill.ads @@ -18,8 +18,6 @@ package skill is ------------------------------------------------------------------------------------------ - subtype limit is natural range 0 .. 7; - type definition is record name : access string := new string'("--"); text : access string := new string'("--"); @@ -31,6 +29,8 @@ package skill is limit : natural := 0; end record; + subtype limit is natural range 0 .. 7; + type points is array (limit) of point; ------------------------------------------------------------------------------------------ diff --git a/source/world.adb b/source/world.adb index 523c6a8..593e2a2 100644 --- a/source/world.adb +++ b/source/world.adb @@ -510,19 +510,7 @@ package body world is orient := orient + view_chad_equipment (data, x + offset, y + offset + orient.y + 2 * core.base, limit - 2 * offset); orient := orient + view_chad_skills (data, x + offset, y + offset + orient.y + 2 * core.base, limit - 2 * offset); ui.draw_separator ( x + offset, y + offset + orient.y + 2 * core.base, limit - 2 * offset); - -- - --~ui.draw_separator (at_x, at_y, width - 2 * offset); - --~-- - --~at_y := at_y + core.base; - --~-- - --~for index_y in 0 .. 2 loop - --~for index_x in 0 .. 7 loop - --~ui.draw_icon (data => equipment.icon (data.items (8 * index_y + index_x)), - --~text => equipment.description (data.items (8 * index_y + index_x)).name.all, - --~x => at_x + index_x * core.icon, - --~y => at_y + index_y * core.icon); - --~end loop; - --~end loop; + orient := orient + view_chad_inventory (data, x + offset, y + offset + orient.y + 3 * core.base, limit - 2 * offset); --~-- --~at_y := at_y + 3 * core.icon; --~-- @@ -672,23 +660,26 @@ package body world is -- for index in attribute.enumeration loop core.save_point (file, map.chads (chad_index).attributes (index)); end loop; for index in resource.enumeration loop core.save_point (file, map.chads (chad_index).resources (index)); end loop; - for index in material.enumeration loop core.save_point (file, map.chads (chad_index).materials (index)); end loop; -- for index in skill.limit loop core.io.write (file, skill.enumeration'pos (map.chads (chad_index).skills (index).index)); end loop; for index in skill.limit loop core.io.write (file, map.chads (chad_index).skills (index).value); end loop; for index in skill.limit loop core.io.write (file, map.chads (chad_index).skills (index).limit); end loop; -- + for index in material.limit loop core.io.write (file, material.enumeration'pos (map.chads (chad_index).materials (index).index)); end loop; + for index in material.limit loop core.io.write (file, map.chads (chad_index).materials (index).value); end loop; + for index in material.limit loop core.io.write (file, map.chads (chad_index).materials (index).limit); end loop; + -- for kind in equipment.kind loop core.io.write (file, equipment.enumeration'pos (map.chads (chad_index).equipments (kind))); end loop; -- - core.io.write (file, map.chads (chad_index).item_count); - -- - if map.chads (chad_index).item_count > 0 then - for index in 0 .. map.chads (chad_index).item_count - 1 loop - core.io.write (file, equipment.enumeration'pos (map.chads (chad_index).items (index))); - end loop; - end if; + --~core.io.write (file, map.chads (chad_index).item_count); + --~-- + --~if map.chads (chad_index).item_count > 0 then + --~for index in 0 .. map.chads (chad_index).item_count - 1 loop + --~core.io.write (file, equipment.enumeration'pos (map.chads (chad_index).items (index))); + --~end loop; + --~end if; end loop; -- core.io.close (file); @@ -764,23 +755,26 @@ package body world is -- for index in attribute.enumeration loop core.load_point (file, map.chads (chad_index).attributes (index)); end loop; for index in resource.enumeration loop core.load_point (file, map.chads (chad_index).resources (index)); end loop; - for index in material.enumeration loop core.load_point (file, map.chads (chad_index).materials (index)); end loop; -- for index in skill.limit loop core.io.read (file, this); map.chads (chad_index).skills (index).index := skill.enumeration'val (this); end loop; for index in skill.limit loop core.io.read (file, map.chads (chad_index).skills (index).value); end loop; for index in skill.limit loop core.io.read (file, map.chads (chad_index).skills (index).limit); end loop; -- + for index in material.limit loop core.io.read (file, this); map.chads (chad_index).materials (index).index := material.enumeration'val (this); end loop; + for index in material.limit loop core.io.read (file, map.chads (chad_index).materials (index).value); end loop; + for index in material.limit loop core.io.read (file, map.chads (chad_index).materials (index).limit); end loop; + -- for kind in equipment.kind loop core.io.read (file, this); map.chads (chad_index).equipments (kind) := equipment.enumeration'val (this); end loop; -- - core.io.read (file, map.chads (chad_index).item_count); - -- - if map.chads (chad_index).item_count > 0 then - for index in 0 .. map.chads (chad_index).item_count - 1 loop - core.io.read (file, this); map.chads (chad_index).items (index) := equipment.enumeration'val (this); - end loop; - end if; + --~core.io.read (file, map.chads (chad_index).item_count); + --~-- + --~if map.chads (chad_index).item_count > 0 then + --~for index in 0 .. map.chads (chad_index).item_count - 1 loop + --~core.io.read (file, this); map.chads (chad_index).items (index) := equipment.enumeration'val (this); + --~end loop; + --~end if; end loop; -- core.io.close (file); @@ -1235,7 +1229,16 @@ package body world is function view_chad_inventory (data : in chad.information; x, y, limit : in integer) return core.vector is begin - return (0, 0); + for index_y in 0 .. 3 loop + for index_x in 0 .. 7 loop + ui.draw_icon (data => material.icon (data.materials (8 * index_y + index_x).index), + text => material.description (data.materials (8 * index_y + index_x).index).name.all, + x => x + index_x * core.icon, + y => y + index_y * core.icon); + end loop; + end loop; + -- + return (limit, 4 * core.icon); end view_chad_inventory; ------------------------------------------------------------------------------------------ @@ -1282,7 +1285,7 @@ package body world is attribute_index : attribute.enumeration; --~skill_index : skill.enumeration; resource_index : resource.enumeration; - material_index : material.enumeration; + --~material_index : material.enumeration; begin case data.kind is when effect.idle => null; @@ -1292,7 +1295,6 @@ package body world is ui.echo ("Player " & (if data.amount < 0 then "lost" else "gained") & integer'image (abs data.amount) & " " & attribute.description (attribute_index).name.all & " attribute points."); -- - when effect.modify_skill => null; --~when effect.modify_skill => skill_index := skill.enumeration'val (data.modifier); --~player.skills (skill_index) := player.skills (skill_index) + data.amount; --~ui.echo ("Player " & (if data.amount < 0 then "lost" else "gained") & integer'image (abs data.amount) & " " @@ -1303,9 +1305,10 @@ package body world is ui.echo ("Player " & (if data.amount < 0 then "lost" else "gained") & integer'image (abs data.amount) & " " & resource.description (resource_index).name.all & " resource points."); -- - when effect.modify_material => material_index := material.enumeration'val (data.modifier); - player.materials (material_index) := player.materials (material_index) + data.amount; - ui.echo ("+" & data.amount'image & " " & material.description (material_index).name.all); + --~when effect.modify_material => material_index := material.enumeration'val (data.modifier); + --~player.materials (material_index) := player.materials (material_index) + data.amount; + --~ui.echo ("+" & data.amount'image & " " & material.description (material_index).name.all); + when others => null; end case; end; -- @@ -1344,15 +1347,15 @@ package body world is y => offset.y + (map.equipments (index).y - core.camera.y) * core.base * core.zoom, factor => core.zoom); -- - if map.equipments (index).x = core.camera.x and map.equipments (index).y = core.camera.y then - if map.chads (1).item_count < chad.item_limit and equipment_valid (map.equipments (index).index) then - map.chads (1).items (map.chads (1).item_count) := map.equipments (index).index; - -- - core.increment (map.chads (1).item_count); - -- - map.equipments (index).index := equipment.none; - end if; - end if; + --~if map.equipments (index).x = core.camera.x and map.equipments (index).y = core.camera.y then + --~if map.chads (1).item_count < chad.item_limit and equipment_valid (map.equipments (index).index) then + --~map.chads (1).items (map.chads (1).item_count) := map.equipments (index).index; + --~-- + --~core.increment (map.chads (1).item_count); + --~-- + --~map.equipments (index).index := equipment.none; + --~end if; + --~end if; end if; end loop; end draw_equipments;