Exemple #1
0
def cards():
    return [
        Card(HEART, 5, 'Elixir'),
        Card(SPADE, 2),
        Card(CLUB, 9, ''),
        Card(DIAMOND, 6, 'Stalwart'),
    ]
def CreateStandardDeck(deck):
    suits = ["S", "H", "C", "D"]
    values = [
        "Ace",
        "Two",
        "Three",
        "Four",
        "Five",
        "Six",
        "Seven",
        "Eight",
        "Nine",
        "Ten",
        "Jack",
        "Queen",
        "King",
    ]

    for suit in suits:
        for value in values:
            new_card = Card(suit=suit, value=value, deck=deck)
            new_card.save()
Exemple #3
0
    def _create_card(self, player):
        try:
            song_pks = Song.objects.values_list("pk", flat=True)

            selected_pks = (random.sample(list(song_pks)[:16], 5) +
                            random.sample(list(song_pks)[16:32], 5) +
                            random.sample(list(song_pks)[32:48], 5) +
                            random.sample(list(song_pks)[48:64], 5) +
                            random.sample(list(song_pks)[64:], 5))
            songs = Song.objects.filter(pk__in=selected_pks)

            new_card = Card()
            new_card.player = player
            new_card.items = songs
            new_card.full_clean()
            new_card.save()
            return False
        except:
            return True
Exemple #4
0
 async def get_cards(self, user_id: int) -> typing.List[Card]:
     return [Card(id=int(card_id)) for card_id in await Controller.lrange(f'{self.__hand_key}:{user_id}', 35)]
Exemple #5
0
 async def get_trump_card(self) -> Card:
     return Card(id=int(await Controller.get(self.__trump_card_key)))
Exemple #6
0
 async def get_cards(self) -> typing.List[Card]:
     card_ids = await Controller.lrange(self.__deck_key, 36)
     del card_ids[0]
     return [Card(id=int(card_id)) for card_id in card_ids]
Exemple #7
0
 async def get_cards(self) -> typing.List[Card]:
     return [
         Card(id=int(card_id))
         for card_id in await Controller.lrange(self.__table_key, 35)
     ]
Exemple #8
0
def delete_unused(request):
    Card.delete_unused()
    Player.delete_unused()
    return redirect('index')
Exemple #9
0
def test_card_diamond_is_not_monster():
    c = Card(DIAMOND, 5)
    assert c.is_monster() == False
Exemple #10
0
def test_card_creation_without_name():
    c = Card('heart', 5)
    assert c.name == 'heart'
    assert c.suit == 'heart'
    assert c.value == 5
Exemple #11
0
def test_card_heart_is_not_monster():
    c = Card(HEART, 5)
    assert c.is_monster() == False
Exemple #12
0
def test_card_club_is_monster():
    c = Card(CLUB, 5)
    assert c.is_monster() == True
Exemple #13
0
def test_card_spade_is_monster():
    c = Card(SPADE, 5)
    assert c.is_monster() == True
Exemple #14
0
def test_card_creation_with_name():
    c = Card('spade', 5, name='jabberwock')
    assert c.name == 'jabberwock'
    assert c.suit == 'spade'
    assert c.value == 5