blob: 6e82837fe838e38d5c245c0507613ef3bf11566d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
|