diff options
author | Diego Mazzone <mazzone.diego@gmail.com> | 2010-12-15 22:04:41 (GMT) |
---|---|---|
committer | Diego Mazzone <mazzone.diego@gmail.com> | 2010-12-15 22:04:41 (GMT) |
commit | a4387347cc20804e4dbf1c8c446d2785a2868ab1 (patch) | |
tree | 32bb7e931fcc68dc1d226fb8e6e795e5187620bc | |
parent | 830190a30e1a73f6214912a68c0e23336e547b89 (diff) | |
parent | b8f0dd93d018381f2b9a10feb3c5e63a0fe1cec5 (diff) |
Merge branch 'master' of git://git.sugarlabs.org/saludame/mainline
Conflicts:
Saludame.activity/status_bars.py [Fixed]
-rwxr-xr-x | Saludame.activity/character.py | 10 | ||||
-rwxr-xr-x | Saludame.activity/game_manager.py | 36 | ||||
-rwxr-xr-x | Saludame.activity/main_window.py | 11 | ||||
-rwxr-xr-x | Saludame.activity/status_bars.py | 11 |
4 files changed, 64 insertions, 4 deletions
diff --git a/Saludame.activity/character.py b/Saludame.activity/character.py index 6ce940e..7fd07ac 100755 --- a/Saludame.activity/character.py +++ b/Saludame.activity/character.py @@ -70,6 +70,15 @@ class Character: self.grade = game_status["grade"] self.current_place = game_status["current_place"] self.level = game_status["level"] + + def reset(self): + """ + Restore some character properties to its default values. + """ + self.level = 1 + self.clothes = 'school' + self.current_place = 'schoolyard' + self.mappings = DEFAULT_MAPPINGS.copy() class Environment: @@ -117,3 +126,4 @@ class Clothes: self.clothes_id = clothes_id self.texture_path = texture_path self.weather_effects_list = weather_effects_list #list of tuples (id_weather, effect_indoor, effect_outdoor) + diff --git a/Saludame.activity/game_manager.py b/Saludame.activity/game_manager.py index def606a..d456719 100755 --- a/Saludame.activity/game_manager.py +++ b/Saludame.activity/game_manager.py @@ -208,9 +208,10 @@ class GameManager: action with the 'action_id'. If the action_id is 'None', just stops the active action. """ - self.active_char_action.reset() - self.active_char_action = None - self.windows_controller.stop_actual_action_animation() + if self.active_char_action: + self.active_char_action.reset() + self.active_char_action = None + self.windows_controller.stop_actual_action_animation() if action_id: action = self.get_action(action_id) @@ -460,7 +461,33 @@ class GameManager: self.windows_controller.show_master_challenge_intro() -# Save and load game +# Save, load and reset game + + def reset_game(self): + """ + Reset game properties + """ + # actions + self.interrupt_active_action(None) + # events + for personal_event in self.active_events: + self.windows_controller.remove_personal_event(personal_event) + for social_event in self.active_social_events: + self.windows_controller.remove_social_event(social_event) + self.active_events = [] + self.active_social_events = [] + self.events_interval = EVENTS_OCCURRENCE_INTERVAL + # character + self.character.reset() + # bars + self.bars_controller.reset() + # weather + self.current_weather = "sunny" # default weather + self.update_environment() + # hour + self.hour = 2 + self.hour_count = HOUR_COUNT_CYCLE + self.current_time = self.day_dic[self.hour] def save_game(self): """ @@ -530,3 +557,4 @@ class GameManager: """ return self.current_time + diff --git a/Saludame.activity/main_window.py b/Saludame.activity/main_window.py index 34a407b..0ac7c80 100755 --- a/Saludame.activity/main_window.py +++ b/Saludame.activity/main_window.py @@ -3,6 +3,8 @@ import pygame from gettext import gettext as _ +import utilities + from window import * from panel_window import PanelWindow from kid_window import KidWindow @@ -16,6 +18,8 @@ class MainWindow(Window): self.clock = clock self.cha_loader = cha_loader + self.game_manager = game_man + self.windows = [] # Lista de ventanas que 'componen' la ventana principal # temporal para probar PanelWindow (se cargará el diccionario en un módulo aparte). @@ -42,6 +46,9 @@ class MainWindow(Window): challenges_button2.set_tooltip(_("True or false")) self.add_button(challenges_button2) + button_back = pygame.image.load("customization/customization_button.png").convert_alpha() + btn_reset = utilities.TextButton2(self.rect, pygame.Rect((1000, 20), (70, 30)), 1, _("Reset"), 30, (255, 255, 255), button_back, self._cb_reset_game) + self.add_button(btn_reset) #stop_animation_button = TextButton(self.rect, pygame.Rect((800, 550), (30, 30)), 1, "Stop animation", 38, (255, 0, 0), self._cb_button_click_stop_animation) #self.add_button(stop_animation_button) @@ -62,6 +69,9 @@ class MainWindow(Window): def _cb_button_click_change_mood(self, button): self.kidW.change_mood() + + def _cb_reset_game(self, button): + self.game_manager.reset_game() class Clock(Widget): @@ -98,3 +108,4 @@ class Clock(Widget): return change + diff --git a/Saludame.activity/status_bars.py b/Saludame.activity/status_bars.py index 5d69fcd..47ac252 100755 --- a/Saludame.activity/status_bars.py +++ b/Saludame.activity/status_bars.py @@ -8,6 +8,8 @@ import utilities from window import * import game_manager +DEFAULT_BARS_VALUES = 65.0 + SECTION_OFFSET_X = 0 SECTION_WIDTH = 220 SECTION_MIN_HEIGHT = 50 @@ -416,6 +418,14 @@ class BarsController: value = bar.value lowest_bar = bar return lowest_bar + + def reset(self): + """ + Restore the bars value to the default value. + """ + for bar in self.bars: + bar.value = DEFAULT_BARS_VALUES + self.score_bar.value = 0.0 class StatusBar: """ @@ -493,3 +503,4 @@ class StatusBar: elif self.value < 0: self.value = 0 + |