mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
Added Celestial Dawn.
This commit is contained in:
parent
9072fb95d7
commit
f4a643437b
11 changed files with 513 additions and 53 deletions
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* 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
|
||||
|
|
@ -20,18 +20,19 @@
|
|||
* 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.effects;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.ManaType;
|
||||
import mage.game.Game;
|
||||
import mage.players.ManaPoolItem;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -40,7 +41,11 @@ import mage.game.Game;
|
|||
public interface AsThoughEffect extends ContinuousEffect {
|
||||
|
||||
boolean applies(UUID sourceId, Ability affectedAbility, Ability source, Game game);
|
||||
|
||||
boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game);
|
||||
|
||||
boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game, ManaType manaType, ManaPoolItem mana);
|
||||
|
||||
AsThoughEffectType getAsThoughEffectType();
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* 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
|
||||
|
|
@ -20,12 +20,11 @@
|
|||
* 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.effects;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -33,8 +32,10 @@ import mage.abilities.Ability;
|
|||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.EffectType;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.ManaPoolItem;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -54,12 +55,17 @@ public abstract class AsThoughEffectImpl extends ContinuousEffectImpl implements
|
|||
super(effect);
|
||||
this.type = effect.type;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game) {
|
||||
return applies(objectId, source, affectedAbility.getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game, ManaType manaType, ManaPoolItem mana) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsThoughEffectType getAsThoughEffectType() {
|
||||
return type;
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ import mage.constants.CostModificationType;
|
|||
import mage.constants.Duration;
|
||||
import mage.constants.EffectType;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.ManaType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.SubLayer;
|
||||
|
|
@ -70,6 +71,7 @@ import mage.game.events.ZoneChangeEvent;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.PermanentCard;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.ManaPoolItem;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
import org.apache.log4j.Logger;
|
||||
|
|
@ -546,6 +548,26 @@ public class ContinuousEffects implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
public boolean asThoughMana(UUID objectId, AsThoughEffectType type, Ability affectedAbility, UUID controllerId, Game game, ManaType manaType, ManaPoolItem mana) {
|
||||
List<AsThoughEffect> asThoughEffectsList = getApplicableAsThoughEffects(type, game);
|
||||
for (AsThoughEffect effect : asThoughEffectsList) {
|
||||
HashSet<Ability> abilities = asThoughEffectsMap.get(type).getAbility(effect.getId());
|
||||
for (Ability ability : abilities) {
|
||||
if (affectedAbility == null) {
|
||||
if (effect.applies(objectId, ability, controllerId, game)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (effect.applies(objectId, affectedAbility, ability, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters out asThough effects that are not active.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -5,12 +5,13 @@ package mage.constants;
|
|||
* @author North
|
||||
*/
|
||||
public enum AsThoughEffectType {
|
||||
|
||||
ATTACK,
|
||||
ACTIVATE_HASTE,
|
||||
BLOCK_TAPPED,
|
||||
BLOCK_SHADOW,
|
||||
BLOCK_DRAGON,
|
||||
BE_BLOCKED,
|
||||
BE_BLOCKED,
|
||||
PLAY_FROM_NOT_OWN_HAND_ZONE,
|
||||
CAST_AS_INSTANT,
|
||||
ACTIVATE_AS_INSTANT,
|
||||
|
|
@ -19,5 +20,6 @@ public enum AsThoughEffectType {
|
|||
PAY,
|
||||
LOOK_AT_FACE_DOWN,
|
||||
SPEND_ANY_MANA,
|
||||
SPEND_COLORLESS_MANA,
|
||||
TARGET
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,6 +65,13 @@ public class ManaPool implements Serializable {
|
|||
|
||||
private final Set<ManaType> doNotEmptyManaTypes = new HashSet<>();
|
||||
|
||||
private enum SpendType {
|
||||
|
||||
NORMAL,
|
||||
ANY,
|
||||
COLORLESS
|
||||
}
|
||||
|
||||
public ManaPool(UUID playerId) {
|
||||
this.playerId = playerId;
|
||||
autoPayment = true;
|
||||
|
|
@ -138,29 +145,37 @@ public class ManaPool implements Serializable {
|
|||
// no mana added beyond the stock so don't auto pay this
|
||||
continue;
|
||||
}
|
||||
boolean spendAnyMana = spendAnyMana(ability, game);
|
||||
if (mana.get(manaType) > 0 || (spendAnyMana && mana.count() > 0)) {
|
||||
GameEvent event = new GameEvent(GameEvent.EventType.MANA_PAYED, ability.getId(), mana.getSourceId(), ability.getControllerId(), 0, mana.getFlag());
|
||||
event.setData(mana.getOriginalId().toString());
|
||||
game.fireEvent(event);
|
||||
if (spendAnyMana) {
|
||||
mana.removeAny();
|
||||
} else {
|
||||
mana.remove(manaType);
|
||||
SpendType spendType = getSpendType(ability, game, manaType, mana);
|
||||
if (!SpendType.COLORLESS.equals(spendType) || ManaType.COLORLESS.equals(manaType)) {
|
||||
if (mana.get(manaType) > 0 || (spendType.equals(SpendType.ANY) && mana.count() > 0)) {
|
||||
GameEvent event = new GameEvent(GameEvent.EventType.MANA_PAYED, ability.getId(), mana.getSourceId(), ability.getControllerId(), 0, mana.getFlag());
|
||||
event.setData(mana.getOriginalId().toString());
|
||||
game.fireEvent(event);
|
||||
if (!SpendType.NORMAL.equals(spendType)) {
|
||||
mana.removeAny();
|
||||
} else {
|
||||
mana.remove(manaType);
|
||||
}
|
||||
if (mana.count() == 0) { // so no items with count 0 stay in list
|
||||
manaItems.remove(mana);
|
||||
}
|
||||
lockManaType(); // pay only one mana if mana payment is set to manually
|
||||
return true;
|
||||
}
|
||||
if (mana.count() == 0) { // so no items with count 0 stay in list
|
||||
manaItems.remove(mana);
|
||||
}
|
||||
lockManaType(); // pay only one mana if mana payment is set to manually
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// check if any mana can be spend to cast the mana cost of an ability
|
||||
private boolean spendAnyMana(Ability ability, Game game) {
|
||||
return game.getContinuousEffects().asThough(ability.getSourceId(), AsThoughEffectType.SPEND_ANY_MANA, ability, ability.getControllerId(), game);
|
||||
private SpendType getSpendType(Ability ability, Game game, ManaType manaType, ManaPoolItem mana) {
|
||||
if (game.getContinuousEffects().asThoughMana(ability.getSourceId(), AsThoughEffectType.SPEND_ANY_MANA, ability, ability.getControllerId(), game, manaType, mana)) {
|
||||
return SpendType.ANY;
|
||||
}
|
||||
if (game.getContinuousEffects().asThoughMana(ability.getSourceId(), AsThoughEffectType.SPEND_COLORLESS_MANA, ability, ability.getControllerId(), game, manaType, mana)) {
|
||||
return SpendType.COLORLESS;
|
||||
}
|
||||
return SpendType.NORMAL;
|
||||
}
|
||||
|
||||
public int get(ManaType manaType) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue