Finished item pick-ups and inventory...

This commit is contained in:
Ognjen Milan Robovic 2024-05-17 20:02:37 -04:00
parent bcbc66d8e1
commit 5e1aad287e
4 changed files with 27 additions and 5 deletions

View File

@ -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;
--

View File

@ -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;

View File

@ -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;

View File

@ -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;