2024-05-19 11:32:19 -04:00
|
|
|
-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
|
|
|
|
--
|
|
|
|
-- GNU General Public Licence (version 3 or later)
|
|
|
|
|
2024-05-31 07:14:00 -04:00
|
|
|
with core, ui, attribute, skill, resource, material, chad, world;
|
2024-05-19 11:32:19 -04:00
|
|
|
|
2024-05-23 03:34:45 -04:00
|
|
|
use type core.point;
|
|
|
|
|
2024-05-19 11:32:19 -04:00
|
|
|
package body effect is
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure apply (data : in value) is
|
2024-05-31 07:14:00 -04:00
|
|
|
player : chad.value renames world.map.chads (1);
|
|
|
|
--
|
|
|
|
attribute_index : attribute.enumeration;
|
|
|
|
skill_index : skill.enumeration;
|
|
|
|
resource_index : resource.enumeration;
|
|
|
|
material_index : material.enumeration;
|
2024-05-19 11:32:19 -04:00
|
|
|
begin
|
2024-05-31 07:14:00 -04:00
|
|
|
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) & " "
|
|
|
|
& core.bound (attribute.trait (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) & " "
|
|
|
|
& core.bound (skill.trait (skill_index).name) & " skill points.");
|
2024-05-28 06:08:45 -04:00
|
|
|
--
|
2024-05-31 07:14:00 -04:00
|
|
|
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) & " "
|
|
|
|
& core.bound (resource.trait (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 & " " & core.bound (material.trait (material_index).name));
|
2024-05-19 11:32:19 -04:00
|
|
|
end case;
|
|
|
|
end apply;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
end effect;
|