mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- Changes to Thopter Foundry
- Added initial AIPreference code. - Changed MagicStack.push to .add outside of MagicStack
This commit is contained in:
@@ -2,6 +2,7 @@ Name:Thopter Foundry
|
||||
ManaCost:WB U
|
||||
Types:Artifact
|
||||
Text:no text
|
||||
SVar:AIPreference:SacCost$Permanent.namedSword of the Meek
|
||||
SVar:Rarity:Uncommon
|
||||
SVar:Picture:http://www.wizards.com/global/images/magic/general/thopter_foundry.jpg
|
||||
End
|
||||
|
||||
@@ -8304,7 +8304,7 @@ public class CardFactory implements NewConstants {
|
||||
//this order is very important, do not change
|
||||
stop();
|
||||
if (paid)
|
||||
AllZone.Stack.push(ability);
|
||||
AllZone.Stack.add(ability);
|
||||
}
|
||||
};//Input
|
||||
ability.setBeforePayMana(payLife);
|
||||
@@ -8775,7 +8775,7 @@ public class CardFactory implements NewConstants {
|
||||
|
||||
@Override
|
||||
public void showMessage() {
|
||||
AllZone.Stack.push(ability2);
|
||||
AllZone.Stack.add(ability2);
|
||||
stop();
|
||||
}//showMessage()
|
||||
});
|
||||
@@ -10205,99 +10205,35 @@ public class CardFactory implements NewConstants {
|
||||
|
||||
//*************** START *********** START **************************
|
||||
else if(cardName.equals("Thopter Foundry")) {
|
||||
final Player player = card.getController();
|
||||
|
||||
final SpellAbility ability = new Ability(card, "1") {
|
||||
@Override
|
||||
public void chooseTargetAI() {
|
||||
Card c;
|
||||
PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
|
||||
|
||||
CardList meek = new CardList();
|
||||
meek.addAll(play.getCards());
|
||||
meek = meek.getName("Sword of the Meek");
|
||||
|
||||
if(meek.size() >= 1) c = meek.get(0);
|
||||
else c = getArtifact();
|
||||
if(c != null) setTargetCard(c);
|
||||
|
||||
}
|
||||
|
||||
public Card getArtifact() {
|
||||
//target creature that is going to attack
|
||||
PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
|
||||
|
||||
CardList arts = new CardList();
|
||||
arts.addAll(play.getCards());
|
||||
arts = arts.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
return c.isArtifact()
|
||||
&& !c.isToken()
|
||||
&& (CardUtil.getConvertedManaCost(c.getManaCost()) <= 1 && !c.equals(card) || c.getName().equals(
|
||||
"Sword of the Meek"));
|
||||
}
|
||||
});
|
||||
|
||||
if(arts.size() > 0) {
|
||||
arts.shuffle();
|
||||
return arts.get(0);
|
||||
} else return null;
|
||||
}
|
||||
|
||||
Ability_Cost abCost = new Ability_Cost("1 Sac<1/Artifact.nonToken>", cardName, true);
|
||||
final SpellAbility ability = new Ability_Activated(card, abCost, null) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean canPlayAI() {
|
||||
String phase = AllZone.Phase.getPhase();
|
||||
return phase.equals(Constant.Phase.Main2) && getArtifact() != null;
|
||||
return phase.equals(Constant.Phase.Main2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve() {
|
||||
Card c = getTargetCard();
|
||||
if(AllZone.GameAction.isCardInPlay(c)) {
|
||||
AllZone.GameAction.sacrifice(c);
|
||||
makeToken();
|
||||
card.getController().gainLife(1, card);
|
||||
}
|
||||
}//resolve
|
||||
|
||||
public void makeToken() {
|
||||
CardFactoryUtil.makeToken("Thopter", "U 1 1 Thopter", card.getController(), "U", new String[] {
|
||||
CardFactoryUtil.makeToken("Thopter", "U 1 1 Thopter", getActivatingPlayer(), "U", new String[] {
|
||||
"Artifact", "Creature", "Thopter"}, 1, 1, new String[] {"Flying"});
|
||||
}
|
||||
};
|
||||
|
||||
Input runtime = new Input() {
|
||||
|
||||
private static final long serialVersionUID = 3557158378851031238L;
|
||||
|
||||
@Override
|
||||
public void showMessage() {
|
||||
PlayerZone play = AllZone.getZone(Constant.Zone.Play, player);
|
||||
|
||||
CardList arts = new CardList();
|
||||
arts.addAll(play.getCards());
|
||||
arts = arts.filter(new CardListFilter() {
|
||||
public boolean addCard(Card c) {
|
||||
return c.isArtifact() && !c.isToken();
|
||||
}
|
||||
});
|
||||
|
||||
stopSetNext(CardFactoryUtil.input_targetSpecific(ability, arts,
|
||||
"Select a non-token Artifact to sacrifice", false, false));
|
||||
|
||||
}//showMessage()
|
||||
};//Input
|
||||
|
||||
card.addSpellAbility(ability);
|
||||
ability.setDescription("1, Sacrifice a nontoken artifact: Put a 1/1 blue Thopter artifact creature token with flying onto the battlefield. You gain 1 life.");
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(card.getName()).append(" - Put a 1/1 blue Thopter artifact creature token with flying onto the battlefield. You gain 1 life.");
|
||||
ability.setStackDescription(sb.toString());
|
||||
|
||||
ability.setBeforePayMana(runtime);
|
||||
|
||||
}//*************** END ************ END **************************
|
||||
|
||||
|
||||
|
||||
@@ -2770,7 +2770,7 @@ public class CardFactoryUtil {
|
||||
if(card.isCreature() && zone.is(Constant.Zone.Play) && canTarget(spell, card)) {
|
||||
spell.setTargetCard(card);
|
||||
spell.getSourceCard().tap();
|
||||
AllZone.Stack.push(spell);
|
||||
AllZone.Stack.add(spell);
|
||||
stop();
|
||||
}
|
||||
}
|
||||
@@ -2803,7 +2803,7 @@ public class CardFactoryUtil {
|
||||
&& card.getKeyword().contains(keyword)) {
|
||||
spell.setTargetCard(card);
|
||||
spell.getSourceCard().tap();
|
||||
AllZone.Stack.push(spell);
|
||||
AllZone.Stack.add(spell);
|
||||
stop();
|
||||
}
|
||||
}
|
||||
@@ -2933,7 +2933,7 @@ public class CardFactoryUtil {
|
||||
&& !card.getKeyword().contains("Shroud")) {
|
||||
spell.setTargetCard(card);
|
||||
spell.getSourceCard().tap();
|
||||
AllZone.Stack.push(spell);
|
||||
AllZone.Stack.add(spell);
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1041,7 +1041,7 @@ public class CardFactory_Creatures {
|
||||
list = list.getName(card.getName());
|
||||
list.get(0).getController().discard(list.get(0), ability);
|
||||
|
||||
AllZone.Stack.push(ability);
|
||||
AllZone.Stack.add(ability);
|
||||
stop();
|
||||
}
|
||||
};
|
||||
@@ -1112,7 +1112,7 @@ public class CardFactory_Creatures {
|
||||
list = list.getName(card.getName());
|
||||
list.get(0).getController().discard(list.get(0), ability);
|
||||
|
||||
AllZone.Stack.push(ability);
|
||||
AllZone.Stack.add(ability);
|
||||
stop();
|
||||
}
|
||||
};
|
||||
@@ -1173,7 +1173,7 @@ public class CardFactory_Creatures {
|
||||
list = list.getName(card.getName());
|
||||
list.get(0).getController().discard(list.get(0), ability);
|
||||
|
||||
AllZone.Stack.push(ability);
|
||||
AllZone.Stack.add(ability);
|
||||
stop();
|
||||
}
|
||||
};
|
||||
@@ -8400,7 +8400,7 @@ public class CardFactory_Creatures {
|
||||
else if(ability.canPlayAI()) {
|
||||
ability.chooseTargetAI();
|
||||
//need to add this to the stack
|
||||
AllZone.Stack.push(ability);
|
||||
AllZone.Stack.add(ability);
|
||||
}
|
||||
|
||||
}//execute()
|
||||
|
||||
@@ -93,7 +93,7 @@ class CardFactory_Planeswalkers {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
|
||||
AllZone.Stack.push(ability2);
|
||||
AllZone.Stack.add(ability2);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -183,7 +183,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability3);
|
||||
AllZone.Stack.add(ability3);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -228,7 +228,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability1);
|
||||
AllZone.Stack.add(ability1);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -329,7 +329,7 @@ class CardFactory_Planeswalkers {
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
|
||||
|
||||
AllZone.Stack.push(ability2);
|
||||
AllZone.Stack.add(ability2);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -403,7 +403,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability3);
|
||||
AllZone.Stack.add(ability3);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -476,7 +476,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability1);
|
||||
AllZone.Stack.add(ability1);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -607,7 +607,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability3);
|
||||
AllZone.Stack.add(ability3);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -702,7 +702,7 @@ class CardFactory_Planeswalkers {
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
|
||||
|
||||
AllZone.Stack.push(ability2);
|
||||
AllZone.Stack.add(ability2);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -787,7 +787,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability1);
|
||||
AllZone.Stack.add(ability1);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -911,7 +911,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability2);
|
||||
AllZone.Stack.add(ability2);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -955,7 +955,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability3);
|
||||
AllZone.Stack.add(ability3);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -1001,7 +1001,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability1);
|
||||
AllZone.Stack.add(ability1);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -1119,7 +1119,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability2);
|
||||
AllZone.Stack.add(ability2);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -1181,7 +1181,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability3);
|
||||
AllZone.Stack.add(ability3);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -1667,7 +1667,7 @@ class CardFactory_Planeswalkers {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
|
||||
AllZone.Stack.push(ability2);
|
||||
AllZone.Stack.add(ability2);
|
||||
stop();
|
||||
}
|
||||
}
|
||||
@@ -1752,7 +1752,7 @@ class CardFactory_Planeswalkers {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
|
||||
AllZone.Stack.push(ability3);
|
||||
AllZone.Stack.add(ability3);
|
||||
stop();
|
||||
}
|
||||
}
|
||||
@@ -2004,7 +2004,7 @@ class CardFactory_Planeswalkers {
|
||||
{
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability1);
|
||||
AllZone.Stack.add(ability1);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -2516,7 +2516,7 @@ class CardFactory_Planeswalkers {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
|
||||
AllZone.Stack.push(ability1);
|
||||
AllZone.Stack.add(ability1);
|
||||
stop();
|
||||
}
|
||||
}
|
||||
@@ -3156,7 +3156,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability3);
|
||||
AllZone.Stack.add(ability3);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -3200,7 +3200,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability1);
|
||||
AllZone.Stack.add(ability1);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -3243,7 +3243,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability2);
|
||||
AllZone.Stack.add(ability2);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
@@ -3394,7 +3394,7 @@ class CardFactory_Planeswalkers {
|
||||
if(check != AllZone.Phase.getTurn()) {
|
||||
check = AllZone.Phase.getTurn();
|
||||
turn[0] = AllZone.Phase.getTurn();
|
||||
AllZone.Stack.push(ability3);
|
||||
AllZone.Stack.add(ability3);
|
||||
}
|
||||
stop();
|
||||
}//showMessage()
|
||||
|
||||
@@ -612,6 +612,17 @@ public class ComputerUtil
|
||||
}
|
||||
}
|
||||
|
||||
static public Card getCardPreference(Card activate, String pref, CardList typeList){
|
||||
String[] prefValid = activate.getSVar("AIPreference").split("\\$");
|
||||
if (prefValid[0].equals(pref)){
|
||||
CardList prefList = typeList.getValidCards(prefValid[1].split(","));
|
||||
if (prefList.size() != 0){
|
||||
prefList.shuffle();
|
||||
return prefList.get(0);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static public Card chooseSacrificeType(String type, Card activate, Card target){
|
||||
PlayerZone play = AllZone.getZone(Constant.Zone.Play, AllZone.ComputerPlayer);
|
||||
@@ -623,6 +634,10 @@ public class ComputerUtil
|
||||
if (typeList.size() == 0)
|
||||
return null;
|
||||
|
||||
Card prefCard = getCardPreference(activate, "SacCost", typeList);
|
||||
if (prefCard != null)
|
||||
return prefCard;
|
||||
|
||||
CardListUtil.sortAttackLowFirst(typeList);
|
||||
return typeList.get(0);
|
||||
}
|
||||
|
||||
@@ -6843,7 +6843,7 @@ public class GameActionUtil {
|
||||
|
||||
};// Ability
|
||||
ability.setStackDescription("Squee gets returned from graveyard to hand.");
|
||||
AllZone.Stack.push(ability);
|
||||
AllZone.Stack.add(ability);
|
||||
} // if creatures > 0
|
||||
|
||||
}
|
||||
@@ -13985,7 +13985,7 @@ public class GameActionUtil {
|
||||
};
|
||||
ability.setStackDescription("Baru, Fist of Krosa - creatures get +1/+1 until end of turn.");
|
||||
|
||||
if(!all.getName("Baru, Fist of Krosa").isEmpty()) AllZone.Stack.push(ability);
|
||||
if(!all.getName("Baru, Fist of Krosa").isEmpty()) AllZone.Stack.add(ability);
|
||||
}// outer for
|
||||
|
||||
old = current;
|
||||
@@ -14064,7 +14064,7 @@ public class GameActionUtil {
|
||||
ability.setStackDescription(sb.toString());
|
||||
|
||||
if(n[0] != 0) {
|
||||
AllZone.Stack.push(ability);
|
||||
AllZone.Stack.add(ability);
|
||||
}
|
||||
}// outer for
|
||||
|
||||
|
||||
@@ -396,7 +396,8 @@ public class MagicStack extends MyObservable {
|
||||
return stack.size();
|
||||
}
|
||||
|
||||
public void push(SpellAbility sp) {
|
||||
// Push should only be used by add.
|
||||
private void push(SpellAbility sp) {
|
||||
if (null == sp.getActivatingPlayer()) {
|
||||
sp.setActivatingPlayer(sp.getSourceCard().getController());
|
||||
System.out.println(sp.getSourceCard().getName() + " - activatingPlayer not set before adding to stack.");
|
||||
@@ -490,7 +491,7 @@ public class MagicStack extends MyObservable {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Spell fizzles, alert player?
|
||||
// TODO: Spell fizzles, what's the best way to alert player?
|
||||
Log.debug(c.getName() + " ability fizzles.");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user