Fixed tests. Need to check for damage from AI code

This commit is contained in:
2026-06-11 16:39:58 -06:00
parent df68358a2e
commit 6d2c2162f0
9 changed files with 149 additions and 78 deletions
+13 -12
View File
@@ -1,5 +1,5 @@
# Nathan Hinton 22 Dec 2025
# The main player file
# Represents a player in the game.
# Tracks resources, owned planets, ships, and researched technology.
require 'securerandom'
require 'yaml'
@@ -8,6 +8,9 @@ require 'yaml'
class Player
attr_accessor :player_resources, :player_id, :player_planets, :player_ships, :faction, :researched_tech, :buildings, :ship_build_power, :research_tech_build_power, :military_tech_build_power
# Create a new player. Default values are stored in the game_config.yaml file.
# @param player_id [String] An ID used to validate the player.
# @param faction [String] The faction that the player should start as. Should be \`good\` or \`evil\`
def initialize(player_id, faction)
@player_id = player_id
@player_planets = []
@@ -26,20 +29,12 @@ class Player
@faction = faction
end
# Create a new player. This is actually just setting it up. All the defaults
# are defined in the game_config.yaml file.
#
# @param credits [Integer] The number of starting credits
# @param metal [Integer] The amount of starting metal
# @param crystals [Integer] The amount of starting crystals
# @param fuel [Integer] The amount of fuel to start with.
# @param faction [String] The faction that the player should start as. Should be \`good\` or \`evil\`
def create_new(credits, metal, crystals, fuel)
def set_resources(credits, metal, crystals, fuel)
@player_resources = {
'credits' => credits,
'metal' => metal,
'crystals' => crystals,
'fuel' => fuel
'fuel' => fuel,
}
end
@@ -164,10 +159,16 @@ class Player
@military_tech_build_power = data[:military_tech_build_power] || 0
end
# Returns all buildings owned by the player.
# @return [Array<Building>] list of buildings.
def all_buildings
@buildings
end
# Returns all researched technology for the player.
# @return [Array<String>] list of researched tech.
def all_tech
@researched_tech
end