Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2014-07-14 17:47:48 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2014-07-14 17:47:48 (GMT)
commit84d843b4981b664cb171518ca14b0a91a227ea88 (patch)
treeaad78f815e75dd949e6cb735ca56153b1d93ad66
parentd6a93685bacb7e8e244132cf9160fc87911c9d65 (diff)
Avoid error with multiple clicks while flipping
This patch remove the posibility of flop with a second click. Now the user need wit until the flop is trigger at 2 seconds. Is needed to avoid a race condition making the table be in a inconsisitent state, and don't allow the user win just doing multiple random touches.
-rw-r--r--activity.py1
-rw-r--r--cardtable.py5
-rw-r--r--game.py4
-rw-r--r--svgcard.py2
4 files changed, 2 insertions, 10 deletions
diff --git a/activity.py b/activity.py
index a48f99e..0a9a661 100644
--- a/activity.py
+++ b/activity.py
@@ -138,7 +138,6 @@ class MemorizeActivity(Activity):
self.connect('key-press-event', self.table.key_press_event)
self.table.connect('card-flipped', self.game.card_flipped)
- self.table.connect('card-overflipped', self.game.card_overflipped)
self.table.connect('card-highlighted', self.game.card_highlighted)
self.game.connect('set-border', self.table.set_border)
diff --git a/cardtable.py b/cardtable.py
index 77a7910..c6f058c 100644
--- a/cardtable.py
+++ b/cardtable.py
@@ -36,7 +36,6 @@ class CardTable(Gtk.EventBox):
__gsignals__ = {
'card-flipped': (GObject.SignalFlags.RUN_FIRST,
None, [int, GObject.TYPE_PYOBJECT]),
- 'card-overflipped': (GObject.SignalFlags.RUN_FIRST, None, [int]),
'card-highlighted': (GObject.SignalFlags.RUN_FIRST,
None, [int, GObject.TYPE_PYOBJECT]), }
@@ -234,9 +233,7 @@ class CardTable(Gtk.EventBox):
def card_flipped(self, card):
identifer = self.cd2id[card]
- if card.is_flipped():
- self.emit('card-overflipped', identifer)
- else:
+ if not card.is_flipped():
self.emit('card-flipped', identifer, False)
def set_border(self, widget, identifer, stroke_color, fill_color):
diff --git a/game.py b/game.py
index e188df6..0f64f6b 100644
--- a/game.py
+++ b/game.py
@@ -176,10 +176,6 @@ class MemorizeGame(GObject.GObject):
self.current_player = self.players[next_player]
self.update_turn()
- def card_overflipped(self, widget, identifier):
- if self._flop_cards and identifier in self._flop_cards:
- self.card_flipped(widget, identifier)
-
def card_flipped(self, widget, identifier, signal=False):
self.model.count = self.model.count + 1
if self._flop_cards:
diff --git a/svgcard.py b/svgcard.py
index dcea9d0..d0d433f 100644
--- a/svgcard.py
+++ b/svgcard.py
@@ -285,7 +285,7 @@ class SvgCard(Gtk.EventBox):
widget.set_size_request(self.size, self.size)
def is_flipped(self):
- return self.flipped
+ return self.flipped or self._on_animation
def get_id(self):
return self.id