예제 #1
0
    def __init__(self, names):
        print "---------------------Creazione del deck"
        CardGame.__init__(self)

        print "---------------------Rimozione della regina di picche"
        self.getDeck().removeCard(Card(Card.suits.index('Clubs'), 12))

        self.hands = []
        for name in names:
            self.hands.append(OldMaidHand(name))
예제 #2
0
def bartok_setup(env):
    if env.deck.is_empty():
        print('ERROR: Deck is empty. Cannot place card in center pile.',
              file=stderr)
        exit()  # TODO Throw exception instead of exiting
    env.center.put(env.deck.take_top())


def bartok_pre_player_turn(env):
    top_card = env.center.look_top()
    print("=================================")
    print(f"Center Card: {top_card}")
    print("=================================")


BARTOK = {
    ENV: BartokEnv,
    DECK_SIZE: 1,
    DECK_W_JOKERS: False,
    DECK_WO_QUEENS: False,
    NUM_PLAYERS: 3,
    START_HAND_SIZE: 5,
    DIRECTION: CLOCKWISE,
    GAME_RULES: BARTOK_RULES,
    SETUP: bartok_setup,
    PRE_PLAYER_TURN: bartok_pre_player_turn,
    WIN_COND: empty_hand_win_cond
}

CardGame(BARTOK).play()
예제 #3
0
    print("=================================")
    print("              Table")
    print("---------------------------------")
    for suit, layout in table.items():
        print(f"{suit}: \t", end="")
        if suit == 'CLUBS':
            print('\t', end="")
        if len(layout) == 0:
            print("[]")
        else:
            for card in layout:
                print(f"{card} ", end="")
            print()
    print("=================================")


SEVENS = {
    ENV: SevensEnv,
    DECK_SIZE: 1,
    DECK_W_JOKERS: False,
    NUM_PLAYERS: 3,
    START_HAND_SIZE: EQUAL_NUM_CARDS,
    DIRECTION: CLOCKWISE,
    GAME_RULES: SEVENS_RULES,
    SETUP: sevens_set_up,
    PRE_PLAYER_TURN: sevens_pre_player_turn,
    WINNING_COND: empty_hand_win_cond
}

CardGame(SEVENS).play()
예제 #4
0
                 start_hand_size, direction):
        super(SpoonsEnv,
              self).__init__(deck_size, deck_w_jokers, deck_wo_queens,
                             num_players, start_hand_size, direction)
        self.trash = Pile()
        self.pass_pile = Pile()
        self.end_player = num_players - 1


def spoons_win_cond(env):
    for i, player in enumerate(env.players):
        if any_four_of_a_kind(player.hand):
            env.winner_pos = i
            return True
    return False


SPOONS = {
    ENV: SpoonsEnv,
    DECK_SIZE: 1,
    DECK_W_JOKERS: False,
    DECK_WO_QUEENS: False,
    NUM_PLAYERS: 5,
    START_HAND_SIZE: 4,
    DIRECTION: CLOCKWISE,
    GAME_RULES: SPOONS_RULES,
    WIN_COND: spoons_win_cond
}

CardGame(SPOONS).play()
예제 #5
0
from oldmaidrules import OLDMAID_RULES


class OldmaidEnv(Env):
    def __init__(self, deck_size, deck_w_jokers, deck_wo_queens, num_players, start_hand_size, direction):
        super(OldmaidEnv, self).__init__(deck_size, deck_w_jokers, deck_wo_queens, num_players, start_hand_size, direction)
        self.trash = Pile()
        self.pass_pile = Pile()


def spoons_win_cond(env):
    for player in env.players:
        if any_four_of_a_kind(player.hand):
            return True
    return False


OLDMAID = {
    ENV: OldmaidEnv,
    DECK_SIZE: 1,
    DECK_W_JOKERS: False,
    DECK_WO_QUEENS: True,
    NUM_PLAYERS: 2,
    START_HAND_SIZE: 24,
    DIRECTION: CLOCKWISE,
    GAME_RULES: OLDMAID_RULES,
    WIN_COND: empty_hand_win_cond
}

CardGame(OLDMAID).play()
예제 #6
0
 def __init__(self, name):
     CardGame.__init__(self, name)
     self.maxPlayers = 5
     self.timeTill