Refactored other packages, lot of changes, smaller executable size...

This commit is contained in:
Ognjen Milan Robovic 2024-06-04 07:52:44 -04:00
parent 021157e4e6
commit f34f33b9a8
10 changed files with 111 additions and 115 deletions

View File

@ -4,8 +4,6 @@
with core, attribute, skill, resource, material, faction, equipment;
use core;
package chad is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ -17,11 +15,11 @@ package chad is
------------------------------------------------------------------------------------------
type definition is record
name : core.short_string;
kind : faction.enumeration;
bonus_attribute : attribute.enumeration;
bonus_skill : skill.enumeration;
bonus_resource : resource.enumeration;
name : access string;
kind : faction.enumeration;
bonus_attribute : attribute.enumeration;
bonus_skill : skill.enumeration;
bonus_resource : resource.enumeration;
end record;
item_limit : constant natural := 24;
@ -52,12 +50,12 @@ package chad is
count : constant natural := enumeration'pos (enumeration'last) + 1;
description : constant array (enumeration) of definition := (
ada => ("Ada Augusta King ", faction.fairy, attribute.defense, skill.diplomacy, resource.metal),
richard => ("Richard Martin Stallman ", faction.dwarf, attribute.offense, skill.leadership, resource.wood),
ognjen => ("Ognjen Milan Robovic ", faction.kobold, attribute.stamina, skill.archery, resource.leather),
wouter => ("Wouter van Oortmerssen ", faction.gnoll, attribute.speed, skill.medicine, resource.stone),
john => ("John Warner Backus ", faction.goblin, attribute.wisdom, skill.sorcery, resource.gem),
marina => ("Marina Ann Hantzis ", faction.imp, attribute.reach, skill.necromancy, resource.gold)
ada => (new string' ("Ada Augusta King"), faction.fairy, attribute.defense, skill.diplomacy, resource.metal),
richard => (new string' ("Richard Martin Stallman"), faction.dwarf, attribute.offense, skill.leadership, resource.wood),
ognjen => (new string' ("Ognjen Milan Robovic"), faction.kobold, attribute.stamina, skill.archery, resource.leather),
wouter => (new string' ("Wouter van Oortmerssen"), faction.gnoll, attribute.speed, skill.medicine, resource.stone),
john => (new string' ("John Warner Backus"), faction.goblin, attribute.wisdom, skill.sorcery, resource.gem),
marina => (new string' ("Marina Ann Hantzis"), faction.imp, attribute.reach, skill.necromancy, resource.gold)
);
view_width : constant integer := 64;

View File

@ -4,8 +4,6 @@
with core, effect, resource, faction;
use core;
package construction is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ -17,11 +15,11 @@ package construction is
------------------------------------------------------------------------------------------
type definition is record
name : core.unstring;
kind : faction.enumeration;
price : resource.price;
frames : integer;
evoke : effect.information;
name : access string;
kind : faction.enumeration;
price : resource.price;
frames : natural;
evoke : effect.information;
end record;
------------------------------------------------------------------------------------------
@ -29,12 +27,12 @@ package construction is
count : constant natural := enumeration'pos (enumeration'last) + 1;
description : constant array (enumeration) of definition := (
house => (+("Dwarf House"), faction.dwarf, (others => 0), 1, effect.none),
cottage => (+("Fairy Cottage"), faction.fairy, (others => 0), 1, effect.none),
shack => (+("Gnoll Shack"), faction.gnoll, (others => 0), 1, effect.none),
homestead => (+("Kobold Homestead"), faction.kobold, (others => 0), 1, effect.none),
hut => (+("Goblin Hut"), faction.goblin, (others => 0), 1, effect.none),
den => (+("Imp Den"), faction.imp, (others => 0), 1, effect.none)
house => (new string' ("Dwarf House"), faction.dwarf, (others => 0), 1, effect.none),
cottage => (new string' ("Fairy Cottage"), faction.fairy, (others => 0), 1, effect.none),
shack => (new string' ("Gnoll Shack"), faction.gnoll, (others => 0), 1, effect.none),
homestead => (new string' ("Kobold Homestead"), faction.kobold, (others => 0), 1, effect.none),
hut => (new string' ("Goblin Hut"), faction.goblin, (others => 0), 1, effect.none),
den => (new string' ("Imp Den"), faction.imp, (others => 0), 1, effect.none)
);
sprite : array (enumeration) of core.sprite;

View File

@ -16,12 +16,12 @@ package deity is
------------------------------------------------------------------------------------------
type definition is record
name : core.short_string;
favor : integer;
loved_faction : faction.enumeration;
bonus_attribute : attribute.enumeration;
bonus_skill : skill.enumeration;
bonus_resource : resource.enumeration;
name : access string;
favor : integer;
loved_faction : faction.enumeration;
bonus_attribute : attribute.enumeration;
bonus_skill : skill.enumeration;
bonus_resource : resource.enumeration;
end record;
------------------------------------------------------------------------------------------
@ -29,16 +29,16 @@ package deity is
count : constant natural := enumeration'pos (enumeration'last) + 1;
description : constant array (enumeration) of definition := (
AEZORA => ("Aezora ", 0, faction.fairy, attribute.offense, skill.archery, resource.gold),
MITENA => ("Mitena ", 0, faction.dwarf, attribute.offense, skill.archery, resource.gold),
SHEILA => ("Sheila ", 0, faction.gnoll, attribute.offense, skill.archery, resource.gold),
ILIONA => ("Iliona ", 0, faction.kobold, attribute.offense, skill.archery, resource.gold),
ULDRAE => ("Uldrae ", 0, faction.goblin, attribute.offense, skill.archery, resource.gold),
KANAKO => ("Kanako ", 0, faction.imp, attribute.offense, skill.archery, resource.gold),
HENEAL => ("Heneal ", 0, faction.human, attribute.offense, skill.archery, resource.gold),
EVELOR => ("Evelor ", 0, faction.elf, attribute.offense, skill.archery, resource.gold),
OROHAN => ("Orohan ", 0, faction.orc, attribute.offense, skill.archery, resource.gold),
XORANA => ("Xorana ", 0, faction.neutral, attribute.offense, skill.archery, resource.gold)
AEZORA => (new string' ("Aezora"), 0, faction.fairy, attribute.offense, skill.archery, resource.gold),
MITENA => (new string' ("Mitena"), 0, faction.dwarf, attribute.offense, skill.archery, resource.gold),
SHEILA => (new string' ("Sheila"), 0, faction.gnoll, attribute.offense, skill.archery, resource.gold),
ILIONA => (new string' ("Iliona"), 0, faction.kobold, attribute.offense, skill.archery, resource.gold),
ULDRAE => (new string' ("Uldrae"), 0, faction.goblin, attribute.offense, skill.archery, resource.gold),
KANAKO => (new string' ("Kanako"), 0, faction.imp, attribute.offense, skill.archery, resource.gold),
HENEAL => (new string' ("Heneal"), 0, faction.human, attribute.offense, skill.archery, resource.gold),
EVELOR => (new string' ("Evelor"), 0, faction.elf, attribute.offense, skill.archery, resource.gold),
OROHAN => (new string' ("Orohan"), 0, faction.orc, attribute.offense, skill.archery, resource.gold),
XORANA => (new string' ("Xorana"), 0, faction.neutral, attribute.offense, skill.archery, resource.gold)
);
sprite : array (enumeration) of core.sprite;

View File

@ -16,10 +16,10 @@ package faction is
------------------------------------------------------------------------------------------
type definition is record
name : core.short_string;
bonus_attribute : attribute.enumeration;
bonus_skill : skill.enumeration;
bonus_resource : resource.enumeration;
name : access string;
bonus_attribute : attribute.enumeration;
bonus_skill : skill.enumeration;
bonus_resource : resource.enumeration;
end record;
------------------------------------------------------------------------------------------
@ -27,16 +27,16 @@ package faction is
count : constant natural := enumeration'pos (enumeration'last) + 1;
description : constant array (enumeration) of definition := (
fairy => ("Fairy Kingdom ", attribute.speed, skill.mysticism, resource.gold),
dwarf => ("Dwarf Kingdom ", attribute.defense, skill.estates, resource.stone),
gnoll => ("Gnoll Kingdom ", attribute.stamina, skill.logistics, resource.leather),
kobold => ("Kobold Kingdom ", attribute.offense, skill.tactics, resource.metal),
goblin => ("Goblin Kingdom ", attribute.reach, skill.exploration, resource.wood),
imp => ("Imp Kingdom ", attribute.wisdom, skill.sorcery, resource.gem),
human => ("Fallen Human Empire ", attribute.wisdom, skill.estates, resource.gold),
elf => ("Fallen Elf Empire ", attribute.wisdom, skill.estates, resource.gold),
orc => ("Fallen Orc Empire ", attribute.wisdom, skill.estates, resource.gold),
neutral => ("Neutral ", attribute.offense, skill.archery, resource.gold)
fairy => (new string' ("Fairy Kingdom"), attribute.speed, skill.mysticism, resource.gold),
dwarf => (new string' ("Dwarf Kingdom"), attribute.defense, skill.estates, resource.stone),
gnoll => (new string' ("Gnoll Kingdom"), attribute.stamina, skill.logistics, resource.leather),
kobold => (new string' ("Kobold Kingdom"), attribute.offense, skill.tactics, resource.metal),
goblin => (new string' ("Goblin Kingdom"), attribute.reach, skill.exploration, resource.wood),
imp => (new string' ("Imp Kingdom"), attribute.wisdom, skill.sorcery, resource.gem),
human => (new string' ("Fallen Human Empire"), attribute.wisdom, skill.estates, resource.gold),
elf => (new string' ("Fallen Elf Empire"), attribute.wisdom, skill.estates, resource.gold),
orc => (new string' ("Fallen Orc Empire"), attribute.wisdom, skill.estates, resource.gold),
neutral => (new string' ("Neutral"), attribute.offense, skill.archery, resource.gold)
);
sprite : array (enumeration) of core.sprite;

View File

@ -32,11 +32,11 @@ package magic is
subtype level_limit is natural range 0 .. 6;
type definition is record
name : core.short_string;
kind : school;
level : level_limit;
evoke : effect.information;
text : core.long_string;
name : access string;
kind : school;
level : level_limit;
evoke : effect.information;
text : access string;
end record;
------------------------------------------------------------------------------------------
@ -44,12 +44,12 @@ package magic is
count : constant natural := enumeration'pos (enumeration'last) + 1;
description : constant array (enumeration) of definition := (
arrow_storm => ("Arrow Storm ", air, 1, effect.none, "Arrow Storm increases the range of your ranged units. "),
torment => ("Torment ", dark, 1, effect.none, "Torment causes targeted friend or foe to feel pain and shit. "),
stone_armour => ("Stone Armour ", earth, 1, effect.none, "Stone Armour increases defense of selected unit. "),
fireball => ("Fireball ", fire, 1, effect.none, "Fireball conjures a literal ball of fire that flies go brr. "),
heal => ("Heal ", light, 1, effect.none, "Heal does what it says it will do, keeps the promise. "),
ice_armour => ("Ice Armour ", water, 1, effect.none, "Ice Armour increases defense and stamina of selected unit. ")
arrow_storm => (new string' ("Arrow Storm"), air, 1, effect.none, new string' ("Arrow Storm increases the range of your ranged units.")),
torment => (new string' ("Torment"), dark, 1, effect.none, new string' ("Torment causes targeted friend or foe to feel pain and shit.")),
stone_armour => (new string' ("Stone Armour"), earth, 1, effect.none, new string' ("Stone Armour increases defense of selected unit.")),
fireball => (new string' ("Fireball"), fire, 1, effect.none, new string' ("Fireball conjures a literal ball of fire that flies go brr.")),
heal => (new string' ("Heal"), light, 1, effect.none, new string' ("Heal does what it says it will do, keeps the promise.")),
ice_armour => (new string' ("Ice Armour"), water, 1, effect.none, new string' ("Ice Armour increases defense and stamina of selected unit."))
);
view_width : constant natural := 64;

View File

@ -9,7 +9,9 @@ with core, ui, effect, attribute, skill, resource, faction, deity, material, mag
with ada.strings.unbounded;
use ada.strings.unbounded;
use core;
use type core.cursor_code;
use type core.signal_code;
use type core.point;
procedure main is
@ -354,7 +356,7 @@ begin
begin
ui.draw_frame ("--", x, y, 360 + 2 * 8, 96 + 2 * 8);
--
ui.draw_sprite (chad.view (player.index), chad.description (player.index).name, x + 8, y + 8, 0);
ui.draw_sprite (chad.view (player.index), chad.description (player.index).name.all, x + 8, y + 8, 0);
--
ui.draw_tiny_fill_bar (x + chad.view_width + 2 * 8, y + 1 * core.icon + 8, 360 - chad.view_width - 8, float (player.health.value) / float (player.health.limit), (127, 0, 0, 255));
ui.draw_tiny_fill_bar (x + chad.view_width + 2 * 8, y + 2 * core.icon + 8, 360 - chad.view_width - 8, float (player.mana.value) / float (player.mana.limit), (0, 0, 127, 255));
@ -408,10 +410,10 @@ begin
move_y := y + 96 + 5 * 8 + 6 * core.icon;
end if;
--
ui.draw_icon (skill.icon (index), -(skill.description (index).text), move_x, move_y);
ui.draw_icon (skill.icon (index), skill.description (index).text.all, move_x, move_y);
ui.draw_text_box (move_x + core.icon, move_y, core.icon, core.icon);
ui.write (player.skills (index).value'image, move_x + core.icon, move_y + 8, (others => 255), 15, true);
ui.write (-(skill.description (index).name), move_x + 2 * core.icon + 4, move_y + 8, (others => 255), 15, true);
ui.write (skill.description (index).name.all, move_x + 2 * core.icon + 4, move_y + 8, (others => 255), 15, true);
--
move_y := move_y + core.icon;
end loop;
@ -452,8 +454,8 @@ begin
end loop;
--
for index in resource.enumeration loop
ui.draw_icon (resource.icon (index), -(resource.description (index).text), (preview_width - 6 * core.icon * resource.count) / 2 + (6 * core.icon) * resource.enumeration'pos (index), core.base);
ui.draw_frame (-(resource.description (index).text), (preview_width - 6 * core.icon * resource.count) / 2 + (6 * core.icon) * resource.enumeration'pos (index) + core.icon, core.base, 6 * core.icon, core.icon);
ui.draw_icon (resource.icon (index), resource.description (index).text.all, (preview_width - 6 * core.icon * resource.count) / 2 + (6 * core.icon) * resource.enumeration'pos (index), core.base);
ui.draw_frame (resource.description (index).text.all, (preview_width - 6 * core.icon * resource.count) / 2 + (6 * core.icon) * resource.enumeration'pos (index) + core.icon, core.base, 6 * core.icon, core.icon);
--
ui.write (text => world.map.chads (1).resources (index).value'image & " /" & world.map.chads (1).resources (index).limit'image,
x => (preview_width - 6 * core.icon * resource.count) / 2 + (6 * core.icon) * resource.enumeration'pos (index) + core.icon - 1,

View File

@ -3,7 +3,6 @@
-- GNU General Public Licence (version 3 or later)
with core;
use core;
package resource is
@ -16,9 +15,9 @@ package resource is
------------------------------------------------------------------------------------------
type definition is record
base : core.point;
name : core.unstring;
text : core.unstring;
base : core.point;
name : access string;
text : access string;
end record;
type points is array (enumeration) of core.point;
@ -29,12 +28,12 @@ package resource is
count : constant natural := enumeration'pos (enumeration'last) + 1;
description : constant array (enumeration) of definition := (
gold => ((24, 480), +("Gold"), +("Gold is precious yellowish shiny metal, valued since ancient times.")),
wood => ((12, 240), +("Wood"), +("Wood is just bundle of lignin and cellulose, nothing more.")),
stone => ((12, 240), +("Stone"), +("Stone is essential building block for most constructions in this world.")),
metal => ((12, 240), +("Metal"), +("Metal as a resource is mixture of commonly found metalic elements.")),
leather => ((12, 240), +("Leather"), +("Leather is general purpose resource, used for armours and decorations.")),
gem => ((12, 240), +("Gem"), +("Gem as a resource is same as metal, just mixture of various gems."))
gold => ((24, 480), new string' ("Gold"), new string' ("Gold is precious yellowish shiny metal, valued since ancient times.")),
wood => ((12, 240), new string' ("Wood"), new string' ("Wood is just bundle of lignin and cellulose, nothing more.")),
stone => ((12, 240), new string' ("Stone"), new string' ("Stone is essential building block for most constructions in this world.")),
metal => ((12, 240), new string' ("Metal"), new string' ("Metal as a resource is mixture of commonly found metalic elements.")),
leather => ((12, 240), new string' ("Leather"), new string' ("Leather is general purpose resource, used for armours and decorations.")),
gem => ((12, 240), new string' ("Gem"), new string' ("Gem as a resource is same as metal, just mixture of various gems."))
);
icon : array (enumeration) of core.sprite;

View File

@ -3,7 +3,6 @@
-- GNU General Public Licence (version 3 or later)
with core;
use core;
package skill is
@ -18,9 +17,9 @@ package skill is
------------------------------------------------------------------------------------------
type definition is record
base : core.point;
name : core.unstring;
text : core.unstring;
base : core.point;
name : access string;
text : access string;
end record;
type points is array (enumeration) of core.point;
@ -33,24 +32,24 @@ package skill is
default : constant points := (others => (0, 24));
description : constant array (enumeration) of definition := (
alchemy => ((0, 24), +("Alchemy"), +("Alchemy skill determines effectiveness of your vials and potions.")),
archery => ((0, 24), +("Archery"), +("Archery skill determines effectiveness and range or your archers.")),
architecture => ((0, 24), +("Architecture"), +("Architecture decreases time spent on building constructions.")),
athletics => ((0, 24), +("Athletics"), +("Athletics increases movement speed of all your units, since they train.")),
diplomacy => ((0, 24), +("Diplomacy"), +("Diplomacy helps you to avoid starting a battle you can't win.")),
estates => ((0, 24), +("Estates"), +("Estates makes you the ultimate crypto-bro, establishing a blockchain.")),
exploration => ((0, 24), +("Exploration"), +("Exploration is quite self-explanatory by its' name, seriously.")),
leadership => ((0, 24), +("Leadership"), +("Leadership is the default skill for any true chad, like God intended.")),
logistics => ((0, 24), +("Logistics"), +("Logistics is a nightmare in real life, but this is only a game.")),
medicine => ((0, 24), +("Medicine"), +("Medicine skill makes you swallow pills like a kid in a drugstore.")),
mercantile => ((0, 24), +("Mercantile"), +("Mercantile is the skill of any true-born nosy person, otherwise useless.")),
mysticism => ((0, 24), +("Mysticism"), +("Mysticism allows you to have 60 cats, drink wine and talk weird.")),
necromancy => ((0, 24), +("Necromancy"), +("Necromancy lets you not to waste the bones after every battle.")),
resistance => ((0, 24), +("Resistence"), +("Resistence skill increases defense points of all your units slightly.")),
skirmish => ((0, 24), +("Skirmish"), +("Skirmish makes your units go berserk when they have little health left.")),
sorcery => ((0, 24), +("Sorcery"), +("Sorcery skill is appropriately named useless skill to have in real life.")),
tactics => ((0, 24), +("Tactics"), +("Tactics is the opposite of skirmish, master it and lose in every battle.")),
thaumaturgy => ((0, 24), +("Thaumaturgy"), +("Thaumaturgy lets you do nothing, and hope that the best will happen."))
alchemy => ((0, 24), new string' ("Alchemy"), new string' ("Alchemy skill determines effectiveness of your vials and potions.")),
archery => ((0, 24), new string' ("Archery"), new string' ("Archery skill determines effectiveness and range or your archers.")),
architecture => ((0, 24), new string' ("Architecture"), new string' ("Architecture decreases time spent on building constructions.")),
athletics => ((0, 24), new string' ("Athletics"), new string' ("Athletics increases movement speed of all your units, since they train.")),
diplomacy => ((0, 24), new string' ("Diplomacy"), new string' ("Diplomacy helps you to avoid starting a battle you can't win.")),
estates => ((0, 24), new string' ("Estates"), new string' ("Estates makes you the ultimate crypto-bro, establishing a blockchain.")),
exploration => ((0, 24), new string' ("Exploration"), new string' ("Exploration is quite self-explanatory by its' name, seriously.")),
leadership => ((0, 24), new string' ("Leadership"), new string' ("Leadership is the default skill for any true chad, like God intended.")),
logistics => ((0, 24), new string' ("Logistics"), new string' ("Logistics is a nightmare in real life, but this is only a game.")),
medicine => ((0, 24), new string' ("Medicine"), new string' ("Medicine skill makes you swallow pills like a kid in a drugstore.")),
mercantile => ((0, 24), new string' ("Mercantile"), new string' ("Mercantile is the skill of any true-born nosy person, otherwise useless.")),
mysticism => ((0, 24), new string' ("Mysticism"), new string' ("Mysticism allows you to have 60 cats, drink wine and talk weird.")),
necromancy => ((0, 24), new string' ("Necromancy"), new string' ("Necromancy lets you not to waste the bones after every battle.")),
resistance => ((0, 24), new string' ("Resistence"), new string' ("Resistence skill increases defense points of all your units slightly.")),
skirmish => ((0, 24), new string' ("Skirmish"), new string' ("Skirmish makes your units go berserk when they have little health left.")),
sorcery => ((0, 24), new string' ("Sorcery"), new string' ("Sorcery skill is appropriately named useless skill to have in real life.")),
tactics => ((0, 24), new string' ("Tactics"), new string' ("Tactics is the opposite of skirmish, master it and lose in every battle.")),
thaumaturgy => ((0, 24), new string' ("Thaumaturgy"), new string' ("Thaumaturgy lets you do nothing, and hope that the best will happen."))
);
icon : array (enumeration) of core.sprite;

View File

@ -7,6 +7,9 @@ with core;
with ada.strings.unbounded;
use type core.cursor_code;
use type core.signal_code;
use type core.point;
use type ada.strings.unbounded.unbounded_string;
package body ui is
@ -237,7 +240,6 @@ package body ui is
------------------------------------------------------------------------------------------
procedure synchronize is
use core;
begin
prioritize := false;
--

View File

@ -4,11 +4,9 @@
with core, ui, attribute, skill, resource, equipment, unit, construction, chad, effect;
use core;
--~use type core.cursor_code;
--~use type core.signal_code;
--~use type core.point;
use type core.cursor_code;
use type core.signal_code;
use type core.point;
package body world is
@ -133,7 +131,7 @@ package body world is
end loop;
end loop;
--
if target /= (-1, -1) then
if target.x /= -1 and target.y /= -1 then
step := core.camera;
hits := 0;
--
@ -310,12 +308,12 @@ package body world is
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.");
& skill.description (skill_index).name.all & " 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.");
& resource.description (resource_index).name.all & " resource points.");
--
when effect.modify_material => material_index := material.enumeration'val (data.modifier);
player.materials (material_index) := player.materials (material_index) + data.amount;
@ -354,7 +352,7 @@ package body world is
if core.cursor_inside (x, y, construction.sprite (this).width, construction.sprite (this).height)
and core.cursor_mode = core.cursor_middle
and not ui.prioritize then
core.write_text_box (-(construction.description (this).name));
core.write_text_box (construction.description (this).name.all);
end if;
--
core.increment (drawn_constructions);