From 92183f99594e935abad1fff0ccb80043d5f8ddc8 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Fri, 20 Apr 2012 19:40:59 +0000 Subject: fixed typo preventing animation from closing --- diff --git a/NEWS b/NEWS index dd3caaf..8c12fb7 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +37 + +BUG FIX: +* Fixed typo that prevented help animation from terminating + +ENHANCEMENT: +* Autoadvance levels when play improves + 36 ENHANCEMENTS: diff --git a/VisualMatchActivity.py b/VisualMatchActivity.py index e7d3bb1..d6f7ebc 100644 --- a/VisualMatchActivity.py +++ b/VisualMatchActivity.py @@ -141,12 +141,12 @@ class VisualMatchActivity(activity.Activity): if self.vmw.joiner(): # joiner cannot change level return self.vmw.level = level + self._notify_new_game(self._prompt) self.set_level_label() def set_level_label(self): self.level_label.set_text(self.calc_level_label(self.vmw.low_score, self.vmw.level)) - self._notify_new_game(self._prompt) self.vmw.new_game() def calc_level_label(self, low_score, play_level): diff --git a/activity/activity.info b/activity/activity.info index df3b0e4..674b39c 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -1,7 +1,7 @@ [Activity] #TRANS: Please translate Visual Match as Dimensions name = Visual Match -activity_version = 36 +activity_version = 37 license = GPLv3 bundle_id = org.sugarlabs.VisualMatchActivity exec = sugar-activity VisualMatchActivity.VisualMatchActivity diff --git a/game.py b/game.py index 6327e42..ff5ef4f 100644 --- a/game.py +++ b/game.py @@ -383,6 +383,10 @@ class Game(): def _button_press_cb(self, win, event): ''' Look for a card under the button press and save its position. ''' win.grab_focus() + + # Turn off help animation + self._stop_help = True + # Keep track of starting drag position. x, y = map(int, event.get_coords()) self._drag_pos = [x, y] @@ -391,9 +395,6 @@ class Game(): # Find the sprite under the mouse. spr = self._sprites.find_sprite((x, y)) - # Turn off help animation - self.stop_help = True - # If there is a match showing, hide it. if self._matches_on_display: self.clean_up_match(share=True) @@ -627,7 +628,7 @@ class Game(): if self._matches_on_display: self._smiley[-1].spr.set_layer(100) _logger.debug('Found a match') - else: + elif self._failure is not None: self._frowny[self._failure].spr.set_layer(100) return @@ -709,9 +710,6 @@ class Game(): self.match_list.append(c.spr) self._matches_on_display = True - # Wait a few seconds before dealing new cards. - gobject.timeout_add(2000, self._deal_new_cards) - # Test to see if the game is over. if self._game_over(): if hasattr(self, 'timeout_id'): @@ -727,14 +725,12 @@ class Game(): self.all_scores.append(int(self.total_time + 0.5)) if not self._sugar: self.activity.save_score() + else: + self._auto_increase_difficulty() return True - - # Consolidate the grid. - self.grid.consolidate() - - # Test to see if we need to deal extra cards. - if not self._find_a_match(): - self.grid.deal_extra_cards(self.deck) + else: + # Wait a few seconds before dealing new cards. + gobject.timeout_add(2000, self._deal_new_cards) # Keep playing. self._update_labels() @@ -743,13 +739,33 @@ class Game(): else: self._matches_on_display = False + def _auto_increase_difficulty(self): + ''' Auto advance levels ''' + if self.level == 2 and len(self.all_scores) > 3: + sum = 0 + for i in range(3): + sum += self.all_scores[-i - 1] + if sum < 120: + self.level = 0 + self.activity.intermediate_button.set_active(True) + elif self.level == 0 and len(self.all_scores) > 8: + sum = 0 + for i in range(3): + sum += self.all_scores[-i - 1] + if sum < 240: + self.level = 1 + self.activity.expert_button.set_active(True) + def _deal_new_cards(self): ''' Deal three new cards. ''' self.grid.replace(self.clicked, self.deck) self.set_label('deck', '%d %s' % (self.deck.cards_remaining(), _('cards'))) - - + # Consolidate the grid. + self.grid.consolidate() + # Test to see if we need to deal extra cards. + if not self._find_a_match(): + self.grid.deal_extra_cards(self.deck) def _keypress_cb(self, area, event): ''' Keypress: editing word cards or selecting cards to play ''' @@ -1106,8 +1122,6 @@ class Game(): def help_animation(self): ''' Simple explanatory animation at start of play ''' - if not self._sugar: - return self._help_index = 0 self._stop_help = False self._help[self._help_index].set_layer(5000) -- cgit v0.9.1