mirror of
https://github.com/correl/mage.git
synced 2025-01-12 11:08:01 +00:00
* Diluvian Primordial - Fixed a bug that it only was able to cast a card from one opponent (last handled) in a multiplayer game.
This commit is contained in:
parent
13300d5807
commit
9450407b5a
1 changed files with 14 additions and 11 deletions
|
@ -80,10 +80,10 @@ public class DiluvianPrimordial extends CardImpl {
|
||||||
@Override
|
@Override
|
||||||
public void adjustTargets(Ability ability, Game game) {
|
public void adjustTargets(Ability ability, Game game) {
|
||||||
if (ability instanceof EntersBattlefieldTriggeredAbility) {
|
if (ability instanceof EntersBattlefieldTriggeredAbility) {
|
||||||
|
ability.getTargets().clear();
|
||||||
for(UUID opponentId : game.getOpponents(ability.getControllerId())) {
|
for(UUID opponentId : game.getOpponents(ability.getControllerId())) {
|
||||||
Player opponent = game.getPlayer(opponentId);
|
Player opponent = game.getPlayer(opponentId);
|
||||||
if (opponent != null) {
|
if (opponent != null) {
|
||||||
ability.getTargets().clear();
|
|
||||||
FilterCard filter = new FilterCard(new StringBuilder("instant or sorcery card from ").append(opponent.getName()).append("'s graveyard").toString());
|
FilterCard filter = new FilterCard(new StringBuilder("instant or sorcery card from ").append(opponent.getName()).append("'s graveyard").toString());
|
||||||
filter.add(new OwnerIdPredicate(opponentId));
|
filter.add(new OwnerIdPredicate(opponentId));
|
||||||
filter.add(Predicates.or(new CardTypePredicate(CardType.INSTANT),new CardTypePredicate(CardType.SORCERY)));
|
filter.add(Predicates.or(new CardTypePredicate(CardType.INSTANT),new CardTypePredicate(CardType.SORCERY)));
|
||||||
|
@ -122,13 +122,13 @@ class DiluvianPrimordialEffect extends OneShotEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
for (Target target: source.getTargets()) {
|
for (Target target: source.getTargets()) {
|
||||||
if (target instanceof TargetCardInOpponentsGraveyard) {
|
if (target instanceof TargetCardInOpponentsGraveyard) {
|
||||||
Card targetCard = game.getCard(target.getFirstTarget());
|
Card targetCard = game.getCard(target.getFirstTarget());
|
||||||
if (player != null && targetCard != null) {
|
if (controller != null && targetCard != null) {
|
||||||
if (player.chooseUse(outcome, "Cast " + targetCard.getName() +"?", game)) {
|
if (controller.chooseUse(outcome, "Cast " + targetCard.getName() +"?", game)) {
|
||||||
player.cast(targetCard.getSpellAbility(), game, true);
|
controller.cast(targetCard.getSpellAbility(), game, true);
|
||||||
ContinuousEffect effect = new DiluvianPrimordialReplacementEffect();
|
ContinuousEffect effect = new DiluvianPrimordialReplacementEffect();
|
||||||
effect.setTargetPointer(new FixedTarget(targetCard.getId()));
|
effect.setTargetPointer(new FixedTarget(targetCard.getId()));
|
||||||
game.addEffect(effect, source);
|
game.addEffect(effect, source);
|
||||||
|
@ -174,14 +174,17 @@ class DiluvianPrimordialReplacementEffect extends ReplacementEffectImpl {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checksEventType(GameEvent event, Game game) {
|
||||||
|
return event.getType() == EventType.ZONE_CHANGE;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
if (event.getType() == EventType.ZONE_CHANGE) {
|
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
if (zEvent.getToZone() == Zone.GRAVEYARD
|
||||||
if (zEvent.getToZone() == Zone.GRAVEYARD
|
&& ((ZoneChangeEvent) event).getTargetId().equals(getTargetPointer().getFirst(game, source))) {
|
||||||
&& ((ZoneChangeEvent) event).getTargetId().equals(getTargetPointer().getFirst(game, source))) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue