ctf-server
old server for hosting capture-the-flag
git clone https://9o.is/git/ctf-server.git
commit f9b6e667fc94e2c35ecc94e7301882a71d754c2a parent a7368236b0337c10458bd482034e3cd1f0cfa1bc Author: Jul <jul@9o.is> Date: Sat, 7 Dec 2013 19:02:39 -0500 fixed runtime overflow error Diffstat:
| M | src/main/scala/com/jcabrra/model/User.scala | | | 7 | ++++--- |
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/main/scala/com/jcabrra/model/User.scala b/src/main/scala/com/jcabrra/model/User.scala @@ -77,7 +77,9 @@ class User extends MegaProtoUser[User] with ManyToMany { /* The least amount of challenges needed to win */ def howManyToWin(flags: List[Flag] = Nil, nodesAway: Int = -1): Int = - if(flags.exists(f => capturedFlags.exists(_.id == f.id))) + if(capturedFlags.isEmpty) + Flag.findAll.size + else if(flags.exists(f => capturedFlags.exists(_.id == f.id))) nodesAway else { val prevFlags = @@ -87,4 +89,4 @@ class User extends MegaProtoUser[User] with ManyToMany { howManyToWin(prevFlags, nodesAway + 1) } -} -\ No newline at end of file +}