xhads/source/effect.adb

48 lines
2.5 KiB
Ada
Raw Normal View History

-- 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;
use type core.point;
package body effect is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
procedure apply (data : in information) is
player : chad.information renames world.map.chads (1);
2024-05-31 07:14:00 -04:00
--
attribute_index : attribute.enumeration;
skill_index : skill.enumeration;
resource_index : resource.enumeration;
material_index : material.enumeration;
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.description (attribute_index).name) & " attribute points.");
2024-05-31 07:14:00 -04:00
--
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.");
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.description (resource_index).name) & " resource points.");
2024-05-31 07:14:00 -04:00
--
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;