mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
consolidating Doubling Season code (part 1/2)
This commit is contained in:
@@ -572,4 +572,11 @@ public class AllZoneUtil {
|
|||||||
|
|
||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getDoublingSeasonMagnitude(Player player) {
|
||||||
|
int multiplier = 1;
|
||||||
|
int doublingSeasons = getPlayerCardsInPlay(player, "Doubling Season").size();
|
||||||
|
if(doublingSeasons > 0) multiplier = (int) Math.pow(2, doublingSeasons);
|
||||||
|
return multiplier;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -327,10 +327,7 @@ public class Card extends MyObservable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addCounter(Counters counterName, int n) {
|
public void addCounter(Counters counterName, int n) {
|
||||||
int multiplier = 1;
|
int multiplier = AllZoneUtil.getDoublingSeasonMagnitude(this.getController());
|
||||||
int doublingSeasons = AllZoneUtil.getPlayerCardsInPlay(this.getController(), "Doubling Season").size();
|
|
||||||
if(doublingSeasons > 0) multiplier = (int) Math.pow(2, doublingSeasons);
|
|
||||||
|
|
||||||
if(counters.containsKey(counterName)) {
|
if(counters.containsKey(counterName)) {
|
||||||
Integer aux = counters.get(counterName) + (multiplier * n);
|
Integer aux = counters.get(counterName) + (multiplier * n);
|
||||||
counters.put(counterName, aux);
|
counters.put(counterName, aux);
|
||||||
|
|||||||
@@ -10214,13 +10214,13 @@ public class CardFactory implements NewConstants {
|
|||||||
}
|
}
|
||||||
public boolean canPlayAI()
|
public boolean canPlayAI()
|
||||||
{
|
{
|
||||||
int m = (int)Math.pow(2, AllZoneUtil.getPlayerCardsInPlay(AllZone.ComputerPlayer, "Doubling Season").size());
|
int m = AllZoneUtil.getDoublingSeasonMagnitude(AllZone.ComputerPlayer);
|
||||||
int n = Math.max(1, Math.min((100-getSourceCard().getCounters(Counters.TOWER))/m,
|
int n = Math.max(1, Math.min((100-getSourceCard().getCounters(Counters.TOWER))/m,
|
||||||
ComputerUtil.getAvailableMana().size())) ;
|
ComputerUtil.getAvailableMana().size())) ;
|
||||||
setManaCost(n + "");
|
setManaCost(n + "");
|
||||||
return !(new CardList(AllZone.Computer_Hand.getCards()).containsName("Doubling Season") && n>=5 )
|
return !(new CardList(AllZone.Computer_Hand.getCards()).containsName("Doubling Season") && n>=5 )
|
||||||
&& m*n >= Math.min(20, 100 - getSourceCard().getCounters(Counters.TOWER));
|
&& m*n >= Math.min(20, 100 - getSourceCard().getCounters(Counters.TOWER));
|
||||||
//Persuming if AI cast the Pinnacle, it has green mana
|
//Presuming if AI cast the Pinnacle, it has green mana
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ability.setBeforePayMana(new Input()
|
ability.setBeforePayMana(new Input()
|
||||||
|
|||||||
@@ -544,15 +544,12 @@ public class CardFactory_Creatures {
|
|||||||
&& getTargetCard().getController().equals(card.getController())
|
&& getTargetCard().getController().equals(card.getController())
|
||||||
&& CardFactoryUtil.canTarget(card, getTargetCard())) {
|
&& CardFactoryUtil.canTarget(card, getTargetCard())) {
|
||||||
|
|
||||||
int multiplier = 1;
|
int multiplier = AllZoneUtil.getDoublingSeasonMagnitude(card.getController());
|
||||||
int doublingSeasons = AllZoneUtil.getPlayerCardsInPlay(card.getController(), "Doubling Season").size();
|
|
||||||
if(doublingSeasons > 0) multiplier = (int) Math.pow(2, doublingSeasons);
|
|
||||||
Card[] crds = new Card[multiplier];
|
Card[] crds = new Card[multiplier];
|
||||||
|
|
||||||
for (int i=0;i<multiplier;i++)
|
for (int i=0;i<multiplier;i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
Card copy;
|
Card copy;
|
||||||
if(!getTargetCard().isToken()) {
|
if(!getTargetCard().isToken()) {
|
||||||
//CardFactory cf = new CardFactory("cards.txt");
|
//CardFactory cf = new CardFactory("cards.txt");
|
||||||
@@ -10070,9 +10067,7 @@ public class CardFactory_Creatures {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
int multiplier = 1;
|
int multiplier = AllZoneUtil.getDoublingSeasonMagnitude(card.getController());
|
||||||
int doublingSeasons = AllZoneUtil.getPlayerCardsInPlay(card.getController(), "Doubling Season").size();
|
|
||||||
if(doublingSeasons > 0) multiplier = (int) Math.pow(2, doublingSeasons);
|
|
||||||
|
|
||||||
for(int i = 0; i < allTokens.size(); i++) {
|
for(int i = 0; i < allTokens.size(); i++) {
|
||||||
Card c = allTokens.get(i);
|
Card c = allTokens.get(i);
|
||||||
|
|||||||
@@ -4284,11 +4284,8 @@ public class CardFactory_Sorceries {
|
|||||||
if(AllZone.GameAction.isCardInPlay(getTargetCard())
|
if(AllZone.GameAction.isCardInPlay(getTargetCard())
|
||||||
&& CardFactoryUtil.canTarget(card, getTargetCard())) {
|
&& CardFactoryUtil.canTarget(card, getTargetCard())) {
|
||||||
PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
|
PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
|
||||||
CardList DoublingSeasons = new CardList(play.getCards());
|
|
||||||
DoublingSeasons = DoublingSeasons.getName("Doubling Season");
|
|
||||||
PlayerZone_ComesIntoPlay.SimultaneousEntry = true;
|
PlayerZone_ComesIntoPlay.SimultaneousEntry = true;
|
||||||
double Count = DoublingSeasons.size();
|
double Count = AllZoneUtil.getDoublingSeasonMagnitude(card.getController());
|
||||||
Count = Math.pow(2,Count);
|
|
||||||
for(int i = 0; i < Count; i++) {
|
for(int i = 0; i < Count; i++) {
|
||||||
if(i + 1== Count) PlayerZone_ComesIntoPlay.SimultaneousEntry = false;
|
if(i + 1== Count) PlayerZone_ComesIntoPlay.SimultaneousEntry = false;
|
||||||
Card Copy = AllZone.CardFactory.copyCardintoNew(getTargetCard());
|
Card Copy = AllZone.CardFactory.copyCardintoNew(getTargetCard());
|
||||||
@@ -4354,11 +4351,8 @@ public class CardFactory_Sorceries {
|
|||||||
if(AllZone.GameAction.isCardInPlay(getTargetCard())
|
if(AllZone.GameAction.isCardInPlay(getTargetCard())
|
||||||
&& CardFactoryUtil.canTarget(card, getTargetCard())) {
|
&& CardFactoryUtil.canTarget(card, getTargetCard())) {
|
||||||
PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
|
PlayerZone play = AllZone.getZone(Constant.Zone.Play, card.getController());
|
||||||
CardList DoublingSeasons = new CardList(play.getCards());
|
|
||||||
DoublingSeasons = DoublingSeasons.getName("Doubling Season");
|
|
||||||
PlayerZone_ComesIntoPlay.SimultaneousEntry = true;
|
PlayerZone_ComesIntoPlay.SimultaneousEntry = true;
|
||||||
int Count = DoublingSeasons.size();
|
int Count = 5 * AllZoneUtil.getDoublingSeasonMagnitude(card.getController());
|
||||||
Count = 5 * (int)Math.pow(2,Count);
|
|
||||||
for(int i = 0; i < Count; i++) {
|
for(int i = 0; i < Count; i++) {
|
||||||
if(i + 1 == Count) PlayerZone_ComesIntoPlay.SimultaneousEntry = false;
|
if(i + 1 == Count) PlayerZone_ComesIntoPlay.SimultaneousEntry = false;
|
||||||
Card Copy = AllZone.CardFactory.copyCardintoNew(getTargetCard());
|
Card Copy = AllZone.CardFactory.copyCardintoNew(getTargetCard());
|
||||||
|
|||||||
Reference in New Issue
Block a user