Exemplo n.º 1
0
def removeplayer(player, conqueror):
    """Remove a dead player from the game."""
    global currentplayernum, playerorder
    for card in player.cards:
        risknetwork.add_card(card, conqueror)
        risknetwork.remove_card(card, player)
    conqueror.cards += player.cards
    if currentplayernum >= playerorder.index(player):
        currentplayernum -= 1
    riskgui.removeplayer(player.name)
    risknetwork.removeplayer(player.name)
    playerorder.remove(player)
    del players[player.name]

    if len(players) == 1:  #game over
        riskgui.won_game(players.values()[0].name)
        setphase("PostGame")
Exemplo n.º 2
0
def removeplayer(player, conqueror):
    """Remove a dead player from the game."""
    global currentplayernum, playerorder
    for card in player.cards:
        risknetwork.add_card(card, conqueror)
        risknetwork.remove_card(card, player)
    conqueror.cards += player.cards
    if currentplayernum >= playerorder.index(player):
        currentplayernum -= 1
    riskgui.removeplayer(player.name)
    risknetwork.removeplayer(player.name)
    playerorder.remove(player)
    del players[player.name]
    
    if len(players) == 1: #game over
        riskgui.won_game(players.values()[0].name)
        setphase("PostGame")
Exemplo n.º 3
0
def turnincards(player, cards):
    """Turn in a set of cards."""
    global currentcard
    if risknetwork.turnincards(cards):
        return
    
    if phase != "Place":
        return
        
    for c in cards:
        if not c in player.cards:
            return
            
    cards.sort(lambda a, b:cmp(a.picture, b.picture))
    
    if not cardset(cards):
        return
        
    for c in cards:
        if territories[c.territory].player == player:
            territories[c.territory].armies += 2
            riskgui.drawarmy(territories[c.territory])
        
    if currentcard < len(cardvals):
        player.freeArmies += cardvals[currentcard]
    else:
        player.freeArmies += cardvals[-1] + \
                             incrementval * (currentcard - len(cardvals) + 1)
    currentcard += 1
    
    
    for c in cards:
        allcards.append(c)
        for ca in player.cards:
            if c == ca:
                player.cards.remove(ca)
                risknetwork.remove_card(ca, currentplayer)
    riskgui.set_armies(currentplayer.freeArmies)  
Exemplo n.º 4
0
def turnincards(player, cards):
    """Turn in a set of cards."""
    global currentcard
    if risknetwork.turnincards(cards):
        return

    if phase != "Place":
        return

    for c in cards:
        if not c in player.cards:
            return

    cards.sort(lambda a, b: cmp(a.picture, b.picture))

    if not cardset(cards):
        return

    for c in cards:
        if territories[c.territory].player == player:
            territories[c.territory].armies += 2
            riskgui.drawarmy(territories[c.territory])

    if currentcard < len(cardvals):
        player.freeArmies += cardvals[currentcard]
    else:
        player.freeArmies += cardvals[-1] + \
                             incrementval * (currentcard - len(cardvals) + 1)
    currentcard += 1

    for c in cards:
        allcards.append(c)
        for ca in player.cards:
            if c == ca:
                player.cards.remove(ca)
                risknetwork.remove_card(ca, currentplayer)
    riskgui.set_armies(currentplayer.freeArmies)