Joking around...
This commit is contained in:
parent
f618b0ddef
commit
9934e634e9
145
xabina.adb
145
xabina.adb
@ -1,8 +1,8 @@
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Copyright (c) 2023 - Ognjen 'xolatile' Milan Robovic
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- This program 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 2 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
|
||||
-- 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.
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Experimental minimal terminal rogue-like game in Ada programming language. I used to write a lot of Ada programs some time ago, then went in full C and assembly mode, and came
|
||||
@ -13,8 +13,8 @@
|
||||
with ada.text_io, ada.strings.unbounded;
|
||||
use ada.text_io, ada.strings.unbounded;
|
||||
|
||||
--~ TODO: Do not use this command below, it's for real-time game...
|
||||
--~ TODO: gnatmake xabina.adb && stty raw -echo && ./xabina && reset
|
||||
-- Do not use this command below, it's for real-time game...
|
||||
-- $ gnatmake xabina.adb && stty raw -echo && ./xabina && reset
|
||||
|
||||
function xabina return integer is
|
||||
|
||||
@ -34,29 +34,62 @@ function xabina return integer is
|
||||
maximum : natural := 0;
|
||||
end record;
|
||||
|
||||
type colour_id is (
|
||||
type colours is (
|
||||
COLOUR_GREY, COLOUR_RED, COLOUR_GREEN, COLOUR_YELLOW, COLOUR_BLUE, COLOUR_PINK, COLOUR_CYAN, COLOUR_WHITE
|
||||
);
|
||||
|
||||
type effect_id is (
|
||||
type effects is (
|
||||
EFFECT_NORMAL, EFFECT_BOLD, EFFECT_ITALIC, EFFECT_UNDERLINE, EFFECT_BLINK, EFFECT_REVERSE
|
||||
);
|
||||
|
||||
function render_character ( -- A joke function...
|
||||
symbol : character := ' ';
|
||||
colour : colours := COLOUR_WHITE;
|
||||
effect : effects := EFFECT_NORMAL
|
||||
) return natural is
|
||||
begin
|
||||
put (character'val (27) & "[");
|
||||
case effect is
|
||||
when EFFECT_NORMAL => put ("0");
|
||||
when EFFECT_BOLD => put ("1");
|
||||
when EFFECT_ITALIC => put ("3");
|
||||
when EFFECT_UNDERLINE => put ("4");
|
||||
when EFFECT_BLINK => put ("5");
|
||||
when EFFECT_REVERSE => put ("7");
|
||||
end case;
|
||||
put (";3");
|
||||
case colour is
|
||||
when COLOUR_GREY => put ("0");
|
||||
when COLOUR_RED => put ("1");
|
||||
when COLOUR_GREEN => put ("2");
|
||||
when COLOUR_YELLOW => put ("3");
|
||||
when COLOUR_BLUE => put ("4");
|
||||
when COLOUR_PINK => put ("5");
|
||||
when COLOUR_CYAN => put ("6");
|
||||
when COLOUR_WHITE => put ("7");
|
||||
end case;
|
||||
put ("m");
|
||||
put (symbol);
|
||||
put (character'val (27) & "[0m");
|
||||
return 1;
|
||||
end render_character;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Entity
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
type entity_id is (
|
||||
ENTITY_NONE, ENTITY_MENU, ENTITY_MAP, ENTITY_ITEM, ENTITY_PLANT, ENTITY_ANIMAL, ENTITY_GOBLIN, ENTITY_PLAYER
|
||||
type entities is (
|
||||
ENTITY_NONE, ENTITY_MENU, ENTITY_MAP, ENTITY_ITEM, ENTITY_PLANT, ENTITY_ANIMAL, ENTITY_GOBLIN, ENTITY_PLAYER,
|
||||
ENTITY_SPELL, ENTITY_AMMUNITION, ENTITY_WEAPON, ENTITY_ARMOUR, ENTITY_SCROLL, ENTITY_POTION, ENTITY_CONSUMABLE, ENTITY_NOTE
|
||||
);
|
||||
|
||||
type entity_constant_type is tagged
|
||||
record
|
||||
entity : entity_id := ENTITY_NONE; -- Entity identifier.
|
||||
entity : entities := ENTITY_NONE; -- Entity identifier.
|
||||
name : unbounded_string := null_unbounded_string; -- Entity general name.
|
||||
code : character := ' '; -- Entity ASCII character representation.
|
||||
colour : colour_id := COLOUR_WHITE; -- Entity VT100 escape sequence colour.
|
||||
effect : effect_id := EFFECT_NORMAL; -- Entity VT100 escape sequence effect.
|
||||
symbol : character := ' '; -- Entity ASCII character representation.
|
||||
colour : colours := COLOUR_WHITE; -- Entity VT100 escape sequence colour.
|
||||
effect : effects := EFFECT_NORMAL; -- Entity VT100 escape sequence effect.
|
||||
end record;
|
||||
|
||||
type entity_variable_type is tagged
|
||||
@ -70,102 +103,93 @@ function xabina return integer is
|
||||
-- -- Map data is only constant, not variable, since X and Y coordinates are determined by player, camera or global position.
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
type map_id is (
|
||||
MAP_NONE, MAP_VOID, MAP_WALL, MAP_FLOOR, MAP_HOLE, MAP_STAIRS_DOWN, MAP_STAIRS_UP, MAP_DOOR
|
||||
);
|
||||
|
||||
type map_list_id is (
|
||||
type map_list is (
|
||||
STONE_WALL, WOODEN_WALL, STONE_FLOOR, WOODEN_FLOOR
|
||||
);
|
||||
|
||||
type map_constant_type is new entity_constant_type with
|
||||
record
|
||||
map : map_id := MAP_NONE;
|
||||
trigger : natural := 0;
|
||||
collide : boolean := false;
|
||||
end record;
|
||||
|
||||
type map_constant_list is array (map_list_id) of map_constant_type;
|
||||
type map_constant_list is array (map_list) of map_constant_type;
|
||||
|
||||
map_data : constant map_constant_list := (
|
||||
(ENTITY_MAP, to_unbounded_string ("Stone Wall"), '#', COLOUR_GREY, EFFECT_BOLD, MAP_WALL, 0),
|
||||
(ENTITY_MAP, to_unbounded_string ("Wooden Wall"), '#', COLOUR_YELLOW, EFFECT_NORMAL, MAP_WALL, 0),
|
||||
(ENTITY_MAP, to_unbounded_string ("Stone Floor"), '.', COLOUR_GREY, EFFECT_BOLD, MAP_FLOOR, 0),
|
||||
(ENTITY_MAP, to_unbounded_string ("Wooden Floor"), '.', COLOUR_YELLOW, EFFECT_NORMAL, MAP_FLOOR, 0)
|
||||
map_constant_data : constant map_constant_list := (
|
||||
(ENTITY_MAP, to_unbounded_string ("Stone Wall"), '#', COLOUR_GREY, EFFECT_BOLD, true),
|
||||
(ENTITY_MAP, to_unbounded_string ("Wooden Wall"), '#', COLOUR_YELLOW, EFFECT_NORMAL, true),
|
||||
(ENTITY_MAP, to_unbounded_string ("Stone Floor"), '.', COLOUR_GREY, EFFECT_BOLD, false),
|
||||
(ENTITY_MAP, to_unbounded_string ("Wooden Floor"), '.', COLOUR_YELLOW, EFFECT_NORMAL, false)
|
||||
);
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Item
|
||||
-- Weapon
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
type item_id is (
|
||||
ITEM_NONE, ITEM_AMMUNITION, ITEM_WEAPON, ITEM_ARMOUR, ITEM_SCROLL, ITEM_POTION, ITEM_CONSUMABLE, ITEM_NOTE
|
||||
);
|
||||
|
||||
type item_list_id is (
|
||||
type weapon_list is (
|
||||
IRON_SWORD, IRON_GREATSWORD, IRON_AXE, IRON_BATTLEAXE, IRON_SPEAR, IRON_SHIELD, IRON_MACE, IRON_HAMMER
|
||||
);
|
||||
|
||||
type item_constant_type is new entity_constant_type with
|
||||
type weapon_mark is mod 72;
|
||||
|
||||
type weapon_constant_type is new entity_constant_type with
|
||||
record
|
||||
item : item_id := ITEM_NONE;
|
||||
amount_limit : natural := 0;
|
||||
dual_wield : boolean := false;
|
||||
weight : natural := 0;
|
||||
value : natural := 0;
|
||||
attack_range : integer_subrange := (0, 0);
|
||||
defense_range : integer_subrange := (0, 0);
|
||||
distance_range : integer_subrange := (0, 0);
|
||||
health_shift : natural_subrange := (0, 0);
|
||||
mana_shift : natural_subrange := (0, 0);
|
||||
stamina_shift : natural_subrange := (0, 0);
|
||||
-- description : unbounded_string := null_unbounded_string;
|
||||
end record;
|
||||
|
||||
type item_variable_type is new entity_variable_type with
|
||||
type weapon_variable_type is new entity_variable_type with
|
||||
record
|
||||
amount : natural := 0;
|
||||
enchantment : natural := 0;
|
||||
condition : natural := 0;
|
||||
end record;
|
||||
|
||||
type item_constant_list is array (item_list_id) of item_constant_type;
|
||||
type weapon_constant_list is array (weapon_list) of weapon_constant_type;
|
||||
type weapon_variable_list is array (weapon_mark) of weapon_variable_type;
|
||||
|
||||
item_data : constant item_constant_list := ( -- Please...
|
||||
(ENTITY_ITEM, to_unbounded_string ("Iron Sword"), '!', COLOUR_RED, EFFECT_NORMAL, ITEM_WEAPON, 0, 31, 30, (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1)),
|
||||
(ENTITY_ITEM, to_unbounded_string ("Iron Greatsword"), '!', COLOUR_RED, EFFECT_NORMAL, ITEM_WEAPON, 0, 32, 31, (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1)),
|
||||
(ENTITY_ITEM, to_unbounded_string ("Iron Axe"), '!', COLOUR_RED, EFFECT_NORMAL, ITEM_WEAPON, 0, 33, 32, (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1)),
|
||||
(ENTITY_ITEM, to_unbounded_string ("Iron Battleaxe"), '!', COLOUR_RED, EFFECT_NORMAL, ITEM_WEAPON, 0, 34, 33, (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1)),
|
||||
(ENTITY_ITEM, to_unbounded_string ("Iron Spear"), '!', COLOUR_RED, EFFECT_NORMAL, ITEM_WEAPON, 0, 35, 34, (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1)),
|
||||
(ENTITY_ITEM, to_unbounded_string ("Iron Shield"), '!', COLOUR_RED, EFFECT_NORMAL, ITEM_WEAPON, 0, 36, 35, (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1)),
|
||||
(ENTITY_ITEM, to_unbounded_string ("Iron Mace"), '!', COLOUR_RED, EFFECT_NORMAL, ITEM_WEAPON, 0, 37, 36, (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1)),
|
||||
(ENTITY_ITEM, to_unbounded_string ("Iron Hammer"), '!', COLOUR_RED, EFFECT_NORMAL, ITEM_WEAPON, 0, 38, 37, (1, 1), (1, 1), (1, 1), (1, 1), (1, 1), (1, 1))
|
||||
weapon_constant_data : constant weapon_constant_list := (
|
||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Sword"), 'l', COLOUR_RED, EFFECT_NORMAL, true, 31, 11, (3, 7), (0, 2), (0, 1)),
|
||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Greatsword"), 'L', COLOUR_RED, EFFECT_BOLD, false, 67, 19, (5, 11), (1, 3), (0, 2)),
|
||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Axe"), 'r', COLOUR_RED, EFFECT_NORMAL, true, 43, 13, (1, 7), (0, 2), (0, 1)),
|
||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Battleaxe"), 'T', COLOUR_RED, EFFECT_BOLD, false, 73, 17, (6, 13), (1, 2), (0, 2)),
|
||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Spear"), 'I', COLOUR_RED, EFFECT_BOLD, false, 53, 11, (4, 10), (2, 4), (0, 2)),
|
||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Shield"), 'o', COLOUR_RED, EFFECT_NORMAL, true, 37, 13, (0, 3), (4, 9), (0, 1)),
|
||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Mace"), 'i', COLOUR_RED, EFFECT_NORMAL, true, 41, 11, (3, 8), (0, 2), (0, 1)),
|
||||
(ENTITY_WEAPON, to_unbounded_string ("Iron Hammer"), 't', COLOUR_RED, EFFECT_NORMAL, true, 47, 13, (4, 7), (0, 3), (0, 1))
|
||||
);
|
||||
|
||||
weapon_variable_data : weapon_variable_list;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Plant
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
type plant_id is (
|
||||
PLANT_NONE, PLANT_GRASS, PLANT_REED, PLANT_BUSH, PLANT_APPLE_TREE, PLANT_LEMON_TREE, PLANT_OAK_TREE, PLANT_PINE_TREE
|
||||
type plant_list is (
|
||||
PLANT_FLOWER, PLANT_GRASS, PLANT_REED, PLANT_BUSH, PLANT_APPLE_TREE, PLANT_LEMON_TREE, PLANT_OAK_TREE, PLANT_PINE_TREE
|
||||
);
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Animal
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
type animal_id is (
|
||||
ANIMAL_NONE, ANIMAL_RAT, ANIMAL_BAT, ANIMAL_SPIDER, ANIMAL_LIZARD, ANIMAL_SNAIL, ANIMAL_WORM, ANIMAL_MOLE
|
||||
type animal_list is (
|
||||
ANIMAL_ROACH, ANIMAL_RAT, ANIMAL_BAT, ANIMAL_SPIDER, ANIMAL_LIZARD, ANIMAL_SNAIL, ANIMAL_WORM, ANIMAL_MOLE
|
||||
);
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Goblin
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
type goblin_id is (
|
||||
GOBLIN_NONE, GOBLIN_WORKER, GOBLIN_WARRIOR, GOBLIN_BOAR_RIDER, GOBLIN_SHAMAN, GOBLIN_CHIEF, GOBLIN_KING, GOBLIN_OGRE
|
||||
type goblin_list is (
|
||||
GOBLIN_FEMALE, GOBLIN_WORKER, GOBLIN_WARRIOR, GOBLIN_BOAR_RIDER, GOBLIN_SHAMAN, GOBLIN_CHIEF, GOBLIN_KING, GOBLIN_OGRE
|
||||
);
|
||||
|
||||
type goblin_constant_type is new entity_constant_type with
|
||||
record
|
||||
goblin : goblin_id := GOBLIN_NONE; -- Index of 'goblin_data'.
|
||||
health_limit : natural := 0;
|
||||
armour_limit : natural := 0;
|
||||
mana_limit : natural := 0;
|
||||
@ -179,20 +203,23 @@ function xabina return integer is
|
||||
armour : natural := 0;
|
||||
mana : natural := 0;
|
||||
stamina : natural := 0;
|
||||
weapon : item_id := ITEM_NONE;
|
||||
end record;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Gameplay
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
x : natural := 0;
|
||||
|
||||
begin
|
||||
|
||||
for this in item_list_id
|
||||
for this in weapon_list
|
||||
loop
|
||||
put_line ("> " & to_string (item_data (this).name));
|
||||
put_line ("> " & to_string (weapon_constant_data (this).name));
|
||||
end loop;
|
||||
|
||||
x := x + render_character ('@', COLOUR_BLUE, EFFECT_BOLD);
|
||||
|
||||
return 0;
|
||||
|
||||
end xabina;
|
||||
|
Loading…
Reference in New Issue
Block a user