From 668915417c00258addb49771417f719ee3799c7a Mon Sep 17 00:00:00 2001 From: Pablo Moleri Date: Thu, 30 Dec 2010 19:02:28 +0000 Subject: Corrected some bits of code which differ from pep8 guidelines Trailing spaces removed Removed unused module content_parser --- diff --git a/Saludame.activity/actions.py b/Saludame.activity/actions.py index def2400..75d9f03 100755 --- a/Saludame.activity/actions.py +++ b/Saludame.activity/actions.py @@ -46,7 +46,7 @@ class Action: self.time_left = 0 def reset(self): - self.time_left = self.time_span + self.time_left = self.time_span class Mood: diff --git a/Saludame.activity/actions_creator.py b/Saludame.activity/actions_creator.py index 44ec31b..56c8574 100755 --- a/Saludame.activity/actions_creator.py +++ b/Saludame.activity/actions_creator.py @@ -20,7 +20,7 @@ JUMP_ROPE_PATH = os.path.normpath("assets/kid/actions/ropejump") bar_dec_effect = effects.Effect(None, [("nutrition", BARS_DECREASE_RATE), ("spare_time", BARS_DECREASE_RATE), ("physica", BARS_DECREASE_RATE), ("hygiene", BARS_DECREASE_RATE)]) #actions list tuple format: -#[("action's id","icon_path","picture_path", appereance_probability, time_span, +#[("action's id","icon_path","picture_path", appereance_probability, time_span, # kid_animation_frame_rate,kid_animation_loop_times, kid_animation_path, window_animation_frame_rate, # window_animation_loop_times, window_animation_path, sound_loop_times, sound_path, action's effect)] @@ -208,9 +208,9 @@ class ActionsLoader: def __init__(self, bar_controller, game_manager): self.bar_controller = bar_controller self.game_manager = game_manager - self.actions_list = self.__load_actions() + self.actions_list = self.__load_actions() - def get_actions_list(self): + def get_actions_list(self): return self.actions_list def __load_actions(self): @@ -244,5 +244,3 @@ class ActionsLoader: return action[16] else: return None - - diff --git a/Saludame.activity/activity.py b/Saludame.activity/activity.py index e35ce24..380de80 100755 --- a/Saludame.activity/activity.py +++ b/Saludame.activity/activity.py @@ -130,4 +130,3 @@ class SaludameActivity(Activity): def set_library(self, link): self.toolbox.set_current_toolbar(2) self.health_library.set_url(link) - \ No newline at end of file diff --git a/Saludame.activity/animation.py b/Saludame.activity/animation.py index 3165e1d..c78fcb1 100755 --- a/Saludame.activity/animation.py +++ b/Saludame.activity/animation.py @@ -22,7 +22,7 @@ class Kid(gui.Window): def __init__(self, container, rect, frame_rate, windows_controller, game_man, mood): gui.Window.__init__(self, container, rect, frame_rate, windows_controller, "character_window") - self.character = game_man.character + self.character = game_man.character self.moods = game_man.moods_list @@ -30,12 +30,12 @@ class Kid(gui.Window): self.mood = self.moods[9] # Default mood (normal) self.action_index = -1 # Default action_index (no-action) - self.action = None + self.action = None self.sprite = None self.set_animation() - ##### Moods ##### + ##### Moods ##### def change_mood(self): self.mood_index += 1 if self.mood_index == len(self.moods): @@ -44,7 +44,7 @@ class Kid(gui.Window): self.index = 0 def set_mood(self, mood): - self.mood_index = self.moods.index(mood) + self.mood_index = self.moods.index(mood) self.mood = self.moods[self.mood_index] self.set_animation() @@ -89,7 +89,7 @@ class Kid(gui.Window): return [self.rect] - ##### Colors ##### + ##### Colors ##### def change_color(self, old, new): index = 0 for old_color in old: @@ -130,7 +130,7 @@ class ActionAnimation(gui.Widget): return self.rect_absolute -class FPS: +class FPS: def __init__(self, container, rect, frame_rate, clock): self.register_id = "" self.buttons = [] diff --git a/Saludame.activity/app_init.py b/Saludame.activity/app_init.py index ac5b4f1..96194e2 100755 --- a/Saludame.activity/app_init.py +++ b/Saludame.activity/app_init.py @@ -16,7 +16,7 @@ class AppLoader: ### loaders self.bars_loader = status_bars_creator.BarsLoader() - ### status bars + ### status bars self.status_bars_controller = self.bars_loader.get_bar_controller() self.character_bars = self.bars_loader.get_third_level_bars() #the third level status bars @@ -35,7 +35,7 @@ class AppLoader: self.game_man = game_manager.GameManager(self.character, self.status_bars_controller, None, self.events_list, character_loader.get_places(), character_loader.get_environments_dictionary(), character_loader.get_weather_effects(), self.moods_list, windows_controller) actions_loader = actions_creator.ActionsLoader(self.bars_loader.get_bar_controller(), self.game_man) - self.actions_list = actions_loader.get_actions_list() + self.actions_list = actions_loader.get_actions_list() self.game_man.actions_list = self.actions_list self.game_man.add_background_action("BARS_DEC") #acción de decrementar las barras @@ -68,7 +68,7 @@ class AppLoader: def __load_events(self, bars_controller): #Events constructor params: - #picture, kid_animation_path, id, description, appereance_probability, time_span, kind, event_status, effect, kid_message, + #picture, kid_animation_path, id, description, appereance_probability, time_span, kind, event_status, effect, kid_message, #preferred_mood=9, message_time_span = time_span) _events = [] diff --git a/Saludame.activity/challenges.py b/Saludame.activity/challenges.py index 7553e11..85b31ef 100755 --- a/Saludame.activity/challenges.py +++ b/Saludame.activity/challenges.py @@ -29,7 +29,7 @@ class MultipleChoice(gui.Window): def __init__(self, container, rect, frame_rate, windows_controller, challenges_creator, register_id, bg_color=(0, 0, 0)): gui.Window.__init__(self, container, rect, frame_rate, windows_controller, register_id, bg_color) - self.set_bg_image("assets/windows/window_1.png") + self.set_bg_image("assets/windows/window_1.png") ###### Sounds ###### self.s_correct = pygame.mixer.Sound(S_CORRECT_PATH) @@ -52,7 +52,7 @@ class MultipleChoice(gui.Window): # Close Button self.btn_close = gui.TextButton(self.rect, pygame.Rect((910, 0), (30, 30)), 1, "X", 32, (0, 0, 0), self._cb_button_click_close) - self.add_button(self.btn_close) + self.add_button(self.btn_close) self.wait = 0 @@ -68,8 +68,8 @@ class MultipleChoice(gui.Window): self.correct = a def set_answers(self, answers): - x = 30 - y = self.question.rect_absolute.top + x = 30 + y = self.question.rect_absolute.top y += 40 * len(self.question.lines) @@ -78,10 +78,10 @@ class MultipleChoice(gui.Window): b = gui.TextButton(self.rect, pygame.Rect((x, y), (1, 1)), 1, ans, TEXT_FONT_SIZE, ANSWER_COLOR, self._cb_button_click_choice, self._cb_button_over_choice, self._cb_button_out_choice) self.choices.append(b) self.buttons.append(b) - self.add_child(b) + self.add_child(b) def set_image(self, image): - if (not isinstance(image, pygame.Surface)): + if not isinstance(image, pygame.Surface): image = pygame.image.load(image) image = gui.Image(self.rect, pygame.Rect(500, 40, 20, 20), 1, image) self.add_child(image) @@ -95,24 +95,24 @@ class MultipleChoice(gui.Window): ######## Callbacks buttons ######## def _cb_button_click_choice(self, button): - if(button == self.choices[self.correct]): + if button == self.choices[self.correct]: self.s_correct.play() - self.windows_controller.game_man.add_points(self.win_points) + self.windows_controller.game_man.add_points(self.win_points) self.windows_controller.close_active_window() self.windows_controller.windows["info_challenge_window"].update_content(u"¡Respuesta correcta!", u"Muy bien, \nganaste %s puntos para tu barra %s" % (self.win_points, self.challenges_creator.game_man.get_lowest_bar().label)) - self.windows_controller.set_active_window("info_challenge_window") - self.opportinities = 1 + self.windows_controller.set_active_window("info_challenge_window") + self.opportinities = 1 else: self.windows_controller.game_man.add_points(-self.lose_points) self.s_incorrect.play() self.windows_controller.close_active_window() - if (self.opportinities == 0): + if self.opportinities == 0: self.windows_controller.windows["info_challenge_window"].update_content(u"Perdiste", u"Qué lástima, no era correcta, \nperdiste %s puntos en tu barra de %s. \nLee la biblioteca o pregunta al maestro/a." % (self.lose_points, self.challenges_creator.game_man.get_lowest_bar().label)) self.windows_controller.set_active_window("info_challenge_window") self.opportinities = 1 - else: + else: self.opportinities -= 1 self.windows_controller.windows["info_challenge_window"].update_content(u"Respuseta incorrecta", u"La respuesta no esta correcta, intenta otra vez") self.windows_controller.set_active_window("mc_challenge_window") @@ -123,12 +123,12 @@ class MultipleChoice(gui.Window): if not FIN_MC: button.switch_color_text(MOUSE_OVER_COLOR) button.force_update() - self.s_over.play() + self.s_over.play() def _cb_button_out_choice(self, button): if not FIN_MC: button.switch_color_text(ANSWER_COLOR) - button.force_update() + button.force_update() def _cb_button_click_close(self, button): self.windows_controller.close_active_window() @@ -152,12 +152,12 @@ class TrueOrFalse(MultipleChoice): MultipleChoice.__init__(self, container, rect, frame_rate, windows_controller, challenges_creator, register_id, bg_color) - self.n_tf = N_TF + self.n_tf = N_TF self.question_number = 0 self.answers = ["waiting", "waiting", "waiting", "waiting", "waiting"] self.kind = "normal" # normal or master - # master challenge is like a TrueOrFalse challenge with mutlitple choice questions + # master challenge is like a TrueOrFalse challenge with mutlitple choice questions self.limit = 3 self.perdio = False @@ -205,14 +205,14 @@ class TrueOrFalse(MultipleChoice): return [q0, q1, q2, q3, q4] def _cb_button_click_choice(self, button): - if(button == self.choices[self.correct]): + if button == self.choices[self.correct]: self.s_correct.play() self.windows_controller.game_man.add_points(self.win_points) if self.n_tf: # Correct answer self.answers[self.question_number] = "correct" self.n_tf -= 1 - if self.kind == "master": + if self.kind == "master": self.challenges_creator.get_challenge("master") elif self.kind == "normal": self.challenges_creator.get_challenge("tf") @@ -230,7 +230,7 @@ class TrueOrFalse(MultipleChoice): if self.kind == "master": if self.answers.count("incorrect") == 5 - self.limit: - self.perdio = True + self.perdio = True self.challenges_creator.get_challenge("master") if self.kind == "normal": @@ -256,7 +256,7 @@ class TrueOrFalse(MultipleChoice): self.perdio = False def _cb_button_click_close(self, button): - self.windows_controller.close_active_window() + self.windows_controller.close_active_window() self.n_tf = N_TF self.question_number = 0 self.answers = ["waiting", "waiting", "waiting", "waiting", "waiting"] @@ -288,17 +288,17 @@ class InfoChallenge(gui.Window): self.image = image def _cb_button_click_continue(self, button): - self.windows_controller.close_active_window() + self.windows_controller.close_active_window() class Cooking(gui.Window): def __init__(self, container, rect, frame_rate, windows_controller, register_id, bg_color=(0, 0, 0)): gui.Window.__init__(self, container, rect, frame_rate, windows_controller, register_id, bg_color) - self.set_bg_image("assets/windows/window_1.png") + self.set_bg_image("assets/windows/window_1.png") # Close Button self.btn_close = gui.TextButton(self.rect, pygame.Rect((910, 0), (30, 30)), 1, "X", 32, (0, 0, 0), self._cb_button_click_close) - self.add_button(self.btn_close) + self.add_button(self.btn_close) # Some widgets to test DnD self.dnd = [] @@ -310,20 +310,20 @@ class Cooking(gui.Window): for w in self.dnd: self.add_child(w) - self.add_child(self.trash) + self.add_child(self.trash) # Mouse mode (1 - left button pressed) - self.mouse_mode = 0 + self.mouse_mode = 0 def handle_mouse_down(self, (x, y)): - gui.Window.handle_mouse_down(self, (x, y)) - self.mouse_mode = 1 + gui.Window.handle_mouse_down(self, (x, y)) + self.mouse_mode = 1 - def handle_mouse_up(self, pos): - gui.Window.handle_mouse_up(self, pos) + def handle_mouse_up(self, pos): + gui.Window.handle_mouse_up(self, pos) for widget in self.dnd: if self.trash.contains_point(widget.rect_absolute.centerx, widget.rect_absolute.centery): - self.remove_child(widget) + self.remove_child(widget) self.mouse_mode = 0 def handle_mouse_motion(self, pos): @@ -332,8 +332,8 @@ class Cooking(gui.Window): for widget in self.dnd: if widget.contains_point(pos[0], pos[1]): widget.rect_absolute.centerx = pos[0] - widget.rect_absolute.centery = pos[1] - self.repaint = True + widget.rect_absolute.centery = pos[1] + self.repaint = True def _cb_button_click_close(self, button): self.windows_controller.close_active_window() diff --git a/Saludame.activity/challenges_creator.py b/Saludame.activity/challenges_creator.py index a8107b1..ca3a304 100755 --- a/Saludame.activity/challenges_creator.py +++ b/Saludame.activity/challenges_creator.py @@ -24,10 +24,10 @@ class ChallengesCreator: # True or False window self.tf_challenge = challenges.TrueOrFalse(self.container, self.rect, self.frame_rate, self.windows_controller, self, "tf_challenge_window", self.bg_color) - # Cooking window - self.cooking_challenge = challenges.Cooking(self.container, self.rect, self.frame_rate, self.windows_controller, "cooking_challenge_window", self.bg_color) + # Cooking window + self.cooking_challenge = challenges.Cooking(self.container, self.rect, self.frame_rate, self.windows_controller, "cooking_challenge_window", self.bg_color) - # Tuples of mc_challenges + # Tuples of mc_challenges self.mc_challenges = [] # Tuples of tf_challenges @@ -70,14 +70,14 @@ class ChallengesCreator: """ Create a new mc_challenge (tuple) """ - challenge = (question, answers, correct_answer, win_points, lose_points, image) + challenge = (question, answers, correct_answer, win_points, lose_points, image) self.mc_challenges.append(challenge) def _create_tf_challenge(self, question, correct_answer, win_points, lose_points, image=None): """ Create a new tf_challenge (tuple) """ - challenge = (question, ["False", "True"], correct_answer, win_points, lose_points, image) + challenge = (question, ["False", "True"], correct_answer, win_points, lose_points, image) return challenge def get_challenge(self, kind): @@ -97,12 +97,12 @@ class ChallengesCreator: # If challenge has an image if c[5]: - self.mc_challenge.set_image(c[5]) + self.mc_challenge.set_image(c[5]) - return self.mc_challenge + return self.mc_challenge - elif kind == "tf": - self.tf_challenge.kind = "normal" + elif kind == "tf": + self.tf_challenge.kind = "normal" bar = self.game_man.get_lowest_bar() if bar.id == "physica": r = random.randrange(0, len(self.tf_challenges_physica)) @@ -115,7 +115,7 @@ class ChallengesCreator: c = self.tf_challenges_nutrition[r] elif bar.id == "spare_time": r = random.randrange(0, len(self.tf_challenges_spare_time)) - c = self.tf_challenges_spare_time[r] + c = self.tf_challenges_spare_time[r] # Set challenge attributes self.tf_challenge.set_question(c[0]) @@ -126,7 +126,7 @@ class ChallengesCreator: # If challenge has an image if c[5]: - self.tf_challenge.set_image(c[5]) + self.tf_challenge.set_image(c[5]) return self.tf_challenge @@ -152,7 +152,6 @@ class ChallengesCreator: # If challenge has an image if c[5]: - self.tf_challenge.set_image(c[5]) + self.tf_challenge.set_image(c[5]) return self.tf_challenge - diff --git a/Saludame.activity/character.py b/Saludame.activity/character.py index 1a6a23b..40f0e71 100755 --- a/Saludame.activity/character.py +++ b/Saludame.activity/character.py @@ -30,7 +30,7 @@ class Character: self.clothes = clothes def set_place(self, place_id): - self.actual_place = place_id + self.current_place = place_id def get_status(self): """ @@ -98,7 +98,7 @@ class Place: Verify if the action is allowed in this place """ for id in self.allowed_actions_list: - if(id == action_id): + if id == action_id: return True return False @@ -116,5 +116,3 @@ 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/character_creator.py b/Saludame.activity/character_creator.py index e98d902..0fbad62 100755 --- a/Saludame.activity/character_creator.py +++ b/Saludame.activity/character_creator.py @@ -30,7 +30,7 @@ class CharacterLoader: def __init__(self): self.character = self.__load_character(SEX, NAME, LEVEL, SCORE, "school") self.environments_dictionary = self.__load_environments() - self.places = self.__load_places() + self.places = self.__load_places() self.weather_effects = self.__load_weather_effects() def get_character(self): @@ -130,4 +130,3 @@ class CharacterLoader: } return environments - diff --git a/Saludame.activity/content_parser.py b/Saludame.activity/content_parser.py deleted file mode 100644 index 2893c18..0000000 --- a/Saludame.activity/content_parser.py +++ /dev/null @@ -1,115 +0,0 @@ -# -*- coding: utf-8 -*- - -# Created by: Pablo Astigarraga (poteland@gmail.com)** -# License: GPLv3 -# -# Description: Base for Saludame, a health-awareness teaching game for children intended for Plan Ceibal OLPC laptops implemented in Uruguay. -# -# URL: http://ceibaljam.org/ - -""" -This module will read all html documents and subdirectories on a given directory and create a tree based on the directory disposition of the files in the following manner: - -root directory - DirectoryLevel1 - htmldocument1 - htmldocument2 - DirectoryLevel1 - DirectoryLevel2 - htmldocument1 - htmldocument2 - Directorylevel3 - htmldocument1 - htmldocument1 - htmldocument2 - htmldocument3 - DirectoryLevel1 - htmldocument1 - - -Usage involves initializing an instance of the ContentTree object, this object will attempt to parse the root directory and create a hierarchy of topics consisting only of directories and .html files. - -The default location will be a /content/ folder located on the same directory as the script calling the function. -""" - -import os - -PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__)) - -class ComplexContentTree(object): - """A ComplexContentTree object will search for its contents recursively down a directory - tree, creating one topic with each subdirectory that contains one or more html files. - Its intended use is to instanciate it, load contents and be able to reference each of its - topics and files. Aiming at a graphical display the application will be able create a - representation of all topics and subtopics available and to pull the html content for each - topic and present it as a help page.""" - - def __init__(self,root="content",load_content=True): - self.root = os.path.join(PROJECT_ROOT,root) - if load_content: - self.load_content() - - - def load_content(self): - """Will parse the root directory of the content tree for html files and create - the information tree. - """ - if not self.root: - raise Exception("No root directory has been assigned") - - if not os.path.exists(self.root): - raise Exception("Invalid root directory - does not exist") - - all_topics = [] - for root, dirs, files in os.walk(self.root): - if os.path.exists(root): - new_topic = Topic(root) - if (new_topic not in all_topics) and (new_topic.files != []): - all_topics.append(new_topic) - - self.topics = all_topics - - - -class SimpleContentTree(object): - """A SimpleContentTree object contains just one topic and and is intended for - lightweight implementations where only one level will be used (no additional - subdirectories other than the root dir)""" - - def __init__(self,root="content",load_content=True): - self.root = os.path.join(PROJECT_ROOT,root) - if load_content: - self.load_content() - - - def load_content(self): - if not self.root: - raise Exception("No root directory has been assigned") - - if not os.path.exists(self.root): - raise Exception("Invalid root directory - does not exist") - - self.topic = Topic(self.root) - self.topic.parent = None - - - -class Topic(object): - """Minimum object - it will usually know its parent, title and files - so that an application can easily create and display the content tree - by showing the html content of each of the topic's files """ - - def __init__(self,path,parent=None): - self.subdirectories,self.files = [],[] - - for thing in os.listdir(path): - if os.path.isdir(os.path.join(path,thing)): - self.subdirectories.append(os.path.join(path,thing)) - if (os.path.isfile(os.path.join(path,thing))) and (os.path.splitext(thing)[1] == '.html'): - self.files.append(os.path.join(path,thing)) - - self.parent = os.path.basename(os.path.dirname(path)) - self.title = os.path.basename(path) - self.parent = parent - self.path = path - diff --git a/Saludame.activity/content_window.py b/Saludame.activity/content_window.py index fec10f0..b63c8f5 100644 --- a/Saludame.activity/content_window.py +++ b/Saludame.activity/content_window.py @@ -17,13 +17,11 @@ HOME_PAGE = os.path.join(ROOT_PATH, u'01-Introducción.html') hulahop_ok = True try: import hulahop - hulahop.startup( STARTUP_DIR ) + hulahop.startup(STARTUP_DIR) from hulahop.webview import WebView except: hulahop_ok = False -import content_parser - gobject.threads_init() class ContentWindow(gtk.HBox): diff --git a/Saludame.activity/events.py b/Saludame.activity/events.py index f8b3b1b..897e63b 100755 --- a/Saludame.activity/events.py +++ b/Saludame.activity/events.py @@ -68,7 +68,7 @@ class PersonalEvent(Event): self.effect = effect def perform(self): - if(self.time_left): + if self.time_left: if self.effect: self.effect.activate() self.time_left -= 1 @@ -97,7 +97,7 @@ class SocialEvent(Event): self.effect = effect def perform(self): - if(self.time_left): + if self.time_left: if self.effect: self.effect.activate() self.time_left -= 1 diff --git a/Saludame.activity/game.py b/Saludame.activity/game.py index a91aa14..bbf0548 100755 --- a/Saludame.activity/game.py +++ b/Saludame.activity/game.py @@ -72,15 +72,15 @@ class Main(): screen = pygame.display.get_surface() assert screen, "No screen" - pygame.display.update() + pygame.display.update() # This clock is used to keep the game at the desired FPS. clock = pygame.time.Clock() # windows_controller asociado al screen - self.windows_controller = saludame_windows_controller.SaludameWindowsController(screen, None) + self.windows_controller = saludame_windows_controller.SaludameWindowsController(screen, None) - # Initialize sound_manager, game_manager, character, actions and menu. + # Initialize sound_manager, game_manager, character, actions and menu. sound_manager.SoundManager() app_loader = app_init.AppLoader(self.windows_controller) @@ -143,5 +143,3 @@ class Main(): if __name__ == "__main__": Main().main(False) - - diff --git a/Saludame.activity/game_manager.py b/Saludame.activity/game_manager.py index e096898..d1d325b 100755 --- a/Saludame.activity/game_manager.py +++ b/Saludame.activity/game_manager.py @@ -41,7 +41,7 @@ class GameManager: self.personal_events_list = self.__get_personal_events(events_list) self.social_events_list = self.__get_social_events(events_list) self.actions_list = actions_list - self.moods_list = moods_list + self.moods_list = moods_list self.background_actions = [] @@ -87,11 +87,11 @@ class GameManager: def signal(self): """ - Increment signal, it means that a main iteration has been completed + Increment signal, it means that a main iteration has been completed """ if not self.pause: self.count += 1 - if(self.count >= CONTROL_INTERVAL): + if self.count >= CONTROL_INTERVAL: self.__control_active_actions() # handle active character actions self.bars_controller.calculate_score() # calculates the score of the score_bar self.__control_level() # Checks if level must be changed @@ -120,7 +120,7 @@ class GameManager: def update_environment_effect(self): """ - Create and action with the effect on the character by the environment, taking current_place + + Create and action with the effect on the character by the environment, taking current_place + clothes + current_weather. """ outdoor = self.places_dictionary[self.character.current_place]["outdoor"] @@ -214,15 +214,15 @@ class GameManager: if isinstance(action.effect, effects.Effect): #this action affects status bars self.set_active_action(action_id) elif isinstance(action.effect, effects.LocationEffect): #this action affects character location - if(self.active_char_action): + if self.active_char_action: self.interrupt_active_action(None) action.perform() - action.reset() + action.reset() elif isinstance(action.effect, effects.ClothesEffect): #this action affects character clothes - if(self.active_char_action): + if self.active_char_action: self.interrupt_active_action(None) action.perform() - action.reset() + action.reset() def interrupt_active_action(self, action_id): """ @@ -233,7 +233,7 @@ class GameManager: if self.active_char_action: self.active_char_action.reset() self.active_char_action = None - self.windows_controller.stop_actual_action_animation() + self.windows_controller.stop_current_action_animation() if action_id: action = self.get_action(action_id) @@ -258,13 +258,13 @@ class GameManager: """ Set the active char actions """ - #place = get_place(self.character.actual_place) - #if(place.allowed_action(action_id)): #continúa con la acción, solo si es permitida en el lugar - if(not self.active_char_action): #Si existe una accion activa no la interrumpe - if(True): #dont check char's place yet + #place = get_place(self.character.current_place) + #if place.allowed_action(action_id): #continúa con la acción, solo si es permitida en el lugar + if not self.active_char_action: #Si existe una accion activa no la interrumpe + if True: #dont check char's place yet action = self.get_action(action_id) - if(action): - action.perform() + if action: + action.perform() self.windows_controller.show_action_animation(action) self.active_char_action = action @@ -273,7 +273,7 @@ class GameManager: Returns the action asociated to the id_action """ for action in self.actions_list: - if(action.id == action_id): + if action.id == action_id: return action def get_lowest_bar(self): @@ -287,13 +287,13 @@ class GameManager: action.perform() action.time_span = -1 #that means background actions never stop - if self.active_char_action: #if the character is performing an action: + if self.active_char_action: #if the character is performing an action: if self.active_char_action.time_left > 0: self.active_char_action.perform() - else: #if the action was completed: + else: #if the action was completed: self.active_char_action.reset() self.active_char_action = None - self.windows_controller.stop_actual_action_animation() + self.windows_controller.stop_current_action_animation() ## Moods handling @@ -381,7 +381,7 @@ class GameManager: if event.time_left: event.perform() - else: + else: self.windows_controller.remove_personal_event(event) event.reset() self.active_events.remove(event) @@ -483,7 +483,7 @@ class GameManager: # reach the master challenge again. #self.windows_controller.show_master_challenge_intro() - pass + pass # Save, load and reset game @@ -511,8 +511,8 @@ class GameManager: self.update_environment_effect() self.windows_controller.update_clothes() # hour - self.hour = 2 - self.hour_count = HOUR_COUNT_CYCLE + self.hour = 2 + self.hour_count = HOUR_COUNT_CYCLE self.current_time = self.day_dic[self.hour] print "game reseted successfully... " @@ -562,7 +562,7 @@ class GameManager: except: print "no se pudo cargar la partida." -## +## def get_level(self): """ returns the character's current level @@ -587,6 +587,3 @@ class GameManager: returns current momento of day. """ return self.current_time - - - diff --git a/Saludame.activity/gui/utilities.py b/Saludame.activity/gui/utilities.py index fa149e0..519b230 100644 --- a/Saludame.activity/gui/utilities.py +++ b/Saludame.activity/gui/utilities.py @@ -83,15 +83,15 @@ class Button(Widget): self.super_tooltip = text def on_mouse_click(self): - if (self.function_on_mouse_click and self.enable): # if there's a callback setted makes the call + if self.function_on_mouse_click and self.enable: # if there's a callback setted makes the call self.function_on_mouse_click(self) def on_mouse_over(self): - if (self.function_on_mouse_over and self.enable): # if there's a callback setted makes the call + if self.function_on_mouse_over and self.enable: # if there's a callback setted makes the call self.function_on_mouse_over(self) def on_mouse_out(self): - if (self.function_on_mouse_out and self.enable): # if there's a callback setted makes the call + if self.function_on_mouse_out and self.enable: # if there's a callback setted makes the call self.function_on_mouse_out(self) def set_on_mouse_click(self, fn): @@ -189,7 +189,7 @@ class TextBlock(Widget): for l in self.lines: number_of_lines += 1 r = self.font.render(l, False, self.color) - if (r.get_rect().width > self.rect_absolute.width): + if r.get_rect().width > self.rect_absolute.width: self.rect_absolute.width = r.get_rect().width self.rect_absolute.height += r.get_rect().height diff --git a/Saludame.activity/gui/window.py b/Saludame.activity/gui/window.py index 1c725c4..b130dde 100755 --- a/Saludame.activity/gui/window.py +++ b/Saludame.activity/gui/window.py @@ -30,7 +30,7 @@ class Window: return self.register_id def set_bg_image(self, image): - if (not isinstance(image, pygame.Surface)): + if not isinstance(image, pygame.Surface): # Is a path, convert it to a surface self.bg_image = pygame.image.load(image).convert_alpha() else: @@ -42,11 +42,11 @@ class Window: def dispose(self): self.windows_controller.unregister_window(self) - # Abstract function. + # Abstract function. def pre_draw(self, screen): return [] - # Logica de pintado de cualquier ventana + # Logica de pintado de cualquier ventana def draw(self, screen, frames): changes = [] @@ -54,7 +54,7 @@ class Window: changes += self.pre_draw(screen) if self.repaint: # Solo actualizamos el fondo de la ventana cuando hagamos un 'repaint' - # De otra forma solo actualizamos los widgets y subventanas + # De otra forma solo actualizamos los widgets y subventanas if self.bg_image != None: screen.blit(self.bg_image, self.rect) # Pintamos el "fondo" de la ventana @@ -67,11 +67,11 @@ class Window: self.repaint = False for win in self.windows: - if (frames % win.frame_rate == 0): + if frames % win.frame_rate == 0: changes.extend(win.draw(screen, frames)) # Le decimos a cada ventana que se pinte for widget in self.widgets: - if (frames % widget.frame_rate == 0): + if frames % widget.frame_rate == 0: changes.append(widget.draw(screen)) # Pintamos los widgets que "contiene" la ventana return changes @@ -130,7 +130,7 @@ class Window: for button in buttons: if button.contains_point(x, y): - if(not button.over): + if not button.over: # Tooltips if button.tooltip: # Si el boton tiene tooltip entonces lo mostramos self.windows_controller.hide_active_tooltip() @@ -141,7 +141,7 @@ class Window: self.windows_controller.show_super_tooltip(button.super_tooltip) button.showing_tooltip = True button.on_mouse_over() - button.over = True + button.over = True return # No seguimos buscando el botón else: # Ineficiente! Por ahora lo dejo asi para PROBAR @@ -153,11 +153,11 @@ class Window: button.over = False button.on_mouse_out() - # It will be overridden by cooking challenge or other D&D challenge + # It will be overridden by cooking challenge or other D&D challenge def handle_mouse_motion(self, (x, y)): pass - # It will be overridden by cooking challenge or other D&D challenge + # It will be overridden by cooking challenge or other D&D challenge def handle_mouse_up(self, pos): pass @@ -185,4 +185,3 @@ class Window: def get_background(self): return self.get_background_and_owner()[0] - diff --git a/Saludame.activity/gui/windows_controller.py b/Saludame.activity/gui/windows_controller.py index e6a3adf..fb05aa4 100755 --- a/Saludame.activity/gui/windows_controller.py +++ b/Saludame.activity/gui/windows_controller.py @@ -35,13 +35,13 @@ class WindowsController: self.windows_stack[-1].repaint = True # Solo puede ser llamado por la ventana activa e implica # hacer un pop del stack - self.windows_stack.pop() + self.windows_stack.pop() self.show_window_hierarchy(self.windows_stack[-1]) - if (self.windows_stack[-1].get_register_id() == "main_window"): + if self.windows_stack[-1].get_register_id() == "main_window": self.game_man.continue_game() - self.reload_main = True + self.reload_main = True for win in self.windows_stack[-1].windows: if isinstance(win, Window): win.enable_repaint() @@ -50,11 +50,11 @@ class WindowsController: if window_key <> "main_window": self.game_man.pause_game() - self.windows_stack.append(self.windows[window_key]) - self.show_window_hierarchy(self.windows_stack[-1]) + self.windows_stack.append(self.windows[window_key]) + self.show_window_hierarchy(self.windows_stack[-1]) def register_new_window(self, id, window): - self.windows[id] = window + self.windows[id] = window def unregister_window(self, window): try: @@ -67,7 +67,7 @@ class WindowsController: W = [] for win in window.windows: W.append(win.register_id) - print(" (%s)" % (W)) + print(" (%s)" % (W)) # Events handlers @@ -93,14 +93,14 @@ class WindowsController: self.active_tooltip = Text(self.screen.get_rect(), x, y, 1, tooltip, 18, pygame.Color('red'), "tooltip") # Necesitamos guardar lo que esta atras del tooltip para cuando lo querramos esconder - self.active_tooltip_bg = (self.screen.subsurface(self.active_tooltip.rect_absolute).copy(), self.active_tooltip.rect_absolute) + self.active_tooltip_bg = (self.screen.subsurface(self.active_tooltip.rect_absolute).copy(), self.active_tooltip.rect_absolute) self.showing_tooltip = True def show_super_tooltip(self, tooltip): x, y = self.scaled_game.scale_coordinates(pygame.mouse.get_pos()) self.active_tooltip = TextBlock(self.screen.get_rect(), x, y, 1, tooltip, 18, pygame.Color('red'), "tooltip") - self.active_tooltip_bg = (self.screen.subsurface(self.active_tooltip.rect_absolute).copy(), self.active_tooltip.rect_absolute) + self.active_tooltip_bg = (self.screen.subsurface(self.active_tooltip.rect_absolute).copy(), self.active_tooltip.rect_absolute) self.showing_tooltip = True def hide_active_tooltip(self): @@ -108,8 +108,8 @@ class WindowsController: if self.showing_tooltip: # Hacemos un blit con lo que tenia atras el tooltip self.screen.blit(self.active_tooltip_bg[0], self.active_tooltip_bg[1]) - # Lo guardamos en la lista de las proximas actualizaciones - self.next_update(self.active_tooltip_bg[1]) + # Lo guardamos en la lista de las proximas actualizaciones + self.next_update(self.active_tooltip_bg[1]) self.showing_tooltip = False @@ -122,24 +122,24 @@ class WindowsController: def update(self, frames): """ - Updates GUI - """ + Updates GUI + """ # Cada vez que "volvamos" a la ventana principal es necesario # repintar el fondo para que no queden rastros de la ventana anterior if self.reload_main: pygame.display.flip() # Actualizamos el screen para hacer visibles los efectos - self.reload_main = False + self.reload_main = False changes = [] if frames % self.windows_stack[-1].frame_rate == 0: - changes.extend(self.windows_stack[-1].draw(self.screen, frames)) + changes.extend(self.windows_stack[-1].draw(self.screen, frames)) if changes: if self.next_update_list: changes.extend(self.next_update_list) self.next_update_list = [] # Vaciamos la lista - # Tooltips + # Tooltips if self.showing_tooltip: if isinstance(self.active_tooltip, Text): self.screen.fill((255, 255, 255), self.active_tooltip.rect_in_container) diff --git a/Saludame.activity/kid_window.py b/Saludame.activity/kid_window.py index 669e92d..578d187 100644 --- a/Saludame.activity/kid_window.py +++ b/Saludame.activity/kid_window.py @@ -13,15 +13,15 @@ class KidWindow(gui.Window): def __init__(self, container, rect, frame_rate, windows_controller, game_man): gui.Window.__init__(self, container, rect, frame_rate, windows_controller, "kid") - self.set_bg_image(pygame.image.load(BACKGROUND_PATH).convert()) + self.set_bg_image(pygame.image.load(BACKGROUND_PATH).convert()) - self.kid_rect = pygame.Rect((280, 70), (350, 480)) - self.mood = "normal" + self.kid_rect = pygame.Rect((280, 70), (350, 480)) + self.mood = "normal" self.kid = animation.Kid(rect, self.kid_rect, 1, windows_controller, game_man, self.mood) self.add_window(self.kid) - self.kid.set_bg_image(self.bg_image.subsurface(self.kid_rect)) + self.kid.set_bg_image(self.bg_image.subsurface(self.kid_rect)) self.balloon = None @@ -39,7 +39,7 @@ class KidWindow(gui.Window): ##### Environment ##### def set_environment(self, environment): - self.set_bg_image(pygame.image.load(environment.background_path).convert()) + self.set_bg_image(pygame.image.load(environment.background_path).convert()) self.kid.set_bg_image(self.bg_image.subsurface(self.kid_rect)) self.repaint = True @@ -47,7 +47,7 @@ class KidWindow(gui.Window): def update_clothes(self): self.kid.update_clothes() - ##### Moods ##### + ##### Moods ##### def change_mood(self): self.kid.change_mood() @@ -95,15 +95,15 @@ class KidWindow(gui.Window): # If the menu is showing repaint the whole window if self.menu.show: self.last_repaint = True - self.repaint = True + self.repaint = True changes += gui.Window.draw(self, screen, frames) - if self.balloon: + if self.balloon: if not self.balloon.visible: self.remove_kid_balloon() - if self.external_character: + if self.external_character: if not self.external_character.visible: self.remove_social_event() @@ -122,32 +122,32 @@ class ExternalCharacter(gui.Window): self.visible = True self.time_span = event.message_time_span - self.message_balloon = MessageBalloon(self.container, pygame.Rect(580, 80, 1, 1), 1, self.windows_controller) + self.message_balloon = MessageBalloon(self.container, pygame.Rect(580, 80, 1, 1), 1, self.windows_controller) self.message_balloon.set_text(event.person_message) self.message_balloon.set_time_span(self.time_span) # same time_span as character self.bg1 = (self.windows_controller.screen.subsurface(self.rect).copy()) self.bg2 = (self.windows_controller.screen.subsurface(self.message_balloon.rect).copy()) - # Override handle_mouse_down + # Override handle_mouse_down def handle_mouse_down(self, (x, y)): self.visible = False def draw(self, screen, frames): - if (not self.time_span): + if not self.time_span: self.visible = False - if (self.visible): + if self.visible: changes = [] self.time_span -= 1 self.repaint = True changes += gui.Window.draw(self, screen, frames) changes += self.message_balloon.draw(screen, frames) return changes - else: + else: screen.blit(self.bg1, self.rect) screen.blit(self.bg2, self.message_balloon.rect) self.dispose() - return [self.rect, self.message_balloon.rect] + return [self.rect, self.message_balloon.rect] class MessageBalloon(gui.Window): @@ -166,7 +166,7 @@ class MessageBalloon(gui.Window): self.visible = True - # Override handle_mouse_down + # Override handle_mouse_down def handle_mouse_down(self, (x, y)): self.visible = False @@ -178,9 +178,9 @@ class MessageBalloon(gui.Window): self.time_span = time_span def draw(self, screen, frames): - if (not self.time_span): + if not self.time_span: self.visible = False - if (self.visible): + if self.visible: self.time_span -= 1 self.repaint = True return gui.Window.draw(self, screen, frames) diff --git a/Saludame.activity/main_window.py b/Saludame.activity/main_window.py index 264f187..1224789 100755 --- a/Saludame.activity/main_window.py +++ b/Saludame.activity/main_window.py @@ -33,7 +33,7 @@ class MainWindow(gui.Window): self.add_child(Clock(container, pygame.Rect(0, 528, 1, 1), 1, game_man)) - # Challenges + # Challenges challenges_button = gui.ImageButton(self.rect, pygame.Rect((1120, 400), (60, 60)), 1, "challenges/trophy.png", self._cb_button_click_mc_challenges) challenges_button.set_tooltip(_("Multiple choice")) self.add_button(challenges_button) diff --git a/Saludame.activity/menu.py b/Saludame.activity/menu.py index 4c88223..2b14895 100755 --- a/Saludame.activity/menu.py +++ b/Saludame.activity/menu.py @@ -57,7 +57,7 @@ class Menu(gui.Window): self.back.rect_in_container.center = center self.back.set_rect_in_container(self.back.rect_in_container) - self.actual_selection = self.item_list #list of actual subitems selection + self.current_selection = self.item_list #list of current subitems selection self.radius = RADIUS self.show = False @@ -79,11 +79,11 @@ class Menu(gui.Window): if self.on_expansion: if self.radius < 90: self.radius += EXP_SPEED - self.__calculate_items_position(self.actual_selection) + self.__calculate_items_position(self.current_selection) else: self.on_expansion = False - for item in self.actual_selection: + for item in self.current_selection: item.draw_item(screen) changes.append(item.rect_absolute) @@ -109,24 +109,24 @@ class Menu(gui.Window): self.game_manager.execute_action(action_id) self.close() - def set_actual_selection(self, items_list): + def set_current_selection(self, items_list): """ - Set the actual items selection. + Set the current items selection. """ - if(not self.on_expansion): - actual_selection = self.get_allowed_items(items_list) # gets some allowed items, fewer than nine - if len(actual_selection) > MAX_ITEMS: - actual_selection = random.sample(actual_selection, MAX_ITEMS) + if not self.on_expansion: + current_selection = self.get_allowed_items(items_list) # gets some allowed items, fewer than nine + if len(current_selection) > MAX_ITEMS: + current_selection = random.sample(current_selection, MAX_ITEMS) - self.actual_selection = actual_selection + self.current_selection = current_selection # self.on_expansion = True #if the selection changes, display the animation self.radius = 0 def get_allowed_items(self, items_list): """ - Verifies wich items are allowed to perform its actions - for currently character's properties. + Verifies wich items are allowed to perform its actions + for currently character's properties. """ allowed_items = [] for item in items_list: @@ -217,7 +217,7 @@ class Menu(gui.Window): self.show = False self.depth = 0 self.previous_items = [] - self.actual_selection = [] + self.current_selection = [] self.game_manager.menu_active = False def back_to_previous_selection(self): @@ -225,7 +225,7 @@ class Menu(gui.Window): comes back to a previous items selection. """ self.depth -= 1 - self.set_actual_selection(self.previous_items[self.depth]) + self.set_current_selection(self.previous_items[self.depth]) if self.depth == 0: self.previous_items = [] @@ -233,26 +233,26 @@ class Menu(gui.Window): """ shows the recive items """ - self.previous_items.append(self.actual_selection) + self.previous_items.append(self.current_selection) self.depth += 1 - self.set_actual_selection(subitems_list) + self.set_current_selection(subitems_list) #handlers def handle_mouse_down(self, coord): if self.show and not self.on_expansion: if self.exit.rect_absolute.collidepoint(coord) and self.depth == 0: - self.close() + self.close() elif self.exit.rect_absolute.collidepoint(coord) and self.depth > 0: #click on back item, it's in the same position of exit item self.back_to_previous_selection() else: - for item in self.actual_selection: + for item in self.current_selection: if item.rect_absolute.collidepoint(coord): item.on_mouse_click() break else: - self.set_actual_selection(self.item_list) + self.set_current_selection(self.item_list) self.show = True self.game_manager.menu_active = True @@ -260,9 +260,9 @@ class Menu(gui.Window): def calculate(self): """ - Calculate the position for each menu's actual selection. + Calculate the position for each menu's current selection. """ - self.__calculate_items_position(self.actual_selection) + self.__calculate_items_position(self.current_selection) def __calculate_items_position(self, item_list): if len(item_list) > 0: @@ -280,7 +280,7 @@ class Menu(gui.Window): """ coord = int(self.center[0] + math.cos(angle) * self.radius), int(self.center[1] + math.sin(angle) * self.radius) rect = item.rect_in_container - if coord[0] < self.center[0]: + if coord[0] < self.center[0]: if coord[1] > self.center[1]: #third quadrant rect.topright = coord elif coord[1] < self.center[1]: #second quadrant diff --git a/Saludame.activity/menu_creator.py b/Saludame.activity/menu_creator.py index 1c96cb4..fddda49 100755 --- a/Saludame.activity/menu_creator.py +++ b/Saludame.activity/menu_creator.py @@ -43,7 +43,7 @@ items = [ (_("Leche chocolatada"), "assets/icons/icon.png", "leche_chocolatada", None), (_("Café con leche"), "assets/icons/icon.png", "leche_cafe", None), (_("Leche"), "assets/icons/icon.png", "leche", None), - (_("Leche con cereales"), "assets/icons/icon.png", "leche_cereales", None)], + (_("Leche con cereales"), "assets/icons/icon.png", "leche_cereales", None)], ["schoolyard", "home"], ["morning", "afternoon"] ), @@ -126,5 +126,3 @@ def create_item(item_tuple, a_menu, container, font): elif lenght == 6: # the item has time restrictions item = menu.Item(container, MENU_FRAME_RATE, item_tuple[0], item_tuple[1], item_tuple[2], subitems, a_menu, font, item_tuple[4], item_tuple[5]) return item - - diff --git a/Saludame.activity/panel_window.py b/Saludame.activity/panel_window.py index b48e7c7..8686099 100644 --- a/Saludame.activity/panel_window.py +++ b/Saludame.activity/panel_window.py @@ -21,7 +21,7 @@ class PanelWindow(gui.Window): def __init__(self, container, rect, frame_rate, windows_controller): - self.timing = 1 # la idea de timing es llevar una cuenta adentro, de los frames que fueron pasando + self.timing = 1 # la idea de timing es llevar una cuenta adentro, de los frames que fueron pasando gui.Window.__init__(self, container, rect, frame_rate, windows_controller, "panel_window") self.set_bg_image(PANEL_BG_PATH) @@ -30,16 +30,16 @@ class PanelWindow(gui.Window): self.rect_action = pygame.Rect((560, 36), (310, 124)) self.on_animation = False - self.actual_action = None - self.actual_animation = None + self.current_action = None + self.current_animation = None - self.action_progress_bar = None + self.action_progress_bar = None # Personal self.surf_personal = pygame.Surface((130, 110)) self.rect_personal = pygame.Rect((410, 652), self.surf_personal.get_rect().size) self.active_personal_events = [] # tuple (event, button) - self.index_personal_event = 0 + self.index_personal_event = 0 personal_next = gui.ImageButton(self.rect_personal, pygame.Rect(105, 80, 30, 30), 1, "assets/events/go-next.png", self._cb_button_click_personal_next) personal_back = gui.ImageButton(self.rect_personal, pygame.Rect(0, 80, 30, 30), 1, "assets/events/go-back.png", self._cb_button_click_personal_back) @@ -78,7 +78,7 @@ class PanelWindow(gui.Window): info_button = gui.ImageButton(self.rect, pygame.Rect(953, 0, 1, 1), 1, "assets/layout/info.png", self._cb_button_click_stop_action) self.add_button(info_button) - # Environment + # Environment self.weather_button = None self.set_weather() @@ -94,10 +94,10 @@ class PanelWindow(gui.Window): # Actions def set_active_action(self, action): - self.actual_action = action + self.current_action = action if action.window_animation_path: - self.actual_animation = animation.ActionAnimation(self.rect, self.rect_action, 10, action.window_animation_path, action.sound_path) - self.add_child(self.actual_animation) + self.current_animation = animation.ActionAnimation(self.rect, self.rect_action, 10, action.window_animation_path, action.sound_path) + self.add_child(self.current_animation) else: rect_progress = self.rect_action.move(65, 45) rect_progress.size = (182, 26) @@ -110,10 +110,10 @@ class PanelWindow(gui.Window): def stop_action_animation(self): self.on_animation = False - self.actual_action = None - if self.actual_animation: - self.remove_child(self.actual_animation) - self.actual_animation = None + self.current_action = None + if self.current_animation: + self.remove_child(self.current_animation) + self.current_animation = None self.repaint = True if self.action_progress_bar: @@ -123,7 +123,7 @@ class PanelWindow(gui.Window): # Events def add_personal_event(self, event): - if not event in self.active_personal_events: + if not event in self.active_personal_events: b_event_personal = gui.ImageButton(self.rect_personal, pygame.Rect(23, 3, 100, 100), 1, pygame.image.load("assets/events/%s" % (event.picture)).convert()) event_info = "%s \n" % (event.description) @@ -131,7 +131,7 @@ class PanelWindow(gui.Window): if event.effect: for eff in event.effect.effect_status_list: bar_label = event.effect.bars_controller.get_bar_label(eff[0]) - if (eff[1] > 0): + if eff[1] > 0: event_info += "+ %s \n" % (bar_label) else: event_info += "- %s \n" % (bar_label) @@ -164,7 +164,7 @@ class PanelWindow(gui.Window): self.windows_controller.hide_active_tooltip() - self.refresh_count_personal_events() + self.refresh_count_personal_events() def add_social_event(self, event): if not event in self.active_social_events: @@ -176,7 +176,7 @@ class PanelWindow(gui.Window): if event.effect: for eff in event.effect.effect_status_list: bar_label = event.effect.bars_controller.get_bar_label(eff[0]) - if (eff[1] > 0): + if eff[1] > 0: event_info += "+ %s \n" % (bar_label) else: event_info += "- %s \n" % (bar_label) @@ -235,7 +235,7 @@ class PanelWindow(gui.Window): self.timing += 1 # Actions - if self.on_animation and self.actual_animation and self.timing % self.actual_animation.frame_rate == 0: + if self.on_animation and self.current_animation and self.timing % self.current_animation.frame_rate == 0: if self.timing > 12: self.timing = 0 @@ -258,7 +258,7 @@ class PanelWindow(gui.Window): if game.set_library_function: game.set_library_function("99-Eventos.html") #diarrhea") - def _cb_button_click_personal_next(self, button): + def _cb_button_click_personal_next(self, button): if self.index_personal_event < len (self.active_personal_events) - 1: self.remove_button(self.b_event_personal) self.index_personal_event += 1 @@ -269,12 +269,12 @@ class PanelWindow(gui.Window): def _cb_button_click_personal_back(self, button): if self.index_personal_event > 0: self.remove_button(self.b_event_personal) - self.index_personal_event -= 1 - self.refresh_count_personal_events() + self.index_personal_event -= 1 + self.refresh_count_personal_events() self.b_event_personal = self.active_personal_events[self.index_personal_event][1] self.add_button(self.b_event_personal) - def _cb_button_click_social_next(self, button): + def _cb_button_click_social_next(self, button): if self.index_social_event < len (self.active_social_events) - 1: self.remove_button(self.b_event_social) self.index_social_event += 1 @@ -286,9 +286,9 @@ class PanelWindow(gui.Window): if self.index_social_event > 0: self.remove_button(self.b_event_social) self.index_social_event -= 1 - self.refresh_count_social_events() + self.refresh_count_social_events() self.b_event_social = self.active_social_events[self.index_social_event][1] - self.add_button(self.b_event_social) + self.add_button(self.b_event_social) def _cb_button_click_customization(self, button): self.windows_controller.set_active_window("customization_window") @@ -328,7 +328,7 @@ class ActionProgressBar(gui.Widget): """ Draw the progress bar (if the action is still active), override widget draw """ - if (self.decrease > 0): - self._prepare_surface() - screen.blit(self.surface, self.rect_absolute) + if self.decrease > 0: + self._prepare_surface() + screen.blit(self.surface, self.rect_absolute) return self.rect_absolute diff --git a/Saludame.activity/saludame_windows_controller.py b/Saludame.activity/saludame_windows_controller.py index 9ff9577..9a128c4 100644 --- a/Saludame.activity/saludame_windows_controller.py +++ b/Saludame.activity/saludame_windows_controller.py @@ -43,12 +43,12 @@ class SaludameWindowsController(gui.WindowsController): # BACKGROUND def set_environment(self, environment): - self.windows["kid"].set_environment(environment) + self.windows["kid"].set_environment(environment) # CLOTHES def update_clothes(self): - self.windows["kid"].update_clothes() + self.windows["kid"].update_clothes() # Actions @@ -59,8 +59,8 @@ class SaludameWindowsController(gui.WindowsController): self.windows["panel_window"].play_action_animation(action) self.windows["kid"].play_action_animation(action) - def stop_actual_action_animation(self): - self.windows["panel_window"].stop_action_animation() + def stop_current_action_animation(self): + self.windows["panel_window"].stop_action_animation() self.windows["kid"].stop_action_animation() @@ -72,7 +72,7 @@ class SaludameWindowsController(gui.WindowsController): self.show_kid_message(event.kid_message, event.message_time_span) def remove_personal_event(self, event): - self.windows["panel_window"].remove_personal_event(event) + self.windows["panel_window"].remove_personal_event(event) def add_social_event(self, event): self.windows["panel_window"].add_social_event(event) @@ -81,7 +81,7 @@ class SaludameWindowsController(gui.WindowsController): self.windows["kid"].add_social_event(event) def remove_social_event(self, event): - self.windows["panel_window"].remove_social_event(event) + self.windows["panel_window"].remove_social_event(event) # Messages at ballon @@ -92,5 +92,4 @@ class SaludameWindowsController(gui.WindowsController): # Moods def set_mood(self, mood): if self.windows: - self.windows["kid"].set_mood(mood) - \ No newline at end of file + self.windows["kid"].set_mood(mood) diff --git a/Saludame.activity/status_bars.py b/Saludame.activity/status_bars.py index 4ac8a2a..b283a50 100755 --- a/Saludame.activity/status_bars.py +++ b/Saludame.activity/status_bars.py @@ -96,7 +96,7 @@ class BarsWindow(gui.Window): class Accordeon: """ - Clase encargada de realizar los calculos para expandir y + Clase encargada de realizar los calculos para expandir y contraer las secciones. """ @@ -116,7 +116,7 @@ class Accordeon: self.compress_sections() for i in range(0, len(self.sections_list)): - if(self.sections_list[i] == section): + if self.sections_list[i] == section: self.sections_list[i].expand() offset = self.sections_list[i].max_expand @@ -376,7 +376,7 @@ class BarsController: def increase_bar(self, bar_id, increase_rate): for bar in self.bars: - if(bar.id == bar_id): + if bar.id == bar_id: bar.increase(increase_rate) break @@ -386,7 +386,7 @@ class BarsController: self.score_bar.increase(3) else: #more than a half. self.score_bar.increase(1) - else: + else: if self.overall_bar.value < (self.overall_bar.max / 2) - (self.overall_bar.max / 4): #less than 1/4 self.score_bar.increase(-3) else: # less than 1/2 @@ -404,7 +404,7 @@ class BarsController: def get_bars_status(self): """ - Generates a dictionary {bar_id : actual_bar_value} and + Generates a dictionary {bar_id : bar_value} and returns it. """ bars_state = {} @@ -424,11 +424,11 @@ class BarsController: def get_lowest_bar(self): value = self.bars[0].value lowest_bar = None - for bar in self.bars[0:4]: # bars in second_level (section bars) are self.bars[0:4] + for bar in self.bars[0:4]: # bars in second_level (section bars) are self.bars[0:4] if bar.value <= value: value = bar.value lowest_bar = bar - return lowest_bar + return lowest_bar def reset(self): """ @@ -512,4 +512,3 @@ class WeightBar(StatusBar): return self.value * 2.0 else: return self.max - 2.0 * self.value - diff --git a/Saludame.activity/status_bars_creator.py b/Saludame.activity/status_bars_creator.py index 426b59b..2577a4b 100755 --- a/Saludame.activity/status_bars_creator.py +++ b/Saludame.activity/status_bars_creator.py @@ -31,13 +31,13 @@ class BarsLoader: hygiene_children_bar = [status_bars.StatusBar(id[0], id[1], hygiene, [], hard_level[0], hard_level[1]) for id in hygiene_children_id] hygiene.children_list = hygiene_children_bar - ### nutrition + ### nutrition nutrition_children_id = [("c_leguminosas", _("Cereales y leguminosas")), ("v_frutas", _("Verduras y frutas")), ("c_huevos", _("Carnes y huevos")), ("dulces", _("Dulces")), ("g_aceites", _("Grasas y aceites")), ("l_quesos", _("Leches y quesos")), ("agua", _("Agua"))] nutrition = status_bars.StatusBar("nutrition", _("Alimentation"), self.overall_bar, [], hard_level[0], hard_level[1]) nutrition_children_bar = [status_bars.StatusBar(id[0], id[1], nutrition, [], hard_level[0], hard_level[1]) for id in nutrition_children_id] nutrition.children_list = nutrition_children_bar - ### fun + ### fun fun_children_id = [("sports", _("Deportes")), ("fun", _(u"Diversión")), ("relaxing", _("Descanso")), ("responsability", _("Responsabilidad"))] fun = status_bars.StatusBar("spare_time", _("Tiempo Libre"), self.overall_bar, [], hard_level[0], hard_level[1]) fun_children_bar = [status_bars.StatusBar(id[0], id[1], fun, [], hard_level[0], hard_level[1]) for id in fun_children_id] @@ -66,4 +66,3 @@ class BarsLoader: def get_score_bar(self): return self.score_bar - diff --git a/Saludame.activity/utilities.py b/Saludame.activity/utilities.py index c355246..104c802 100755 --- a/Saludame.activity/utilities.py +++ b/Saludame.activity/utilities.py @@ -43,7 +43,7 @@ def check_image(image_path): try: print image_path pygame.image.load(image_path) - return True + return True except: return False @@ -58,6 +58,6 @@ def verify_path(action, game_manager): 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 check_image(game_manager.environments_dictionary[action.effect.place_id + "_" + game_manager.current_weather].background_path) return True -- cgit v0.9.1