*Added AF_EndTurn. canPlayAI always returns false because I couldn't think of a good,general way to decide it's usefulness.

*Added
	Sundial of the Infinite
	Time Stop
This commit is contained in:
Hellfish
2012-02-13 10:07:00 +00:00
parent 5eddf37eb6
commit 10f1859d0c
8 changed files with 167 additions and 0 deletions

View File

@@ -1029,6 +1029,11 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
public final void setDevPhaseState(final String phaseID) {
this.phaseIndex = this.findIndex(phaseID);
}
public final void setPhaseState(final String phaseID) {
this.phaseIndex = this.findIndex(phaseID);
this.handleBeginPhase();
}
/**
*

View File

@@ -760,6 +760,16 @@ public class AbilityFactory {
spellAbility = AbilityFactoryEffect.createDrawbackEffect(this);
}
}
else if (this.api.equals("EndTurn")) {
if(this.isAb) {
spellAbility = AbilityFactoryTurns.createAbilityEndTurn(this);
} else if (this.isSp) {
spellAbility = AbilityFactoryTurns.createSpellEndTurn(this);
} else if (this.isDb) {
spellAbility = AbilityFactoryTurns.createDrawbackEndTurn(this);
}
}
else if (this.api.equals("ExchangeLife")) {
if (this.isAb) {

View File

@@ -21,6 +21,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import forge.AllZone;
import forge.Card;
import forge.Constant;
import forge.Player;
import forge.card.spellability.AbilityActivated;
import forge.card.spellability.AbilitySub;
@@ -286,5 +288,127 @@ public class AbilityFactoryTurns {
}
}
}
// *************************************************************************
// ************************* END TURN **************************************
// *************************************************************************
public static SpellAbility createAbilityEndTurn(final AbilityFactory af) {
SpellAbility ret = new AbilityActivated(af.getHostCard(),af.getAbCost(),af.getAbTgt()) {
private static final long serialVersionUID = 72570867940224012L;
@Override
public String getStackDescription() {
return "End the turn.";
}
@Override
public boolean canPlayAI() {
return false;
}
@Override
public boolean doTrigger(boolean mandatory) {
if(mandatory) {
return true;
}
return false;
}
@Override
public void resolve() {
endTurnResolve(af,this);
}
};
return ret;
}
public static SpellAbility createSpellEndTurn(final AbilityFactory af) {
SpellAbility ret = new Spell(af.getHostCard(),af.getAbCost(),af.getAbTgt()) {
private static final long serialVersionUID = -2553413143747617709L;
@Override
public String getStackDescription() {
return "End the turn.";
}
@Override
public boolean canPlayAI() {
return false;
}
@Override
public void resolve() {
endTurnResolve(af,this);
}
};
return ret;
}
public static SpellAbility createDrawbackEndTurn(final AbilityFactory af) {
final SpellAbility dbEndTurn = new AbilitySub(af.getHostCard(), af.getAbTgt()) {
private static final long serialVersionUID = -562517287448810951L;
@Override
public String getStackDescription() {
return "End the turn.";
}
@Override
public void resolve() {
AbilityFactoryTurns.endTurnResolve(af, this);
}
@Override
public boolean chkAIDrawback() {
return false;
}
@Override
public boolean doTrigger(final boolean mandatory) {
if(mandatory) {
return true;
}
return false;
}
};
return dbEndTurn;
}
private static void endTurnResolve(final AbilityFactory af, final SpellAbility sa) {
//Steps taken from gatherer's rulings on Time Stop.
//1) All spells and abilities on the stack are exiled. This includes Time Stop, though it will continue to resolve. It also includes spells and abilities that can't be countered.
for(Card c : AllZone.getStackZone().getCards()) {
AllZone.getGameAction().exile(c);
}
AllZone.getStack().getStack().clear();
//2) All attacking and blocking creatures are removed from combat.
AllZone.getCombat().resetAttackers();
AllZone.getCombat().resetBlockers();
//3) State-based actions are checked. No player gets priority, and no triggered abilities are put onto the stack.
AllZone.getGameAction().checkStateEffects();
//4) The current phase and/or step ends. The game skips straight to the cleanup step. The cleanup step happens in its entirety.
AllZone.getPhaseHandler().setPhaseState(Constant.Phase.CLEANUP);
//Update observers
AllZone.getStack().updateObservers();
AllZone.getComputerPlayer().updateObservers();
AllZone.getHumanPlayer().updateObservers();
AllZone.getComputerPlayer().updateLabelObservers();
AllZone.getHumanPlayer().updateLabelObservers();
}
} // end class AbilityFactory_Turns