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);
|
||||
else restDamage = pl.staticReplaceDamage(restDamage, AF.getHostCard(), false);
|
||||
// will include creatures already dealt damage
|
||||
return c.getKillDamage() <= restDamage && c.getShield() > 0 &&
|
||||
!c.getKeyword().contains("Indestructible") && !(c.getSVar("SacMe").length() > 0);
|
||||
return c.getKillDamage() <= restDamage && c.getShield() == 0 &&
|
||||
!c.getKeyword().contains("Indestructible") && !(c.getSVar("SacMe").length() > 0);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -258,6 +258,9 @@ public class AbilityFactory_DealDamage {
|
||||
return targetCard;
|
||||
}
|
||||
|
||||
if (!mandatory)
|
||||
return null;
|
||||
|
||||
if(hPlay.size() > 0) {
|
||||
if (pl.isHuman())
|
||||
targetCard = CardFactoryUtil.AI_getBestCreature(hPlay);
|
||||
@@ -303,7 +306,13 @@ public class AbilityFactory_DealDamage {
|
||||
|
||||
// When giving priority to targeting Creatures for mandatory triggers
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,4 @@ abstract public class Ability_Activated extends SpellAbility implements java.io.
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
{
|
||||
if (isAbility)
|
||||
@@ -638,5 +645,4 @@ public class Ability_Cost {
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1927,11 +1927,6 @@ public class CardFactory_Sorceries {
|
||||
SpellAbility spell = new Spell(card) {
|
||||
private static final long serialVersionUID = -7652317332073733242L;
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
Player player = card.getController();
|
||||
|
||||
@@ -247,19 +247,13 @@ public class ComputerAI_General implements Computer {
|
||||
if (AllZone.Stack.size() == 0){
|
||||
sas = getOtherPhases();
|
||||
|
||||
if (sas.length > 0){
|
||||
// do things dependent on the phase,
|
||||
|
||||
// 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
|
||||
boolean pass = (sas.length == 0);
|
||||
if (!pass){ // Each AF should check the phase individually
|
||||
pass = ComputerUtil.playCards(sas);
|
||||
}
|
||||
|
||||
AllZone.Phase.passPriority();
|
||||
if (pass)
|
||||
AllZone.Phase.passPriority();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -275,7 +269,9 @@ public class ComputerAI_General implements Computer {
|
||||
sas = getOtherPhases();
|
||||
|
||||
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();
|
||||
// does it target me or something I own?
|
||||
// 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?
|
||||
|
||||
// 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()
|
||||
AllZone.Phase.passPriority();
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
|
||||
package forge;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
|
||||
private static final long serialVersionUID = 5750837078903423978L;
|
||||
|
||||
|
||||
@@ -90,20 +90,15 @@ public abstract class SpellAbility {
|
||||
//all Spell's and Abilities must override this method
|
||||
abstract public void resolve();
|
||||
|
||||
/*
|
||||
public boolean canPlayAI()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public void chooseTargetAI()
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
public boolean canPlayAI() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// This should be overridden by ALL AFs
|
||||
public boolean doTrigger(boolean mandatory){
|
||||
return false;
|
||||
}
|
||||
|
||||
public void chooseTargetAI() {
|
||||
randomTarget.execute(this);
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class TriggerHandler {
|
||||
|
||||
HashMap<String,String> trigParams = regtrig.getMapParams();
|
||||
final Player[] decider = new Player[1];
|
||||
boolean isOptional = false;
|
||||
final boolean isOptional = false;
|
||||
|
||||
if(mode.equals(trigParams.get("Mode")))
|
||||
{
|
||||
@@ -759,7 +759,8 @@ public class TriggerHandler {
|
||||
}
|
||||
else
|
||||
{
|
||||
sa[0].canPlayAI();
|
||||
final boolean mandatory = sa[0].getTarget().getMandatory();
|
||||
sa[0].doTrigger(mandatory);
|
||||
ComputerUtil.playNoStack(sa[0]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user