working on reimplimenting server

This commit is contained in:
2025-12-19 19:23:54 -07:00
parent 4737531805
commit 057164122a
20 changed files with 1145 additions and 6 deletions
+43
View File
@@ -0,0 +1,43 @@
# Nathan Hinton 19 Dec 2025
require 'securerandom'
# This defines the player class
class Player
attr_reader :name, :resources, :id
attr_accessor :home_planet
# initialize a player.
#
# @param name [String] The name of the player
def initialize(name: 'test player')
@name = name
@planets = []
@fleets = []
@tech = []
@resources = {
'metal' => 0,
'crystals' => 0,
'credits' => 0
}
# This id will be used to validate the player in the game
@id = SecureRandom.hex()
@id_retrieved = false
@home_planet = nil
end
# Returns the player ID. This *should* only be called once. When called again
# it should print a warning to the log.
#
# @return [String] The ID of the player
def get_id
if @id_retrieved
# Print a warning message!
end
@id_retrieved = true
return @id
end
end