Revert "Zeth Fixes"

This reverts commit 78d3828f1e.
This commit is contained in:
Anthony Calosa
2016-07-07 09:16:03 +08:00
parent cf71f84e49
commit e39dee6e1d
9 changed files with 1611 additions and 1640 deletions
+247 -259
View File
@@ -41,111 +41,111 @@ public:
class MTGRevealingCards : public MTGAbility, public CardDisplay
{
public:
vector<CardView*> cards;
Player * playerForZone;
MTGGameZone * RevealZone;
MTGGameZone * RevealFromZone;
string revealCertainTypes;
string revealUntil;
vector<CardView*> cards;
Player * playerForZone;
MTGGameZone * RevealZone;
MTGGameZone * RevealFromZone;
string revealCertainTypes;
string revealUntil;
CardDisplay * revealDisplay;
vector<CardDisplay*>trashDisplays;//used for repeat
int nbCard;
string abilityString;
string number;
string abilityOne;
string abilityTwo;
string afterReveal;
bool afterEffectActivated;
MTGAbility * abilityToCast;
MTGAbility * abilityFirst;
MTGAbility * abilitySecond;
MTGAbility * abilityAfter;
vector<MTGAbility*>abilities;
bool repeat;//only the first ability can be repeated, and it must be targeted.
bool initCD;
CardDisplay * revealDisplay;
vector<CardDisplay*>trashDisplays;//used for repeat
int nbCard;
string abilityString;
string number;
string abilityOne;
string abilityTwo;
string afterReveal;
bool afterEffectActivated;
MTGAbility * abilityToCast;
MTGAbility * abilityFirst;
MTGAbility * abilitySecond;
MTGAbility * abilityAfter;
vector<MTGAbility*>abilities;
bool repeat;//only the first ability can be repeated, and it must be targeted.
bool initCD;
void Update(float dt);
int testDestroy();
int toResolve();
void CardViewBackup(MTGCardInstance * backup);
void Render();
bool CheckUserInput(JButton key);
MTGAbility * contructAbility(string abilityToMake = "");
MTGRevealingCards(GameObserver* observer, int _id, MTGCardInstance * card, string text);
virtual MTGRevealingCards * clone() const;
~MTGRevealingCards();
int receiveEvent(WEvent*);
void Update(float dt);
int testDestroy();
int toResolve();
void CardViewBackup(MTGCardInstance * backup);
void Render();
bool CheckUserInput(JButton key);
MTGAbility * contructAbility(string abilityToMake = "");
MTGRevealingCards(GameObserver* observer, int _id, MTGCardInstance * card, string text);
virtual MTGRevealingCards * clone() const;
~MTGRevealingCards();
int receiveEvent(WEvent*);
};
class RevealDisplay : public CardDisplay
{
public:
RevealDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener = NULL, TargetChooser * tc = NULL,
int nb_displayed_items = 7);
void AddCard(MTGCardInstance * _card);
bool CheckUserInput(JButton key);
RevealDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener = NULL, TargetChooser * tc = NULL,
int nb_displayed_items = 7);
void AddCard(MTGCardInstance * _card);
bool CheckUserInput(JButton key);
};
class GenericRevealAbility : public ActivatedAbility
{
public:
string howMany;
MTGRevealingCards * ability;
GenericRevealAbility(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target, string _howMany);
int resolve();
const string getMenuText();
GenericRevealAbility * clone() const;
~GenericRevealAbility();
string howMany;
MTGRevealingCards * ability;
GenericRevealAbility(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target, string _howMany);
int resolve();
const string getMenuText();
GenericRevealAbility * clone() const;
~GenericRevealAbility();
};
class MTGScryCards : public MTGAbility, public CardDisplay
{
public:
vector<CardView*> cards;
MTGGameZone * RevealZone;
MTGGameZone * RevealFromZone;
vector<CardView*> cards;
MTGGameZone * RevealZone;
MTGGameZone * RevealFromZone;
CardDisplay * revealDisplay;
vector<CardDisplay*>trashDisplays;//used for repeat
int nbCard;
bool delayed;
bool dontRevealAfter;
int revealTopAmount;
string delayedAbilityString;
string abilityString;
string number;
string abilityOne;
string abilityTwo;
MTGAbility * abilityToCast;
MTGAbility * abilityFirst;
MTGAbility * abilitySecond;
vector<MTGAbility*>abilities;
bool initCD;
void Update(float dt);
int testDestroy();
void initDisplay(int value = 0);
int toResolve();
void Render();
bool CheckUserInput(JButton key);
MTGAbility * contructAbility(string abilityToMake = "");
MTGScryCards(GameObserver* observer, int _id, MTGCardInstance * card, string text);
virtual MTGScryCards * clone() const;
~MTGScryCards();
int receiveEvent(WEvent*);
CardDisplay * revealDisplay;
vector<CardDisplay*>trashDisplays;//used for repeat
int nbCard;
bool delayed;
bool dontRevealAfter;
int revealTopAmount;
string delayedAbilityString;
string abilityString;
string number;
string abilityOne;
string abilityTwo;
MTGAbility * abilityToCast;
MTGAbility * abilityFirst;
MTGAbility * abilitySecond;
vector<MTGAbility*>abilities;
bool initCD;
void Update(float dt);
int testDestroy();
void initDisplay(int value = 0);
int toResolve();
void Render();
bool CheckUserInput(JButton key);
MTGAbility * contructAbility(string abilityToMake = "");
MTGScryCards(GameObserver* observer, int _id, MTGCardInstance * card, string text);
virtual MTGScryCards * clone() const;
~MTGScryCards();
int receiveEvent(WEvent*);
};
class GenericScryAbility : public ActivatedAbility
{
public:
string howMany;
MTGScryCards * ability;
GenericScryAbility(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target, string _howMany);
int resolve();
const string getMenuText();
GenericScryAbility * clone() const;
~GenericScryAbility();
string howMany;
MTGScryCards * ability;
GenericScryAbility(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target, string _howMany);
int resolve();
const string getMenuText();
GenericScryAbility * clone() const;
~GenericScryAbility();
};
@@ -166,11 +166,11 @@ private:
{
if(!s.size())
return;
if (!card)
{
intValue = atoi(s.c_str());//if there is no card, try parsing a number.
return;
}
if (!card)
{
intValue = atoi(s.c_str());//if there is no card, try parsing a number.
return;
}
MTGCardInstance * target = card->target;
if(!card->storedCard)
card->storedCard = card->storedSourceCard;
@@ -179,8 +179,10 @@ private:
bool halfdown = false;
bool twice = false;
bool thrice = false;
bool plusone = false;
bool plustwo = false;
bool plusthree = false;
bool other = false;//othertype:[subtype]
if (!target) target = card;
int multiplier = 1;
if (s[0] == '-')
@@ -229,7 +231,24 @@ private:
size_t tXXX = s.find("thrice");
s.erase(tXXX,tXXX + 6);
}
if(s.find("plusone") != string::npos)
{
plusone = true;
size_t pOne = s.find("plusone");
s.erase(pOne,pOne + 7);
}
if(s.find("plustwo") != string::npos)
{
plustwo = true;
size_t pTwo = s.find("plustwo");
s.erase(pTwo,pTwo + 7);
}
if(s.find("plusthree") != string::npos)
{
plusthree = true;
size_t pThree = s.find("plusthree");
s.erase(pThree,pThree + 9);
}
if(s.find("othertype") != string::npos)
{
other = true;
@@ -254,58 +273,18 @@ private:
size_t otc = s.find("otherconvertedcost");
s.erase(otc,otc + 5);
}
if (s.find("plusend") != string::npos || s.find("minusend") != string::npos || s.find("math") != string::npos)
if(s == "prex")
{
//plus#plusend and minus#minusend splits the first part and second parts and parses the
//ints for each part, then either adds or subtracts those 2 variables as specified.
vector<string>mathFound = parseBetween(s, "math", "mathend", true);
if (mathFound.size())//maths allows us to get the value before applying multipliers
{
WParsedInt numPar(mathFound[1], NULL, card);
intValue = numPar.getValue();
}
else
{
vector<string>plusSplit = parseBetween(s, "", "plus", true);
if (plusSplit.size())
{
WParsedInt numPar(plusSplit[1], NULL, card);
intValue = numPar.getValue();
}
vector<string>plusFound = parseBetween(s, "plus", "plusend", true);
if (plusFound.size())
{
WParsedInt numPar(plusFound[1], NULL, card);
intValue += numPar.getValue();
}
vector<string>minusSplit = parseBetween(s, "", "minus", true);
if (minusSplit.size())
{
WParsedInt numPar(minusSplit[1], NULL, card);
intValue = numPar.getValue();
}
vector<string>minusFound = parseBetween(s, "minus", "minusend", true);
if (minusFound.size())
{
WParsedInt numPar(minusFound[1], NULL, card);
intValue -= numPar.getValue();
}
}
}
else if(s == "prex")
{
if (card->setX > -1)
{
intValue = card->setX;
}
else
{
ManaCost * cX = card->controller()->getManaPool()->Diff(card->getManaCost());
intValue = cX->getCost(Constants::NB_Colors);
delete cX;
}
if (card->setX > -1)
{
intValue = card->setX;
}
else
{
ManaCost * cX = card->controller()->getManaPool()->Diff(card->getManaCost());
intValue = cX->getCost(Constants::NB_Colors);
delete cX;
}
}
else if (s == "x" || s == "X")
{
@@ -382,10 +361,10 @@ private:
{
intValue = countDevotionTo(card,card->controller()->inPlay(),Constants::MTG_COLOR_BLUE,Constants::MTG_COLOR_GREEN);
}
else if (s == "Iroas")//devotion to red white
{
intValue = countDevotionTo(card, card->controller()->inPlay(), Constants::MTG_COLOR_RED, Constants::MTG_COLOR_WHITE);
}
else if (s == "Iroas")//devotion to red white
{
intValue = countDevotionTo(card, card->controller()->inPlay(), Constants::MTG_COLOR_RED, Constants::MTG_COLOR_WHITE);
}
else if (s.find("type:") != string::npos)
{
size_t begins = s.find("type:");
@@ -702,10 +681,10 @@ private:
{
intValue = target->getCurrentToughness();
}
else if (s == "countedamount")
{
intValue = target->CountedObjects;
}
else if (s == "countedamount")
{
intValue = target->CountedObjects;
}
else if (s == "kicked")
{
intValue = target->kicked;
@@ -827,18 +806,12 @@ private:
else if (s == "pbasiclandtypes")//Basic Land types
{
MTGGameZone * checkZone = card->controller()->inPlay();
intValue = //mtg rules 205.4c
cardHasTypeinZone("waste", checkZone) +
cardHasTypeinZone("forest", checkZone) +
cardHasTypeinZone("plains", checkZone) +
cardHasTypeinZone("swamp", checkZone) +
cardHasTypeinZone("island", checkZone) +
cardHasTypeinZone("mountain", checkZone) +
cardHasTypeinZone("snow-covered forest", checkZone) +
cardHasTypeinZone("snow-covered plains", checkZone) +
cardHasTypeinZone("snow-covered swamp", checkZone) +
cardHasTypeinZone("snow-covered island", checkZone) +
cardHasTypeinZone("snow-covered mountain", checkZone);
intValue =
cardHasTypeinZone("forest",checkZone) +
cardHasTypeinZone("plains",checkZone) +
cardHasTypeinZone("swamp",checkZone) +
cardHasTypeinZone("island",checkZone) +
cardHasTypeinZone("mountain",checkZone);
}
else if (s == "myname")//Name of the card you control
{
@@ -885,6 +858,13 @@ private:
cardHasTypeinZone("artifact",checkZone);
}
}
else if (s == "morethanfourcards")
{
intValue = 0;
int damage = card->playerTarget ? card->playerTarget->game->hand->nb_cards - 4 : card->controller()->opponent()->game->hand->nb_cards - 4;
if ( damage > 0 )
intValue = damage;
}
else if (s == "powertotalinplay")//Count Total Power of Creatures you control... Formidable
{
intValue = 0;
@@ -894,47 +874,55 @@ private:
intValue += card->controller()->game->inPlay->cards[j]->power;
}
}
else if (s == "revealedp")
{
if (card->revealedLast)
intValue = card->revealedLast->power;
}
else if (s == "revealedt")
{
if (card->revealedLast)
intValue = card->revealedLast->toughness;
}
else if (s == "revealedmana")
{
if (card->revealedLast)
intValue = card->revealedLast->getManaCost()->getConvertedCost();
}
else if(!intValue)//found nothing, try parsing a atoi
else if (s == "revealedp")
{
if (card->revealedLast)
intValue = card->revealedLast->power;
}
else if (s == "revealedt")
{
if (card->revealedLast)
intValue = card->revealedLast->toughness;
}
else if (s == "revealedmana")
{
if (card->revealedLast)
intValue = card->revealedLast->getManaCost()->getConvertedCost();
}
else
{
intValue = atoi(s.c_str());
}
if (intValue > 0)//dont divide by 0 the rest are valid.
if(intValue > 0)
{
if (halfup)
if(halfup)
{
if (intValue % 2 == 1)
if(intValue%2 == 1)
intValue++;
intValue = intValue / 2;
intValue = intValue/2;
}
if (halfdown)
intValue = intValue / 2;
if(halfdown)
intValue = intValue/2;
if(twice)
intValue = intValue*2;
if(thrice)
intValue = intValue*3;
if(plusone)
intValue = intValue+1;
if(plustwo)
intValue = intValue+2;
if(plusthree)
intValue = intValue+3;
}
if (twice)
intValue = intValue * 2;
if (thrice)
intValue = intValue * 3;
if (intValue < 0)
else
{
//we remove "-" at the start and are parsing for real values.
//if we ended up with a value less than 0, then we return just 0
intValue = 0;
if(plusone)
intValue = intValue+1;
if(plustwo)
intValue = intValue+2;
if(plusthree)
intValue = intValue+3;
}
intValue *= multiplier;
}
public:
@@ -3489,7 +3477,7 @@ public:
list<int> colors;
int power, toughness;
int tokenId;
string _cardName;
string _cardName;
string name;
string sabilities;
string starfound;
@@ -3501,7 +3489,7 @@ public:
MTGCardInstance * myToken;
vector<MTGAbility *> currentAbilities;
Player * tokenReciever;
//by id
//by id
ATokenCreator(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable *, ManaCost * _cost, int tokenId,string starfound, WParsedInt * multiplier = NULL,
int who = 0,bool aLivingWeapon = false) :
ActivatedAbility(observer, _id, _source, _cost, 0), tokenId(tokenId), starfound(starfound),multiplier(multiplier), who(who),aLivingWeapon(aLivingWeapon)
@@ -3511,18 +3499,18 @@ public:
if (card) name = card->data->getName();
battleReady = false;
}
//by name, card still require valid card.dat info, this just makes the primitive code far more readable. token(Eldrazi scion) instead of token(-1234234)...
ATokenCreator(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable *, ManaCost * _cost, string cardName, string starfound, WParsedInt * multiplier = NULL,
int who = 0, bool aLivingWeapon = false) :
ActivatedAbility(observer, _id, _source, _cost, 0), _cardName(cardName), starfound(starfound), multiplier(multiplier), who(who), aLivingWeapon(aLivingWeapon)
{
if (!multiplier) this->multiplier = NEW WParsedInt(1);
MTGCard * card = MTGCollection()->getCardByName(_cardName);
tokenId = card->getId();
if (card) name = card->data->getName();
battleReady = false;
}
//by construction
//by name, card still require valid card.dat info, this just makes the primitive code far more readable. token(Eldrazi scion) instead of token(-1234234)...
ATokenCreator(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable *, ManaCost * _cost, string cardName, string starfound, WParsedInt * multiplier = NULL,
int who = 0, bool aLivingWeapon = false) :
ActivatedAbility(observer, _id, _source, _cost, 0), _cardName(cardName), starfound(starfound), multiplier(multiplier), who(who), aLivingWeapon(aLivingWeapon)
{
if (!multiplier) this->multiplier = NEW WParsedInt(1);
MTGCard * card = MTGCollection()->getCardByName(_cardName);
tokenId = card->getId();
if (card) name = card->data->getName();
battleReady = false;
}
//by construction
ATokenCreator(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable *, ManaCost * _cost, string sname, string stypes, int _power, int _toughness,
string sabilities, string starfound,WParsedInt * multiplier = NULL, int _who = 0,bool aLivingWeapon = false,string spt = "") :
ActivatedAbility(observer, _id, _source, _cost, 0),sabilities(sabilities),starfound(starfound), multiplier(multiplier), who(_who),aLivingWeapon(aLivingWeapon),spt(spt)
@@ -4045,12 +4033,12 @@ class AThis: public MTGAbility, public NestedAbility
public:
MTGAbility * a;
ThisDescriptor * td;
string restrictionCheck;
string restrictionCheck;
AThis(GameObserver* observer, int _id, MTGCardInstance * _source, Damageable * _target, ThisDescriptor * _td, MTGAbility * ability, string restriction = "") :
MTGAbility(observer, _id, _source, _target), NestedAbility(ability)
{
td = _td;
restrictionCheck = restriction;
restrictionCheck = restriction;
ability->source = source;
ability->target = target;
a = NULL;
@@ -4074,18 +4062,18 @@ public:
int resolve()
{
int match = 0;
if (td)
{
match = td->match(source);
}
else
{//restriction check instead of Targetchooser
AbilityFactory abf(target->getObserver());
int checkCond = abf.parseCastRestrictions(source, source->controller(), restrictionCheck);
if (checkCond)
match = 1;
}
int match = 0;
if (td)
{
match = td->match(source);
}
else
{//restriction check instead of Targetchooser
AbilityFactory abf(target->getObserver());
int checkCond = abf.parseCastRestrictions(source, source->controller(), restrictionCheck);
if (checkCond)
match = 1;
}
if (match > 0)
{
addAbilityToGame();
@@ -4132,7 +4120,7 @@ public:
{
AThis * a = NEW AThis(*this);
a->ability = ability->clone();
if(a->td)
if(a->td)
a->td = td->clone();
return a;
}
@@ -4350,11 +4338,11 @@ public:
class ABestow : public ActivatedAbility
{
public:
MTGCardInstance * _card;
ABestow(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL);
int resolve();
const string getMenuText();
ABestow * clone() const;
MTGCardInstance * _card;
ABestow(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost = NULL);
int resolve();
const string getMenuText();
ABestow * clone() const;
};
/* Can tap a target for a cost */
@@ -4381,16 +4369,16 @@ public:
class AAWhatsX : public ActivatedAbility
{
public:
int value;
MTGAbility * costRule;
AAWhatsX(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * source, int value = 0, MTGAbility * costRule = NULL);
int resolve();
const string getMenuText()
{
sprintf(menuText, "%i", value);
return menuText;
};
AAWhatsX * clone() const;
int value;
MTGAbility * costRule;
AAWhatsX(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * source, int value = 0, MTGAbility * costRule = NULL);
int resolve();
const string getMenuText()
{
sprintf(menuText, "%i", value);
return menuText;
};
AAWhatsX * clone() const;
};
/* set max level up on a levelup creature this is an Ai hint ability, no effect for players.*/
@@ -4407,17 +4395,17 @@ public:
class AACountObject : public ActivatedAbility
{
public:
string value;
string value;
AACountObject(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * source, ManaCost * _cost = NULL, string value ="");
int resolve();
AACountObject * clone() const;
AACountObject(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * source, ManaCost * _cost = NULL, string value ="");
int resolve();
AACountObject * clone() const;
};
/* Can prevent a card from untapping next untap */
class AAFrozen: public ActivatedAbility
{
public:
bool freeze;
bool freeze;
AAFrozen(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * _target, bool tap, ManaCost * _cost = NULL);
int resolve();
const string getMenuText();
@@ -5208,32 +5196,32 @@ public:
class AGrant : public MTGAbility
{
public:
MTGCardInstance * Blessed;
bool resolved;
MTGAbility * Granted;
MTGAbility * toGrant;
AGrant(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * _target, MTGAbility * toGrant);
void Update(float dt);
void resolveGrant();
int resolve();
const string getMenuText();
AGrant * clone() const;
~AGrant();
MTGCardInstance * Blessed;
bool resolved;
MTGAbility * Granted;
MTGAbility * toGrant;
AGrant(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * _target, MTGAbility * toGrant);
void Update(float dt);
void resolveGrant();
int resolve();
const string getMenuText();
AGrant * clone() const;
~AGrant();
private:
void removeGranted(MTGCardInstance *_target);
void removeGranted(MTGCardInstance *_target);
};
//GrantWrapper
class AGrantWrapper : public InstantAbility
{
public:
AGrant * ability;
MTGAbility * Granted;
AGrantWrapper(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * _target, MTGAbility * toGrant);
int resolve();
const string getMenuText();
AGrantWrapper * clone() const;
~AGrantWrapper();
AGrant * ability;
MTGAbility * Granted;
AGrantWrapper(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * _target, MTGAbility * toGrant);
int resolve();
const string getMenuText();
AGrantWrapper * clone() const;
~AGrantWrapper();
};
//ABlink
@@ -6485,7 +6473,7 @@ public:
MTGCardInstance * theNamedCard;
bool noEvent;
bool putinplay;
bool asNormalMadness;
bool asNormalMadness;
AACastCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target,bool restricted,bool copied,bool _asNormal,string nameCard,string abilityName,bool _noEvent, bool putinplay,bool asNormalMadness = false);
int testDestroy(){return 0;};