[KHM] improved Cosima, God of the Voyage - "to the voyage" exile window, user friendly choose dialog, visible counters in exile, AI support (#7248);

This commit is contained in:
Oleg Agafonov 2021-02-03 14:59:52 +04:00
parent 4b9de96a6b
commit c381ea7716
2 changed files with 34 additions and 7 deletions

View file

@ -102,8 +102,13 @@ class CosimaGodOfTheVoyageEffect extends OneShotEffect {
return false;
}
Card card = game.getCard(permanent.getId());
player.moveCards(permanent, Zone.EXILED, source, game);
if (card == null || game.getState().getZone(card.getId()) != Zone.EXILED) {
if (card == null) {
return false;
}
String exileName = "Exiled to the voyage";
player.moveCardsToExile(permanent, source, game, true, source.getSourceId(), exileName);
if (game.getState().getZone(card.getId()) != Zone.EXILED) {
return true;
}
game.addEffect(new CosimaGodOfTheVoyageGainAbilityEffect(new MageObjectReference(card, game)), source);
@ -206,19 +211,29 @@ class CosimaGodOfTheVoyageReturnEffect extends OneShotEffect {
if (player == null || card == null) {
return false;
}
if (player.chooseUse(outcome, "Add a voyage counter?", source, game)
// AI hint to return card on 2+ counters
int currentCount = card.getCounters(game).getCount(CounterType.VOYAGE);
Outcome aiOutcome = (currentCount >= 2) ? Outcome.Benefit : Outcome.Detriment;
if (player.chooseUse(aiOutcome, "Add a voyage counter (current: " + currentCount + ")?", null,
"Yes, add counter", "No, return to battlefield", source, game)
&& card.addCounters(CounterType.VOYAGE.createInstance(), player.getId(), source, game)) {
return true;
}
int counterCount = card.getCounters(game).getCount(CounterType.VOYAGE);
// return to battle
int newCount = card.getCounters(game).getCount(CounterType.VOYAGE);
player.moveCards(card, Zone.BATTLEFIELD, source, game);
if (counterCount < 1) {
if (newCount < 1) {
return true;
}
player.drawCards(counterCount, source, game);
// draw and boost
player.drawCards(newCount, source, game);
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(counterCount), player.getId(), source, game);
permanent.addCounters(CounterType.P1P1.createInstance(newCount), player.getId(), source, game);
}
return true;
}

View file

@ -7,7 +7,9 @@ import mage.abilities.*;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.constants.*;
import mage.counters.Counters;
import mage.game.Game;
import mage.game.GameState;
import mage.game.events.ZoneChangeEvent;
import mage.util.CardUtil;
import mage.util.SubTypes;
@ -111,6 +113,16 @@ public abstract class ModalDoubleFacesCard extends CardImpl {
rightHalfCard.updateZoneChangeCounter(game, event);
}
@Override
public Counters getCounters(Game game) {
return leftHalfCard.getCounters(game.getState());
}
@Override
public Counters getCounters(GameState state) {
return state.getCardState(leftHalfCard.getId()).getCounters();
}
@Override
public boolean cast(Game game, Zone fromZone, SpellAbility ability, UUID controllerId) {
switch (ability.getSpellAbilityType()) {