mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
- Improved logic for AiAttackController.toProtectAttacker() and added documentation
This commit is contained in:
@@ -1075,20 +1075,29 @@ public class AiAttackController {
|
|||||||
return false; // don't attack
|
return false; // don't attack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a protection type that will make an attacker unblockable.
|
||||||
|
* @param sa ability belonging to ApiType.Protection
|
||||||
|
* @return colour string or "artifacts", null if no possible choice exists
|
||||||
|
*/
|
||||||
public String toProtectAttacker(SpellAbility sa) {
|
public String toProtectAttacker(SpellAbility sa) {
|
||||||
|
//AiAttackController is created with the selected attacker as the only entry in "attackers"
|
||||||
if (sa.getApi() != ApiType.Protection || oppList.isEmpty() || getPossibleBlockers(oppList, attackers).isEmpty()) {
|
if (sa.getApi() != ApiType.Protection || oppList.isEmpty() || getPossibleBlockers(oppList, attackers).isEmpty()) {
|
||||||
return null;
|
return null; //not protection sa or attacker is already unblockable
|
||||||
}
|
}
|
||||||
final List<String> choices = ProtectEffect.getProtectionList(sa);
|
final List<String> choices = ProtectEffect.getProtectionList(sa);
|
||||||
String color = ComputerUtilCard.getMostProminentColor(oppList), artifact = null;
|
String color = ComputerUtilCard.getMostProminentColor(getPossibleBlockers(oppList, attackers)), artifact = null;
|
||||||
if (choices.contains("artifacts")) {
|
if (choices.contains("artifacts")) {
|
||||||
artifact = "artifacts";
|
artifact = "artifacts"; //flag to indicate that protection from artifacts is available
|
||||||
}
|
}
|
||||||
if (choices.contains(color)) {
|
if (!choices.contains(color)) {
|
||||||
for (Card c : oppList) {
|
color = null;
|
||||||
if (!c.isArtifact()) {
|
}
|
||||||
artifact = null;
|
for (Card c : oppList) { //find a blocker that ignores the currently selected protection
|
||||||
}
|
if (artifact != null && !c.isArtifact()) {
|
||||||
|
artifact = null;
|
||||||
|
}
|
||||||
|
if (color != null) {
|
||||||
switch (color) {
|
switch (color) {
|
||||||
case "black":
|
case "black":
|
||||||
if (!c.isBlack()) {
|
if (!c.isBlack()) {
|
||||||
@@ -1116,12 +1125,10 @@ public class AiAttackController {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (color == null && artifact == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
if (color == null && artifact == null) { //nothing can make the attacker unblockable
|
||||||
color = null;
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
return color;
|
return color;
|
||||||
@@ -1129,7 +1136,7 @@ public class AiAttackController {
|
|||||||
if (artifact != null) {
|
if (artifact != null) {
|
||||||
return artifact;
|
return artifact;
|
||||||
}
|
}
|
||||||
return null;
|
return null; //should never get here
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end class ComputerUtil_Attack2
|
} // end class ComputerUtil_Attack2
|
||||||
|
|||||||
Reference in New Issue
Block a user