Skip to content

Commit

Permalink
event naming consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed May 10, 2014
1 parent e2bd4b8 commit a65d480
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions doc/mobile-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ http --form POST en.l.org/setup/ai variant=1 clock=false time=60 increment=60 le
- color: white|black|random
- variant: 1 (standard) or 2 (chess960)

Response: `201 CREATED`
```javascript
{
"game": {
Expand Down Expand Up @@ -133,7 +134,7 @@ Each event has a version number `v`, a type `t` and data `d`.
"t": "b", // "b" is the batch type.
"d": [{
"v": 8, // message version
"t": "possible_moves", // list of moves you can play. Empty if not your turn to play.
"t": "possibleMoves", // list of moves you can play. Empty if not your turn to play.
"d": {
"b2": "b3b4", // from b2, you can either go on b3 or b4.
"e1": "e2",
Expand Down Expand Up @@ -171,7 +172,7 @@ Each event has a version number `v`, a type `t` and data `d`.
"d": null
}, {
"v": 12, // ignore that for now.
"t": "reload_table",
"t": "reloadTable",
"d": null
}, {
"v": 13 // some events may come empty. Just increment the client socket version.
Expand Down
10 changes: 5 additions & 5 deletions modules/game/src/main/Event.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ object Event {
case class PossibleMoves(
color: Color,
moves: Map[Pos, List[Pos]]) extends Event {
def typ = "possible_moves"
def typ = "possibleMoves"
def data =
if (moves.isEmpty) JsNull
else JsObject(moves map {
Expand Down Expand Up @@ -130,21 +130,21 @@ object Event {
}

object Threefold extends Empty {
def typ = "threefold_repetition"
def typ = "threefoldRepetition"
}

case class ReloadTable(color: Color) extends Event {
def typ = "reload_table"
def typ = "reloadTable"
def data = JsNull
override def only = Some(color)
}

case object ReloadTables extends Event {
def typ = "reload_table"
def typ = "reloadTable"
def data = JsNull
}
case object ReloadTablesOwner extends Event {
def typ = "reload_table"
def typ = "reloadTable"
def data = JsNull
override def owner = true
}
Expand Down
6 changes: 3 additions & 3 deletions modules/simulation/src/main/PlayerBot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ private[simulation] final class PlayerBot(
goto(RoundEnd)
}

case Event(Message("possible_moves", obj), player: Player) =>
case Event(Message("possibleMoves", obj), player: Player) =>
if (~getVersion(obj) <= player.v) {
log(s"skip possible_moves v ${getVersion(obj)} because at v ${player.v}")
log(s"skip possibleMoves v ${getVersion(obj)} because at v ${player.v}")
stay
}
else {
setVersion(obj)
maybe(1d / 200)(self ! Resign)
log("possible_moves: " + (obj obj "d"))
log("possibleMoves: " + (obj obj "d"))
// opponent move
if ((obj obj "d").isEmpty) {
val (_, nextPlayer) = player.nextMove
Expand Down
4 changes: 2 additions & 2 deletions public/javascripts/big.js
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ var storage = {
}, 400);
});
},
threefold_repetition: function() {
threefoldRepetition: function() {
self.element.queue(function() {
self.reloadTable(function() {
self.element.dequeue();
Expand Down Expand Up @@ -1055,7 +1055,7 @@ var storage = {
});
});
},
reload_table: function() {
reloadTable: function() {
self.element.queue(function() {
self.reloadTable(function() {
self.element.dequeue();
Expand Down
1 change: 1 addition & 0 deletions public/stylesheets/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,7 @@ a#sound_state.unavailable {
display: block;
max-height: 100px;
overflow-y: auto;
transition: all 0.1s;
}
#friend_box .content a:hover {
background: #F0F0F0;
Expand Down

0 comments on commit a65d480

Please sign in to comment.