当前位置: 首页>>代码示例>>Python>>正文


Python base.CardQuery类代码示例

本文整理汇总了Python中hearthbreaker.tags.base.CardQuery的典型用法代码示例。如果您正苦于以下问题:Python CardQuery类的具体用法?Python CardQuery怎么用?Python CardQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CardQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: use

 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)
开发者ID:Ragowit,项目名称:hearthbreaker,代码行数:9,代码来源:warlock.py

示例2: ApplySecret

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
开发者ID:bussiere,项目名称:hearthbreaker,代码行数:25,代码来源:action.py

示例3: Transform

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
开发者ID:Adeimantius,项目名称:hearthbreaker,代码行数:34,代码来源:action.py

示例4: __init__

 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
开发者ID:jademcgough,项目名称:hearthstone-simulator,代码行数:7,代码来源:action.py

示例5: ApplySecret

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
开发者ID:Ragowit,项目名称:hearthbreaker,代码行数:31,代码来源:action.py

示例6: Transform

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
开发者ID:Ragowit,项目名称:hearthbreaker,代码行数:28,代码来源:action.py

示例7: ReplaceHeroWithMinion

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
开发者ID:Ragowit,项目名称:hearthbreaker,代码行数:29,代码来源:action.py

示例8: AddCard

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
开发者ID:Ragowit,项目名称:hearthbreaker,代码行数:40,代码来源:action.py

示例9: Summon

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
开发者ID:randomflyingtaco,项目名称:hearthbreaker-fork,代码行数:46,代码来源:action.py

示例10: Summon

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
开发者ID:Ragowit,项目名称:hearthbreaker,代码行数:45,代码来源:action.py

示例11: Summon

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
开发者ID:bussiere,项目名称:hearthbreaker,代码行数:43,代码来源:action.py

示例12: AddCard

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
开发者ID:nilrogen,项目名称:CGS-AI-UML,代码行数:20,代码来源:action.py

示例13: Equip

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
开发者ID:bussiere,项目名称:hearthbreaker,代码行数:21,代码来源:action.py

示例14: Transform

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
开发者ID:bussiere,项目名称:hearthbreaker,代码行数:22,代码来源:action.py

示例15: Summon

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
开发者ID:nilrogen,项目名称:CGS-AI-UML,代码行数:37,代码来源:action.py


注:本文中的hearthbreaker.tags.base.CardQuery类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。