diff options
author | dmazzone <mazzone.diego@gmail.com> | 2010-12-10 15:30:31 (GMT) |
---|---|---|
committer | dmazzone <mazzone.diego@gmail.com> | 2010-12-10 15:30:31 (GMT) |
commit | 569068caa4db5da29a47c7a3aa127a2022d66969 (patch) | |
tree | 17756f6764435ad4e67b2c8244f1ce30cb5a7403 | |
parent | ff718136126c69a0a432eb4966a515b4d6b32b69 (diff) |
Path control.
Restrictions on menu.
-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 | 10 | ||||
-rwxr-xr-x | Saludame.activity/utilities.py | 36 |
5 files changed, 49 insertions, 6 deletions
diff --git a/Saludame.activity/actions_creator.py b/Saludame.activity/actions_creator.py index cd0abe9..4b1fb6e 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 61070af..9ec380a 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 163b66b..e9117cc 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 @@ -107,9 +108,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 @@ -299,6 +300,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 39a907e..cda8df1 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 @@ -156,7 +160,9 @@ class Menu(Window): break if not allowed: return False - return True + + #verify path + return utilities.verify_path(action, self.game_manager) 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 |