예제 #1
0
 def __init__(self, text, type, group, number=0):
     self.type = type
     self.group = group
     self.text = AlphaText(text, group, number)
     self.make_active_zone()
     self.init_for_group(number)
     self.init_for_type()
예제 #2
0
 def make_person_texts(self, person):
     obj = self.text[person]
     for key in ('info', 'splitter'):
         if key == 'info':
             text = Globals.TEMP_VARS['trading'][person]['info'].name
             text_type = 'trade_summary_' + person + '_name'
         else:
             text = '- - - - - - - - - - - - - - - - - - - - - - - - -'
             text_type = 'trade_summary_trader_splitter'
         obj[key] = AlphaText(text, text_type)
         y_pos = (0, 34)[person == 'tradingwith'] + 14*(key == 'splitter')
         obj[key].rect.topleft = (100, y_pos)
         obj[key].new_pos = (0, obj[key].rect.y)
예제 #3
0
 def make_person_texts(self, person):
     obj = self.text[person]
     for key in ('info', 'splitter'):
         if key == 'info':
             text = Globals.TEMP_VARS['trading'][person]['info'].name
             text_type = 'trade_summary_' + person + '_name'
         else:
             text = '- - - - - - - - - - - - - - - - - - - - - - - - -'
             text_type = 'trade_summary_trader_splitter'
         obj[key] = AlphaText(text, text_type)
         y_pos = (0, 34)[person == 'tradingwith'] + 14 * (key == 'splitter')
         obj[key].rect.topleft = (100, y_pos)
         obj[key].new_pos = (0, obj[key].rect.y)
예제 #4
0
 def __init__(self):
     self.text = {}
     for person in ('trader', 'tradingwith'):
         self.text[person] = {
             'fields': AlphaText('', 'trade_summary_fields'),
             'money': AlphaText('', 'trade_summary_fields'),
             'jail': AlphaText('', 'trade_summary_fields')
         }
     self.make_person_texts('trader')
     pos = (Globals.RESOLUTION[0] - 290,
            Globals.main_scr.objects['game_log'].pos[1])
     new_pos = (Globals.RESOLUTION[0] - 290,
                Globals.main_scr.objects['game_log'].new_pos[1])
     InfoWindow.__init__(self, pos, new_pos)
예제 #5
0
 def __init__(self, text, type, group, number=0):
     self.type = type
     self.group = group
     self.text = AlphaText(text, group, number)
     self.make_active_zone()
     self.init_for_group(number)
     self.init_for_type()
예제 #6
0
 def __init__(self):
     self.messages = [
         AlphaText(Globals.GAMELOG_TRANSLATION[0], 'gamelog_message_common',
                   0)
     ]
     self.add_message('change_player')
     InfoWindow.__init__(self, (10, 170), (10, 70))
예제 #7
0
 def add_field(self, num):
     temp_var = Globals.TEMP_VARS['prop_manage_CHANGED']
     self.storage[num] = temp_var[num]
     pics = prop_manage_pictures().replace(u'●', u'X')
     state = []
     for i in range(2):
         if Globals.main_scr.objects['gamefield'].cells[num].group in (
                 'railroad', 'service') and temp_var[num][i] > -1:
             state.append(pics[1])
         else:
             state.append(pics[temp_var[num][i] + 1])
     self.text[num] = [
         AlphaText(str(num), 'prop_manage_summary_fields'),
         AlphaText(':', 'prop_manage_summary_fields'),
         AlphaText(state[0] + ' -> ' + state[1],
                   'prop_manage_summary_fields'),
         AlphaText(('', '+')[temp_var[num][2] > 0] + str(temp_var[num][2]),
                   'prop_manage_summary_fields')
     ]
     self.upd_TOTAL()
예제 #8
0
 def __init__(self, group_symbol, group_colors, build_costs, number, size,
              pos):
     self.owner = None
     self.NAME = None
     self.buildings = 0
     if number in Globals.TEMP_VARS['onboard_text']['fieldnames'].keys():
         self.NAME = Globals.TEMP_VARS['onboard_text']['fieldnames'][number]
     #--- Onboard text
     self.number = number
     self.group = Globals.TEMP_VARS['cells_groups'][number]
     self.group_symbol = group_symbol
     if self.group in range(9):
         self.build_cost = build_costs[self.group - 1]
     if number in Globals.TEMP_VARS['cells_cost'].keys():
         self.buy_cost = Globals.TEMP_VARS['cells_cost'][number]
     else:
         self.buy_cost = None
     if number in Globals.TEMP_VARS['cells_rent_costs'].keys():
         self.rent_costs = Globals.TEMP_VARS['cells_rent_costs'][number]
     else:
         self.rent_costs = None
     if self.group in range(1, 9):
         self.group_color = group_colors[self.group - 1]
     else:
         self.group_color = None
     if number in Globals.TEMP_VARS['onboard_text']['onboard'].keys():
         self.onboard_text = Globals.FONTS['ubuntu_16'].render(
             Globals.TEMP_VARS['onboard_text']['onboard'][number], True,
             Globals.COLORS['black'])
     else:
         self.onboard_text = None
     self.a_little_number = AlphaText(str(number), 'a_little_cell_number',
                                      number)
     self.a_little_number_visible = False
     self.step_indicator = AlphaText(u'●', 'step_indicator', number)
     self.step_indicator_visible = False
     #--- Position, rect and surface
     self.pos = pos
     self.rect = pygame.Rect((0, 0), size)
     self.surf = pygame.Surface(size)
     self.color = Globals.COLORS['grey22']
예제 #9
0
 def make_header(self):
     obj = self.text
     for key in ('info', 'splitter1', 'splitter2', 'total', 'totalmoney'):
         if key == 'info':
             text = check_cur_prop_management()
             text = text.name
             text_type = 'prop_manage_summary_name'
         elif key == 'total':
             text = 'TOTAL:'
             text_type = 'prop_manage_summary_fields'
         elif key == 'totalmoney':
             text = str(Globals.TEMP_VARS['prop_manage_CHANGED']['TOTAL'])
             text_type = 'prop_manage_summary_fields'
         else:
             text = '- - - - - - - - - - - - - - - - - - - - - - - - -'
             text_type = 'prop_manage_summary_splitter'
         obj[key] = AlphaText(text, text_type)
         if key == 'totalmoney': Xpos = 160 - obj[key].rect.w
         else: Xpos = 0
         obj[key].rect.topleft = (Xpos + 100, 0)
         obj[key].new_pos = (Xpos, 0)
예제 #10
0
 def make_header(self):
     obj = self.text
     for key in ('info', 'splitter1', 'splitter2', 'total', 'totalmoney'):
         if key == 'info':
             text = check_cur_prop_management()
             text = text.name
             text_type = 'prop_manage_summary_name'
         elif key == 'total':
             text = 'TOTAL:'
             text_type = 'prop_manage_summary_fields'
         elif key == 'totalmoney':
             text = str(Globals.TEMP_VARS['prop_manage_CHANGED']['TOTAL'])
             text_type = 'prop_manage_summary_fields'
         else:
             text = '- - - - - - - - - - - - - - - - - - - - - - - - -'
             text_type = 'prop_manage_summary_splitter'
         obj[key] = AlphaText(text, text_type)
         if key == 'totalmoney': Xpos = 160 - obj[key].rect.w
         else: Xpos = 0
         obj[key].rect.topleft = (Xpos + 100, 0)
         obj[key].new_pos = (Xpos, 0)
예제 #11
0
 def add_rm_items(self, add, new_length):
     if add:
         for i in range(len(self.items), new_length):
             self.items.append(AlphaText(u'●', self.type, i))
             self.items[i].rect.topleft = self.items[i].new_pos
             self.rects.append(
                 pygame.Rect(self.items[i].rect.inflate(
                     self.cursor_inflate)))
     else:
         self.items = self.items[:new_length]
         self.rects = self.rects[:new_length]
         if self.active >= new_length:
             self.apply_new_active(new_length - 1)
예제 #12
0
 def __init__(self, type):
     self.type = type
     itemcount_start = 0
     if 'volume_SELECTOR' in type:
         text = 10 * u'●'
         itemcount_end = 10
         self.active = int(Globals.SETTINGS['volume'] * 10 - 1)
     elif type == 'main_settings_player_color_SELECTOR':
         text = 10 * u'●'
         itemcount_end = len(Globals.PLAYERS_COLORS)
         if Globals.PLAYERS[Globals.TEMP_VARS[
                 'edit_player']].color in Globals.PLAYERS_COLORS:
             self.active = Globals.PLAYERS_COLORS.index(
                 Globals.PLAYERS[Globals.TEMP_VARS['edit_player']].color)
         else:
             self.active = 0
     elif type == 'main_new_total_SELECTOR':
         text = 10 * u'●'
         itemcount_start = 1
         itemcount_end = 6
         self.active = len(Globals.PLAYERS) - 2
     elif type == 'main_new_humans_SELECTOR':
         text = 10 * u'●'
         itemcount_end = len(Globals.PLAYERS)
         for i in range(len(Globals.PLAYERS)):
             if Globals.PLAYERS[i].human:
                 self.active = i
     elif type == 'cell_state_SELECTOR':
         num = int(Globals.main_scr.
                   labels['property_management_input_ready'].symbols)
         gamefield = Globals.main_scr.objects['gamefield']
         group = gamefield.cells[num].group
         itemcount_end = 2 + (5 - int(Globals.TEMP_VARS['cur_game'])) * (
             group in range(9)) * bool(gamefield.groups_monopolies[group])
         self.active = gamefield.cells[num].buildings + 1
         if group in ('railroad', 'service') and self.active > 0:
             self.active = 1
         text = prop_manage_pictures()
     self.items = [
         AlphaText(text[i], type, i)
         for i in range(itemcount_start, itemcount_end)
     ]
     self.cursor_inflate = (10, 16)
     self.rects = [
         pygame.Rect(item.rect.inflate(self.cursor_inflate))
         for item in self.items
     ]
     self.cursor = SelectorCursor(self.rects[self.active])
     if type == 'in_game_volume_SELECTOR':
         self.cursor.new_cords = self.rects[self.active].topleft
예제 #13
0
class MenuItem():
    def __init__(self, text, type, group, number=0):
        self.type = type
        self.group = group
        self.text = AlphaText(text, group, number)
        self.make_active_zone()
        self.init_for_group(number)
        self.init_for_type()
    def init_for_group(self, number):
        self.HOTKEYS = ()
        if self.group == 'onboard_select_cell':
            self.cursor = FieldCellCursor(self.active_zone)
            self.tooltip = Tooltip(number, 'fieldcells_info')
        elif self.group == 'pl_info_tab':
            self.cursor = OwnCursor('light_blue', self.active_zone)
            self.tooltip = Tooltip(Globals.PLAYERS[number].name, 'left', self.text, 'ubuntu_13')
        elif self.group == 'from_game_return_to_menu':
            self.cursor = OwnCursor('light_brown', self.active_zone)
            self.tooltip = Tooltip(u'HOTKEY: Escape', 'left', self.text)
            self.HOTKEYS = (pygame.K_ESCAPE)
        elif self.group == 'show_menu':
            self.cursor = OwnCursor('orange', self.active_zone)
            self.tooltip = Tooltip(u'HOTKEYS: PageDown, PageUp', 'downright', self.text)
            self.HOTKEYS = (pygame.K_PAGEDOWN, pygame.K_PAGEUP)
        elif self.group == 'show_prev_trades':
            self.cursor = OwnCursor('orange', self.active_zone)
            self.tooltip = Tooltip(u'HOTKEYS: Tab', 'left', self.text)
            self.HOTKEYS = (pygame.K_TAB, None)
        elif self.group == 'volume_in_game':
            self.cursor = OwnCursor('grey', self.active_zone)
            self.tooltip = None
        elif self.group == 'music_and_sound_switches':
            self.cursor = OwnCursor('light_blue', self.active_zone)
            self.tooltip = None
        elif self.group == 'stats_switch':
            self.cursor = OwnCursor('light_green', self.active_zone)
            self.tooltip = Tooltip(u'HOTKEYS: ← →', 'top', self.text)
        else:
            self.tooltip = None
    def init_for_type(self):
        #--- Hotkeys
        if self.type in ('main_settings_language', 'main_settings_hotkeys', 'main_settings_music', 'main_settings_sounds', 'main_settings_build_style', 'main_settings_fav_game', 'stats_switch', 'main_new_game_switch'):
            self.HOTKEYS = (pygame.K_LEFT, pygame.K_RIGHT)
        #--- Selector
        if 'SELECTOR' in self.type:
            self.selector = MenuSelector(self.type)
    def move_text(self):
        self.text.move_text()
        if 'SELECTOR' in self.type:
            self.selector.move_text()
        self.make_active_zone()
        if self.group[:4] not in ('main', 'inga'):
            self.cursor.rect = self.active_zone.copy()
            if self.group not in ('onboard_select_cell', 'volume_in_game', 'music_and_sound_switches'):
                self.tooltip.move_text(self.text.rect)
    def change_new_pos(self, offset):
        self.text.new_pos = count_new_pos(self.text.new_pos, offset)
        if 'SELECTOR' in self.type:
            for item in self.selector.items:
                item.change_new_pos(offset)
    def update_text(self, text):
        self.text.update_text(text)
        self.make_active_zone()
    def make_active_zone(self):
        if self.group[:4] in ('main', 'inga'):
            if self.text.x == 'center':
                self.active_zone = self.text.rect.inflate(400-self.text.rect.w, 6)
            else:
                self.active_zone = self.text.rect.move(-100, -3)
                self.active_zone.size = (400, self.text.rect.h+6)
        elif self.group == 'onboard_select_cell':
            self.active_zone = self.text.rect
        elif self.group in ('from_game_return_to_menu', 'show_menu', 'show_prev_trades', 'music_and_sound_switches'):
            self.active_zone = self.text.rect.inflate(20, 10)
        elif self.type == 'in_game_volume_SELECTOR':
            self.active_zone = self.text.rect
            self.active_zone.size = (251, 33)
        else:
            self.active_zone = self.text.rect.inflate(6, 6)
    def render(self, state):
        if self.text.new_pos != self.text.rect.topleft:
            self.move_text()
        if self.group[:4] not in ('main', 'inga'):
            self.cursor.render(state)
            if self.tooltip and ((Globals.SETTINGS['hotkeys'] and self.HOTKEYS) or (not self.HOTKEYS)) and not (self.group == 'onboard_select_cell' and Globals.main_scr.objects['gamefield'].pos[1] != 70):
                self.tooltip.render(state)
        if 'SELECTOR' in self.type:
            self.selector.render(state)
        else:
            self.text.render(True)
    def action(self, key):
        play_click_sound()
        if self.group == 'main_settings_exit':
            Globals.SETTINGS['pl_name'] = Globals.PLAYERS[0].name
            Globals.SETTINGS['pl_color'] = Globals.PLAYERS[0].color
            Globals.TEMP_VARS.pop('edit_player')
            save_settings()
        elif self.group == 'music_and_sound_switches':
            type = self.type[8:len(self.type)-7]
            switch_sound_state(type, Globals.SETTINGS[type], True)
            self.text.choose_switch_color(type)
            self.update_text((u'✖', u'✓')[int(Globals.SETTINGS[type])])
            return self.group
        if 'SELECTOR' in self.type:
            return self.selector.action()
        elif self.type == 'ingame_start_game' and self.text.rect.topleft != self.text.new_pos:
            return None
        elif self.type == 'main_sysexit':
            SYSEXIT()
        elif self.type in ('main_settings_music', 'main_settings_sounds', 'main_settings_hotkeys', 'main_settings_build_style'):
            if self.type in ('main_settings_music', 'main_settings_sounds'):
                switch_sound_state(self.type[14:], Globals.SETTINGS[self.type[14:]])
            else:
                KEY = ('hotkeys', 'build_style')['build' in self.type]
                Globals.SETTINGS[KEY] = not Globals.SETTINGS[KEY]
            self.update_text(u'‹ '+Globals.TRANSLATION[18-int(Globals.SETTINGS[self.type[14:]])]+u' ›')
            return None
        elif self.type == 'game_start':
            if self.text.color == Globals.COLORS['white']:
                save_last_game_settings()
            else:
                return None
        elif self.type in ('main_new_game_switch', 'main_new_uniform_build'):
            key = ('cur_game', 'build_style')['build' in self.type]
            Globals.TEMP_VARS[key] = int(not(Globals.TEMP_VARS[key]))
            if key == 'cur_game':
                self.update_text(u'‹ '+Globals.TRANSLATION[5+int(Globals.TEMP_VARS[key])]+u' ›')
            else:
                self.update_text(u'‹ '+Globals.TRANSLATION[18-int(Globals.TEMP_VARS[key])]+u' ›')
            return None
        elif key != 'exit' and 'main_new_edit_player' in self.type:
            Globals.TEMP_VARS['edit_player'] = int(self.type[len(self.type)-1])
        elif self.type == 'main_settings_fav_game':
            Globals.SETTINGS['fav_game'] = int(not(Globals.SETTINGS['fav_game']))
            self.update_text(u'‹ '+Globals.TRANSLATION[5+int(Globals.SETTINGS['fav_game'])]+u' ›')
            return None
        elif self.type == 'main_settings_language':
            choose_next_language()
        elif self.type == 'onboard_select_cell' or 'pl_info_tab' in self.type:
            return None
        return self.type
예제 #14
0
class MenuItem():
    def __init__(self, text, type, group, number=0):
        self.type = type
        self.group = group
        self.text = AlphaText(text, group, number)
        self.make_active_zone()
        self.init_for_group(number)
        self.init_for_type()

    def init_for_group(self, number):
        self.HOTKEYS = ()
        if self.group == 'onboard_select_cell':
            self.cursor = FieldCellCursor(self.active_zone)
            self.tooltip = Tooltip(number, 'fieldcells_info')
        elif self.group == 'pl_info_tab':
            self.cursor = OwnCursor('light_blue', self.active_zone)
            self.tooltip = Tooltip(Globals.PLAYERS[number].name, 'left',
                                   self.text, 'ubuntu_13')
        elif self.group == 'from_game_return_to_menu':
            self.cursor = OwnCursor('light_brown', self.active_zone)
            self.tooltip = Tooltip(u'HOTKEY: Escape', 'left', self.text)
            self.HOTKEYS = (pygame.K_ESCAPE)
        elif self.group == 'show_menu':
            self.cursor = OwnCursor('orange', self.active_zone)
            self.tooltip = Tooltip(u'HOTKEYS: PageDown, PageUp', 'downright',
                                   self.text)
            self.HOTKEYS = (pygame.K_PAGEDOWN, pygame.K_PAGEUP)
        elif self.group == 'show_prev_trades':
            self.cursor = OwnCursor('orange', self.active_zone)
            self.tooltip = Tooltip(u'HOTKEYS: Tab', 'left', self.text)
            self.HOTKEYS = (pygame.K_TAB, None)
        elif self.group == 'volume_in_game':
            self.cursor = OwnCursor('grey', self.active_zone)
            self.tooltip = None
        elif self.group == 'music_and_sound_switches':
            self.cursor = OwnCursor('light_blue', self.active_zone)
            self.tooltip = None
        elif self.group == 'stats_switch':
            self.cursor = OwnCursor('light_green', self.active_zone)
            self.tooltip = Tooltip(u'HOTKEYS: ← →', 'top', self.text)
        else:
            self.tooltip = None

    def init_for_type(self):
        #--- Hotkeys
        if self.type in ('main_settings_language', 'main_settings_hotkeys',
                         'main_settings_music', 'main_settings_sounds',
                         'main_settings_build_style', 'main_settings_fav_game',
                         'stats_switch', 'main_new_game_switch'):
            self.HOTKEYS = (pygame.K_LEFT, pygame.K_RIGHT)
        #--- Selector
        if 'SELECTOR' in self.type:
            self.selector = MenuSelector(self.type)

    def move_text(self):
        self.text.move_text()
        if 'SELECTOR' in self.type:
            self.selector.move_text()
        self.make_active_zone()
        if self.group[:4] not in ('main', 'inga'):
            self.cursor.rect = self.active_zone.copy()
            if self.group not in ('onboard_select_cell', 'volume_in_game',
                                  'music_and_sound_switches'):
                self.tooltip.move_text(self.text.rect)

    def change_new_pos(self, offset):
        self.text.new_pos = count_new_pos(self.text.new_pos, offset)
        if 'SELECTOR' in self.type:
            for item in self.selector.items:
                item.change_new_pos(offset)

    def update_text(self, text):
        self.text.update_text(text)
        self.make_active_zone()

    def make_active_zone(self):
        if self.group[:4] in ('main', 'inga'):
            if self.text.x == 'center':
                self.active_zone = self.text.rect.inflate(
                    400 - self.text.rect.w, 6)
            else:
                self.active_zone = self.text.rect.move(-100, -3)
                self.active_zone.size = (400, self.text.rect.h + 6)
        elif self.group == 'onboard_select_cell':
            self.active_zone = self.text.rect
        elif self.group in ('from_game_return_to_menu', 'show_menu',
                            'show_prev_trades', 'music_and_sound_switches'):
            self.active_zone = self.text.rect.inflate(20, 10)
        elif self.type == 'in_game_volume_SELECTOR':
            self.active_zone = self.text.rect
            self.active_zone.size = (251, 33)
        else:
            self.active_zone = self.text.rect.inflate(6, 6)

    def render(self, state):
        if self.text.new_pos != self.text.rect.topleft:
            self.move_text()
        if self.group[:4] not in ('main', 'inga'):
            self.cursor.render(state)
            if self.tooltip and (
                (Globals.SETTINGS['hotkeys'] and self.HOTKEYS) or
                (not self.HOTKEYS)
            ) and not (self.group == 'onboard_select_cell'
                       and Globals.main_scr.objects['gamefield'].pos[1] != 70):
                self.tooltip.render(state)
        if 'SELECTOR' in self.type:
            self.selector.render(state)
        else:
            self.text.render(True)

    def action(self, key):
        play_click_sound()
        if self.group == 'main_settings_exit':
            Globals.SETTINGS['pl_name'] = Globals.PLAYERS[0].name
            Globals.SETTINGS['pl_color'] = Globals.PLAYERS[0].color
            Globals.TEMP_VARS.pop('edit_player')
            save_settings()
        elif self.group == 'music_and_sound_switches':
            type = self.type[8:len(self.type) - 7]
            switch_sound_state(type, Globals.SETTINGS[type], True)
            self.text.choose_switch_color(type)
            self.update_text((u'✖', u'✓')[int(Globals.SETTINGS[type])])
            return self.group
        if 'SELECTOR' in self.type:
            return self.selector.action()
        elif self.type == 'ingame_start_game' and self.text.rect.topleft != self.text.new_pos:
            return None
        elif self.type == 'main_sysexit':
            SYSEXIT()
        elif self.type in ('main_settings_music', 'main_settings_sounds',
                           'main_settings_hotkeys',
                           'main_settings_build_style'):
            if self.type in ('main_settings_music', 'main_settings_sounds'):
                switch_sound_state(self.type[14:],
                                   Globals.SETTINGS[self.type[14:]])
            else:
                KEY = ('hotkeys', 'build_style')['build' in self.type]
                Globals.SETTINGS[KEY] = not Globals.SETTINGS[KEY]
            self.update_text(u'‹ ' + Globals.TRANSLATION[
                18 - int(Globals.SETTINGS[self.type[14:]])] + u' ›')
            return None
        elif self.type == 'game_start':
            if self.text.color == Globals.COLORS['white']:
                save_last_game_settings()
            else:
                return None
        elif self.type in ('main_new_game_switch', 'main_new_uniform_build'):
            key = ('cur_game', 'build_style')['build' in self.type]
            Globals.TEMP_VARS[key] = int(not (Globals.TEMP_VARS[key]))
            if key == 'cur_game':
                self.update_text(
                    u'‹ ' +
                    Globals.TRANSLATION[5 + int(Globals.TEMP_VARS[key])] +
                    u' ›')
            else:
                self.update_text(
                    u'‹ ' +
                    Globals.TRANSLATION[18 - int(Globals.TEMP_VARS[key])] +
                    u' ›')
            return None
        elif key != 'exit' and 'main_new_edit_player' in self.type:
            Globals.TEMP_VARS['edit_player'] = int(self.type[len(self.type) -
                                                             1])
        elif self.type == 'main_settings_fav_game':
            Globals.SETTINGS['fav_game'] = int(not (
                Globals.SETTINGS['fav_game']))
            self.update_text(
                u'‹ ' +
                Globals.TRANSLATION[5 + int(Globals.SETTINGS['fav_game'])] +
                u' ›')
            return None
        elif self.type == 'main_settings_language':
            choose_next_language()
        elif self.type == 'onboard_select_cell' or 'pl_info_tab' in self.type:
            return None
        return self.type
예제 #15
0
 def __init__(self):
     self.list = []
     for i in range(len(Globals.TEMP_VARS['auction']['order'])):
         self.list.append(AlphaText(u'●', 'auction_player_order', i))
예제 #16
0
 def add_message(self, type):
     if type in ('roll_the_dice', 'chest_goto'):
         text = Globals.GAMELOG_TRANSLATION[(
             2, 10
         )[type == 'chest_goto']].replace(
             '%',
             str(Globals.PLAYERS[Globals.TEMP_VARS['cur_turn']].cur_field))
         if Globals.TEMP_VARS['dice1'] == Globals.TEMP_VARS[
                 'dice2'] and type == 'roll_the_dice':
             text += Globals.GAMELOG_TRANSLATION[23]
     elif type == 'change_player':
         text = Globals.GAMELOG_TRANSLATION[1].replace(
             '%', Globals.PLAYERS[Globals.TEMP_VARS['cur_turn']].name)
     elif type in ('ingame_continue_tax', 'ingame_continue_income'):
         text = Globals.GAMELOG_TRANSLATION[
             3 + 10 * (type[16:] == 'income')].replace(
                 '%',
                 str(Globals.TEMP_VARS['MUST_PAY'])[(type[16:] == 'tax'):])
     elif type == 'ingame_continue_PAY_RENT':
         text = Globals.GAMELOG_TRANSLATION[4].replace(
             '%', str(Globals.TEMP_VARS['MUST_PAY'])).replace(
                 '^', Globals.main_scr.objects['gamefield'].cells[
                     Globals.PLAYERS[
                         Globals.TEMP_VARS['cur_turn']].cur_field].owner)
     elif type == 'ingame_buy_a_cell':
         text = Globals.GAMELOG_TRANSLATION[5].replace(
             '%',
             str(Globals.PLAYERS[
                 Globals.TEMP_VARS['cur_turn']].cur_field)).replace(
                     '^', str(Globals.TEMP_VARS['MUST_PAY']))
     elif type == 'ingame_continue_gotojail':
         text = Globals.main_scr.objects['gamefield'].cells[30].NAME
         text = Globals.GAMELOG_TRANSLATION[6].replace(
             '%', text[text.index(' ') + 1:])
         if Globals.TEMP_VARS['double_dices_count'] == 3:
             text += Globals.GAMELOG_TRANSLATION[23]
     elif type == 'money_for_start_passing':
         text = Globals.GAMELOG_TRANSLATION[7].replace(
             '%',
             str(Globals.main_scr.objects['gamefield'].cells[0].buy_cost))
     elif type == 'chest_income':
         text = '- ' + Globals.GAMELOG_TRANSLATION[(3, 7)[
             Globals.TEMP_VARS['MUST_PAY'] > 0]].split()[1] + ' $' + str(
                 Globals.TEMP_VARS['MUST_PAY']).lstrip('-')
     elif type in ('chest_free_jail', 'use_card_to_exit_jail'):
         text = Globals.GAMELOG_TRANSLATION[
             9 + 5 * (type == 'use_card_to_exit_jail')]
     elif type == 'roll_the_dice_to_exit_jail':
         text = Globals.GAMELOG_TRANSLATION[8].replace(
             '%',
             str(Globals.PLAYERS[
                 Globals.TEMP_VARS['cur_turn']].exit_jail_attempts))
     elif type == 'pay_money_to_exit_jail':
         CELL = Globals.main_scr.objects['gamefield'].cells[10]
         text = Globals.GAMELOG_TRANSLATION[3].replace(
             '%', str(CELL.buy_cost)) + ' (' + CELL.NAME + ')'
     elif type == 'ingame_trading_ACCEPT_ALL':
         text = Globals.GAMELOG_TRANSLATION[15].replace(
             '1', Globals.TEMP_VARS['trading']['trader']['info'].name)
         text = text.replace(
             '2', Globals.TEMP_VARS['trading']['tradingwith']['info'].name)
     elif type[:18] == 'prop_manage_mortra':
         field = type[21:]
         temp_var = Globals.TEMP_VARS['prop_manage_CHANGED'][int(field)]
         IF = int(temp_var[0] < 0)
         cost = Globals.main_scr.objects['gamefield'].cells[int(
             field)].buy_cost / 2
         if IF: cost = int(cost * 1.1)
         text = Globals.GAMELOG_TRANSLATION[19 + IF].replace(
             '%', field) + str(cost)
     elif type[:18] == 'prop_manage_build_':
         field = type[18:]
         temp_var = Globals.TEMP_VARS['prop_manage_CHANGED'][int(field)]
         text = Globals.GAMELOG_TRANSLATION[21].replace(
             '%', field) + str(temp_var[2] + int(
                 int(temp_var[0] < 0) * 1.1 *
                 (Globals.main_scr.objects['gamefield'].cells[int(
                     field)].buy_cost / 2)))[1:]
     elif type[:18] == 'prop_manage_debuil':
         field = type[20:]
         temp_var = Globals.TEMP_VARS['prop_manage_CHANGED'][int(field)]
         text = Globals.GAMELOG_TRANSLATION[22].replace('%', field) + str(
             temp_var[2] - int(temp_var[1] < 0) * Globals.main_scr.
             objects['gamefield'].cells[int(field)].buy_cost / 2)
     elif type == 'auction_end':
         temp_var = Globals.TEMP_VARS['auction']
         if temp_var['bet']:
             text = Globals.GAMELOG_TRANSLATION[17].replace(
                 '%', str(temp_var['field'].number))
             self.messages.append(
                 AlphaText(text, 'gamelog_message_common',
                           len(self.messages)))
             text = Globals.GAMELOG_TRANSLATION[18].replace(
                 '%', temp_var['player'].name)
             text = text.replace('@', str(temp_var['bet']))
         else:
             text = Globals.GAMELOG_TRANSLATION[16]
     elif type[:16] == 'bankruptcy_field':
         temp_var = Globals.TEMP_VARS['bankruptcy_fields_changing'][0]
         CELL = Globals.main_scr.objects['gamefield'].cells[temp_var]
         money = CELL.buy_cost / 20
         if type == 'bankruptcy_field_10':
             num = 25
         else:
             num = 20
             money += CELL.buy_cost / 2
         text = Globals.GAMELOG_TRANSLATION[num].replace(
             '%', str(CELL.number)) + str(money)
     elif type == 'bankrupt_player':
         player = check_cur_prop_management()
         text = '- ' + player.name + Globals.GAMELOG_TRANSLATION[24]
     elif type in ('birthday', 'pay_each'):
         text = Globals.GAMELOG_TRANSLATION[
             11 + (type == 'pay_each')].replace(
                 '%', str(Globals.TEMP_VARS['MUST_PAY']))
     ATtype = ('gamelog_message_common',
               'gamelog_message_player_switched')[type == 'change_player']
     self.messages.append(AlphaText(text, ATtype, len(self.messages)))
     if len(self.messages) > 24:
         count = len(self.messages) - 24
         for i in range(count):
             self.messages.pop(i)
         for message in self.messages:
             message.change_new_pos((0, -18 * count))