Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Moleri <pmoleri@gmail.com>2010-12-29 19:57:18 (GMT)
committer Pablo Moleri <pmoleri@gmail.com>2010-12-29 19:57:18 (GMT)
commitc94c6f08e265b1c411b6bf840771d7cd7921e79f (patch)
tree92439bf2ad3979ab4633f33b8bb727fca6c87065
parent7cc3724d4c4be7e52ae2b325228ec4c5cc97940a (diff)
parentde53ded4d45bc6d6d19acc60b746cf0c1eed6a34 (diff)
Merge branch 'master' of git.sugarlabs.org:saludame/mainline
-rwxr-xr-xSaludame.activity/app_init.py3
-rwxr-xr-xSaludame.activity/character.py11
-rwxr-xr-xSaludame.activity/character_creator.py62
-rwxr-xr-xSaludame.activity/game_manager.py47
-rwxr-xr-xSaludame.activity/status_bars.py6
5 files changed, 102 insertions, 27 deletions
diff --git a/Saludame.activity/app_init.py b/Saludame.activity/app_init.py
index 8f62630..ac5b4f1 100755
--- a/Saludame.activity/app_init.py
+++ b/Saludame.activity/app_init.py
@@ -33,7 +33,7 @@ class AppLoader:
### game manager
- self.game_man = game_manager.GameManager(self.character, self.status_bars_controller, None, self.events_list, None, character_loader.get_environments_dictionary(), self.moods_list, windows_controller)
+ 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.game_man.actions_list = self.actions_list
@@ -148,3 +148,4 @@ class AppLoader:
m_normal, m_happy3, m_happy2, m_happy1]
return moods_list
+
diff --git a/Saludame.activity/character.py b/Saludame.activity/character.py
index 7fd07ac..1a6a23b 100755
--- a/Saludame.activity/character.py
+++ b/Saludame.activity/character.py
@@ -37,16 +37,6 @@ class Character:
Get the character current status, and returns
a dictionary.
"""
- #status = {"hair_color" : self.hair_color,
- # "socks_color" : self.socks_color,
- # "skin_color" : self.skin_color,
- # "shoes_color" : self.shoes_color,
- # "current_place" : self.current_place,
- # "name" : self.name,
- # "level" : self.level,
- # "grade" : self.grade,
- # "clothes" : self.clothes
- # }
status = {"character_colors" : self.mappings, # add by CustomizatedKid in module customization.
"current_place" : self.current_place,
"name" : self.name,
@@ -127,3 +117,4 @@ class Clothes:
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 7197cc1..e98d902 100755
--- a/Saludame.activity/character_creator.py
+++ b/Saludame.activity/character_creator.py
@@ -28,9 +28,10 @@ import pygame
class CharacterLoader:
def __init__(self):
- self.clothes_list = self.__load_clothes()
- self.character = self.__load_character(SEX, NAME, LEVEL, SCORE, self.clothes_list[0])
- self.environments_dictionary = self.__load_environments()
+ self.character = self.__load_character(SEX, NAME, LEVEL, SCORE, "school")
+ self.environments_dictionary = self.__load_environments()
+ self.places = self.__load_places()
+ self.weather_effects = self.__load_weather_effects()
def get_character(self):
return self.character
@@ -38,8 +39,11 @@ class CharacterLoader:
def get_environments_dictionary(self):
return self.environments_dictionary
- def __load_clothes(self):
- return ["a clothes"]
+ def get_places(self):
+ return self.places
+
+ def get_weather_effects(self):
+ return self.weather_effects
def __load_character(self, sex, name, level, score, clothes):
hair_color = [pygame.Color(color) for color in HAIR_COLOR]
@@ -50,6 +54,53 @@ class CharacterLoader:
char = character.Character(sex, name, level, score, hair_color, socks_color, skin_color, shoes_color, clothes)
return char
+ def __load_weather_effects(self):
+ weather_effects = {
+ # (clothes_id, weather_id, boolean indoor outdoor) : list of tuples [(id_bar, rate)]
+ #school clothes
+ ("school", "sunny", True) : [("fun", 1.0)],
+ ("school", "sunny", False) : [("physica", 1.0)],
+ ("school", "rainy", True) : [("physica", 1.0)],
+ ("school", "rainy", False) : [("physica", 1.0)],
+ ("school", "normal", True) : [("physica", 1.0)],
+ ("school", "normal", False) : [("physica", 1.0)],
+ ("school", "cold", True) : [("physica", 1.0)],
+ ("school", "cold", False) : [("physica", 1.0)],
+ #sunny clothes
+ ("sunny", "sunny", True) : [("physica", 1.0)],
+ ("sunny", "sunny", False) : [("physica", 1.0)],
+ ("sunny", "rainy", True) : [("physica", 1.0)],
+ ("sunny", "rainy", False) : [("physica", 1.0)],
+ ("sunny", "normal", True) : [("physica", 1.0)],
+ ("sunny", "normal", False) : [("physica", 1.0)],
+ ("sunny", "cold", True) : [("physica", 1.0)],
+ ("sunny", "cold", False) : [("physica", 1.0)],
+ #rainy clothes
+ ("rainy", "sunny", True) : [("physica", 1.0)],
+ ("rainy", "sunny", False) : [("physica", 1.0)],
+ ("rainy", "rainy", True) : [("physica", 1.0)],
+ ("rainy", "rainy", False) : [("physica", 1.0)],
+ ("rainy", "normal", True) : [("physica", 1.0)],
+ ("rainy", "normal", False) : [("physica", 1.0)],
+ ("rainy", "cold", True) : [("physica", 1.0)],
+ ("rainy", "cold", False) : [("physica", 1.0)],
+ }
+ return weather_effects
+
+ def __load_places(self):
+ places = { #schoolyard
+ "schoolyard" : {"outdoor": True},
+ #square
+ "square" : {"outdoor": True},
+ #classroom
+ "classroom" : {"outdoor": False},
+ #home
+ "home": {"outdoor": False},
+ #country
+ "country": {"outdoor": True}
+ }
+ return places
+
def __load_environments(self):
environments = {#schoolyard
"schoolyard_sunny" : character.Environment("assets/background/schoolyard_sunny.png", "music_path"),
@@ -79,3 +130,4 @@ class CharacterLoader:
}
return environments
+
diff --git a/Saludame.activity/game_manager.py b/Saludame.activity/game_manager.py
index 4e78d46..e096898 100755
--- a/Saludame.activity/game_manager.py
+++ b/Saludame.activity/game_manager.py
@@ -22,7 +22,7 @@ class GameManager:
y los eventos del juego.
"""
- def __init__(self, character, bars_controller, actions_list, events_list, places_list, environments_dictionary, moods_list, windows_controller):
+ def __init__(self, character, bars_controller, actions_list, events_list, places_dictionary, environments_dictionary, weather_effects, moods_list, windows_controller):
"""
Constructor de la clase
"""
@@ -52,7 +52,7 @@ class GameManager:
self.active_mood = None
self.__check_active_mood() # sets active_mood
- self.places_list = places_list
+ self.places_dictionary = places_dictionary
#for events handling:
self.events_interval = EVENTS_OCCURRENCE_INTERVAL
@@ -74,7 +74,9 @@ class GameManager:
#for weather
self.p_i = 0
-
+ self.weather_effects = weather_effects
+ self.environment_effect = None # this is an Effect that represents the effect on the character by the environment: weather + place + clothes
+ self.update_environment_effect()
# management
def pause_game(self):
@@ -97,6 +99,11 @@ class GameManager:
self.__check_active_mood() # check if the active character mood
self.__handle_time()
+ if self.environment_effect:
+ self.environment_effect.activate()
+ else:
+ self.update_environment_effect()
+
self.count = 0
## Environment handling
@@ -110,6 +117,18 @@ class GameManager:
self.environment = self.environments_dictionary[environment_id]
self.windows_controller.set_environment(self.environment)
+
+ def update_environment_effect(self):
+ """
+ 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"]
+ affected_bars = self.weather_effects[(self.character.clothes, self.current_weather, outdoor)]
+ effect = effects.Effect(self.bars_controller, affected_bars)
+
+ self.environment_effect = effect
+ print "environment effect updated: ", affected_bars
### time of day
@@ -140,6 +159,7 @@ class GameManager:
Set the current weather.
"""
self.current_weather = weather
+ self.update_environment_effect()
def get_random_weather(self):
"""
@@ -166,14 +186,13 @@ class GameManager:
self.character.current_place = place_id
self.update_environment()
+ self.update_environment_effect()
def get_place(self, place_id):
"""
- Returns the place asociated to the place_id
+ (not implemented) Returns the place asociated to the place_id
"""
- for place in self.places_list:
- if(place.id == place_id):
- return place
+ None
### Clothes
def set_character_clothes(self, clothes_id):
@@ -181,8 +200,10 @@ class GameManager:
Set the character clothes.
"""
self.character.set_clothes(clothes_id)
- self.windows_controller.update_clothes()
print "character's clothes: ", clothes_id
+
+ self.update_environment_effect()
+ self.windows_controller.update_clothes()
## Actions handling
@@ -487,10 +508,13 @@ class GameManager:
# weather
self.current_weather = "sunny" # default weather
self.update_environment()
+ self.update_environment_effect()
+ self.windows_controller.update_clothes()
# hour
self.hour = 2
self.hour_count = HOUR_COUNT_CYCLE
self.current_time = self.day_dic[self.hour]
+ print "game reseted successfully... "
def save_game(self):
"""
@@ -525,10 +549,14 @@ class GameManager:
#load bars status
self.bars_controller.load_bars_status(game_status)
+ print "status bars loaded..."
#character properties
self.character.load_properties(game_status)
-
+ print "character properties loaded..."
+
self.update_environment()
+ self.update_environment_effect()
+ self.windows_controller.update_clothes()
print "se cargo la partida con exito. Version ", game_status["version"]
except:
@@ -561,3 +589,4 @@ class GameManager:
return self.current_time
+
diff --git a/Saludame.activity/status_bars.py b/Saludame.activity/status_bars.py
index 4c8749e..4db7dd6 100755
--- a/Saludame.activity/status_bars.py
+++ b/Saludame.activity/status_bars.py
@@ -9,6 +9,7 @@ from window import *
import game_manager
DEFAULT_BARS_VALUES = 50.0
+MAX_BARS_VALUE = 100
SECTION_OFFSET_X = 0
SECTION_WIDTH = 220
@@ -284,7 +285,8 @@ class BarDisplay(Widget):
if self.last_value != self.status_bar.value:
if isinstance(self.status_bar, WeightBar):
- arrow_position = self.status_bar.value * (self.rect_in_container.width - 2.0) / self.status_bar.max
+ position = self.status_bar.value * (self.rect_in_container.width) / (BAR_WIDTH)
+ arrow_position = min([position, BAR_WIDTH + BAR_OFFSET_X])
self.surface.blit(self.background, (0, 0))
self.surface.blit(self.arrow, (arrow_position, 14))
elif isinstance(self.status_bar, StatusBar):
@@ -509,5 +511,5 @@ class WeightBar(StatusBar):
if self.value < 50:
return self.value * 2.0
else:
- return 100.0 - 2.0 * self.value
+ return self.max - 2.0 * self.value