mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
- Some AI Tweaks for Damage and General Ability use.
This commit is contained in:
@@ -246,8 +246,8 @@ public class AbilityFactory_DealDamage {
|
|||||||
restDamage = c.predictDamage(d,AF.getHostCard(),false);
|
restDamage = c.predictDamage(d,AF.getHostCard(),false);
|
||||||
else restDamage = pl.staticReplaceDamage(restDamage, AF.getHostCard(), false);
|
else restDamage = pl.staticReplaceDamage(restDamage, AF.getHostCard(), false);
|
||||||
// will include creatures already dealt damage
|
// will include creatures already dealt damage
|
||||||
return c.getKillDamage() <= restDamage && c.getShield() > 0 &&
|
return c.getKillDamage() <= restDamage && c.getShield() == 0 &&
|
||||||
!c.getKeyword().contains("Indestructible") && !(c.getSVar("SacMe").length() > 0);
|
!c.getKeyword().contains("Indestructible") && !(c.getSVar("SacMe").length() > 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -258,6 +258,9 @@ public class AbilityFactory_DealDamage {
|
|||||||
return targetCard;
|
return targetCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mandatory)
|
||||||
|
return null;
|
||||||
|
|
||||||
if(hPlay.size() > 0) {
|
if(hPlay.size() > 0) {
|
||||||
if (pl.isHuman())
|
if (pl.isHuman())
|
||||||
targetCard = CardFactoryUtil.AI_getBestCreature(hPlay);
|
targetCard = CardFactoryUtil.AI_getBestCreature(hPlay);
|
||||||
@@ -303,7 +306,13 @@ public class AbilityFactory_DealDamage {
|
|||||||
|
|
||||||
// When giving priority to targeting Creatures for mandatory triggers
|
// When giving priority to targeting Creatures for mandatory triggers
|
||||||
// feel free to add the Human after we run out of good targets
|
// feel free to add the Human after we run out of good targets
|
||||||
if (mandatory && tgt.addTarget(AllZone.HumanPlayer))
|
|
||||||
|
// todo: add check here if card is about to die from something on the stack
|
||||||
|
// or from taking combat damage
|
||||||
|
boolean freePing = mandatory || (saMe.getPayCosts().isReusuableResource() &&
|
||||||
|
AllZone.Phase.is(Constant.Phase.End_Of_Turn, AllZone.HumanPlayer));
|
||||||
|
|
||||||
|
if (freePing && tgt.addTarget(AllZone.HumanPlayer))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,9 +45,4 @@ abstract public class Ability_Activated extends SpellAbility implements java.io.
|
|||||||
|
|
||||||
return Cost_Payment.canPayAdditionalCosts(payCosts, this);
|
return Cost_Payment.canPayAdditionalCosts(payCosts, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This should be overridden by ALL AFs
|
|
||||||
public boolean doTrigger(boolean mandatory){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,6 +283,13 @@ public class Ability_Cost {
|
|||||||
returnCost || lifeCost) && hasNoXManaCost() && hasNoManaCost();
|
returnCost || lifeCost) && hasNoXManaCost() && hasNoManaCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isReusuableResource() {
|
||||||
|
return !(sacCost || exileCost || exileFromHandCost || tapXTypeCost || discardCost ||
|
||||||
|
returnCost || lifeCost);
|
||||||
|
// todo: add/sub counter? Maybe check if it's we're adding a positive counter, or removing a negative counter
|
||||||
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
if (isAbility)
|
if (isAbility)
|
||||||
@@ -638,5 +645,4 @@ public class Ability_Cost {
|
|||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1927,11 +1927,6 @@ public class CardFactory_Sorceries {
|
|||||||
SpellAbility spell = new Spell(card) {
|
SpellAbility spell = new Spell(card) {
|
||||||
private static final long serialVersionUID = -7652317332073733242L;
|
private static final long serialVersionUID = -7652317332073733242L;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canPlayAI() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
Player player = card.getController();
|
Player player = card.getController();
|
||||||
|
|||||||
@@ -247,19 +247,13 @@ public class ComputerAI_General implements Computer {
|
|||||||
if (AllZone.Stack.size() == 0){
|
if (AllZone.Stack.size() == 0){
|
||||||
sas = getOtherPhases();
|
sas = getOtherPhases();
|
||||||
|
|
||||||
if (sas.length > 0){
|
boolean pass = (sas.length == 0);
|
||||||
// do things dependent on the phase,
|
if (!pass){ // Each AF should check the phase individually
|
||||||
|
pass = ComputerUtil.playCards(sas);
|
||||||
// if beginCombat tap best attackers etc
|
|
||||||
|
|
||||||
// if declareBlockers pump my guys to kill his guys or save my guys or regen my guys
|
|
||||||
|
|
||||||
// if end of Human's turn, feel free to use tap/mana abilities that will untap next turn
|
|
||||||
|
|
||||||
// if you don't or can't play anything
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AllZone.Phase.passPriority();
|
if (pass)
|
||||||
|
AllZone.Phase.passPriority();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +269,9 @@ public class ComputerAI_General implements Computer {
|
|||||||
sas = getOtherPhases();
|
sas = getOtherPhases();
|
||||||
|
|
||||||
if (sas.length > 0){
|
if (sas.length > 0){
|
||||||
if (topSA.getTarget() != null){
|
// each AF should check the Stack/Phase on it's own
|
||||||
|
|
||||||
|
|
||||||
//ArrayList<Object> targets = topSA.getTarget().getTargets();
|
//ArrayList<Object> targets = topSA.getTarget().getTargets();
|
||||||
// does it target me or something I own?
|
// does it target me or something I own?
|
||||||
// can i protect it? can I counter it?
|
// can i protect it? can I counter it?
|
||||||
@@ -283,10 +279,6 @@ public class ComputerAI_General implements Computer {
|
|||||||
// if i can't save it, can I activate an ability on that card in response? sacrifice etc?
|
// if i can't save it, can I activate an ability on that card in response? sacrifice etc?
|
||||||
|
|
||||||
// does it target his stuff? can I kill it in response?
|
// does it target his stuff? can I kill it in response?
|
||||||
}
|
|
||||||
else{
|
|
||||||
// no target, figure out what type of spell it is and react according
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// if this hasn't been covered above, just PassPriority()
|
// if this hasn't been covered above, just PassPriority()
|
||||||
AllZone.Phase.passPriority();
|
AllZone.Phase.passPriority();
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
|
|
||||||
package forge;
|
package forge;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
|
|
||||||
public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||||
private static final long serialVersionUID = 5750837078903423978L;
|
private static final long serialVersionUID = 5750837078903423978L;
|
||||||
|
|
||||||
|
|||||||
@@ -90,20 +90,15 @@ public abstract class SpellAbility {
|
|||||||
//all Spell's and Abilities must override this method
|
//all Spell's and Abilities must override this method
|
||||||
abstract public void resolve();
|
abstract public void resolve();
|
||||||
|
|
||||||
/*
|
|
||||||
public boolean canPlayAI()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
public void chooseTargetAI()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public boolean canPlayAI() {
|
public boolean canPlayAI() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This should be overridden by ALL AFs
|
||||||
|
public boolean doTrigger(boolean mandatory){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void chooseTargetAI() {
|
public void chooseTargetAI() {
|
||||||
randomTarget.execute(this);
|
randomTarget.execute(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ public class TriggerHandler {
|
|||||||
|
|
||||||
HashMap<String,String> trigParams = regtrig.getMapParams();
|
HashMap<String,String> trigParams = regtrig.getMapParams();
|
||||||
final Player[] decider = new Player[1];
|
final Player[] decider = new Player[1];
|
||||||
boolean isOptional = false;
|
final boolean isOptional = false;
|
||||||
|
|
||||||
if(mode.equals(trigParams.get("Mode")))
|
if(mode.equals(trigParams.get("Mode")))
|
||||||
{
|
{
|
||||||
@@ -759,7 +759,8 @@ public class TriggerHandler {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sa[0].canPlayAI();
|
final boolean mandatory = sa[0].getTarget().getMandatory();
|
||||||
|
sa[0].doTrigger(mandatory);
|
||||||
ComputerUtil.playNoStack(sa[0]);
|
ComputerUtil.playNoStack(sa[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user