mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Support AI assisting
This commit is contained in:
@@ -1897,27 +1897,27 @@ public class AiController {
|
|||||||
|
|
||||||
PlayerCollection allies = player.getAllies();
|
PlayerCollection allies = player.getAllies();
|
||||||
|
|
||||||
if (allies.size() > 0) {
|
if (allies.isEmpty()) {
|
||||||
// AI has allies, don't help out anyone but allies.
|
|
||||||
if (!allies.contains(activator)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// AI only has opponents.
|
// AI only has opponents.
|
||||||
// TODO: Maybe help out someone if it seems good for us, but who knows how you calculate that.
|
// TODO: Maybe help out someone if it seems good for us, but who knows how you calculate that.
|
||||||
// Probably needs some specific AI here.
|
// Probably needs some specific AI here.
|
||||||
// If the spell is a creature, probably don't help.
|
// If the spell is a creature, probably don't help.
|
||||||
// If spell is a instant/sorcery, help based on the situation
|
// If spell is a instant/sorcery, help based on the situation
|
||||||
return 0;
|
return 0;
|
||||||
|
} else {
|
||||||
|
// AI has allies, don't help out anyone but allies.
|
||||||
|
if (!allies.contains(activator)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AI has decided to help. Now let's figure out how much they can help
|
// AI has decided to help. Now let's figure out how much they can help
|
||||||
int mana = ComputerUtilMana.getAvailableManaEstimate(player, false);
|
int mana = ComputerUtilMana.getAvailableManaEstimate(player, true);
|
||||||
|
|
||||||
// TODO We should make a logical guess here, but for now just uh yknow randomly decide?
|
// TODO We should make a logical guess here, but for now just uh yknow randomly decide?
|
||||||
// What do I want to play next? Can I still pay for that and have mana left over to help?
|
// What do I want to play next? Can I still pay for that and have mana left over to help?
|
||||||
// Is the spell I'm helping cast better for me than the thing I would cast?
|
// Is the spell I'm helping cast better for me than the thing I would cast?
|
||||||
if (MyRandom.getRandom().nextInt(100) < 80) {
|
if (MyRandom.percentTrue(80)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -188,11 +188,17 @@ public class PlayerControllerAi extends PlayerController {
|
|||||||
public boolean helpPayForAssistSpell(ManaCostBeingPaid cost, SpellAbility sa, int max, int requested) {
|
public boolean helpPayForAssistSpell(ManaCostBeingPaid cost, SpellAbility sa, int max, int requested) {
|
||||||
int toPay = getAi().attemptToAssist(sa, max, requested);
|
int toPay = getAi().attemptToAssist(sa, max, requested);
|
||||||
|
|
||||||
// TODO Figure out how to pay toPay amount
|
|
||||||
if (toPay == 0) {
|
if (toPay == 0) {
|
||||||
//return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
ManaCost manaCost = ManaCost.get(toPay);
|
||||||
|
ManaCostBeingPaid assistCost = new ManaCostBeingPaid(manaCost);
|
||||||
|
if (ComputerUtilMana.canPayManaCost(assistCost, sa, player, false)) {
|
||||||
|
ComputerUtilMana.payManaCost(assistCost, sa, player, false);
|
||||||
|
cost.decreaseGenericMana(toPay);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -616,13 +616,11 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
|
|||||||
InputPayMana inpPayment = new InputPayManaOfCostPayment(this, assistCost, sa, this.getPlayer(), null, true);
|
InputPayMana inpPayment = new InputPayManaOfCostPayment(this, assistCost, sa, this.getPlayer(), null, true);
|
||||||
inpPayment.setMessagePrefix("Paying for assist - ");
|
inpPayment.setMessagePrefix("Paying for assist - ");
|
||||||
inpPayment.showAndWait();
|
inpPayment.showAndWait();
|
||||||
// Once you pay, loop in the paid SAs and add them to cost
|
|
||||||
|
|
||||||
if (inpPayment.isPaid()) {
|
if (inpPayment.isPaid()) {
|
||||||
// Apply payments from assistCost to cost
|
// Apply payments from assistCost to cost
|
||||||
// If cost is canceled, how do we make sure mana gets undone?
|
// If cost is canceled, how do we make sure mana gets undone?
|
||||||
|
|
||||||
final List<SpellAbility> paidAbs = sa.getPayingManaAbilities();
|
|
||||||
cost.decreaseGenericMana(willPay);
|
cost.decreaseGenericMana(willPay);
|
||||||
return true;
|
return true;
|
||||||
} else if (sa.getHostCard().getGame().EXPERIMENTAL_RESTORE_SNAPSHOT) {
|
} else if (sa.getHostCard().getGame().EXPERIMENTAL_RESTORE_SNAPSHOT) {
|
||||||
|
|||||||
Reference in New Issue
Block a user