From 5996aa12e6f4de0abe595a9d99a3fb76ced9dc61 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 15 Sep 2017 17:51:54 +0200 Subject: [PATCH] Trove of Temptation working for Human. --- .../player/ai/ma/ArtificialScoringSystem.java | 7 +++-- .../java/mage/player/ai/CombatEvaluator.java | 27 +++++++++---------- .../java/mage/player/ai/ComputerPlayer.java | 2 +- .../src/mage/player/human/HumanPlayer.java | 4 +-- .../src/mage/cards/i/IllicitAuction.java | 11 ++++---- Mage.Sets/src/mage/sets/Ixalan.java | 1 + .../java/mage/game/permanent/Permanent.java | 21 ++++++++++----- .../mage/game/permanent/PermanentImpl.java | 10 +++---- 8 files changed, 45 insertions(+), 38 deletions(-) diff --git a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/ArtificialScoringSystem.java b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/ArtificialScoringSystem.java index d322ec6c3b..379dadee6a 100644 --- a/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/ArtificialScoringSystem.java +++ b/Mage.Server.Plugins/Mage.Player.AI.MA/src/mage/player/ai/ma/ArtificialScoringSystem.java @@ -1,18 +1,17 @@ package mage.player.ai.ma; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.Effect; import mage.abilities.keyword.HasteAbility; import mage.cards.Card; import mage.constants.CardType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.counters.CounterType; import mage.game.Game; import mage.game.permanent.Permanent; -import java.util.UUID; -import mage.constants.SubType; - /** * @author ubeefx, nantuko */ @@ -104,7 +103,7 @@ public final class ArtificialScoringSystem { } score += equipments * 50 + enchantments * 100; - if (!permanent.canAttack(game)) { + if (!permanent.canAttack(null, game)) { score -= 100; } diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/CombatEvaluator.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/CombatEvaluator.java index 12032f470b..62b13acd84 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/CombatEvaluator.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/CombatEvaluator.java @@ -1,16 +1,16 @@ /* * 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 @@ -20,24 +20,22 @@ * 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 java.util.HashMap; +import java.util.Map; +import java.util.UUID; import mage.abilities.keyword.DoubleStrikeAbility; import mage.abilities.keyword.FirstStrikeAbility; import mage.abilities.keyword.TrampleAbility; import mage.game.Game; import mage.game.permanent.Permanent; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - /** * * @author BetaSteward_at_googlemail.com @@ -50,15 +48,16 @@ public class CombatEvaluator { public int evaluate(Permanent creature, Game game) { if (!values.containsKey(creature.getId())) { int value = 0; - if (creature.canAttack(game)) + if (creature.canAttack(null, game)) { value += 2; + } value += creature.getPower().getValue(); value += creature.getToughness().getValue(); value += creature.getAbilities().getEvasionAbilities().size(); value += creature.getAbilities().getProtectionAbilities().size(); - value += creature.getAbilities().containsKey(FirstStrikeAbility.getInstance().getId())?1:0; - value += creature.getAbilities().containsKey(DoubleStrikeAbility.getInstance().getId())?2:0; - value += creature.getAbilities().containsKey(TrampleAbility.getInstance().getId())?1:0; + value += creature.getAbilities().containsKey(FirstStrikeAbility.getInstance().getId()) ? 1 : 0; + value += creature.getAbilities().containsKey(DoubleStrikeAbility.getInstance().getId()) ? 2 : 0; + value += creature.getAbilities().containsKey(TrampleAbility.getInstance().getId()) ? 1 : 0; values.put(creature.getId(), value); } return values.get(creature.getId()); diff --git a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java index 005158b651..84253863c6 100644 --- a/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai/ComputerPlayer.java @@ -1939,7 +1939,7 @@ public class ComputerPlayer extends PlayerImpl implements Player { protected int combatPotential(Permanent creature, Game game) { log.debug("combatPotential"); - if (!creature.canAttack(game)) { + if (!creature.canAttack(null, game)) { return 0; } int potential = creature.getPower().getValue(); diff --git a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java index 762c5408e7..751e1739d2 100644 --- a/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java +++ b/Mage.Server.Plugins/Mage.Player.Human/src/mage/player/human/HumanPlayer.java @@ -1073,7 +1073,7 @@ public class HumanPlayer extends PlayerImpl { List possibleAttackers = new ArrayList<>(); for (Permanent possibleAttacker : game.getBattlefield().getActivePermanents(filter, attackingPlayerId, game)) { - if (possibleAttacker.canAttack(game)) { + if (possibleAttacker.canAttack(null, game)) { possibleAttackers.add(possibleAttacker.getId()); } } @@ -1207,7 +1207,7 @@ public class HumanPlayer extends PlayerImpl { // already attacks other player taht has to be attacked continue; } - if (defendingPlayerId != null || attacker.canAttack(forcedToAttackId, game)) { + if (defendingPlayerId != null || attacker.canAttackInPrinciple(forcedToAttackId, game)) { game.informPlayer(this, "You are forced to attack " + forcedToAttack.getName() + " or a controlled planeswalker e.g. with " + attacker.getIdName() + "."); return false; } diff --git a/Mage.Sets/src/mage/cards/i/IllicitAuction.java b/Mage.Sets/src/mage/cards/i/IllicitAuction.java index 32b4742e69..bb87c8d63c 100644 --- a/Mage.Sets/src/mage/cards/i/IllicitAuction.java +++ b/Mage.Sets/src/mage/cards/i/IllicitAuction.java @@ -137,18 +137,19 @@ class CreatureEvaluator { public int evaluate(Permanent creature, Game game) { if (!values.containsKey(creature.getId())) { int value = 0; - if (creature.canAttack(game)) + if (creature.canAttack(null, game)) { value += 2; + } value += creature.getPower().getValue(); value += creature.getToughness().getValue(); value += creature.getAbilities().getEvasionAbilities().size(); value += creature.getAbilities().getProtectionAbilities().size(); - value += creature.getAbilities().containsKey(FirstStrikeAbility.getInstance().getId())?1:0; - value += creature.getAbilities().containsKey(DoubleStrikeAbility.getInstance().getId())?2:0; - value += creature.getAbilities().containsKey(TrampleAbility.getInstance().getId())?1:0; + value += creature.getAbilities().containsKey(FirstStrikeAbility.getInstance().getId()) ? 1 : 0; + value += creature.getAbilities().containsKey(DoubleStrikeAbility.getInstance().getId()) ? 2 : 0; + value += creature.getAbilities().containsKey(TrampleAbility.getInstance().getId()) ? 1 : 0; values.put(creature.getId(), value); } return values.get(creature.getId()); } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/Ixalan.java b/Mage.Sets/src/mage/sets/Ixalan.java index a579435115..67d0c43832 100644 --- a/Mage.Sets/src/mage/sets/Ixalan.java +++ b/Mage.Sets/src/mage/sets/Ixalan.java @@ -213,6 +213,7 @@ public class Ixalan extends ExpansionSet { cards.add(new SetCardInfo("Tocatli Honor Guard", 42, Rarity.RARE, mage.cards.t.TocatliHonorGuard.class)); cards.add(new SetCardInfo("Treasure Cove", 1250, Rarity.RARE, mage.cards.t.TreasureCove.class)); cards.add(new SetCardInfo("Treasure Map", 250, Rarity.RARE, mage.cards.t.TreasureMap.class)); + cards.add(new SetCardInfo("Trove of Temptation", 171, Rarity.UNCOMMON, mage.cards.t.TroveOfTemptation.class)); cards.add(new SetCardInfo("Unclaimed Territory", 258, Rarity.UNCOMMON, mage.cards.u.UnclaimedTerritory.class)); cards.add(new SetCardInfo("Unfriendly Fire", 172, Rarity.COMMON, mage.cards.u.UnfriendlyFire.class)); cards.add(new SetCardInfo("Vance's Blasting Cannons", 173, Rarity.RARE, mage.cards.v.VancesBlastingCannons.class)); diff --git a/Mage/src/main/java/mage/game/permanent/Permanent.java b/Mage/src/main/java/mage/game/permanent/Permanent.java index c7d0a4c1d2..68efe807b6 100644 --- a/Mage/src/main/java/mage/game/permanent/Permanent.java +++ b/Mage/src/main/java/mage/game/permanent/Permanent.java @@ -27,6 +27,9 @@ */ package mage.game.permanent; +import java.util.List; +import java.util.Set; +import java.util.UUID; import mage.MageObject; import mage.MageObjectReference; import mage.abilities.Ability; @@ -37,10 +40,6 @@ import mage.game.Controllable; import mage.game.Game; import mage.game.GameState; -import java.util.List; -import java.util.Set; -import java.util.UUID; - public interface Permanent extends Card, Controllable { void setControllerId(UUID controllerId); @@ -223,16 +222,24 @@ public interface Permanent extends Card, Controllable { */ void setMaxBlockedBy(int maxBlockedBy); - boolean canAttack(Game game); - /** * - * @param defenderId id of planeswalker or player to attack + * @param defenderId id of planeswalker or player to attack - can be empty + * to check generally * @param game * @return */ boolean canAttack(UUID defenderId, Game game); + /** + * Checks if a creature can attack (also if it is tapped) + * + * @param defenderId + * @param game + * @return + */ + boolean canAttackInPrinciple(UUID defenderId, Game game); + boolean canBlock(UUID attackerId, Game game); boolean canBlockAny(Game game); diff --git a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java index b0afa82a08..56dd77e916 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java @@ -1029,16 +1029,16 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { return game.replaceEvent(GameEvent.getEvent(eventType, this.objectId, ownerId));// controllerId seems to me more logical (LevelX2) } - @Override - public boolean canAttack(Game game) { - return canAttack(null, game); - } - @Override public boolean canAttack(UUID defenderId, Game game) { if (tapped) { return false; } + return canAttackInPrinciple(defenderId, game); + } + + @Override + public boolean canAttackInPrinciple(UUID defenderId, Game game) { if (hasSummoningSickness() && !game.getContinuousEffects().asThough(this.objectId, AsThoughEffectType.ATTACK_AS_HASTE, this.getControllerId(), game)) { return false; }