Merge pull request #4158 from Zzooouhh/master

Implemented more cards & fix for Grinning Totem
This commit is contained in:
theelk801 2017-11-18 09:52:01 -05:00 committed by GitHub
commit ad249d7c6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
48 changed files with 3299 additions and 18 deletions

View file

@ -49,6 +49,8 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
private UUID onlyIfControlledByPlayer;
private String targetName;
// used for Telekinesis - skips next two untap steps if true
private boolean twoSteps;
// holds the info what target was already handled in Untap of its controller
private final Map<UUID, Boolean> handledTargetsDuringTurn = new HashMap<>();
@ -63,7 +65,7 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
}
public DontUntapInControllersNextUntapStepTargetEffect(String targetName) {
this(targetName, null);
this(targetName, false, null);
}
/**
@ -73,14 +75,20 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
* controlled by that controller, null = it works for all players
*/
public DontUntapInControllersNextUntapStepTargetEffect(String targetName, UUID onlyIfControlledByPlayer) {
this(targetName, false, onlyIfControlledByPlayer);
}
public DontUntapInControllersNextUntapStepTargetEffect(String targetName, boolean twoSteps, UUID onlyIfControlledByPlayer) {
super(Duration.Custom, Outcome.Detriment, false, true);
this.targetName = targetName;
this.twoSteps = twoSteps;
this.onlyIfControlledByPlayer = onlyIfControlledByPlayer;
}
public DontUntapInControllersNextUntapStepTargetEffect(final DontUntapInControllersNextUntapStepTargetEffect effect) {
super(effect);
this.targetName = effect.targetName;
this.twoSteps = effect.twoSteps;
this.handledTargetsDuringTurn.putAll(effect.handledTargetsDuringTurn);
this.onlyIfControlledByPlayer = effect.onlyIfControlledByPlayer;
}
@ -112,7 +120,7 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
// the check if a permanent untap pahse is already handled is needed if multiple effects are added to prevent untap in next untap step of controller
// the check if a permanent untap phase is already handled is needed if multiple effects are added to prevent untap in next untap step of controller
// if we don't check it for every untap step of a turn only one effect would be consumed instead of all be valid for the next untap step
if (event.getType() == EventType.UNTAP_STEP) {
boolean allHandled = true;
@ -127,13 +135,14 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
allHandled = false;
} else if (!handledTargetsDuringTurn.get(targetId)) {
// if it was already ready to be handled on an previous Untap step set it to done if not already so
handledTargetsDuringTurn.put(targetId, true);
handledTargetsDuringTurn.put(targetId, !twoSteps);
}
} else {
allHandled = false;
}
}
}
if (allHandled) {
discard();
}
@ -146,7 +155,7 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && game.getActivePlayerId().equals(permanent.getControllerId())) {
if ((onlyIfControlledByPlayer == null) || game.getActivePlayerId().equals(onlyIfControlledByPlayer)) { // If onlyIfControlledByPlayer is set, then don't apply unless we're currently controlled by the specified player.
handledTargetsDuringTurn.put(event.getTargetId(), true);
handledTargetsDuringTurn.put(event.getTargetId(), !twoSteps);
return true;
}
}
@ -162,11 +171,11 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
}
if (targetName != null && !targetName.isEmpty()) {
if (targetName.equals("Those creatures") || targetName.equals("They")) {
return targetName + " don't untap during their controller's next untap step";
return targetName + " don't untap during their controller's next " + (twoSteps ? "two " : "") + "untap step" + (twoSteps ? "s" : "");
} else
return targetName + " doesn't untap during its controller's next untap step";
return targetName + " doesn't untap during its controller's next " + (twoSteps ? "two " : "") + "untap step" + (twoSteps ? "s" : "");
} else {
return "target " + (mode == null ? "creature" : mode.getTargets().get(0).getTargetName()) + " doesn't untap during its controller's next untap step";
return "target " + (mode == null ? "creature" : mode.getTargets().get(0).getTargetName()) + " doesn't untap during its controller's next " + (twoSteps ? "two " : "") + "untap step" + (twoSteps ? "s" : "");
}
}

View file

@ -72,6 +72,7 @@ public class SacrificeSourceUnlessPaysEffect extends OneShotEffect {
if (costText.toLowerCase().startsWith("discard")
|| costText.toLowerCase().startsWith("remove")
|| costText.toLowerCase().startsWith("return")
|| costText.toLowerCase().startsWith("put")
|| costText.toLowerCase().startsWith("exile")
|| costText.toLowerCase().startsWith("sacrifice")) {
sb.append(costText.substring(0, 1).toLowerCase());

View file

@ -13,7 +13,7 @@ public enum PhaseStep {
PRECOMBAT_MAIN ("Precombat Main", 3,"precombat main step"),
BEGIN_COMBAT ("Begin Combat", 4, "begin combat step"),
DECLARE_ATTACKERS ("Declare Attackers", 5, "declare attackers step"),
DECLARE_BLOCKERS ("Declare Blockers", 6, "declare blockers"),
DECLARE_BLOCKERS ("Declare Blockers", 6, "declare blockers step"),
FIRST_COMBAT_DAMAGE ("First Combat Damage", 7, "first combat damage"),
COMBAT_DAMAGE ("Combat Damage", 8, "combat damage step"),
END_COMBAT ("End Combat", 9, "end combat step"),

View file

@ -0,0 +1,50 @@
/*
* 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.game.permanent.token;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.MageInt;
import mage.abilities.keyword.HasteAbility;
/**
*
* @author L_J
*/
public class TombspawnZombieToken extends Token {
public TombspawnZombieToken() {
super("Tombspawn", "2/2 black Zombie creature token with haste named Tombspawn");
cardType.add(CardType.CREATURE);
subtype.add(SubType.ZOMBIE);
color.setBlack(true);
power = new MageInt(2);
toughness = new MageInt(2);
this.addAbility(HasteAbility.getInstance());
}
}

View file

@ -0,0 +1,100 @@
/*
* 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.watchers.common;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.GameEvent;
import mage.watchers.Watcher;
/**
*
* @author L_J
*/
public class BlockedByOnlyOneCreatureThisCombatWatcher extends Watcher {
private final Map<CombatGroup, UUID> blockedByOneCreature = new HashMap<>();
public BlockedByOnlyOneCreatureThisCombatWatcher() {
super(BlockedByOnlyOneCreatureThisCombatWatcher.class.getSimpleName(), WatcherScope.GAME);
}
public BlockedByOnlyOneCreatureThisCombatWatcher(final BlockedByOnlyOneCreatureThisCombatWatcher watcher) {
super(watcher);
this.blockedByOneCreature.putAll(watcher.blockedByOneCreature);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.BEGIN_COMBAT_STEP_PRE) {
this.blockedByOneCreature.clear();
}
else if (event.getType() == GameEvent.EventType.BLOCKER_DECLARED) {
CombatGroup combatGroup = game.getCombat().findGroup(event.getTargetId());
if (combatGroup != null) {
if (combatGroup.getBlockers().size() == 1) {
if (!blockedByOneCreature.containsKey(combatGroup)) {
blockedByOneCreature.put(combatGroup, event.getSourceId());
}
else if (blockedByOneCreature.get(combatGroup) != event.getSourceId()) {
blockedByOneCreature.put(combatGroup, null);
}
}
else if (combatGroup.getBlockers().size() > 1) {
blockedByOneCreature.put(combatGroup, null);
}
}
}
}
public Set<CombatGroup> getBlockedOnlyByCreature(UUID creature) {
Set<CombatGroup> combatGroups = new HashSet<>();
for (Map.Entry<CombatGroup, UUID> entry : blockedByOneCreature.entrySet()) {
if (entry.getValue() != null) {
if (entry.getValue().equals(creature)) {
combatGroups.add(entry.getKey());
}
}
}
if (combatGroups.size() > 0) {
return combatGroups;
}
return null;
}
@Override
public BlockedByOnlyOneCreatureThisCombatWatcher copy() {
return new BlockedByOnlyOneCreatureThisCombatWatcher(this);
}
}