Created
February 17, 2014 18:28
-
-
Save anonymous/9056223 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Id[T](var id:Int) { | |
override def toString = "id:"+this.id.toString | |
def == (other: Id[T]) : Boolean = toString == other.toString | |
} | |
object Id { | |
private var _v: Int = 0 | |
def apply[T](): Id[T] = { | |
_v += 1 | |
return new Id[T](_v) | |
} | |
} | |
trait Entity[T] { | |
val id = Id[T] | |
} | |
abstract class Job( | |
) { | |
val jobId = Id[Job] | |
} | |
class Status( | |
val str:Int, | |
val int:Int, | |
val dex:Int | |
) | |
object Job { | |
case object Knight extends Job() | |
case object Rogue extends Job() | |
case object Wizard extends Job() | |
} | |
class Actor ( | |
val name: String, | |
val status: Status, | |
val job: Job | |
) extends Entity[Actor] | |
class Party( | |
val actors: List[Actor] | |
) extends Entity[Party] | |
class BattleSession( | |
val parties: List[Party] | |
) extends Entity[BattleSession]{ | |
def init = { | |
//... | |
} | |
def process = { | |
//... | |
} | |
} | |
val players = new Party( | |
actors = List( | |
new Actor ( | |
name = "mizchi", | |
status = new Status(10,10,10), | |
job = Job.Knight), | |
new Actor ( | |
name = "bob", | |
status = new Status(10,11,11), | |
job = Job.Rogue), | |
new Actor ( | |
name = "Chik", | |
status = new Status(10,11,16), | |
job = Job.Wizard) | |
) | |
) | |
val enemies = new Party( | |
actors = List( | |
new Actor ( | |
name = "goblin1", | |
status = new Status(5,4,6), | |
job = Job.Rogue), | |
new Actor ( | |
name = "globin2", | |
status = new Status(5,5,5), | |
job = Job.Rogue) | |
) | |
) | |
var session = new BattleSession(List(players, enemies)) | |
session.process | |
println( | |
session | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment