Permalink
Browse files

v1.2 (2009-10-06) - Created a chime for when it's a human player's tu…

…rn but

  the last turn was started over 6 seconds ago. There is currently no way to
  disable it, wait for 1.2.1!
  • Loading branch information...
audiodude committed Oct 6, 2009
1 parent ed091a4 commit 828915ece120931fad027af05fb4e33b0abd53fa
Showing with 28 additions and 1 deletion.
  1. +3 −0 README
  2. +10 −1 main_controller.rb
  3. +15 −0 main_frame.rb
  4. BIN resources/your_turn.wav
View
3 README
@@ -16,6 +16,9 @@ THANKS:
permission for anyone to code it!
CHANGES:
+1.2 (2009-10-06) - Created a chime for when it's a human player's turn but
+ the last turn was started over 6 seconds ago. There is currently no way to
+ disable it, wait for 1.2.1!
1.1 (2009-10-01) - Visual refresh. White pieces are now white, and all
pieces are bigger. Red dot on the last placed piece.
View
@@ -26,14 +26,15 @@ class MainController
# The controller observes the gameboard, and everyone else observes the controller
include Observable
- attr_reader :roots
+ attr_reader :roots, :last_turn_time
attr_accessor :player1, :player2
RUN = 1
PAUSE = 0
STOP = nil
BOARD_READY_EVENT = -33
+ TURN_CHANGE_READY_EVENT = -58
def initialize
@run_mutex = Mutex.new
@@ -45,6 +46,8 @@ def initialize
def reset!
# The game board is a 19x19 2D grid of intersections (a Go board)
@gameboard = TanboBoard.new
+
+ @last_turn_time = 0
@gameboard.add_observer(self)
@@ -98,8 +101,14 @@ def start!
next
end
+ changed
+ notify_observers(TURN_CHANGE_READY_EVENT)
if @gameboard.turn == TanboBoard::BLACK
+ start_time = Time.new.to_f
next_move = @player1.move(@gameboard, last_move)
+ end_time = Time.new.to_f
+
+ @last_turn_time = end_time - start_time
else
next_move = @player2.move(@gameboard, last_move)
end
View
@@ -40,6 +40,8 @@ def initialize(controller)
self.set_min_size([450,550])
+ @snd_your_turn = Sound.new('./resources/your_turn.wav')
+
@sizer = Wx::BoxSizer.new(VERTICAL)
@board = BoardPanel.new(self, @controller)
@@ -159,6 +161,19 @@ def update(event)
@waiting_to_select_ai = false
end
end
+ when MainController::TURN_CHANGE_READY_EVENT
+ if ( # See if it is now a human's turn
+ ( @controller.get_board.turn == TanboBoard::BLACK &&
+ @player1.is_a?(HumanPlayer) ) ||
+ ( @controller.get_board.turn == TanboBoard::WHITE &&
+ @player2.is_a?(HumanPlayer) )
+ )
+ if @controller.last_turn_time > 6 # We've waited more than 6 seconds
+ @snd_your_turn.play(SOUND_ASYNC) if @snd_your_turn.is_ok
+ else
+ puts @controller.last_turn_time
+ end
+ end
end
end
View
Binary file not shown.

0 comments on commit 828915e

Please sign in to comment.