48 lines
2.5 KiB
Ada
48 lines
2.5 KiB
Ada
-- 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 type core.point;
|
|
|
|
package body effect is
|
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
procedure apply (data : in value) is
|
|
player : chad.value 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) & " "
|
|
& core.bound (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) & " "
|
|
& core.bound (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) & " "
|
|
& core.bound (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 & " " & core.bound (material.description (material_index).name));
|
|
end case;
|
|
end apply;
|
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
end effect;
|