* Mind Bomb - Fixed that it can't do damage to players with 0 selected cards;

This commit is contained in:
Oleg Agafonov 2018-11-19 01:46:44 +04:00
parent d78d818a66
commit 9cb69fbc83

View file

@ -1,17 +1,10 @@
package mage.cards.m; package mage.cards.m;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; import mage.cards.*;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.filter.FilterCard; import mage.filter.FilterCard;
@ -20,8 +13,11 @@ import mage.players.Player;
import mage.target.Target; import mage.target.Target;
import mage.target.common.TargetDiscard; import mage.target.common.TargetDiscard;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/** /**
*
* @author TheElk801 * @author TheElk801
*/ */
public final class MindBomb extends CardImpl { public final class MindBomb extends CardImpl {
@ -67,6 +63,7 @@ class MindBombEffect extends OneShotEffect {
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
Map<UUID, Cards> cardsToDiscard = new HashMap<>(); Map<UUID, Cards> cardsToDiscard = new HashMap<>();
// choose
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
@ -77,6 +74,8 @@ class MindBombEffect extends OneShotEffect {
cardsToDiscard.put(playerId, cards); cardsToDiscard.put(playerId, cards);
} }
} }
// discard
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
@ -91,31 +90,17 @@ class MindBombEffect extends OneShotEffect {
} }
} }
} }
// damage
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null) {
Cards cardsPlayer = cardsToDiscard.get(playerId); Cards cardsPlayer = cardsToDiscard.get(playerId);
if (cardsPlayer != null && !cardsPlayer.isEmpty()) { if (cardsPlayer != null) {
player.damage(3 - cardsPlayer.size(), source.getId(), game, false, true); player.damage(3 - cardsPlayer.size(), source.getId(), game, false, true);
} }
} }
} }
// reveal the searched lands, put in hands, and shuffle
// for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
// Player player = game.getPlayer(playerId);
// if (player != null) {
// Cards cardsPlayer = cardsToReveal.get(playerId);
// if (cardsPlayer != null) {
// for (UUID cardId : cardsPlayer) {
// Cards cards = new CardsImpl(game.getCard(cardId));
// Card card = game.getCard(cardId);
// player.revealCards(sourceObject.getIdName() + " (" + player.getName() + ')', cards, game);
// player.moveCards(card, Zone.HAND, source, game);
// player.shuffleLibrary(source, game);
// }
// }
// }
// }
return true; return true;
} }
return false; return false;