本文整理汇总了Python中hearthbreaker.game_objects.Minion.__from_json__方法的典型用法代码示例。如果您正苦于以下问题:Python Minion.__from_json__方法的具体用法?Python Minion.__from_json__怎么用?Python Minion.__from_json__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hearthbreaker.game_objects.Minion
的用法示例。
在下文中一共展示了Minion.__from_json__方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __from_json__
# 需要导入模块: from hearthbreaker.game_objects import Minion [as 别名]
# 或者: from hearthbreaker.game_objects.Minion import __from_json__ [as 别名]
def __from_json__(cls, pd, game, agent):
deck = Deck.__from__to_json__(pd["deck"],
hearthbreaker.constants.CHARACTER_CLASS.from_str(pd["hero"]["character"]))
player = Player("whatever", deck, agent, game)
hero = Hero.__from_json__(pd["hero"], player)
player.hero = hero
hero.player = player
if hero.weapon:
hero.weapon.player = player
player.mana = pd["mana"]
player.max_mana = pd["max_mana"]
player.name = pd['name']
player.hand = [card_lookup(name) for name in pd["hand"]]
player.graveyard = set()
for card_name in pd["graveyard"]:
player.graveyard.add(card_name)
player.secrets = []
for secret_name in pd["secrets"]:
secret = card_lookup(secret_name)
secret.player = player
player.secrets.append(secret)
i = 0
player.minions = []
for md in pd["minions"]:
minion = Minion.__from_json__(md, player, game)
minion.index = i
player.minions.append(minion)
i += 1
return player
示例2: __from_json__
# 需要导入模块: from hearthbreaker.game_objects import Minion [as 别名]
# 或者: from hearthbreaker.game_objects.Minion import __from_json__ [as 别名]
def __from_json__(cls, pd, game, agent):
deck = Deck.__from__to_json__(pd["deck"], hero_from_name(pd["hero"]["name"]))
player = Player("whatever", deck, agent, game)
hero = Hero.__from_json__(pd["hero"], player)
player.hero = hero
hero.player = player
if pd["weapon"]:
player.weapon = Weapon.__from_json__(pd["weapon"], player)
player.weapon.player = player
player.mana = pd["mana"]
player.max_mana = pd["max_mana"]
player.upcoming_overload = pd["upcoming_overload"]
player.current_overload = pd["current_overload"]
player.name = pd["name"]
player.hand = []
for card_def in pd["hand"]:
card = card_lookup(card_def["name"])
card.__from_json__(card, **card_def)
card.attach(card, player)
player.hand.append(card)
player.graveyard = pd["graveyard"]
player.secrets = []
for secret_name in pd["secrets"]:
secret = card_lookup(secret_name)
secret.player = player
player.secrets.append(secret)
i = 0
player.minions = []
for md in pd["minions"]:
minion = Minion.__from_json__(md, player, game)
minion.index = i
player.minions.append(minion)
i += 1
return player