本文整理汇总了Python中hearthbreaker.tags.base.CardQuery.get_card方法的典型用法代码示例。如果您正苦于以下问题:Python CardQuery.get_card方法的具体用法?Python CardQuery.get_card怎么用?Python CardQuery.get_card使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hearthbreaker.tags.base.CardQuery
的用法示例。
在下文中一共展示了CardQuery.get_card方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: use
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
def use(self, player, game):
super().use(player, game)
if self.target.health <= player.effective_spell_damage(2) and \
(isinstance(self.target, Minion) and not self.target.divine_shield):
self.target.damage(player.effective_spell_damage(2), self)
demons = CardQuery(conditions=[IsType(MINION_TYPE.DEMON)])
demons.get_card(player, player, self).summon(player, game, len(player.minions))
else:
self.target.damage(player.effective_spell_damage(2), self)
示例2: Transform
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
class Transform(Action):
def __init__(self, card):
if isinstance(card, CardQuery):
self.card = card
else:
self.card = CardQuery(card.ref_name)
def act(self, actor, target, other=None):
card = self.card.get_card(target, target.player, actor)
if target.is_card():
target.replace(card)
elif target.is_minion():
minion = card.create_minion(target.player)
minion.card = card
target.replace(minion)
elif target.is_hero():
hero = card.create_hero(target.player)
hero.card = card
target.player.trigger("minion_played", actor)
hero.buffs = copy.deepcopy(actor.buffs)
hero.health = actor.health
target.replace(hero)
if hero.health <= 0:
hero.die(None)
def __to_json__(self):
return {
'name': 'transform',
'card': self.card
}
def __from_json__(self, card):
self.card = CardQuery.from_json(**card)
return self
示例3: ApplySecret
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
class ApplySecret(Action):
def __init__(self, source):
self.source = source
self._query = CardQuery(conditions=[IsSecret()], source=source)
def act(self, actor, target):
secret = self._query.get_card(target)
if secret:
target.secrets.append(secret)
secret.player = target
if target is target.game.other_player:
secret.player = target
secret.activate(target)
def __to_json__(self):
return {
'name': 'apply_secret',
'source': CARD_SOURCE.to_str(self.source)
}
def __from_json__(self, source):
self.source = CARD_SOURCE.from_str(source)
self._query = CardQuery(conditions=[IsSecret()], source=self.source)
return self
示例4: ApplySecret
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
class ApplySecret(Action):
def __init__(self, source):
self.source = source
self._query = CardQuery(conditions=[IsSecret()], source=source)
def act(self, actor, target, other=None):
secret = self._query.get_card(target, target, actor)
if secret:
target.secrets.append(secret)
secret.player = target
if target is target.game.other_player:
secret.player = target
# To allow for Mad Scientist not to be redeemed or duplicated as a result of its death,
# but still allow other minions that die during the same cycle to be duplicated.
# Based on testing for patch 2.1.0.7785
if actor.dead:
target.bind_once("after_death", secret.activate)
else:
secret.activate(target)
def __to_json__(self):
return {
'name': 'apply_secret',
'source': CARD_SOURCE.to_str(self.source)
}
def __from_json__(self, source):
self.source = CARD_SOURCE.from_str(source)
self._query = CardQuery(conditions=[IsSecret()], source=self.source)
return self
示例5: Transform
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
class Transform(Action):
def __init__(self, card):
if isinstance(card, CardQuery):
self.card = card
else:
self.card = CardQuery(card.ref_name)
def act(self, actor, target, other=None):
card = self.card.get_card(target, target.player, actor)
if target.is_card():
target.replace(card)
elif target.is_minion():
minion = card.create_minion(target.player)
minion.card = card
target.replace(minion)
elif target.is_hero():
hero = card.create_hero(target.player)
target.replace(hero)
def __to_json__(self):
return {
'name': 'transform',
'card': self.card
}
def __from_json__(self, card):
self.card = CardQuery.from_json(**card)
return self
示例6: ReplaceHeroWithMinion
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
class ReplaceHeroWithMinion(Action):
# Used only for Jaraxxus currently
def __init__(self, card):
if isinstance(card, CardQuery):
self.card = card
else:
self.card = CardQuery(card.ref_name)
def act(self, actor, target, other=None):
card = self.card.get_card(target, target.player, actor)
hero = card.create_hero(target.player)
hero.card = card
target.player.trigger("minion_played", actor)
hero.buffs = copy.deepcopy(actor.buffs)
hero.health = actor.health
target.replace(hero)
if hero.health <= 0:
hero.die(None)
def __to_json__(self):
return {
'name': 'replace_hero_with_minion',
'card': self.card
}
def __from_json__(self, card):
self.card = CardQuery.from_json(**card)
return self
示例7: AddCard
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
class AddCard(Action):
def __init__(self, card, count=1, add_to_deck=False):
if isinstance(card, CardQuery):
self.card = card
else:
self.card = CardQuery(card.ref_name)
self.add_to_deck = add_to_deck
self.count = count
def act(self, actor, target, other=None):
if self.add_to_deck:
for i in range(self.count):
target.deck.put_back(self.card.get_card(target, target, actor))
else:
for i in range(self.count):
if len(target.hand) < 10:
card = self.card.get_card(target, target, actor)
if card:
target.hand.append(copy.copy(card))
card.drawn = True
def __to_json__(self):
if self.add_to_deck:
return {
'name': 'add_card',
'card': self.card,
'count': self.count,
'add_to_deck': self.add_to_deck,
}
return {
'name': 'add_card',
'card': self.card,
'count': self.count
}
def __from_json__(self, card, count=1, add_to_deck=False):
self.card = CardQuery.from_json(**card)
self.count = count
self.add_to_deck = add_to_deck
return self
示例8: Summon
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
class Summon(Action):
def __init__(self, card, count=1):
if isinstance(card, CardQuery):
self.card = card
else:
self.card = CardQuery(card.ref_name)
self.count = count
def act(self, actor, target):
card = self.card.get_card(target)
if card is None:
return
if actor.is_minion() and actor.player is target:
# Cenaurius and Dr. Boom are special snowflakes that summon minions on either side of themselves
if self.count == 2:
card.summon(target, target.game, actor.index)
card.summon(target, target.game, actor.index + 1)
else:
if actor.removed:
index = actor.index
else:
index = actor.index + 1
for summon in range(self.count):
card.summon(target, target.game, index)
index += 1
else:
for summon in range(self.count):
card.summon(target, target.game, len(target.minions))
def __to_json__(self):
if self.count > 1:
return {
'name': 'summon',
'card': self.card,
'count': self.count
}
return {
'name': 'summon',
'card': self.card
}
def __from_json__(self, card, count=1):
self.card = CardQuery.from_json(**card)
self.count = count
return self
示例9: Summon
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
class Summon(Action):
def __init__(self, card, count=1):
if isinstance(card, CardQuery):
self.card = card
else:
self.card = CardQuery(card.ref_name)
self.count = count
def act(self, actor, target, other=None):
card = self.card.get_card(target, target, actor)
if card is None:
return
if actor.is_minion() and actor.player is target:
# When a minion is summoned around another minion, they alternate between left and right,
# starting on the right
if actor.removed:
c = 0
else:
c = 1
for summon in range(self.count):
index = actor.index + (c % 2)
card.summon(target, target.game, index)
if not actor.removed:
c += 1
else:
for summon in range(self.count):
card.summon(target, target.game, len(target.minions))
def __to_json__(self):
if self.count > 1:
return {
'name': 'summon',
'card': self.card,
'count': self.count
}
return {
'name': 'summon',
'card': self.card
}
def __from_json__(self, card, count=1):
self.card = CardQuery.from_json(**card)
self.count = count
return self
示例10: Summon
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
class Summon(Action):
def __init__(self, card, count=1):
if isinstance(card, CardQuery):
self.card = card
else:
self.card = CardQuery(card.ref_name)
self.count = count
def act(self, actor, target):
if actor.is_minion():
if actor.removed:
index = actor.index
else:
index = actor.index + 1
else:
for summon in range(self.count):
index = len(target.minions)
card = self.card.get_card(target)
if card is None:
return
# TODO add explicit patters for multi minion summoning (if there is ever more than two)
for summon in range(self.count):
card.summon(target, target.game, index)
if actor.is_minion():
index = actor.index # Move the later minions to the left of their originator
def __to_json__(self):
if self.count > 1:
return {
'name': 'summon',
'card': self.card,
'count': self.count
}
return {
'name': 'summon',
'card': self.card
}
def __from_json__(self, card, count=1):
self.card = CardQuery.from_json(**card)
self.count = count
return self
示例11: AddCard
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
class AddCard(Action):
def __init__(self, card):
if isinstance(card, hearthbreaker.game_objects.Card):
self.card = CardQuery(card.name)
else:
self.card = card
def act(self, actor, target):
if len(target.hand) < 10:
target.hand.append(self.card.get_card(target))
def __to_json__(self):
return {
'name': 'add_card',
'card': self.card
}
def __from_json__(self, card, count=1):
self.card = CardQuery.from_json(**card)
return self
示例12: Equip
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
class Equip(Action):
def __init__(self, weapon):
if isinstance(weapon, CardQuery):
self.weapon = weapon
else:
self.weapon = CardQuery(weapon.ref_name)
def act(self, actor, target):
card = self.weapon.get_card(target)
weapon = card.create_weapon(target)
weapon.equip(target)
def __to_json__(self):
return {
'name': 'equip',
'weapon': self.weapon
}
def __from_json__(self, weapon):
self.weapon = CardQuery.from_json(**weapon)
return self
示例13: Transform
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
class Transform(Action):
def __init__(self, card):
if isinstance(card, CardQuery):
self.card = card
else:
self.card = CardQuery(card.ref_name)
def act(self, actor, target):
card = self.card.get_card(target)
minion = card.create_minion(target.player)
minion.card = card
target.replace(minion)
def __to_json__(self):
return {
'name': 'transform',
'card': self.card
}
def __from_json__(self, card):
self.card = CardQuery.from_json(**card)
return self
示例14: Summon
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
class Summon(Action):
def __init__(self, card, count=1):
if isinstance(card, hearthbreaker.game_objects.Card):
self.card = CardQuery(card.name)
else:
self.card = card
self.count = count
def act(self, actor, target):
if isinstance(actor, hearthbreaker.game_objects.Minion):
if actor.removed:
index = actor.index
else:
index = actor.index + 1
else:
for summon in range(self.count):
index = len(target.minions)
card = self.card.get_card(target)
for summon in range(self.count):
card.summon(target, target.game, index)
def __to_json__(self):
if self.count > 1:
return {
'name': 'summon',
'card': self.card,
'count': self.count
}
return {
'name': 'summon',
'card': self.card
}
def __from_json__(self, card, count=1):
self.card = CardQuery.from_json(**card)
self.count = count
return self
示例15: AddCard
# 需要导入模块: from hearthbreaker.tags.base import CardQuery [as 别名]
# 或者: from hearthbreaker.tags.base.CardQuery import get_card [as 别名]
class AddCard(Action):
def __init__(self, card, count=1):
if isinstance(card, CardQuery):
self.card = card
else:
self.card = CardQuery(card.ref_name)
self.count = count
def act(self, actor, target):
for i in range(self.count):
if len(target.hand) < 10:
target.hand.append(self.card.get_card(target))
def __to_json__(self):
return {
'name': 'add_card',
'card': self.card,
'count': self.count
}
def __from_json__(self, card, count=1):
self.card = CardQuery.from_json(**card)
self.count = count
return self