mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
- AI for Fight
This commit is contained in:
@@ -3,7 +3,6 @@ ManaCost:G
|
||||
Types:Sorcery
|
||||
Text:no text
|
||||
A:SP$ Fight | Cost$ G | ValidTgts$ Creature | TgtPrompt$ Select target creature | TargetsFromDifferentZone$ True | TargetMin$ 2 | TargetMax$ 2 | SpellDescription$ Target creature you control fights target creature you don't control. (Each deals damage equal to its power to the other.)
|
||||
SVar:RemAIDeck:True
|
||||
SVar:Rarity:Common
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/prey_upon.jpg
|
||||
SetInfo:M13|Common|http://magiccards.info/scans/en/m13/181.jpg
|
||||
|
||||
@@ -632,7 +632,6 @@ public class AbilityFactoryAttach {
|
||||
prefList = prefList.filter(new CardListFilter() {
|
||||
@Override
|
||||
public boolean addCard(final Card c) {
|
||||
System.out.println("Not Attaching");
|
||||
return !c.getSVar("Targeting").equals("Dies");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1842,9 +1842,42 @@ public class AbilityFactoryDealDamage {
|
||||
}
|
||||
|
||||
private boolean fightCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
||||
Target tgt = sa.getTarget();
|
||||
tgt.resetTargets();
|
||||
|
||||
//final Target tgt = sa.getTarget();
|
||||
CardList aiCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer());
|
||||
aiCreatures = aiCreatures.filter(new CardListFilter() {
|
||||
@Override
|
||||
public boolean addCard(final Card c) {
|
||||
return !c.getSVar("Targeting").equals("Dies");
|
||||
}
|
||||
});
|
||||
|
||||
CardList humCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
|
||||
|
||||
final Random r = MyRandom.getRandom();
|
||||
boolean rr = false;
|
||||
if (r.nextFloat() <= Math.pow(.6667, sa.getActivationsThisTurn())) {
|
||||
rr = true;
|
||||
}
|
||||
|
||||
if (humCreatures.size() > 0 && aiCreatures.size() > 0) {
|
||||
for (Card humanCreature : humCreatures) {
|
||||
for (Card aiCreature : aiCreatures) {
|
||||
if (humanCreature.getNetDefense() <= aiCreature.getNetAttack()
|
||||
&& humanCreature.getNetAttack() < aiCreature.getNetDefense()) {
|
||||
// todo: check min/max targets; see if we picked the best matchup
|
||||
tgt.addTarget(humanCreature);
|
||||
tgt.addTarget(aiCreature);
|
||||
return rr;
|
||||
} else if (humanCreature.getSVar("Targeting").equals("Dies")) {
|
||||
tgt.addTarget(humanCreature);
|
||||
tgt.addTarget(aiCreature);
|
||||
return rr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user