- Improved changeKnownOriginCanPlayAI.

This commit is contained in:
Sloth
2012-09-02 12:06:15 +00:00
parent d6793b5700
commit 3e37506a7e
2 changed files with 25 additions and 9 deletions

View File

@@ -4,9 +4,8 @@ Types:Creature Zombie
Text:no text Text:no text
PT:2/2 PT:2/2
S:Mode$ Continuous | Affected$ Creature.Zombie+Other | AddPower$ 1 | AddToughness$ 1 | Description$ Other Zombie creatures get +1/+1. S:Mode$ Continuous | Affected$ Creature.Zombie+Other | AddPower$ 1 | AddToughness$ 1 | Description$ Other Zombie creatures get +1/+1.
A:AB$ ChangeZone | Cost$ 1 B T | TgtPrompt$ Choose target Zombie card in your graveyard | ValidTgts$ Zombie.YouCtrl | Origin$ Graveyard | Destination$ Hand | SpellDescription$ Return target Zombie card from your graveyard to your hand. A:AB$ ChangeZone | Cost$ 1 B T | TgtPrompt$ Choose target Zombie card in your graveyard | ValidTgts$ Zombie.YouOwn | Origin$ Graveyard | Destination$ Hand | SpellDescription$ Return target Zombie card from your graveyard to your hand.
SVar:PlayMain1:TRUE SVar:PlayMain1:TRUE
SVar:RemRandomDeck:True
SVar:Rarity:Rare SVar:Rarity:Rare
SVar:Picture:http://www.wizards.com/global/images/magic/general/lord_of_the_undead.jpg SVar:Picture:http://www.wizards.com/global/images/magic/general/lord_of_the_undead.jpg
SetInfo:8ED|Rare|http://magiccards.info/scans/en/8e/141.jpg SetInfo:8ED|Rare|http://magiccards.info/scans/en/8e/141.jpg

View File

@@ -1446,8 +1446,6 @@ public final class AbilityFactoryChangeZone {
final ZoneType origin = ZoneType.smartValueOf(params.get("Origin")); final ZoneType origin = ZoneType.smartValueOf(params.get("Origin"));
final ZoneType destination = ZoneType.smartValueOf(params.get("Destination")); final ZoneType destination = ZoneType.smartValueOf(params.get("Destination"));
float pct = origin.equals(ZoneType.Battlefield) ? .8f : .667f;
final Random r = MyRandom.getRandom(); final Random r = MyRandom.getRandom();
if (abCost != null) { if (abCost != null) {
@@ -1512,24 +1510,39 @@ public final class AbilityFactoryChangeZone {
} }
final ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(af); final ArrayList<Object> objects = AbilityFactory.predictThreatenedObjects(af);
boolean contains = false;
for (final Card c : retrieval) { for (final Card c : retrieval) {
if (objects.contains(c)) { if (objects.contains(c)) {
pct = 1; contains = true;
} }
} }
if (pct < 1) { if (!contains) {
return false; return false;
} }
} }
} }
// don't return something to your hand if your hand is full of good stuff
if (destination.equals(ZoneType.Hand) && origin.equals(ZoneType.Graveyard)) {
int handSize = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand).size();
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN1)) {
return false;
}
if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.MAIN2)
&& handSize > 1) {
return false;
}
if (Singletons.getModel().getGameState().getPhaseHandler().isPlayerTurn(AllZone.getComputerPlayer())
&& handSize >= AllZone.getComputerPlayer().getMaxHandSize()) {
return false;
}
}
final AbilitySub subAb = sa.getSubAbility(); final AbilitySub subAb = sa.getSubAbility();
if (subAb != null) { if (subAb != null) {
chance &= subAb.chkAIDrawback(); chance &= subAb.chkAIDrawback();
} }
return ((r.nextFloat() < pct) && chance); return (chance);
} }
/** /**
@@ -1583,6 +1596,7 @@ public final class AbilityFactoryChangeZone {
subAffected = subParams.get("Defined"); subAffected = subParams.get("Defined");
} }
} }
System.out.println("changeZone: " + origin + destination + source);
if (tgt != null) { if (tgt != null) {
tgt.resetTargets(); tgt.resetTargets();
@@ -1590,7 +1604,9 @@ public final class AbilityFactoryChangeZone {
CardList list = AllZoneUtil.getCardsIn(origin); CardList list = AllZoneUtil.getCardsIn(origin);
list = list.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), source); list = list.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), source);
list = list.getNotName(source.getName()); // Don't get the same card back. if (source.isInZone(ZoneType.Hand)) {
list = list.getNotName(source.getName()); // Don't get the same card back.
}
if (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) { if (list.size() < tgt.getMinTargets(sa.getSourceCard(), sa)) {
return false; return false;
@@ -1672,6 +1688,7 @@ public final class AbilityFactoryChangeZone {
if (destination.equals(ZoneType.Hand)) { if (destination.equals(ZoneType.Hand)) {
// only retrieve cards from computer graveyard // only retrieve cards from computer graveyard
list = list.getController(AllZone.getComputerPlayer()); list = list.getController(AllZone.getComputerPlayer());
System.out.println("changeZone:" + list);
} }
} }