mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
Fixed a bug of cost paying handling not showing only the left over unpaid part of mana cost (fixes #185). Added the name of the object the cost is paid for to the feedback panel.
This commit is contained in:
parent
972fe78898
commit
4a5140d0ab
6 changed files with 43 additions and 29 deletions
|
@ -1011,7 +1011,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean playMana(ManaCost unpaid, Game game) {
|
||||
public boolean playMana(ManaCost unpaid, String promptText, Game game) {
|
||||
payManaMode = true;
|
||||
boolean result = playManaHandling(unpaid, game);
|
||||
payManaMode = false;
|
||||
|
|
|
@ -606,17 +606,17 @@ public class HumanPlayer extends PlayerImpl {
|
|||
|
||||
|
||||
@Override
|
||||
public boolean playMana(ManaCost unpaid, Game game) {
|
||||
public boolean playMana(ManaCost unpaid, String promptText, Game game) {
|
||||
payManaMode = true;
|
||||
boolean result = playManaHandling(unpaid, game);
|
||||
boolean result = playManaHandling(unpaid, promptText, game);
|
||||
payManaMode = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected boolean playManaHandling(ManaCost unpaid, Game game) {
|
||||
protected boolean playManaHandling(ManaCost unpaid, String promptText, Game game) {
|
||||
updateGameStatePriority("playMana", game);
|
||||
game.firePlayManaEvent(playerId, "Pay " + unpaid.getText());
|
||||
game.firePlayManaEvent(playerId, "Pay " + promptText);
|
||||
waitForResponse(game);
|
||||
if (!this.isInGame()) {
|
||||
return false;
|
||||
|
|
|
@ -39,6 +39,7 @@ import mage.filter.Filter;
|
|||
import mage.game.Game;
|
||||
import mage.players.ManaPool;
|
||||
import mage.players.Player;
|
||||
import mage.util.ManaUtil;
|
||||
|
||||
|
||||
public abstract class ManaCostImpl extends CostImpl implements ManaCost {
|
||||
|
@ -218,12 +219,15 @@ public abstract class ManaCostImpl extends CostImpl implements ManaCost {
|
|||
Player player = game.getPlayer(controllerId);
|
||||
assignPayment(game, ability, player.getManaPool());
|
||||
while (!isPaid()) {
|
||||
if (player.playMana(this, game)) {
|
||||
ManaCost unpaid = this.getUnpaid();
|
||||
String promptText = ManaUtil.addSpecialManaPayAbilities(ability, game, unpaid);
|
||||
if (player.playMana(unpaid, promptText, game)) {
|
||||
assignPayment(game, ability, player.getManaPool());
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
game.getState().getSpecialActions().removeManaActions();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ import mage.MageObject;
|
|||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.keyword.DelveAbility;
|
||||
import mage.abilities.mana.ManaOptions;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
import mage.filter.Filter;
|
||||
|
@ -45,6 +44,7 @@ import mage.game.Game;
|
|||
import mage.players.ManaPool;
|
||||
import mage.players.Player;
|
||||
import mage.target.Targets;
|
||||
import mage.util.ManaUtil;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
@ -121,8 +121,9 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
Player player = game.getPlayer(controllerId);
|
||||
assignPayment(game, ability, player.getManaPool());
|
||||
while (!isPaid()) {
|
||||
addSpecialManaPayAbilities(ability, game);
|
||||
if (player.playMana(this.getUnpaid(), game)) {
|
||||
ManaCost unpaid = this.getUnpaid();
|
||||
String promptText = ManaUtil.addSpecialManaPayAbilities(ability, game, unpaid);
|
||||
if (player.playMana(unpaid, promptText, game)) {
|
||||
assignPayment(game, ability, player.getManaPool());
|
||||
} else {
|
||||
return false;
|
||||
|
@ -132,25 +133,6 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This activates the special button if there exists special ways to pay the mana (Delve, Convoke)
|
||||
*
|
||||
* @param ability
|
||||
* @param game
|
||||
*/
|
||||
private void addSpecialManaPayAbilities(Ability source, Game game) {
|
||||
// check for special mana payment possibilities
|
||||
MageObject mageObject = source.getSourceObject(game);
|
||||
if (mageObject != null) {
|
||||
for (Ability ability :mageObject.getAbilities()) {
|
||||
if (ability instanceof AlternateManaPaymentAbility) {
|
||||
((AlternateManaPaymentAbility) ability).addSpecialAction(source, game, getUnpaid());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bookmarks the current state and restores it if player doesn't pay the mana cost
|
||||
*
|
||||
|
|
|
@ -299,7 +299,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
boolean chooseUse(Outcome outcome, String message, Game game);
|
||||
boolean choose(Outcome outcome, Choice choice, Game game);
|
||||
boolean choosePile(Outcome outcome, String message, List<? extends Card> pile1, List<? extends Card> pile2, Game game);
|
||||
boolean playMana(ManaCost unpaid, Game game);
|
||||
boolean playMana(ManaCost unpaid, String promptText, Game game);
|
||||
|
||||
/**
|
||||
* Moves the cards from cards to the bottom of the players library.
|
||||
|
|
|
@ -10,6 +10,10 @@ import java.util.HashSet;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.mana.AlternateManaPaymentAbility;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* @author noxx
|
||||
|
@ -334,4 +338,28 @@ public class ManaUtil {
|
|||
|
||||
return useableAbilities;
|
||||
}
|
||||
|
||||
/**
|
||||
* This activates the special button inthe feedback panel of the client
|
||||
* if there exists special ways to pay the mana (e.g. Delve, Convoke)
|
||||
*
|
||||
* @param source ability the mana costs have to be paid for
|
||||
* @param game
|
||||
* @param unpaid mana that has still to be paid
|
||||
* @return message to be shown in human players feedback area
|
||||
*/
|
||||
public static String addSpecialManaPayAbilities(Ability source, Game game, ManaCost unpaid) {
|
||||
// check for special mana payment possibilities
|
||||
MageObject mageObject = source.getSourceObject(game);
|
||||
if (mageObject != null) {
|
||||
for (Ability ability :mageObject.getAbilities()) {
|
||||
if (ability instanceof AlternateManaPaymentAbility) {
|
||||
((AlternateManaPaymentAbility) ability).addSpecialAction(source, game, unpaid);
|
||||
}
|
||||
}
|
||||
return unpaid.getText() + "<div style='font-size:11pt'>" + mageObject.getLogName() + "</div>";
|
||||
} else {
|
||||
return unpaid.getText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue