Skip to content

Commit

Permalink
add some Status functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Sep 4, 2012
1 parent 56b2604 commit 6fc6095
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/scala/Status.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package chess
sealed abstract class Status(val id: Int) extends Ordered[Status] {

def compare(other: Status) = id compare other.id

def name = toString
}

object Status {
Expand All @@ -20,6 +22,10 @@ object Status {

val all = List(Created, Started, Aborted, Mate, Resign, Stalemate, Timeout, Draw, Outoftime, Cheat)

val finishedNotCheated = all filter { s
s.id >= Mate.id && s.id < Cheat.id
}

val byId = all map { v (v.id, v) } toMap

def apply(id: Int): Option[Status] = byId get id
Expand Down

0 comments on commit 6fc6095

Please sign in to comment.