Refactored Effect package...
This commit is contained in:
parent
7c353ee9ea
commit
712acf8d8c
@ -1,47 +0,0 @@
|
||||
-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
|
||||
--
|
||||
-- GNU General Public Licence (version 3 or later)
|
||||
|
||||
with core, ui, attribute, skill, resource, material, chad, world;
|
||||
|
||||
use core;
|
||||
|
||||
package body effect is
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
procedure apply (data : in information) is
|
||||
player : chad.information renames world.map.chads (1);
|
||||
--
|
||||
attribute_index : attribute.enumeration;
|
||||
skill_index : skill.enumeration;
|
||||
resource_index : resource.enumeration;
|
||||
material_index : material.enumeration;
|
||||
begin
|
||||
case data.kind is
|
||||
when idle => null;
|
||||
--
|
||||
when modify_attribute => attribute_index := attribute.enumeration'val (data.modifier);
|
||||
player.attributes (attribute_index) := player.attributes (attribute_index) + data.amount;
|
||||
ui.echo ("Player " & (if data.amount < 0 then "lost" else "gained") & integer'image (abs data.amount) & " "
|
||||
& (-(attribute.description (attribute_index).name)) & " attribute points.");
|
||||
--
|
||||
when 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) & " "
|
||||
& (-(skill.description (skill_index).name)) & " skill points.");
|
||||
--
|
||||
when modify_resource => resource_index := resource.enumeration'val (data.modifier);
|
||||
player.resources (resource_index) := player.resources (resource_index) + data.amount;
|
||||
ui.echo ("Player " & (if data.amount < 0 then "lost" else "gained") & integer'image (abs data.amount) & " "
|
||||
& (-(resource.description (resource_index).name)) & " resource points.");
|
||||
--
|
||||
when 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)));
|
||||
end case;
|
||||
end apply;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
end effect;
|
@ -26,10 +26,6 @@ package effect is
|
||||
|
||||
none : constant information := (idle, 0, 0, false, 0);
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure apply (data : in information);
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
end effect;
|
||||
|
@ -286,7 +286,39 @@ package body world is
|
||||
and map.locations (index).state = 0
|
||||
and core.signal_code'pos (core.signal_mode) = core.signal_code'pos (core.signal_e)
|
||||
and not ui.prioritize then
|
||||
effect.apply (location_description (location_index'val (map.locations (index).index)).evoke);
|
||||
--~effect.apply ();
|
||||
declare player : chad.information renames world.map.chads (1);
|
||||
--
|
||||
data : effect.information := location_description (location_index'val (map.locations (index).index)).evoke;
|
||||
--
|
||||
attribute_index : attribute.enumeration;
|
||||
skill_index : skill.enumeration;
|
||||
resource_index : resource.enumeration;
|
||||
material_index : material.enumeration;
|
||||
begin
|
||||
case data.kind is
|
||||
when effect.idle => null;
|
||||
--
|
||||
when effect.modify_attribute => attribute_index := attribute.enumeration'val (data.modifier);
|
||||
player.attributes (attribute_index) := player.attributes (attribute_index) + data.amount;
|
||||
ui.echo ("Player " & (if data.amount < 0 then "lost" else "gained") & integer'image (abs data.amount) & " "
|
||||
& (-(attribute.description (attribute_index).name)) & " attribute points.");
|
||||
--
|
||||
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) & " "
|
||||
& (-(skill.description (skill_index).name)) & " skill points.");
|
||||
--
|
||||
when effect.modify_resource => resource_index := resource.enumeration'val (data.modifier);
|
||||
player.resources (resource_index) := player.resources (resource_index) + data.amount;
|
||||
ui.echo ("Player " & (if data.amount < 0 then "lost" else "gained") & integer'image (abs data.amount) & " "
|
||||
& (-(resource.description (resource_index).name)) & " 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)));
|
||||
end case;
|
||||
end;
|
||||
--
|
||||
map.locations (index).state := 1;
|
||||
end if;
|
||||
|
Loading…
Reference in New Issue
Block a user