Pushing all changes
This commit is contained in:
+12
-1
@@ -3,12 +3,23 @@
|
||||
|
||||
# Class for the player. For now does not do much.
|
||||
class Player
|
||||
attr_reader :name
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user