mirror of
https://github.com/correl/mage.git
synced 2025-03-12 17:00:08 -09:00
Some fclean-up and fixes for commander handling.
This commit is contained in:
parent
ea841e4908
commit
e83982498f
4 changed files with 15 additions and 16 deletions
|
@ -30,6 +30,7 @@ package mage.abilities.dynamicvalue.common;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
|
||||
|
@ -44,14 +45,14 @@ public class ManaSpentToCastCount implements DynamicValue{
|
|||
|
||||
@Override
|
||||
public int calculate(Game game, Ability source) {
|
||||
int count = 0;
|
||||
if (!game.getStack().isEmpty()) {
|
||||
StackObject spell = game.getStack().getFirst();
|
||||
if (spell != null && spell instanceof Spell && ((Spell)spell).getSourceId().equals(source.getSourceId())) {
|
||||
count = ((Spell)spell).getSpellAbility().getManaCostsToPay().convertedManaCost();
|
||||
for (StackObject stackObject : game.getStack()) {
|
||||
if (stackObject instanceof Spell && ((Spell)stackObject).getSourceId().equals(source.getSourceId())) {
|
||||
return ((Spell)stackObject).getSpellAbility().getManaCostsToPay().convertedManaCost();
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -293,6 +293,8 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
|||
game.getPlayer(ownerId).getSideboard().remove(this);
|
||||
break;
|
||||
case COMMAND:
|
||||
game.getState().getCommand().remove((Commander)game.getObject(objectId));
|
||||
break;
|
||||
case STACK:
|
||||
case PICK:
|
||||
break;
|
||||
|
@ -469,6 +471,7 @@ public abstract class CardImpl<T extends CardImpl<T>> extends MageObjectImpl<T>
|
|||
removed = true;
|
||||
break;
|
||||
case COMMAND:
|
||||
game.getState().getCommand().remove((Commander)game.getObject(objectId));
|
||||
removed = true;
|
||||
break;
|
||||
case PICK:
|
||||
|
|
|
@ -1072,11 +1072,6 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
|
|||
@Override
|
||||
public void addCommander(Commander commander){
|
||||
state.addCommandObject(commander);
|
||||
for(Ability ability : commander.getAbilities()){
|
||||
if(ability instanceof CastCommanderAbility){
|
||||
state.addOtherAbility(commander.getId(), (CastCommanderAbility)ability);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -583,10 +583,11 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Other abilities are used to implement some special kind of continious effects.
|
||||
* Other abilities are used to implement some special kind of continious effects given to non permanents.
|
||||
*
|
||||
* Crucible of Worlds - You may play land cards from your graveyard.
|
||||
* Past in Flames - Each instant and sorcery card in your graveyard gains flashback until end of turn. The flashback cost is equal to its mana cost.
|
||||
* Varolz, the Scar-Striped - Each creature card in your graveyard has scavenge. The scavenge cost is equal to its mana cost.
|
||||
*
|
||||
* @param objectId
|
||||
* @param zone
|
||||
|
@ -601,15 +602,14 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
|
||||
public void addOtherAbility(UUID objectId, ActivatedAbility ability) {
|
||||
if (!otherAbilities.containsKey(objectId)) {
|
||||
otherAbilities.put(objectId, new AbilitiesImpl());
|
||||
otherAbilities.put(objectId, new AbilitiesImpl(ability));
|
||||
} else {
|
||||
otherAbilities.get(objectId).add(ability);
|
||||
}
|
||||
otherAbilities.get(objectId).add(ability);
|
||||
}
|
||||
|
||||
private void resetOtherAbilities() {
|
||||
for (Abilities<ActivatedAbility> abilities: otherAbilities.values()) {
|
||||
abilities.clear();
|
||||
}
|
||||
otherAbilities.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue