mirror of
https://github.com/correl/mage.git
synced 2024-11-28 11:09:54 +00:00
Added card "Unpleasant Discovery" and its abilities and effects
This commit is contained in:
parent
b89ba1b229
commit
9abb4d3091
2 changed files with 121 additions and 1 deletions
|
@ -1,4 +1,35 @@
|
|||
package mage.cards.u;
|
||||
|
||||
public class UnpleasantDiscovery {
|
||||
import mage.abilities.effects.common.LoseLifeOpponentsEffect;
|
||||
import mage.abilities.effects.common.MillCardsEachPlayerEffect;
|
||||
import mage.abilities.effects.common.RevealHandEachPlayerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.TargetController;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Merlingilb
|
||||
*/
|
||||
public class UnpleasantDiscovery extends CardImpl {
|
||||
public UnpleasantDiscovery(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{B}");
|
||||
|
||||
//Each opponent reveals their hand, loses 1 life, and mills two cards.
|
||||
this.getSpellAbility().addEffect(new RevealHandEachPlayerEffect(TargetController.OPPONENT));
|
||||
this.getSpellAbility().addEffect(new LoseLifeOpponentsEffect(1).setText("and loses 1 life"));
|
||||
this.getSpellAbility().addEffect(new MillCardsEachPlayerEffect(2, TargetController.OPPONENT)
|
||||
.setText(" and mills two cards"));
|
||||
}
|
||||
|
||||
public UnpleasantDiscovery(final UnpleasantDiscovery card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnpleasantDiscovery copy() {
|
||||
return new UnpleasantDiscovery(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Merlingilb
|
||||
*/
|
||||
public class RevealHandEachPlayerEffect extends OneShotEffect {
|
||||
private final TargetController targetController;
|
||||
|
||||
public RevealHandEachPlayerEffect() {
|
||||
this(TargetController.ANY);
|
||||
}
|
||||
|
||||
public RevealHandEachPlayerEffect(TargetController targetController) {
|
||||
super(Outcome.Benefit);
|
||||
this.targetController = targetController;
|
||||
}
|
||||
|
||||
public RevealHandEachPlayerEffect(final RevealHandEachPlayerEffect effect) {
|
||||
super(effect);
|
||||
this.targetController = effect.targetController;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source);
|
||||
if (controller == null) {
|
||||
return true;
|
||||
}
|
||||
for (UUID playerId : game.getPlayers().keySet()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
switch (targetController) {
|
||||
case NOT_YOU:
|
||||
if (playerId.equals(source.getControllerId())) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case OPPONENT:
|
||||
if (!game.getOpponents(source.getControllerId()).contains(playerId)) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
player.revealCards(sourceObject.getIdName() + player.getName(), player.getHand(), game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevealHandEachPlayerEffect copy() {
|
||||
return new RevealHandEachPlayerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("each ");
|
||||
switch (targetController) {
|
||||
case NOT_YOU:
|
||||
sb.append("other player");
|
||||
break;
|
||||
case OPPONENT:
|
||||
sb.append("opponent");
|
||||
break;
|
||||
case ANY:
|
||||
sb.append("player");
|
||||
break;
|
||||
}
|
||||
sb.append(" reveals their hand");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue