*Initial Delve keyword checkin. (Does not work with X-cost spells.)

*Added OwnerDoesntControl property.
*Added
	Bronze Bombshell
	Death Rattle
	Tombstalker
*Ran Setinfo and Oracle script.
This commit is contained in:
Hellfish
2011-10-16 08:07:37 +00:00
parent ab7b9760ee
commit 4c6d2f6eb1
21 changed files with 220 additions and 29 deletions

View File

@@ -5109,6 +5109,8 @@ public class Card extends GameEntity implements Comparable<Card> {
if (!getOwner().isPlayer(sourceController)) return false;
} else if (Property.startsWith("YouDontOwn")) {
if (getOwner().isPlayer(sourceController)) return false;
} else if (Property.startsWith("OwnerDoesntControl")) {
if(getOwner().isPlayer(getController())) return false;
} else if (Property.startsWith("ControllerControls")) {
String type = Property.substring(18);
CardList list = getController().getCardsIn(Zone.Battlefield);

View File

@@ -1769,6 +1769,73 @@ public class GameAction {
manaCost = new ManaCost("G G");
} // Avatar of Might
}
else if(spell.getIsDelve()) {
int cardsInGrave = originalCard.getController().getCardsIn(Zone.Graveyard).size();
ArrayList<Integer> choiceList = new ArrayList<Integer>();
for(int i=0;i<=cardsInGrave;i++) {
choiceList.add(i);
}
if(originalCard.getController().isHuman()) {
int chosenAmount = (Integer)GuiUtils.getChoice("Exile how many cards?", choiceList.toArray());
System.out.println("Delve for " + chosenAmount);
CardList choices = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard);
CardList chosen = new CardList();
for(int i=0;i<chosenAmount;i++) {
Card nowChosen = (Card)GuiUtils.getChoiceOptional("Exile which card?", choices.toArray());
if(nowChosen == null) //User canceled,abort delving.
{
chosen.clear();
break;
}
choices.remove(nowChosen);
chosen.add(nowChosen);
}
for(Card c : chosen) {
exile(c);
}
manaCost = new ManaCost(originalCost.toString());
manaCost.decreaseColorlessMana(chosenAmount);
}
else {
//AI
int numToExile = 0;
int colorlessCost = originalCost.getColorlessManaAmount();
if(cardsInGrave <= colorlessCost) {
numToExile = cardsInGrave;
}
else {
numToExile = colorlessCost;
}
for(int i=0;i<numToExile;i++) {
CardList grave = new CardList(AllZone.getComputerPlayer().getZone(Zone.Graveyard).getCards());
Card chosen = null;
for(Card c : grave) { //Exile noncreatures first in case we can revive. Might wanna do some additional checking here for Flashback and the like.
if(!c.isCreature()) {
chosen = c;
break;
}
}
if(chosen == null) {
chosen = CardFactoryUtil.AI_getWorstCreature(grave);
}
if(chosen == null) {
//Should never get here but... You know how it is.
chosen = grave.get(0);
}
exile(chosen);
}
}
}
} // isSpell
// Get Cost Reduction

View File

@@ -4800,6 +4800,10 @@ public class CardFactoryUtil {
}
}
if(card.hasKeyword("Delve")) {
card.getSpellAbilities().get(0).setIsDelve(true);
}
if(card.hasStartOfKeyword("Haunt")) {
int hauntPos = card.getKeywordPosition("Haunt");
String[] splitKeyword = card.getKeyword().get(hauntPos).split(":");

View File

@@ -239,6 +239,44 @@ public class ManaCost {
}
manaPart.add(new Mana_PartColorless(manaToAdd));
}
/**
* <p>decreaseColorlessMana</p>
* @param manaToSubtract an int. The amount of colorless mana to subtract from the cost.Used by Delve.
*/
public void decreaseColorlessMana(int manaToSubtract) {
if(manaToSubtract <= 0)
return;
Mana_Part m;
for(int i = 0; i < manaPart.size();i++) {
m = (Mana_Part) manaPart.get(i);
if(m instanceof Mana_PartColorless) {
int remainingColorless = ((Mana_PartColorless) m).getManaNeeded() - manaToSubtract;
if(remainingColorless <= 0) {
manaPart.remove(m);
break;
}
else {
manaPart.remove(m);
manaPart.add(new Mana_PartColorless(remainingColorless));
}
}
}
}
/**
* <p>getColorlessManaAmount</p>
* Returns how much colorless mana must be paid to pay the cost.Used by Delve AI.
* @return an int.
*/
public int getColorlessManaAmount() {
for(Object m : manaPart) {
if(m instanceof Mana_PartColorless) {
return ((Mana_PartColorless) m).getManaNeeded();
}
}
return 0;
}
/**
* <p>addMana.</p>

View File

@@ -62,6 +62,7 @@ public abstract class SpellAbility {
private boolean kothThirdAbility = false;
private boolean cycling = false;
private boolean isCharm = false;
private boolean isDelve = false;
private int charmNumber;
private ArrayList<SpellAbility> charmChoices = new ArrayList<SpellAbility>();
@@ -1340,4 +1341,18 @@ public abstract class SpellAbility {
return charmChoices;
}
/**
* @return the isDelve
*/
public boolean getIsDelve() {
return isDelve;
}
/**
* @param isDelve0 the isDelve to set
*/
public void setIsDelve(boolean isDelve0) {
this.isDelve = isDelve0; // TODO: Add 0 to parameter's name.
}
}