1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-03-31 17:00:10 -09:00

Some minor changes.

This commit is contained in:
LevelX2 2015-09-16 15:45:38 +02:00
parent 3c743e781a
commit 391b766b6e
4 changed files with 80 additions and 34 deletions
Mage.Sets/src/mage/sets/riseoftheeldrazi
Mage.Tests/src/test/java/org/mage/test/cards/triggers
Mage/src/mage/game

View file

@ -36,7 +36,6 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.abilities.keyword.AnnihilatorAbility;
import mage.abilities.keyword.IndestructibleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
@ -45,7 +44,6 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.target.TargetPermanent;
@ -131,23 +129,10 @@ class UlamogTheInfiniteGyreEnterGraveyardEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
UUID ownerId = null;
Card card = game.getCard(source.getSourceId());
if (card != null) {
ownerId = card.getOwnerId();
}
if (ownerId == null) {
Permanent permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
if (permanent != null) {
ownerId = permanent.getOwnerId();
}
}
Player player = game.getPlayer(ownerId);
if (player != null) {
for (Card cardToMove : player.getGraveyard().getCards(game)) {
cardToMove.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true);
}
player.shuffleLibrary(game);
Player owner = game.getPlayer(game.getOwnerId(source.getSourceId()));
if (owner != null) {
owner.moveCards(owner.getGraveyard(), null, Zone.LIBRARY, source, game);
owner.shuffleLibrary(game);
return true;
}
return false;

View file

@ -36,7 +36,6 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
*
* @author LevelX2
*/
public class ReturnToHandEffectsTest extends CardTestPlayerBase {
/**
@ -49,24 +48,59 @@ public class ReturnToHandEffectsTest extends CardTestPlayerBase {
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
// Play with your hand revealed.
// If you would draw a card, reveal the top card of your library instead. If it's a creature card, put it into your graveyard. Otherwise, draw a card.
// Whenever a creature is put into your graveyard from the battlefield, return it to your hand.
// Whenever a creature is put into your graveyard from the battlefield, return it to your hand.
addCard(Zone.BATTLEFIELD, playerA, "Enduring Renewal");
// {T}, Sacrifice an artifact: Target player puts the top three cards of his or her library into his or her graveyard.
// Whenever an artifact enters the battlefield, you may untap Grinding Station.
// Whenever an artifact enters the battlefield, you may untap Grinding Station.
addCard(Zone.BATTLEFIELD, playerA, "Grinding Station", 1);
addCard(Zone.BATTLEFIELD, playerA, "Ornithopter", 1);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}, Sacrifice an artifact", playerB);
// addTarget(playerA, "Ornithopter");
// addTarget(playerA, "Ornithopter");
setChoice(playerA, "Ornithopter");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerB, 3);
assertGraveyardCount(playerB, 3);
assertHandCount(playerA, "Ornithopter", 1);
}
@Test
public void testStormfrontRidersTriggerForToken() {
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 2);
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 5);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 1);
// Flying
// When Stormfront Riders enters the battlefield, return two creatures you control to their owner's hand.
// Whenever Stormfront Riders or another creature is returned to your hand from the battlefield, put a 1/1 white Soldier creature token onto the battlefield.
addCard(Zone.HAND, playerA, "Stormfront Riders"); // {4}{W}
// Buyback {4} (You may pay an additional {4} as you cast this spell. If you do, put this card into your hand as it resolves.)
// Put a 1/1 black Rat creature token onto the battlefield.
addCard(Zone.HAND, playerA, "Lab Rats"); // {B}
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
addCard(Zone.HAND, playerB, "Boomerang", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Stormfront Riders");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lab Rats");
setChoice(playerA, "No");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Boomerang", "Rat");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPermanentCount(playerA, "Stormfront Riders", 1);
assertPermanentCount(playerA, "Rat", 0);
assertHandCount(playerA, "Silvercoat Lion", 2);
assertGraveyardCount(playerA, "Lab Rats", 1);
assertGraveyardCount(playerB, "Boomerang", 1);
assertPermanentCount(playerA, "Soldier", 3);
}
}

View file

@ -107,6 +107,10 @@ public interface Game extends MageItem, Serializable {
UUID getControllerId(UUID objectId);
UUID getOwnerId(UUID objectId);
UUID getOwnerId(MageObject object);
Permanent getPermanent(UUID permanentId);
Permanent getPermanentOrLKIBattlefield(UUID permanentId);

View file

@ -347,12 +347,12 @@ public abstract class GameImpl implements Game, Serializable {
MageObject object;
if (state.getBattlefield().containsPermanent(objectId)) {
object = state.getBattlefield().getPermanent(objectId);
state.setZone(objectId, Zone.BATTLEFIELD);
state.setZone(objectId, Zone.BATTLEFIELD); // why is this neccessary?
return object;
}
for (StackObject item : state.getStack()) {
if (item.getId().equals(objectId)) {
state.setZone(objectId, Zone.STACK);
state.setZone(objectId, Zone.STACK); // why is this neccessary?
return item;
}
if (item.getSourceId().equals(objectId) && item instanceof Spell) {
@ -361,7 +361,7 @@ public abstract class GameImpl implements Game, Serializable {
}
for (CommandObject commandObject : state.getCommand()) {
if (commandObject instanceof Commander && commandObject.getId().equals(objectId)) {
if (commandObject.getId().equals(objectId)) {
return commandObject;
}
}
@ -369,11 +369,11 @@ public abstract class GameImpl implements Game, Serializable {
object = getCard(objectId);
if (object == null) {
for (CommandObject commandObject : state.getCommand()) {
if (commandObject.getId().equals(objectId)) {
return commandObject;
}
}
// for (CommandObject commandObject : state.getCommand()) {
// if (commandObject.getId().equals(objectId)) {
// return commandObject;
// }
// }
// can be an ability of a sacrificed Token trying to get it's source object
object = getLastKnownInformation(objectId, Zone.BATTLEFIELD);
}
@ -431,6 +431,29 @@ public abstract class GameImpl implements Game, Serializable {
return null;
}
@Override
public UUID getOwnerId(UUID objectId) {
return getOwnerId(getObject(objectId));
}
@Override
public UUID getOwnerId(MageObject object) {
if (object instanceof Card) {
return ((Card) object).getOwnerId();
}
if (object instanceof Spell) {
return ((Spell) object).getOwnerId();
}
if (object instanceof StackObject) {
// maybe this is not correct in all cases?
return ((StackObject) object).getControllerId();
}
if (object instanceof CommandObject) {
return ((CommandObject) object).getControllerId();
}
return null;
}
@Override
public UUID getControllerId(UUID objectId) {
if (objectId == null) {