[C16] Implemented Partner ability.

This commit is contained in:
emerald000 2016-11-01 22:59:39 -04:00
parent dfc72a9adb
commit c38f96ae55
13 changed files with 161 additions and 127 deletions

View file

@ -27,6 +27,8 @@
*/
package mage.cards.c;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -71,28 +73,44 @@ public class CommandBeacon extends CardImpl {
}
class CommandBeaconEffect extends OneShotEffect {
CommandBeaconEffect() {
super(Outcome.ReturnToHand);
this.staticText = "Put your commander into your hand from the command zone";
}
CommandBeaconEffect(final CommandBeaconEffect effect) {
super(effect);
}
@Override
public CommandBeaconEffect copy() {
return new CommandBeaconEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Card commander = game.getCard(controller.getCommanderId());
if (commander != null && game.getState().getZone(commander.getId()) == Zone.COMMAND) {
controller.moveCards(commander, Zone.HAND, source, game);
List<Card> commandersInCommandZone = new ArrayList<>(1);
for (UUID commanderId : controller.getCommandersIds()) {
Card commander = game.getCard(commanderId);
if (commander != null && game.getState().getZone(commander.getId()) == Zone.COMMAND) {
commandersInCommandZone.add(commander);
}
}
if (commandersInCommandZone.size() == 1) {
controller.moveCards(commandersInCommandZone.get(0), Zone.HAND, source, game);
}
else if (commandersInCommandZone.size() == 2) {
Card firstCommander = commandersInCommandZone.get(0);
Card secondCommander = commandersInCommandZone.get(1);
if (controller.chooseUse(Outcome.ReturnToHand, "Return which commander to hand?", null, firstCommander.getName(), secondCommander.getName(), source, game)) {
controller.moveCards(firstCommander, Zone.HAND, source, game);
}
else {
controller.moveCards(secondCommander, Zone.HAND, source, game);
}
}
return true;
}

View file

@ -127,17 +127,19 @@ class ConspiracyEffect extends ContinuousEffectImpl {
}
}
// commander in command zone
if (controller.getCommanderId() != null && game.getState().getZone(controller.getCommanderId()).equals(Zone.COMMAND)) {
Card card = game.getCard(controller.getCommanderId());
if (card.getCardType().contains(CardType.CREATURE)) {
setCreatureSubtype(card, choice, game);
for (UUID commanderId : controller.getCommandersIds()) {
if (game.getState().getZone(commanderId).equals(Zone.COMMAND)) {
Card card = game.getCard(commanderId);
if (card.getCardType().contains(CardType.CREATURE)) {
setCreatureSubtype(card, choice, game);
}
}
}
// creature spells you control
for (Iterator<StackObject> iterator = game.getStack().iterator(); iterator.hasNext();) {
StackObject stackObject = iterator.next();
if (stackObject instanceof Spell &&
stackObject.getControllerId().equals(source.getControllerId()) &&
stackObject.getControllerId().equals(source.getControllerId()) &&
stackObject.getCardType().contains(CardType.CREATURE)) {
Card card = ((Spell) stackObject).getCard();
setCreatureSubtype(card, choice, game);
@ -153,20 +155,20 @@ class ConspiracyEffect extends ContinuousEffectImpl {
}
return false;
}
private void setCreatureSubtype(MageObject object, String subtype, Game game) {
if (object != null) {
if (object instanceof Card) {
Card card = (Card) object;
setChosenSubtype(
game.getState().getCreateCardAttribute(card).getSubtype(),
game.getState().getCreateCardAttribute(card).getSubtype(),
subtype);
} else {
setChosenSubtype(object.getSubtype(game), subtype);
}
}
}
private void setChosenSubtype(List<String> subtype, String choice) {
if (subtype.size() != 1 || !subtype.contains(choice)) {
subtype.removeAll(CardRepository.instance.getCreatureTypes());

View file

@ -140,7 +140,7 @@ class KarnLiberatedEffect extends OneShotEffect {
if (card.getOwnerId().equals(player.getId()) && !card.isCopy() // no copies
&& !player.getSideboard().contains(card.getId())
&& !cards.contains(card)) { // not the exiled cards
if (card.getId().equals(player.getCommanderId())) {
if (player.getCommandersIds().contains(card.getId())) {
game.addCommander(new Commander(card));
game.setZone(card.getId(), Zone.COMMAND);
} else {

View file

@ -119,7 +119,7 @@ class OpalPalaceWatcher extends Watcher {
for (UUID playerId : game.getPlayerList()) {
Player player = game.getPlayer(playerId);
if (player != null) {
if (player.getCommanderId() != null && player.getCommanderId().equals(card.getId())) {
if (player.getCommandersIds().contains(card.getId())) {
commanderId.add(card.getId());
break;
}

View file

@ -131,10 +131,12 @@ class TeferiMageOfZhalfirAddFlashEffect extends ContinuousEffectImpl {
}
}
// commander in command zone
if (controller.getCommanderId() != null && game.getState().getZone(controller.getCommanderId()).equals(Zone.COMMAND)) {
Card card = game.getCard(controller.getCommanderId());
if (card.getCardType().contains(CardType.CREATURE)) {
game.getState().addOtherAbility(card, FlashAbility.getInstance());
for (UUID commanderId : controller.getCommandersIds()) {
if (game.getState().getZone(commanderId).equals(Zone.COMMAND)) {
Card card = game.getCard(commanderId);
if (card.getCardType().contains(CardType.CREATURE)) {
game.getState().addOtherAbility(card, FlashAbility.getInstance());
}
}
}
return true;