Example #1
0
def game_start(asd, gamers):
    # schnelles durchprobieren, ob genug spieler da sind
    amount_players = 0
    for i in range(0, 4):  # enough players or bots
        if gamers[i] in [1, 2, 4]:  # human, bot or networkplayer
            amount_players += 1
    if amount_players in [0, 1]:
        return
    del amount_players
    for i in range(4):  # players with no names
        if start_window.names[i].get_text() == "" and start_window.sel_but.get_active_text() != "Closed":
            start_window.bgohg = gtk.MessageDialog(message_format="Ein Spieler hat keinen Namen")
            start_window.bgohg.show_all()
            return
            # game can begin

    if network.hosting:
        network.send("g")
        for i in range(4):
            if start_window.sel_but[i].get_active_text() != "Network":
                network.gamedetails.op.append(i)
                # set players
    print(network.gamedetails.op)
    for i in range(0, 4):
        if start_window.loaded:
            break
        if gamers[i]:
            game.players[i] = plun.player(i, "balubel")
            game.players[i].name = start_window.names[i].get_text()

        else:
            game.players[i] = 0

            # Make sure that the grave of the other players is grey
    surface.restrict_to_player(game.memo.act_pl.nr)

    start_window.optwindow.hide()
    start_window.joinwindow.hide()
    start_window.hide()
    surface.set_visi(True)
    # todo: network stuff
    # send msg to clients that the game has started
    # send playernames to the server and otherway round
    # send rules of the game

    surface.pre_render(game.players)
    game.newgame()
    surface.set_msg(game.memo.get_plstr() + "\nstarts the game")