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", "");
int port = Integer.parseInt(prefs.get("serverPort", ""));
try {
server = "192.168.121.201";
setCursor(new Cursor(Cursor.WAIT_CURSOR));
if (MageFrame.connect(userName, server, port)) {
return true;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -287,4 +287,9 @@ public class StackAbility implements StackObject, Ability {
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
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.ACTIVATE_ABILITY, ability.getSourceId(), ability.getId(), playerId))) {
game.bookmarkState();
ability.newId();
game.getStack().push(new StackAbility(ability, playerId));
String message = ability.getActivatedMessage(game);
if (ability.activate(game, false)) {

View file

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