Refactoring snow mana to allow tracking how much is spent (Ready for Review) (#7406)

* refactored mana methods to WUBRG order

* more WUBRG refactoring

* added new mana tracking object

* fixed code error

* fixed missing mana count

* fixed null pointer exception in tests

* fixed issue with equality

* more equality fixes

* some cosmetic changes to ManaTest

* added copy method to setToMana

* fixed some initialization issues

* fixed serialization issue

* [KHM] Implemented Search for Glory

* updated mana handling to track snow

* added tests for snow mana tracking

* updated implementation of setter methods

* updated paramater to use copy methods

* fixed snow mana test to ensure proper mana tapping

* replaced instances of getPayment with getUsedManaToPay

* updated tracking of snow mana

* reverted snow mana tracking removal

* finished reverting change
This commit is contained in:
Evan Kranzler 2021-01-21 18:13:51 -05:00 committed by GitHub
parent 5e4b5239d8
commit e5344b7a96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 1006 additions and 720 deletions

View file

@ -0,0 +1,49 @@
package mage.abilities.dynamicvalue.common;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.constants.AbilityType;
import mage.game.Game;
import mage.watchers.common.ManaSpentToCastWatcher;
/**
* @author TheElk801
*/
public enum SnowManaSpentValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
if (sourceAbility.getAbilityType() == AbilityType.SPELL) {
return sourceAbility.getManaCostsToPay().getUsedManaToPay().getSnow();
}
ManaSpentToCastWatcher watcher = game.getState().getWatcher(
ManaSpentToCastWatcher.class, sourceAbility.getSourceId()
);
if (watcher == null) {
return 0;
}
Mana payment = watcher.getAndResetLastPayment();
if (payment == null) {
return 0;
}
return payment.getSnow();
}
@Override
public SnowManaSpentValue copy() {
return instance;
}
@Override
public String toString() {
return "1";
}
@Override
public String getMessage() {
return "{S} spent to cast this spell";
}
}

View file

@ -21,7 +21,7 @@ public enum SunburstCount implements DynamicValue {
if (!game.getStack().isEmpty()) {
StackObject spell = game.getStack().getFirst();
if (spell instanceof Spell && ((Spell) spell).getSourceId().equals(sourceAbility.getSourceId())) {
Mana mana = ((Spell) spell).getSpellAbility().getManaCostsToPay().getPayment();
Mana mana = ((Spell) spell).getSpellAbility().getManaCostsToPay().getUsedManaToPay();
if (mana.getBlack() > 0) {
count++;
}