fireplace icon indicating copy to clipboard operation
fireplace copied to clipboard

Faceless Manipulator/ExactCopy does not copy enchantment attributes

Open beheh opened this issue 9 years ago • 2 comments

If you play a minion and Vol'jin it, and then play a Faceless Manipulator targeting either Vol'jin or the minion with Voljin's Shadowed buff, the following error occurs:

self = <Enchantment ('Shadowed')>, i = 1

>   max_health = lambda self, i: self.health
E   AttributeError: 'Enchantment' object has no attribute 'health'

../fireplace/cards/gvg/priest.py:26: AttributeError

Test case:

def test_faceless_manipulator_voljin():
    game = prepare_game()
    wisp = game.player1.give(WISP)
    wisp.play()
    assert wisp.health == 1
    voljin = game.player1.give("GVG_014")
    voljin.play(target=wisp)
    assert wisp.health == 2
    assert voljin.health == 1
    game.end_turn()

    faceless = game.player2.give("EX1_564")
    faceless.play(target=wisp)
    morphed = game.player2.field[0]
    assert wisp.health == 2
    assert voljin.health == 1
    assert morphed.health == 2

Full log

For reference, Vol'jin's implemenation:

# Vol'jin
class GVG_014:
    # TODO
    def play(self):
        health = self.target.health
        self.buff(self.target, "GVG_014a", health=self.health)
        self.buff(self, "GVG_014a", health=health)

class GVG_014a:
    max_health = lambda self, i: self.health

beheh avatar Sep 12 '15 10:09 beheh

The problem is that the health attribute (actually no attribute in at all) is transferred when recreating the buff in ExactCopy:

class ExactCopy(Copy):
    """
    Lazily create an exact copy of the target.
    An exact copy will include buffs and all tags.
    """
    def copy(self, source, entity):
        ret = super().copy(source, entity)
        for k in entity.silenceable_attributes:
            v = getattr(entity, k)
            setattr(ret, k, v)
        ret.silenced = entity.silenced
        ret.damage = entity.damage
        for buff in entity.buffs:
            # Recreate the buff stack
            entity.buff(ret, buff.id)
        return ret

beheh avatar Nov 15 '15 10:11 beheh

This might also affect Void Terror.

beheh avatar Nov 23 '15 19:11 beheh