def begin(self, gameStateObj, metaDataObj):
        if not self.started:
            self.config = [('Animation', ['Always', 'Your Turn', 'Combat Only', 'Never'], cf.WORDS['Animation_desc'], 0),
                           ('temp_Screen Size', ['1', '2', '3', '4', '5'], cf.WORDS['temp_Screen Size_desc'], 18),
                           ('Unit Speed', list(reversed(range(15, 180, 15))), cf.WORDS['Unit Speed_desc'], 1),
                           ('Text Speed', cf.text_speed_options, cf.WORDS['Text Speed_desc'], 2),
                           ('Cursor Speed', list(reversed(range(0, 220, 20))), cf.WORDS['Cursor Speed_desc'], 8),
                           ('Show Terrain', ['ON', 'OFF'], cf.WORDS['Show Terrain_desc'], 7),
                           ('Show Objective', ['ON', 'OFF'], cf.WORDS['Show Objective_desc'], 6),
                           ('Autocursor', ['ON', 'OFF'], cf.WORDS['Autocursor_desc'], 13),
                           ('HP Map Team', ['All', 'Ally', 'Enemy'], cf.WORDS['HP Map Team_desc'], 10),
                           ('HP Map Cull', ['None', 'Wounded', 'All'], cf.WORDS['HP Map Cull_desc'], 10),
                           ('Music Volume', [x/10.0 for x in range(0, 11, 1)], cf.WORDS['Music Volume_desc'], 15),
                           ('Sound Volume', [x/10.0 for x in range(0, 11, 1)], cf.WORDS['Sound Volume_desc'], 16),
                           ('Autoend Turn', ['ON', 'OFF'], cf.WORDS['Autoend Turn_desc'], 14),
                           ('Confirm End', ['ON', 'OFF'], cf.WORDS['Confirm End_desc'], 14),
                           ('Display Hints', ['ON', 'OFF'], cf.WORDS['Display Hints_desc'], 3)]

            self.controls = {'key_SELECT': Engine.subsurface(GC.IMAGESDICT['Buttons'], (0, 66, 14, 13)),
                             'key_BACK': Engine.subsurface(GC.IMAGESDICT['Buttons'], (0, 82, 14, 13)),
                             'key_INFO': Engine.subsurface(GC.IMAGESDICT['Buttons'], (1, 149, 16, 9)),
                             'key_AUX': Engine.subsurface(GC.IMAGESDICT['Buttons'], (1, 133, 16, 9)),
                             'key_START': Engine.subsurface(GC.IMAGESDICT['Buttons'], (0, 165, 33, 9)),
                             'key_LEFT': Engine.subsurface(GC.IMAGESDICT['Buttons'], (1, 4, 13, 12)),
                             'key_RIGHT': Engine.subsurface(GC.IMAGESDICT['Buttons'], (1, 19, 13, 12)),
                             'key_DOWN': Engine.subsurface(GC.IMAGESDICT['Buttons'], (1, 34, 12, 13)),
                             'key_UP': Engine.subsurface(GC.IMAGESDICT['Buttons'], (1, 50, 12, 13))}

            self.currentSelection = 0
            self.start_offset = 32
            self.top_of_menu = 0

            self.control_order = ['key_SELECT', 'key_BACK', 'key_INFO', 'key_AUX', 'key_LEFT', 'key_RIGHT', 'key_UP', 'key_DOWN', 'key_START']

            self.background = MenuFunctions.MovingBackground(GC.IMAGESDICT['StatusBackground'])

            self.state = CustomObjects.StateMachine('TopMenu')

            Counters.CursorControl.__init__(self)
            self.up_arrow = GUIObjects.ScrollArrow('up', (GC.WINWIDTH//2 - 7, self.start_offset - 4), 0)
            self.down_arrow = GUIObjects.ScrollArrow('down', (GC.WINWIDTH//2 - 7, self.start_offset + 6*16 - 1), 0.5)
            self.left_arrow = GUIObjects.ScrollArrow('left', (0, 0), 0)
            self.right_arrow = GUIObjects.ScrollArrow('right', (0, 0), 0.5)

            self.backSurf = gameStateObj.generic_surf

            # Transition in:
            gameStateObj.stateMachine.changeState("transition_in")
            return 'repeat'
Beispiel #2
0
    def __init__(self, gameStateObj, upkeep=True):
        # Initial setup
        self.upkeep = upkeep  # Whether I'm running this on upkeep or on endstep
        self.current_phase = gameStateObj.phase.get_current_phase()
        self.previous_phase = gameStateObj.phase.get_previous_phase()
        affected_units = [
            unit for unit in gameStateObj.allunits
            if unit.position and unit.status_effects
        ]
        if self.upkeep:
            self.units = [
                unit for unit in affected_units
                if unit.team == self.current_phase
            ]
        else:
            self.units = [
                unit for unit in affected_units
                if unit.team == self.previous_phase
            ]
        logger.info('Building Status_Processor: %s %s %s', self.upkeep,
                    self.current_phase, self.previous_phase)

        # State control
        self.current_unit = None
        self.current_unit_statuses = []
        self.current_status = None
        self.status_index = 0
        self.state = CustomObjects.StateMachine('begin')
        self.state_buffer = False

        # Animation properties
        self.time_spent_on_each_status = 1200  # Only if it has a onetime animation
        self.start_time_for_this_status = Engine.get_time()

        # Health bar
        self.health_bar = Interaction.HealthBar('splash', None, None)

        # Waiting timer
        self.wait_time = 200
        self.started_waiting = Engine.get_time()
Beispiel #3
0
    def __init__(self,
                 gameStateObj,
                 unit,
                 exp,
                 force_level=None,
                 force_promote=False,
                 in_combat=False):
        self.unit = unit
        # if cf.OPTIONS['debug']:
        #     print('LevelUpScreen: ', exp)

        self.expNew = min(100, exp)
        self.expOld = self.unit.exp
        self.expSet = self.expOld

        self.force_level = force_level or force_promote
        self.in_combat = in_combat
        self.prev_level = self.unit.level
        self.new_wexp = None  # For promotion

        # spriting
        self.levelUpScreen = GC.IMAGESDICT['LevelScreen']
        if self.in_combat:
            topleft = (0, 6)
            timing = [1 for _ in range(19)] + [10, 1, 1, 1, 1, 1] + [
                2 for _ in range(15)
            ] + [-1] + [1 for _ in range(12)]
            self.levelUpAnimation = CustomObjects.Animation(
                GC.IMAGESDICT['LevelUpBattle'],
                topleft, (5, 11),
                52,
                ignore_map=True,
                set_timing=timing)
        else:
            if unit.position:
                x, y = unit.position
                topleft = (x - gameStateObj.cameraOffset.x -
                           2) * GC.TILEWIDTH, (y - gameStateObj.cameraOffset.y
                                               - 1) * GC.TILEHEIGHT
            else:
                topleft = GC.WINWIDTH // 2, GC.WINHEIGHT // 2
            timing = [1 for _ in range(24)] + [44]
            self.levelUpAnimation = CustomObjects.Animation(
                GC.IMAGESDICT['LevelUpMap'],
                topleft, (5, 5),
                ignore_map=True,
                set_timing=timing)
        self.statupanimation = GC.IMAGESDICT['StatUpSpark']
        self.statunderline = GC.IMAGESDICT['StatUnderline']
        self.uparrow = GC.IMAGESDICT['LevelUpArrow']
        self.numbers = GC.IMAGESDICT['LevelUpNumber']

        self.exp_bar = None

        self.levelup_list = force_level
        self.sparkCounter = -1  # Where we are in the levelScreen spark display section
        self.lastSparkUpdate = Engine.get_time()
        self.first_spark_flag = False
        self.unit_scroll_offset = 80
        self.screen_scroll_offset = self.levelUpScreen.get_width() + 32
        self.underline_offset = 0
        self.state = CustomObjects.StateMachine('init')
        self.animations, self.arrow_animations, self.number_animations = [], [], []
        if force_level:
            # Need to prevent from going over max
            current_stats = list(self.unit.stats.values())
            klass = gameStateObj.metaDataObj['class_dict'][self.unit.klass]
            for index, stat in enumerate(self.levelup_list):
                self.levelup_list[index] = min(
                    stat, klass['max'][index] - current_stats[index].base_stat)
            self.unit.apply_levelup(self.levelup_list, exp == 0)
            self.state.changeState('levelScreen')
            self.state_time = Engine.get_time()
        if force_promote:
            self.state.changeState('item_promote')
            self.state_time = Engine.get_time()

        # TIMING
        self.total_time_for_exp = self.expNew * GC.FRAMERATE  # exp rate is 16
        self.level_up_sound_played = False
        self.SPARKTIME = 320
        self.LEVELUPWAIT = 1660