alathon / AwesomeMUD

An awesome MUD in Scala
1 stars 1 forks source link

Fix type issues in command parser #11

Open alathon opened 10 years ago

alathon commented 10 years ago

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 _ => } }

alathon commented 10 years ago

See http://twitter.github.io/scala_school/type-basics.html f.ex