def safety_checks_Player(): """ Checks that, when invalid cards are passed as argument to 'play_cards', no card actually gets played. Checks that all cards correctly get played """ c = Cards(2) p1 = Player(c, 0) p2 = Player(c, 1) p1.add_to_hand(c.draw()) p2.add_to_hand(c.draw()) len_p1_hand = len(p1.hand) len_p2_hand = len(p2.hand) assert len_p1_hand == len_p1_hand, "Errore in fase di pesca" p1.play_cards([22222, 23313, 34414]) assert len_p1_hand == len( p1.hand), "Some cards were played despite none should have been played" p1.play_cards([i for i in p1.hand]) assert len( p1.hand ) == 0, "Non sono state giocate tutte le carte che avrebbero dovuto essere giocate" p2.play_cards([i for i in p2.hand][:1] + [32313231]) assert len( p2.hand) == len_p2_hand - 1, "Sono state sbagliate le carte giocate"
def keyPressEvent(self, event): print(event) if event.key() == self.Front: print('alright') self.Current = 'Front' self.update() elif event.key() == self.Back: print('ok') self.Current = 'Back' self.update() elif event.key() == self.Package: self.close() create.Cards(controller.Deck, create.TEST_MODEL) controller.hook() elif event.key() == self.Choose: if self.Choice is False: self.Choice = True else: self.Choice = False elif event.key()==self.Decks: self.switch_window.emit("Decks")
def __init__(self): self.room_class = r.Room() self.map = [[self.room_class.all_rooms.get("Vestibule")]] self.main_room = (0, 0) self.difficulty_level = d.All_Difficulties().difficulties.get("Normal") # random diff for now self.player_list = [h.HeroesCards.aelfric, h.HeroesCards.cecilia, h.HeroesCards.tetemeko] # random players for now self.current_player = self.player_list[0] self.map[0][0].players = self.player_list self.card_class = c.Cards()
def initNetwork(numPlayers): global HOST, ADDR, PORT, selector, server_socket, casefile, hands, cards server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if HOST: server_socket.bind((ADDR, PORT)) server_socket.listen() #add num_players for max socket count # print('listening on ', (ADDR,PORT)) server_socket.setblocking(False) selector.register(server_socket, selectors.EVENT_READ, data=None) print('Host server started, waiting for clients...') cards = Cards.Cards() casefile = cards.CaseFile() print(str(cards.getCaseFile())) # FOR DEBUGGING/TESTING cards.shufflecards() cards.deal(numPlayers) hands = cards.hands start_connections(ADDR, PORT)
def __init__(self, num_players): self.Deck = Cards(num_players) self.num_players = num_players self.players = [Player(self.Deck, id_=i) for i in range(1, num_players+1)] # a cosa corrisponde il jolly? self.jolly = 100 self.turn = 0 self.player = 0 self.consec_passes = 0 self.need_to_declare = True self.decl_istr = "Dichiara il tipo di carta che andrà giocata (il numero, non il seme): " self.playc_istr = "Inserire il numero di ogni carta che vuoi buttare, separando ogni carta con spazi o virgole: " self.doubt_istr = "Insert the number of the player who wants to doubt, if any. Otherwise just press enter: " self.play()
def safety_checks_Deck(): """ Some (not thourough) checks that cards are correctly distributed among players, and that the pool gets correctly expanded and reset """ c = Cards(3) hand1 = c.draw() hand2 = c.draw() hand3 = c.draw() assert len(hand1) == len(hand2) == len(hand3) len_hand = len(hand1) c.add_to_pool(hand1) assert len(c.pool) == len_hand, "Error in adding cards to the pool" c.reset_pool() assert not c.pool return
# @Last modified time: 15-05-2017 from Cards import * from Board import * from ClassMoney import * from Info import * game = True while game: name = raw_input('Please input the name of the player: ') game_on = True while game_on: a = Info(name) b = Cards() c1 = b.rand_card() b.mod_card(c1) point = int(Cards.cards_values[c1]) a.addpoint(point) print "Your card is %s with %s points" % (c1, Cards.cards_values[c1]) print "You have a Total of %s points" c2 = b.rand_card() b.mod_card(c2) point = int(Cards.cards_values[c2]) a.addpoint(point) totpoints = a.pointsC() print "Your card is %s with %s points" % (c2, Cards.cards_values[c2]) print "You have a Total points of: %i" % (totpoints)
import Cards class Player: def __init__(self, name): self.name = name self.all_cards = [] def remove_one(self): self.all_cards.pop(0) def add_cards(self, new_card): if (type(new_card) == type([])): self.all_cards.extend(new_card) else: self.all_cards.append(new_card) def __str__(self): return "Player {} has {} cards".format(self.name, len(self.all_cards)) jose = Player("Jose") print(jose) new_card = Cards("Spades", "Seven") jose.add_cards(new_card) print(jose) jose.add_cards([new_card, new_card, new_card]) print(jose)
# @Email: [email protected] # @Filename: main2.py # @Last modified time: 20-05-2017 # from Cards import * from Board import * from ClassMoney import * from Player import * game = True while game: ask_name = raw_input("Please input your name: ") play1 = Player(ask_name) play1card = Cards() '''First turn of player 1, we get two random cards''' card1 = play1card.rand_card() play1card.mod_card(card1) card2 = pla1card.rand_card() play1card.mod_card(card2) if play1.points == 21: print "BLACKJACK - PLAYER1 WINS!!!!" break else: print "It´s turn for the crupier!!" crup = Player('crupier') crupcard = Cards() '''Now it´s turn to get two cards for the crupier'''
def __init__(self): self.all_cards = [] for suit in suits: for rank in ranks: self.all_cards.append(Cards(suit, rank))
def __init__(self): self.name = "" self.cards = Cards.Cards() self.guessed_tricks = 0 self.won_tricks = 0 self.score = 0
def randomCards(self): self.cards = Cards.Cards(self.tmxList) self.cards.randomCards(self.startID, self.endID, self.count)
def __init__(self): self.deck = [] for suit in suits: for rank in ranks: self.deck.append(Cards(suit, rank))