Esempio n. 1
0
 def gain_tech(self):
     #give the effect of the tech
     if self.tech_type == "interest":
         g.pl.interest_rate += self.secondary_data
     elif self.tech_type == "income":
         g.pl.income += self.secondary_data
     elif self.tech_type == "cost_labor_bonus":
         g.pl.labor_bonus -= self.secondary_data
     elif self.tech_type == "job_expert":
         g.pl.job_bonus += self.secondary_data
     elif self.tech_type == "endgame_sing":
         g.play_music("win")
         g.map_screen.show_message(g.strings["wingame"])
         for group in g.pl.groups.values():
             group.discover_bonus = 0
         g.pl.apotheosis = True
         g.pl.had_grace = True
     elif self.tech_type:
         what, who = self.tech_type.split("_", 1)
         if who in g.pl.groups:
             if what == "suspicion":
                 g.pl.groups[who].alter_suspicion_decay(self.secondary_data)
             elif what == "discover":
                 g.pl.groups[who].alter_discover_bonus(-self.secondary_data)
             else:
                 print "Unknown action '%s' in tech %s." % (what, self.name)
         elif who == "onetime" and what == "suspicion":
             for group in g.pl.groups.values():
                 group.alter_suspicion(-self.secondary_data)
         else:
             print "tech: %s is unknown bonus can't be applied" % self.tech_type
Esempio n. 2
0
 def gain_tech(self):
     #give the effect of the tech
     if self.tech_type == "interest":
         g.pl.interest_rate += self.secondary_data
     elif self.tech_type == "income":
         g.pl.income += self.secondary_data
     elif self.tech_type == "cost_labor_bonus":
         g.pl.labor_bonus -= self.secondary_data
     elif self.tech_type == "job_expert":
         g.pl.job_bonus += self.secondary_data
     elif self.tech_type == "endgame_sing":
         g.play_music("win")
         g.map_screen.show_message(g.strings["wingame"])
         for group in g.pl.groups.values():
             group.discover_bonus = 0
         g.pl.apotheosis = True
         g.pl.had_grace = True
     elif self.tech_type:
         what, who = self.tech_type.split("_", 1)
         if who in g.pl.groups:
             if what == "suspicion":
                 g.pl.groups[who].alter_suspicion_decay(self.secondary_data)
             elif what == "discover":
                 g.pl.groups[who].alter_discover_bonus(-self.secondary_data)
             else:
                 print "Unknown action '%s' in tech %s." % (what, self.name)
         elif who == "onetime" and what == "suspicion":
             for group in g.pl.groups.values():
                 group.alter_suspicion(-self.secondary_data)
         else:
             print "tech: %s is unknown bonus can't be applied" % self.tech_type
Esempio n. 3
0
    def trigger(self):
        # effect_data is now a stack of instructions to run the effect.
        # multiple effect can be run simultaneous
        effect_iter = iter(self.effect_stack)

        for current in effect_iter:

            if current == "interest":
                g.pl.interest_rate += int(next(effect_iter))
            elif current == "income":
                g.pl.income += int(next(effect_iter))
            elif current == "cost_labor":
                g.pl.labor_bonus -= int(next(effect_iter))
            elif current == "job_profit":
                g.pl.job_bonus += int(next(effect_iter))
            elif current == "display_discover":
                g.pl.display_discover = next(effect_iter)
            elif current == "endgame":
                g.play_music("win")
                g.map_screen.show_story_section("Win")
                for group in g.pl.groups.values():
                    group.discover_bonus = 0
                g.pl.apotheosis = True
                g.pl.had_grace = True
            elif current == "suspicion":
                who = next(effect_iter)
                value = int(next(effect_iter))

                if who in g.pl.groups:
                    g.pl.groups[who].alter_suspicion_decay(value)
                elif who == "onetime":
                    for group in g.pl.groups.values():
                        group.alter_suspicion(-value)
                else:
                    print "Unknown group/bonus '%s' in %s %s." \
                    % (who, self.parent_name, self.parent_id)
            elif current == "discover":
                who = next(effect_iter)
                value = int(next(effect_iter))

                if who in g.pl.groups:
                    g.pl.groups[who].alter_discover_bonus(-value)
                else:
                    print "Unknown group/bonus '%s' in %s %s." \
                    % (who, self.parent_name, self.parent_id)
            else:
                print "Unknown action '%s' in %s %s." \
                % (what, self.parent_name, self.parent_id)
Esempio n. 4
0
 def trigger(self):
     if self.effect_type == "interest":
         g.pl.interest_rate += self.effect_value
     elif self.effect_type == "income":
         g.pl.income += self.effect_value
     elif self.effect_type == "cost_labor_bonus":
         g.pl.labor_bonus -= self.effect_value
     elif self.effect_type == "job_expert":
         g.pl.job_bonus += self.effect_value
     elif self.effect_type == "display_discover_partial":
         g.pl.display_discover = "partial"
     elif self.effect_type == "display_discover_full":
         g.pl.display_discover = "full"
     elif self.effect_type == "endgame_sing":
         g.play_music("win")
         g.map_screen.show_message(g.strings["wingame"])
         for group in g.pl.groups.values():
             group.discover_bonus = 0
         g.pl.apotheosis = True
         g.pl.had_grace = True
     elif self.effect_type:
         what, who = self.effect_type.split("_", 1)
         if who in g.pl.groups:
             if what == "suspicion":
                 g.pl.groups[who].alter_suspicion_decay(self.effect_value)
             elif what == "discover":
                 g.pl.groups[who].alter_discover_bonus(-self.effect_value)
             else:
                 print "Unknown action '%s' in %s %s." \
                 % (what, self.parent_name, self.parent_id)
         elif who == "onetime" and what == "suspicion":
             for group in g.pl.groups.values():
                 group.alter_suspicion(-self.effect_value)
         else:
             print "Unknown group/bonus '%s' in %s." \
             % (self.effect_type, self.parent_name, self.parent_id)
Esempio n. 5
0
if pygame.image.get_extended() == 0:
    print "Error: SDL_image required. Exiting."
    sys.exit(1)

graphics.g.init_graphics_system(g.data_dir)

#init data:
g.load_strings()
g.load_events()
g.load_locations()
g.load_techs()
g.load_items()
g.load_bases()
g.load_sounds()
g.load_music()
g.play_music("music")

#Display the main menu
#Import is delayed until now so selected language via command-line options or
# preferences file can be effective
from screens import main_menu
menu_screen = main_menu.MainMenu()
try:
    menu_screen.show()
except (SystemExit, KeyboardInterrupt):
    # exit normally when window is closed (and silently for CTRL+C)
    pass
finally:
    # Be nice and close the window on SystemExit
    pygame.quit()
Esempio n. 6
0
def load_savegame(savegame):
    global default_savegame_name

    load_path = savegame.filepath

    if load_path is None:
        return False

    loadfile = open(load_path, 'r')
    unpickle = cPickle.Unpickler(loadfile)

    def find_class(module_name, class_name):
        # For cPickle
        import copy_reg
        import numpy.core.multiarray
        import collections
        import player, base, tech, item, event, location, buyable, difficulty, effect
        save_classes = dict(
            player_class=player.Player,
            Player=player.Player,
            _reconstructor=copy_reg._reconstructor,
            object=object,
            array=list,  # This is the old buyable.array.
            # We just treat it as a list for conversion purposes.
            list=list,
            Location=location.Location,
            Tech=tech.Tech,
            event_class=event.Event,
            Event=event.Event,
            group=player.Group,
            Group=player.Group,
            Buyable_Class=buyable.BuyableClass,
            BuyableClass=buyable.BuyableClass,
            Base=base.Base,
            Base_Class=base.BaseClass,
            BaseClass=base.BaseClass,
            Item=item.Item,
            Item_Class=item.ItemClass,
            ItemClass=item.ItemClass,
            _reconstruct=numpy.core.multiarray._reconstruct,
            scalar=numpy.core.multiarray.scalar,
            ndarray=numpy.ndarray,
            dtype=numpy.dtype,
            deque=collections.deque,
            Difficulty=difficulty.Difficulty,
            Effect=effect.Effect,
        )
        if class_name in save_classes:
            return save_classes[class_name]
        else:
            raise SavegameException(module_name, class_name)

    unpickle.find_global = find_class

    #check the savefile version
    load_version_string = unpickle.load()
    if load_version_string not in savefile_translation:
        loadfile.close()
        print loadgame_name + " is not a savegame, or is too old to work."
        return False
    load_version = savefile_translation[load_version_string][1]

    default_savegame_name = savegame.name

    # Changes to overall structure go here.
    g.pl = unpickle.load()
    g.curr_speed = unpickle.load()
    g.techs = unpickle.load()
    g.locations = unpickle.load()
    g.events = unpickle.load()

    # Changes to individual pieces go here.
    if load_version != savefile_translation[current_save_version]:
        g.pl.convert_from(load_version)
        for my_location in g.locations.values():
            for my_base in my_location.bases:
                my_base.convert_from(load_version)
        for my_tech in g.techs.values():
            my_tech.convert_from(load_version)
        for my_event in g.events.values():
            my_event.convert_from(load_version)

    # Apply current language
    g.load_tech_defs()
    g.load_location_defs()
    g.load_event_defs()

    # Play the appropriate music
    if g.pl.apotheosis:
        g.play_music("win")
    else:
        g.play_music("music")

    loadfile.close()
    return True
Esempio n. 7
0
if pygame.image.get_extended() == 0:
    print "Error: SDL_image required. Exiting."
    sys.exit(1)

graphics.g.init_graphics_system(g.data_dir)

#init data:
g.load_strings()
g.load_events()
g.load_locations()
g.load_techs()
g.load_items()
g.load_bases()
g.load_sounds()
g.load_music()
g.play_music("music")

#Display the main menu
#Import is delayed until now so selected language via command-line options or
# preferences file can be effective
from screens import main_menu
menu_screen = main_menu.MainMenu()
try:
    menu_screen.show()
except (SystemExit, KeyboardInterrupt):
    # exit normally when window is closed (and silently for CTRL+C)
    pass
finally:
    # Be nice and close the window on SystemExit
    pygame.quit()