Browse files

Corrected alert messages

  • Loading branch information...
1 parent 6e47a8a commit 618e5e244899c1cbf46e9cab6d715775842f699f @mg50 committed Mar 19, 2012
Showing with 27 additions and 6 deletions.
  1. +1 −0 src/javattt/Game.java
  2. +2 −0 src/javattt/fsm/Play3x3State.java
  3. +13 −6 src/server/httpgame.rb
  4. +11 −0 test/server/httpgame_spec.rb
View
1 src/javattt/Game.java
@@ -79,6 +79,7 @@ public void onSuccessfulMove(int[] coords) {}
public void onReceivingPlayVsAI() {}
public void onHalt() {}
public void onReceivingPlayAsX() {}
+ public void onPlay3x3() {}
public void onGameOver(Side victor) {}
public void onRestart() {}
public boolean readyForGameStart() {
View
2 src/javattt/fsm/Play3x3State.java
@@ -23,11 +23,13 @@ public Command readNextCommand() {
public void yes() {
game.board = new Board(3);
+ game.onPlay3x3();
game.state = new BeginningGameState(game);
}
public void no() {
game.board = new Board(4);
+ game.onPlay3x3();
game.state = new BeginningGameState(game);
}
}
View
19 src/server/httpgame.rb
@@ -76,14 +76,14 @@ def remove_player(player)
self.client_player = nil
if self.masterPlayer
- self.masterPlayer.alert_message "The game owner has left the game."
self.receive_signal self.masterPlayer, "RESTART"
+ self.masterPlayer.alert_message "The game owner has left the game."
end
elsif player == self.client_player
if two_player? and self.state.is_a? MoveState
- self.masterPlayer.alert_message "Your opponent has left the game."
self.receive_signal self.masterPlayer, "RESTART"
+ self.masterPlayer.alert_message "Your opponent has left the game."
end
self.client_player = nil
@@ -165,16 +165,23 @@ def two_player?
end
def onNewGame
- #self.masterPlayer.alert_message nil if self.masterPlayer
- #self.masterPlayer.wait_message nil if self.masterPlayer
- #waiting_for_second_player = false
+ self.masterPlayer.alert_message nil if self.masterPlayer
+ self.masterPlayer.wait_message nil if self.masterPlayer
+ waiting_for_second_player = false
+ end
+
+ def onRestart
+ if client_player
+ client_player.alert_message "Your opponent has restarted the game."
+ end
end
def readyForGameStart
return true unless two_player?
if not client_player
- self.masterPlayer.wait_message "Waiting for second player to join."
+ self.masterPlayer.wait_message "Waiting for second player to join. " +
+ "(Send the URL to another person to invite him to the game)."
return false
else
self.masterPlayer.wait_message nil
View
11 test/server/httpgame_spec.rb
@@ -265,6 +265,17 @@
game.board.getCell(1, 1).should == Side._
end
+ it "alerts a player if the game owner restarts" do
+ p1 = HTTPPlayer[{:session_id => 1}]
+ p2 = HTTPPlayer[{:session_id => 2}]
+ game = HTTPGame["room"]
+ game.add_player p1
+ game.add_player p2
+
+ game.receive_signal p1, "RESTART"
+ p2.ui.alert_message.should_not be_nil
+ end
+
# it "returns valid JSON about its state" do
# time = Time.now.to_i
# game = HTTPGame.new

0 comments on commit 618e5e2

Please sign in to comment.