From a8fe5c2333686ac22e762f7585a8b659140d9c3f Mon Sep 17 00:00:00 2001 From: xolatile Date: Sun, 9 Jun 2024 19:24:58 -0400 Subject: [PATCH] Major refactoring in progress, biome, landmark, location, lore... --- source/biome.ads | 23 +++++++ source/core.adb | 2 - source/core.ads | 1 + source/landmark.ads | 67 +++++++++++++++++++ source/location.ads | 51 +++++++++++++++ source/lore.ads | 98 ++++++++++++++++++++++++++++ source/main.adb | 28 ++++---- source/ui.adb | 7 -- source/ui.ads | 5 ++ source/world.adb | 97 +++++++++++++--------------- source/world.ads | 183 +++------------------------------------------------- 11 files changed, 312 insertions(+), 250 deletions(-) create mode 100644 source/biome.ads create mode 100644 source/landmark.ads create mode 100644 source/location.ads create mode 100644 source/lore.ads diff --git a/source/biome.ads b/source/biome.ads new file mode 100644 index 0000000..3475692 --- /dev/null +++ b/source/biome.ads @@ -0,0 +1,23 @@ +-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic +-- +-- GNU General Public Licence (version 3 or later) + +with core; + +package biome is + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + type enumeration is ( + ash, sand, grass, rough, snow, swamp + ); + + ------------------------------------------------------------------------------------------ + + count : constant natural := enumeration'pos (enumeration'last) + 1; + + tiles : array (enumeration) of core.sprite; + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + +end biome; diff --git a/source/core.adb b/source/core.adb index be8dc0a..e156d21 100644 --- a/source/core.adb +++ b/source/core.adb @@ -2,8 +2,6 @@ -- -- GNU General Public Licence (version 3 or later) -with ray; - package body core is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/core.ads b/source/core.ads index cc14920..ef80777 100644 --- a/source/core.ads +++ b/source/core.ads @@ -6,6 +6,7 @@ with ada.text_io, ada.strings.unbounded, interfaces.c, ray, system; use ada.text_io, ada.strings.unbounded, interfaces.c, ray, system; with ada.sequential_io; +with ray; package core is diff --git a/source/landmark.ads b/source/landmark.ads new file mode 100644 index 0000000..928f888 --- /dev/null +++ b/source/landmark.ads @@ -0,0 +1,67 @@ +-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic +-- +-- GNU General Public Licence (version 3 or later) + +with core, biome; + +package landmark is + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + type enumeration is ( + dead_tree, mossy_rock, palm_tree, pine_tree, pine_forest, reeds, + rock, snowed_pine_tree, snowed_rock, spiky_rock, wooden_sign, wooden_arrow_sign, + rune_stone, snowed_rune_stone, mossy_rune_stone, snowed_pine_forest, hyacinths, orchids, + asters, daffodils, royal_grave, grave, humble_grave, wooden_wide_sign, + birch_tree, fir_tree, oak_tree, old_willow_tree + ); + + ------------------------------------------------------------------------------------------ + + type definition is record + name : access string; + spawn : biome.enumeration; + clip : boolean; + frames : integer; + end record; + + ------------------------------------------------------------------------------------------ + + count : constant natural := enumeration'pos (enumeration'last) + 1; + + description : constant array (enumeration) of definition := ( + dead_tree => (new string'("Dead Tree"), biome.ash, true, 1), + mossy_rock => (new string'("Mossy Rock"), biome.swamp, true, 1), + palm_tree => (new string'("Palm Tree"), biome.sand, true, 4), + pine_tree => (new string'("Pine Tree"), biome.grass, true, 4), + pine_forest => (new string'("Pine Forest"), biome.grass, true, 4), + reeds => (new string'("Reeds"), biome.swamp, false, 4), + rock => (new string'("Rock"), biome.sand, true, 1), + snowed_pine_tree => (new string'("Snowed Pine Tree"), biome.snow, true, 4), + snowed_rock => (new string'("Snowed Rock"), biome.snow, true, 1), + spiky_rock => (new string'("Spiky Rock"), biome.ash, true, 1), + wooden_sign => (new string'("Wooden Sign"), biome.grass, false, 1), + wooden_arrow_sign => (new string'("Wooden Arrow Sign"), biome.grass, false, 1), + rune_stone => (new string'("Rune Stone"), biome.grass, true, 4), + snowed_rune_stone => (new string'("Snowed Rune Stone"), biome.snow, true, 1), + mossy_rune_stone => (new string'("Mossy Rune Stone"), biome.swamp, true, 4), + snowed_pine_forest => (new string'("Snowed Pine Forest"), biome.snow, true, 4), + hyacinths => (new string'("Hyacinths"), biome.grass, false, 1), + orchids => (new string'("Orchids"), biome.grass, false, 1), + asters => (new string'("Asters"), biome.grass, false, 1), + daffodils => (new string'("Daffodils"), biome.grass, false, 1), + royal_grave => (new string'("Royal Grave"), biome.ash, true, 1), + grave => (new string'("Grave"), biome.ash, true, 1), + humble_grave => (new string'("Humble Grave"), biome.ash, true, 1), + wooden_wide_sign => (new string'("Wooden Wide Sign"), biome.grass, false, 1), + birch_tree => (new string'("Birch Tree"), biome.grass, true, 4), + fir_tree => (new string'("Fir Tree"), biome.grass, true, 4), + oak_tree => (new string'("Oak Tree"), biome.grass, true, 4), + old_willow_tree => (new string'("Old Willow Tree"), biome.swamp, true, 4) + ); + + game : array (enumeration) of core.sprite; + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + +end landmark; diff --git a/source/location.ads b/source/location.ads new file mode 100644 index 0000000..7c8774e --- /dev/null +++ b/source/location.ads @@ -0,0 +1,51 @@ +-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic +-- +-- GNU General Public Licence (version 3 or later) + +with core, effect, attribute, skill, resource, material; + +package location is + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + type enumeration is ( + well_of_agility, well_of_knowledge, well_of_strength, old_dwarven_grave, huge_ancient_urn, banana_tree, + apple_tree, cherry_tree, lemon_tree, orange_tree, pear_tree, peach_tree, + plum_tree + ); + + ------------------------------------------------------------------------------------------ + + type definition is record + name : access string; + clip : boolean; + frames : integer; + states : integer; + evoke : effect.information; + end record; + + ------------------------------------------------------------------------------------------ + + count : constant natural := enumeration'pos (enumeration'last) + 1; + + description : constant array (enumeration) of definition := ( + well_of_agility => (new string'("Well of Agility"), true, 4, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.speed), 2, false, 0)), + well_of_knowledge => (new string'("Well of Knowledge"), true, 4, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.wisdom), 2, false, 0)), + well_of_strength => (new string'("Well of Strength"), true, 4, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.offense), 2, false, 0)), + old_dwarven_grave => (new string'("Old Dwarven Grave"), true, 1, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.defense), 1, false, 0)), + huge_ancient_urn => (new string'("Huge Ancient Urn"), true, 1, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.offense), 1, false, 0)), + banana_tree => (new string'("Banana Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.banana), 4, true, 600)), + apple_tree => (new string'("Apple Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.apple), 6, true, 600)), + cherry_tree => (new string'("Cherry Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.cherry), 6, true, 600)), + lemon_tree => (new string'("Lemon Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.lemon), 6, true, 600)), + orange_tree => (new string'("Orange Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.orange), 6, true, 600)), + pear_tree => (new string'("Pear Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.pear), 6, true, 600)), + peach_tree => (new string'("Peach Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.peach), 6, true, 600)), + plum_tree => (new string'("Plum Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.plum), 6, true, 600)) + ); + + game : array (enumeration) of core.sprite; + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + +end location; diff --git a/source/lore.ads b/source/lore.ads new file mode 100644 index 0000000..e0f3c4d --- /dev/null +++ b/source/lore.ads @@ -0,0 +1,98 @@ +-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic +-- +-- GNU General Public Licence (version 3 or later) + +with core; + +package lore is + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + month_count : constant natural := 13; + week_count : constant natural := 52; + day_count : constant natural := 7; + + month_name : constant array (1 .. month_count) of access string := ( + new string'("I <> Month of Genesis"), + new string'("II <> Month of Life"), + new string'("III <> Month of Xorana"), + new string'("IV <> Month of Heneal"), + new string'("V <> Month of Evelor"), + new string'("VI <> Month of Orohan"), + new string'("VII <> Month of Aezora"), + new string'("VIII <> Month of Mitena"), + new string'("IX <> Month of Sheila"), + new string'("X <> Month of Iliona"), + new string'("XI <> Month of Uldrae"), + new string'("XII <> Month of Kanako"), + new string'("XIII <> Month of Death") + ); + + week_name : constant array (1 .. week_count) of access string := ( + new string'("I <> Week of Miners"), -- R 0 Gold + new string'("II <> Week of Flora"), -- D 0 Aezora + new string'("III <> Week of Alchemists"), -- S 0 Alchemy + new string'("IV <> Week of Shape"), -- D 7 Evelor + new string'("V <> Week of Sword"), -- A 0 Offense + new string'("VI <> Week of Necromancers"), -- S 12 Necromancy + new string'("VII <> Week of Fauna"), -- D 2 Sheila + new string'("VIII <> Week of Windmill"), -- S 20 Aerokinesis + new string'("IX <> Week of Guards"), -- S 13 Resistance + new string'("X <> Week of Blacksmiths"), -- R 3 Metal + new string'("XI <> Week of Archers"), -- S 1 Archery + new string'("XII <> Week of Bumblebee"), -- - -- + new string'("XIII <> Week of Sound"), -- D 8 Orohan + new string'("XIV <> Week of Water"), -- D 3 Iliona + new string'("XV <> Week of Bankers"), -- S 5 Estates + new string'("XVI <> Week of Wall"), -- S 21 Khousokinesis + new string'("XVII <> Week of Axolotl"), -- - -- + new string'("XVIII <> Week of Thaumaturgs"), -- S 17 Thaumaturgy + new string'("XIX <> Week of Stonecutters"), -- R 2 Stone + new string'("XX <> Week of Mole"), -- - -- + new string'("XXI <> Week of Shrine"), -- S 22 Phosokinesis + new string'("XXII <> Week of Logic"), -- D 6 Heneal + new string'("XXIII <> Week of Mystics"), -- S 11 Mysticism + new string'("XXIV <> Week of Diplomats"), -- S 4 Diplomacy + new string'("XXV <> Week of Boots"), -- A 4 Speed + new string'("XXVI <> Week of Shield"), -- A 1 Defense + new string'("XXVII <> Week of Advisors"), -- S 8 Logistics + new string'("XXVIII <> Week of Architects"), -- S 2 Architecture + new string'("XXIX <> Week of Flame"), -- D 5 Kanako + new string'("XXX <> Week of Spider"), -- - -- + new string'("XXXI <> Week of Value"), -- D 4 Uldrae + new string'("XXXII <> Week of Healers"), -- S 9 Medicine + new string'("XXXIII <> Week of Spear"), -- A 5 Reach + new string'("XXXIV <> Week of Gallows"), -- S 23 Eremnokinesis + new string'("XXXV <> Week of Leaders"), -- S 7 Leaderhsip + new string'("XXXVI <> Week of Skirmishers"), -- S 14 Skirmish + new string'("XXXVII <> Week of Lubmerjacks"), -- R 1 Wood + new string'("XXXVIII <> Week of Pathfinders"), -- S 3 Athletics + new string'("XXXIX <> Week of Frog"), -- - -- + new string'("XL <> Week of Stakes"), -- S 18 Pyrokinesis + new string'("XLI <> Week of Helmet"), -- A 2 Wisdom + new string'("XLII <> Week of Leatherers"), -- R 4 Leather + new string'("XLIII <> Week of Rat"), -- - -- + new string'("XLIV <> Week of Sorcerers"), -- S 15 Sorcery + new string'("XLV <> Week of Gloves"), -- A 3 Stamina + new string'("XLVI <> Week of Earth"), -- D 1 Mitena + new string'("XLVII <> Week of Explorers"), -- S 6 Exploration + new string'("XLVIII <> Week of Bridge"), -- S 19 Hydrokinesis + new string'("XLIX <> Week of Strategists"), -- S 16 Tactics + new string'("L <> Week of Gemologists"), -- R 5 Gem + new string'("LI <> Week of Merchants"), -- S 10 Mercantile + new string'("LII <> Week of Farce") -- D 9 Xorana (Osamu Dazai - The God of Farce) + ); + + day_name : constant array (1 .. day_count) of access string := ( + new string'("I <> Day of Sun"), + new string'("II <> Day of Mother-Moon"), + new string'("III <> Day of Daughter-Moon"), + new string'("IV <> Day of All-Earth"), + new string'("V <> Day of All-Water"), + new string'("VI <> Day of All-Sky"), + new string'("VII <> Day of Deities") + ); + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + +end lore; diff --git a/source/main.adb b/source/main.adb index c53a047..68328da 100644 --- a/source/main.adb +++ b/source/main.adb @@ -4,7 +4,7 @@ pragma ada_2012; -with core, ui, effect, attribute, skill, resource, faction, deity, material, magic, equipment, unit, construction, chad, world; +with core, ui, effect, lore, biome, attribute, skill, resource, faction, deity, material, magic, equipment, unit, construction, chad, world; use type core.cursor_code; use type core.signal_code; @@ -66,11 +66,11 @@ procedure main is new string'("Toggle fullscreen or windowed mode.") ); - game_title : core.sprite; - game_preview : array (world.biome) of core.sprite; + game_title : core.sprite; + game_preview : array (biome.enumeration) of core.sprite; - switch : natural := 0; - choose : world.biome := world.grass; + switch : natural := 0; + choose : biome.enumeration := biome.grass; view_source_code : natural := 17; @@ -187,7 +187,7 @@ procedure main is at_y := at_y + core.base; -- for index in equipment.kind loop - if equipment.enumeration'pos (player_1.equipments (index)) /= equipment.enumeration'pos (equipment.none) then + if world.equipment_valid (player_1.equipments (index)) then ui.draw_overicon (data => equipment.icon (player_1.equipments (index)), text => equipment.description (player_1.equipments (index)).name.all, x => at_x + equipment.kind'pos (index) * core.icon, @@ -249,9 +249,9 @@ procedure main is begin ui.draw_frame (x, y, width, height); -- - ui.draw_text (world.day_name (7).all, x + offset, y + 0 * core.icon + offset, width - 2 * offset - 64, core.icon, more, 0); - ui.draw_text (world.week_name (6).all, x + offset, y + 1 * core.icon + offset, width - 2 * offset - 64, core.icon, more, 0); - ui.draw_text (world.month_name (2).all, x + offset, y + 2 * core.icon + offset, width - 2 * offset - 64, core.icon, more, 0); + ui.draw_text (lore.day_name (7).all, x + offset, y + 0 * core.icon + offset, width - 2 * offset - 64, core.icon, more, 0); + ui.draw_text (lore.week_name (6).all, x + offset, y + 1 * core.icon + offset, width - 2 * offset - 64, core.icon, more, 0); + ui.draw_text (lore.month_name (2).all, x + offset, y + 2 * core.icon + offset, width - 2 * offset - 64, core.icon, more, 0); -- ui.draw_end_turn_button (x + width - offset - 64, y + offset + core.icon / 2); end time_information; @@ -365,7 +365,7 @@ begin world.configure; --~ai.configure; - world.make (world.grass, 640, 480, 8); + world.make (biome.grass, 640, 480, 8); world.add_chad (player); core.dash; @@ -379,8 +379,8 @@ begin game_title := core.import_sprite (core.folder & "/ui/game_title.png", 1, 1); - for index in world.biome loop - game_preview (index) := core.import_sprite (core.folder & "/ui/preview/" & core.lowercase (world.biome'image (index)) & "land.png", 1, 1); + for index in biome.enumeration loop + game_preview (index) := core.import_sprite (core.folder & "/ui/preview/" & core.lowercase (index'image) & "land.png", 1, 1); end loop; ------------------------------------------------------------------------------------------ @@ -393,8 +393,8 @@ begin case core.signal_mode is when core.signal_none => null; when core.signal_space => null; - when others => switch := (switch + 1) mod world.biome_count; - choose := world.biome'val (switch); + when others => switch := (switch + 1) mod biome.count; + choose := biome.enumeration'val (switch); end case; -- core.draw (game_preview (choose), core.center_x (game_preview (choose).width * 2), core.center_y (game_preview (choose).height * 2), factor => 2); diff --git a/source/ui.adb b/source/ui.adb index 8ed89ab..65c5453 100644 --- a/source/ui.adb +++ b/source/ui.adb @@ -2,13 +2,6 @@ -- -- GNU General Public Licence (version 3 or later) -with core; - -use type core.cursor_code; -use type core.signal_code; -use type core.point; -use type core.unstring; - package body ui is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/ui.ads b/source/ui.ads index ba92d8e..ebd01e7 100644 --- a/source/ui.ads +++ b/source/ui.ads @@ -4,6 +4,11 @@ with core; +use type core.cursor_code; +use type core.signal_code; +use type core.point; +use type core.unstring; + package ui is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/source/world.adb b/source/world.adb index efe03ba..55a19e5 100644 --- a/source/world.adb +++ b/source/world.adb @@ -2,12 +2,6 @@ -- -- GNU General Public Licence (version 3 or later) -with core, ui, attribute, skill, resource, faction, equipment, unit, construction, chad, effect; - -use type core.cursor_code; -use type core.signal_code; -use type core.point; - package body world is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -22,8 +16,6 @@ package body world is equipment_limit : constant natural := 300; unit_limit : constant natural := 600; - tiles : array (biome) of core.sprite; - target : core.vector := (-1, -1); dark : core.sprite; @@ -85,8 +77,8 @@ package body world is begin core.echo (core.comment, "Configuring world components..."); -- - for index in biome loop - tiles (index) := core.import_sprite (core.folder & "/game/world/terrain/" & core.lowercase (index'image) & ".png", 4, 1); + for index in biome.enumeration loop + biome.tiles (index) := core.import_sprite (core.folder & "/game/world/terrain/" & core.lowercase (index'image) & ".png", 4, 1); end loop; -- dark := core.import_sprite (core.folder & "/game/world/dark.png", 1, 1); @@ -108,16 +100,16 @@ package body world is arrow_lower_left := core.import_sprite (core.folder & "/game/world/arrow/lower_left.png", 1, 1); arrow_lower_right := core.import_sprite (core.folder & "/game/world/arrow/lower_right.png", 1, 1); -- - for index in landmark_index loop - landmarks (index) := core.import_sprite (file_path => core.folder & "/game/world/landmark/" & core.lowercase (index'image) & ".png", - frames => landmark_description (index).frames, - states => 1); + for index in landmark.enumeration loop + landmark.game (index) := core.import_sprite (file_path => core.folder & "/game/world/landmark/" & core.lowercase (index'image) & ".png", + frames => landmark.description (index).frames, + states => 1); end loop; -- - for index in location_index loop - locations (index) := core.import_sprite (file_path => core.folder & "/game/world/location/" & core.lowercase (index'image) & ".png", - frames => location_description (index).frames, - states => location_description (index).states); + for index in location.enumeration loop + location.game (index) := core.import_sprite (file_path => core.folder & "/game/world/location/" & core.lowercase (index'image) & ".png", + frames => location.description (index).frames, + states => location.description (index).states); end loop; end configure; @@ -130,7 +122,7 @@ package body world is ------------------------------------------------------------------------------------------ - procedure make (index : in biome; width, height, chad_limit : in natural) is + procedure make (index : in biome.enumeration; width, height, chad_limit : in natural) is begin core.echo (core.comment, "-- Procedurally generating new map..."); -- @@ -180,7 +172,7 @@ package body world is end loop; -- for index in 1 .. landmark_limit loop - map.landmarks (index).index := core.random (0, landmark_count - 1); + map.landmarks (index).index := core.random (0, landmark.count - 1); map.landmarks (index).state := 0; <> map.landmarks (index).x := core.random (6, map.width - 6); @@ -190,9 +182,9 @@ package body world is goto repeat_landmark_generation; end if; -- - if landmark_description (landmark_index'val (map.landmarks (index).index)).clip then - declare reach_x : constant natural := landmarks (landmark_index'val (map.landmarks (index).index)).width / core.base; - reach_y : constant natural := landmarks (landmark_index'val (map.landmarks (index).index)).height / core.base; + if landmark.description (landmark.enumeration'val (map.landmarks (index).index)).clip then + declare reach_x : constant natural := landmark.game (landmark.enumeration'val (map.landmarks (index).index)).width / core.base; + reach_y : constant natural := landmark.game (landmark.enumeration'val (map.landmarks (index).index)).height / core.base; begin for x in 0 .. reach_x - 1 loop for y in 0 .. reach_y - 1 loop @@ -204,7 +196,7 @@ package body world is end loop; -- for index in 1 .. location_limit loop - map.locations (index).index := core.random (0, location_count - 1); + map.locations (index).index := core.random (0, location.count - 1); map.locations (index).state := 0; <> map.locations (index).x := core.random (6, map.width - 6); @@ -214,9 +206,9 @@ package body world is goto repeat_location_generation; end if; -- - if location_description (location_index'val (map.locations (index).index)).clip then - declare reach_x : constant natural := locations (location_index'val (map.locations (index).index)).width / core.base; - reach_y : constant natural := locations (location_index'val (map.locations (index).index)).height / core.base; + if location.description (location.enumeration'val (map.locations (index).index)).clip then + declare reach_x : constant natural := location.game (location.enumeration'val (map.locations (index).index)).width / core.base; + reach_y : constant natural := location.game (location.enumeration'val (map.locations (index).index)).height / core.base; begin for x in 0 .. reach_x - 1 loop for y in 0 .. reach_y - 1 loop @@ -293,7 +285,7 @@ package body world is begin core.io.create (file, core.io.out_file, core.folder & "/map/" & file_name); -- - core.io.write (file, biome'pos (map.kind)); + core.io.write (file, biome.enumeration'pos (map.kind)); core.io.write (file, map.width); core.io.write (file, map.height); core.io.write (file, map.chad_count); @@ -369,7 +361,7 @@ package body world is begin core.io.open (file, core.io.in_file, core.folder & "/map/" & file_name); -- - core.io.read (file, this); map.kind := biome'val (this); + core.io.read (file, this); map.kind := biome.enumeration'val (this); core.io.read (file, map.width); core.io.read (file, map.height); core.io.read (file, map.chad_count); @@ -510,7 +502,7 @@ package body world is -- for vertical in 0 .. map.height - 1 loop for horizontal in 0 .. map.width - 1 loop - core.render_image (data => tiles (map.kind), + core.render_image (data => biome.tiles (map.kind), x => horizontal * core.base, y => vertical * core.base, u => core.base * map.tiles (horizontal, vertical), @@ -521,23 +513,23 @@ package body world is end loop; -- for index in 1 .. landmark_limit loop - core.render_image (data => landmarks (landmark_index'val (map.landmarks (index).index)), + core.render_image (data => landmark.game (landmark.enumeration'val (map.landmarks (index).index)), x => map.landmarks (index).x * core.base, y => map.landmarks (index).y * core.base, u => 0, v => 0, - width => landmarks (landmark_index'val (map.landmarks (index).index)).width, - height => landmarks (landmark_index'val (map.landmarks (index).index)).height); + width => landmark.game (landmark.enumeration'val (map.landmarks (index).index)).width, + height => landmark.game (landmark.enumeration'val (map.landmarks (index).index)).height); end loop; -- for index in 1 .. location_limit loop - core.render_image (data => locations (location_index'val (map.locations (index).index)), + core.render_image (data => location.game (location.enumeration'val (map.locations (index).index)), x => map.locations (index).x * core.base, y => map.locations (index).y * core.base, u => 0, v => 0, - width => locations (location_index'val (map.locations (index).index)).width, - height => locations (location_index'val (map.locations (index).index)).height); + width => location.game (location.enumeration'val (map.locations (index).index)).width, + height => location.game (location.enumeration'val (map.locations (index).index)).height); end loop; -- for index in 1 .. construction_limit loop @@ -719,11 +711,11 @@ package body world is exit when horizontal > map.width - 1; -- if map.views (horizontal, vertical) then - core.draw (data => tiles (map.kind), + core.draw (data => biome.tiles (map.kind), x => offset.x + (horizontal - core.camera.x) * size, y => offset.y + (vertical - core.camera.y) * size, u => core.base * map.tiles (horizontal, vertical), - v => core.base * (core.animation_time mod tiles (map.kind).frames), + v => core.base * (core.animation_time mod biome.tiles (map.kind).frames), width => core.base, height => core.base, ignore => true); @@ -854,7 +846,7 @@ package body world is if map.views (map.landmarks (index).x, map.landmarks (index).y) and map.landmarks (index).x > view_from.x and map.landmarks (index).x < view_from.x + view_to.x and map.landmarks (index).y > view_from.y and map.landmarks (index).y < view_from.y + view_to.y then - core.draw (data => landmarks (landmark_index'val (map.landmarks (index).index)), + core.draw (data => landmark.game (landmark.enumeration'val (map.landmarks (index).index)), x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom, y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom); -- @@ -862,11 +854,11 @@ package body world is -- if core.cursor_inside (x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom, y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom, - width => landmarks (landmark_index'val (map.landmarks (index).index)).width, - height => landmarks (landmark_index'val (map.landmarks (index).index)).height) + width => landmark.game (landmark.enumeration'val (map.landmarks (index).index)).width, + height => landmark.game (landmark.enumeration'val (map.landmarks (index).index)).height) and core.cursor_mode = core.cursor_middle and not ui.prioritize then - core.write_text_box (landmark_description (landmark_index'val (map.landmarks (index).index)).name.all); + core.write_text_box (landmark.description (landmark.enumeration'val (map.landmarks (index).index)).name.all); end if; end if; end loop; @@ -877,8 +869,7 @@ package body world is ------------------------------------------------------------------------------------------ procedure draw_locations (offset, view_from, view_to : in core.vector) is - time : float := 0.0; - sprite : core.sprite; + time : float := 0.0; begin time := core.time; -- @@ -886,7 +877,7 @@ package body world is if map.views (map.locations (index).x, map.locations (index).y) and map.locations (index).x > view_from.x and map.locations (index).x < view_from.x + view_to.x and map.locations (index).y > view_from.y and map.locations (index).y < view_from.y + view_to.y then - core.draw (data => locations (location_index'val (map.locations (index).index)), + core.draw (data => location.game (location.enumeration'val (map.locations (index).index)), x => offset.x + (map.locations (index).x - core.camera.x) * core.base * core.zoom, y => offset.y + (map.locations (index).y - core.camera.y) * core.base * core.zoom, state => core.animation'val (map.locations (index).state)); @@ -895,11 +886,11 @@ package body world is -- if core.cursor_inside (x => offset.x + (map.locations (index).x - core.camera.x) * core.base * core.zoom, y => offset.y + (map.locations (index).y - core.camera.y) * core.base * core.zoom, - width => locations (location_index'val (map.locations (index).index)).width, - height => locations (location_index'val (map.locations (index).index)).height) + width => location.game (location.enumeration'val (map.locations (index).index)).width, + height => location.game (location.enumeration'val (map.locations (index).index)).height) and core.cursor_mode = core.cursor_middle and not ui.prioritize then - core.write_text_box (location_description (location_index'val (map.locations (index).index)).name.all); + core.write_text_box (location.description (location.enumeration'val (map.locations (index).index)).name.all); end if; end if; -- @@ -908,15 +899,15 @@ package body world is end if; -- if core.camera.x > map.locations (index).x - 2 - and core.camera.x < map.locations (index).x + 1 + locations (location_index'val (map.locations (index).index)).width / core.base + and core.camera.x < map.locations (index).x + 1 + location.game (location.enumeration'val (map.locations (index).index)).width / core.base and core.camera.y > map.locations (index).y - 2 - and core.camera.y < map.locations (index).y + 1 + locations (location_index'val (map.locations (index).index)).height / core.base + and core.camera.y < map.locations (index).y + 1 + location.game (location.enumeration'val (map.locations (index).index)).height / core.base and map.locations (index).state = 0 and core.signal_code'pos (core.signal_mode) = core.signal_code'pos (core.signal_e) and not ui.prioritize then declare player : chad.information renames world.map.chads (1); -- - data : effect.information := location_description (location_index'val (map.locations (index).index)).evoke; + data : effect.information := location.description (location.enumeration'val (map.locations (index).index)).evoke; -- attribute_index : attribute.enumeration; skill_index : skill.enumeration; @@ -1012,7 +1003,7 @@ package body world is -- if core.cursor_inside (x, y, equipment.sprite (this).width, equipment.sprite (this).height) and core.cursor_mode = core.cursor_middle - and equipment.enumeration'pos (this) /= equipment.enumeration'pos (equipment.none) + and equipment_valid (this) and not ui.prioritize then core.write_text_box (equipment.description (this).name.all); end if; @@ -1023,7 +1014,7 @@ package body world is if map.equipments (index).x = core.camera.x and map.equipments (index).y = core.camera.y and core.signal_code'pos (core.signal_mode) = core.signal_code'pos (core.signal_e) then - if map.chads (1).item_count < chad.item_limit and map.equipments (index).index /= equipment.enumeration'pos (equipment.none) then + if map.chads (1).item_count < chad.item_limit and equipment_valid (equipment.enumeration'val (map.equipments (index).index)) then map.chads (1).items (map.chads (1).item_count) := equipment.enumeration'val (map.equipments (index).index); -- core.increment (map.chads (1).item_count); diff --git a/source/world.ads b/source/world.ads index 0372db5..0466785 100644 --- a/source/world.ads +++ b/source/world.ads @@ -2,47 +2,16 @@ -- -- GNU General Public Licence (version 3 or later) -with core, attribute, skill, resource, material, equipment, unit, construction, chad, effect; +with core, ui, attribute, skill, resource, material, lore, biome, landmark, location, faction, equipment, unit, construction, chad, effect; + +use type core.cursor_code; +use type core.signal_code; +use type core.point; package world is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - type biome is ( - ash, sand, grass, rough, snow, swamp - ); - - type landmark_index is ( - dead_tree, mossy_rock, palm_tree, pine_tree, pine_forest, reeds, - rock, snowed_pine_tree, snowed_rock, spiky_rock, wooden_sign, wooden_arrow_sign, - rune_stone, snowed_rune_stone, mossy_rune_stone, snowed_pine_forest, hyacinths, orchids, - asters, daffodils, royal_grave, grave, humble_grave, wooden_wide_sign, - birch_tree, fir_tree, oak_tree, old_willow_tree - ); - - type location_index is ( - well_of_agility, well_of_knowledge, well_of_strength, old_dwarven_grave, huge_ancient_urn, banana_tree, - apple_tree, cherry_tree, lemon_tree, orange_tree, pear_tree, peach_tree, - plum_tree - ); - - ------------------------------------------------------------------------------------------ - - type landmark_stats is record - name : access string; - spawn : biome; - clip : boolean; - frames : integer; - end record; - - type location_stats is record - name : access string; - clip : boolean; - frames : integer; - states : integer; - evoke : effect.information; - end record; - type entity_description is record index : natural; state : natural; @@ -54,7 +23,7 @@ package world is type entity_array is array (natural range <>) of entity_description; type definition is record - kind : biome; + kind : biome.enumeration; width : natural; height : natural; chad_count : natural; @@ -72,142 +41,6 @@ package world is ------------------------------------------------------------------------------------------ - biome_count : constant natural := biome'pos (biome'last) + 1; - - landmarks : array (landmark_index) of core.sprite; - locations : array (location_index) of core.sprite; - - landmark_count : constant natural := landmark_index'pos (landmark_index'last) + 1; - location_count : constant natural := location_index'pos (location_index'last) + 1; - - landmark_description : constant array (landmark_index) of landmark_stats := ( - dead_tree => (new string'("Dead Tree"), ash, true, 1), - mossy_rock => (new string'("Mossy Rock"), swamp, true, 1), - palm_tree => (new string'("Palm Tree"), sand, true, 4), - pine_tree => (new string'("Pine Tree"), grass, true, 4), - pine_forest => (new string'("Pine Forest"), grass, true, 4), - reeds => (new string'("Reeds"), swamp, false, 4), - rock => (new string'("Rock"), sand, true, 1), - snowed_pine_tree => (new string'("Snowed Pine Tree"), snow, true, 4), - snowed_rock => (new string'("Snowed Rock"), snow, true, 1), - spiky_rock => (new string'("Spiky Rock"), ash, true, 1), - wooden_sign => (new string'("Wooden Sign"), grass, false, 1), - wooden_arrow_sign => (new string'("Wooden Arrow Sign"), grass, false, 1), - rune_stone => (new string'("Rune Stone"), grass, true, 4), - snowed_rune_stone => (new string'("Snowed Rune Stone"), snow, true, 1), - mossy_rune_stone => (new string'("Mossy Rune Stone"), swamp, true, 4), - snowed_pine_forest => (new string'("Snowed Pine Forest"), snow, true, 4), - hyacinths => (new string'("Hyacinths"), grass, false, 1), - orchids => (new string'("Orchids"), grass, false, 1), - asters => (new string'("Asters"), grass, false, 1), - daffodils => (new string'("Daffodils"), grass, false, 1), - royal_grave => (new string'("Royal Grave"), ash, true, 1), - grave => (new string'("Grave"), ash, true, 1), - humble_grave => (new string'("Humble Grave"), ash, true, 1), - wooden_wide_sign => (new string'("Wooden Wide Sign"), grass, false, 1), - birch_tree => (new string'("Birch Tree"), grass, true, 4), - fir_tree => (new string'("Fir Tree"), grass, true, 4), - oak_tree => (new string'("Oak Tree"), grass, true, 4), - old_willow_tree => (new string'("Old Willow Tree"), swamp, true, 4) - ); - - location_description : constant array (location_index) of location_stats := ( - well_of_agility => (new string'("Well of Agility"), true, 4, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.speed), 2, false, 0)), - well_of_knowledge => (new string'("Well of Knowledge"), true, 4, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.wisdom), 2, false, 0)), - well_of_strength => (new string'("Well of Strength"), true, 4, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.offense), 2, false, 0)), - old_dwarven_grave => (new string'("Old Dwarven Grave"), true, 1, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.defense), 1, false, 0)), - huge_ancient_urn => (new string'("Huge Ancient Urn"), true, 1, 3, (effect.modify_attribute, attribute.enumeration'pos (attribute.offense), 1, false, 0)), - banana_tree => (new string'("Banana Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.banana), 4, true, 600)), - apple_tree => (new string'("Apple Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.apple), 6, true, 600)), - cherry_tree => (new string'("Cherry Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.cherry), 6, true, 600)), - lemon_tree => (new string'("Lemon Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.lemon), 6, true, 600)), - orange_tree => (new string'("Orange Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.orange), 6, true, 600)), - pear_tree => (new string'("Pear Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.pear), 6, true, 600)), - peach_tree => (new string'("Peach Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.peach), 6, true, 600)), - plum_tree => (new string'("Plum Tree"), true, 4, 3, (effect.modify_material, material.enumeration'pos (material.plum), 6, true, 600)) - ); - - month_name : constant array (1 .. 13) of access string := ( - new string'("I <> Month of Genesis"), - new string'("II <> Month of Life"), - new string'("III <> Month of Xorana"), - new string'("IV <> Month of Heneal"), - new string'("V <> Month of Evelor"), - new string'("VI <> Month of Orohan"), - new string'("VII <> Month of Aezora"), - new string'("VIII <> Month of Mitena"), - new string'("IX <> Month of Sheila"), - new string'("X <> Month of Iliona"), - new string'("XI <> Month of Uldrae"), - new string'("XII <> Month of Kanako"), - new string'("XIII <> Month of Death") - ); - - week_name : constant array (1 .. 52) of access string := ( - new string'("I <> Week of Miners"), -- R 0 Gold - new string'("II <> Week of Flora"), -- D 0 Aezora - new string'("III <> Week of Alchemists"), -- S 0 Alchemy - new string'("IV <> Week of Shape"), -- D 7 Evelor - new string'("V <> Week of Sword"), -- A 0 Offense - new string'("VI <> Week of Necromancers"), -- S 12 Necromancy - new string'("VII <> Week of Fauna"), -- D 2 Sheila - new string'("VIII <> Week of Windmill"), -- S 20 Aerokinesis - new string'("IX <> Week of Guards"), -- S 13 Resistance - new string'("X <> Week of Blacksmiths"), -- R 3 Metal - new string'("XI <> Week of Archers"), -- S 1 Archery - new string'("XII <> Week of Bumblebee"), -- - -- - new string'("XIII <> Week of Sound"), -- D 8 Orohan - new string'("XIV <> Week of Water"), -- D 3 Iliona - new string'("XV <> Week of Bankers"), -- S 5 Estates - new string'("XVI <> Week of Wall"), -- S 21 Khousokinesis - new string'("XVII <> Week of Axolotl"), -- - -- - new string'("XVIII <> Week of Thaumaturgs"), -- S 17 Thaumaturgy - new string'("XIX <> Week of Stonecutters"), -- R 2 Stone - new string'("XX <> Week of Mole"), -- - -- - new string'("XXI <> Week of Shrine"), -- S 22 Phosokinesis - new string'("XXII <> Week of Logic"), -- D 6 Heneal - new string'("XXIII <> Week of Mystics"), -- S 11 Mysticism - new string'("XXIV <> Week of Diplomats"), -- S 4 Diplomacy - new string'("XXV <> Week of Boots"), -- A 4 Speed - new string'("XXVI <> Week of Shield"), -- A 1 Defense - new string'("XXVII <> Week of Advisors"), -- S 8 Logistics - new string'("XXVIII <> Week of Architects"), -- S 2 Architecture - new string'("XXIX <> Week of Flame"), -- D 5 Kanako - new string'("XXX <> Week of Spider"), -- - -- - new string'("XXXI <> Week of Value"), -- D 4 Uldrae - new string'("XXXII <> Week of Healers"), -- S 9 Medicine - new string'("XXXIII <> Week of Spear"), -- A 5 Reach - new string'("XXXIV <> Week of Gallows"), -- S 23 Eremnokinesis - new string'("XXXV <> Week of Leaders"), -- S 7 Leaderhsip - new string'("XXXVI <> Week of Skirmishers"), -- S 14 Skirmish - new string'("XXXVII <> Week of Lubmerjacks"), -- R 1 Wood - new string'("XXXVIII <> Week of Pathfinders"), -- S 3 Athletics - new string'("XXXIX <> Week of Frog"), -- - -- - new string'("XL <> Week of Stakes"), -- S 18 Pyrokinesis - new string'("XLI <> Week of Helmet"), -- A 2 Wisdom - new string'("XLII <> Week of Leatherers"), -- R 4 Leather - new string'("XLIII <> Week of Rat"), -- - -- - new string'("XLIV <> Week of Sorcerers"), -- S 15 Sorcery - new string'("XLV <> Week of Gloves"), -- A 3 Stamina - new string'("XLVI <> Week of Earth"), -- D 1 Mitena - new string'("XLVII <> Week of Explorers"), -- S 6 Exploration - new string'("XLVIII <> Week of Bridge"), -- S 19 Hydrokinesis - new string'("XLIX <> Week of Strategists"), -- S 16 Tactics - new string'("L <> Week of Gemologists"), -- R 5 Gem - new string'("LI <> Week of Merchants"), -- S 10 Mercantile - new string'("LII <> Week of Farce") -- D 9 Xorana (Osamu Dazai - The God of Farce) - ); - - day_name : constant array (1 .. 7) of access string := ( - new string'("I <> Day of Sun"), - new string'("II <> Day of Mother-Moon"), - new string'("III <> Day of Daughter-Moon"), - new string'("IV <> Day of All-Earth"), - new string'("V <> Day of All-Water"), - new string'("VI <> Day of All-Sky"), - new string'("VII <> Day of Deities") - ); - map : definition; show_unit_data : unit.enumeration := unit.none; @@ -216,7 +49,9 @@ package world is procedure configure; - procedure make (index : in biome; width, height, chad_limit : in natural); + function equipment_valid (data : in equipment.enumeration) return boolean; + + procedure make (index : in biome.enumeration; width, height, chad_limit : in natural); procedure save (file_name : in string); procedure load (file_name : in string);