Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/activity.py
diff options
context:
space:
mode:
Diffstat (limited to 'activity.py')
-rw-r--r--activity.py489
1 files changed, 243 insertions, 246 deletions
diff --git a/activity.py b/activity.py
index 2868d62..7c283d5 100644
--- a/activity.py
+++ b/activity.py
@@ -56,6 +56,11 @@ class PlayGo(Activity):
self.script = ["", "This is the main board for a game of Go.", "There are three different board sizes to choose from; 9 x 9, 13 x 13, and 19 x 19.", "This game is played by placing stones down on the board.", "One person has black stones, and the other has white stones.", "To place a stone, move your mouse to the where you want to put the stone and click.", "Territories are created when you place stones of your color near other stones.", "If empty places on the board are surrounded by your pieces alone, then it counts as your territory.", "Scoring is based on a lot of different things.", "During the game, your score increases based on the amount of pieces you capture that are your opponents.", "When the game ends, territory is also added to these scores.", "A liberty is when there is a blank space next to one of your pieces.", "In this example, the black piece has four liberties.", "Those liberties are shown by the four squares around the piece.", "At one time, a piece can only have four liberties.", "To capture an opponents piece, it must have no more liberties.", "In this example, the black piece would be captured if white placed a piece where the triangle is.", "This would give white one point.", "Seki is a situation where both players share liberties.", "In this example, the black and white pieces share the two liberties that have circles in them.", "It is recommended for neither player to place pieces in those spots, because the other opponent could then capture the other player's pieces.", "Ko is a situation which prevents a game from going on forever.", "The example above shows a normal ko situation.", "If white were to place a piece where the X is, then it would capture the black piece.", "Black can't place a piece back in the same place though, since it would allow black and white capture the same pieces over and over.", "Superko is similar to ko, but on a larger scale.", "The superko rule states that the board can't be brought back to a previous position.", "This can happen when there is many ko's on the board, and players could keep capturing them forever.", "In the example above, there are two ko's that could be captured over and over, causing a superko.", "Life and death are important things to consider in Go.", "When some of your pieces become surrounded, then they are considered to be dead.", "This is because they could be captured at any time.", "It is important to know when a group of pieces are dead, since it will let you place pieces where they may be more useful.", "A ko fight is when two players challenge each other with their kos.", "When fighting, they will place pieces that will give them advantage as long as the opponent doesn't stop them.", "In this example, a white piece was taken where the circle was.", "During white's turn they then place the white piece with the x, which gives the black player a choice.", "They can either place a spot where the circle is, or stop the white player from having territory that won't be capturable.", "Semeai, or \"Capture Race\", is when there is a mutual capturing contest between the two players.", "These situations are usually won by whomever moves first in the race, since they tend to involve the same amount of moves on both sides.", "The current board is a common example of semeai.", "Sente and gote are terms for who has initiative at a current time.", "Sente means that you are making the first move, which the opponent may then have to respond to.", "Gote is the direct opposite, where you have to play a piece in respose to your opponent's move.", "In this example, black has played at x in sente.", "This places white in gote, where they must respond where the circle is or they will lose their pieces eventually.", "It's important to know when you have initiative in the game, since it will commonly exchange between the players.", "Maintaining sente and keeping out of gote will give you a higher chance of winning, since you will be able to make your opponent play where you want them to play.", "The game ends with both players have passed in the same turn.", "When that happens, each player's score is settled.", "First, the pieces that were captured by each player are counted.", "Then, the score of each player's territories are added to their scores.", "Finally, the komi (a point handicap given for playing second) is added to the white player.", "Whomever has the higher score after this is the winner!"]
self.next_script_frame = [0,1,3,6,8,11,15,18,21,25,29,33,38,41,48]
+
+ self.is_editing = 0
+ self.edit_type = 0
+ self.edit_status = { }
+
# Set the activity toolbox
toolbox = ActivityToolbox(self)
self.set_toolbox(toolbox)
@@ -80,8 +85,7 @@ class PlayGo(Activity):
# Set the editor toolbox
self.editToolbar = EditToolbar(self)
toolbox.add_toolbar(_('Editor'), self.editToolbar)
- self.editToolbar.connect('add-black', self.add_black_cb)
- self.editToolbar.connect('add-white', self.add_white_cb)
+ self.editToolbar.connect('edit', self.edit_cb)
self.editToolbar.connect('add-x', self.add_x_cb)
self.editToolbar.connect('add-circle', self.add_circle_cb)
self.editToolbar.connect('add-triangle', self.add_triangle_cb)
@@ -102,6 +106,10 @@ class PlayGo(Activity):
self.tutorialToolbar.grey_out_previous()
self.tutorialToolbar.grey_out_next()
self.tutorialToolbar.grey_out_category()
+ self.editToolbar.grey_out_add_x()
+ self.editToolbar.grey_out_add_triangle()
+ self.editToolbar.grey_out_add_circle()
+ self.editToolbar.grey_out_add_square()
if not handle.object_id:
self.infopanel.show(_('Welcome to PlayGo!'))
@@ -180,58 +188,191 @@ class PlayGo(Activity):
self.show_all()
def insert_cb(self, widget, x, y, announce=True, ai_play=False):
- ''' The insert function. It makes the play and manages turn changing
- stone drawing, etc.
+
+ if self.is_editing == 0:
+ ''' The insert function. It makes the play and manages turn changing
+ stone drawing, etc.
- Parameters x and y are the coordinates of the play ((0,0) is top left),
- widget points to the widget that emitted the signal connected to this
- function, announce is True when we need to announce this play to
- other people collaborating, and ai_play is True when this is called
- by the AI, so we know not to ask for an AI play again '''
-
- # Check if it's our turn only if it's a local play (announce is True)
- # Calls by other players will always be out of turn for us.
- if announce and self.get_currentcolor() != self.get_playercolor():
- logger.debug('Play at %s x %s was out-of-turn!', x, y)
- self.infopanel.show(_('It\'s not your turn!'))
- return False
- # Make the play only if it wasn't a pass move.
- if x != -1:
- self.pass_count = 0
- error = self.game.illegal(x, y, self.get_currentcolor())
- if error:
- self.infopanel.show(error)
+ Parameters x and y are the coordinates of the play ((0,0) is top left),
+ widget points to the widget that emitted the signal connected to this
+ function, announce is True when we need to announce this play to
+ other people collaborating, and ai_play is True when this is called
+ by the AI, so we know not to ask for an AI play again '''
+
+
+
+ # Check if it's our turn only if it's a local play (announce is True)
+ # Calls by other players will always be out of turn for us.
+ if announce and self.get_currentcolor() != self.get_playercolor():
+ logger.debug('Play at %s x %s was out-of-turn!', x, y)
+ self.infopanel.show(_('It\'s not your turn!'))
return False
- # Make the play
- captures = self.game.play((x, y), self.get_currentcolor())
- if self.ai_activated and not ai_play:
- self.notify_ai(x, y, self.get_currentcolor())
- self.gameToolbar.grey_out_size_change()
- if captures: self.redraw_captures(captures)
- self.show_score()
- self.board.draw_stone(x, y, self.get_currentcolor(), widget)
- # Player passed
+ # Make the play only if it wasn't a pass move.
+ if x != -1:
+ self.pass_count = 0
+ error = self.game.illegal(x, y, self.get_currentcolor())
+ if error:
+ self.infopanel.show(error)
+ return False
+ # Make the play
+ captures = self.game.play((x, y), self.get_currentcolor())
+ if self.ai_activated and not ai_play:
+ self.notify_ai(x, y, self.get_currentcolor())
+ self.gameToolbar.grey_out_size_change()
+ if captures: self.redraw_captures(captures)
+ self.show_score()
+ self.board.draw_stone(x, y, self.get_currentcolor(), widget)
+ # Player passed
+ else:
+ self.pass_count += 1
+ # Announce the local play
+ if self.get_shared() and announce:
+ self.collaboration.Play(x, y)
+ self.change_turn()
+ if x == -1:
+ self.infopanel.show(_('Opponent passed'))
+ # If this is the second consecutive pass, the game ends
+ if self.pass_count == 2:
+ self.game_end()
+ return
+ # If we are playing a local game with AI turned off, change the color
+ if not self.get_shared() and not self.ai_activated:
+ self.change_player_color()
+ # Else, if the AI is on, and this wasn't played by it, request a play by it.
+ elif self.ai_activated:
+ self.change_player_color()
+ if not ai_play:
+ self.play_ai()
+
+ self.edit_status = self.game.status
else:
- self.pass_count += 1
- # Announce the local play
- if self.get_shared() and announce:
- self.collaboration.Play(x, y)
- self.change_turn()
- if x == -1:
- self.infopanel.show(_('Opponent passed'))
- # If this is the second consecutive pass, the game ends
- if self.pass_count == 2:
- self.game_end()
- return
- # If we are playing a local game with AI turned off, change the color
- if not self.get_shared() and not self.ai_activated:
- self.change_player_color()
- # Else, if the AI is on, and this wasn't played by it, request a play by it.
- elif self.ai_activated:
- self.change_player_color()
- if not ai_play:
- self.play_ai()
+ if self.edit_type == 0:
+ if not self.board.status.has_key((x, y)):
+ self.board.status[(x,y)] = 'X'
+ elif self.board.status[(x,y)] == 'B':
+ self.board.status[(x,y)] = 'E'
+ elif self.board.status[(x,y)] == 'W':
+ self.board.status[(x,y)] = 'F'
+ elif self.board.status[(x,y)] == 'X':
+ del self.board.status[(x,y)]
+ elif self.board.status[(x,y)] == 'T':
+ self.board.status[(x,y)] = 'X'
+ elif self.board.status[(x,y)] == 'C':
+ self.board.status[(x,y)] = 'X'
+ elif self.board.status[(x,y)] == 'S':
+ self.board.status[(x,y)] = 'X'
+ elif self.board.status[(x,y)] == 'E':
+ self.board.status[(x,y)] = 'B'
+ elif self.board.status[(x,y)] == 'F':
+ self.board.status[(x,y)] = 'W'
+ elif self.board.status[(x,y)] == 'G':
+ self.board.status[(x,y)] = 'E'
+ elif self.board.status[(x,y)] == 'H':
+ self.board.status[(x,y)] = 'F'
+ elif self.board.status[(x,y)] == 'I':
+ self.board.status[(x,y)] = 'E'
+ elif self.board.status[(x,y)] == 'J':
+ self.board.status[(x,y)] = 'F'
+ elif self.board.status[(x,y)] == 'K':
+ self.board.status[(x,y)] = 'E'
+ else:
+ self.board.status[(x,y)] = 'F'
+ elif self.edit_type == 2:
+ if not self.board.status.has_key((x, y)):
+ self.board.status[(x,y)] = 'T'
+ elif self.board.status[(x,y)] == 'B':
+ self.board.status[(x,y)] = 'G'
+ elif self.board.status[(x,y)] == 'W':
+ self.board.status[(x,y)] = 'H'
+ elif self.board.status[(x,y)] == 'X':
+ self.board.status[(x,y)] = 'T'
+ elif self.board.status[(x,y)] == 'T':
+ del self.board.status[(x,y)]
+ elif self.board.status[(x,y)] == 'C':
+ self.board.status[(x,y)] = 'T'
+ elif self.board.status[(x,y)] == 'S':
+ self.board.status[(x,y)] = 'T'
+ elif self.board.status[(x,y)] == 'E':
+ self.board.status[(x,y)] = 'G'
+ elif self.board.status[(x,y)] == 'F':
+ self.board.status[(x,y)] = 'H'
+ elif self.board.status[(x,y)] == 'G':
+ self.board.status[(x,y)] = 'B'
+ elif self.board.status[(x,y)] == 'H':
+ self.board.status[(x,y)] = 'W'
+ elif self.board.status[(x,y)] == 'I':
+ self.board.status[(x,y)] = 'G'
+ elif self.board.status[(x,y)] == 'J':
+ self.board.status[(x,y)] = 'H'
+ elif self.board.status[(x,y)] == 'K':
+ self.board.status[(x,y)] = 'G'
+ else:
+ self.board.status[(x,y)] = 'H'
+ elif self.edit_type == 1:
+ if not self.board.status.has_key((x, y)):
+ self.board.status[(x,y)] = 'C'
+ elif self.board.status[(x,y)] == 'B':
+ self.board.status[(x,y)] = 'I'
+ elif self.board.status[(x,y)] == 'W':
+ self.board.status[(x,y)] = 'J'
+ elif self.board.status[(x,y)] == 'X':
+ self.board.status[(x,y)] = 'C'
+ elif self.board.status[(x,y)] == 'T':
+ self.board.status[(x,y)] = 'C'
+ elif self.board.status[(x,y)] == 'C':
+ del self.board.status[(x,y)]
+ elif self.board.status[(x,y)] == 'S':
+ self.board.status[(x,y)] = 'C'
+ elif self.board.status[(x,y)] == 'E':
+ self.board.status[(x,y)] = 'I'
+ elif self.board.status[(x,y)] == 'F':
+ self.board.status[(x,y)] = 'J'
+ elif self.board.status[(x,y)] == 'G':
+ self.board.status[(x,y)] = 'I'
+ elif self.board.status[(x,y)] == 'H':
+ self.board.status[(x,y)] = 'J'
+ elif self.board.status[(x,y)] == 'I':
+ self.board.status[(x,y)] = 'B'
+ elif self.board.status[(x,y)] == 'J':
+ self.board.status[(x,y)] = 'W'
+ elif self.board.status[(x,y)] == 'K':
+ self.board.status[(x,y)] = 'I'
+ else:
+ self.board.status[(x,y)] = 'J'
+ else:
+ if not self.board.status.has_key((x, y)):
+ self.board.status[(x,y)] = 'S'
+ elif self.board.status[(x,y)] == 'B':
+ self.board.status[(x,y)] = 'K'
+ elif self.board.status[(x,y)] == 'W':
+ self.board.status[(x,y)] = 'L'
+ elif self.board.status[(x,y)] == 'X':
+ self.board.status[(x,y)] = 'S'
+ elif self.board.status[(x,y)] == 'T':
+ self.board.status[(x,y)] = 'S'
+ elif self.board.status[(x,y)] == 'C':
+ self.board.status[(x,y)] = 'S'
+ elif self.board.status[(x,y)] == 'S':
+ del self.board.status[(x,y)]
+ elif self.board.status[(x,y)] == 'E':
+ self.board.status[(x,y)] = 'K'
+ elif self.board.status[(x,y)] == 'F':
+ self.board.status[(x,y)] = 'L'
+ elif self.board.status[(x,y)] == 'G':
+ self.board.status[(x,y)] = 'K'
+ elif self.board.status[(x,y)] == 'H':
+ self.board.status[(x,y)] = 'L'
+ elif self.board.status[(x,y)] == 'I':
+ self.board.status[(x,y)] = 'K'
+ elif self.board.status[(x,y)] == 'J':
+ self.board.status[(x,y)] = 'L'
+ elif self.board.status[(x,y)] == 'K':
+ self.board.status[(x,y)] = 'B'
+ else:
+ self.board.status[(x,y)] = 'W'
+ self.board.do_expose_event()
+
def undo_cb(self, widget=None, data=None):
if self.game.undo():
self.board.queue_draw()
@@ -354,6 +495,7 @@ class PlayGo(Activity):
self.CurrentColor = 'B'
self.PlayerColor = 'B'
self.pass_count = 0
+ self.edit_status = { }
self.game.clear()
self.board.territories = None
self.board.status = self.game.status
@@ -366,6 +508,13 @@ class PlayGo(Activity):
self.tutorialToolbar.grey_out_next()
self.tutorialToolbar.grey_out_category()
self.tutorialToolbar.activate_begin()
+ self.editToolbar.activate_edit()
+ self.editToolbar.grey_out_add_x()
+ self.editToolbar.grey_out_add_square()
+ self.editToolbar.grey_out_add_circle()
+ self.editToolbar.grey_out_add_triangle()
+ self.editToolbar.activate_save()
+ self.editToolbar.activate_load()
self.gameToolbar.activate_size_change()
self.gameToolbar.activate_ai()
self.current_tutorial = 0;
@@ -486,6 +635,13 @@ class PlayGo(Activity):
self.tutorialToolbar.activate_previous()
self.tutorialToolbar.activate_next()
self.tutorialToolbar.activate_category()
+ self.editToolbar.grey_out_edit()
+ self.editToolbar.grey_out_add_x()
+ self.editToolbar.grey_out_add_square()
+ self.editToolbar.grey_out_add_circle()
+ self.editToolbar.grey_out_add_triangle()
+ self.editToolbar.grey_out_save()
+ self.editToolbar.grey_out_load()
self.infopanel.show(self.script[0])
@@ -507,178 +663,6 @@ class PlayGo(Activity):
self.board.set_sensitive(False)
self.buttons_box.set_sensitive(False)
self.board.territories = None
- if self.current_tutorial == 1:
- self.game.clear()
- elif self.current_tutorial == 3:
- self.game.clear()
- elif self.current_tutorial == 6:
- self.game.clear()
- self.game.status[(7,0)] = 'B'
- self.game.status[(8,1)] = 'B'
- self.game.status[(9,1)] = 'B'
- self.game.status[(10,1)] = 'B'
- self.game.status[(11,1)] = 'B'
- self.game.status[(12,0)] = 'B'
- self.game.status[(0,7)] = 'B'
- self.game.status[(0,1)] = 'W'
- self.game.status[(1,2)] = 'W'
- self.game.status[(1,3)] = 'W'
- self.game.status[(1,4)] = 'W'
- self.game.status[(1,5)] = 'W'
- self.game.status[(1,6)] = 'W'
- elif self.current_tutorial == 8:
- self.game.status = self.game.status
- elif self.current_tutorial == 11:
- self.game.clear()
- self.game.status[(11,4)] = 'B'
- self.game.status[(10,4)] = 'S'
- self.game.status[(12,4)] = 'S'
- self.game.status[(11,3)] = 'S'
- self.game.status[(11,5)] = 'S'
- elif self.current_tutorial == 15:
- self.game.clear()
- self.game.status[(9,3)] = 'B'
- self.game.status[(8,4)] = 'B'
- self.game.status[(15,9)] = 'B'
- self.game.status[(15,10)] = 'B'
- self.game.status[(8,3)] = 'W'
- self.game.status[(8,5)] = 'W'
- self.game.status[(9,4)] = 'W'
- self.game.status[(7,4)] = 'T'
- elif self.current_tutorial == 18:
- self.game.clear()
- self.game.status[(8,2)] = 'B'
- self.game.status[(9,1)] = 'B'
- self.game.status[(9,0)] = 'B'
- self.game.status[(7,0)] = 'W'
- self.game.status[(7,1)] = 'W'
- self.game.status[(7,2)] = 'W'
- self.game.status[(8,0)] = 'C'
- self.game.status[(8,1)] = 'C'
- elif self.current_tutorial == 21:
- self.game.clear()
- self.game.status[(9,9)] = 'B'
- self.game.status[(10,8)] = 'B'
- self.game.status[(10,10)] = 'B'
- self.game.status[(11,9)] = 'B'
- self.game.status[(9,8)] = 'W'
- self.game.status[(9,10)] = 'W'
- self.game.status[(8,9)] = 'W'
- self.game.status[(10,9)] = 'X'
- elif self.current_tutorial == 25:
- self.game.clear()
- self.game.status[(9,9)] = 'B'
- self.game.status[(10,8)] = 'B'
- self.game.status[(10,10)] = 'B'
- self.game.status[(11,9)] = 'B'
- self.game.status[(9,12)] = 'B'
- self.game.status[(9,14)] = 'B'
- self.game.status[(8,13)] = 'B'
- self.game.status[(9,8)] = 'W'
- self.game.status[(9,10)] = 'W'
- self.game.status[(8,9)] = 'W'
- self.game.status[(9,13)] = 'W'
- self.game.status[(10,12)] = 'W'
- self.game.status[(10,14)] = 'W'
- self.game.status[(11,13)] = 'W'
- elif self.current_tutorial == 29:
- self.game.clear()
- self.game.status[(7,0)] = 'B'
- self.game.status[(8,0)] = 'B'
- self.game.status[(8,1)] = 'B'
- self.game.status[(9,0)] = 'B'
- self.game.status[(9,1)] = 'B'
- self.game.status[(9,2)] = 'B'
- self.game.status[(10,1)] = 'B'
- self.game.status[(10,2)] = 'B'
- self.game.status[(11,0)] = 'B'
- self.game.status[(11,1)] = 'B'
- self.game.status[(12,0)] = 'B'
- self.game.status[(6,0)] = 'W'
- self.game.status[(7,1)] = 'W'
- self.game.status[(7,2)] = 'W'
- self.game.status[(8,3)] = 'W'
- self.game.status[(9,3)] = 'W'
- self.game.status[(10,3)] = 'W'
- self.game.status[(11,2)] = 'W'
- self.game.status[(12,2)] = 'W'
- self.game.status[(12,1)] = 'W'
- self.game.status[(13,1)] = 'W'
- self.game.status[(13,0)] = 'W'
- elif self.current_tutorial == 33:
- self.game.clear()
- self.game.status[(10,16)] = 'B'
- self.game.status[(10,17)] = 'B'
- self.game.status[(11,15)] = 'B'
- self.game.status[(11,17)] = 'B'
- self.game.status[(11,18)] = 'B'
- self.game.status[(12,16)] = 'B'
- self.game.status[(12,17)] = 'B'
- self.game.status[(12,18)] = 'B'
- self.game.status[(13,16)] = 'B'
- self.game.status[(13,17)] = 'B'
- self.game.status[(14,18)] = 'B'
- self.game.status[(2,18)] = 'W'
- self.game.status[(3,18)] = 'W'
- self.game.status[(3,17)] = 'W'
- self.game.status[(4,16)] = 'W'
- self.game.status[(5,17)] = 'W'
- self.game.status[(6,17)] = 'W'
- self.game.status[(7,17)] = 'W'
- self.game.status[(7,18)] = 'W'
- self.game.status[(8,18)] = 'W'
- self.game.status[(4,18)] = 'T'
- self.game.status[(11,16)] = 'C'
- self.game.status[(5,18)] = 'S'
- elif self.current_tutorial == 38:
- self.game.clear()
- self.game.status[(7,0)] = 'B'
- self.game.status[(7,1)] = 'B'
- self.game.status[(7,2)] = 'B'
- self.game.status[(7,3)] = 'B'
- self.game.status[(7,4)] = 'B'
- self.game.status[(8,5)] = 'B'
- self.game.status[(9,5)] = 'B'
- self.game.status[(10,0)] = 'B'
- self.game.status[(10,1)] = 'B'
- self.game.status[(10,2)] = 'B'
- self.game.status[(10,3)] = 'B'
- self.game.status[(10,4)] = 'B'
- self.game.status[(9,0)] = 'W'
- self.game.status[(9,1)] = 'W'
- self.game.status[(9,2)] = 'W'
- self.game.status[(9,3)] = 'W'
- self.game.status[(9,4)] = 'W'
- self.game.status[(10,5)] = 'W'
- self.game.status[(11,5)] = 'W'
- self.game.status[(12,0)] = 'W'
- self.game.status[(12,1)] = 'W'
- self.game.status[(12,2)] = 'W'
- self.game.status[(12,3)] = 'W'
- self.game.status[(12,4)] = 'W'
- elif self.current_tutorial == 41:
- self.game.clear()
- self.game.status[(3,0)] = 'B'
- self.game.status[(3,1)] = 'B'
- self.game.status[(4,2)] = 'B'
- self.game.status[(5,2)] = 'B'
- self.game.status[(6,2)] = 'B'
- self.game.status[(7,2)] = 'B'
- self.game.status[(8,2)] = 'B'
- self.game.status[(9,1)] = 'B'
- self.game.status[(4,0)] = 'W'
- self.game.status[(4,1)] = 'W'
- self.game.status[(5,1)] = 'W'
- self.game.status[(6,0)] = 'W'
- self.game.status[(6,1)] = 'W'
- self.game.status[(7,1)] = 'W'
- self.game.status[(8,1)] = 'W'
- self.game.status[(8,0)] = 'C'
- self.game.status[(9,1)] = 'X'
- elif self.current_tutorial == 48:
- self.game.clear()
- else:
- self.game.status = self.game.status
self.board.status = self.game.status
self.board.do_expose_event()
@@ -862,7 +846,6 @@ class PlayGo(Activity):
self.game.status[(6,2)] = 'B'
self.game.status[(7,2)] = 'B'
self.game.status[(8,2)] = 'B'
- self.game.status[(9,1)] = 'B'
self.game.status[(4,0)] = 'W'
self.game.status[(4,1)] = 'W'
self.game.status[(5,1)] = 'W'
@@ -871,7 +854,7 @@ class PlayGo(Activity):
self.game.status[(7,1)] = 'W'
self.game.status[(8,1)] = 'W'
self.game.status[(8,0)] = 'C'
- self.game.status[(9,1)] = 'X'
+ self.game.status[(9,1)] = 'E'
elif self.current_tutorial == 48:
self.game.clear()
else:
@@ -885,53 +868,67 @@ class PlayGo(Activity):
# ----------- Editor Functions ------------------ #
- def add_black_cb(self, widget=None):
- self.editToolbar.grey_out_add_black()
- self.editToolbar.activate_add_white()
- self.editToolbar.activate_add_x()
- self.editToolbar.activate_add_circle()
- self.editToolbar.activate_add_triangle()
- self.editToolbar.activate_add_square()
- def add_white_cb(self, widget=None):
- self.editToolbar.grey_out_add_white()
- self.editToolbar.activate_add_black()
- self.editToolbar.activate_add_x()
- self.editToolbar.activate_add_circle()
- self.editToolbar.activate_add_triangle()
- self.editToolbar.activate_add_square()
+
+ def edit_cb(self, widget=None):
+ if self.is_editing == 0:
+ self.is_editing = 1
+ if self.edit_type == 0:
+ self.editToolbar.grey_out_add_x()
+ self.editToolbar.activate_add_circle()
+ self.editToolbar.activate_add_triangle()
+ self.editToolbar.activate_add_square()
+ elif self.edit_type == 1:
+ self.editToolbar.activate_add_x()
+ self.editToolbar.grey_out_add_circle()
+ self.editToolbar.activate_add_triangle()
+ self.editToolbar.activate_add_square()
+ elif self.edit_type == 2:
+ self.editToolbar.activate_add_x()
+ self.editToolbar.activate_add_circle()
+ self.editToolbar.grey_out_add_triangle()
+ self.editToolbar.activate_add_square()
+ else:
+ self.editToolbar.activate_add_x()
+ self.editToolbar.activate_add_circle()
+ self.editToolbar.activate_add_triangle()
+ self.editToolbar.grey_out_add_square()
+ else:
+ self.is_editing = 0
+ self.editToolbar.grey_out_add_x()
+ self.editToolbar.grey_out_add_circle()
+ self.editToolbar.grey_out_add_triangle()
+ self.editToolbar.grey_out_add_square()
+ self.board.status = self.edit_status
+ self.game.status = self.edit_status
def add_x_cb(self, widget=None):
self.editToolbar.grey_out_add_x()
- self.editToolbar.activate_add_white()
- self.editToolbar.activate_add_black()
+ self.edit_type = 0
self.editToolbar.activate_add_circle()
self.editToolbar.activate_add_triangle()
self.editToolbar.activate_add_square()
def add_circle_cb(self, widget=None):
self.editToolbar.grey_out_add_circle()
- self.editToolbar.activate_add_white()
+ self.edit_type = 1
self.editToolbar.activate_add_x()
- self.editToolbar.activate_add_black()
self.editToolbar.activate_add_triangle()
self.editToolbar.activate_add_square()
def add_triangle_cb(self, widget=None):
self.editToolbar.grey_out_add_triangle()
- self.editToolbar.activate_add_white()
+ self.edit_type = 2
self.editToolbar.activate_add_x()
self.editToolbar.activate_add_circle()
- self.editToolbar.activate_add_black()
self.editToolbar.activate_add_square()
def add_square_cb(self, widget=None):
self.editToolbar.grey_out_add_square()
- self.editToolbar.activate_add_white()
+ self.edit_type = 3
self.editToolbar.activate_add_x()
self.editToolbar.activate_add_circle()
self.editToolbar.activate_add_triangle()
- self.editToolbar.activate_add_black()
def save_cb(self, widget=None):
self.infopanel.show(_("To be implemented in the future!"))