From 5e1aad287e5cf5536abe9a167766025761f70cbe Mon Sep 17 00:00:00 2001 From: xolatile Date: Fri, 17 May 2024 20:02:37 -0400 Subject: [PATCH] Finished item pick-ups and inventory... --- source/chad.adb | 2 +- source/equipment.adb | 19 ++++++++++++++++++- source/equipment.ads | 2 ++ source/world.adb | 9 ++++++--- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/source/chad.adb b/source/chad.adb index 991b498..8754bec 100644 --- a/source/chad.adb +++ b/source/chad.adb @@ -108,7 +108,7 @@ package body chad is function take_equipment_item (player : in out data; item : in equipment.enumeration) return boolean is begin - if player.item_count = item_limit - 1 then + if player.item_count = item_limit or not equipment.exist (item) then return false; end if; -- diff --git a/source/equipment.adb b/source/equipment.adb index d22d992..6ab12da 100644 --- a/source/equipment.adb +++ b/source/equipment.adb @@ -8,6 +8,13 @@ package body equipment is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + function "/" (a, b : in enumeration) return boolean is + begin + return natural (enumeration'pos (a)) /= natural (enumeration'pos (b)); + end "/"; + + ------------------------------------------------------------------------------------------ + procedure configure is begin core.echo (core.comment, "Configuring equipment components..."); @@ -39,7 +46,10 @@ package body equipment is begin draw (index, state, x, y); -- - if core.cursor_inside (x, y, sprite (index).width, sprite (index).height) and core.cursor_mode = 2 and not ui.prioritize then + if core.cursor_inside (x, y, sprite (index).width, sprite (index).height) + and core.cursor_mode = 2 + and index / none + and not ui.prioritize then core.write_text_box (trait (index).name); end if; end draw_plus; @@ -51,6 +61,13 @@ package body equipment is --~core.draw (icon_sprite (index), x, y, factor => 1); --~end draw_icon; + ------------------------------------------------------------------------------------------ + + function exist (index : in enumeration) return boolean is + begin + return index / none; + end exist; + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ end equipment; diff --git a/source/equipment.ads b/source/equipment.ads index afa2400..b915ba6 100644 --- a/source/equipment.ads +++ b/source/equipment.ads @@ -206,6 +206,8 @@ package equipment is procedure draw_plus (index : in enumeration; state : in core.animation; x, y : in integer); --~procedure draw_icon (index : in enumeration; x, y : in integer); + function exist (index : in enumeration) return boolean; + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ end equipment; diff --git a/source/world.adb b/source/world.adb index 7712007..cb6ba2a 100644 --- a/source/world.adb +++ b/source/world.adb @@ -239,9 +239,12 @@ package body world is 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.chad_data (1), equipment.enumeration'val (map.equipments (index).index)) then - core.echo (core.comment, "Took item: " & equipment.trait (equipment.enumeration'val (map.equipments (index).index)).name); - else - core.echo (core.warning, "Nope item: " & equipment.trait (equipment.enumeration'val (map.equipments (index).index)).name); + --~core.echo (core.comment, "Took item: " & equipment.trait (equipment.enumeration'val (map.equipments (index).index)).name); + -- + map.equipments (index).index := equipment.enumeration'pos (equipment.none); + --~map.equipments (index).index := 0; + --~else + --~core.echo (core.warning, "Nope item: " & equipment.trait (equipment.enumeration'val (map.equipments (index).index)).name); end if; end if; end loop;