This commit is contained in:
maurer.it 2011-03-02 09:12:13 -05:00
commit 141529c1e8
49 changed files with 2153 additions and 71 deletions

View file

@ -81,15 +81,11 @@ public class CardsList extends javax.swing.JPanel implements MouseListener {
}
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId) {
loadCards(showCards, bigCard, gameId, SortBy.UNSORTED);
}
public void loadCards(CardsView showCards, BigCard bigCard, UUID gameId, SortBy sortBy) {
//FIXME: why we remove all cards? for performance it's better to merge changes
cards = showCards;
this.bigCard = bigCard;
this.gameId = gameId;
drawCards(sortBy);
drawCards((SortBy) cbSortBy.getSelectedItem());
}
private void drawCards(SortBy sortBy) {

View file

@ -62,9 +62,9 @@ public class DeckArea extends javax.swing.JPanel {
}
public void loadDeck(Deck deck, BigCard bigCard) {
deckList.loadCards(new CardsView(deck.getCards()), bigCard, null, SortBy.NAME);
if (sideboardList.isVisible())
sideboardList.loadCards(new CardsView(deck.getSideboard()), bigCard, null, SortBy.NAME);
deckList.loadCards(new CardsView(deck.getCards()), bigCard, null);
if (sideboardList.isVisible())
sideboardList.loadCards(new CardsView(deck.getSideboard()), bigCard, null);
}
public void addDeckEventListener(Listener<Event> listener) {

View file

@ -63,8 +63,8 @@ public class TwoPlayerDuel extends GameImpl<TwoPlayerDuel> {
}
@Override
protected void init(UUID choosingPlayerId) {
super.init(choosingPlayerId);
protected void init(UUID choosingPlayerId, boolean testMode) {
super.init(choosingPlayerId, testMode);
state.getTurnMods().add(new TurnMod(startingPlayerId, PhaseStep.DRAW));
}

View file

@ -160,7 +160,7 @@ public class ComputerPlayer6 extends ComputerPlayer<ComputerPlayer6> implements
}
}
private void printOutState(Game game, UUID playerId) {
protected void printOutState(Game game, UUID playerId) {
Player player = game.getPlayer(playerId);
System.out.println("Turn::"+game.getTurnNum());
System.out.println("[" + game.getPlayer(playerId).getName() + "] " + game.getTurn().getStepType().name() +", life=" + player.getLife());
@ -239,6 +239,7 @@ public class ComputerPlayer6 extends ComputerPlayer<ComputerPlayer6> implements
logger.info("simlating -- game value:" + game.getState().getValue() + " test value:" + test.gameValue);
if (root.playerId.equals(playerId) && root.abilities != null && game.getState().getValue() == test.gameValue) {
/*
// Try to fix horizon effect
if (root.combat == null || root.combat.getAttackers().size() == 0) {
FilterCreatureForAttack attackFilter = new FilterCreatureForAttack();
@ -250,6 +251,7 @@ public class ComputerPlayer6 extends ComputerPlayer<ComputerPlayer6> implements
return false;
}
}
*/
logger.info("simulating -- continuing previous action chain");
actions = new LinkedList<Ability>(root.abilities);
@ -286,6 +288,11 @@ public class ComputerPlayer6 extends ComputerPlayer<ComputerPlayer6> implements
bestChild.setCombat(_combat);
}
}
// no need to check other actions
if (val == GameStateEvaluator2.LOSE_GAME_SCORE) {
logger.debug("lose - break");
break;
}
}
else {
if (val > alpha) {
@ -296,6 +303,11 @@ public class ComputerPlayer6 extends ComputerPlayer<ComputerPlayer6> implements
bestChild.setCombat(_combat);
}
}
// no need to check other actions
if (val == GameStateEvaluator2.WIN_GAME_SCORE) {
logger.debug("win - break");
break;
}
}
}
node.children.clear();
@ -467,6 +479,12 @@ public class ComputerPlayer6 extends ComputerPlayer<ComputerPlayer6> implements
bestNode.setScore(val);
node.setCombat(newNode.getCombat());
}
// no need to check other actions
if (val == GameStateEvaluator2.LOSE_GAME_SCORE) {
logger.debug("lose - break");
break;
}
}
else {
if (val > alpha) {
@ -478,7 +496,7 @@ public class ComputerPlayer6 extends ComputerPlayer<ComputerPlayer6> implements
targets = node.getTargets();
if (node.getChoices().size() > 0)
choices = node.getChoices();
if (depth == 20) {
if (depth == Config2.maxDepth) {
logger.info("saved");
node.children.clear();
node.children.add(bestNode);
@ -488,7 +506,7 @@ public class ComputerPlayer6 extends ComputerPlayer<ComputerPlayer6> implements
// no need to check other actions
if (val == GameStateEvaluator2.WIN_GAME_SCORE) {
logger.info("win - break");
logger.debug("win - break");
break;
}
}
@ -710,10 +728,12 @@ public class ComputerPlayer6 extends ComputerPlayer<ComputerPlayer6> implements
logger.debug("selectAttackers");
if (combat != null) {
UUID opponentId = game.getCombat().getDefenders().iterator().next();
String attackers = "";
for (UUID attackerId: combat.getAttackers()) {
logger.debug("declare attacker: " + game.getCard(attackerId).getName());
attackers = "[" + game.getCard(attackerId).getName() + "]";
this.declareAttacker(attackerId, opponentId, game);
}
logger.info("declare attackers: " + (attackers.isEmpty() ? "none" : attackers));
}
}

View file

@ -0,0 +1,545 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.player.ai;
import mage.Constants.AbilityType;
import mage.Constants.PhaseStep;
import mage.Constants.RangeOfInfluence;
import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.filter.FilterAbility;
import mage.game.Game;
import mage.game.combat.Combat;
import mage.game.combat.CombatGroup;
import mage.game.events.GameEvent;
import mage.game.turn.*;
import mage.players.Player;
import org.apache.log4j.Logger;
import java.util.LinkedList;
import java.util.UUID;
/**
*
* @author ayratn
*/
public class ComputerPlayer7 extends ComputerPlayer6 implements Player {
private static final transient Logger logger = Logger.getLogger(ComputerPlayer7.class);
private static FilterAbility filterLand = new FilterAbility();
private static FilterAbility filterNotLand = new FilterAbility();
static {
filterLand.getTypes().add(AbilityType.PLAY_LAND);
filterLand.setZone(Zone.HAND);
filterNotLand.getTypes().add(AbilityType.PLAY_LAND);
filterNotLand.setZone(Zone.HAND);
filterNotLand.setNotFilter(true);
}
public ComputerPlayer7(String name, RangeOfInfluence range) {
super(name, range);
maxDepth = Config2.maxDepth;
maxNodes = Config2.maxNodes;
}
public ComputerPlayer7(final ComputerPlayer7 player) {
super(player);
}
@Override
public ComputerPlayer7 copy() {
return new ComputerPlayer7(this);
}
@Override
public void priority(Game game) {
logState(game);
if (logger.isDebugEnabled())
logger.debug("Game State: Turn-" + game.getTurnNum() + " Step-" + game.getTurn().getStepType() + " ActivePlayer-" + game.getPlayer(game.getActivePlayerId()).getName() + " PriorityPlayer-" + name);
game.firePriorityEvent(playerId);
switch (game.getTurn().getStepType()) {
case UPKEEP:
case DRAW:
pass();
break;
case PRECOMBAT_MAIN:
if (game.getActivePlayerId().equals(playerId)) {
System.out.println("Computer7:");
printOutState(game, playerId);
printOutState(game, game.getOpponents(playerId).iterator().next());
if (actions.size() == 0) {
calculatePreCombatActions(game);
}
act(game);
}
else
pass();
break;
case BEGIN_COMBAT:
pass();
break;
case DECLARE_ATTACKERS:
if (!game.getActivePlayerId().equals(playerId)) {
printOutState(game, playerId);
printOutState(game, game.getOpponents(playerId).iterator().next());
if (actions.size() == 0) {
calculatePreCombatActions(game);
}
act(game);
}
else
pass();
break;
case DECLARE_BLOCKERS:
case COMBAT_DAMAGE:
case END_COMBAT:
pass();
break;
case POSTCOMBAT_MAIN:
if (game.getActivePlayerId().equals(playerId)) {
printOutState(game, playerId);
printOutState(game, game.getOpponents(playerId).iterator().next());
if (actions.size() == 0) {
calculatePostCombatActions(game);
}
act(game);
}
else
pass();
break;
case END_TURN:
case CLEANUP:
pass();
break;
}
}
protected void calculatePreCombatActions(Game game) {
if (!getNextAction(game)) {
currentScore = GameStateEvaluator2.evaluate(playerId, game);
Game sim = createSimulation(game);
SimulationNode2.resetCount();
root = new SimulationNode2(null, sim, maxDepth, playerId);
logger.debug("simulating pre combat actions -----------------------------------------------------------------------------------------");
addActionsTimed(new FilterAbility());
if (root.children.size() > 0) {
root = root.children.get(0);
int bestScore = root.getScore();
if (bestScore > currentScore) {
actions = new LinkedList<Ability>(root.abilities);
combat = root.combat;
}
}
}
}
protected void calculatePostCombatActions(Game game) {
if (!getNextAction(game)) {
currentScore = GameStateEvaluator2.evaluate(playerId, game);
Game sim = createSimulation(game);
SimulationNode2.resetCount();
root = new SimulationNode2(null, sim, maxDepth, playerId);
logger.debug("simulating post combat actions ----------------------------------------------------------------------------------------");
addActionsTimed(new FilterAbility());
if (root.children.size() > 0) {
root = root.children.get(0);
int bestScore = root.getScore();
if (bestScore > currentScore) {
actions = new LinkedList<Ability>(root.abilities);
combat = root.combat;
}
}
}
}
@Override
protected int addActions(SimulationNode2 node, FilterAbility filter, int depth, int alpha, int beta) {
boolean stepFinished = false;
int val;
Game game = node.getGame();
if (Thread.interrupted()) {
Thread.currentThread().interrupt();
logger.debug("interrupted");
return GameStateEvaluator2.evaluate(playerId, game);
}
if (depth <= 0 || SimulationNode2.nodeCount > maxNodes || game.isGameOver()) {
logger.debug("simulating -- reached end state");
val = GameStateEvaluator2.evaluate(playerId, game);
}
else if (node.getChildren().size() > 0) {
logger.debug("simulating -- somthing added children:" + node.getChildren().size());
val = minimaxAB(node, filter, depth-1, alpha, beta);
}
else {
if (logger.isDebugEnabled())
logger.debug("simulating -- alpha: " + alpha + " beta: " + beta + " depth:" + depth + " step:" + game.getTurn().getStepType() + " for player:" + game.getPlayer(game.getPlayerList().get()).getName());
if (allPassed(game)) {
if (!game.getStack().isEmpty()) {
resolve(node, depth, game);
}
else {
stepFinished = true;
}
}
if (game.isGameOver()) {
val = GameStateEvaluator2.evaluate(playerId, game);
}
else if (stepFinished) {
logger.debug("step finished");
int testScore = GameStateEvaluator2.evaluate(playerId, game);
if (game.getActivePlayerId().equals(playerId)) {
if (testScore < currentScore) {
// if score at end of step is worse than original score don't check further
logger.debug("simulating -- abandoning check, no immediate benefit");
val = testScore;
}
else {
switch (game.getTurn().getStepType()) {
case PRECOMBAT_MAIN:
val = simulateCombat(game, node, depth-1, alpha, beta, false);
break;
case POSTCOMBAT_MAIN:
val = simulateCounterAttack(game, node, depth-1, alpha, beta);
break;
default:
val = GameStateEvaluator2.evaluate(playerId, game);
break;
}
}
}
else {
if (game.getTurn().getStepType() == PhaseStep.DECLARE_ATTACKERS)
val = simulateBlockers(game, node, playerId, depth-1, alpha, beta, true);
else
val = GameStateEvaluator2.evaluate(playerId, game);
}
}
else if (node.getChildren().size() > 0) {
logger.debug("simulating -- trigger added children:" + node.getChildren().size());
val = minimaxAB(node, filter, depth, alpha, beta);
}
else {
val = simulatePriority(node, game, filter, depth, alpha, beta);
}
}
if (logger.isDebugEnabled())
logger.debug("returning -- score: " + val + " depth:" + depth + " step:" + game.getTurn().getStepType() + " for player:" + game.getPlayer(node.getPlayerId()).getName());
return val;
}
protected int simulateCombat(Game game, SimulationNode2 node, int depth, int alpha, int beta, boolean counter) {
Integer val = null;
if (Thread.interrupted()) {
Thread.currentThread().interrupt();
logger.debug("interrupted");
return GameStateEvaluator2.evaluate(playerId, game);
}
if (game.getTurn().getStepType() != PhaseStep.DECLARE_BLOCKERS) {
game.getTurn().setPhase(new CombatPhase());
if (game.getPhase().beginPhase(game, game.getActivePlayerId())) {
simulateStep(game, new BeginCombatStep());
game.getPhase().setStep(new DeclareAttackersStep());
if (!game.getStep().skipStep(game, game.getActivePlayerId())) {
game.fireEvent(new GameEvent(GameEvent.EventType.DECLARE_ATTACKERS_STEP_PRE, null, null, game.getActivePlayerId()));
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARING_ATTACKERS, game.getActivePlayerId(), game.getActivePlayerId()))) {
val = simulateAttackers(game, node, game.getActivePlayerId(), depth, alpha, beta, counter);
}
}
else if (!counter) {
simulateToEnd(game);
val = simulatePostCombatMain(game, node, depth, alpha, beta);
}
}
}
else {
if (!game.getStep().skipStep(game, game.getActivePlayerId())) {
game.fireEvent(new GameEvent(GameEvent.EventType.DECLARE_BLOCKERS_STEP_PRE, null, null, game.getActivePlayerId()));
if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.DECLARING_BLOCKERS, game.getActivePlayerId(), game.getActivePlayerId()))) {
//only suitable for two player games - only simulates blocks for 1st defender
val = simulateBlockers(game, node, game.getCombat().getDefenders().iterator().next(), depth, alpha, beta, counter);
}
}
else if (!counter) {
finishCombat(game);
val = simulateCounterAttack(game, node, depth, alpha, beta);
}
}
if (val == null)
val = GameStateEvaluator2.evaluate(playerId, game);
if (logger.isDebugEnabled())
logger.debug("returning -- combat score: " + val + " depth:" + depth + " for player:" + game.getPlayer(node.getPlayerId()).getName());
return val;
}
protected int simulateAttackers(Game game, SimulationNode2 node, UUID attackerId, int depth, int alpha, int beta, boolean counter) {
if (Thread.interrupted()) {
Thread.currentThread().interrupt();
logger.debug("interrupted");
return GameStateEvaluator2.evaluate(playerId, game);
}
Integer val = null;
SimulationNode2 bestNode = null;
SimulatedPlayer2 attacker = (SimulatedPlayer2) game.getPlayer(attackerId);
if (logger.isDebugEnabled())
logger.debug(attacker.getName() + "'s possible attackers: " + attacker.getAvailableAttackers(game));
for (Combat engagement: attacker.addAttackers(game)) {
if (alpha >= beta) {
logger.debug("simulating -- pruning attackers");
break;
}
Game sim = game.copy();
UUID defenderId = game.getOpponents(attackerId).iterator().next();
for (CombatGroup group: engagement.getGroups()) {
for (UUID attackId: group.getAttackers()) {
sim.getPlayer(attackerId).declareAttacker(attackId, defenderId, sim);
}
}
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_ATTACKERS, attackerId, attackerId));
SimulationNode2 newNode = new SimulationNode2(node, sim, depth, attackerId);
if (logger.isDebugEnabled())
logger.debug("simulating attack for player:" + game.getPlayer(attackerId).getName());
sim.checkStateAndTriggered();
while (!sim.getStack().isEmpty()) {
sim.getStack().resolve(sim);
logger.debug("resolving triggered abilities");
sim.applyEffects();
}
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARE_ATTACKERS_STEP_POST, sim.getActivePlayerId(), sim.getActivePlayerId()));
Combat simCombat = sim.getCombat().copy();
sim.getPhase().setStep(new DeclareBlockersStep());
val = simulateCombat(sim, newNode, depth-1, alpha, beta, counter);
if (!attackerId.equals(playerId)) {
if (val < beta) {
beta = val;
bestNode = newNode;
bestNode.setScore(val);
node.setCombat(simCombat);
}
}
else {
if (val > alpha) {
alpha = val;
bestNode = newNode;
bestNode.setScore(val);
node.setCombat(simCombat);
}
}
}
if (val == null)
val = GameStateEvaluator2.evaluate(playerId, game);
if (bestNode != null) {
node.children.clear();
node.children.add(bestNode);
node.setScore(bestNode.getScore());
}
if (logger.isDebugEnabled())
logger.debug("returning -- combat attacker score: " + val + " depth:" + depth + " for player:" + game.getPlayer(node.getPlayerId()).getName());
return val;
}
protected int simulateBlockers(Game game, SimulationNode2 node, UUID defenderId, int depth, int alpha, int beta, boolean counter) {
if (Thread.interrupted()) {
Thread.currentThread().interrupt();
logger.debug("interrupted");
return GameStateEvaluator2.evaluate(playerId, game);
}
Integer val = null;
SimulationNode2 bestNode = null;
//check if defender is being attacked
if (game.getCombat().isAttacked(defenderId, game)) {
SimulatedPlayer2 defender = (SimulatedPlayer2) game.getPlayer(defenderId);
if (logger.isDebugEnabled())
logger.debug(defender.getName() + "'s possible blockers: " + defender.getAvailableBlockers(game));
for (Combat engagement: defender.addBlockers(game)) {
if (alpha >= beta) {
logger.debug("simulating -- pruning blockers");
break;
}
Game sim = game.copy();
for (CombatGroup group: engagement.getGroups()) {
if (group.getAttackers().size() > 0) {
UUID attackerId = group.getAttackers().get(0);
for (UUID blockerId: group.getBlockers()) {
sim.getPlayer(defenderId).declareBlocker(blockerId, attackerId, sim);
}
}
}
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARED_BLOCKERS, defenderId, defenderId));
SimulationNode2 newNode = new SimulationNode2(node, sim, depth, defenderId);
if (logger.isDebugEnabled())
logger.debug("simulating block for player:" + game.getPlayer(defenderId).getName());
sim.checkStateAndTriggered();
while (!sim.getStack().isEmpty()) {
sim.getStack().resolve(sim);
logger.debug("resolving triggered abilities");
sim.applyEffects();
}
sim.fireEvent(GameEvent.getEvent(GameEvent.EventType.DECLARE_BLOCKERS_STEP_POST, sim.getActivePlayerId(), sim.getActivePlayerId()));
Combat simCombat = sim.getCombat().copy();
finishCombat(sim);
if (sim.isGameOver()) {
val = GameStateEvaluator2.evaluate(playerId, sim);
}
else if (!counter) {
val = simulatePostCombatMain(sim, newNode, depth-1, alpha, beta);
}
else
val = GameStateEvaluator2.evaluate(playerId, sim);
if (!defenderId.equals(playerId)) {
if (val < beta) {
beta = val;
bestNode = newNode;
bestNode.setScore(val);
node.setCombat(simCombat);
}
}
else {
if (val > alpha) {
alpha = val;
bestNode = newNode;
node.setCombat(simCombat);
}
}
}
}
if (val == null)
val = GameStateEvaluator2.evaluate(playerId, game);
if (bestNode != null) {
node.children.clear();
node.children.add(bestNode);
node.setScore(bestNode.getScore());
}
if (logger.isDebugEnabled())
logger.debug("returning -- combat blocker score: " + val + " depth:" + depth + " for player:" + game.getPlayer(node.getPlayerId()).getName());
return val;
}
protected int simulateCounterAttack(Game game, SimulationNode2 node, int depth, int alpha, int beta) {
if (Thread.interrupted()) {
Thread.currentThread().interrupt();
logger.debug("interrupted");
return GameStateEvaluator2.evaluate(playerId, game);
}
Integer val = null;
if (!game.isGameOver()) {
simulateToEnd(game);
game.getState().setActivePlayerId(game.getState().getPlayerList(game.getActivePlayerId()).getNext());
logger.debug("simulating -- counter attack for player " + game.getPlayer(game.getActivePlayerId()).getName());
game.getTurn().setPhase(new BeginningPhase());
if (game.getPhase().beginPhase(game, game.getActivePlayerId())) {
simulateStep(game, new UntapStep());
simulateStep(game, new UpkeepStep());
simulateStep(game, new DrawStep());
game.getPhase().endPhase(game, game.getActivePlayerId());
}
val = simulateCombat(game, node, depth-1, alpha, beta, true);
if (logger.isDebugEnabled())
logger.debug("returning -- counter attack score: " + val + " depth:" + depth + " for player:" + game.getPlayer(node.getPlayerId()).getName());
}
if (val == null)
val = GameStateEvaluator2.evaluate(playerId, game);
return val;
}
protected void simulateStep(Game game, Step step) {
if (Thread.interrupted()) {
Thread.currentThread().interrupt();
logger.debug("interrupted");
return;
}
if (!game.isGameOver()) {
game.getPhase().setStep(step);
if (!step.skipStep(game, game.getActivePlayerId())) {
step.beginStep(game, game.getActivePlayerId());
game.checkStateAndTriggered();
while (!game.getStack().isEmpty()) {
game.getStack().resolve(game);
game.applyEffects();
}
step.endStep(game, game.getActivePlayerId());
}
}
}
protected void finishCombat(Game game) {
if (Thread.interrupted()) {
Thread.currentThread().interrupt();
logger.debug("interrupted");
return;
}
simulateStep(game, new CombatDamageStep(true));
simulateStep(game, new CombatDamageStep(false));
simulateStep(game, new EndOfCombatStep());
}
protected int simulatePostCombatMain(Game game, SimulationNode2 node, int depth, int alpha, int beta) {
if (Thread.interrupted()) {
Thread.currentThread().interrupt();
logger.debug("interrupted");
return GameStateEvaluator2.evaluate(playerId, game);
}
logger.debug("simulating -- post combat main");
game.getTurn().setPhase(new PostCombatMainPhase());
if (game.getPhase().beginPhase(game, game.getActivePlayerId())) {
game.getPhase().setStep(new PostCombatMainStep());
game.getStep().beginStep(game, playerId);
game.getPlayers().resetPassed();
return addActions(node, new FilterAbility(), depth, alpha, beta);
}
return simulateCounterAttack(game, node, depth, alpha, beta);
}
protected void simulateToEnd(Game game) {
if (Thread.interrupted()) {
Thread.currentThread().interrupt();
logger.debug("interrupted");
return;
}
if (!game.isGameOver()) {
game.getTurn().getPhase().endPhase(game, game.getActivePlayerId());
game.getTurn().setPhase(new EndPhase());
if (game.getTurn().getPhase().beginPhase(game, game.getActivePlayerId())) {
simulateStep(game, new EndStep());
simulateStep(game, new CleanupStep());
}
}
}
}

View file

@ -218,6 +218,7 @@ public class ComputerPlayer2 extends ComputerPlayer<ComputerPlayer2> implements
protected int minimaxAB(SimulationNode node, FilterAbility filter, int depth, int alpha, int beta) {
UUID currentPlayerId = node.getGame().getPlayerList().get();
SimulationNode bestChild = null;
boolean isSimulatedPlayer = currentPlayerId.equals(playerId);
for (SimulationNode child: node.getChildren()) {
if (alpha >= beta) {
logger.debug("alpha beta pruning");
@ -228,27 +229,33 @@ public class ComputerPlayer2 extends ComputerPlayer<ComputerPlayer2> implements
break;
}
int val = addActions(child, filter, depth-1, alpha, beta);
if (!currentPlayerId.equals(playerId)) {
if (!isSimulatedPlayer) {
if (val < beta) {
beta = val;
bestChild = child;
// if (node.getCombat() == null)
node.setCombat(child.getCombat());
node.setCombat(child.getCombat());
}
if (val == GameStateEvaluator.LOSE_SCORE) {
logger.debug("simulating -- lose, can't do worse than this");
break;
}
}
else {
if (val > alpha) {
alpha = val;
bestChild = child;
// if (node.getCombat() == null)
node.setCombat(child.getCombat());
node.setCombat(child.getCombat());
}
if (val == GameStateEvaluator.WIN_SCORE) {
logger.debug("simulating -- win, can't do better than this");
break;
}
}
}
node.children.clear();
if (bestChild != null)
node.children.add(bestChild);
if (!currentPlayerId.equals(playerId)) {
if (!isSimulatedPlayer) {
logger.debug("returning minimax beta: " + beta);
return beta;
}
@ -380,6 +387,7 @@ public class ComputerPlayer2 extends ComputerPlayer<ComputerPlayer2> implements
}
node.setGameValue(game.getState().getValue());
SimulatedPlayer currentPlayer = (SimulatedPlayer) game.getPlayer(game.getPlayerList().get());
boolean isSimulatedPlayer = currentPlayer.getId().equals(playerId);
logger.debug("simulating -- player " + currentPlayer.getName());
SimulationNode bestNode = null;
List<Ability> allActions = currentPlayer.simulatePriority(game, filter);
@ -401,12 +409,16 @@ public class ComputerPlayer2 extends ComputerPlayer<ComputerPlayer2> implements
logger.debug("simulating -- node #:" + SimulationNode.getCount() + " actions:" + action);
sim.checkStateAndTriggered();
int val = addActions(newNode, filter, depth-1, alpha, beta);
if (!currentPlayer.getId().equals(playerId)) {
if (!isSimulatedPlayer) {
if (val < beta) {
beta = val;
bestNode = newNode;
node.setCombat(newNode.getCombat());
}
if (val == GameStateEvaluator.LOSE_SCORE) {
logger.debug("simulating -- lose, can't do worse than this");
break;
}
}
else {
if (val > alpha) {
@ -418,6 +430,10 @@ public class ComputerPlayer2 extends ComputerPlayer<ComputerPlayer2> implements
if (node.getChoices().size() > 0)
choices = node.getChoices();
}
if (val == GameStateEvaluator.WIN_SCORE) {
logger.debug("simulating -- win, can't do better than this");
break;
}
}
if (alpha >= beta) {
logger.debug("simulating -- pruning");
@ -433,7 +449,7 @@ public class ComputerPlayer2 extends ComputerPlayer<ComputerPlayer2> implements
node.children.clear();
node.children.add(bestNode);
}
if (!currentPlayer.getId().equals(playerId)) {
if (!isSimulatedPlayer) {
logger.debug("returning priority beta: " + beta);
return beta;
}
@ -630,7 +646,7 @@ public class ComputerPlayer2 extends ComputerPlayer<ComputerPlayer2> implements
@Override
public void selectAttackers(Game game) {
if (logger.isDebugEnabled() && combat == null || combat.getGroups().isEmpty())
if (logger.isDebugEnabled() && (combat == null || combat.getGroups().isEmpty()))
logger.debug("not attacking");
if (combat != null) {
UUID opponentId = game.getCombat().getDefenders().iterator().next();

View file

@ -298,7 +298,6 @@ public class ComputerPlayer3 extends ComputerPlayer2 implements Player {
}
else if (!counter) {
finishCombat(game);
// val = GameStateEvaluator.evaluate(playerId, game);
val = simulateCounterAttack(game, node, depth, alpha, beta);
}
}

View file

@ -59,14 +59,17 @@ public class GameStateEvaluator {
private static final int CREATURE_FACTOR = Config.evaluatorCreatureFactor;
private static final int HAND_FACTOR = Config.evaluatorHandFactor;
public static final int WIN_SCORE = Integer.MAX_VALUE - 1;
public static final int LOSE_SCORE = Integer.MIN_VALUE + 1;
public static int evaluate(UUID playerId, Game game) {
Player player = game.getPlayer(playerId);
Player opponent = game.getPlayer(game.getOpponents(playerId).iterator().next());
if (game.isGameOver()) {
if (player.hasLost() || opponent.hasWon())
return Integer.MIN_VALUE + 1;
return LOSE_SCORE;
if (opponent.hasLost() || player.hasWon())
return Integer.MAX_VALUE - 1;
return WIN_SCORE;
}
int lifeScore = (player.getLife() - opponent.getLife()) * LIFE_FACTOR;
int permanentScore = 0;

View file

@ -0,0 +1,116 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.keyword.InfectAbility;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreatureOrPlayer;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author ayratn
*/
public class BurntheImpure extends CardImpl<BurntheImpure> {
public BurntheImpure (UUID ownerId) {
super(ownerId, 59, "Burn the Impure", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{R}");
this.expansionSetCode = "MBS";
this.color.setRed(true);
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addEffect(new BurntheImpureEffect(3));
}
public BurntheImpure (final BurntheImpure card) {
super(card);
}
@Override
public BurntheImpure copy() {
return new BurntheImpure(this);
}
public class BurntheImpureEffect extends OneShotEffect<BurntheImpureEffect> {
protected int amount;
public BurntheImpureEffect(int amount) {
super(Constants.Outcome.Damage);
this.amount = amount;
}
public int getAmount() {
return amount;
}
public BurntheImpureEffect(final BurntheImpureEffect effect) {
super(effect);
this.amount = effect.amount;
}
@Override
public BurntheImpureEffect copy() {
return new BurntheImpureEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
permanent.damage(amount, source.getId(), game, true, false);
if (permanent.getAbilities().contains(InfectAbility.getInstance())) {
Player controller = game.getPlayer(permanent.getControllerId());
if (controller != null) {
controller.damage(amount, source.getId(), game, true, false);
}
}
return true;
}
return false;
}
@Override
public String getText(Ability source) {
return "Burn the Impure deals 3 damage to target creature. If that creature has infect, Burn the Impure deals 3 damage to that creature's controller.";
}
}
}

View file

@ -0,0 +1,66 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.PutIntoGraveFromBattlefieldTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.continious.GainProtectionFromColorTargetEffect;
import mage.cards.CardImpl;
/**
*
* @author ayratn
*/
public class IchorWellspring extends CardImpl<IchorWellspring> {
public IchorWellspring (UUID ownerId) {
super(ownerId, 110, "Ichor Wellspring", Rarity.COMMON, new CardType[]{CardType.ARTIFACT}, "{2}");
this.expansionSetCode = "MBS";
this.addAbility(new EntersBattlefieldTriggeredAbility(new DrawCardControllerEffect(1)));
this.addAbility(new PutIntoGraveFromBattlefieldTriggeredAbility(new DrawCardControllerEffect(1)));
}
public IchorWellspring (final IchorWellspring card) {
super(card);
}
@Override
public IchorWellspring copy() {
return new IchorWellspring(this);
}
}

View file

@ -0,0 +1,66 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.common.AttacksEachTurnStaticAbility;
import mage.abilities.keyword.BattleCryAbility;
import mage.cards.CardImpl;
/**
*
* @author ayratn
*/
public class KuldothaRingleader extends CardImpl<KuldothaRingleader> {
public KuldothaRingleader (UUID ownerId) {
super(ownerId, 70, "Kuldotha Ringleader", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{R}");
this.expansionSetCode = "MBS";
this.subtype.add("Giant");
this.subtype.add("Berserker");
this.color.setRed(true);
this.power = new MageInt(4);
this.toughness = new MageInt(4);
this.addAbility(new BattleCryAbility());
this.addAbility(new AttacksEachTurnStaticAbility());
}
public KuldothaRingleader (final KuldothaRingleader card) {
super(card);
}
@Override
public KuldothaRingleader copy() {
return new KuldothaRingleader(this);
}
}

View file

@ -0,0 +1,84 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.MageInt;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.InfectAbility;
import mage.abilities.keyword.ProtectionAbility;
import mage.abilities.mana.ColorlessManaAbility;
import mage.cards.CardImpl;
import mage.filter.FilterCard;
/**
*
* @author Viserion
*/
public class PhyrexianCrusader extends CardImpl<PhyrexianCrusader> {
private static FilterCard filter = new FilterCard("Red");
private static FilterCard filter2 = new FilterCard("White");
static {
filter.setUseColor(true);
filter.getColor().setRed(true);
filter2.setUseColor(true);
filter2.getColor().setWhite(true);
}
public PhyrexianCrusader (UUID ownerId) {
super(ownerId, 50, "Phyrexian Crusader", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{B}{B}");
this.expansionSetCode = "MBS";
this.subtype.add("Zombie");
this.subtype.add("Knight");
this.color.setBlack(true);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
this.addAbility(FirstStrikeAbility.getInstance());
this.addAbility(new ProtectionAbility(filter));
this.addAbility(new ProtectionAbility(filter2));
this.addAbility(InfectAbility.getInstance());
}
public PhyrexianCrusader (final PhyrexianCrusader card) {
super(card);
}
@Override
public PhyrexianCrusader copy() {
return new PhyrexianCrusader(this);
}
}

View file

@ -0,0 +1,110 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.common.OnEventTriggeredAbility;
import mage.abilities.keyword.InfectAbility;
import mage.cards.CardImpl;
import mage.game.events.GameEvent.EventType;
import mage.Constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.counters.CounterType;
import mage.game.Game;
import mage.players.Player;
/**
*
* @author Viserion
*/
public class PhyrexianVatmother extends CardImpl<PhyrexianVatmother> {
public PhyrexianVatmother (UUID ownerId) {
super(ownerId, 52, "Phyrexian Vatmother", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{2}{B}{B}");
this.expansionSetCode = "MBS";
this.subtype.add("Horror");
this.color.setBlack(true);
this.power = new MageInt(4);
this.toughness = new MageInt(5);
this.addAbility(InfectAbility.getInstance());
this.addAbility(new OnEventTriggeredAbility(EventType.UPKEEP_STEP_PRE, "beginning of your upkeep", new PoisonControllerEffect(1)));
}
public PhyrexianVatmother (final PhyrexianVatmother card) {
super(card);
}
@Override
public PhyrexianVatmother copy() {
return new PhyrexianVatmother(this);
}
}
class PoisonControllerEffect extends OneShotEffect<PoisonControllerEffect> {
protected int amount;
public PoisonControllerEffect(int amount) {
super(Outcome.Damage);
this.amount = amount;
}
public PoisonControllerEffect(final PoisonControllerEffect effect) {
super(effect);
this.amount = effect.amount;
}
@Override
public PoisonControllerEffect copy() {
return new PoisonControllerEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.getCounters().addCounter(CounterType.POISON.createInstance(amount));
return true;
}
return false;
}
@Override
public String getText(Ability source) {
StringBuilder sb = new StringBuilder();
sb.append("you get ").append(Integer.toString(amount)).append(" poison counter(s)");
return sb.toString();
}
}

View file

@ -0,0 +1,124 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.continious.BoostEquippedEffect;
import mage.abilities.effects.common.DiscardTargetEffect;
import mage.abilities.effects.common.UntapAllLandsControllerEffect;
import mage.abilities.effects.common.continious.GainAbilityAttachedEffect;
import mage.abilities.keyword.EquipAbility;
import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.game.events.DamagedPlayerEvent;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.TargetPlayer;
/**
*
* @author Viserion
*/
public class SwordOfFeastAndFamine extends CardImpl<SwordOfFeastAndFamine> {
private static FilterCard filter = new FilterCard("green and from black");
static {
filter.setUseColor(true);
filter.getColor().setBlack(true);
filter.getColor().setGreen(true);
filter.setScopeColor(Filter.ComparisonScope.Any);
}
public SwordOfFeastAndFamine (UUID ownerId) {
super(ownerId, 138, "Sword of Feast and Famine", Rarity.MYTHIC, new CardType[]{CardType.ARTIFACT}, "{3}");
this.expansionSetCode = "MBS";
this.subtype.add("Equipment");
this.addAbility(new EquipAbility(Constants.Outcome.AddAbility, new GenericManaCost(2)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(2, 2)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(new ProtectionAbility(filter), Constants.AttachmentType.EQUIPMENT)));
this.addAbility(new SwordOfFeastAndFamineAbility());
}
public SwordOfFeastAndFamine (final SwordOfFeastAndFamine card) {
super(card);
}
@Override
public SwordOfFeastAndFamine copy() {
return new SwordOfFeastAndFamine(this);
}
}
class SwordOfFeastAndFamineAbility extends TriggeredAbilityImpl<SwordOfFeastAndFamineAbility> {
public SwordOfFeastAndFamineAbility() {
super(Zone.BATTLEFIELD, new DiscardTargetEffect(1));
this.addEffect(new UntapAllLandsControllerEffect());
this.addTarget(new TargetPlayer());
}
public SwordOfFeastAndFamineAbility(final SwordOfFeastAndFamineAbility ability) {
super(ability);
}
@Override
public SwordOfFeastAndFamineAbility copy() {
return new SwordOfFeastAndFamineAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event instanceof DamagedPlayerEvent) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent)event;
Permanent p = game.getPermanent(event.getSourceId());
if (damageEvent.isCombatDamage() && p != null && p.getAttachments().contains(this.getSourceId())) {
this.targets.get(0).add(event.getPlayerId(), game);
return true;
}
}
return false;
}
@Override
public String getRule() {
return "Whenever equipped creature deals combat damage to a player, that player discards a card and you untap all lands you control.";
}
}

View file

@ -51,7 +51,7 @@ public class ViridianClaw extends CardImpl<ViridianClaw> {
super(ownerId, 143, "Viridian Claw", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT}, "{2}");
this.expansionSetCode = "MBS";
this.subtype.add("Equipment");
this.addAbility(new EquipAbility(Constants.Outcome.AddAbility, new GenericManaCost(3)));
this.addAbility(new EquipAbility(Constants.Outcome.AddAbility, new GenericManaCost(1)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(1, 0)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), Constants.AttachmentType.EQUIPMENT)));
}

View file

@ -0,0 +1,127 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.riseoftheeldrazi;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Outcome;
import mage.Constants.Rarity;
import mage.Constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.filter.Filter.ComparisonScope;
import mage.filter.Filter.ComparisonType;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.TargetPlayer;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class InquisitionOfKozilek extends CardImpl<InquisitionOfKozilek> {
public InquisitionOfKozilek(UUID ownerId){
super(ownerId, 115, "Inquisition of Kozilek", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY},"{B}");
this.expansionSetCode = "ROE";
this.color.setBlack(true);
this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addEffect(new InquisitionOfKozilekEffect());
}
public InquisitionOfKozilek(final InquisitionOfKozilek card) {
super(card);
}
@Override
public InquisitionOfKozilek copy() {
return new InquisitionOfKozilek(this);
}
@Override
public String getArt() {
return "122154_typ_reg_sty_010.jpg";
}
}
class InquisitionOfKozilekEffect extends OneShotEffect<InquisitionOfKozilekEffect> {
private static FilterCard filter = new FilterCard("nonland card with converted mana cost 3 or less");
static {
filter.getCardType().add(CardType.LAND);
filter.setScopeCardType(ComparisonScope.Any);
filter.setNotCardType(true);
filter.setConvertedManaCost(4);
filter.setConvertedManaCostComparison(ComparisonType.LessThan);
}
public InquisitionOfKozilekEffect() {
super(Outcome.Discard);
}
public InquisitionOfKozilekEffect(final InquisitionOfKozilekEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget());
if (player != null) {
player.revealCards("Inquisition of Kozilek", player.getHand(), game);
Player you = game.getPlayer(source.getControllerId());
if (you != null) {
TargetCard target = new TargetCard(Zone.PICK, filter);
if (you.choose(player.getHand(), target, game)) {
Card card = player.getHand().get(target.getFirstTarget(), game);
if (card != null) {
return player.discard(card, source, game);
}
}
}
}
return false;
}
@Override
public InquisitionOfKozilekEffect copy() {
return new InquisitionOfKozilekEffect(this);
}
@Override
public String getText(Ability source) {
return "Target player reveals his or her hand. You choose a nonland card from it with converted mana cost 3 or less. That player discards that card";
}
}

View file

@ -0,0 +1,110 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.scarsofmirrodin;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.ProliferateEffect;
import mage.cards.CardImpl;
import mage.counters.CounterType;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPlayer;
/**
*
* @author Loki
*/
public class ContagionEngine extends CardImpl<ContagionEngine> {
public ContagionEngine (UUID ownerId) {
super(ownerId, 145, "Contagion Engine", Rarity.RARE, new CardType[]{CardType.ARTIFACT}, "{6}");
this.expansionSetCode = "SOM";
Ability ability = new EntersBattlefieldTriggeredAbility(new ContagionEngineEffect());
ability.addTarget(new TargetPlayer());
this.addAbility(ability);
ability = new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new ProliferateEffect(), new GenericManaCost(4));
ability.addCost(new TapSourceCost());
ability.addEffect(new ProliferateEffect());
this.addAbility(ability);
}
public ContagionEngine (final ContagionEngine card) {
super(card);
}
@Override
public ContagionEngine copy() {
return new ContagionEngine(this);
}
}
class ContagionEngineEffect extends OneShotEffect<ContagionEngineEffect> {
ContagionEngineEffect() {
super(Constants.Outcome.UnboostCreature);
}
ContagionEngineEffect(final ContagionEngineEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player target = game.getPlayer(source.getFirstTarget());
if (target != null) {
for (Permanent p : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), target.getId())) {
p.getCounters().addCounter(CounterType.M1M1.createInstance());
}
return true;
}
return false;
}
@Override
public ContagionEngineEffect copy() {
return new ContagionEngineEffect(this);
}
@Override
public String getText(Ability source) {
return "put a -1/-1 counter on each creature target player controls";
}
}

View file

@ -0,0 +1,102 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.scarsofmirrodin;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.continious.BoostSourceEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
/**
*
* @author Loki
*/
public class MolderBeast extends CardImpl<MolderBeast> {
public MolderBeast (UUID ownerId) {
super(ownerId, 125, "Molder Beast", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{G}");
this.expansionSetCode = "SOM";
this.subtype.add("Beast");
this.color.setGreen(true);
this.power = new MageInt(5);
this.toughness = new MageInt(3);
this.addAbility(new MolderBeastTriggeredAbility());
}
public MolderBeast (final MolderBeast card) {
super(card);
}
@Override
public MolderBeast copy() {
return new MolderBeast(this);
}
}
class MolderBeastTriggeredAbility extends TriggeredAbilityImpl<MolderBeastTriggeredAbility> {
MolderBeastTriggeredAbility() {
super(Constants.Zone.BATTLEFIELD, new BoostSourceEffect(2, 0, Constants.Duration.EndOfTurn));
}
MolderBeastTriggeredAbility(final MolderBeastTriggeredAbility ability) {
super(ability);
}
@Override
public MolderBeastTriggeredAbility copy() {
return new MolderBeastTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD && zEvent.getTarget().getCardType().contains(CardType.ARTIFACT)) {
return true;
}
}
return false;
}
@Override
public String getRule() {
return "Whenever an artifact is put into a graveyard from the battlefield, Molder Beast gets +2/+0 until end of turn.";
}
}

View file

@ -87,7 +87,7 @@ class ThrummingbirdTriggeredAbility extends TriggeredAbilityImpl<ThrummingbirdTr
if (event instanceof DamagedPlayerEvent) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent p = game.getPermanent(event.getSourceId());
if (damageEvent.isCombatDamage() && p != null && p.getId().equals(event.getSourceId())) {
if (damageEvent.isCombatDamage() && p != null && p.getId().equals(this.getSourceId())) {
return true;
}
}

View file

@ -0,0 +1,96 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.scarsofmirrodin;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.continious.BoostSourceEffect;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
/**
*
* @author Loki
*/
public class ViridianRevel extends CardImpl<ViridianRevel> {
public ViridianRevel (UUID ownerId) {
super(ownerId, 132, "Viridian Revel", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}{G}");
this.expansionSetCode = "SOM";
this.color.setGreen(true);
this.addAbility(new ViridianRevelTriggeredAbility());
}
public ViridianRevel (final ViridianRevel card) {
super(card);
}
@Override
public ViridianRevel copy() {
return new ViridianRevel(this);
}
}
class ViridianRevelTriggeredAbility extends TriggeredAbilityImpl<ViridianRevelTriggeredAbility> {
ViridianRevelTriggeredAbility() {
super(Constants.Zone.BATTLEFIELD, new DrawCardControllerEffect(1), true);
}
ViridianRevelTriggeredAbility(final ViridianRevelTriggeredAbility ability) {
super(ability);
}
@Override
public ViridianRevelTriggeredAbility copy() {
return new ViridianRevelTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
if (zEvent.getFromZone() == Constants.Zone.BATTLEFIELD && zEvent.getToZone() == Constants.Zone.GRAVEYARD && game.getOpponents(this.getControllerId()).contains(zEvent.getPlayerId())) {
return true;
}
}
return false;
}
@Override
public String getRule() {
return "Whenever an artifact is put into an opponent's graveyard from the battlefield, you may draw a card.";
}
}

View file

@ -0,0 +1,122 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.shardsofalara;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AttacksTriggeredAbility;
import mage.abilities.costs.VariableCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetCreatureOrPlayer;
/**
* @author Loki
*/
public class FlameblastDragon extends CardImpl<FlameblastDragon> {
public FlameblastDragon(UUID ownerId) {
super(ownerId, 100, "Flameblast Dragon", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{4}{R}{R}");
this.expansionSetCode = "ALA";
this.subtype.add("Dragon");
this.color.setRed(true);
this.power = new MageInt(5);
this.toughness = new MageInt(5);
this.addAbility(FlyingAbility.getInstance());
Ability ability = new AttacksTriggeredAbility(new FlameblastDragonEffect(), false);
ability.addTarget(new TargetCreatureOrPlayer());
this.addAbility(ability);
}
public FlameblastDragon(final FlameblastDragon card) {
super(card);
}
@Override
public FlameblastDragon copy() {
return new FlameblastDragon(this);
}
}
class FlameblastDragonEffect extends OneShotEffect<FlameblastDragonEffect> {
FlameblastDragonEffect() {
super(Constants.Outcome.Benefit);
}
FlameblastDragonEffect(final FlameblastDragonEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
ManaCosts cost = new ManaCostsImpl("{X}{R}");
if (player != null) {
if (player.chooseUse(Constants.Outcome.Damage, "Pay " + cost.getText() + "? If you do, Flameblast Dragon deals X damage to target creature or player", game)) {
cost.clearPaid();
if (cost.pay(game, source.getId(), source.getControllerId(), false)) {
int costX = ((VariableCost) cost.getVariableCosts().get(0)).getAmount();
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
permanent.damage(costX, source.getId(), game, true, false);
return true;
}
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null) {
targetPlayer.damage(costX, source.getId(), game, true, false);
return true;
}
return false;
}
}
}
return false;
}
@Override
public FlameblastDragonEffect copy() {
return new FlameblastDragonEffect(this);
}
@Override
public String getText(Ability source) {
return "you may pay {X}{R}. If you do, Flameblast Dragon deals X damage to target creature or player";
}
}

View file

@ -0,0 +1,86 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.shardsofalara;
import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
import mage.game.permanent.token.Token;
/**
*
* @author Loki
*/
public class Godsire extends CardImpl<Godsire> {
public Godsire (UUID ownerId) {
super(ownerId, 170, "Godsire", Rarity.MYTHIC, new CardType[]{CardType.CREATURE}, "{4}{R}{G}{G}{W}");
this.expansionSetCode = "ALA";
this.subtype.add("Beast");
this.color.setRed(true);
this.color.setGreen(true);
this.color.setWhite(true);
this.power = new MageInt(8);
this.toughness = new MageInt(8);
this.addAbility(VigilanceAbility.getInstance());
this.addAbility(new SimpleActivatedAbility(Constants.Zone.BATTLEFIELD, new CreateTokenEffect(new BeastToken()), new TapSourceCost()));
}
public Godsire (final Godsire card) {
super(card);
}
@Override
public Godsire copy() {
return new Godsire(this);
}
}
class BeastToken extends Token {
BeastToken() {
super("Beast", "an 8/8 Beast creature token that's red, green, and white");
cardType.add(CardType.CREATURE);
color.setGreen(true);
color.setWhite(true);
color.setRed(true);
subtype.add("Beast");
power = new MageInt(8);
toughness = new MageInt(8);
}
}

View file

@ -0,0 +1,72 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.zendikar;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.ReturnToHandTargetEffect;
import mage.abilities.keyword.KickerAbility;
import mage.cards.CardImpl;
import mage.target.common.TargetNonlandPermanent;
/**
*
* @author Viserion
*/
public class IntoTheRoil extends CardImpl<IntoTheRoil> {
public IntoTheRoil(UUID ownerId) {
super(ownerId, 48, "Into the Roil", Rarity.COMMON, new CardType[]{CardType.INSTANT}, "{1}{U}");
this.expansionSetCode = "ZEN";
this.color.setBlue(true);
this.getSpellAbility().addTarget(new TargetNonlandPermanent());
this.getSpellAbility().addEffect(new ReturnToHandTargetEffect());
KickerAbility ability = new KickerAbility(new DrawCardControllerEffect(1), false);
ability.addManaCost(new ManaCostsImpl("{1}{U}"));
this.addAbility(ability);
}
public IntoTheRoil(final IntoTheRoil card) {
super(card);
}
@Override
public IntoTheRoil copy() {
return new IntoTheRoil(this);
}
@Override
public String getArt() {
return "123560_typ_reg_sty_010.jpg";
}
}

View file

@ -4,7 +4,7 @@
<server serverAddress="localhost" serverName="mage-server" port="17171" maxGameThreads="10" maxSecondsIdle="600"/>
<playerTypes>
<playerType name="Computer - minimax hybrid" jar="mage-player-aiminimax.jar" className="mage.player.ai.ComputerPlayer3"/>
<playerType name="Computer - mad" jar="mage-player-ai-ma.jar" className="mage.player.ai.ComputerPlayer6"/>
<playerType name="Computer - mad" jar="mage-player-ai-ma.jar" className="mage.player.ai.ComputerPlayer7"/>
</playerTypes>
<gameTypes>
<gameType name="Two Player Duel" jar="mage-game-twoplayerduel.jar" className="mage.game.TwoPlayerMatch" typeName="mage.game.TwoPlayerDuelType"/>

View file

@ -1,7 +1,9 @@
# Test playing Lightning Bolts (there was a bug with targeting players)
### ComputerA ###
# Battlefield
battlefield:ComputerA:Mountain:1
#battlefield:ComputerA:Goblin Guide:1
# Hand
hand:ComputerA:Mountain:2
hand:ComputerA:Lightning Bolt:5

View file

@ -1,22 +1,36 @@
# Reproduces game where AI didn't attack though could win
### ComputerA ###
# Battlefield
battlefield:ComputerA:Island:2
battlefield:ComputerA:Mountain:2
battlefield:ComputerA:Mountain:3
battlefield:ComputerA:Lavaclaw Reaches:2
battlefield:ComputerA:Dragonskull Summit:1
# Hand
hand:ComputerA:Mountain:0
hand:ComputerA:Hellspark Elemental:5
hand:ComputerA:Searing Blaze:1
hand:ComputerA:Lavaclaw Reaches:1
# Library
# from down to top
library:ComputerA:clear:0
library:ComputerA:Hellspark Elemental:10
library:ComputerA:Mountain:10
# Life
player:ComputerA:life:3
### ComputerB ###
# Battlefield
battlefield:ComputerB:Plains:1
battlefield:ComputerB:Mountain:4:{tapped}
battlefield:ComputerB:Dragonskull Summit:1:{tapped}
battlefield:ComputerB:Arid Mesa:1:{tapped}
battlefield:ComputerB:Lavaclaw Reaches:1:{tapped}
# Hand
hand:ComputerB:Plains:2
hand:ComputerB:Ball Lightning:2
# Library
# from down to top
library:ComputerB:clear:0
library:ComputerB:Plains:10
library:ComputerB:Lightning Bolt:10
library:ComputerB:Mountain:1
# Life
player:ComputerB:life:1

View file

@ -1,3 +1,5 @@
# Test attacking with Hellspark Elemental
### ComputerA ###
# Battlefield
battlefield:ComputerA:Island:2

View file

@ -1,3 +1,5 @@
# Test playing Blightning
### ComputerA ###
# Battlefield
battlefield:ComputerA:Swamp:1

36
Mage.Tests/scenario8.txt Normal file
View file

@ -0,0 +1,36 @@
# This scenario makes AI frozen
### ComputerA ###
# Battlefield
battlefield:ComputerA:Mountain:3
battlefield:ComputerA:Lavaclaw Reaches:2
battlefield:ComputerA:Dragonskull Summit:1
# Hand
hand:ComputerA:Searing Blaze:1
hand:ComputerA:Lavaclaw Reaches:1
# Library
# from down to top
library:ComputerA:clear:0
library:ComputerA:Mountain:10
# Life
player:ComputerA:life:3
### ComputerB ###
# Battlefield
battlefield:ComputerB:Mountain:4
battlefield:ComputerB:Dragonskull Summit:1
battlefield:ComputerB:Arid Mesa:1
battlefield:ComputerB:Lavaclaw Reaches:1
# Hand
hand:ComputerB:Ball Lightning:2
# Library
# from down to top
library:ComputerB:clear:0
library:ComputerB:Lightning Bolt:10
library:ComputerB:Mountain:1
# Life
player:ComputerB:life:1

View file

@ -7,6 +7,9 @@ import mage.cards.decks.Deck;
import mage.game.Game;
import mage.game.GameException;
import mage.game.TwoPlayerDuel;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard;
import mage.game.permanent.PermanentImpl;
import mage.players.Player;
import mage.server.game.PlayerFactory;
import mage.sets.Sets;
@ -39,6 +42,7 @@ public class PlayGameTest extends MageTestBase {
public void playOneGame() throws GameException, FileNotFoundException, IllegalArgumentException {
Game game = new TwoPlayerDuel(Constants.MultiplayerAttackOption.LEFT, Constants.RangeOfInfluence.ALL);
//Player computerA = createPlayer("ComputerA", "Computer - minimax hybrid");
Player computerA = createPlayer("ComputerA", "Computer - mad");
Deck deck = Deck.load(Sets.loadDeck("RB Aggro.dck"));
@ -48,7 +52,8 @@ public class PlayGameTest extends MageTestBase {
game.addPlayer(computerA, deck);
game.loadCards(deck.getCards(), computerA.getId());
Player computerB = createPlayer("ComputerB", "Computer - minimax hybrid");
//Player computerB = createPlayer("ComputerB", "Computer - minimax hybrid");
Player computerB = createPlayer("ComputerB", "Computer - mad");
Deck deck2 = Deck.load(Sets.loadDeck("RB Aggro.dck"));
if (deck2.getCards().size() < 40) {
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size());
@ -56,15 +61,17 @@ public class PlayGameTest extends MageTestBase {
game.addPlayer(computerB, deck2);
game.loadCards(deck2.getCards(), computerB.getId());
/*parseScenario("scenario7.txt");
parseScenario("tests/Burn the Impure.test");
game.cheat(computerA.getId(), commandsA);
game.cheat(computerA.getId(), libraryCardsA, handCardsA, battlefieldCardsA, graveyardCardsA);
game.cheat(computerB.getId(), commandsB);
game.cheat(computerB.getId(), libraryCardsB, handCardsB, battlefieldCardsB, graveyardCardsB);
*/
//boolean testMode = false;
boolean testMode = true;
long t1 = System.nanoTime();
game.start(computerA.getId(), false);
game.start(computerA.getId(), testMode);
long t2 = System.nanoTime();
logger.info("Winner: " + game.getWinner());
@ -90,7 +97,7 @@ public class PlayGameTest extends MageTestBase {
try {
while (scanner.hasNextLine()) {
String line = scanner.nextLine().trim();
if (line.startsWith("#")) continue;
if (line == null || line.isEmpty() || line.startsWith("#")) continue;
Matcher m = pattern.matcher(line);
if (m.matches()) {
@ -128,6 +135,7 @@ public class PlayGameTest extends MageTestBase {
String cardName = m.group(3);
Integer amount = Integer.parseInt(m.group(4));
boolean tapped = m.group(5) != null && m.group(5).equals(":{tapped}");
if (cardName.equals("clear")) {
if (nickname.equals("ComputerA")) {
@ -139,7 +147,13 @@ public class PlayGameTest extends MageTestBase {
for (int i = 0; i < amount; i++) {
Card card = Sets.findCard(cardName, true);
if (card != null) {
cards.add(card);
if (gameZone.equals(Constants.Zone.BATTLEFIELD)) {
PermanentCard p = new PermanentCard(card, null);
p.setTapped(tapped);
cards.add(p);
} else {
cards.add(card);
}
} else {
logger.fatal("Couldn't find a card: " + cardName);
logger.fatal("line: " + line);

View file

@ -29,7 +29,7 @@ public class MageTestBase {
private final static String pluginFolder = "plugins";
protected Pattern pattern = Pattern.compile("([a-zA-Z]*):([\\w]*):([a-zA-Z ,\\-.!'\\d]*):([\\d]*)");
protected Pattern pattern = Pattern.compile("([a-zA-Z]*):([\\w]*):([a-zA-Z ,\\-.!'\\d]*):([\\d]*)(:\\{tapped\\})?");
@BeforeClass
public static void init() {

View file

@ -9,7 +9,7 @@ log4j.appender.console.Threshold=INFO
#file log
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.file=MagicWars.log
log4j.appender.file.file=Mage.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%-5p [%d{yyyy-MM-dd HH:mm [ss:SSS]}] %C{1}[%t]: %m%n
log4j.appender.file.Threshold=INFO

View file

@ -0,0 +1,34 @@
# Test playing Burn the Impure
### ComputerA ###
# Battlefield
battlefield:ComputerA:Mountain:2
# Hand
hand:ComputerA:Mountain:4
hand:ComputerA:Burn the Impure:1
# Library
# from down to top
library:ComputerA:clear:0
library:ComputerA:Mountain:10
### ComputerB ###
# Battlefield
battlefield:ComputerB:Plains:1
battlefield:ComputerB:Tine Shrike:1
#battlefield:ComputerB:Runeclaw Bear:1
# Hand
hand:ComputerB:Plains:2
# Library
# from down to top
library:ComputerB:clear:0
library:ComputerB:Plains:10
# Life
player:ComputerB:life:3

View file

@ -41,6 +41,10 @@ public class PutIntoGraveFromBattlefieldTriggeredAbility extends ZoneChangeTrigg
super(Zone.BATTLEFIELD, Zone.GRAVEYARD, effect, "When {this} is put into a graveyard from the battlefield, ", optional);
}
public PutIntoGraveFromBattlefieldTriggeredAbility(Effect effect) {
this(effect, false);
}
public PutIntoGraveFromBattlefieldTriggeredAbility(PutIntoGraveFromBattlefieldTriggeredAbility ability) {
super(ability);
}

View file

@ -0,0 +1,19 @@
package mage.abilities.condition.common;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.counters.CounterType;
import mage.game.Game;
public class HaveCounter implements Condition {
private CounterType counterType;
public HaveCounter(CounterType type) {
this.counterType = type;
}
@Override
public boolean apply(Game game, Ability source) {
return game.getPermanent(source.getSourceId()).getCounters().getCount(counterType) > 0;
}
}

View file

@ -0,0 +1,75 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.effects.common;
import mage.Constants.Outcome;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
* @author Viserion
*/
public class UntapAllLandsControllerEffect extends OneShotEffect<UntapAllLandsControllerEffect> {
public UntapAllLandsControllerEffect() {
super(Outcome.Untap);
}
public UntapAllLandsControllerEffect(final UntapAllLandsControllerEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
for (Permanent land: game.getBattlefield().getAllActivePermanents(new FilterLandPermanent(), player.getId())) {
land.untap(game);
}
return true;
}
return false;
}
@Override
public UntapAllLandsControllerEffect copy() {
return new UntapAllLandsControllerEffect(this);
}
@Override
public String getText(Ability source) {
return "Untap all lands you control";
}
}

View file

@ -37,6 +37,8 @@ import mage.abilities.effects.ContinuousEffectImpl;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -62,15 +64,19 @@ public class GainAbilityTargetEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
permanent.addAbility(ability.copy());
return true;
int affectedTargets = 0;
for (UUID permanentId : source.getTargets().get(0).getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
permanent.addAbility(ability.copy());
affectedTargets++;
}
}
return false;
return affectedTargets > 0;
}
@Override
//TODO redone text for multiple targets
public String getText(Ability source) {
StringBuilder sb = new StringBuilder();
sb.append("Target ").append(source.getTargets().get(0).getTargetName()).append(" gains ");

View file

@ -35,6 +35,8 @@ import mage.counters.Counter;
import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -45,12 +47,6 @@ public class AddCountersTargetEffect extends OneShotEffect<AddCountersTargetEffe
private String name;
private Counter counter;
public AddCountersTargetEffect(String name, int amount) {
super(Outcome.Benefit);
this.name = name;
this.amount = amount;
}
public AddCountersTargetEffect(Counter counter) {
super(Outcome.Benefit);
this.name = counter.getName();
@ -66,15 +62,18 @@ public class AddCountersTargetEffect extends OneShotEffect<AddCountersTargetEffe
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
if (counter != null) {
int affectedTargets = 0;
for (UUID permanentId : source.getTargets().get(0).getTargets()) {
Permanent permanent = game.getPermanent(permanentId);
if (permanent != null) {
if (counter != null) {
permanent.addCounters(counter);
} else {
permanent.addCounters(name, amount);
}
}
}
return true;
return affectedTargets > 0;
}
@Override

View file

@ -46,7 +46,8 @@ public enum CounterType {
FEATHER(new FeatherCounter().name),
QUEST(new QuestCounter().name),
ARROWHEAD(new ArrowheadCounter().name),
EON(new EonCounter().name);
EON(new EonCounter().name),
AWAKENING(new AwakeningCounter().name);
private String name;
@ -102,6 +103,8 @@ public enum CounterType {
return new ArrowheadCounter(amount);
case EON:
return new EonCounter(amount);
case AWAKENING:
return new AwakeningCounter(amount);
}
return null;
}

View file

@ -0,0 +1,14 @@
package mage.counters.common;
import mage.counters.Counter;
public class AwakeningCounter extends Counter<AwakeningCounter> {
public AwakeningCounter() {
this(1);
}
public AwakeningCounter(int amount) {
super("Awakening");
this.count = amount;
}
}

View file

@ -317,10 +317,10 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
saveState();
}
protected void init(UUID choosingPlayerId) {
init(choosingPlayerId, false);
}
// protected void init(UUID choosingPlayerId) {
// init(choosingPlayerId, false);
// }
//
protected void init(UUID choosingPlayerId, boolean testMode) {
for (Player player: state.getPlayers().values()) {
player.beginTurn(this);
@ -1002,7 +1002,6 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
setZone(card.getId(), Zone.GRAVEYARD);
player.getGraveyard().add(card);
}
List<Card> permanents = new ArrayList<Card>();
for (Card card : battlefield) {
card.setOwnerId(ownerId);
PermanentCard permanent = new PermanentCard(card, ownerId);

View file

@ -30,9 +30,7 @@ package mage.sets.[=$longset=];
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity;
import mage.Constants.Zone;[= if (defined($power)) {$OUT .= "\nimport mage.MageInt;"}=]
import mage.Constants.Rarity;[= if (defined($power)) {$OUT .= "\nimport mage.MageInt;"}=]
import mage.cards.CardImpl;
/**
@ -48,7 +46,7 @@ public class [=$classname=] extends CardImpl<[=$classname=]> {
[=if (defined($power)) {
$OUT .= "this.power = new MageInt($power);\n";
}=][=if (defined($toughness)) {
$OUT .= " this.toughness = new MageInt($toughness);";
$OUT .= " this.toughness = new MageInt($toughness);";
}=]
}

View file

@ -365,6 +365,7 @@ foreach my $div (@divs) {
}
}
if ($id =~m/currentSetSymbol/) {
print "*** " . $div->as_HTML();
my ($imgurl) = $div->look_down('_tag', 'img');
$imgurl->attr('src') =~m/set=(\w+)\&.*rarity=(\w+)/;
my $multiverseid = $multiverses[0];