diff options
Diffstat (limited to 'src/scalevalapokalypsi/Model/Entities/Player.scala')
-rw-r--r-- | src/scalevalapokalypsi/Model/Entities/Player.scala | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/scalevalapokalypsi/Model/Entities/Player.scala b/src/scalevalapokalypsi/Model/Entities/Player.scala new file mode 100644 index 0000000..6e82837 --- /dev/null +++ b/src/scalevalapokalypsi/Model/Entities/Player.scala @@ -0,0 +1,27 @@ +package scalevalapokalypsi.Model.Entities + +import scala.collection.mutable.Buffer +import scalevalapokalypsi.Model.* + +/** A `Player` object represents a player character controlled by one real-life player + * of the program. + * + * A player object’s state is mutable: the player’s location and possessions can change, + * for instance. + * + * @param name the player's name + * @param initialLocation the player’s initial location + */ +class Player(name: String, initialLocation: Area) extends Entity(name, initialLocation): + + private val observations: Buffer[String] = Buffer.empty + + override def observe(observation: String): Unit = + this.observations.append(observation) + + def readAndClearObservations(): Vector[String] = + val res = this.observations.toVector + observations.clear() + res + +end Player |