diff options
author | echinelli <emilianochinelli@gmail.com> | 2010-12-10 15:48:56 (GMT) |
---|---|---|
committer | echinelli <emilianochinelli@gmail.com> | 2010-12-10 15:48:56 (GMT) |
commit | 435b2794da0c41a56da67c9342e89d59ef8ac31d (patch) | |
tree | 3b245368b2a52b6d715b72e9578d20408f04a761 | |
parent | 4b0a9e9c782de6d6257d81415200d71780940aab (diff) | |
parent | 569068caa4db5da29a47c7a3aa127a2022d66969 (diff) |
Merge branch 'master' of git://git.sugarlabs.org/saludame/mainline
Conflicts:
Saludame.activity/menu.py
-rwxr-xr-x | Saludame.activity/actions_creator.py | 2 | ||||
-rwxr-xr-x | Saludame.activity/character.py | 1 | ||||
-rwxr-xr-x | Saludame.activity/game_manager.py | 6 | ||||
-rwxr-xr-x | Saludame.activity/menu.py | 13 | ||||
-rwxr-xr-x | Saludame.activity/utilities.py | 36 |
5 files changed, 52 insertions, 6 deletions
diff --git a/Saludame.activity/actions_creator.py b/Saludame.activity/actions_creator.py index 921d11c..ae28d7b 100755 --- a/Saludame.activity/actions_creator.py +++ b/Saludame.activity/actions_creator.py @@ -197,7 +197,7 @@ locations_ac_list = [("goto_schoolyard", None, 1, None, None, None, None, None, ### ACTIONS THAT SET CHARACTER CLOTHES clothes_ac_list = [("change_school_clothes", None, 1, None, None, None, None, None, None, None, None, effects.ClothesEffect(None, "school"), None, None, None), ("change_sunny_clothes", None, 1, None, None, None, None, None, None, None, None, effects.ClothesEffect(None, "sunny"), None, None, None), - ("change_rainy_clothes", None, 1, None, None, None, None, None, None, None, None, effects.ClothesEffect(None, "sunny"), None, None, None), + ("change_rainy_clothes", None, 1, None, None, None, None, None, None, None, None, effects.ClothesEffect(None, "rainy"), None, None, None), ] class ActionsLoader: diff --git a/Saludame.activity/character.py b/Saludame.activity/character.py index a4d2146..6ce940e 100755 --- a/Saludame.activity/character.py +++ b/Saludame.activity/character.py @@ -16,6 +16,7 @@ class Character: self.sex = sex self.name = name self.level = level + self.mood = "normal" # visuals self.mappings = DEFAULT_MAPPINGS.copy() diff --git a/Saludame.activity/game_manager.py b/Saludame.activity/game_manager.py index cb6c00a..6c8104a 100755 --- a/Saludame.activity/game_manager.py +++ b/Saludame.activity/game_manager.py @@ -59,6 +59,7 @@ class GameManager: #environment self.environments_dictionary = environments_dictionary self.current_weather = "sunny" # default weather + self.environment = None # time of day self.hour = 2 # value between 0 and 3 @@ -105,9 +106,9 @@ class GameManager: windows_controller """ environment_id = self.character.current_place + "_" + self.current_weather - environment = self.environments_dictionary[environment_id] + self.environment = self.environments_dictionary[environment_id] - self.windows_controller.set_environment(environment) + self.windows_controller.set_environment(self.environment) ### time of day @@ -297,6 +298,7 @@ class GameManager: if mood <> self.active_mood: self.active_mood = mood self.windows_controller.set_mood(mood) + self.character.mood = mood print "cambio estado de animo a: ", self.active_mood.name ## Events handling diff --git a/Saludame.activity/menu.py b/Saludame.activity/menu.py index 05c4171..3ed67e5 100755 --- a/Saludame.activity/menu.py +++ b/Saludame.activity/menu.py @@ -12,6 +12,7 @@ import math from widget import Widget from window import Window import utilities +import effects SIZE = 600, 280 EXP_SPEED = 15 #expansion speed, in pixels per frame @@ -125,7 +126,8 @@ class Menu(Window): return allowed_items def verify_action(self, action, game_manager): - # verify place + + #verify place allowed = False if action.allowed_places: current_place = game_manager.get_current_place() @@ -135,6 +137,7 @@ class Menu(Window): break if not allowed: return False + #verify hour if action.allowed_hours: allowed = False @@ -145,6 +148,7 @@ class Menu(Window): break if not allowed: return False + #verify event if action.allowed_events: allowed = False @@ -159,8 +163,13 @@ class Menu(Window): if action.level > self.game_manager.get_level(): return False - + + if not utilities.verify_path(action, self.game_manager): + return False + + #verify path return True + def close(self): """ diff --git a/Saludame.activity/utilities.py b/Saludame.activity/utilities.py index 5655b99..62e554c 100755 --- a/Saludame.activity/utilities.py +++ b/Saludame.activity/utilities.py @@ -4,6 +4,8 @@ from widget import * import pygame +import os +from game_manager import * class Text(Widget): @@ -146,7 +148,7 @@ class TextButton2(ImageButton): render = font.render(self.text, True, self.color) surface = self.back.copy() - surface.blit(render, render.get_rect(center=surface.get_rect().center) ) + surface.blit(render, render.get_rect(center=surface.get_rect().center)) return surface def get_accept_button(container, rect, text, cb_click=None, cb_over=None, cb_out=None): @@ -234,3 +236,35 @@ def get_font(size, bold=False, italic=False): font_dict[key] = font return font + +#### Paths controls #### +def check_directory(directory): + try: + print directory + os.listdir(directory) + return True + except OSError: + return False + +def check_image(image_path): + try: + print image_path + pygame.image.load(image_path) + return True + except: + return False + +def verify_path(action, game_manager): + if isinstance(action.effect, effects.Effect): # If the action has effects on bars + if action.kid_animation_path: # and has a kid animation path + return check_directory("%s/%s/%s" % (action.kid_animation_path, game_manager.character.sex, game_manager.character.clothes)) # check animation directory (action_path/sex/clothes) + else: + return True + + if isinstance(action.effect, effects.ClothesEffect): # If the action has clothes effects + return check_directory("%s/%s/%s" % (game_manager.character.mood.kid_animation_path, game_manager.character.sex, action.effect.clothes_id)) + + if isinstance(action.effect, effects.LocationEffect): # If the action has location effects + return check_image(game_manager.environments_dictionary[action.effect.place_id + "_" + game_manager.current_weather].background_path) + + return True |