26 lines
584 B
Ruby
26 lines
584 B
Ruby
# Nathan Hinton 2 Oct 2025
|
|
|
|
|
|
# Class for the player. For now does not do much.
|
|
class Player
|
|
attr_reader :name, :resources
|
|
|
|
# initializes with just the player name.
|
|
#
|
|
# @param name [String] The name of the player
|
|
def initialize(name)
|
|
@name = name
|
|
@resources = {:ships => 10, :metal => 100}
|
|
end
|
|
|
|
def add_resources(resources)
|
|
resources.keys.each do |resource_key|
|
|
if @resources[resource_key].nil?
|
|
@resources[resource_key] = resources[resource_key]
|
|
else
|
|
@resources[resource_key] += resources[resource_key]
|
|
end
|
|
end
|
|
end
|
|
end
|