def __init__(self, position_name, name_img, obj, vertical_shift=0): """ Args: position_name ('str'): The key to obtain the position of this button. name_img ('str'): The key to obtain name of the button image. obj (class:'Object_Into'): The object to be displayed by the button. Note: Object_Into is a general class. Some of the classes that extends this class are Pokemon or Move. vertical_shift ('int'): Vertical shift where display the button Action: Create an General Button to show relevant information of 'obj' and allows to detect if it has been clicked. """ top_left_location = Select_Config[position_name] height = Display_Config['BATTLE_SIZE'][1] + Display_Config['LOG_SIZE'][ 1] height_shift = (vertical_shift, height) self.location_pre_scale = shift(top_left_location, height_shift) Image.__init__(self, name_img, self.location_pre_scale) self.obj = obj button_shift = Select_Config['BUTTON_NAME_SHIFT'] self.font_name = Font(self.location_pre_scale, button_shift) self.font_name.set_text('' if obj == None else obj.name())
def __init__(self): """ Args: - Action: Create an extension of the "Display" class to display the dialog section of the game. """ top_left_location = (0, Display_Config['BATTLE_SIZE'][1]) bg = Image(Directory['DIALOG_FILE'], top_left_location) self.font = Font(top_left_location, Dialog_Config['LOG_TEXT_SHIFT']) Display.__init__(self, [bg, self.font])
def __init__(self, position_name, move, vertical_shift=0): """ Args: position_name ('str'): The key to obtain the position. move (class:'Move'): The move to be displayed by the button. vertical_shift ('int'): Vertical shift where display the button Action: Create an extencion of 'Button' to show relevant information abount 'move'. """ Button_Move.__init__(self, position_name, move, vertical_shift) x, y = scale( shift(self.location_pre_scale, Select_Config['SHIFT_RECT_EFF'])) width, height = scale(Select_Config['SIZE_RECT_EFF']) # Create rectangles width_1 = width / 2 self.bar_0 = Rect(x, y, width_1, height) self.bar_1 = Rect(x + width_1, y, width_1, height) y += height + scale([1, Select_Config['V_SPACE_RECTS']])[1] self.bar_2 = Rect(x, y, width, height) #Create text effectiveness text_shift = shift( Select_Config['SHIFT_RECT_EFF'],\ Select_Config['SHIFT_TEXT_EFF']) self.text_0 = Font(self.location_pre_scale, text_shift) text_shift_1 = shift(text_shift, [Select_Config['SIZE_RECT_EFF'][0] / 2, 0]) self.text_1 = Font(self.location_pre_scale, text_shift_1) #Create text info move aux = Select_Config['SIZE_RECT_EFF'][1] + Select_Config['V_SPACE_RECTS'] text_shift_2 = shift(text_shift, [-Select_Config['SHIFT_TEXT_EFF'][0] / 2, aux]) self.text_2 = Font(self.location_pre_scale, text_shift_2) #Set text info move string_pattern = 'P: {pow} A: {acc} {tp}' pow = self.obj.power() acc = self.obj.accuracy() if self.obj.accuracy() != None else '-' dmg_class = ' Sp.' if self.obj.damage_class() == 'special' else 'Ph.' string = string_pattern.format(pow=pow, acc=acc, tp=dmg_class) self.text_2.set_text(string)
def __init__(self, position_name, move, vertical_shift=0): """ Args: position_name ('str'): The key to obtain the position. move (class:'Move'): The move to be displayed by the button. vertical_shift ('int'): Vertical shift where display the button Action: Create an extencion of 'Button' to show relevant information abount 'move'. """ if move != None: name_img = Directory['CELL_NAME'].format( move.type().name().lower()) else: name_img = Directory['NONE_CELL_FILE'] Button.__init__(self, position_name, name_img, move, vertical_shift) if move != None: a_pp_shift = Select_Config['BUTTON_A_PP_SHIFT'] self.font_actual_pp = Font(self.location_pre_scale, a_pp_shift) m_pp_shift = Select_Config['BUTTON_M_PP_SHIFT'] self.font_max_pp = Font(self.location_pre_scale, m_pp_shift) self.font_max_pp.set_text(num_to_text(move.max_pp()))