This commit is contained in:
BetaSteward 2010-05-04 02:19:02 +00:00
parent e10b1be9c4
commit 9e925a7723
8 changed files with 36 additions and 45 deletions

View file

@ -32,8 +32,6 @@ import java.io.Serializable;
public class ObjectColor implements Serializable { public class ObjectColor implements Serializable {
private static final long serialVersionUID = 1L;
public static final ObjectColor WHITE = new ObjectColor("W"); public static final ObjectColor WHITE = new ObjectColor("W");
public static final ObjectColor BLUE = new ObjectColor("U"); public static final ObjectColor BLUE = new ObjectColor("U");
public static final ObjectColor BLACK = new ObjectColor("B"); public static final ObjectColor BLACK = new ObjectColor("B");

View file

@ -142,23 +142,4 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
return null; return null;
} }
// @Override
// public ManaCosts getManaCosts() {
// ManaCosts manaCosts = new ManaCosts(ability);
// for (T cost: this) {
// if (cost instanceof ManaCost)
// manaCosts.add((ManaCost)cost);
// }
// return manaCosts;
// }
//
// @Override
// public List<VariableManaCost> getVariableCosts() {
// List<VariableManaCost> variableCosts = new ArrayList<VariableManaCost>();
// for (T cost: this) {
// if (cost instanceof ManaCosts)
// variableCosts.addAll(((ManaCosts)cost).getVariableCosts());
// }
// return variableCosts;
// }
} }

View file

@ -53,7 +53,6 @@ import mage.players.Player;
*/ */
public class ContinuousEffects implements Serializable { public class ContinuousEffects implements Serializable {
private static final long serialVersionUID = 1L;
private List<ContinuousEffect> effects = new ArrayList<ContinuousEffect>(); private List<ContinuousEffect> effects = new ArrayList<ContinuousEffect>();
public void removeEndOfTurnEffects() { public void removeEndOfTurnEffects() {

View file

@ -33,10 +33,12 @@ import mage.Constants.Outcome;
import mage.Constants.TimingRule; import mage.Constants.TimingRule;
import mage.Constants.Zone; import mage.Constants.Zone;
import mage.abilities.ActivatedAbilityImpl; import mage.abilities.ActivatedAbilityImpl;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.OnEventTriggeredAbility; import mage.abilities.common.OnEventTriggeredAbility;
import mage.abilities.costs.mana.ManaCosts; import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.ExileSourceEffect; import mage.abilities.effects.common.ExileSourceEffect;
import mage.abilities.effects.common.GainAbilitySourceEffect; import mage.abilities.effects.common.GainAbilitySourceEffect;
import mage.cards.Card; import mage.cards.Card;
@ -58,7 +60,7 @@ public class UnearthAbility extends ActivatedAbilityImpl {
super(Zone.GRAVEYARD, new UnearthEffect(), costs); super(Zone.GRAVEYARD, new UnearthEffect(), costs);
this.timing = TimingRule.SORCERY; this.timing = TimingRule.SORCERY;
this.effects.add(new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.WhileOnBattlefield)); this.effects.add(new GainAbilitySourceEffect(HasteAbility.getInstance(), Duration.WhileOnBattlefield));
this.effects.add(new GainAbilitySourceEffect(new OnEventTriggeredAbility(EventType.END_TURN_STEP_PRE, "beginning of the end step", new ExileSourceEffect()), Duration.WhileOnBattlefield)); this.effects.add(new CreateDelayedTriggeredAbilityEffect(new UnearthDelayedTriggeredAbility()));
this.effects.add(new UnearthLeavesBattlefieldEffect()); this.effects.add(new UnearthLeavesBattlefieldEffect());
} }
@ -85,6 +87,7 @@ class UnearthEffect extends OneShotEffect {
Card card = player.getGraveyard().get(this.source.getSourceId()); Card card = player.getGraveyard().get(this.source.getSourceId());
if (card != null) { if (card != null) {
player.putOntoBattlefield(card, game); player.putOntoBattlefield(card, game);
player.removeFromGraveyard(card, game);
return true; return true;
} }
return false; return false;
@ -97,6 +100,28 @@ class UnearthEffect extends OneShotEffect {
} }
class UnearthDelayedTriggeredAbility extends DelayedTriggeredAbility {
public UnearthDelayedTriggeredAbility() {
super(new ExileSourceEffect());
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == EventType.END_TURN_STEP_PRE && event.getPlayerId().equals(this.controllerId)) {
trigger(game, event.getPlayerId());
return true;
}
return false;
}
@Override
public String getRule() {
return "Exile {this} at the beginning of the next end step";
}
}
class UnearthLeavesBattlefieldEffect extends ReplacementEffectImpl { class UnearthLeavesBattlefieldEffect extends ReplacementEffectImpl {
@ -108,7 +133,7 @@ class UnearthLeavesBattlefieldEffect extends ReplacementEffectImpl {
public boolean applies(GameEvent event, Game game) { public boolean applies(GameEvent event, Game game) {
if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(this.source.getSourceId())) { if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(this.source.getSourceId())) {
ZoneChangeEvent zEvent = (ZoneChangeEvent)event; ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
if (zEvent.getFromZone() == Zone.BATTLEFIELD) if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getToZone() != Zone.EXILED)
return true; return true;
} }
return false; return false;
@ -128,6 +153,6 @@ class UnearthLeavesBattlefieldEffect extends ReplacementEffectImpl {
@Override @Override
public String getText() { public String getText() {
return "When {this} leaves the battlefield, exile {this}"; return "When {this} leaves the battlefield, exile it";
} }
} }

View file

@ -58,7 +58,7 @@ public class Exile implements Serializable {
} }
public ExileZone createZone(UUID id, String name) { public ExileZone createZone(UUID id, String name) {
return createZone(id, name, false); return createZone(id, name + " - Exile", false);
} }
public ExileZone createZone(UUID id, String name, boolean hidden) { public ExileZone createZone(UUID id, String name, boolean hidden) {

View file

@ -524,6 +524,7 @@ public abstract class GameImpl implements Game, Serializable {
if (!replaceEvent(new GameEvent(GameEvent.EventType.DRAW_STEP, null, null, activePlayerId))) { if (!replaceEvent(new GameEvent(GameEvent.EventType.DRAW_STEP, null, null, activePlayerId))) {
//20091005 - 504.1/703.4c //20091005 - 504.1/703.4c
getPlayer(activePlayerId).drawCards(1, this); getPlayer(activePlayerId).drawCards(1, this);
saveState();
fireEvent(new GameEvent(GameEvent.EventType.DRAW_STEP_PRE, null, null, activePlayerId)); fireEvent(new GameEvent(GameEvent.EventType.DRAW_STEP_PRE, null, null, activePlayerId));
playPriority(activePlayerId); playPriority(activePlayerId);
fireEvent(new GameEvent(GameEvent.EventType.DRAW_STEP_POST, null, null, activePlayerId)); fireEvent(new GameEvent(GameEvent.EventType.DRAW_STEP_POST, null, null, activePlayerId));
@ -606,6 +607,7 @@ public abstract class GameImpl implements Game, Serializable {
playPriority(activePlayerId); playPriority(activePlayerId);
fireEvent(new GameEvent(GameEvent.EventType.END_COMBAT_STEP_POST, null, null, activePlayerId)); fireEvent(new GameEvent(GameEvent.EventType.END_COMBAT_STEP_POST, null, null, activePlayerId));
removeCreaturesFromCombat(); removeCreaturesFromCombat();
saveState();
return true; return true;
} }
return false; return false;

View file

@ -60,8 +60,6 @@ import mage.target.common.TargetCardInLibrary;
public interface Player extends MageItem { public interface Player extends MageItem {
public boolean isHuman(); public boolean isHuman();
public Deck getDeck();
public void setDeck(Deck deck);
public String getName(); public String getName();
public Library getLibrary(); public Library getLibrary();
public Cards getGraveyard(); public Cards getGraveyard();

View file

@ -76,7 +76,6 @@ public abstract class PlayerImpl implements Player, Serializable {
protected int life; protected int life;
protected boolean wins; protected boolean wins;
protected boolean loses; protected boolean loses;
protected Deck deck;
protected Library library; protected Library library;
protected Cards hand = new CardsImpl(Zone.HAND); protected Cards hand = new CardsImpl(Zone.HAND);
protected Cards graveyard = new CardsImpl(Zone.GRAVEYARD); protected Cards graveyard = new CardsImpl(Zone.GRAVEYARD);
@ -90,10 +89,12 @@ public abstract class PlayerImpl implements Player, Serializable {
protected boolean passedTurn; protected boolean passedTurn;
protected boolean left; protected boolean left;
public PlayerImpl(String name) { public PlayerImpl(String name, Deck deck) {
this.playerId = UUID.randomUUID(); this.playerId = UUID.randomUUID();
this.name = name; this.name = name;
deck.setOwnerId(playerId);
library = new Library(playerId); library = new Library(playerId);
library.addAll(deck.getCards());
} }
@Override @Override
@ -101,14 +102,12 @@ public abstract class PlayerImpl implements Player, Serializable {
this.hand.clear(); this.hand.clear();
this.graveyard.clear(); this.graveyard.clear();
this.abilities.clear(); this.abilities.clear();
this.library.clear();
this.wins = false; this.wins = false;
this.loses = false; this.loses = false;
this.left = false; this.left = false;
this.passed = false; this.passed = false;
this.passedTurn = false; this.passedTurn = false;
library.addAll(deck.getCards()); for (Card card: library.getCards()) {
for (Card card: deck.getCards().values()) {
for (Watcher watcher: card.getWatchers()) { for (Watcher watcher: card.getWatchers()) {
watcher.setControllerId(playerId); watcher.setControllerId(playerId);
game.getState().getWatchers().add(watcher); game.getState().getWatchers().add(watcher);
@ -470,17 +469,6 @@ public abstract class PlayerImpl implements Player, Serializable {
return graveyard; return graveyard;
} }
@Override
public Deck getDeck() {
return deck;
}
@Override
public void setDeck(Deck deck) {
this.deck = deck;
deck.setOwnerId(playerId);
}
@Override @Override
public ManaPool getManaPool() { public ManaPool getManaPool() {
return this.manaPool; return this.manaPool;
@ -578,7 +566,7 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public void restore(Player player) { public void restore(Player player) {
this.library = player.getLibrary(); this.library = player.getLibrary();
this.deck = player.getDeck(); // this.deck = player.getDeck();
this.hand = player.getHand(); this.hand = player.getHand();
this.graveyard = player.getGraveyard(); this.graveyard = player.getGraveyard();
this.abilities = player.getAbilities(); this.abilities = player.getAbilities();