From 5060c66738898913ca880d83b0fdcd5be2e0b59d Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sun, 17 Nov 2024 14:19:58 +0200 Subject: Small style fixes (mostly shortening comment lines written by others...) --- src/scalevalapokalypsi/Model/Entities/Player.scala | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/scalevalapokalypsi/Model/Entities/Player.scala (limited to 'src/scalevalapokalypsi/Model/Entities/Player.scala') 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 -- cgit v1.2.3