Trove of Temptation working for Human.

This commit is contained in:
LevelX2 2017-09-15 17:51:54 +02:00
parent 24c2c69a81
commit 5996aa12e6
8 changed files with 45 additions and 38 deletions

View file

@ -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;
}

View file

@ -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());

View file

@ -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();

View file

@ -1073,7 +1073,7 @@ public class HumanPlayer extends PlayerImpl {
List<UUID> 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;
}

View file

@ -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());
}
}
}

View file

@ -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));

View file

@ -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);

View file

@ -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;
}