mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
[THS] Added DynamicValue for Devotion.
This commit is contained in:
parent
40102af238
commit
93ca287478
1 changed files with 70 additions and 0 deletions
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.constants.ManaType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* Each colored mana symbol (e.g. {U}) in the mana costs of permanents you control counts toward your devotion to that color.
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class DevotionCount implements DynamicValue {
|
||||
|
||||
private ManaType devotionColor;
|
||||
|
||||
|
||||
public DevotionCount(ManaType devotionColor) {
|
||||
this.devotionColor = devotionColor;
|
||||
}
|
||||
|
||||
public DevotionCount(final DevotionCount dynamicValue) {
|
||||
this.devotionColor = dynamicValue.devotionColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility) {
|
||||
int devotion = 0;
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(sourceAbility.getControllerId())) {
|
||||
switch (devotionColor) {
|
||||
case BLACK:
|
||||
devotion += permanent.getManaCost().getMana().getBlack();
|
||||
break;
|
||||
case BLUE:
|
||||
devotion += permanent.getManaCost().getMana().getBlue();
|
||||
break;
|
||||
case GREEN:
|
||||
devotion += permanent.getManaCost().getMana().getGreen();
|
||||
break;
|
||||
case RED:
|
||||
devotion += permanent.getManaCost().getMana().getRed();
|
||||
break;
|
||||
case WHITE:
|
||||
devotion += permanent.getManaCost().getMana().getWhite();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return devotion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicValue copy() {
|
||||
return new DevotionCount(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuilder("devotion to ").append(devotionColor.toString()).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return toString();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue