diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-17 14:19:58 +0200 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-17 14:20:27 +0200 |
commit | 5060c66738898913ca880d83b0fdcd5be2e0b59d (patch) | |
tree | bd4ecd70ebb8cc0342bd0a29c91c5b27fed38fb6 /src/scalevalapokalypsi/Model/Entities/Player.scala | |
parent | 4de67b497e0e229fe4a42f66f833640b6e50fd5a (diff) | |
download | scalevalapokalypsi-5060c66738898913ca880d83b0fdcd5be2e0b59d.tar.gz scalevalapokalypsi-5060c66738898913ca880d83b0fdcd5be2e0b59d.zip |
Small style fixes (mostly shortening comment lines written by others...)
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 |