示例#1
0
    def __init__(self):
        super().__init__()
        # 초기화
        self.setupUi(self)
        self.UpgradeButton1.setDisabled(True)
        self.UpgradeButton2.setDisabled(True)
        self.UpgradeButton3.setDisabled(True)
        self.UpgradeButton4.setDisabled(True)
        
        # 시작버튼을 누를 시 시작
        self.check.setText("시작")
        self.wordInput.setReadOnly(True)
        self.wordInput.setText("시작버튼을 눌러주세요.")
        self.check.clicked.connect(self.button_clicked)

        # 이벤트카드 생성
        self.cards = [Card(), Card(), Card(), Card()]
        self.card_buttons = [self.UpgradeButton1, self.UpgradeButton2, self.UpgradeButton3, self.UpgradeButton4]

        # 이벤트카드 누를 시
        self.UpgradeButton1.clicked.connect(self.action)
        self.UpgradeButton2.clicked.connect(self.action)
        self.UpgradeButton3.clicked.connect(self.action)
        self.UpgradeButton4.clicked.connect(self.action)

        # 스테이지 설정
        self.stage = 1

        # 캐릭터 생성
        self.hero = Hero()

        # 타이머 쓰레드
        self.timer = AAThread()
        self.timer.start()

        # 시그널 슬롯 연결
        self.timer.change_value.connect(self.auto_attack)

        # 단어 퀴즈
        self.word_game = WordGame()
示例#2
0
    def test_defense_when_cant_beat_attack(self):
        hand = [
            Card(Suit.CLUBS, Rank.SEVEN),
            Card(Suit.HEARTS, Rank.SEVEN),
            Card(Suit.SPADES, Rank.SEVEN),
            Card(Suit.HEARTS, Rank.JACK),
            Card(Suit.CLUBS, Rank.JACK),
            Card(Suit.SPADES, Rank.JACK)
        ]
        game = Game()
        game.trump = Card(Suit.DIAMONDS, Rank.SIX)
        game.attack_cards = [Card(Suit.CLUBS, Rank.ACE)]
        p = AIPlayer(hand=hand, game=game)

        assert p.defend() == None
示例#3
0
 def setUp(self):
   card_one = Card("Heart", "5", 5)
   card_two = Card("Diamond", "Jack",11)
   card_three = Card("Spade", "7", 7)
   card_four = Card("Spade", "Ace", 14)
   cards = [card_one, card_two, card_three, card_four]
   self.deck = Deck(cards)
   self.player1 = Player("John", self.deck)
   card_five = Card("Heart", "8", 8)
   card_six = Card("Diamond", "Jack",11)
   card_seven = Card("Spade", "3", 3)
   card_eight = Card("Club", "Queen", 12)
   cards2 = [card_five, card_six, card_seven, card_eight]
   self.deck2 = Deck(cards2)
   self.player2 = Player("John", self.deck2)
   self.turn = Turn(self.player1, self.player2)
示例#4
0
def update(strings, names, order, maxlen, asc_order=False, is_karsten=False):
    os.system('cls')
    for string in strings:
        print("> %s" % string)
    print("")
    largeset = set()
    for nameset in names:
        if len(nameset) == maxlen:
            continue
        for name in nameset:
            largeset.add(Card(name, order[name], is_karsten))
    cardset = sorted(largeset)
    cardset = cardset if asc_order else cardset[::-1]
    for name in cardset:
        print(name)
示例#5
0
    def test_attack_with_all_cards_with_lowest_value(self):
        hand = [
            Card(Suit.CLUBS, Rank.SEVEN),
            Card(Suit.HEARTS, Rank.SEVEN),
            Card(Suit.SPADES, Rank.SEVEN),
            Card(Suit.HEARTS, Rank.JACK),
            Card(Suit.CLUBS, Rank.JACK),
            Card(Suit.SPADES, Rank.JACK)
        ]
        game = Game()
        game.trump = Card(Suit.SPADES, Rank.SIX)
        p = AIPlayer(hand=hand, game=game)

        attack = p.attack()
        assert len(attack) == 2
        assert attack[0].rank == attack[1].rank == Rank.SEVEN
        assert len(p.hand) == 4
示例#6
0
 def setUp(self):
     self.card = Card("Geography", "What is it?", "I don't know!")
示例#7
0
文件: game_test.py 项目: khodzha/pyfo
 def test_check_win_conditions(self):
     game = Game()
     game.defender.hand = []
     game.attacker.hand = [Card(Suit.CLUBS, Rank.JACK)]
     assert game.check_win_conditions() == (True, game.defender)
示例#8
0
 def test_it_exists(self):
     new_card = Card("Heart", "5", 5)
     assert type(new_card) == Card
     assert new_card.suit == 'Heart'
     assert new_card.rank == '5'
     assert new_card.value == 5
示例#9
0
 def test_attributes(self):
     card = Card("What is the capital of Alaska?", "Juneau", "Geography")
     self.assertEqual(card.question, "What is the capital of Alaska?")
     self.assertEqual(card.answer, "Juneau")
     self.assertEqual(card.category, "Geography")
示例#10
0
 def test_it_exists(self):
     category = {"category": "Geography"}
     card = Card("What is the capital of Alaska?", "Juneau", category)
     assert isinstance(card, Card)
    def test_incorrect_guess(self):
        card = Card("What is the capital of Alaska?", "Juneau", 'Geography')
        turn = Turn('Juno', card)

        assert turn.correct() == False
        assert turn.feedback() == 'Incorrect.'
示例#12
0
    def test_successful_defense(self):
        hand = [
            Card(Suit.CLUBS, Rank.KING),
            Card(Suit.HEARTS, Rank.SIX),
            Card(Suit.SPADES, Rank.ACE),
            Card(Suit.CLUBS, Rank.ACE),
            Card(Suit.HEARTS, Rank.ACE),
            Card(Suit.SPADES, Rank.JACK)
        ]
        game = Game()
        game.trump = Card(Suit.DIAMONDS, Rank.SIX)
        game.attack_cards = [
            Card(Suit.CLUBS, Rank.QUEEN),
            Card(Suit.HEARTS, Rank.QUEEN)
        ]
        p = AIPlayer(hand=hand, game=game)

        assert p.defend() == [
            Card(Suit.CLUBS, Rank.KING),
            Card(Suit.HEARTS, Rank.ACE)
        ]
示例#13
0
 def setUp(self):
   self.card = Card("Geography", "What is it?", "I don't know!")
   self.turn = Turn("I know!", self.card)
   self.turn2 = Turn("I don't know!", self.card)
示例#14
0
 def test_it_exists(self):
     category_1 = {"category": "Geography"}
     card_1 = Card("What is the capital of Alaska?", "Juneau", category_1)
     turn_1 = Turn("Juneau", card_1)
     assert isinstance(turn_1, Turn)
 def __init__(self):
     self.shuffled_deck = [
         Card('spades', '2', 2),
         Card('spades', '3', 3),
         Card('spades', '4', 4),
         Card('spades', '5', 5),
         Card('spades', '6', 6),
         Card('spades', '7', 7),
         Card('spades', '8', 8),
         Card('spades', '9', 9),
         Card('spades', '10', 10),
         Card('spades', 'Jack', 11),
         Card('spades', 'Queen', 12),
         Card('spades', 'King', 13),
         Card('spades', 'Ace', 14),
         Card('diamonds', '2', 2),
         Card('diamonds', '3', 3),
         Card('diamonds', '4', 4),
         Card('diamonds', '5', 5),
         Card('diamonds', '6', 6),
         Card('diamonds', '7', 7),
         Card('diamonds', '8', 8),
         Card('diamonds', '9', 9),
         Card('diamonds', '10', 10),
         Card('diamonds', 'Jack', 11),
         Card('diamonds', 'Queen', 12),
         Card('diamonds', 'King', 13),
         Card('diamonds', 'Ace', 14),
         Card('clubs', '2', 2),
         Card('clubs', '3', 3),
         Card('clubs', '4', 4),
         Card('clubs', '5', 5),
         Card('clubs', '6', 6),
         Card('clubs', '7', 7),
         Card('clubs', '8', 8),
         Card('clubs', '9', 9),
         Card('clubs', '10', 10),
         Card('clubs', 'Jack', 11),
         Card('clubs', 'Queen', 12),
         Card('clubs', 'King', 13),
         Card('clubs', 'Ace', 14),
         Card('hearts', '2', 2),
         Card('hearts', '3', 3),
         Card('hearts', '4', 4),
         Card('hearts', '5', 5),
         Card('hearts', '6', 6),
         Card('hearts', '7', 7),
         Card('hearts', '8', 8),
         Card('hearts', '9', 9),
         Card('hearts', '10', 10),
         Card('hearts', 'Jack', 11),
         Card('hearts', 'Queen', 12),
         Card('hearts', 'King', 13),
         Card('hearts', 'Ace', 14)
     ]
     random.shuffle(self.shuffled_deck)
     self.deck1 = self.shuffled_deck[:len(self.shuffled_deck) // 2]
     self.deck2 = self.shuffled_deck[len(self.shuffled_deck) // 2:]
示例#16
0
 def test_winner_mad(self):
   self.player2.deck.cards.insert(0, Card("Spade", "5", 5))
   self.player1.deck.cards.insert(1, Card("Diamond", "7", 7))
   assert self.turn.turn_type() == 'MAD!'
   assert self.turn.winner() == 'No Winner'
示例#17
0
 def test_winner_war(self):
   self.player2.deck.cards.insert(0, Card("Spade", "5", 5))
   assert self.turn.turn_type() == 'War!'
   self.turn.pile_those_cards(self.turn.player1.deck.cards, self.turn.player2.deck.cards)
   assert self.turn.winner() == self.player2
示例#18
0
 def test_turn_type_war(self):
   self.player2.deck.cards.insert(0, Card("Spade", "5", 5))
   assert self.turn.turn_type() == 'War!'
示例#19
0
from lib.card import Card
from lib.turn import Turn
from lib.deck import Deck
from lib.round import Round

card_1 = Card("In what state is Greendale Community College?", "colorado", 'Community Trivia')
card_2 = Card("What is the first name of the character that wins Dungeons and Dragons in the first D&D episode?", "pierce", 'Community Trivia')
card_3 = Card("What is the slogan of the STD fair?", "catch knowledge", 'Community Trivia')
card_4 = Card('According to Greek mythology, who was the first woman on Earth?', 'pandora', 'Random Trivia')
card_5 = Card('Two US States dont recognize daylight savings. Hawaii is one. What is the other?', 'arizona', 'Random Trivia')
card_6 = Card('The ____ is the loudest animal on Earth.', 'sperm whale', 'Random Trivia')

cards = [card_1, card_2, card_3, card_4, card_5, card_6]
deck = Deck(cards)
round = Round(deck)
total_cards = len(cards)
categories = deck.all_categories()

intro = "Welcome to Flashcards! You are playing with %s cards" % total_cards
print(intro)

while len(cards) > 0:
  print('*-*-*-*-*-*-*-*-*-*-*-*-*-*-*')
  print('This is card number %s out of %s' % (total_cards - len(cards) + 1, total_cards))
  print('Question: %s' % round.current_card().question)

  guess = input('>>').lower()
  
  guess = round.take_turn(guess)
  answer = guess.card.answer
示例#20
0
 def __init__(self, shuffled=False):
     Card.__init__(self)
     self.deck = list(reversed(self.card_list))
     self.shuffle_deck_compare = list(self.deck)
     self.shuffled = shuffled
示例#21
0
 def test_it_has_a_category(self):
     category = {"category": "Geography"}
     card = Card("What is the capital of Alaska?", "Juneau", category)
     assert card.category == {"category": "Geography"}
示例#22
0
#!/usr/bin/env python3.9

import sys

from PySide6.QtWidgets import QApplication

from lib.card import Card

app = QApplication(sys.argv)
title = 'Chapter Four, Exercise 2b'
instructions = 'Translate into Japanese.'
questions = [
    'The library is behind the university.',
    'The hospital is in front of the department store.'
]
answers = [[['図書館', 'としょかん'], ['は', ''], ['大学', 'だいがく'], ['の', ''],
            ['後ろ', 'うし'], ['です', '']],
           [['病院', 'びょういん'], ['は', ''], ['デパート', ''], ['の', ''], ['前', 'まえ'],
            ['です', '']]]
card = Card(title, instructions, questions, answers)
card.show()
sys.exit(app.exec())
示例#23
0
 def test_it_exists(self):
     card = Card("What is the capital of Alaska?", "Juneau", "Geography")
     self.assertIsInstance(card, Card)
示例#24
0
 def processed_attack_input(prompt):
     text = input(prompt)
     str_cards = text.split()
     cards = list(map(lambda c: Card.from_str(c), str_cards))
     return cards
 def __init__(self, file):
     self.file = open(file, "r")
     self.cards = []
     for line in self.file:
         card = line.split(",")
         self.cards.append(Card(card[0], card[1], card[2]))
示例#26
0
文件: game_test.py 项目: khodzha/pyfo
 def test_starting_ai(self):
     game = TestGame.prepare_test(trump=Card(Suit.CLUBS, Rank.SIX), player_card=Card(Suit.CLUBS, Rank.JACK), ai_card=Card(Suit.CLUBS, Rank.EIGHT))
     assert game.turn == 'ai'
示例#27
0
 def test_add_card(self):
     new_card = Card("Heart", "King", 13)
     self.deck.add_card(new_card)
     assert len(self.deck.cards) == 5
示例#28
0
 def test_it_exists(self):
     card = Card("What is the capital of Alaska?", "Juneau", "Geography")
     turn = Turn("Juneau", card)
     self.assertIsInstance(turn, Turn)