This commit is contained in:
BetaSteward 2010-12-09 04:55:01 +00:00
parent 50702a026d
commit b2d9c3b344
19 changed files with 60 additions and 33 deletions

View file

@ -311,7 +311,6 @@ public class MageFrame extends javax.swing.JFrame {
String server = prefs.get("serverAddress", ""); String server = prefs.get("serverAddress", "");
int port = Integer.parseInt(prefs.get("serverPort", "")); int port = Integer.parseInt(prefs.get("serverPort", ""));
try { try {
server = "192.168.121.201";
setCursor(new Cursor(Cursor.WAIT_CURSOR)); setCursor(new Cursor(Cursor.WAIT_CURSOR));
if (MageFrame.connect(userName, server, port)) { if (MageFrame.connect(userName, server, port)) {
return true; return true;

View file

@ -317,6 +317,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
break; break;
case DRAW: case DRAW:
logState(game); logState(game);
break;
case PRECOMBAT_MAIN: case PRECOMBAT_MAIN:
findPlayables(game); findPlayables(game);
if (playableAbilities.size() > 0) { if (playableAbilities.size() > 0) {
@ -336,10 +337,14 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
} }
break; break;
case DECLARE_BLOCKERS: case DECLARE_BLOCKERS:
findPlayables(game);
playRemoval(game.getCombat().getBlockers(), game); playRemoval(game.getCombat().getBlockers(), game);
playDamage(game.getCombat().getBlockers(), game); playDamage(game.getCombat().getBlockers(), game);
break;
case END_COMBAT: case END_COMBAT:
findPlayables(game);
playDamage(game.getCombat().getBlockers(), game); playDamage(game.getCombat().getBlockers(), game);
break;
case POSTCOMBAT_MAIN: case POSTCOMBAT_MAIN:
findPlayables(game); findPlayables(game);
if (game.getStack().isEmpty()) { if (game.getStack().isEmpty()) {
@ -370,11 +375,16 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
switch (game.getTurn().getStepType()) { switch (game.getTurn().getStepType()) {
case UPKEEP: case UPKEEP:
findPlayables(game); findPlayables(game);
break;
case DECLARE_ATTACKERS: case DECLARE_ATTACKERS:
findPlayables(game);
playRemoval(game.getCombat().getAttackers(), game); playRemoval(game.getCombat().getAttackers(), game);
playDamage(game.getCombat().getAttackers(), game); playDamage(game.getCombat().getAttackers(), game);
break;
case END_COMBAT: case END_COMBAT:
findPlayables(game);
playDamage(game.getCombat().getAttackers(), game); playDamage(game.getCombat().getAttackers(), game);
break;
} }
} }
pass(); pass();

View file

@ -99,7 +99,7 @@ class QuenchableFireEffect extends OneShotEffect<QuenchableFireEffect> {
delayedAbility.setSourceId(source.getSourceId()); delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId()); delayedAbility.setControllerId(source.getControllerId());
delayedAbility.getTargets().addAll(source.getTargets()); delayedAbility.getTargets().addAll(source.getTargets());
game.getState().addDelayedTriggeredAbility(delayedAbility); game.addDelayedTriggeredAbility(delayedAbility);
//create special action //create special action
QuenchableFireSpecialAction newAction = new QuenchableFireSpecialAction(delayedAbility.getId()); QuenchableFireSpecialAction newAction = new QuenchableFireSpecialAction(delayedAbility.getId());
delayedAbility.setSpecialActionId(newAction.getId()); delayedAbility.setSpecialActionId(newAction.getId());

View file

@ -106,7 +106,7 @@ class MystifyingMazeEffect extends OneShotEffect<MystifyingMazeEffect> {
MystifyingMazeDelayedTriggeredAbility delayedAbility = new MystifyingMazeDelayedTriggeredAbility(source.getSourceId()); MystifyingMazeDelayedTriggeredAbility delayedAbility = new MystifyingMazeDelayedTriggeredAbility(source.getSourceId());
delayedAbility.setSourceId(source.getSourceId()); delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId()); delayedAbility.setControllerId(source.getControllerId());
game.getState().addDelayedTriggeredAbility(delayedAbility); game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }
} }

View file

@ -142,7 +142,7 @@ class GideonJuraEffect extends RequirementAttackEffect<GideonJuraEffect> {
if (player != null) { if (player != null) {
for (Permanent creature: game.getBattlefield().getAllActivePermanents(new FilterCreatureForCombat(), player.getId())) { for (Permanent creature: game.getBattlefield().getAllActivePermanents(new FilterCreatureForCombat(), player.getId())) {
if (creature.canAttack(game)) { if (creature.canAttack(game)) {
game.getCombat().declareAttacker(creature.getId(), source.getControllerId(), game); game.getCombat().declareAttacker(creature.getId(), source.getSourceId(), game);
} }
} }
return true; return true;

View file

@ -52,8 +52,8 @@ public class Condemn extends CardImpl<Condemn> {
this.expansionSetCode = "10E"; this.expansionSetCode = "10E";
this.color.setWhite(true); this.color.setWhite(true);
this.getSpellAbility().addTarget(new TargetAttackingCreature()); this.getSpellAbility().addTarget(new TargetAttackingCreature());
this.getSpellAbility().addEffect(new PutOnLibraryTargetEffect(false));
this.getSpellAbility().addEffect(new CondemnEffect()); this.getSpellAbility().addEffect(new CondemnEffect());
this.getSpellAbility().addEffect(new PutOnLibraryTargetEffect(false));
} }

View file

@ -110,10 +110,10 @@ class PacifismEffect extends ReplacementEffectImpl<PacifismEffect> {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
Permanent enchantment = game.getPermanent(source.getSourceId()); if (event.getType() == EventType.DECLARE_ATTACKER || event.getType() == EventType.DECLARE_BLOCKER) {
if (enchantment != null && enchantment.getAttachedTo() != null) { Permanent enchantment = game.getPermanent(source.getSourceId());
if (source.getSourceId().equals(enchantment.getAttachedTo())) { if (enchantment != null && enchantment.getAttachedTo() != null) {
if (event.getType() == EventType.DECLARE_ATTACKER || event.getType() == EventType.DECLARE_BLOCKER) { if (event.getSourceId().equals(enchantment.getAttachedTo())) {
return true; return true;
} }
} }

View file

@ -50,6 +50,7 @@ import mage.target.Targets;
public interface Ability extends Serializable { public interface Ability extends Serializable {
public UUID getId(); public UUID getId();
public void newId();
public AbilityType getAbilityType(); public AbilityType getAbilityType();
public UUID getControllerId(); public UUID getControllerId();
public UUID getSourceId(); public UUID getSourceId();

View file

@ -116,6 +116,11 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
return id; return id;
} }
@Override
public void newId() {
this.id = UUID.randomUUID();
}
@Override @Override
public AbilityType getAbilityType() { public AbilityType getAbilityType() {
return this.abilityType; return this.abilityType;

View file

@ -382,32 +382,24 @@ public class ContinuousEffects implements Serializable {
public void addEffect(ContinuousEffect effect, Ability source) { public void addEffect(ContinuousEffect effect, Ability source) {
switch (effect.getEffectType()) { switch (effect.getEffectType()) {
case REPLACEMENT: case REPLACEMENT:
ReplacementEffect newReplacementEffect = (ReplacementEffect)effect.copy(); ReplacementEffect newReplacementEffect = (ReplacementEffect)effect;
newReplacementEffect.setTimestamp();
newReplacementEffect.newId();
replacementEffects.add(newReplacementEffect); replacementEffects.add(newReplacementEffect);
abilityMap.put(newReplacementEffect.getId(), source.copy()); abilityMap.put(newReplacementEffect.getId(), source);
break; break;
case PREVENTION: case PREVENTION:
PreventionEffect newPreventionEffect = (PreventionEffect)effect.copy(); PreventionEffect newPreventionEffect = (PreventionEffect)effect;
newPreventionEffect.setTimestamp();
newPreventionEffect.newId();
preventionEffects.add(newPreventionEffect); preventionEffects.add(newPreventionEffect);
abilityMap.put(newPreventionEffect.getId(), source.copy()); abilityMap.put(newPreventionEffect.getId(), source);
break; break;
case ASTHOUGH: case ASTHOUGH:
AsThoughEffect newAsThoughEffect = (AsThoughEffect)effect.copy(); AsThoughEffect newAsThoughEffect = (AsThoughEffect)effect;
newAsThoughEffect.setTimestamp();
newAsThoughEffect.newId();
asThoughEffects.add(newAsThoughEffect); asThoughEffects.add(newAsThoughEffect);
abilityMap.put(newAsThoughEffect.getId(), source.copy()); abilityMap.put(newAsThoughEffect.getId(), source);
break; break;
default: default:
ContinuousEffect newEffect = (ContinuousEffect)effect.copy(); ContinuousEffect newEffect = (ContinuousEffect)effect;
newEffect.setTimestamp();
newEffect.newId();
layeredEffects.add(newEffect); layeredEffects.add(newEffect);
abilityMap.put(newEffect.getId(), source.copy()); abilityMap.put(newEffect.getId(), source);
break; break;
} }
} }

View file

@ -62,7 +62,7 @@ public class CreateDelayedTriggeredAbilityEffect extends OneShotEffect<CreateDel
delayedAbility.setSourceId(source.getSourceId()); delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId()); delayedAbility.setControllerId(source.getControllerId());
delayedAbility.getTargets().addAll(source.getTargets()); delayedAbility.getTargets().addAll(source.getTargets());
game.getState().addDelayedTriggeredAbility(delayedAbility); game.addDelayedTriggeredAbility(delayedAbility);
return true; return true;
} }

View file

@ -33,7 +33,6 @@ import mage.abilities.Ability;
import mage.abilities.effects.PreventionEffectImpl; import mage.abilities.effects.PreventionEffectImpl;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
/** /**
* *
@ -73,7 +72,7 @@ public class PreventAllDamageSourceEffect extends PreventionEffectImpl<PreventAl
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (super.applies(event, source, game)) { if (super.applies(event, source, game)) {
if (event.getTargetId().equals(source.getId())) { if (event.getTargetId().equals(source.getSourceId())) {
return true; return true;
} }
} }

View file

@ -35,7 +35,7 @@ package mage.filter.common;
public class FilterAttackingCreature extends FilterCreaturePermanent<FilterAttackingCreature> { public class FilterAttackingCreature extends FilterCreaturePermanent<FilterAttackingCreature> {
public FilterAttackingCreature() { public FilterAttackingCreature() {
this(""); this("attacking creature");
} }
public FilterAttackingCreature(String name) { public FilterAttackingCreature(String name) {

View file

@ -41,6 +41,7 @@ import mage.Constants.Zone;
import mage.MageItem; import mage.MageItem;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.ActivatedAbility; import mage.abilities.ActivatedAbility;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.TriggeredAbilities; import mage.abilities.TriggeredAbilities;
import mage.abilities.TriggeredAbility; import mage.abilities.TriggeredAbility;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
@ -138,6 +139,7 @@ public interface Game extends MageItem, Serializable {
public void emptyManaPools(); public void emptyManaPools();
public void addEffect(ContinuousEffect continuousEffect, Ability source); public void addEffect(ContinuousEffect continuousEffect, Ability source);
public void addTriggeredAbility(TriggeredAbility ability); public void addTriggeredAbility(TriggeredAbility ability);
public void addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility);
public void applyEffects(); public void applyEffects();
public boolean checkStateAndTriggered(); public boolean checkStateAndTriggered();
public void playPriority(UUID activePlayerId); public void playPriority(UUID activePlayerId);

View file

@ -49,6 +49,7 @@ import mage.Constants.Zone;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.ActivatedAbility; import mage.abilities.ActivatedAbility;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.TriggeredAbilities; import mage.abilities.TriggeredAbilities;
import mage.abilities.TriggeredAbility; import mage.abilities.TriggeredAbility;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
@ -503,15 +504,28 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
@Override @Override
public void addEffect(ContinuousEffect continuousEffect, Ability source) { public void addEffect(ContinuousEffect continuousEffect, Ability source) {
continuousEffect.init(source, this); ContinuousEffect newEffect = (ContinuousEffect)continuousEffect.copy();
state.addEffect(continuousEffect, source); Ability newAbility = source.copy();
newEffect.newId();
newEffect.setTimestamp();
newEffect.init(newAbility, this);
state.addEffect(newEffect, newAbility);
} }
@Override @Override
public void addTriggeredAbility(TriggeredAbility ability) { public void addTriggeredAbility(TriggeredAbility ability) {
state.addTriggeredAbility((TriggeredAbility) ability.copy()); TriggeredAbility newAbility = (TriggeredAbility) ability.copy();
newAbility.newId();
state.addTriggeredAbility(newAbility);
} }
@Override
public void addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility) {
DelayedTriggeredAbility newAbility = (DelayedTriggeredAbility) delayedAbility.copy();
newAbility.newId();
state.addDelayedTriggeredAbility(newAbility);
}
@Override @Override
public boolean checkStateAndTriggered() { public boolean checkStateAndTriggered() {
boolean somethingHappened = false; boolean somethingHappened = false;

View file

@ -287,4 +287,9 @@ public class StackAbility implements StackObject, Ability {
return true; return true;
} }
@Override
public void newId() {
throw new UnsupportedOperationException("Not supported yet.");
}
} }

View file

@ -415,6 +415,7 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
//20091005 - 602.2a //20091005 - 602.2a
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATE_ABILITY, ability.getSourceId(), ability.getId(), playerId))) { if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATE_ABILITY, ability.getSourceId(), ability.getId(), playerId))) {
game.bookmarkState(); game.bookmarkState();
ability.newId();
game.getStack().push(new StackAbility(ability, playerId)); game.getStack().push(new StackAbility(ability, playerId));
String message = ability.getActivatedMessage(game); String message = ability.getActivatedMessage(game);
if (ability.activate(game, false)) { if (ability.activate(game, false)) {

View file

@ -28,7 +28,6 @@
package mage.target.common; package mage.target.common;
import mage.Constants.TargetController;
import mage.filter.common.FilterAttackingCreature; import mage.filter.common.FilterAttackingCreature;
/** /**