mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
improvements to AF_GainControl and AI decisions
-AI will choose not to untap (if possible) a card that is controlling another when given the opportunity (like Old Man of the Sea) -if it is not controlling, then it will untap -"+Controlling: <target>" added in CardDetailPanel
This commit is contained in:
@@ -89,42 +89,42 @@ public class AbilityFactory_GainControl {
|
||||
}
|
||||
|
||||
public SpellAbility getAbility() {
|
||||
|
||||
final SpellAbility abControl = new Ability_Activated(hostCard, AF.getAbCost(), AF.getAbTgt()) {
|
||||
private static final long serialVersionUID = -4384705198674678831L;
|
||||
|
||||
@Override
|
||||
public boolean canPlay(){
|
||||
return super.canPlay();
|
||||
}
|
||||
final SpellAbility abControl = new Ability_Activated(hostCard, AF.getAbCost(), AF.getAbTgt()) {
|
||||
private static final long serialVersionUID = -4384705198674678831L;
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
return doTgtAI(this);
|
||||
}
|
||||
@Override
|
||||
public boolean canPlay(){
|
||||
return super.canPlay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
doResolve(this);
|
||||
hostCard.setAbilityUsed(hostCard.getAbilityUsed() + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStackDescription(){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String name = AF.getHostCard().getName();
|
||||
sb.append(name).append(" - gain control of ");
|
||||
Card tgt = getTargetCard();
|
||||
if (tgt != null) {
|
||||
if(tgt.isFaceDown()) sb.append("Morph");
|
||||
else sb.append(tgt.getName());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
};//Ability_Activated
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
return doTgtAI(this);
|
||||
}
|
||||
|
||||
return abControl;
|
||||
}
|
||||
@Override
|
||||
public void resolve() {
|
||||
doResolve(this);
|
||||
hostCard.setAbilityUsed(hostCard.getAbilityUsed() + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStackDescription(){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String name = AF.getHostCard().getName();
|
||||
sb.append(name).append(" - gain control of ");
|
||||
Card tgt = getTargetCard();
|
||||
if (tgt != null) {
|
||||
if(tgt.isFaceDown()) sb.append("Morph");
|
||||
else sb.append(tgt.getName());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
};//Ability_Activated
|
||||
|
||||
return abControl;
|
||||
}
|
||||
|
||||
|
||||
private boolean doTgtAI(SpellAbility sa) {
|
||||
@@ -155,7 +155,7 @@ public class AbilityFactory_GainControl {
|
||||
|
||||
|
||||
|
||||
while(tgt.getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)){
|
||||
while(tgt.getNumTargeted() < tgt.getMaxTargets(sa.getSourceCard(), sa)) {
|
||||
Card t = null;
|
||||
for(Card c:list) {
|
||||
if(c.isCreature()) hasCreature = true;
|
||||
@@ -212,6 +212,7 @@ public class AbilityFactory_GainControl {
|
||||
|
||||
//Card c = getTargetCard();
|
||||
movedCards[j] = tgtC;
|
||||
hostCard.addGainControlTarget(tgtC);
|
||||
|
||||
if(AllZone.GameAction.isCardInPlay(tgtC) && CardFactoryUtil.canTarget(hostCard, tgtC)) {
|
||||
//set summoning sickness
|
||||
@@ -274,6 +275,10 @@ public class AbilityFactory_GainControl {
|
||||
hostCard.addChangeControllerCommand(getDestroyCommand(j));
|
||||
}
|
||||
}
|
||||
|
||||
//for Old Man of the Sea - 0 is hardcoded since it only allows 1 target
|
||||
hostCard.clearGainControlReleaseCommands();
|
||||
hostCard.addGainControlReleaseCommand(getLoseControlCommand(0));
|
||||
|
||||
}//end foreach target
|
||||
|
||||
@@ -324,6 +329,7 @@ public class AbilityFactory_GainControl {
|
||||
|
||||
public void execute() {
|
||||
Card c = movedCards[i];
|
||||
//ArrayList<Card> c = hostCard.getGainControlTargets();
|
||||
|
||||
if(AllZone.GameAction.isCardInPlay(c)) {
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Play).setTriggers(false);
|
||||
@@ -356,6 +362,8 @@ public class AbilityFactory_GainControl {
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Human_Play).setTriggers(true);
|
||||
((PlayerZone_ComesIntoPlay) AllZone.Computer_Play).setTriggers(true);
|
||||
}//if
|
||||
hostCard.clearGainControlTargets();
|
||||
hostCard.clearGainControlReleaseCommands();
|
||||
}//execute()
|
||||
};
|
||||
|
||||
|
||||
@@ -130,8 +130,8 @@ public class Card extends MyObservable {
|
||||
private String namedCard = "";
|
||||
private String topCardName = "";
|
||||
private String reflectableMana = "";
|
||||
private Card oldManTarget;
|
||||
private Command oldManReleaseCommand;
|
||||
private ArrayList<Card> gainControlTargets = new ArrayList<Card>();
|
||||
private ArrayList<Command> gainControlReleaseCommands = new ArrayList<Command>();;
|
||||
|
||||
|
||||
private ArrayList<Ability_Triggered> zcTriggers = new ArrayList<Ability_Triggered>();
|
||||
@@ -656,23 +656,58 @@ public class Card extends MyObservable {
|
||||
}
|
||||
|
||||
/**
|
||||
* get a list of Cards this card has gained control of
|
||||
*
|
||||
* @return
|
||||
* used primarily with AbilityFactory_GainControl
|
||||
*
|
||||
* @return a list of cards this card has gained control of
|
||||
*/
|
||||
public Card getOldManTarget() {
|
||||
return oldManTarget;
|
||||
public ArrayList<Card> getGainControlTargets() {
|
||||
return gainControlTargets;
|
||||
}
|
||||
|
||||
public void setOldManTarget(Card c) {
|
||||
oldManTarget = c;
|
||||
/**
|
||||
* add a Card to the list of Cards this card has gained control of
|
||||
*
|
||||
* used primarily with AbilityFactory_GainControl
|
||||
*/
|
||||
public void addGainControlTarget(Card c) {
|
||||
gainControlTargets.add(c);
|
||||
}
|
||||
|
||||
public Command getOldManReleaseCommand() {
|
||||
return oldManReleaseCommand;
|
||||
/**
|
||||
* clear the list of Cards this card has gained control of
|
||||
*
|
||||
* used primarily with AbilityFactory_GainControl
|
||||
*/
|
||||
public void clearGainControlTargets() {
|
||||
gainControlTargets.clear();
|
||||
}
|
||||
|
||||
public void setOldManReleaseCommand(Command c) {
|
||||
oldManReleaseCommand = c;
|
||||
/**
|
||||
* get the commands to be executed to lose control of Cards this
|
||||
* card has gained control of
|
||||
*
|
||||
* used primarily with AbilityFactory_GainControl (Old Man of the Sea specifically)
|
||||
*/
|
||||
public ArrayList<Command> getGainControlReleaseCommands() {
|
||||
return gainControlReleaseCommands;
|
||||
}
|
||||
|
||||
/**
|
||||
* set a command to be executed to lose control of Cards this
|
||||
* card has gained control of
|
||||
*
|
||||
* used primarily with AbilityFactory_GainControl (Old Man of the Sea specifically)
|
||||
*
|
||||
* @param c the Command to be executed
|
||||
*/
|
||||
public void addGainControlReleaseCommand(Command c) {
|
||||
gainControlReleaseCommands.add(c);
|
||||
}
|
||||
|
||||
public void clearGainControlReleaseCommands() {
|
||||
gainControlReleaseCommands.clear();
|
||||
}
|
||||
|
||||
public String getSpellText() {
|
||||
|
||||
@@ -15478,9 +15478,12 @@ public class GameActionUtil {
|
||||
public void execute() {
|
||||
CardList list = AllZoneUtil.getCardsInPlay("Old Man of the Sea");
|
||||
for(Card oldman:list) {
|
||||
if(null != oldman.getOldManTarget()) {
|
||||
if(oldman.getNetAttack() < oldman.getOldManTarget().getNetAttack()) {
|
||||
oldman.getOldManReleaseCommand().execute();
|
||||
if(!oldman.getGainControlTargets().isEmpty()) {
|
||||
if(oldman.getNetAttack() < oldman.getGainControlTargets().get(0).getNetAttack()) {
|
||||
for(Command c:oldman.getGainControlReleaseCommands()) {
|
||||
c.execute();
|
||||
}
|
||||
oldman.clearGainControlReleaseCommands();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,9 @@ public class PhaseUtil {
|
||||
}
|
||||
}
|
||||
else { //computer
|
||||
//computer probably doesn't want to untap based on this ability...
|
||||
//if it is controlling something by staying tapped, leave it tapped
|
||||
//if not, untap it
|
||||
if(!(c.getGainControlTargets().size() > 0)) c.untap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,6 +215,17 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
||||
area.append("*");
|
||||
}
|
||||
|
||||
//controlling
|
||||
if(card.getGainControlTargets().size() > 0) {
|
||||
if(area.length() != 0) area.append("\n");
|
||||
area.append("+Controlling: ");
|
||||
for(Iterator<Card> it = card.getGainControlTargets().iterator(); it.hasNext();) {
|
||||
area.append(it.next());
|
||||
if(it.hasNext()) area.append(", ");
|
||||
}
|
||||
area.append("+");
|
||||
}
|
||||
|
||||
//uncastable
|
||||
if(card.isUnCastable()) {
|
||||
if(area.length() != 0) area.append("\n");
|
||||
|
||||
Reference in New Issue
Block a user