PlayerImpl fix

This commit is contained in:
magenoxx 2011-02-12 11:46:20 +03:00
parent 76537b0c66
commit 4b2a9cd203
8 changed files with 53 additions and 35 deletions

View file

@ -61,12 +61,16 @@ public class GameStateEvaluator2 {
} }
int permanentScore = 0; int permanentScore = 0;
try {
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(playerId)) { for (Permanent permanent: game.getBattlefield().getAllActivePermanents(playerId)) {
permanentScore += evaluatePermanent(permanent, game); permanentScore += evaluatePermanent(permanent, game);
} }
for (Permanent permanent: game.getBattlefield().getAllActivePermanents(opponent.getId())) { for (Permanent permanent: game.getBattlefield().getAllActivePermanents(opponent.getId())) {
permanentScore -= evaluatePermanent(permanent, game); permanentScore -= evaluatePermanent(permanent, game);
} }
} catch (Throwable t) {
t.printStackTrace();
}
//permanentScore *= PERMANENT_FACTOR; //permanentScore *= PERMANENT_FACTOR;
/*int handScore = 0; /*int handScore = 0;

View file

@ -26,7 +26,7 @@ public class ArtificialScoringSystem {
private static final int LIFE_ABOVE_MULTIPLIER = 100; private static final int LIFE_ABOVE_MULTIPLIER = 100;
public static int getCardDefinitionScore(final Game game, final Card card) { public static int getCardDefinitionScore(final Game game, final Card card) {
int value = 0; //TODO: add new rating system card value int value = 3; //TODO: add new rating system card value
if (card.getCardType().contains(Constants.CardType.LAND)) { if (card.getCardType().contains(Constants.CardType.LAND)) {
int score = (int) ((value / 2.0f) * 50); int score = (int) ((value / 2.0f) * 50);
//TODO: check this for "any color" lands //TODO: check this for "any color" lands

View file

@ -15,35 +15,36 @@ import java.util.zip.Inflater;
public class MagicAbility { public class MagicAbility {
private static Map<String, Integer> scores = new HashMap<String, Integer>() {{ private static Map<String, Integer> scores = new HashMap<String, Integer>() {{
scores.put(DeathtouchAbility.getInstance().getRule(), 60); put(DeathtouchAbility.getInstance().getRule(), 60);
scores.put(DefenderAbility.getInstance().getRule(), -100); put(DefenderAbility.getInstance().getRule(), -100);
scores.put(DoubleStrikeAbility.getInstance().getRule(), 100); put(DoubleStrikeAbility.getInstance().getRule(), 100);
scores.put(DoubleStrikeAbility.getInstance().getRule(), 100); put(DoubleStrikeAbility.getInstance().getRule(), 100);
scores.put(new ExaltedAbility().getRule(), 10); put(new ExaltedAbility().getRule(), 10);
scores.put(FirstStrikeAbility.getInstance().getRule(), 50); put(FirstStrikeAbility.getInstance().getRule(), 50);
scores.put(FlashAbility.getInstance().getRule(), 0); put(FlashAbility.getInstance().getRule(), 0);
scores.put(FlyingAbility.getInstance().getRule(), 50); put(FlyingAbility.getInstance().getRule(), 50);
scores.put(new ForestwalkAbility().getRule(), 10); put(new ForestwalkAbility().getRule(), 10);
scores.put(HasteAbility.getInstance().getRule(), 0); put(HasteAbility.getInstance().getRule(), 0);
scores.put(IndestructibleAbility.getInstance().getRule(), 150); put(IndestructibleAbility.getInstance().getRule(), 150);
scores.put(InfectAbility.getInstance().getRule(), 60); put(InfectAbility.getInstance().getRule(), 60);
scores.put(IntimidateAbility.getInstance().getRule(), 50); put(IntimidateAbility.getInstance().getRule(), 50);
scores.put(new IslandwalkAbility().getRule(), 10); put(new IslandwalkAbility().getRule(), 10);
scores.put(new MountainwalkAbility().getRule(), 10); put(new MountainwalkAbility().getRule(), 10);
scores.put(new PlainswalkAbility().getRule(), 10); put(new PlainswalkAbility().getRule(), 10);
scores.put(ReachAbility.getInstance().getRule(), 20); put(ReachAbility.getInstance().getRule(), 20);
scores.put(ShroudAbility.getInstance().getRule(), 60); put(ShroudAbility.getInstance().getRule(), 60);
scores.put(new SwampwalkAbility().getRule(), 10); put(new SwampwalkAbility().getRule(), 10);
scores.put(TrampleAbility.getInstance().getRule(), 30); put(TrampleAbility.getInstance().getRule(), 30);
scores.put(UnblockableAbility.getInstance().getRule(), 100); put(UnblockableAbility.getInstance().getRule(), 100);
scores.put(VigilanceAbility.getInstance().getRule(), 20); put(VigilanceAbility.getInstance().getRule(), 20);
scores.put(WitherAbility.getInstance().getRule(), 30); put(WitherAbility.getInstance().getRule(), 30);
}}; }};
public static int getAbilityScore(Ability ability) { public static int getAbilityScore(Ability ability) {
if (!scores.containsKey(ability.getRule())) { if (!scores.containsKey(ability.getRule())) {
System.err.println("Couldn't find ability score: " + ability.getRule()); //System.err.println("Couldn't find ability score: " + ability.getRule());
//TODO: add handling protection from ..., levelup, kicker, etc. abilities //TODO: add handling protection from ..., levelup, kicker, etc. abilities
return 0;
} }
return scores.get(ability.getRule()); return scores.get(ability.getRule());
} }

View file

@ -1,5 +1,5 @@
#Generated by Maven #Generated by Maven
#Sun Feb 06 08:07:38 EST 2011 #Sat Feb 12 11:24:53 MSK 2011
version=0.6 version=0.6
groupId=org.mage groupId=org.mage
artifactId=Mage-Tournament-BoosterDraft artifactId=Mage-Tournament-BoosterDraft

View file

@ -32,7 +32,7 @@ public class PlayGameTest extends MageTestBase {
game.loadCards(deck.getCards(), player.getId()); game.loadCards(deck.getCards(), player.getId());
Player player2 = createPlayer("computer2", "Computer - mad"); Player player2 = createPlayer("computer2", "Computer - mad");
Deck deck2 = Deck.load(Sets.loadDeck("UW Control.dck")); Deck deck2 = Deck.load(Sets.loadDeck("RB Aggro.dck"));
if (deck2.getCards().size() < 40) { if (deck2.getCards().size() < 40) {
throw new IllegalArgumentException("Couldn't load deck, deck side=" + deck2.getCards().size()); throw new IllegalArgumentException("Couldn't load deck, deck side=" + deck2.getCards().size());
} }

View file

@ -33,10 +33,13 @@ import mage.Constants.Layer;
import mage.Constants.Outcome; import mage.Constants.Outcome;
import mage.Constants.SubLayer; import mage.Constants.SubLayer;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.VariableCost;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import java.util.List;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -50,6 +53,7 @@ public class BoostPowerXSourceEffect extends ContinuousEffectImpl<BoostPowerXSou
public BoostPowerXSourceEffect(final BoostPowerXSourceEffect effect) { public BoostPowerXSourceEffect(final BoostPowerXSourceEffect effect) {
super(effect); super(effect);
this.amount = effect.amount;
} }
@Override @Override
@ -59,8 +63,15 @@ public class BoostPowerXSourceEffect extends ContinuousEffectImpl<BoostPowerXSou
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
if (amount < 0) if (amount < 0) {
amount = source.getCosts().getVariableCosts().get(0).getAmount(); List<VariableCost> varCost = source.getCosts().getVariableCosts();
if (varCost.size() > 0) {
amount = varCost.get(0).getAmount();
} else {
amount = 0;
return false;
}
}
Permanent target = (Permanent) game.getPermanent(source.getSourceId()); Permanent target = (Permanent) game.getPermanent(source.getSourceId());
if (target != null) { if (target != null) {
target.addPower(amount); target.addPower(amount);

View file

@ -962,7 +962,9 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
for (UUID targetId: option.getTargets().getUnchosen().get(targetNum).possibleTargets(option.getSourceId(), playerId, game)) { for (UUID targetId: option.getTargets().getUnchosen().get(targetNum).possibleTargets(option.getSourceId(), playerId, game)) {
Ability newOption = option.copy(); Ability newOption = option.copy();
newOption.getTargets().get(targetNum).addTarget(targetId, option, game); newOption.getTargets().get(targetNum).addTarget(targetId, option, game);
if (targetNum < option.getTargets().size() - 1) { if (targetNum < option.getTargets().size() - 2) {
//addTargetOptions(options, newOption, targetNum + 1, game);
// ayrat: bug fix
addTargetOptions(options, newOption, targetNum + 1, game); addTargetOptions(options, newOption, targetNum + 1, game);
} }
else { else {