[C21] Fixed Fractal Harness adding too many counters on attack (fixes #8377)

This commit is contained in:
Daniel Bomar 2021-10-20 14:38:05 -05:00
parent f48eb4a179
commit e8db40bb8d
No known key found for this signature in database
GPG key ID: C86C8658F4023918
2 changed files with 4 additions and 5 deletions

View file

@ -108,14 +108,11 @@ class FractalHarnessDoubleEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) getValue("attachedPermanent");
Permanent permanent = game.getPermanent((UUID) getValue("sourceId"));
if (permanent == null) {
return false;
}
// BUG : changed this to a integer due to the trigger firing twice
final int addedCounters = permanent.getCounters(game).getCount(CounterType.P1P1);
// BUG : this oneShotEffect is being run twice for some reason, so the number of counters is four times as many
return permanent.addCounters(CounterType.P1P1.createInstance(addedCounters),
return permanent.addCounters(CounterType.P1P1.createInstance(permanent.getCounters(game).getCount(CounterType.P1P1)),
source.getControllerId(), source, game);
}
}

View file

@ -54,6 +54,8 @@ public class AttacksAttachedTriggeredAbility extends TriggeredAbilityImpl {
if (equipment != null && equipment.getAttachedTo() != null
&& event.getSourceId().equals(equipment.getAttachedTo())) {
getEffects().setValue("sourceId", event.getSourceId());
// TODO: Passing a permanent object like this can cause bugs. May need refactoring to use UUID instead.
// See https://github.com/magefree/mage/issues/8377
getEffects().setValue("attachedPermanent", game.getPermanent(event.getSourceId()));
return true;
}