mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
- Workaround for #5437. The delayed triggers work correctly now and the game will no longer freeze. TODO: Cards that are copied and then cast do not retain the correct sourceObject. They instead point to the spell on the stack which fails when delayed triggers are used.
This commit is contained in:
parent
75ad7e73e0
commit
5aaec29361
4 changed files with 43 additions and 15 deletions
|
|
@ -52,7 +52,8 @@ public class DrawCardSourceControllerEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
if (player != null
|
||||
&& player.isInGame()) {
|
||||
player.drawCards(amount.calculate(game, source, this), game);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -61,9 +62,14 @@ public class DrawCardSourceControllerEffect extends OneShotEffect {
|
|||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean oneCard = (amount instanceof StaticValue && amount.calculate(null, null, this) == 1)
|
||||
|| amount instanceof PermanentsOnBattlefieldCount || amount.toString().equals("1") || amount.toString().equals("a");
|
||||
sb.append(whoDrawCard.isEmpty() ? "" : whoDrawCard + " ").append("draw ").append(oneCard ? "a" : CardUtil.numberToText(amount.toString())).append(" card");
|
||||
boolean oneCard = (amount instanceof StaticValue
|
||||
&& amount.calculate(null, null, this) == 1)
|
||||
|| amount instanceof PermanentsOnBattlefieldCount
|
||||
|| amount.toString().equals("1")
|
||||
|| amount.toString().equals("a");
|
||||
sb.append(whoDrawCard.isEmpty() ? "" : whoDrawCard
|
||||
+ " ").append("draw ").append(oneCard ? "a"
|
||||
: CardUtil.numberToText(amount.toString())).append(" card");
|
||||
if (!oneCard) {
|
||||
sb.append('s');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -63,12 +62,14 @@ public class DrawCardTargetEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID playerId : getTargetPointer().getTargets(game, source)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
if (player != null
|
||||
&& player.isInGame()) {
|
||||
int cardsToDraw = amount.calculate(game, source, this);
|
||||
if (upTo) {
|
||||
cardsToDraw = player.getAmount(0, cardsToDraw, "Draw how many cards?", game);
|
||||
}
|
||||
if (!optional || player.chooseUse(outcome, "Use draw effect?", source, game)) {
|
||||
if (!optional
|
||||
|| player.chooseUse(outcome, "Use draw effect?", source, game)) {
|
||||
player.drawCards(cardsToDraw, game);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue