mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
20 global calls less (80 to go)
This commit is contained in:
@@ -6311,6 +6311,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
public final boolean isType(String type) {
|
public final boolean isType(String type) {
|
||||||
|
if ( type == null ) return false;
|
||||||
|
|
||||||
type = this.toMixedCase(type);
|
type = this.toMixedCase(type);
|
||||||
|
|
||||||
if (this.typeContains(type)
|
if (this.typeContains(type)
|
||||||
|
|||||||
@@ -2835,7 +2835,7 @@ public class AbilityFactory {
|
|||||||
public void execute() {
|
public void execute() {
|
||||||
sa.resolve();
|
sa.resolve();
|
||||||
if (params.containsKey("PowerSink")) {
|
if (params.containsKey("PowerSink")) {
|
||||||
GameActionUtil.doPowerSink(AllZone.getHumanPlayer());
|
GameActionUtil.doPowerSink(sa.getActivatingPlayer());
|
||||||
}
|
}
|
||||||
AbilityFactory.resolveSubAbilities(sa);
|
AbilityFactory.resolveSubAbilities(sa);
|
||||||
if (usedStack) {
|
if (usedStack) {
|
||||||
@@ -2847,8 +2847,8 @@ public class AbilityFactory {
|
|||||||
if (payer.isHuman()) {
|
if (payer.isHuman()) {
|
||||||
GameActionUtil.payCostDuringAbilityResolve(ability, cost, paidCommand, unpaidCommand, sa);
|
GameActionUtil.payCostDuringAbilityResolve(ability, cost, paidCommand, unpaidCommand, sa);
|
||||||
} else {
|
} else {
|
||||||
if (ComputerUtil.canPayCost(ability, payer) && CostUtil.checkLifeCost(cost, source, 4, sa)
|
if (ComputerUtil.canPayCost(ability, payer) && CostUtil.checkLifeCost(payer, cost, source, 4, sa)
|
||||||
&& CostUtil.checkDamageCost(cost, source, 4)) {
|
&& CostUtil.checkDamageCost(payer, cost, source, 4)) {
|
||||||
// AI was crashing because the blank ability used to pay costs
|
// AI was crashing because the blank ability used to pay costs
|
||||||
// Didn't have any of the data on the original SA to pay dependant costs
|
// Didn't have any of the data on the original SA to pay dependant costs
|
||||||
ability.setTarget(sa.getTarget());
|
ability.setTarget(sa.getTarget());
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ public class AbilityFactoryAlterLife {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -756,7 +756,7 @@ public class AbilityFactoryAlterLife {
|
|||||||
|
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for these costs
|
// AI currently disabled for these costs
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, amount, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, amount, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1257,7 +1257,7 @@ public class AbilityFactoryAlterLife {
|
|||||||
|
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for these costs
|
// AI currently disabled for these costs
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 1, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 1, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ public final class AbilityFactoryChangeZone {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1516,7 +1516,7 @@ public final class AbilityFactoryChangeZone {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2579,7 +2579,7 @@ public final class AbilityFactoryChangeZone {
|
|||||||
|
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for these costs
|
// AI currently disabled for these costs
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ public class AbilityFactoryCounterMagic {
|
|||||||
if (!CostUtil.checkSacrificeCost(ai, abCost, source)) {
|
if (!CostUtil.checkSacrificeCost(ai, abCost, source)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ public class AbilityFactoryCounters {
|
|||||||
|
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for these costs
|
// AI currently disabled for these costs
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1011,7 +1011,7 @@ public class AbilityFactoryCounters {
|
|||||||
|
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for these costs
|
// AI currently disabled for these costs
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1866,7 +1866,7 @@ public class AbilityFactoryCounters {
|
|||||||
|
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for these costs
|
// AI currently disabled for these costs
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 8, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 8, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -394,7 +394,7 @@ public class AbilityFactoryDealDamage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// temporarily disabled until better AI
|
// temporarily disabled until better AI
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1181,7 +1181,7 @@ public class AbilityFactoryDealDamage {
|
|||||||
// abCost stuff that should probably be centralized...
|
// abCost stuff that should probably be centralized...
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for some costs
|
// AI currently disabled for some costs
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ public final class AbilityFactoryDebuff {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CostUtil.checkLifeCost(cost, source, 40, null)) {
|
if (!CostUtil.checkLifeCost(ai, cost, source, 40, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ public class AbilityFactoryDestroy {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -961,7 +961,7 @@ public class AbilityFactoryDestroy {
|
|||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for some costs
|
// AI currently disabled for some costs
|
||||||
|
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ public final class AbilityFactoryPlay {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ public class AbilityFactoryPreventDamage {
|
|||||||
final Cost cost = sa.getPayCosts();
|
final Cost cost = sa.getPayCosts();
|
||||||
|
|
||||||
// temporarily disabled until better AI
|
// temporarily disabled until better AI
|
||||||
if (!CostUtil.checkLifeCost(cost, hostCard, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, cost, hostCard, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -725,7 +725,7 @@ public class AbilityFactoryPreventDamage {
|
|||||||
final Cost cost = sa.getPayCosts();
|
final Cost cost = sa.getPayCosts();
|
||||||
|
|
||||||
// temporarily disabled until better AI
|
// temporarily disabled until better AI
|
||||||
if (!CostUtil.checkLifeCost(cost, hostCard, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, cost, hostCard, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ public final class AbilityFactoryProtection {
|
|||||||
final Cost cost = sa.getPayCosts();
|
final Cost cost = sa.getPayCosts();
|
||||||
|
|
||||||
// temporarily disabled until better AI
|
// temporarily disabled until better AI
|
||||||
if (!CostUtil.checkLifeCost(cost, hostCard, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, cost, hostCard, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1039,7 +1039,7 @@ public final class AbilityFactoryProtection {
|
|||||||
final Cost cost = sa.getPayCosts();
|
final Cost cost = sa.getPayCosts();
|
||||||
|
|
||||||
// temporarily disabled until better AI
|
// temporarily disabled until better AI
|
||||||
if (!CostUtil.checkLifeCost(cost, hostCard, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, cost, hostCard, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -818,7 +818,7 @@ public class AbilityFactoryPump {
|
|||||||
final Cost cost = sa.getPayCosts();
|
final Cost cost = sa.getPayCosts();
|
||||||
final PhaseHandler ph = Singletons.getModel().getGameState().getPhaseHandler();
|
final PhaseHandler ph = Singletons.getModel().getGameState().getPhaseHandler();
|
||||||
|
|
||||||
if (!CostUtil.checkLifeCost(cost, sa.getSourceCard(), 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, cost, sa.getSourceCard(), 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ public class AbilityFactoryRegenerate {
|
|||||||
final Cost abCost = af.getAbCost();
|
final Cost abCost = af.getAbCost();
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for these costs
|
// AI currently disabled for these costs
|
||||||
if (!CostUtil.checkLifeCost(abCost, hostCard, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, hostCard, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -716,7 +716,7 @@ public class AbilityFactoryRegenerate {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CostUtil.checkLifeCost(abCost, hostCard, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, hostCard, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1289,7 +1289,7 @@ public final class AbilityFactoryReveal {
|
|||||||
|
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for these costs
|
// AI currently disabled for these costs
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2275,7 +2275,7 @@ public final class AbilityFactoryReveal {
|
|||||||
|
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for these costs
|
// AI currently disabled for these costs
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -866,7 +866,7 @@ public class AbilityFactorySacrifice {
|
|||||||
|
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for some costs
|
// AI currently disabled for some costs
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ public class AbilityFactoryToken extends AbilityFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cost != null) {
|
if (cost != null) {
|
||||||
if (!CostUtil.checkLifeCost(cost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, cost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ public class AbilityFactoryZoneAffecting {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -874,7 +874,7 @@ public class AbilityFactoryZoneAffecting {
|
|||||||
|
|
||||||
if (abCost != null) {
|
if (abCost != null) {
|
||||||
// AI currently disabled for these costs
|
// AI currently disabled for these costs
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1604,7 +1604,7 @@ public class AbilityFactoryZoneAffecting {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CostUtil.checkLifeCost(abCost, source, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, abCost, source, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -793,69 +793,46 @@ public class CardFactorySorceries {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final static SpellAbility getPatriarchsBidding( final Card card ) {
|
private final static SpellAbility getPatriarchsBidding( final Card card ) {
|
||||||
final String[] input = new String[2];
|
|
||||||
|
|
||||||
final SpellAbility spell = new Spell(card) {
|
final SpellAbility spell = new Spell(card) {
|
||||||
private static final long serialVersionUID = -2182173662547136798L;
|
private static final long serialVersionUID = -2182173662547136798L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
input[0] = "";
|
List<String> types = new ArrayList<String>();
|
||||||
while (input[0] == "") {
|
for(Player p : AllZone.getPlayersInGame()) {
|
||||||
input[0] = JOptionPane.showInputDialog(null, "Which creature type?", "Pick type",
|
if ( p.isHuman() ) {
|
||||||
JOptionPane.QUESTION_MESSAGE);
|
types.add(GuiChoose.one("Which creature type?", Constant.CardTypes.CREATURE_TYPES));
|
||||||
if (input[0] == null) {
|
} else {
|
||||||
break;
|
final HashMap<String, Integer> countInGraveyard = new HashMap<String, Integer>();
|
||||||
}
|
final List<Card> aiGrave = p.getCardsIn(ZoneType.Graveyard);
|
||||||
if (!CardUtil.isACreatureType(input[0])) {
|
for (final Card c : Iterables.filter(aiGrave, CardPredicates.Presets.CREATURES)) {
|
||||||
input[0] = "";
|
for (final String type : c.getType()) {
|
||||||
// TODO some more input validation,
|
if (CardUtil.isACreatureType(type)) {
|
||||||
// case-sensitivity,
|
Integer oldVal = countInGraveyard.get(type);
|
||||||
// etc.
|
countInGraveyard.put(type, 1 + ( oldVal != null ? oldVal : 0 ));
|
||||||
}
|
}
|
||||||
|
|
||||||
input[0] = input[0].trim(); // this is to prevent
|
|
||||||
// "cheating", and selecting
|
|
||||||
// multiple creature
|
|
||||||
// types,eg "Goblin Soldier"
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input[0] == null) {
|
|
||||||
input[0] = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
final HashMap<String, Integer> countInGraveyard = new HashMap<String, Integer>();
|
|
||||||
final List<Card> allGrave = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard);
|
|
||||||
for (final Card c : Iterables.filter(allGrave, CardPredicates.Presets.CREATURES)) {
|
|
||||||
for (final String type : c.getType()) {
|
|
||||||
if (CardUtil.isACreatureType(type)) {
|
|
||||||
if (countInGraveyard.containsKey(type)) {
|
|
||||||
countInGraveyard.put(type, countInGraveyard.get(type) + 1);
|
|
||||||
} else {
|
|
||||||
countInGraveyard.put(type, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
String maxKey = "";
|
||||||
|
int maxCount = -1;
|
||||||
|
for (final Entry<String, Integer> entry : countInGraveyard.entrySet()) {
|
||||||
|
if (entry.getValue() > maxCount) {
|
||||||
|
maxKey = entry.getKey();
|
||||||
|
maxCount = entry.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
types.add( maxKey.equals("") ? "Sliver" : maxKey );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String maxKey = "";
|
|
||||||
int maxCount = -1;
|
|
||||||
for (final Entry<String, Integer> entry : countInGraveyard.entrySet()) {
|
|
||||||
if (entry.getValue() > maxCount) {
|
|
||||||
maxKey = entry.getKey();
|
|
||||||
maxCount = entry.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!maxKey.equals("")) {
|
|
||||||
input[1] = maxKey;
|
|
||||||
} else {
|
|
||||||
input[1] = "Sliver";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actually put everything on the battlefield
|
|
||||||
List<Card> bidded = CardLists.filter(AllZoneUtil.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES);
|
List<Card> bidded = CardLists.filter(AllZoneUtil.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES);
|
||||||
for (final Card c : bidded) {
|
for (final Card c : bidded) {
|
||||||
if (c.isType(input[1]) || (!input[0].equals("") && c.isType(input[0]))) {
|
for(int i = 0; i < types.size(); i++) {
|
||||||
Singletons.getModel().getGameAction().moveToPlay(c);
|
if (c.isType(types.get(i))) {
|
||||||
|
Singletons.getModel().getGameAction().moveToPlay(c);
|
||||||
|
i = types.size(); // break inner loop
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // resolve()
|
} // resolve()
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class CostDamage extends CostPart {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
AllZone.getComputerPlayer().addDamage(this.getLastPaidAmount(), source);
|
AllZone.getComputerPlayer().addDamage(this.getLastPaidAmount(), source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -163,10 +163,9 @@ public class CostDiscard extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
final Player activator = ability.getActivatingPlayer();
|
|
||||||
for (final Card c : this.getList()) {
|
for (final Card c : this.getList()) {
|
||||||
activator.discard(c, ability);
|
ai.discard(c, ability);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public class CostExile extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
for (final Card c : this.getList()) {
|
for (final Card c : this.getList()) {
|
||||||
Singletons.getModel().getGameAction().exile(c);
|
Singletons.getModel().getGameAction().exile(c);
|
||||||
if (this.from.equals(ZoneType.Stack)) {
|
if (this.from.equals(ZoneType.Stack)) {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package forge.card.cost;
|
package forge.card.cost;
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.GameActionUtil;
|
import forge.GameActionUtil;
|
||||||
import forge.card.abilityfactory.AbilityFactory;
|
import forge.card.abilityfactory.AbilityFactory;
|
||||||
@@ -105,8 +104,8 @@ public class CostGainLife extends CostPart {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
AllZone.getHumanPlayer().gainLife(this.getLastPaidAmount(), null);
|
ai.getOpponent().gainLife(this.getLastPaidAmount(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -197,8 +197,8 @@ public class CostMana extends CostPart {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
ComputerUtil.payManaCost(ability.getActivatingPlayer(), ability);
|
ComputerUtil.payManaCost(ai, ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public class CostMill extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
for (final Card c : this.getList()) {
|
for (final Card c : this.getList()) {
|
||||||
Singletons.getModel().getGameAction().moveToGraveyard(c);
|
Singletons.getModel().getGameAction().moveToGraveyard(c);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ public abstract class CostPart {
|
|||||||
* @param payment
|
* @param payment
|
||||||
* the payment
|
* the payment
|
||||||
*/
|
*/
|
||||||
public abstract void payAI(SpellAbility ability, Card source, CostPayment payment);
|
public abstract void payAI(final Player ai, SpellAbility ability, Card source, CostPayment payment);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pay human.
|
* Pay human.
|
||||||
|
|||||||
@@ -109,8 +109,8 @@ public class CostPayLife extends CostPart {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
ability.getActivatingPlayer().payLife(this.getLastPaidAmount(), null);
|
ai.payLife(this.getLastPaidAmount(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ public class CostPayment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (final CostPart part : parts) {
|
for (final CostPart part : parts) {
|
||||||
part.payAI(this.ability, this.ability.getSourceCard(), this);
|
part.payAI(ai, this.ability, this.ability.getSourceCard(), this);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public class CostPutCounter extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
Integer c = this.convertAmount();
|
Integer c = this.convertAmount();
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
c = AbilityFactory.calculateAmount(source, this.getAmount(), ability);
|
c = AbilityFactory.calculateAmount(source, this.getAmount(), ability);
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ public class CostRemoveCounter extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
final String amount = this.getAmount();
|
final String amount = this.getAmount();
|
||||||
Integer c = this.convertAmount();
|
Integer c = this.convertAmount();
|
||||||
if (c == null) {
|
if (c == null) {
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public class CostReturn extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
for (final Card c : this.getList()) {
|
for (final Card c : this.getList()) {
|
||||||
Singletons.getModel().getGameAction().moveToHand(c);
|
Singletons.getModel().getGameAction().moveToHand(c);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class CostReveal extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
GuiChoose.oneOrNone("Revealed cards:", this.getList());
|
GuiChoose.oneOrNone("Revealed cards:", this.getList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ public class CostSacrifice extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
this.addListToHash(ability, "Sacrificed");
|
this.addListToHash(ability, "Sacrificed");
|
||||||
for (final Card c : this.getList()) {
|
for (final Card c : this.getList()) {
|
||||||
Singletons.getModel().getGameAction().sacrifice(c, ability);
|
Singletons.getModel().getGameAction().sacrifice(c, ability);
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class CostTap extends CostPart {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
source.tap();
|
source.tap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class CostTapType extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
for (final Card c : this.getList()) {
|
for (final Card c : this.getList()) {
|
||||||
c.tap();
|
c.tap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class CostUntap extends CostPart {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
source.untap();
|
source.untap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ public class CostUntapType extends CostPartWithList {
|
|||||||
* forge.Card, forge.card.cost.Cost_Payment)
|
* forge.Card, forge.card.cost.Cost_Payment)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final void payAI(final SpellAbility ability, final Card source, final CostPayment payment) {
|
public final void payAI(final Player ai, final SpellAbility ability, final Card source, final CostPayment payment) {
|
||||||
for (final Card c : this.getList()) {
|
for (final Card c : this.getList()) {
|
||||||
c.untap();
|
c.untap();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public class CostUtil {
|
|||||||
* @param sourceAbility TODO
|
* @param sourceAbility TODO
|
||||||
* @return true, if successful
|
* @return true, if successful
|
||||||
*/
|
*/
|
||||||
public static boolean checkLifeCost(final Cost cost, final Card source, final int remainingLife, SpellAbility sourceAbility) {
|
public static boolean checkLifeCost(final Player ai, final Cost cost, final Card source, final int remainingLife, SpellAbility sourceAbility) {
|
||||||
// TODO - Pass in SA for everything else that calls this function
|
// TODO - Pass in SA for everything else that calls this function
|
||||||
if (cost == null) {
|
if (cost == null) {
|
||||||
return true;
|
return true;
|
||||||
@@ -157,7 +157,7 @@ public class CostUtil {
|
|||||||
amount = AbilityFactory.calculateAmount(source, payLife.getAmount(), sourceAbility);
|
amount = AbilityFactory.calculateAmount(source, payLife.getAmount(), sourceAbility);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((AllZone.getComputerPlayer().getLife() - amount) < remainingLife) {
|
if ((ai.getLife() - amount) < remainingLife) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,21 +176,20 @@ public class CostUtil {
|
|||||||
* the remaining life
|
* the remaining life
|
||||||
* @return true, if successful
|
* @return true, if successful
|
||||||
*/
|
*/
|
||||||
public static boolean checkDamageCost(final Cost cost, final Card source, final int remainingLife) {
|
public static boolean checkDamageCost(final Player ai, final Cost cost, final Card source, final int remainingLife) {
|
||||||
if (cost == null) {
|
if (cost == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (final CostPart part : cost.getCostParts()) {
|
for (final CostPart part : cost.getCostParts()) {
|
||||||
if (part instanceof CostDamage) {
|
if (part instanceof CostDamage) {
|
||||||
final CostDamage pay = (CostDamage) part;
|
final CostDamage pay = (CostDamage) part;
|
||||||
Player computer = AllZone.getComputerPlayer();
|
int realDamage = ai.predictDamage(pay.convertAmount(), source, false);
|
||||||
int realDamage = computer.predictDamage(pay.convertAmount(), source, false);
|
if (ai.getLife() - realDamage < remainingLife
|
||||||
if (computer.getLife() - realDamage < remainingLife
|
&& realDamage > 0 && !ai.cantLoseForZeroOrLessLife()
|
||||||
&& realDamage > 0 && !computer.cantLoseForZeroOrLessLife()
|
&& ai.canLoseLife()) {
|
||||||
&& computer.canLoseLife()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (source.getName().equals("Skullscorch") && computer.getCardsIn(ZoneType.Hand).size() < 2) {
|
if (source.getName().equals("Skullscorch") && ai.getCardsIn(ZoneType.Hand).size() < 2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ public class SpellPermanent extends Spell {
|
|||||||
|
|
||||||
if (cost != null) {
|
if (cost != null) {
|
||||||
// AI currently disabled for these costs
|
// AI currently disabled for these costs
|
||||||
if (!CostUtil.checkLifeCost(cost, card, 4, null)) {
|
if (!CostUtil.checkLifeCost(ai, cost, card, 4, null)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import forge.Card;
|
|||||||
import forge.CardPredicates;
|
import forge.CardPredicates;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.game.phase.CombatUtil;
|
import forge.game.phase.CombatUtil;
|
||||||
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.PlayerZone;
|
import forge.game.zone.PlayerZone;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.framework.SDisplayUtil;
|
import forge.gui.framework.SDisplayUtil;
|
||||||
@@ -98,7 +99,8 @@ public class InputAttack extends Input {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zone.is(ZoneType.Battlefield, AllZone.getHumanPlayer())
|
final Player human = Singletons.getControl().getPlayer();
|
||||||
|
if (zone.is(ZoneType.Battlefield, human)
|
||||||
&& CombatUtil.canAttack(card, AllZone.getCombat())) {
|
&& CombatUtil.canAttack(card, AllZone.getCombat())) {
|
||||||
|
|
||||||
// TODO add the propaganda code here and remove it in
|
// TODO add the propaganda code here and remove it in
|
||||||
@@ -109,7 +111,7 @@ public class InputAttack extends Input {
|
|||||||
AllZone.getCombat().addAttacker(card);
|
AllZone.getCombat().addAttacker(card);
|
||||||
|
|
||||||
// just to make sure the attack symbol is marked
|
// just to make sure the attack symbol is marked
|
||||||
AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers();
|
human.getZone(ZoneType.Battlefield).updateObservers();
|
||||||
CombatUtil.showCombat();
|
CombatUtil.showCombat();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class InputBlock extends Input {
|
|||||||
} else {
|
} else {
|
||||||
// Make sure this card is valid to even be a blocker
|
// Make sure this card is valid to even be a blocker
|
||||||
if (this.currentAttacker != null && card.isCreature() && card.getController().isHuman()
|
if (this.currentAttacker != null && card.isCreature() && card.getController().isHuman()
|
||||||
&& zone.is(ZoneType.Battlefield, AllZone.getHumanPlayer())) {
|
&& zone.is(ZoneType.Battlefield, Singletons.getControl().getPlayer())) {
|
||||||
// Create a new blockedBy list if it doesn't exist
|
// Create a new blockedBy list if it doesn't exist
|
||||||
if (!this.allBlocking.containsKey(card)) {
|
if (!this.allBlocking.containsKey(card)) {
|
||||||
this.allBlocking.put(card, new ArrayList<Card>());
|
this.allBlocking.put(card, new ArrayList<Card>());
|
||||||
|
|||||||
@@ -153,60 +153,59 @@ public class InputMulligan extends Input {
|
|||||||
// Human Leylines & Chancellors
|
// Human Leylines & Chancellors
|
||||||
ButtonUtil.reset();
|
ButtonUtil.reset();
|
||||||
final AbilityFactory af = new AbilityFactory();
|
final AbilityFactory af = new AbilityFactory();
|
||||||
final List<Card> humanOpeningHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand);
|
|
||||||
|
for (Player p : AllZone.getPlayersInGame()) {
|
||||||
for (final Card c : humanOpeningHand) {
|
final List<Card> openingHand = p.getCardsIn(ZoneType.Hand);
|
||||||
final ArrayList<String> kws = c.getKeyword();
|
|
||||||
for (int i = 0; i < kws.size(); i++) {
|
for (final Card c : openingHand) {
|
||||||
final String kw = kws.get(i);
|
if ( p.isHuman() ) {
|
||||||
|
final ArrayList<String> kws = c.getKeyword();
|
||||||
if (kw.startsWith("MayEffectFromOpeningHand")) {
|
for (int i = 0; i < kws.size(); i++) {
|
||||||
final String effName = kw.split(":")[1];
|
final String kw = kws.get(i);
|
||||||
|
|
||||||
final SpellAbility effect = af.getAbility(c.getSVar(effName), c);
|
if (kw.startsWith("MayEffectFromOpeningHand")) {
|
||||||
if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) {
|
final String effName = kw.split(":")[1];
|
||||||
// If we ever let the AI memorize cards in the players
|
|
||||||
// hand, this would be a place to do so.
|
final SpellAbility effect = af.getAbility(c.getSVar(effName), c);
|
||||||
ga.playSpellAbilityNoStack(effect, false);
|
if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) {
|
||||||
}
|
// If we ever let the AI memorize cards in the players
|
||||||
}
|
// hand, this would be a place to do so.
|
||||||
}
|
ga.playSpellAbilityNoStack(effect, false);
|
||||||
if (c.getName().startsWith("Leyline")) {
|
}
|
||||||
if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) {
|
|
||||||
ga.moveToPlay(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Computer Leylines & Chancellors
|
|
||||||
Player ai = AllZone.getComputerPlayer();
|
|
||||||
final List<Card> aiOpeningHand = ai.getCardsIn(ZoneType.Hand);
|
|
||||||
for (final Card c : aiOpeningHand) {
|
|
||||||
if (!c.getName().startsWith("Leyline")) {
|
|
||||||
final ArrayList<String> kws = c.getKeyword();
|
|
||||||
for (int i = 0; i < kws.size(); i++) {
|
|
||||||
final String kw = kws.get(i);
|
|
||||||
|
|
||||||
if (kw.startsWith("MayEffectFromOpeningHand")) {
|
|
||||||
final String effName = kw.split(":")[1];
|
|
||||||
|
|
||||||
final SpellAbility effect = af.getAbility(c.getSVar(effName), c);
|
|
||||||
|
|
||||||
// Is there a better way for the AI to decide this?
|
|
||||||
if (effect.doTrigger(false)) {
|
|
||||||
GameActionUtil.showInfoDialg("Computer reveals " + c.getName() + "(" + c.getUniqueNumber()
|
|
||||||
+ ").");
|
|
||||||
ComputerUtil.playNoStack(ai, effect);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (c.getName().startsWith("Leyline")) {
|
||||||
|
if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) {
|
||||||
|
ga.moveToPlay(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else { // Computer Leylines & Chancellors
|
||||||
|
if (!c.getName().startsWith("Leyline")) {
|
||||||
|
final ArrayList<String> kws = c.getKeyword();
|
||||||
|
for (int i = 0; i < kws.size(); i++) {
|
||||||
|
final String kw = kws.get(i);
|
||||||
|
|
||||||
|
if (kw.startsWith("MayEffectFromOpeningHand")) {
|
||||||
|
final String effName = kw.split(":")[1];
|
||||||
|
|
||||||
|
final SpellAbility effect = af.getAbility(c.getSVar(effName), c);
|
||||||
|
|
||||||
|
// Is there a better way for the AI to decide this?
|
||||||
|
if (effect.doTrigger(false)) {
|
||||||
|
GameActionUtil.showInfoDialg("Computer reveals " + c.getName() + "(" + c.getUniqueNumber() + ").");
|
||||||
|
ComputerUtil.playNoStack(p, effect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (c.getName().startsWith("Leyline")
|
||||||
|
&& !(c.getName().startsWith("Leyline of Singularity") && (AllZoneUtil.getCardsIn(ZoneType.Battlefield,
|
||||||
|
"Leyline of Singularity").size() > 0))) {
|
||||||
|
ga.moveToPlay(c);
|
||||||
|
//ga.checkStateEffects();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c.getName().startsWith("Leyline")
|
|
||||||
&& !(c.getName().startsWith("Leyline of Singularity") && (AllZoneUtil.getCardsIn(ZoneType.Battlefield,
|
|
||||||
"Leyline of Singularity").size() > 0))) {
|
|
||||||
ga.moveToPlay(c);
|
|
||||||
//ga.checkStateEffects();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//ga.checkStateEffects();
|
//ga.checkStateEffects();
|
||||||
|
|
||||||
|
|||||||
@@ -67,13 +67,16 @@ public class GameNew {
|
|||||||
Card.resetUniqueNumber();
|
Card.resetUniqueNumber();
|
||||||
|
|
||||||
for( PlayerStartsGame p : players ) {
|
for( PlayerStartsGame p : players ) {
|
||||||
p.getPlayer().setStartingLife(p.initialLives);
|
final Player player = p.getPlayer();
|
||||||
|
player.setStartingLife(p.initialLives);
|
||||||
// what if I call it for AI player?
|
// what if I call it for AI player?
|
||||||
p.getPlayer().updateObservers();
|
player.updateObservers();
|
||||||
p.getPlayer().setDeck(p.getDeck());
|
player.setDeck(p.getDeck());
|
||||||
PlayerZone bf = p.getPlayer().getZone(ZoneType.Battlefield);
|
PlayerZone bf = player.getZone(ZoneType.Battlefield);
|
||||||
if (p.cardsOnBattlefield != null) {
|
if (p.cardsOnBattlefield != null) {
|
||||||
for (final Card c : p.cardsOnBattlefield) {
|
for (final Card c : p.cardsOnBattlefield) {
|
||||||
|
c.addController(player);
|
||||||
|
c.setOwner(player);
|
||||||
bf.add(c, false);
|
bf.add(c, false);
|
||||||
c.setSickness(true);
|
c.setSickness(true);
|
||||||
c.setStartsGameInPlay(true);
|
c.setStartsGameInPlay(true);
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ public class GauntletMini {
|
|||||||
* Draft mode status.
|
* Draft mode status.
|
||||||
* @return boolean, gauntletDraft
|
* @return boolean, gauntletDraft
|
||||||
*/
|
*/
|
||||||
public final boolean getGauntletDraft() {
|
public final boolean isGauntletDraft() {
|
||||||
return gauntletDraft;
|
return gauntletDraft;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,8 +237,9 @@ public class Untap extends Phase implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (AllZoneUtil.isCardInPlay("Damping Field") || AllZoneUtil.isCardInPlay("Imi Statue")) {
|
if (AllZoneUtil.isCardInPlay("Damping Field") || AllZoneUtil.isCardInPlay("Imi Statue")) {
|
||||||
if (Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().isComputer()) {
|
final Player turnOwner = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn();
|
||||||
List<Card> artList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield);
|
if (turnOwner.isComputer()) {
|
||||||
|
List<Card> artList = turnOwner.getCardsIn(ZoneType.Battlefield);
|
||||||
artList = CardLists.filter(artList, Presets.ARTIFACTS);
|
artList = CardLists.filter(artList, Presets.ARTIFACTS);
|
||||||
artList = CardLists.filter(artList, tappedCanUntap);
|
artList = CardLists.filter(artList, tappedCanUntap);
|
||||||
if (artList.size() > 0) {
|
if (artList.size() > 0) {
|
||||||
@@ -268,7 +269,7 @@ public class Untap extends Phase implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
} // selectCard()
|
} // selectCard()
|
||||||
}; // Input
|
}; // Input
|
||||||
List<Card> artList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield);
|
List<Card> artList = turnOwner.getCardsIn(ZoneType.Battlefield);
|
||||||
artList = CardLists.filter(artList, Presets.ARTIFACTS);
|
artList = CardLists.filter(artList, Presets.ARTIFACTS);
|
||||||
artList = CardLists.filter(artList, tappedCanUntap);
|
artList = CardLists.filter(artList, tappedCanUntap);
|
||||||
if (artList.size() > 0) {
|
if (artList.size() > 0) {
|
||||||
|
|||||||
@@ -1216,13 +1216,6 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
|||||||
boolean wantDamageCreatures = false;
|
boolean wantDamageCreatures = false;
|
||||||
final String[] smallCreatures = { "Creature.toughnessLE2" };
|
final String[] smallCreatures = { "Creature.toughnessLE2" };
|
||||||
|
|
||||||
List<Card> humanCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
|
|
||||||
humanCreatures = CardLists.getValidCards(humanCreatures, smallCreatures, k.getController(), k);
|
|
||||||
humanCreatures = CardLists.getNotKeyword(humanCreatures, "Indestructible");
|
|
||||||
|
|
||||||
List<Card> computerCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer());
|
|
||||||
computerCreatures = CardLists.getValidCards(computerCreatures, smallCreatures, k.getController(), k);
|
|
||||||
computerCreatures = CardLists.getNotKeyword(computerCreatures, "Indestructible");
|
|
||||||
|
|
||||||
// We assume that both players will want to peek, ask if
|
// We assume that both players will want to peek, ask if
|
||||||
// they want to reveal.
|
// they want to reveal.
|
||||||
@@ -1242,6 +1235,15 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
|||||||
}
|
}
|
||||||
// player isComputer()
|
// player isComputer()
|
||||||
else {
|
else {
|
||||||
|
List<Card> humanCreatures = AllZoneUtil.getCreaturesInPlay(player.getOpponent());
|
||||||
|
humanCreatures = CardLists.getValidCards(humanCreatures, smallCreatures, k.getController(), k);
|
||||||
|
humanCreatures = CardLists.getNotKeyword(humanCreatures, "Indestructible");
|
||||||
|
|
||||||
|
List<Card> computerCreatures = AllZoneUtil.getCreaturesInPlay(player);
|
||||||
|
computerCreatures = CardLists.getValidCards(computerCreatures, smallCreatures, k.getController(), k);
|
||||||
|
computerCreatures = CardLists.getNotKeyword(computerCreatures, "Indestructible");
|
||||||
|
|
||||||
|
|
||||||
if (humanCreatures.size() > computerCreatures.size()) {
|
if (humanCreatures.size() > computerCreatures.size()) {
|
||||||
final String title = "Computer reveals";
|
final String title = "Computer reveals";
|
||||||
this.revealTopCard(title);
|
this.revealTopCard(title);
|
||||||
@@ -2203,7 +2205,7 @@ public class Upkeep extends Phase implements java.io.Serializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectCard(final Card card, final PlayerZone zone) {
|
public void selectCard(final Card card, final PlayerZone zone) {
|
||||||
if (zone.is(ZoneType.Battlefield, AllZone.getHumanPlayer())
|
if (zone.is(ZoneType.Battlefield, player)
|
||||||
&& list.contains(card)) {
|
&& list.contains(card)) {
|
||||||
card.tap();
|
card.tap();
|
||||||
list.remove(card);
|
list.remove(card);
|
||||||
|
|||||||
@@ -51,18 +51,19 @@ public class ViewWinLose {
|
|||||||
btnContinue = new FButton();
|
btnContinue = new FButton();
|
||||||
btnRestart = new FButton();
|
btnRestart = new FButton();
|
||||||
btnQuit = new FButton();
|
btnQuit = new FButton();
|
||||||
|
|
||||||
|
final Player human = Singletons.getControl().getPlayer();
|
||||||
|
|
||||||
// Control of the win/lose is handled differently for various game modes.
|
// Control of the win/lose is handled differently for various game modes.
|
||||||
ControlWinLose control;
|
ControlWinLose control;
|
||||||
if (Singletons.getModel().getMatchState().getGameType() == GameType.Quest) {
|
if (matchState.getGameType() == GameType.Quest) {
|
||||||
control = new QuestWinLoseHandler(this);
|
control = new QuestWinLoseHandler(this);
|
||||||
}
|
}
|
||||||
else if (Singletons.getModel().getMatchState().getGameType() == GameType.Sealed
|
else if (matchState.getGameType() == GameType.Sealed
|
||||||
|| (Singletons.getModel().getMatchState().getGameType() == GameType.Draft && AllZone.getGauntlet().getGauntletDraft())) {
|
|| (matchState.getGameType() == GameType.Draft && AllZone.getGauntlet().isGauntletDraft())) {
|
||||||
|
|
||||||
control = new GauntletWinLose(this);
|
control = new GauntletWinLose(this);
|
||||||
}
|
}
|
||||||
else if (Singletons.getModel().getMatchState().getGameType() == GameType.Gauntlet) {
|
else if (matchState.getGameType() == GameType.Gauntlet) {
|
||||||
control = new OtherGauntletWinLose(this);
|
control = new OtherGauntletWinLose(this);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -102,7 +103,7 @@ public class ViewWinLose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Show Wins and Loses
|
// Show Wins and Loses
|
||||||
final Player human = AllZone.getHumanPlayer();
|
|
||||||
final int humanWins = matchState.countGamesWonBy(human);
|
final int humanWins = matchState.countGamesWonBy(human);
|
||||||
final int humanLosses = matchState.getGamesPlayedCount() - humanWins;
|
final int humanLosses = matchState.getGamesPlayedCount() - humanWins;
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package forge.quest;
|
package forge.quest;
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
|
|
||||||
import forge.card.cardfactory.CardFactory;
|
import forge.card.cardfactory.CardFactory;
|
||||||
import forge.game.player.Player;
|
|
||||||
import forge.item.CardDb;
|
import forge.item.CardDb;
|
||||||
import forge.quest.bazaar.QuestPetController;
|
import forge.quest.bazaar.QuestPetController;
|
||||||
|
|
||||||
@@ -70,7 +68,7 @@ public class QuestUtil {
|
|||||||
final List<String> extras = ((QuestEventChallenge) qe).getAIExtraCards();
|
final List<String> extras = ((QuestEventChallenge) qe).getAIExtraCards();
|
||||||
|
|
||||||
for (final String s : extras) {
|
for (final String s : extras) {
|
||||||
list.add(QuestUtil.readExtraCard(s, AllZone.getComputerPlayer()));
|
list.add(QuestUtil.readExtraCard(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,9 +95,8 @@ public class QuestUtil {
|
|||||||
if (pet != null) {
|
if (pet != null) {
|
||||||
Card c = pet.getPetCard(qc.getAssets());
|
Card c = pet.getPetCard(qc.getAssets());
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
Card copy = CardFactory.getCard2(c, AllZone.getHumanPlayer());
|
Card copy = CardFactory.getCard2(c, null);
|
||||||
copy.setSickness(true);
|
copy.setSickness(true);
|
||||||
copy.addController(AllZone.getHumanPlayer());
|
|
||||||
copy.setImageName(c.getImageName());
|
copy.setImageName(c.getImageName());
|
||||||
copy.setToken(true);
|
copy.setToken(true);
|
||||||
list.add(copy);
|
list.add(copy);
|
||||||
@@ -130,7 +127,7 @@ public class QuestUtil {
|
|||||||
final List<String> extras = ((QuestEventChallenge) qe).getHumanExtraCards();
|
final List<String> extras = ((QuestEventChallenge) qe).getHumanExtraCards();
|
||||||
|
|
||||||
for (final String s : extras) {
|
for (final String s : extras) {
|
||||||
list.add(QuestUtil.readExtraCard(s, AllZone.getHumanPlayer()));
|
list.add(QuestUtil.readExtraCard(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,17 +178,15 @@ public class QuestUtil {
|
|||||||
* the owner
|
* the owner
|
||||||
* @return the card
|
* @return the card
|
||||||
*/
|
*/
|
||||||
public static Card readExtraCard(final String name, final Player owner) {
|
public static Card readExtraCard(final String name) {
|
||||||
// Token card creation
|
// Token card creation
|
||||||
Card tempcard;
|
Card tempcard;
|
||||||
if (name.startsWith("TOKEN")) {
|
if (name.startsWith("TOKEN")) {
|
||||||
tempcard = QuestUtil.createToken(name);
|
tempcard = QuestUtil.createToken(name);
|
||||||
tempcard.addController(owner);
|
|
||||||
tempcard.setOwner(owner);
|
|
||||||
}
|
}
|
||||||
// Standard card creation
|
// Standard card creation
|
||||||
else {
|
else {
|
||||||
tempcard = CardDb.instance().getCard(name, true).toForgeCard(owner);
|
tempcard = CardDb.instance().getCard(name, true).toForgeCard();
|
||||||
}
|
}
|
||||||
return tempcard;
|
return tempcard;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user