mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Added AtTheBeginningOfNextUpkeepDelayedTriggeredAbility, fixed ability picker giving not always text back for spell ability.
This commit is contained in:
parent
859f068e59
commit
77ac99b03f
8 changed files with 135 additions and 54 deletions
|
@ -49,7 +49,11 @@ public class AbilityPickerView implements Serializable {
|
|||
if (objectName == null) {
|
||||
choices.put(ability.getId(), ability.getRule(true));
|
||||
} else {
|
||||
choices.put(ability.getId(), ability.getRule(objectName));
|
||||
String rule = ability.getRule(objectName);
|
||||
if (rule.isEmpty()) {
|
||||
rule = ability.toString();
|
||||
}
|
||||
choices.put(ability.getId(), rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.cards.Card;
|
||||
import mage.counters.Counter;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentToken;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
package mage.abilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -44,15 +45,14 @@ import mage.game.Game;
|
|||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @param <T>
|
||||
*/
|
||||
public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Abilities<T> {
|
||||
|
||||
public AbilitiesImpl() {}
|
||||
|
||||
public AbilitiesImpl(T... abilities) {
|
||||
for (T ability : abilities) {
|
||||
add(ability);
|
||||
}
|
||||
addAll(Arrays.asList(abilities));
|
||||
}
|
||||
|
||||
public AbilitiesImpl(final AbilitiesImpl<T> abilities) {
|
||||
|
@ -244,7 +244,7 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
|||
if (ability.getOriginalId().equals(test.getId())) {
|
||||
return true;
|
||||
}
|
||||
if (ability instanceof MageSingleton && ability.getRule().equals(test.getRule())) {
|
||||
if (ability instanceof MageSingleton && test instanceof MageSingleton && ability.getRule().equals(test.getRule())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ public class SpellAbility extends ActivatedAbilityImpl<SpellAbility> {
|
|||
@Override
|
||||
public String getRule(boolean all) {
|
||||
if (all) {
|
||||
return super.getRule(all) + name;
|
||||
return new StringBuilder(super.getRule(all)).append(name).toString();
|
||||
}
|
||||
return super.getRule(false);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.abilities.common.delayed;
|
||||
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Duration;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class AtTheBeginOfNextUpkeepDelayedTriggeredAbility extends DelayedTriggeredAbility<AtTheBeginOfNextUpkeepDelayedTriggeredAbility> {
|
||||
|
||||
public AtTheBeginOfNextUpkeepDelayedTriggeredAbility(Effect effect) {
|
||||
this(effect, Duration.Custom);
|
||||
}
|
||||
|
||||
public AtTheBeginOfNextUpkeepDelayedTriggeredAbility(Effect effect, Duration duration) {
|
||||
super(effect, duration);
|
||||
}
|
||||
|
||||
public AtTheBeginOfNextUpkeepDelayedTriggeredAbility(AtTheBeginOfNextUpkeepDelayedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AtTheBeginOfNextUpkeepDelayedTriggeredAbility copy() {
|
||||
return new AtTheBeginOfNextUpkeepDelayedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String text = modes.getText();
|
||||
if (!text.isEmpty()) {
|
||||
sb.append(Character.toUpperCase(text.charAt(0)));
|
||||
if (text.endsWith(".")) {
|
||||
sb.append(text.substring(1, text.length()-1));
|
||||
} else {
|
||||
sb.append(text.substring(1));
|
||||
}
|
||||
}
|
||||
return sb.append(" at the beginning of the next turn's upkeep.").toString();
|
||||
}
|
||||
}
|
|
@ -191,6 +191,7 @@ public interface Game extends MageItem, Serializable {
|
|||
* @param copyToPermanent
|
||||
* @param source
|
||||
* @param applier
|
||||
* @return
|
||||
*/
|
||||
Permanent copyPermanent(Permanent copyFromPermanent, Permanent copyToPermanent, Ability source, ApplyToPermanent applier);
|
||||
|
||||
|
|
|
@ -85,16 +85,22 @@ import mage.watchers.Watchers;
|
|||
*/
|
||||
public class GameState implements Serializable, Copyable<GameState> {
|
||||
|
||||
private Players players;
|
||||
private PlayerList playerList;
|
||||
private final Players players;
|
||||
private final PlayerList playerList;
|
||||
private final Turn turn;
|
||||
private final Revealed revealed;
|
||||
private final Map<UUID, LookedAt> lookedAt = new HashMap<UUID, LookedAt>();
|
||||
private final DelayedTriggeredAbilities delayed;
|
||||
private final SpecialActions specialActions;
|
||||
private final Map<UUID, Abilities<ActivatedAbility>> otherAbilities = new HashMap<UUID, Abilities<ActivatedAbility>>();
|
||||
private final TurnMods turnMods;
|
||||
private final Watchers watchers;
|
||||
|
||||
private UUID activePlayerId;
|
||||
private UUID priorityPlayerId;
|
||||
private Turn turn;
|
||||
private SpellStack stack;
|
||||
private Command command;
|
||||
private Exile exile;
|
||||
private Revealed revealed;
|
||||
private Map<UUID, LookedAt> lookedAt = new HashMap<UUID, LookedAt>();
|
||||
private Battlefield battlefield;
|
||||
private int turnNum = 1;
|
||||
private boolean extraTurn = false;
|
||||
|
@ -104,12 +110,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
private ContinuousEffects effects;
|
||||
private TriggeredAbilities triggers;
|
||||
private List<TriggeredAbility> triggered = new ArrayList<TriggeredAbility>();
|
||||
private DelayedTriggeredAbilities delayed;
|
||||
private SpecialActions specialActions;
|
||||
private Map<UUID, Abilities<ActivatedAbility>> otherAbilities = new HashMap<UUID, Abilities<ActivatedAbility>>();
|
||||
private Combat combat;
|
||||
private TurnMods turnMods;
|
||||
private Watchers watchers;
|
||||
private Map<String, Object> values = new HashMap<String, Object>();
|
||||
private Map<UUID, Zone> zones = new HashMap<UUID, Zone>();
|
||||
|
||||
|
|
|
@ -28,29 +28,49 @@
|
|||
|
||||
package mage.game.permanent;
|
||||
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Zone;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.RestrictionEffect;
|
||||
import mage.abilities.keyword.*;
|
||||
import mage.abilities.keyword.DeathtouchAbility;
|
||||
import mage.abilities.keyword.DefenderAbility;
|
||||
import mage.abilities.keyword.HasteAbility;
|
||||
import mage.abilities.keyword.HexproofAbility;
|
||||
import mage.abilities.keyword.IndestructibleAbility;
|
||||
import mage.abilities.keyword.InfectAbility;
|
||||
import mage.abilities.keyword.LifelinkAbility;
|
||||
import mage.abilities.keyword.ProtectionAbility;
|
||||
import mage.abilities.keyword.ShroudAbility;
|
||||
import mage.abilities.keyword.WitherAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.EffectType;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.Counter;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.*;
|
||||
import mage.game.events.DamageCreatureEvent;
|
||||
import mage.game.events.DamagePlaneswalkerEvent;
|
||||
import mage.game.events.DamagedCreatureEvent;
|
||||
import mage.game.events.DamagedPlaneswalkerEvent;
|
||||
import mage.game.events.EntersTheBattlefieldEvent;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
* @param <T>
|
||||
*/
|
||||
public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl<T> implements Permanent {
|
||||
|
||||
|
@ -154,12 +174,7 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
public void reset(Game game) {
|
||||
this.beforeResetControllerId = this.controllerId;
|
||||
this.controllerId = originalControllerId;
|
||||
if (!controllerId.equals(beforeResetControllerId)) {
|
||||
controllerChanged = true;
|
||||
}
|
||||
else {
|
||||
controllerChanged = false;
|
||||
}
|
||||
controllerChanged = !controllerId.equals(beforeResetControllerId);
|
||||
this.maxBlocks = 1;
|
||||
this.minBlockedBy = 1;
|
||||
this.maxBlockedBy = 0;
|
||||
|
@ -297,11 +312,7 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
|
||||
@Override
|
||||
public boolean canTap() {
|
||||
//20100423 - 302.6
|
||||
if (!cardType.contains(CardType.CREATURE) || !hasSummoningSickness()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return !cardType.contains(CardType.CREATURE) || !hasSummoningSickness();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -572,15 +583,7 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
}
|
||||
}
|
||||
this.attachedTo = permanentId;
|
||||
/*
|
||||
* 20121001 613.6. Within a layer or sublayer, determining which order effects are applied in is
|
||||
* usually done using a timestamp system. An effect with an earlier timestamp is
|
||||
* applied before an effect with a later timestamp
|
||||
* 20121001 613.6d If an Aura, Equipment, or Fortification becomes attached to an object or player,
|
||||
* the Aura, Equipment, or Fortification receives a new timestamp at that time.
|
||||
*/
|
||||
for (Iterator<Ability> it = this.getAbilities().iterator(); it.hasNext();) {
|
||||
Ability ability = it.next();
|
||||
for (Ability ability : this.getAbilities()) {
|
||||
for (Iterator<Effect> ite = ability.getEffects(game, EffectType.CONTINUOUS).iterator(); ite.hasNext();) {
|
||||
ContinuousEffect effect = (ContinuousEffect) ite.next();
|
||||
game.getContinuousEffects().setUniqueTimesstamp(effect);
|
||||
|
@ -866,10 +869,8 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
return false;
|
||||
}
|
||||
}
|
||||
if (abilities.containsKey(DefenderAbility.getInstance().getId()) && !game.getContinuousEffects().asThough(this.objectId, AsThoughEffectType.ATTACK, game)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return !abilities.containsKey(DefenderAbility.getInstance().getId())
|
||||
|| game.getContinuousEffects().asThough(this.objectId, AsThoughEffectType.ATTACK, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -900,11 +901,7 @@ public abstract class PermanentImpl<T extends PermanentImpl<T>> extends CardImpl
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (attacker != null && attacker.hasProtectionFrom(this, game)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return attacker == null || !attacker.hasProtectionFrom(this, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue