mirror of
https://github.com/magefree/mage.git
synced 2025-12-30 07:22:03 -08:00
Fixed that if cards from opponents were cast, that spell cast triggered abilities from this cards or optional additional costs from this card (e.g. Buyback) were controlled by the casting player.
This commit is contained in:
parent
538bb91222
commit
1a93d3a96d
5 changed files with 37 additions and 33 deletions
|
|
@ -43,6 +43,7 @@ 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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -95,6 +96,9 @@ public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbili
|
|||
if (!controllerSet) {
|
||||
if (object instanceof Permanent) {
|
||||
ability.setControllerId(((Permanent) object).getControllerId());
|
||||
} else if (object instanceof Spell) {
|
||||
// needed so that cast triggered abilities have to correct controller (e.g. Ulamog, the Infinite Gyre).
|
||||
ability.setControllerId(((Spell) object).getControllerId());
|
||||
} else if (object instanceof Card) {
|
||||
ability.setControllerId(((Card) object).getOwnerId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,11 +33,14 @@ import mage.game.Game;
|
|||
/**
|
||||
* Interface for abilities that add additional costs to the source.
|
||||
*
|
||||
* Example of such additional source costs: {@link mage.abilities.keyword.KickerAbility}
|
||||
* Example of such additional source costs:
|
||||
* {@link mage.abilities.keyword.KickerAbility}
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public interface OptionalAdditionalSourceCosts {
|
||||
|
||||
void addOptionalAdditionalCosts(Ability ability, Game game);
|
||||
|
||||
String getCastMessageSuffix();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ public class BuybackAbility extends StaticAbility implements OptionalAdditionalS
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActivated() {
|
||||
if (buybackCost != null) {
|
||||
return buybackCost.isActivated();
|
||||
|
|
@ -112,11 +113,11 @@ public class BuybackAbility extends StaticAbility implements OptionalAdditionalS
|
|||
@Override
|
||||
public void addOptionalAdditionalCosts(Ability ability, Game game) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
Player player = game.getPlayer(ability.getControllerId());
|
||||
if (player != null) {
|
||||
this.resetBuyback();
|
||||
if (buybackCost != null) {
|
||||
if (player.chooseUse(Outcome.Benefit, new StringBuilder("Pay ").append(buybackCost.getText(false)).append(" ?").toString(), ability, game)) {
|
||||
if (player.chooseUse(Outcome.Benefit, "Pay " + buybackCost.getText(false) + " ?", ability, game)) {
|
||||
buybackCost.activate();
|
||||
for (Iterator it = ((Costs) buybackCost).iterator(); it.hasNext();) {
|
||||
Cost cost = (Cost) it.next();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue