mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
- AI for Fight
This commit is contained in:
@@ -3,7 +3,6 @@ ManaCost:G
|
|||||||
Types:Sorcery
|
Types:Sorcery
|
||||||
Text:no text
|
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.)
|
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:Rarity:Common
|
||||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/prey_upon.jpg
|
SVar:Picture:http://www.wizards.com/global/images/magic/general/prey_upon.jpg
|
||||||
SetInfo:M13|Common|http://magiccards.info/scans/en/m13/181.jpg
|
SetInfo:M13|Common|http://magiccards.info/scans/en/m13/181.jpg
|
||||||
|
|||||||
@@ -632,7 +632,6 @@ public class AbilityFactoryAttach {
|
|||||||
prefList = prefList.filter(new CardListFilter() {
|
prefList = prefList.filter(new CardListFilter() {
|
||||||
@Override
|
@Override
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
System.out.println("Not Attaching");
|
|
||||||
return !c.getSVar("Targeting").equals("Dies");
|
return !c.getSVar("Targeting").equals("Dies");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1842,9 +1842,42 @@ public class AbilityFactoryDealDamage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean fightCanPlayAI(final AbilityFactory af, final SpellAbility sa) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -579,7 +579,7 @@ public class ComputerUtil {
|
|||||||
* (is for canPayCost, if true does not change the game state)
|
* (is for canPayCost, if true does not change the game state)
|
||||||
* @param extraMana
|
* @param extraMana
|
||||||
* a int.
|
* a int.
|
||||||
* @param checkPlayable
|
* @param checkPlayable
|
||||||
* should we check if playable? use for hypothetical "can AI play this"
|
* should we check if playable? use for hypothetical "can AI play this"
|
||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
@@ -759,7 +759,7 @@ public class ComputerUtil {
|
|||||||
* @param partPriority
|
* @param partPriority
|
||||||
* @param costParts
|
* @param costParts
|
||||||
* @param foundAllSources
|
* @param foundAllSources
|
||||||
* @return Were all mana sources found?
|
* @return Were all mana sources found?
|
||||||
*/
|
*/
|
||||||
private static Boolean findManaSources(final HashMap<String, ArrayList<AbilityMana>> manaAbilityMap,
|
private static Boolean findManaSources(final HashMap<String, ArrayList<AbilityMana>> manaAbilityMap,
|
||||||
final ArrayList<ArrayList<AbilityMana>> partSources, final ArrayList<Integer> partPriority,
|
final ArrayList<ArrayList<AbilityMana>> partSources, final ArrayList<Integer> partPriority,
|
||||||
@@ -818,7 +818,7 @@ public class ComputerUtil {
|
|||||||
srcFound.addAll(manaAbilityMap.get(costParts[nPart]));
|
srcFound.addAll(manaAbilityMap.get(costParts[nPart]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add sources to array lists
|
// add sources to array lists
|
||||||
partSources.add(nPart, srcFound);
|
partSources.add(nPart, srcFound);
|
||||||
// add to sorted priority list
|
// add to sorted priority list
|
||||||
|
|||||||
Reference in New Issue
Block a user