def has_seven_of_hearts(self) -> bool: return Card(Mark.HEARTS, Value.SEVEN) in self.cards
sents_with_chunks = [] for sentence in sentences: sents_with_chunks.append([sentence, chunker.get_chunks(sentence)]) # Make a list of cards translator = Translator() cards = [] for sent in sents_with_chunks: whole_sentence = sent[0] # Here we iterate over the chunks for each sentence and create a card for each. for chunk in sent[1]: # check if suitable chunk_length = len(chunk.split(' ')) if chunk_length >= 4 and chunk_length <= 8: cards.append( Card(whole_sentence, chunk, translator.get_translation(chunk), chunker.get_labels(chunk))) # Shuffle the cards shuffle(cards) # print("!!!!!!!!!!!!!!") # print(sents_with_chunks[0]) def select_next_question(card, cards): ''' This takes a card and a list of cards ''' comp = Comparer() labels = card.labels
def containsAce(self): return Card(1) in self.getCards()
def test_ace_diamonds(self): card_test = Card(1, Suit.DIAMONDS) self.assertEqual("A♦", str(card_test))
root = tk.Tk() HEIGHT = 500 WIDTH = 600 canvas = tk.Canvas(root, height = HEIGHT, width = WIDTH) canvas.pack() background_image = tk.PhotoImage(file='bg.png') background_label = tk.Label(root, image=background_image) background_label.place(relwidth=1, relheight=1) button_confirm = tk.Button(root, text = "Confirm", command=confirm) button_confirm.place(relx=0.45, rely=0.45, relwidth = 0.1, relheight=0.1) button_cancel = tk.Button(root, text = "Cancel", command=cancel) button_cancel.place(relx=0.65, rely=0.65, relwidth = 0.1, relheight=0.1) hand = [Card("ATT"), Card("DOD")] buttons = [] count = 0 def blitHand(): global buttons isCardSelected = False for i in range(len(buttons)): buttons[i].place_forget() buttons = [] for i in range(len(hand)): global count button = tk.Button(root, text = hand[i].full_name, command=lambda x=i:selectCard(x)) buttons.append(button) for i in range(len(buttons)): buttons[i].place(relx=0.35+i*0.15, rely=0.7, relwidth=0.1, relheight=0.1)
def test_ten_spades(self): card_test = Card(10, Suit.SPADES) self.assertEqual("T♠", str(card_test))
def test_queen_spades(self): card_test = Card(12, Suit.SPADES) self.assertEqual("Q♠", str(card_test))
def create_card(name): return Card(name, "cards/" + name + "/data.json")
def generate(self): for i in range(1, 14): for j in range(4): self.cards.append(Card(i, j))
def __init__(self, user_names): #self.__players = [PcPlayer(Card(), 'ddd'), PcPlayer(Card()),PcPlayer(Card(), 'player 1'), PcPlayer(Card(), 'player 2')] self.__players = [PcPlayer(Card())] for user_name in user_names: self.__players.append(UserPlayer(user_name, Card())) self.__arbiter = Arbiter(self.__players)
def __init__(self): self.cards = [] for suit in range(4): for rank in range(1, 14): card = Card(suit, rank) self.cards.append(card)
def populate(self): suits = ["hearts", "clubs", "diamonds", "spades"] numbers = [str(n) for n in range(2, 11)] + ["J", "Q", "K", "A"] self._cards = [Card(suit, num) for suit in suits for num in numbers]
def reset_decks(self): self._decks = [Card(i) for i in range(NUM_CARDS)] * self._num_decks self.shuffle()
def __init__(self): self._cards = [ ] for suit in ["C", "D", "H", "S"]: for rank in range(2, 15): self._cards.append(Card(rank, suit))
def test_two_clubs(self): card_test = Card(2, Suit.CLUBS) self.assertEqual("2♣", str(card_test))
def __init__(self): for suit in Card.suits: for value in Card.values: self.deck.append(Card(Card.values[value], suit, value))
def test_nine_hearts(self): card_test = Card(9, Suit.HEARTS) self.assertEqual("9♥", str(card_test))
def test_length(self): self.assertEqual(len(Pile()), len(Value) * len(Suit)) self.assertEqual(len(Pile([])), 0) self.assertEqual(len(Pile([Card(Value.TWO, Suit.SPADES)])), 1)
def test_jack_spades(self): card_test = Card(11, Suit.SPADES) self.assertEqual("J♠", str(card_test))
def _init_powerups(): stack = Stack() nums = [1, 2, 3, 4, 5] for _ in range(100): stack.push(Card(random.choice(nums))) return stack
def test_king_spades(self): card_test = Card(13, Suit.SPADES) self.assertEqual("K♠", str(card_test))
from card import Card from double_linked_list import DoublyLinkedList list = DoublyLinkedList() valid_rank = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'] valid_suit = ['Diamond', "Club", "Heart", "Spade"] for s in valid_suit: for r in valid_rank: list.insert_at_end(Card(s, r)) list.display_list(list.head) element = Card('Diamond', '8') list.find_node(element)
def setUp(self): self.card = Card(Colour.RED, 10)
cards = Cards() for c in cardsList: if c in constants.pokerNames: cards.add(Card(c)) else: return None cards.sort() return cards if __name__ == '__main__': a = Card('3') b = Card('4') c = Card('5') d = Card('6') e = Card('7') f = Card('8') g = Card('9') h = Card('10') cs = Cards() cs.add(b) cs.add(a) cs.add(c) cs.add(d) print(cs)
def it_should_have_a_value_and_a_suit(self): card = Card('J', 'spades') card.value | should | equal_to('J') card.suit | should | equal_to('spades')
def __init__(self): self.cards = [Card(rank, suit) for rank in Rank for suit in Suit]
def _create_deck(self): self.deck = list() for suit in SUIT: for rank in RANK: self.deck.append(Card(suit, rank)) return self.deck
def dict_to_card(d): return Card(Symbol[d['symbol']], Rank[d['rank']])
def softSum(self): return sum( [card.bjValue() for card in self.getCards() if card != Card(1)])
def skill_using(self, hero, enemy_hero=None): is_use = True if hero.hero_class == 'warrior': hero.armor += 2 print("英雄技能:全副武装") elif hero.hero_class == 'hunter': if enemy_hero.armor > 2: enemy_hero.armor -= 2 elif enemy_hero.armor <= 2: enemy_hero.remain_health -= (2 - enemy_hero.armor) enemy_hero.armor = 0 print("英雄技能:稳固射击") elif hero.hero_class == 'warlock': self.draw_card() if hero.armor > 2: hero.armor -= 2 elif hero.armor <= 2: hero.remain_health -= (2 - hero.armor) hero.armor = 0 print("英雄技能:生命分流") elif hero.hero_class == 'pastor': if self.myturn: world = [self.enemyhero] + self.enemyworldcards + [ self.myhero ] + self.myworldcards else: world = [self.enemyhero] + self.enemyworldcards for i in range(len(world)): print("{0}-{1}({2}-{3}".format(i + 1, world[i].name, world[i].damage, world[i].remain_health), end='') if world[i].armor > 0: print("[{0}]".format(world[i].armor), end='') print("/{0})".format(world[i].health), end=' ') print('') if self.myturn: choose_num = choose_object_num(world, "请选择加血对象序号:") else: choose_num = -1 for i in range(len(world)): if world[i].remain_health != world[i].health: choose_num = i + 1 break if choose_num == -1: print("己方没有受伤单位!") is_use = False else: if not self.myturn: print(">>>>>>>目标序号:{0}".format(choose_num)) world[choose_num - 1].add_health(2) print("英雄技能:次级治疗术->{0}".format(world[choose_num - 1].name)) print("{0}-{1}({2}-{3}/{4})".format( choose_num, world[choose_num - 1].name, world[choose_num - 1].damage, world[choose_num - 1].remain_health, world[choose_num - 1].health)) elif hero.hero_class == 'mage': if self.myturn: world = [self.enemyhero] + self.enemyworldcards + [ self.myhero ] + self.myworldcards else: world = [self.myhero] + self.myworldcards for i in range(len(world)): print("{0}-{1}({2}-{3}".format(i + 1, world[i].name, world[i].damage, world[i].remain_health), end='') if world[i].armor > 0: print("[{0}]".format(world[i].armor), end='') print("/{0})".format(world[i].health), end=' ') print('') if self.myturn: choose_num = choose_object_num(world, "请选择火焰冲击对象序号:") else: choose_num = -1 for i in range(len(world)): if world[i].remain_health == 1: choose_num = i + 1 break if choose_num == -1: choose_num = randint(1, len(world)) print(">>>>>>>目标序号:{0}".format(choose_num)) world[choose_num - 1].reduce(1) print("英雄技能:火焰冲击->{0}".format(world[choose_num - 1].name)) world[choose_num - 1].show() elif hero.hero_class == 'roguer': hero.weapon_damage = 1 hero.weapon_durability = 2 print("英雄技能:匕首精通") elif hero.hero_class == 'druid': hero.hero_damage += 1 hero.armor += 1 print("英雄技能:变形") elif hero.hero_class == 'knight': soldier = Card('白银新兵', '', '', 1, 1, 1) if self.myturn: if len(self.myworldcards) < 7: print("英雄技能:援军") self.myworldcards.append(soldier) else: is_use = False if not self.myturn: if len(self.enemyworldcards) < 7: print("英雄技能:援军") self.enemyworldcards.append(soldier) else: is_use = False elif hero.hero_class == 'shaman': if self.myturn: if len(self.myworldcards) < 7 and len(self.myhero.totem) > 0: random_index = randint(0, len(self.myhero.totem) - 1) self.myworldcards.append(self.myhero.totem[random_index]) print("英雄技能:{0}".format( self.myhero.totem[random_index].name)) self.myhero.totem.remove(self.myhero.totem[random_index]) else: is_use = False if not self.myturn: if len(self.enemyworldcards) < 7 and len( self.enemyhero.totem) > 0: random_index = randint(0, len(self.enemyhero.totem) - 1) self.enemyworldcards.append( self.enemyhero.totem[random_index]) print("英雄技能:{0}".format( self.enemyhero.totem[random_index].name)) self.enemyhero.totem.remove( self.enemyhero.totem[random_index]) else: is_use = False return is_use