Currently, the command parser has some wonky type polymorphism going on. Scala has very advanced support for a variety of different paradigms. The following changes are probably desirable:
1) Allowing commands to specify what type their source should be, as long as it is a child of GameEntity (so ex. 'Command[Mob]' leading to a source argument in go() that is a Mob)
2) Preventing CommandComponent's type information from being erased.
However, its not strictly necessary right now. But it leads to ugly code such as:
def go(source: GameEntity, args: Seq[Any]) {
source match {
case m: Mob =>
m.attemptMove("north", Some("the north"))
case _ =>
}
}
Currently, the command parser has some wonky type polymorphism going on. Scala has very advanced support for a variety of different paradigms. The following changes are probably desirable:
1) Allowing commands to specify what type their source should be, as long as it is a child of GameEntity (so ex. 'Command[Mob]' leading to a source argument in go() that is a Mob) 2) Preventing CommandComponent's type information from being erased.
However, its not strictly necessary right now. But it leads to ugly code such as:
def go(source: GameEntity, args: Seq[Any]) { source match { case m: Mob => m.attemptMove("north", Some("the north")) case _ => } }