xhartae/example/ada.adb

99 lines
4.3 KiB
Ada

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2023 - Ognjen 'xolatile' Milan Robovic
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Xabina is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either
-- version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
-- implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
with core;
package magic is
------------------------------------------------------------------------------------------
type list is (
ignite, illuminate, bladecharm, battlecry
);
type mark is mod 72;
------------------------------------------------------------------------------------------
type constant_type is new core.constant_type with
record
self : boolean := false;
health : integer := 0;
armour : integer := 0;
mana : integer := 0;
stamina : integer := 0;
distance : integer := 0;
tribute : natural := 0;
end record;
type variable_type is new core.variable_type with
record
enchantment : natural := 0;
end record;
type constant_list is array (list) of constant_type;
type variable_list is array (mark) of variable_type;
------------------------------------------------------------------------------------------
constant_data : constant constant_list := (
(core.magic, "Ignite ", '*', core.colour.yellow, core.effect.italic, false, -3, 0, 0, -1, 7, 1),
(core.magic, "Illuminate ", '*', core.colour.yellow, core.effect.italic, false, 0, 0, 0, -1, 13, 1),
(core.magic, "Bladecharm ", '*', core.colour.red, core.effect.italic, true, 0, -3, 0, -1, 7, 3),
(core.magic, "Battlecry ", '*', core.colour.red, core.effect.italic, true, -1, -1, 0, -1, 7, 2)
);
variable_data : variable_list;
------------------------------------------------------------------------------------------
procedure generate;
procedure render;
------------------------------------------------------------------------------------------
end magic;
with core, map;
package body magic is
------------------------------------------------------------------------------------------
procedure generate is
y : natural := 0;
x : natural := 0;
identifier : natural := 0;
begin
for this in map.mark
loop
y := core.randomize (0, natural (map.height'last));
x := core.randomize (0, natural (map.width'last));
identifier := core.randomize (0, natural (list'size));
map.variable_data (this) := (integer (y), integer (x), core.magic, identifier);
end loop;
end generate;
procedure render is
symbol : character := ' ';
colour : character := core.colour.white;
effect : character := core.effect.normal;
begin
for this in map.mark
loop
symbol := constant_data (list'val (map.variable_data (this).identifier)).symbol;
colour := constant_data (list'val (map.variable_data (this).identifier)).colour;
effect := constant_data (list'val (map.variable_data (this).identifier)).effect;
core.render_character (symbol, colour, effect, core.screen_height (map.variable_data (this).y), core.screen_width (map.variable_data (this).x));
end loop;
end render;
------------------------------------------------------------------------------------------
end magic;