示例#1
0
 def callback():
     client.client.chat('/novice')
     found_nations = [ (name, style, id) for name, style, id in client.get_nations() if name == 'Poles' ]
     if found_nations:
         name, style, id = found_nations[0]
         print 'change nation to', name, style, id
         client.freeciv.func.set_nation_settings(id, 'Player', style, 2)
     return True
示例#2
0
 def pick_nation(self):
     def set_nation(style, id):
         self.city_style = style
         self.nation_id = id
         self.set_nation_settings()
         ui.back()
     nations = ui.LinearLayoutWidget()
     for name, style, id in client.get_nations():
         nations.add(ui.Button(name, functools.partial(set_nation, style, id)))
     
     ui.set_dialog(nations, scroll=True)
示例#3
0
    def pick_nation(self):
        def set_nation(style, id):
            self.city_style = style
            self.nation_id = id
            self.set_nation_settings()
            ui.back()
        nations = ui.LinearLayoutWidget()
        for name, style, id in client.get_nations():
            nations.add(ui.Button(name, functools.partial(set_nation, style, id)))

        ui.set_dialog(nations, scroll=True)
示例#4
0
    def setup_ui(self):
        self.has_ui = True
        self.items = []

        client.client.chat('/set nettimeout 0')
        client.client.chat('/set pingtimeout 1800')
        client.client.chat('/set endspaceship disabled')
        client.client.chat('/set victories ALLIED')

        self.pick_nation_button = ui.Button('...', self.pick_nation)
        self.set_leader_name_button = ui.Button('...',
                                                lambda:
                                                uidialog.inputbox('What will be your name?',
                                                                  finish=self.set_leader_name))
        self.difficulty_button = ui.Button('...', self.set_difficulty)

        self.add(ui.Button('Start game!', start_client))
        self.add(self.pick_nation_button)
        self.add(self.set_leader_name_button)
        self.add(self.difficulty_button)
        self.add(ui.Button('Server command', server_command_dialog))

        self.aicount_button = ui.Button('...',
                                        lambda:
                                        uidialog.inputbox('How many computer enemies will you fight?',
                                                          finish=self.set_aicount))
        self.set_aicount(3)
        self.add(self.aicount_button)

        hex_tiles = ''
        if features.get('app.hex_tiles'):
            hex_tiles = '|HEX'
        if features.get('app.ruleset') == 'civ2civ3':
            self.mapsize_button = ui.Button('...',
                                        lambda:
                                        uidialog.inputbox('How large your map will be? (in tiles per player) (1-1000)',
                                                          finish=self.set_tilesperplayer))
            client.client.chat('/set topology WRAPX|WRAPY|ISO' + hex_tiles)
            self.set_tilesperplayer(100)
        else:
            self.mapsize_button = ui.Button('...',
                                        lambda:
                                        uidialog.inputbox('How large your map will be? (in thousands of tiles) (1-20)',
                                                          finish=self.set_mapsize))
            client.client.chat('/set topology WRAPX|ISO' + hex_tiles)
            self.set_mapsize(4)
        self.add(self.mapsize_button)

        self.barbarians_button = ui.Button('...', self.set_barbarians)
        self.barbarians = False
        self.set_barbarians()
        self.add(self.barbarians_button)

        nation = random.choice(client.get_nations())
        self.nation_id = nation[2]
        self.leader_name = 'Player'
        self.city_style = nation[1]
        self.leader_sex = 2
        self.difficulty = features.get('app.difficulty')

        self.set_nation_settings()
        self.set_difficulty_settings()

        self.server_console = ui.Label('loading...', font=ui.consolefont)
        self.add(self.server_console)
        self.update_server_console()
示例#5
0
 def set_nation_group(self, group_id=-1):
     self.nation_group_id = group_id
     self.nations.clear()
     for name, style, id in client.get_nations(group_id):
         self.nations.add(ui.Button(name, functools.partial(self.callback, style, id)))
示例#6
0
 def set_nation_group(self, group_id=-1):
     self.nation_group_id = group_id
     self.nations.clear()
     for name, style, id in client.get_nations(group_id):
         self.nations.add(
             ui.Button(name, functools.partial(self.callback, style, id)))