mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
* Forgotten Ancient - fixed AI game freeze, improved dialog logic (#5023);
This commit is contained in:
parent
238aa7abdc
commit
7ab73dec60
1 changed files with 45 additions and 40 deletions
|
@ -10,11 +10,7 @@ import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.*;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.TargetController;
|
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.counters.CounterType;
|
import mage.counters.CounterType;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
import mage.filter.predicate.permanent.AnotherPredicate;
|
import mage.filter.predicate.permanent.AnotherPredicate;
|
||||||
|
@ -29,17 +25,17 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Blinke
|
* @author Blinke
|
||||||
*/
|
*/
|
||||||
public final class ForgottenAncient extends CardImpl {
|
public final class ForgottenAncient extends CardImpl {
|
||||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature");
|
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.add(AnotherPredicate.instance);
|
filter.add(AnotherPredicate.instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ForgottenAncient(UUID ownerId, CardSetInfo setInfo) {
|
public ForgottenAncient(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}");
|
||||||
this.subtype.add(SubType.ELEMENTAL);
|
this.subtype.add(SubType.ELEMENTAL);
|
||||||
this.power = new MageInt(0);
|
this.power = new MageInt(0);
|
||||||
this.toughness = new MageInt(3);
|
this.toughness = new MageInt(3);
|
||||||
|
@ -88,43 +84,52 @@ public final class ForgottenAncient extends CardImpl {
|
||||||
Player controller = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||||
|
|
||||||
if(controller == null || sourcePermanent == null) {
|
if (controller == null || sourcePermanent == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int numCounters = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
|
int numCounters = sourcePermanent.getCounters(game).getCount(CounterType.P1P1);
|
||||||
|
if (numCounters == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
List<CounterMovement> counterMovements = new ArrayList<>();
|
List<CounterMovement> counterMovements = new ArrayList<>();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Target target = new TargetCreaturePermanent(1, 1, filter, true);
|
Target target = new TargetCreaturePermanent(1, 1, filter, true);
|
||||||
if(numCounters == 0 || !target.choose(Outcome.Benefit, source.getControllerId(), source.getSourceId(), game)) {
|
if (!target.canChoose(source.getSourceId(), controller.getId(), game)) {
|
||||||
continue;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!target.choose(Outcome.BoostCreature, source.getControllerId(), source.getSourceId(), game)) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int amountToMove = controller.getAmount(0, numCounters, "How many counters do you want to move? " + '(' + numCounters + ')' + " counters remaining.", game);
|
int amountToMove = controller.getAmount(0, numCounters, "How many counters do you want to move? " + '(' + numCounters + ')' + " counters remaining.", game);
|
||||||
if(amountToMove > 0)
|
if (amountToMove == 0) {
|
||||||
{
|
break;
|
||||||
boolean previouslyChosen = false;
|
|
||||||
for (CounterMovement cm : counterMovements) {
|
|
||||||
if(cm.target.equals(target.getFirstTarget()))
|
|
||||||
{
|
|
||||||
cm.counters += amountToMove;
|
|
||||||
previouslyChosen = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!previouslyChosen) {
|
|
||||||
CounterMovement cm = new CounterMovement();
|
|
||||||
cm.target = target.getFirstTarget();
|
|
||||||
cm.counters = amountToMove;
|
|
||||||
counterMovements.add(cm);
|
|
||||||
}
|
|
||||||
|
|
||||||
numCounters -= amountToMove;
|
|
||||||
}
|
}
|
||||||
} while(numCounters > 0 && controller.chooseUse(Outcome.Benefit, "Move additonal counters?", source, game));
|
|
||||||
|
boolean previouslyChosen = false;
|
||||||
|
for (CounterMovement cm : counterMovements) {
|
||||||
|
if (cm.target.equals(target.getFirstTarget())) {
|
||||||
|
cm.counters += amountToMove;
|
||||||
|
previouslyChosen = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!previouslyChosen) {
|
||||||
|
CounterMovement cm = new CounterMovement();
|
||||||
|
cm.target = target.getFirstTarget();
|
||||||
|
cm.counters = amountToMove;
|
||||||
|
counterMovements.add(cm);
|
||||||
|
}
|
||||||
|
|
||||||
|
numCounters -= amountToMove;
|
||||||
|
|
||||||
|
} while (numCounters > 0 && controller.chooseUse(Outcome.Benefit, "Move additional counters?", source, game));
|
||||||
|
|
||||||
//Move all the counters for each chosen creature
|
//Move all the counters for each chosen creature
|
||||||
for(CounterMovement cm: counterMovements) {
|
for (CounterMovement cm : counterMovements) {
|
||||||
sourcePermanent.removeCounters(CounterType.P1P1.createInstance(cm.counters), game);
|
sourcePermanent.removeCounters(CounterType.P1P1.createInstance(cm.counters), game);
|
||||||
game.getPermanent(cm.target).addCounters(CounterType.P1P1.createInstance(cm.counters), source, game);
|
game.getPermanent(cm.target).addCounters(CounterType.P1P1.createInstance(cm.counters), source, game);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue