Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_cardclass():
playable_cards = [
enums.CardClass.DRUID,
enums.CardClass.HUNTER,
enums.CardClass.MAGE,
enums.CardClass.PALADIN,
enums.CardClass.PRIEST,
enums.CardClass.ROGUE,
enums.CardClass.SHAMAN,
enums.CardClass.WARLOCK,
enums.CardClass.WARRIOR
]
for c in playable_cards:
assert c.is_playable
for c in enums.CardClass:
if c not in playable_cards:
assert not c.is_playable
def test_cardclass():
playable_cards = [
enums.CardClass.DRUID,
enums.CardClass.HUNTER,
enums.CardClass.MAGE,
enums.CardClass.PALADIN,
enums.CardClass.PRIEST,
enums.CardClass.ROGUE,
enums.CardClass.SHAMAN,
enums.CardClass.WARLOCK,
enums.CardClass.WARRIOR
]
for c in playable_cards:
assert c.is_playable
for c in enums.CardClass:
if c not in playable_cards:
assert not c.is_playable
CardClass.DRUID: "HERO_06",
CardClass.HUNTER: "HERO_05",
CardClass.MAGE: "HERO_08",
CardClass.PALADIN: "HERO_04",
CardClass.PRIEST: "HERO_09",
CardClass.ROGUE: "HERO_03",
CardClass.SHAMAN: "HERO_02",
CardClass.WARLOCK: "HERO_07",
CardClass.WARRIOR: "HERO_01",
CardClass.WHIZBANG: "BOT_914h",
}
SECRET_COSTS = {
CardClass.HUNTER: 2,
CardClass.MAGE: 3,
CardClass.PALADIN: 1,
CardClass.ROGUE: 2,
CardClass.WARRIOR: 0,
}
CRAFTING_COSTS = {
Rarity.COMMON: (40, 400),
Rarity.RARE: (100, 800),
Rarity.EPIC: (400, 1600),
Rarity.LEGENDARY: (1600, 3200),
}
DISENCHANT_COSTS = {
Rarity.COMMON: (5, 50),
Rarity.RARE: (20, 100),
from datetime import datetime
from .enums import CardClass, CardSet, Rarity, ZodiacYear
try:
from lxml import etree as ElementTree # noqa
except ImportError:
from xml.etree import ElementTree # noqa
CARDCLASS_HERO_MAP = {
CardClass.DRUID: "HERO_06",
CardClass.HUNTER: "HERO_05",
CardClass.MAGE: "HERO_08",
CardClass.PALADIN: "HERO_04",
CardClass.PRIEST: "HERO_09",
CardClass.ROGUE: "HERO_03",
CardClass.SHAMAN: "HERO_02",
CardClass.WARLOCK: "HERO_07",
CardClass.WARRIOR: "HERO_01",
CardClass.WHIZBANG: "BOT_914h",
}
SECRET_COSTS = {
CardClass.HUNTER: 2,
CardClass.MAGE: 3,
CardClass.PALADIN: 1,
def setup_game():
"""
initializes a game between two players
Returns:
game: A game entity representing the start of the game after the mulligan phase
"""
#choose classes (priest, rogue, shaman, warlock)
p1 = random.randint(6, 9)
p2 = random.randint(6, 9)
#initialize players and randomly draft decks
#pdb.set_trace()
deck1 = random_draft(CardClass(p1))
deck2 = random_draft(CardClass(p2))
player1 = Player("Player1", deck1, CardClass(p1).default_hero)
player2 = Player("Player2", deck2, CardClass(p2).default_hero)
#begin the game
game = Game(players=(player1, player2))
game.start()
#Skip mulligan for now
for player in game.players:
cards_to_mulligan = random.sample(player.choice.cards, 0)
player.choice.choose(*cards_to_mulligan)
return game
def FastGetRandomMove(self):
if self.game is not None:
if self.game.current_player.playstate != PlayState.PLAYING:
return []
# Move format is [enum, card, index of card in hand, target index]
if self.game is None and self.hero1 is None: # choose p1 hero
return [MOVE.PICK_CLASS, CardClass(randint(2, 10)).default_hero]
if self.game is None and len(self.deck1) == 30 and self.hero2 is None:
return [MOVE.PICK_CLASS, CardClass(randint(2, 10)).default_hero]
if self.game is None and len(self.deck1) < 30 or len(self.deck2) < 30:
possible_cards = []
exclude = []
if len(self.deck1) < 30:
hero = cards.db[self.hero1]
deck = self.deck1
else:
hero = cards.db[self.hero2]
deck = self.deck2
for card in cards.db.keys():
if card in exclude:
continue
cls = cards.db[card]
if not cls.collectible:
continue
def setup_game():
"""
initializes a game between two players
Returns:
game: A game entity representing the start of the game after the mulligan phase
"""
#choose classes (priest, rogue, shaman, warlock)
p1 = random.randint(6, 9)
p2 = random.randint(6, 9)
#initialize players and randomly draft decks
#pdb.set_trace()
deck1 = random_draft(CardClass(p1))
deck2 = random_draft(CardClass(p2))
player1 = Player("Player1", deck1, CardClass(p1).default_hero)
player2 = Player("Player2", deck2, CardClass(p2).default_hero)
#begin the game
game = Game(players=(player1, player2))
game.start()
#Skip mulligan for now
for player in game.players:
cards_to_mulligan = random.sample(player.choice.cards, 0)
player.choice.choose(*cards_to_mulligan)
return game
def setup_game():
"""
initializes a game between two players
Returns:
game: A game entity representing the start of the game after the mulligan phase
"""
#choose classes (priest, rogue, shaman, warlock)
p1 = random.randint(6, 9)
p2 = random.randint(6, 9)
#initialize players and randomly draft decks
#pdb.set_trace()
deck1 = random_draft(CardClass(p1))
deck2 = random_draft(CardClass(p2))
player1 = Player("Player1", deck1, CardClass(p1).default_hero)
player2 = Player("Player2", deck2, CardClass(p2).default_hero)
#begin the game
game = Game(players=(player1, player2))
game.start()
#Skip mulligan for now
for player in game.players:
cards_to_mulligan = random.sample(player.choice.cards, 0)
player.choice.choose(*cards_to_mulligan)
return game
def classes(self):
ret = []
multiclass = self.multiple_classes
if not multiclass:
ret.append(self.card_class)
else:
i = 1
while multiclass != 0:
if (multiclass & 1) == 1 and i in CardClass._value2member_map_:
ret.append(CardClass(i))
multiclass >>= 1
i += 1
return ret
def classes(self):
ret = []
multiclass = self.multiple_classes
if not multiclass:
ret.append(self.card_class)
else:
i = 1
while multiclass != 0:
if (multiclass & 1) == 1 and i in CardClass._value2member_map_:
ret.append(CardClass(i))
multiclass >>= 1
i += 1
return ret