mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Merge pull request #5279 from Zzooouhh/Zzooouhh-magcon
Implemented Mages' Contest
This commit is contained in:
commit
a018f6fb5c
2 changed files with 103 additions and 0 deletions
102
Mage.Sets/src/mage/cards/m/MagesContest.java
Normal file
102
Mage.Sets/src/mage/cards/m/MagesContest.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
|
||||
package mage.cards.m;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetSpell;
|
||||
import mage.util.RandomUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Quercitron & L_J
|
||||
*/
|
||||
public final class MagesContest extends CardImpl {
|
||||
|
||||
public MagesContest(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{R}{R}");
|
||||
|
||||
// You and target spell's controller bid life. You start the bidding with a bid of 1. In turn order, each player may top the high bid. The bidding ends if the high bid stands. The high bidder loses life equal to the high bid. If you win the bidding, counter that spell.
|
||||
this.getSpellAbility().addEffect(new MagesContestEffect());
|
||||
this.getSpellAbility().addTarget(new TargetSpell());
|
||||
|
||||
}
|
||||
|
||||
public MagesContest(final MagesContest card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagesContest copy() {
|
||||
return new MagesContest(this);
|
||||
}
|
||||
}
|
||||
|
||||
class MagesContestEffect extends OneShotEffect {
|
||||
|
||||
public MagesContestEffect() {
|
||||
super(Outcome.Detriment);
|
||||
this.staticText = "You and target spell's controller bid life. You start the bidding with a bid of 1. In turn order, each player may top the high bid. The bidding ends if the high bid stands. The high bidder loses life equal to the high bid. If you win the bidding, counter that spell";
|
||||
}
|
||||
|
||||
public MagesContestEffect(final MagesContestEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagesContestEffect copy() {
|
||||
return new MagesContestEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Spell spell = game.getStack().getSpell(this.getTargetPointer().getFirst(game, source));
|
||||
if (spell != null) {
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
Player spellController = game.getPlayer(spell.getControllerId());
|
||||
if (you != null && spellController != null) {
|
||||
int highBid = 1;
|
||||
game.informPlayers(you.getLogName() + " has bet " + highBid + " life");
|
||||
Player winner = you;
|
||||
Player currentPlayer = spellController;
|
||||
do {
|
||||
if (currentPlayer != null && currentPlayer.canRespond()) {
|
||||
int newBid = 0;
|
||||
if (!currentPlayer.isHuman()) {
|
||||
// make AI evaluate value of the spell to decide on bidding, should be reworked
|
||||
int maxBid = Math.min(RandomUtil.nextInt(Math.max(currentPlayer.getLife(), 0)) + RandomUtil.nextInt(spell.getConvertedManaCost()), currentPlayer.getLife());
|
||||
if (highBid + 1 < maxBid) {
|
||||
newBid = highBid + 1;
|
||||
}
|
||||
} else if (currentPlayer.chooseUse(Outcome.Benefit, winner.getLogName() + " has bet " + highBid + " life. Top the bid?", source, game)) {
|
||||
newBid = currentPlayer.getAmount(highBid + 1, Integer.MAX_VALUE, "Choose bid", game);
|
||||
}
|
||||
if (newBid > highBid) {
|
||||
highBid = newBid;
|
||||
winner = currentPlayer;
|
||||
game.informPlayers(currentPlayer.getLogName() + " has bet " + newBid + " life");
|
||||
currentPlayer = (winner == you ? spellController : you);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (!Objects.equals(currentPlayer, winner));
|
||||
game.informPlayers(winner.getLogName() + " has won the contest with a high bid of " + highBid + " life");
|
||||
winner.loseLife(highBid, game, false);
|
||||
if (winner == you) {
|
||||
game.getStack().counter(spell.getId(), source.getSourceId(), game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -165,6 +165,7 @@ public final class Invasion extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Loafing Giant", 153, Rarity.RARE, mage.cards.l.LoafingGiant.class));
|
||||
cards.add(new SetCardInfo("Lobotomy", 255, Rarity.UNCOMMON, mage.cards.l.Lobotomy.class));
|
||||
cards.add(new SetCardInfo("Lotus Guardian", 305, Rarity.RARE, mage.cards.l.LotusGuardian.class));
|
||||
cards.add(new SetCardInfo("Mages' Contest", 154, Rarity.RARE, mage.cards.m.MagesContest.class));
|
||||
cards.add(new SetCardInfo("Mana Maze", 59, Rarity.RARE, mage.cards.m.ManaMaze.class));
|
||||
cards.add(new SetCardInfo("Maniacal Rage", 155, Rarity.COMMON, mage.cards.m.ManiacalRage.class));
|
||||
cards.add(new SetCardInfo("Manipulate Fate", 60, Rarity.UNCOMMON, mage.cards.m.ManipulateFate.class));
|
||||
|
|
Loading…
Reference in a new issue