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; package mage.player.ai.ma;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.keyword.HasteAbility; import mage.abilities.keyword.HasteAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import java.util.UUID;
import mage.constants.SubType;
/** /**
* @author ubeefx, nantuko * @author ubeefx, nantuko
*/ */
@ -104,7 +103,7 @@ public final class ArtificialScoringSystem {
} }
score += equipments * 50 + enchantments * 100; score += equipments * 50 + enchantments * 100;
if (!permanent.canAttack(game)) { if (!permanent.canAttack(null, game)) {
score -= 100; score -= 100;
} }

View file

@ -25,19 +25,17 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.player.ai; 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.DoubleStrikeAbility;
import mage.abilities.keyword.FirstStrikeAbility; import mage.abilities.keyword.FirstStrikeAbility;
import mage.abilities.keyword.TrampleAbility; import mage.abilities.keyword.TrampleAbility;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -50,8 +48,9 @@ public class CombatEvaluator {
public int evaluate(Permanent creature, Game game) { public int evaluate(Permanent creature, Game game) {
if (!values.containsKey(creature.getId())) { if (!values.containsKey(creature.getId())) {
int value = 0; int value = 0;
if (creature.canAttack(game)) if (creature.canAttack(null, game)) {
value += 2; value += 2;
}
value += creature.getPower().getValue(); value += creature.getPower().getValue();
value += creature.getToughness().getValue(); value += creature.getToughness().getValue();
value += creature.getAbilities().getEvasionAbilities().size(); value += creature.getAbilities().getEvasionAbilities().size();

View file

@ -1939,7 +1939,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
protected int combatPotential(Permanent creature, Game game) { protected int combatPotential(Permanent creature, Game game) {
log.debug("combatPotential"); log.debug("combatPotential");
if (!creature.canAttack(game)) { if (!creature.canAttack(null, game)) {
return 0; return 0;
} }
int potential = creature.getPower().getValue(); int potential = creature.getPower().getValue();

View file

@ -1073,7 +1073,7 @@ public class HumanPlayer extends PlayerImpl {
List<UUID> possibleAttackers = new ArrayList<>(); List<UUID> possibleAttackers = new ArrayList<>();
for (Permanent possibleAttacker : game.getBattlefield().getActivePermanents(filter, attackingPlayerId, game)) { for (Permanent possibleAttacker : game.getBattlefield().getActivePermanents(filter, attackingPlayerId, game)) {
if (possibleAttacker.canAttack(game)) { if (possibleAttacker.canAttack(null, game)) {
possibleAttackers.add(possibleAttacker.getId()); possibleAttackers.add(possibleAttacker.getId());
} }
} }
@ -1207,7 +1207,7 @@ public class HumanPlayer extends PlayerImpl {
// already attacks other player taht has to be attacked // already attacks other player taht has to be attacked
continue; 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() + "."); game.informPlayer(this, "You are forced to attack " + forcedToAttack.getName() + " or a controlled planeswalker e.g. with " + attacker.getIdName() + ".");
return false; return false;
} }

View file

@ -137,8 +137,9 @@ class CreatureEvaluator {
public int evaluate(Permanent creature, Game game) { public int evaluate(Permanent creature, Game game) {
if (!values.containsKey(creature.getId())) { if (!values.containsKey(creature.getId())) {
int value = 0; int value = 0;
if (creature.canAttack(game)) if (creature.canAttack(null, game)) {
value += 2; value += 2;
}
value += creature.getPower().getValue(); value += creature.getPower().getValue();
value += creature.getToughness().getValue(); value += creature.getToughness().getValue();
value += creature.getAbilities().getEvasionAbilities().size(); value += creature.getAbilities().getEvasionAbilities().size();

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("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 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("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("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("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)); 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; package mage.game.permanent;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.MageObjectReference; import mage.MageObjectReference;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -37,10 +40,6 @@ import mage.game.Controllable;
import mage.game.Game; import mage.game.Game;
import mage.game.GameState; import mage.game.GameState;
import java.util.List;
import java.util.Set;
import java.util.UUID;
public interface Permanent extends Card, Controllable { public interface Permanent extends Card, Controllable {
void setControllerId(UUID controllerId); void setControllerId(UUID controllerId);
@ -223,16 +222,24 @@ public interface Permanent extends Card, Controllable {
*/ */
void setMaxBlockedBy(int maxBlockedBy); 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 * @param game
* @return * @return
*/ */
boolean canAttack(UUID defenderId, Game game); 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 canBlock(UUID attackerId, Game game);
boolean canBlockAny(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) 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 @Override
public boolean canAttack(UUID defenderId, Game game) { public boolean canAttack(UUID defenderId, Game game) {
if (tapped) { if (tapped) {
return false; 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)) { if (hasSummoningSickness() && !game.getContinuousEffects().asThough(this.objectId, AsThoughEffectType.ATTACK_AS_HASTE, this.getControllerId(), game)) {
return false; return false;
} }