This commit is contained in:
BetaSteward 2012-03-03 23:20:47 -05:00
parent db02ea3aa6
commit 5525cd24f9
7 changed files with 550 additions and 0 deletions

1
.gitignore vendored
View file

@ -56,3 +56,4 @@ Mage.Server.Plugins/Mage.Draft.8PlayerBooster/target
\.conflict\~$
/Mage.Server.Plugins/Mage.Player.AIMCTS/target/
/Mage.Server.Console/target/
*.classpath

View file

@ -0,0 +1,166 @@
/*
* 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.sets.darkascension;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.WatcherScope;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.TapTargetEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.target.common.TargetCreaturePermanent;
import mage.watchers.Watcher;
import mage.watchers.WatcherImpl;
/**
*
* @author BetaSteward
*/
public class DungeonGeists extends CardImpl<DungeonGeists> {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature an opponent controls");
static {
filter.setTargetController(Constants.TargetController.OPPONENT);
}
public DungeonGeists(UUID ownerId) {
super(ownerId, 36, "Dungeon Geists", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{U}{U}");
this.expansionSetCode = "DKA";
this.subtype.add("Spirit");
this.color.setBlue(true);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
this.addAbility(FlyingAbility.getInstance());
// When Dungeon Geists enters the battlefield, tap target creature an opponent controls. That creature doesn't untap during its controller's untap step for as long as you control Dungeon Geists.
Ability ability = new EntersBattlefieldTriggeredAbility(new TapTargetEffect(), true);
ability.addEffect(new DungeonGeistsEffect());
ability.addTarget(new TargetCreaturePermanent(filter));
this.addAbility(ability);
this.addWatcher(new DungeonGeistsWatcher());
}
public DungeonGeists(final DungeonGeists card) {
super(card);
}
@Override
public DungeonGeists copy() {
return new DungeonGeists(this);
}
}
class DungeonGeistsEffect extends ReplacementEffectImpl<DungeonGeistsEffect> {
public DungeonGeistsEffect() {
super(Constants.Duration.OneUse, Constants.Outcome.Detriment);
this.staticText = "That creature doesn't untap during its controller's untap step for as long as you control Dungeon Geists";
}
public DungeonGeistsEffect(final DungeonGeistsEffect effect) {
super(effect);
}
@Override
public DungeonGeistsEffect copy() {
return new DungeonGeistsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
//don't replace untap event if control of this has been lost
Watcher watcher = game.getState().getWatchers().get("ControlLost", source.getSourceId());
if (watcher == null || !watcher.conditionMet()) {
if (game.getTurn().getStepType() == Constants.PhaseStep.UNTAP && event.getType() == GameEvent.EventType.UNTAP) {
if (event.getTargetId().equals(targetPointer.getFirst(source))) {
return true;
}
}
}
return false;
}
}
class DungeonGeistsWatcher extends WatcherImpl<DungeonGeistsWatcher> {
DungeonGeistsWatcher () {
super("ControlLost", WatcherScope.CARD);
}
DungeonGeistsWatcher(DungeonGeistsWatcher watcher) {
super(watcher);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.LOST_CONTROL && event.getPlayerId().equals(controllerId) && event.getTargetId().equals(sourceId)) {
condition = true;
return;
}
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(sourceId)) {
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
condition = false;
}
}
}
@Override
public void reset() {
//don't reset condition each turn - only when this leaves the battlefield
}
@Override
public DungeonGeistsWatcher copy() {
return new DungeonGeistsWatcher(this);
}
}

View file

@ -0,0 +1,74 @@
/*
* 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.sets.darkascension;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continious.ControlEnchantedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author BetaSteward
*/
public class GhastlyHaunting extends CardImpl<GhastlyHaunting> {
public GhastlyHaunting(UUID ownerId) {
super(ownerId, 50, "Ghastly Haunting", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "");
this.expansionSetCode = "DKA";
this.subtype.add("Aura");
// this card is the second face of double-faced card
this.nightCard = true;
this.canTransform = true;
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
// You control enchanted creature.
this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new ControlEnchantedEffect()));
}
public GhastlyHaunting(final GhastlyHaunting card) {
super(card);
}
@Override
public GhastlyHaunting copy() {
return new GhastlyHaunting(this);
}
}

View file

@ -0,0 +1,161 @@
/*
* 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.sets.darkascension;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.condition.common.NoSpellsWereCastLastTurnCondition;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.TransformSourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.TransformAbility;
import mage.cards.CardImpl;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author BetaSteward
*/
public class SoulSeizer extends CardImpl<SoulSeizer> {
public SoulSeizer(UUID ownerId) {
super(ownerId, 50, "Soul Seizer", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{3}{U}{U}");
this.expansionSetCode = "DKA";
this.subtype.add("Spirit");
this.canTransform = true;
this.secondSideCard = new GhastlyHaunting(ownerId);
this.color.setBlue(true);
this.power = new MageInt(1);
this.toughness = new MageInt(3);
this.addAbility(FlyingAbility.getInstance());
// When Soul Seizer deals combat damage to a player, you may transform it. If you do, attach it to target creature that player controls.
this.addAbility(new TransformAbility());
this.addAbility(new SoulSeizerTriggeredAbility());
}
public SoulSeizer(final SoulSeizer card) {
super(card);
}
@Override
public SoulSeizer copy() {
return new SoulSeizer(this);
}
}
class SoulSeizerTriggeredAbility extends TriggeredAbilityImpl<SoulSeizerTriggeredAbility> {
public SoulSeizerTriggeredAbility() {
super(Constants.Zone.BATTLEFIELD, new SoulSeizerEffect(), true);
}
public SoulSeizerTriggeredAbility(SoulSeizerTriggeredAbility ability) {
super(ability);
}
@Override
public SoulSeizerTriggeredAbility copy() {
return new SoulSeizerTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event instanceof DamagedPlayerEvent) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event;
if (damageEvent.isCombatDamage() && event.getSourceId().equals(this.getSourceId())) {
Player opponent = game.getPlayer(event.getPlayerId());
if (opponent != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + opponent.getName() + " controls");
filter.getControllerId().add(opponent.getId());
this.getTargets().clear();
this.addTarget(new TargetCreaturePermanent(filter));
return true;
}
}
}
return false;
}
@Override
public String getRule() {
return "When {this} deals combat damage to a player, you may transform it. If you do, attach it to target creature that player controls";
}
}
class SoulSeizerEffect extends OneShotEffect<SoulSeizerEffect> {
public SoulSeizerEffect() {
super(Outcome.GainControl);
}
public SoulSeizerEffect(final SoulSeizerEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && permanent.canTransform()) {
if (permanent.transform(game)) {
Permanent attachTo = game.getPermanent(targetPointer.getFirst(source));
if (attachTo != null) {
return attachTo.addAttachment(source.getSourceId(), game);
}
}
}
return false;
}
@Override
public SoulSeizerEffect copy() {
return new SoulSeizerEffect(this);
}
}

View file

@ -5,6 +5,7 @@
<playerTypes>
<playerType name="Computer - minimax hybrid" jar="mage-player-aiminimax.jar" className="mage.player.ai.ComputerPlayer3"/>
<playerType name="Computer - mad" jar="mage-player-ai-ma.jar" className="mage.player.ai.ComputerPlayer7"/>
<playerType name="Computer - monte carlo" jar="mage-player-aimcts.jar" className="mage.player.ai.ComputerPlayerMCTS"/>
</playerTypes>
<gameTypes>
<gameType name="Two Player Duel" jar="mage-game-twoplayerduel.jar" className="mage.game.TwoPlayerMatch" typeName="mage.game.TwoPlayerDuelType"/>

View file

@ -0,0 +1,73 @@
package org.mage.test.cards;
import mage.Constants;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author BetaSteward
*/
public class TestDungeonGeists extends CardTestPlayerBase {
@Test
public void testCard() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 4);
addCard(Constants.Zone.HAND, playerA, "Dungeon Geists");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Craw Wurm");
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Dungeon Geists");
setStopAt(2, Constants.PhaseStep.DRAW);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Dungeon Geists", 1);
assertPermanentCount(playerB, "Craw Wurm", 1);
assertTapped("Dungeon Geists", false);
assertTapped("Craw Wurm", true);
}
@Test
public void testCard1() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 4);
addCard(Constants.Zone.HAND, playerA, "Dungeon Geists");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Craw Wurm");
addCard(Constants.Zone.HAND, playerB, "Act of Treason");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Mountain", 3);
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Dungeon Geists");
castSpell(2, Constants.PhaseStep.PRECOMBAT_MAIN, playerB, "Act of Treason", "Dungeon Geists");
setStopAt(4, Constants.PhaseStep.DRAW);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Dungeon Geists", 1);
assertPermanentCount(playerB, "Craw Wurm", 1);
assertTapped("Dungeon Geists", false);
assertTapped("Craw Wurm", false);
}
@Test
public void testCard2() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Island", 9);
addCard(Constants.Zone.HAND, playerA, "Dungeon Geists");
addCard(Constants.Zone.HAND, playerA, "Mind Control");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Craw Wurm");
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Dungeon Geists");
castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Mind Control", "Craw Wurm");
setStopAt(3, Constants.PhaseStep.DRAW);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertPermanentCount(playerA, "Dungeon Geists", 1);
assertPermanentCount(playerA, "Craw Wurm", 1);
assertTapped("Dungeon Geists", false);
assertTapped("Craw Wurm", true);
}
}

View file

@ -0,0 +1,74 @@
package org.mage.test.cards;
import mage.Constants;
import mage.counters.CounterType;
import mage.filter.Filter;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author BetaSteward
*/
public class TestSoulSeizer extends CardTestPlayerBase {
@Test
public void testCard() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Soul Seizer");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Craw Wurm");
attack(1, playerA, "Soul Seizer");
setStopAt(1, Constants.PhaseStep.END_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 19);
assertPermanentCount(playerA, "Ghastly Haunting", 1);
assertPermanentCount(playerA, "Soul Seizer", 0);
assertPermanentCount(playerA, "Craw Wurm", 1);
}
@Test
public void testCard1() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Soul Seizer");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Craw Wurm");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Plains", 2);
addCard(Constants.Zone.HAND, playerB, "Clear");
attack(1, playerA, "Soul Seizer");
castSpell(2, Constants.PhaseStep.PRECOMBAT_MAIN, playerB, "Clear", "Ghastly Haunting");
setStopAt(2, Constants.PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 19);
assertPermanentCount(playerA, "Ghastly Haunting", 0);
assertPermanentCount(playerA, "Soul Seizer", 0);
assertGraveyardCount(playerA, 1);
assertPermanentCount(playerB, "Craw Wurm", 1);
}
@Test
public void testCard2() {
addCard(Constants.Zone.BATTLEFIELD, playerA, "Soul Seizer");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Forest", 2);
addCard(Constants.Zone.HAND, playerA, "Battlegrowth");
addCard(Constants.Zone.BATTLEFIELD, playerB, "Craw Wurm");
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Battlegrowth", "Soul Seizer");
attack(1, playerA, "Soul Seizer");
setStopAt(1, Constants.PhaseStep.END_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 18);
assertPermanentCount(playerA, "Ghastly Haunting", 1);
assertCounterCount("Ghastly Haunting", CounterType.P1P1, 1);
assertPermanentCount(playerA, "Soul Seizer", 0);
assertGraveyardCount(playerA, 1);
assertPermanentCount(playerA, "Craw Wurm", 1);
assertPowerToughness(playerA, "Craw Wurm", 6, 4, Filter.ComparisonScope.All);
}
}