diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-15 16:45:09 +0200 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-15 16:45:09 +0200 |
commit | eeb83ca379e7f4ab1a86596b80e206df48371454 (patch) | |
tree | 0f595308b7ba9077650e8a368b94ba75c5683c71 /src/main/scala/Model/Adventure.scala | |
parent | ea18a265a22ffc4c3f6ec3ca9d2f542552da9705 (diff) | |
download | scalevalapokalypsi-eeb83ca379e7f4ab1a86596b80e206df48371454.tar.gz scalevalapokalypsi-eeb83ca379e7f4ab1a86596b80e206df48371454.zip |
Added observations for Players in model & implemented sending them to other clients
Diffstat (limited to 'src/main/scala/Model/Adventure.scala')
-rw-r--r-- | src/main/scala/Model/Adventure.scala | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main/scala/Model/Adventure.scala b/src/main/scala/Model/Adventure.scala index 4d0a256..7d5a061 100644 --- a/src/main/scala/Model/Adventure.scala +++ b/src/main/scala/Model/Adventure.scala @@ -34,16 +34,18 @@ class Adventure(val playerNames: Vector[String]): "Problem is, there's no battery." )) - val players: Map[String, Entity] = Map() + val players: Map[String, Player] = Map() playerNames.foreach(this.addPlayer(_)) + val entities: Map[String, Entity] = Map() + /** Adds a player entity with the specified name to the game. * * @param name the name of the player entity to add * @return the created player entity */ - def addPlayer(name: String): Entity = - val newPlayer = Entity(name, middle) + def addPlayer(name: String): Player = + val newPlayer = Player(name, middle) middle.addEntity(newPlayer) players += name -> newPlayer newPlayer @@ -53,7 +55,7 @@ class Adventure(val playerNames: Vector[String]): * @param name name of the player to find * @return the player, if one with the name was found */ - def getPlayer(name: String): Option[Entity] = this.players.get(name) + def getPlayer(name: String): Option[Player] = this.players.get(name) /** Returns a message that is to be displayed to the player at the beginning of the game. */ def welcomeMessage = "Generic welcome message" |