No code change. Reformat code
This commit is contained in:
@@ -625,7 +625,7 @@ public:
|
||||
int power;
|
||||
int toughness;
|
||||
string name;
|
||||
string menu;
|
||||
string menu;
|
||||
|
||||
AACounter(int id, MTGCardInstance * source, MTGCardInstance * target, const char * _name, int power, int toughness, int nb,
|
||||
ManaCost * cost = NULL, int doTap = 0);
|
||||
@@ -1019,7 +1019,7 @@ public:
|
||||
who = who;
|
||||
tokenId = 0;
|
||||
if (!multiplier) this->multiplier = NEW WParsedInt(1);
|
||||
//TODO this is a copy/past of other code that's all around the place, everything should be in a dedicated parser class;
|
||||
//TODO this is a copy/past of other code that's all around the place, everything should be in a dedicated parser class;
|
||||
|
||||
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++)
|
||||
{
|
||||
@@ -1192,8 +1192,8 @@ public:
|
||||
ABasicAbilityModifier(int _id, MTGCardInstance * _source, MTGCardInstance * _target, int _ability, int _modifier = 1) :
|
||||
MTGAbility(_id, _source, _target), modifier(_modifier), ability(_ability)
|
||||
{
|
||||
aType = MTGAbility::STANDARDABILITYGRANT;
|
||||
abilitygranted = ability;
|
||||
aType = MTGAbility::STANDARDABILITYGRANT;
|
||||
abilitygranted = ability;
|
||||
}
|
||||
|
||||
int addToGame()
|
||||
@@ -1251,8 +1251,8 @@ public:
|
||||
int _modifier = 1, int _tap = 1) :
|
||||
TargetAbility(_id, _source, _cost, 0, _tap), modifier(_modifier), ability(_ability)
|
||||
{
|
||||
aType = MTGAbility::STANDARDABILITYGRANT;
|
||||
abilitygranted = ability;
|
||||
aType = MTGAbility::STANDARDABILITYGRANT;
|
||||
abilitygranted = ability;
|
||||
nbTargets = 0;
|
||||
tc = _tc;
|
||||
if (!tc) tc = NEW CreatureTargetChooser(_source);
|
||||
@@ -1325,8 +1325,8 @@ public:
|
||||
AInstantBasicAbilityModifierUntilEOT(int _id, MTGCardInstance * _source, MTGCardInstance * _target, int _ability, int value) :
|
||||
InstantAbility(_id, _source, _target), ability(_ability), value(value)
|
||||
{
|
||||
aType = MTGAbility::STANDARDABILITYGRANT;
|
||||
abilitygranted = ability;
|
||||
aType = MTGAbility::STANDARDABILITYGRANT;
|
||||
abilitygranted = ability;
|
||||
}
|
||||
|
||||
int addToGame()
|
||||
@@ -1375,8 +1375,8 @@ public:
|
||||
{
|
||||
target = _target;
|
||||
ability = NEW AInstantBasicAbilityModifierUntilEOT(_id, _source, _target, _ability, _value);
|
||||
aType = MTGAbility::STANDARDABILITYGRANT;
|
||||
abilitygranted = _ability;
|
||||
aType = MTGAbility::STANDARDABILITYGRANT;
|
||||
abilitygranted = _ability;
|
||||
}
|
||||
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * cost = NULL)
|
||||
@@ -1430,7 +1430,7 @@ public:
|
||||
ASpellCastLife(int id, MTGCardInstance * _source, CardDescriptor _trigger, ManaCost * _cost, int _life) :
|
||||
MTGAbility(id, _source), trigger(_trigger), cost(_cost), life(_life), lastUsedOn(NULL), lastChecked(NULL)
|
||||
{
|
||||
aType = MTGAbility::LIFER;
|
||||
aType = MTGAbility::LIFER;
|
||||
}
|
||||
ASpellCastLife(int id, MTGCardInstance * _source, int color, ManaCost * _cost, int _life) :
|
||||
MTGAbility(id, _source), cost(_cost), life(_life), lastUsedOn(NULL), lastChecked(NULL)
|
||||
@@ -2270,84 +2270,84 @@ public:
|
||||
SAFE_DELETE(ability);
|
||||
}
|
||||
|
||||
const char * getMenuText()
|
||||
{
|
||||
if (AAMover * move = dynamic_cast<AAMover *>(ability))
|
||||
{
|
||||
MTGGameZone * dest = move->destinationZone();
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
// Move card to hand
|
||||
if (dest == g->players[i]->game->hand)
|
||||
{
|
||||
if (tc->targetsZone(g->players[i]->game->inPlay))
|
||||
{
|
||||
return "Bounce";
|
||||
}
|
||||
else if (tc->targetsZone(g->players[i]->game->graveyard))
|
||||
{
|
||||
return "Reclaim";
|
||||
}
|
||||
else if (tc->targetsZone(g->opponent()->game->hand))
|
||||
{
|
||||
return "Steal";
|
||||
}
|
||||
}
|
||||
// Move card to graveyard
|
||||
else if (dest == g->players[i]->game->graveyard)
|
||||
{
|
||||
if (tc->targetsZone(g->players[i]->game->inPlay))
|
||||
{
|
||||
return "Sacrifice";
|
||||
}
|
||||
else if (tc->targetsZone(g->players[i]->game->hand))
|
||||
{
|
||||
return "Discard";
|
||||
}
|
||||
else if (tc->targetsZone(g->opponent()->game->hand))
|
||||
{
|
||||
return "Opponent Discards";
|
||||
}
|
||||
}
|
||||
// move card to library
|
||||
else if (dest == g->players[i]->game->library)
|
||||
{
|
||||
if (tc->targetsZone(g->players[i]->game->graveyard))
|
||||
{
|
||||
return "Recycle";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Put in Library";
|
||||
}
|
||||
}
|
||||
// move card to battlefield
|
||||
else if (dest == g->players[i]->game->battlefield && tc->targetsZone(g->players[i]->game->graveyard))
|
||||
{
|
||||
return "Reanimate";
|
||||
}
|
||||
// move card in play ( different from battlefield? )
|
||||
else if (dest == g->players[i]->game->inPlay)
|
||||
{
|
||||
return "Put in Play";
|
||||
}
|
||||
// move card into exile
|
||||
else if (dest == g->players[i]->game->exile)
|
||||
{
|
||||
return "Exile";
|
||||
}
|
||||
// move card from Library
|
||||
else if (tc->targetsZone(g->players[i]->game->library))
|
||||
{
|
||||
return "Fetch";
|
||||
}
|
||||
}
|
||||
return "Move";
|
||||
}
|
||||
else
|
||||
return ability->getMenuText();
|
||||
}
|
||||
const char * getMenuText()
|
||||
{
|
||||
if (AAMover * move = dynamic_cast<AAMover *>(ability))
|
||||
{
|
||||
MTGGameZone * dest = move->destinationZone();
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
// Move card to hand
|
||||
if (dest == g->players[i]->game->hand)
|
||||
{
|
||||
if (tc->targetsZone(g->players[i]->game->inPlay))
|
||||
{
|
||||
return "Bounce";
|
||||
}
|
||||
else if (tc->targetsZone(g->players[i]->game->graveyard))
|
||||
{
|
||||
return "Reclaim";
|
||||
}
|
||||
else if (tc->targetsZone(g->opponent()->game->hand))
|
||||
{
|
||||
return "Steal";
|
||||
}
|
||||
}
|
||||
// Move card to graveyard
|
||||
else if (dest == g->players[i]->game->graveyard)
|
||||
{
|
||||
if (tc->targetsZone(g->players[i]->game->inPlay))
|
||||
{
|
||||
return "Sacrifice";
|
||||
}
|
||||
else if (tc->targetsZone(g->players[i]->game->hand))
|
||||
{
|
||||
return "Discard";
|
||||
}
|
||||
else if (tc->targetsZone(g->opponent()->game->hand))
|
||||
{
|
||||
return "Opponent Discards";
|
||||
}
|
||||
}
|
||||
// move card to library
|
||||
else if (dest == g->players[i]->game->library)
|
||||
{
|
||||
if (tc->targetsZone(g->players[i]->game->graveyard))
|
||||
{
|
||||
return "Recycle";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Put in Library";
|
||||
}
|
||||
}
|
||||
// move card to battlefield
|
||||
else if (dest == g->players[i]->game->battlefield && tc->targetsZone(g->players[i]->game->graveyard))
|
||||
{
|
||||
return "Reanimate";
|
||||
}
|
||||
// move card in play ( different from battlefield? )
|
||||
else if (dest == g->players[i]->game->inPlay)
|
||||
{
|
||||
return "Put in Play";
|
||||
}
|
||||
// move card into exile
|
||||
else if (dest == g->players[i]->game->exile)
|
||||
{
|
||||
return "Exile";
|
||||
}
|
||||
// move card from Library
|
||||
else if (tc->targetsZone(g->players[i]->game->library))
|
||||
{
|
||||
return "Fetch";
|
||||
}
|
||||
}
|
||||
return "Move";
|
||||
}
|
||||
else
|
||||
return ability->getMenuText();
|
||||
}
|
||||
|
||||
ALord * clone() const
|
||||
{
|
||||
@@ -3175,8 +3175,8 @@ public:
|
||||
{
|
||||
for (int i = 0; i < nbOpponents; i++)
|
||||
{
|
||||
if (game->isInPlay(opponents[i]))
|
||||
opponents[i]->destroy();
|
||||
if (game->isInPlay(opponents[i]))
|
||||
opponents[i]->destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3288,7 +3288,7 @@ public:
|
||||
list<int> oldcolors;
|
||||
list<int> oldtypes;
|
||||
bool remove;
|
||||
string menu;
|
||||
string menu;
|
||||
|
||||
ATransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities);
|
||||
int addToGame();
|
||||
@@ -3305,7 +3305,7 @@ public:
|
||||
list<int> abilities;
|
||||
list<int> types;
|
||||
list<int> colors;
|
||||
string menu;
|
||||
string menu;
|
||||
|
||||
AForeverTransformer(int id, MTGCardInstance * source, MTGCardInstance * target, string stypes, string sabilities);
|
||||
int addToGame();
|
||||
@@ -3344,12 +3344,12 @@ public:
|
||||
class ASwapPTUEOT: public InstantAbility
|
||||
{
|
||||
public:
|
||||
ASwapPT * ability;
|
||||
ASwapPTUEOT(int id, MTGCardInstance * source, MTGCardInstance * target);
|
||||
int resolve();
|
||||
const char * getMenuText();
|
||||
ASwapPTUEOT * clone() const;
|
||||
~ASwapPTUEOT();
|
||||
ASwapPT * ability;
|
||||
ASwapPTUEOT(int id, MTGCardInstance * source, MTGCardInstance * target);
|
||||
int resolve();
|
||||
const char * getMenuText();
|
||||
ASwapPTUEOT * clone() const;
|
||||
~ASwapPTUEOT();
|
||||
};
|
||||
|
||||
//becomes ability
|
||||
@@ -4027,61 +4027,61 @@ public:
|
||||
AErgRaiders * a = NEW AErgRaiders(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Fastbond
|
||||
class AFastbond: public TriggeredAbility
|
||||
{
|
||||
public:
|
||||
int alreadyPlayedALand;
|
||||
int previous;
|
||||
AFastbond(int _id, MTGCardInstance * card) :
|
||||
TriggeredAbility(_id, card)
|
||||
{
|
||||
alreadyPlayedALand = 0;
|
||||
if (source->controller()->landsPlayerCanStillPlay == 0)
|
||||
{
|
||||
alreadyPlayedALand = 1;
|
||||
source->controller()->landsPlayerCanStillPlay += 1;
|
||||
source->controller()->canPutLandsIntoPlay = true;
|
||||
int alreadyPlayedALand;
|
||||
int previous;
|
||||
AFastbond(int _id, MTGCardInstance * card) :
|
||||
TriggeredAbility(_id, card)
|
||||
{
|
||||
alreadyPlayedALand = 0;
|
||||
if (source->controller()->landsPlayerCanStillPlay == 0)
|
||||
{
|
||||
alreadyPlayedALand = 1;
|
||||
source->controller()->landsPlayerCanStillPlay += 1;
|
||||
source->controller()->canPutLandsIntoPlay = true;
|
||||
|
||||
}
|
||||
previous = source->controller()->landsPlayerCanStillPlay;
|
||||
}
|
||||
}
|
||||
previous = source->controller()->landsPlayerCanStillPlay;
|
||||
}
|
||||
|
||||
void Update(float dt)
|
||||
{
|
||||
if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_UNTAP)
|
||||
{
|
||||
alreadyPlayedALand = 0;
|
||||
}
|
||||
TriggeredAbility::Update(dt);
|
||||
}
|
||||
void Update(float dt)
|
||||
{
|
||||
if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_UNTAP)
|
||||
{
|
||||
alreadyPlayedALand = 0;
|
||||
}
|
||||
TriggeredAbility::Update(dt);
|
||||
}
|
||||
|
||||
int trigger()
|
||||
{
|
||||
if (source->controller()->landsPlayerCanStillPlay == 0 && previous >= 1)
|
||||
{
|
||||
previous = 0;
|
||||
source->controller()->canPutLandsIntoPlay = true;
|
||||
source->controller()->landsPlayerCanStillPlay += 1;
|
||||
if (alreadyPlayedALand) return 1;
|
||||
alreadyPlayedALand = 1;
|
||||
return 0;
|
||||
}
|
||||
previous = source->controller()->landsPlayerCanStillPlay;
|
||||
return 0;
|
||||
}
|
||||
int trigger()
|
||||
{
|
||||
if (source->controller()->landsPlayerCanStillPlay == 0 && previous >= 1)
|
||||
{
|
||||
previous = 0;
|
||||
source->controller()->canPutLandsIntoPlay = true;
|
||||
source->controller()->landsPlayerCanStillPlay += 1;
|
||||
if (alreadyPlayedALand) return 1;
|
||||
alreadyPlayedALand = 1;
|
||||
return 0;
|
||||
}
|
||||
previous = source->controller()->landsPlayerCanStillPlay;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int resolve()
|
||||
{
|
||||
game->mLayers->stackLayer()->addDamage(source, source->controller(), 1);
|
||||
game->mLayers->stackLayer()->resolve();
|
||||
return 1;
|
||||
}
|
||||
int resolve()
|
||||
{
|
||||
game->mLayers->stackLayer()->addDamage(source, source->controller(), 1);
|
||||
game->mLayers->stackLayer()->resolve();
|
||||
return 1;
|
||||
}
|
||||
|
||||
virtual ostream& toString(ostream& out) const
|
||||
virtual ostream& toString(ostream& out) const
|
||||
{
|
||||
out << "AFastbond ::: alreadyPlayedALand : " << alreadyPlayedALand << " ; previous : " << previous << " (";
|
||||
return TriggeredAbility::toString(out) << ")";
|
||||
@@ -5222,10 +5222,8 @@ public:
|
||||
|
||||
// utility functions
|
||||
|
||||
void PopulateColorIndexVector( list<int>& colors, const string& colorsString, char delimiter = ',');
|
||||
void PopulateAbilityIndexVector( list<int>& abilities, const string& abilitiesString, char delimiter = ',');
|
||||
void PopulateSubtypesIndexVector( list<int>& subtypes, const string& subtypesString, char delimiter = ' ');
|
||||
|
||||
|
||||
void PopulateColorIndexVector(list<int>& colors, const string& colorsString, char delimiter = ',');
|
||||
void PopulateAbilityIndexVector(list<int>& abilities, const string& abilitiesString, char delimiter = ',');
|
||||
void PopulateSubtypesIndexVector(list<int>& subtypes, const string& subtypesString, char delimiter = ' ');
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,140 +9,172 @@
|
||||
#include "WEvent.h"
|
||||
#include "CardSelector.h"
|
||||
|
||||
class OtherAbilitiesEventReceiver:public MTGAbility{
|
||||
class OtherAbilitiesEventReceiver: public MTGAbility
|
||||
{
|
||||
public:
|
||||
int testDestroy();
|
||||
int receiveEvent(WEvent * event);
|
||||
OtherAbilitiesEventReceiver(int _id);
|
||||
OtherAbilitiesEventReceiver * clone() const;
|
||||
int testDestroy();
|
||||
int receiveEvent(WEvent * event);
|
||||
OtherAbilitiesEventReceiver(int _id);
|
||||
OtherAbilitiesEventReceiver * clone() const;
|
||||
};
|
||||
|
||||
class MTGPutInPlayRule:public MTGAbility{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGPutInPlayRule(int _id);
|
||||
const char * getMenuText(){return "Play Card Normally";}
|
||||
virtual MTGPutInPlayRule * clone() const;
|
||||
class MTGPutInPlayRule: public MTGAbility
|
||||
{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGPutInPlayRule(int _id);
|
||||
const char * getMenuText()
|
||||
{
|
||||
return "Play Card Normally";
|
||||
}
|
||||
virtual MTGPutInPlayRule * clone() const;
|
||||
};
|
||||
|
||||
class MTGAlternativeCostRule:public MTGAbility{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGAlternativeCostRule(int _id);
|
||||
const char * getMenuText(){return "Pay Alternative Cost";}
|
||||
virtual MTGAlternativeCostRule * clone() const;
|
||||
class MTGAlternativeCostRule: public MTGAbility
|
||||
{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGAlternativeCostRule(int _id);
|
||||
const char * getMenuText()
|
||||
{
|
||||
return "Pay Alternative Cost";
|
||||
}
|
||||
virtual MTGAlternativeCostRule * clone() const;
|
||||
};
|
||||
|
||||
class MTGBuyBackRule:public MTGAbility{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGBuyBackRule(int _id);
|
||||
const char * getMenuText(){return "Cast And Buy Back";}
|
||||
virtual MTGBuyBackRule * clone() const;
|
||||
class MTGBuyBackRule: public MTGAbility
|
||||
{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGBuyBackRule(int _id);
|
||||
const char * getMenuText()
|
||||
{
|
||||
return "Cast And Buy Back";
|
||||
}
|
||||
virtual MTGBuyBackRule * clone() const;
|
||||
};
|
||||
|
||||
class MTGFlashBackRule:public MTGAbility{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGFlashBackRule(int _id);
|
||||
const char * getMenuText(){return "Flash Back";}
|
||||
virtual MTGFlashBackRule * clone() const;
|
||||
class MTGFlashBackRule: public MTGAbility
|
||||
{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGFlashBackRule(int _id);
|
||||
const char * getMenuText()
|
||||
{
|
||||
return "Flash Back";
|
||||
}
|
||||
virtual MTGFlashBackRule * clone() const;
|
||||
};
|
||||
|
||||
class MTGRetraceRule:public MTGAbility{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGRetraceRule(int _id);
|
||||
const char * getMenuText(){return "Retrace";}
|
||||
virtual MTGRetraceRule * clone() const;
|
||||
class MTGRetraceRule: public MTGAbility
|
||||
{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGRetraceRule(int _id);
|
||||
const char * getMenuText()
|
||||
{
|
||||
return "Retrace";
|
||||
}
|
||||
virtual MTGRetraceRule * clone() const;
|
||||
};
|
||||
|
||||
class MTGAttackRule:public MTGAbility, public Limitor{
|
||||
public:
|
||||
virtual bool select(Target*);
|
||||
virtual bool greyout(Target*);
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGAttackRule(int _id);
|
||||
const char * getMenuText(){return "Attacker";}
|
||||
int receiveEvent(WEvent * event);
|
||||
virtual MTGAttackRule * clone() const;
|
||||
class MTGAttackRule: public MTGAbility, public Limitor
|
||||
{
|
||||
public:
|
||||
virtual bool select(Target*);
|
||||
virtual bool greyout(Target*);
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGAttackRule(int _id);
|
||||
const char * getMenuText()
|
||||
{
|
||||
return "Attacker";
|
||||
}
|
||||
int receiveEvent(WEvent * event);
|
||||
virtual MTGAttackRule * clone() const;
|
||||
};
|
||||
|
||||
|
||||
/* handles combat trigger send recieve events*/
|
||||
class MTGCombatTriggersRule:public MTGAbility{
|
||||
public:
|
||||
MTGCombatTriggersRule(int _id);
|
||||
int receiveEvent(WEvent * event);
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
int testDestroy();
|
||||
virtual MTGCombatTriggersRule * clone() const;
|
||||
class MTGCombatTriggersRule: public MTGAbility
|
||||
{
|
||||
public:
|
||||
MTGCombatTriggersRule(int _id);
|
||||
int receiveEvent(WEvent * event);
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
int testDestroy();
|
||||
virtual MTGCombatTriggersRule * clone() const;
|
||||
};
|
||||
|
||||
class MTGBlockRule:public MTGAbility{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGBlockRule(int _id);
|
||||
const char * getMenuText(){return "Blocker";}
|
||||
virtual MTGBlockRule * clone() const;
|
||||
class MTGBlockRule: public MTGAbility
|
||||
{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
MTGBlockRule(int _id);
|
||||
const char * getMenuText()
|
||||
{
|
||||
return "Blocker";
|
||||
}
|
||||
virtual MTGBlockRule * clone() const;
|
||||
};
|
||||
|
||||
|
||||
/* Persist Rule */
|
||||
class MTGPersistRule:public MTGAbility{
|
||||
public:
|
||||
MTGPersistRule(int _id);
|
||||
int receiveEvent(WEvent * event);
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
int testDestroy();
|
||||
virtual MTGPersistRule * clone() const;
|
||||
class MTGPersistRule: public MTGAbility
|
||||
{
|
||||
public:
|
||||
MTGPersistRule(int _id);
|
||||
int receiveEvent(WEvent * event);
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
int testDestroy();
|
||||
virtual MTGPersistRule * clone() const;
|
||||
};
|
||||
//affinity rules
|
||||
class MTGAffinityRule:public MTGAbility{
|
||||
public:
|
||||
MTGAffinityRule(int _id);
|
||||
int receiveEvent(WEvent * event);
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
int testDestroy();
|
||||
virtual MTGAffinityRule * clone() const;
|
||||
class MTGAffinityRule: public MTGAbility
|
||||
{
|
||||
public:
|
||||
MTGAffinityRule(int _id);
|
||||
int receiveEvent(WEvent * event);
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
int testDestroy();
|
||||
virtual MTGAffinityRule * clone() const;
|
||||
};
|
||||
//unearths destruction if leaves play effect
|
||||
class MTGUnearthRule:public MTGAbility{
|
||||
public:
|
||||
MTGUnearthRule(int _id);
|
||||
int receiveEvent(WEvent * event);
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
int testDestroy();
|
||||
virtual MTGUnearthRule * clone() const;
|
||||
class MTGUnearthRule: public MTGAbility
|
||||
{
|
||||
public:
|
||||
MTGUnearthRule(int _id);
|
||||
int receiveEvent(WEvent * event);
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
int testDestroy();
|
||||
virtual MTGUnearthRule * clone() const;
|
||||
};
|
||||
class MTGTokensCleanup:public MTGAbility{
|
||||
public:
|
||||
vector<MTGCardInstance *> list;
|
||||
MTGTokensCleanup(int _id);
|
||||
int receiveEvent(WEvent * event);
|
||||
int testDestroy();
|
||||
virtual MTGTokensCleanup * clone() const;
|
||||
class MTGTokensCleanup: public MTGAbility
|
||||
{
|
||||
public:
|
||||
vector<MTGCardInstance *> list;
|
||||
MTGTokensCleanup(int _id);
|
||||
int receiveEvent(WEvent * event);
|
||||
int testDestroy();
|
||||
virtual MTGTokensCleanup * clone() const;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -151,99 +183,112 @@ class MTGTokensCleanup:public MTGAbility{
|
||||
* owners' graveyards. This is called the "legend rule." If only one of those permanents is
|
||||
* legendary, this rule doesn't apply.
|
||||
*/
|
||||
class MTGLegendRule:public ListMaintainerAbility{
|
||||
public:
|
||||
MTGLegendRule(int _id);
|
||||
int canBeInList(MTGCardInstance * card);
|
||||
int added(MTGCardInstance * card);
|
||||
int removed(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
virtual MTGLegendRule * clone() const;
|
||||
class MTGLegendRule: public ListMaintainerAbility
|
||||
{
|
||||
public:
|
||||
MTGLegendRule(int _id);
|
||||
int canBeInList(MTGCardInstance * card);
|
||||
int added(MTGCardInstance * card);
|
||||
int removed(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
virtual MTGLegendRule * clone() const;
|
||||
};
|
||||
|
||||
|
||||
class MTGMomirRule:public MTGAbility{
|
||||
class MTGMomirRule: public MTGAbility
|
||||
{
|
||||
private:
|
||||
int genRandomCreatureId(int convertedCost);
|
||||
static vector<int> pool[20];
|
||||
static int initialized;
|
||||
int genRandomCreatureId(int convertedCost);
|
||||
static vector<int> pool[20];
|
||||
static int initialized;
|
||||
|
||||
int textAlpha;
|
||||
string text;
|
||||
int textAlpha;
|
||||
string text;
|
||||
public:
|
||||
|
||||
int alreadyplayed;
|
||||
MTGAllCards * collection;
|
||||
MTGCardInstance * genCreature(int id);
|
||||
int testDestroy();
|
||||
void Update(float dt);
|
||||
void Render();
|
||||
MTGMomirRule(int _id, MTGAllCards * _collection);
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int reactToClick(MTGCardInstance * card, int id);
|
||||
const char * getMenuText(){return "Momir";}
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
virtual MTGMomirRule * clone() const;
|
||||
int alreadyplayed;
|
||||
MTGAllCards * collection;
|
||||
MTGCardInstance * genCreature(int id);
|
||||
int testDestroy();
|
||||
void Update(float dt);
|
||||
void Render();
|
||||
MTGMomirRule(int _id, MTGAllCards * _collection);
|
||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int reactToClick(MTGCardInstance * card, int id);
|
||||
const char * getMenuText()
|
||||
{
|
||||
return "Momir";
|
||||
}
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
virtual MTGMomirRule * clone() const;
|
||||
};
|
||||
|
||||
|
||||
/* LifeLink */
|
||||
class MTGLifelinkRule:public MTGAbility{
|
||||
public:
|
||||
MTGLifelinkRule(int _id);
|
||||
class MTGLifelinkRule: public MTGAbility
|
||||
{
|
||||
public:
|
||||
MTGLifelinkRule(int _id);
|
||||
|
||||
int receiveEvent(WEvent * event);
|
||||
int receiveEvent(WEvent * event);
|
||||
|
||||
int testDestroy();
|
||||
int testDestroy();
|
||||
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
|
||||
virtual MTGLifelinkRule * clone() const;
|
||||
virtual MTGLifelinkRule * clone() const;
|
||||
};
|
||||
|
||||
/* Deathtouch */
|
||||
class MTGDeathtouchRule:public MTGAbility{
|
||||
public:
|
||||
MTGDeathtouchRule(int _id);
|
||||
class MTGDeathtouchRule: public MTGAbility
|
||||
{
|
||||
public:
|
||||
MTGDeathtouchRule(int _id);
|
||||
|
||||
int receiveEvent(WEvent * event);
|
||||
int receiveEvent(WEvent * event);
|
||||
|
||||
int testDestroy();
|
||||
const char * getMenuText(){return "Deathtouch";}
|
||||
int testDestroy();
|
||||
const char * getMenuText()
|
||||
{
|
||||
return "Deathtouch";
|
||||
}
|
||||
|
||||
virtual MTGDeathtouchRule * clone() const;
|
||||
virtual MTGDeathtouchRule * clone() const;
|
||||
};
|
||||
|
||||
/* HUD Display */
|
||||
|
||||
class HUDString {
|
||||
class HUDString
|
||||
{
|
||||
public:
|
||||
string value;
|
||||
float timestamp;
|
||||
int quantity;
|
||||
HUDString(string s, float ts):value(s),timestamp(ts){quantity = 1;};
|
||||
string value;
|
||||
float timestamp;
|
||||
int quantity;
|
||||
HUDString(string s, float ts) :
|
||||
value(s), timestamp(ts)
|
||||
{
|
||||
quantity = 1;
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
class HUDDisplay:public MTGAbility{
|
||||
class HUDDisplay: public MTGAbility
|
||||
{
|
||||
private:
|
||||
list<HUDString *> events;
|
||||
float timestamp;
|
||||
float popdelay;
|
||||
WFont * f;
|
||||
float maxWidth;
|
||||
int addEvent(string s);
|
||||
list<HUDString *> events;
|
||||
float timestamp;
|
||||
float popdelay;
|
||||
WFont * f;
|
||||
float maxWidth;
|
||||
int addEvent(string s);
|
||||
public:
|
||||
int testDestroy();
|
||||
int receiveEvent(WEvent * event);
|
||||
void Update(float dt);
|
||||
void Render();
|
||||
HUDDisplay(int _id);
|
||||
~HUDDisplay();
|
||||
virtual HUDDisplay * clone() const;
|
||||
int testDestroy();
|
||||
int receiveEvent(WEvent * event);
|
||||
void Update(float dt);
|
||||
void Render();
|
||||
HUDDisplay(int _id);
|
||||
~HUDDisplay();
|
||||
virtual HUDDisplay * clone() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,27 +22,27 @@ public:
|
||||
MODE_TEST_SUITE, MODE_HUMAN, MODE_AI,
|
||||
};
|
||||
|
||||
JTexture * mAvatarTex;
|
||||
JQuad * mAvatar;
|
||||
int playMode;
|
||||
bool canPutLandsIntoPlay;
|
||||
int landsPlayerCanStillPlay;
|
||||
bool nomaxhandsize;
|
||||
int castedspellsthisturn;
|
||||
bool onlyonecast;
|
||||
int castcount;
|
||||
bool nocreatureinstant;
|
||||
bool nospellinstant;
|
||||
bool onlyoneinstant;
|
||||
bool castrestrictedcreature;
|
||||
bool castrestrictedspell;
|
||||
bool onlyoneboth;
|
||||
bool bothrestrictedspell;
|
||||
bool bothrestrictedcreature;
|
||||
MTGPlayerCards * game;
|
||||
string deckFile;
|
||||
string deckFileSmall;
|
||||
string deckName;
|
||||
JTexture * mAvatarTex;
|
||||
JQuad * mAvatar;
|
||||
int playMode;
|
||||
bool canPutLandsIntoPlay;
|
||||
int landsPlayerCanStillPlay;
|
||||
bool nomaxhandsize;
|
||||
int castedspellsthisturn;
|
||||
bool onlyonecast;
|
||||
int castcount;
|
||||
bool nocreatureinstant;
|
||||
bool nospellinstant;
|
||||
bool onlyoneinstant;
|
||||
bool castrestrictedcreature;
|
||||
bool castrestrictedspell;
|
||||
bool onlyoneboth;
|
||||
bool bothrestrictedspell;
|
||||
bool bothrestrictedcreature;
|
||||
MTGPlayerCards * game;
|
||||
string deckFile;
|
||||
string deckFileSmall;
|
||||
string deckName;
|
||||
|
||||
Player(MTGDeck * deck, string deckFile, string deckFileSmall);
|
||||
virtual ~Player();
|
||||
@@ -71,7 +71,6 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virtual int isAI()
|
||||
{
|
||||
return 0;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,6 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "AllAbilities.h"
|
||||
|
||||
|
||||
//Activated Abilities
|
||||
|
||||
//Generic Activated Abilities
|
||||
@@ -21,19 +20,22 @@ int GenericActivatedAbility::resolve()
|
||||
SAFE_DELETE(diff);
|
||||
//SAFE_DELETE(abilityCost); this line has been reported as a bug. removing it doesn't seem to break anything, although I didn't get any error in the test suite by leaving it either, so... leaving it for now as a comment, in case.
|
||||
ability->target = target; //may have been updated...
|
||||
if (ability) return ability->resolve();
|
||||
if (ability)
|
||||
return ability->resolve();
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * GenericActivatedAbility::getMenuText()
|
||||
{
|
||||
if (ability) return ability->getMenuText();
|
||||
if (ability)
|
||||
return ability->getMenuText();
|
||||
return "Error";
|
||||
}
|
||||
|
||||
int GenericActivatedAbility::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
{
|
||||
if (limitPerTurn && counters >= limitPerTurn) return 0;
|
||||
if (limitPerTurn && counters >= limitPerTurn)
|
||||
return 0;
|
||||
return ActivatedAbility::isReactingToClick(card, mana);
|
||||
}
|
||||
|
||||
@@ -48,8 +50,10 @@ void GenericActivatedAbility::Update(float dt)
|
||||
|
||||
int GenericActivatedAbility::testDestroy()
|
||||
{
|
||||
if (!activeZone) return ActivatedAbility::testDestroy();
|
||||
if (activeZone->hasCard(source)) return 0;
|
||||
if (!activeZone)
|
||||
return ActivatedAbility::testDestroy();
|
||||
if (activeZone->hasCard(source))
|
||||
return 0;
|
||||
return 1;
|
||||
|
||||
}
|
||||
@@ -195,7 +199,8 @@ int AADepleter::resolve()
|
||||
MTGLibrary * library = player->game->library;
|
||||
for (int i = 0; i < nbcards; i++)
|
||||
{
|
||||
if (library->nb_cards) player->game->putInZone(library->cards[library->nb_cards - 1], library, player->game->graveyard);
|
||||
if (library->nb_cards)
|
||||
player->game->putInZone(library->cards[library->nb_cards - 1], library, player->game->graveyard);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
@@ -249,7 +254,8 @@ AACounter::AACounter(int id, MTGCardInstance * source, MTGCardInstance * target,
|
||||
ActivatedAbility(id, source, cost, 0, doTap), nb(nb), power(power), toughness(toughness), name(_name)
|
||||
{
|
||||
this->target = target;
|
||||
if (name.find("Level")) aType = MTGAbility::STANDARD_LEVELUP;
|
||||
if (name.find("Level"))
|
||||
aType = MTGAbility::STANDARD_LEVELUP;
|
||||
menu = "";
|
||||
}
|
||||
|
||||
@@ -283,34 +289,34 @@ int AACounter::resolve()
|
||||
|
||||
const char* AACounter::getMenuText()
|
||||
{
|
||||
if(menu.size())
|
||||
{
|
||||
return menu.c_str();
|
||||
}
|
||||
char buffer[128];
|
||||
if (menu.size())
|
||||
{
|
||||
return menu.c_str();
|
||||
}
|
||||
char buffer[128];
|
||||
|
||||
if(name.size())
|
||||
{
|
||||
string s = name;
|
||||
menu.append(s.c_str());
|
||||
}
|
||||
if (name.size())
|
||||
{
|
||||
string s = name;
|
||||
menu.append(s.c_str());
|
||||
}
|
||||
|
||||
if(power != 0 || toughness != 0)
|
||||
{
|
||||
sprintf(buffer, " %i/%i", power,toughness);
|
||||
menu.append(buffer);
|
||||
}
|
||||
if (power != 0 || toughness != 0)
|
||||
{
|
||||
sprintf(buffer, " %i/%i", power, toughness);
|
||||
menu.append(buffer);
|
||||
}
|
||||
|
||||
menu.append(" Counter");
|
||||
if(nb != 1)
|
||||
{
|
||||
sprintf(buffer, ": %i", nb);
|
||||
menu.append(buffer);
|
||||
}
|
||||
menu.append(" Counter");
|
||||
if (nb != 1)
|
||||
{
|
||||
sprintf(buffer, ": %i", nb);
|
||||
menu.append(buffer);
|
||||
}
|
||||
|
||||
sprintf(menuText, "%s",menu.c_str());
|
||||
return menuText;
|
||||
}
|
||||
sprintf(menuText, "%s", menu.c_str());
|
||||
return menuText;
|
||||
}
|
||||
|
||||
AACounter * AACounter::clone() const
|
||||
{
|
||||
@@ -329,7 +335,8 @@ AAFizzler::AAFizzler(int _id, MTGCardInstance * card, Spell * _target, ManaCost
|
||||
int AAFizzler::resolve()
|
||||
{
|
||||
Spell * _target = (Spell *) target;
|
||||
if (target && _target->source->has(Constants::NOFIZZLE)) return 0;
|
||||
if (target && _target->source->has(Constants::NOFIZZLE))
|
||||
return 0;
|
||||
game->mLayers->stackLayer()->Fizzle(_target);
|
||||
return 1;
|
||||
}
|
||||
@@ -350,7 +357,8 @@ AAFizzler* AAFizzler::clone() const
|
||||
AABanishCard::AABanishCard(int _id, MTGCardInstance * _source, MTGCardInstance * _target, int _banishmentType) :
|
||||
ActivatedAbility(_id, _source, NULL), banishmentType(_banishmentType)
|
||||
{
|
||||
if (_target) target = _target;
|
||||
if (_target)
|
||||
target = _target;
|
||||
}
|
||||
|
||||
const char * AABanishCard::getMenuText()
|
||||
@@ -577,7 +585,7 @@ AAFrozen * AAFrozen::clone() const
|
||||
AALifer::AALifer(int _id, MTGCardInstance * card, Targetable * _target, WParsedInt * life, ManaCost * _cost, int _tap, int who) :
|
||||
ActivatedAbilityTP(_id, card, _target, _cost, _tap, who), life(life)
|
||||
{
|
||||
aType = MTGAbility::LIFER;
|
||||
aType = MTGAbility::LIFER;
|
||||
}
|
||||
|
||||
int AALifer::resolve()
|
||||
@@ -657,10 +665,10 @@ AACloner::AACloner(int _id, MTGCardInstance * _source, MTGCardInstance * _target
|
||||
string abilitiesStringList) :
|
||||
ActivatedAbility(_id, _source, _cost, 0, 0), who(who)
|
||||
{
|
||||
aType = MTGAbility::CLONING;
|
||||
aType = MTGAbility::CLONING;
|
||||
target = _target;
|
||||
source = _source;
|
||||
if ( abilitiesStringList.size() > 0 )
|
||||
if (abilitiesStringList.size() > 0)
|
||||
{
|
||||
PopulateAbilityIndexVector(awith, abilitiesStringList);
|
||||
PopulateColorIndexVector(colors, abilitiesStringList);
|
||||
@@ -676,8 +684,10 @@ int AACloner::resolve()
|
||||
MTGCardInstance * myClone = NULL;
|
||||
MTGCard* clone = (_target->isToken ? _target : GameApp::collection->getCardById(_target->getId()));
|
||||
|
||||
if (who != 1) myClone = NEW MTGCardInstance(clone, source->controller()->game);
|
||||
if (who == 1) myClone = NEW MTGCardInstance(clone, source->controller()->opponent()->game);
|
||||
if (who != 1)
|
||||
myClone = NEW MTGCardInstance(clone, source->controller()->game);
|
||||
if (who == 1)
|
||||
myClone = NEW MTGCardInstance(clone, source->controller()->opponent()->game);
|
||||
if (who != 1)
|
||||
source->controller()->game->temp->addCard(myClone);
|
||||
else
|
||||
@@ -703,7 +713,8 @@ int AACloner::resolve()
|
||||
|
||||
const char * AACloner::getMenuText()
|
||||
{
|
||||
if (who == 1) return "Clone For Opponent";
|
||||
if (who == 1)
|
||||
return "Clone For Opponent";
|
||||
return "Clone";
|
||||
}
|
||||
|
||||
@@ -772,7 +783,8 @@ AAMoreLandPlz::~AAMoreLandPlz()
|
||||
AAMover::AAMover(int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest, ManaCost * _cost, int doTap) :
|
||||
ActivatedAbility(_id, _source, _cost, 0, doTap), destination(dest)
|
||||
{
|
||||
if (_target) target = _target;
|
||||
if (_target)
|
||||
target = _target;
|
||||
}
|
||||
|
||||
MTGGameZone * AAMover::destinationZone()
|
||||
@@ -1019,7 +1031,7 @@ AATapper::AATapper(int id, MTGCardInstance * card, MTGCardInstance * _target, Ma
|
||||
ActivatedAbility(id, card, _cost, 0, doTap)
|
||||
{
|
||||
target = _target;
|
||||
aType = MTGAbility::TAPPER;
|
||||
aType = MTGAbility::TAPPER;
|
||||
}
|
||||
|
||||
int AATapper::resolve()
|
||||
@@ -1051,7 +1063,7 @@ AAUntapper::AAUntapper(int id, MTGCardInstance * card, MTGCardInstance * _target
|
||||
ActivatedAbility(id, card, _cost, 0, doTap)
|
||||
{
|
||||
target = _target;
|
||||
aType = MTGAbility::UNTAPPER;
|
||||
aType = MTGAbility::UNTAPPER;
|
||||
}
|
||||
|
||||
int AAUntapper::resolve()
|
||||
@@ -1156,7 +1168,6 @@ AAWinGame * AAWinGame::clone() const
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
//Generic Abilities
|
||||
|
||||
//May Abilities
|
||||
@@ -1175,7 +1186,8 @@ void MayAbility::Update(float dt)
|
||||
triggered = 1;
|
||||
if (TargetAbility * ta = dynamic_cast<TargetAbility *>(ability))
|
||||
{
|
||||
if (!ta->tc->validTargetsExist()) return;
|
||||
if (!ta->tc->validTargetsExist())
|
||||
return;
|
||||
}
|
||||
game->mLayers->actionLayer()->setMenuObject(source, must);
|
||||
game->mLayers->stackLayer()->setIsInterrupting(source->controller());
|
||||
@@ -1189,15 +1201,19 @@ const char * MayAbility::getMenuText()
|
||||
|
||||
int MayAbility::testDestroy()
|
||||
{
|
||||
if (!triggered) return 0;
|
||||
if (game->mLayers->actionLayer()->menuObject) return 0;
|
||||
if (game->mLayers->actionLayer()->getIndexOf(mClone) != -1) return 0;
|
||||
if (!triggered)
|
||||
return 0;
|
||||
if (game->mLayers->actionLayer()->menuObject)
|
||||
return 0;
|
||||
if (game->mLayers->actionLayer()->getIndexOf(mClone) != -1)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MayAbility::isReactingToTargetClick(Targetable * card)
|
||||
{
|
||||
if (card == source) return 1;
|
||||
if (card == source)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1226,7 +1242,8 @@ MayAbility::~MayAbility()
|
||||
MultiAbility::MultiAbility(int _id, MTGCardInstance * card, Targetable * _target, ManaCost * _cost, int _tap) :
|
||||
ActivatedAbility(_id, card, _cost, 0, _tap)
|
||||
{
|
||||
if (_target) target = _target;
|
||||
if (_target)
|
||||
target = _target;
|
||||
}
|
||||
|
||||
int MultiAbility::Add(MTGAbility * ability)
|
||||
@@ -1240,9 +1257,11 @@ int MultiAbility::resolve()
|
||||
vector<int>::size_type sz = abilities.size();
|
||||
for (unsigned int i = 0; i < sz; i++)
|
||||
{
|
||||
if (abilities[i] == NULL) continue;
|
||||
if (abilities[i] == NULL)
|
||||
continue;
|
||||
Targetable * backup = abilities[i]->target;
|
||||
if (target && target != source && abilities[i]->target == abilities[i]->source) abilities[i]->target = target;
|
||||
if (target && target != source && abilities[i]->target == abilities[i]->source)
|
||||
abilities[i]->target = target;
|
||||
abilities[i]->resolve();
|
||||
abilities[i]->target = backup;
|
||||
}
|
||||
@@ -1251,7 +1270,8 @@ int MultiAbility::resolve()
|
||||
|
||||
const char * MultiAbility::getMenuText()
|
||||
{
|
||||
if (abilities.size()) return abilities[0]->getMenuText();
|
||||
if (abilities.size())
|
||||
return abilities[0]->getMenuText();
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -1275,7 +1295,6 @@ MultiAbility::~MultiAbility()
|
||||
abilities.clear();
|
||||
}
|
||||
|
||||
|
||||
//Generic Target Ability
|
||||
GenericTargetAbility::GenericTargetAbility(int _id, MTGCardInstance * _source, TargetChooser * _tc, MTGAbility * a,
|
||||
ManaCost * _cost, int _tap, int limit, int restrictions, MTGGameZone * dest) :
|
||||
@@ -1283,13 +1302,15 @@ GenericTargetAbility::GenericTargetAbility(int _id, MTGCardInstance * _source, T
|
||||
{
|
||||
ability = a;
|
||||
MTGAbility * core = AbilityFactory::getCoreAbility(a);
|
||||
if (dynamic_cast<AACopier *> (core)) tc->other = true; //http://code.google.com/p/wagic/issues/detail?id=209 (avoid inifinite loop)
|
||||
if (dynamic_cast<AACopier *> (core))
|
||||
tc->other = true; //http://code.google.com/p/wagic/issues/detail?id=209 (avoid inifinite loop)
|
||||
counters = 0;
|
||||
}
|
||||
|
||||
const char * GenericTargetAbility::getMenuText()
|
||||
{
|
||||
if (!ability) return "Error";
|
||||
if (!ability)
|
||||
return "Error";
|
||||
|
||||
MTGAbility * core = AbilityFactory::getCoreAbility(ability);
|
||||
if (AAMover * move = dynamic_cast<AAMover *>(core))
|
||||
@@ -1318,7 +1339,9 @@ const char * GenericTargetAbility::getMenuText()
|
||||
{
|
||||
return "Reanimate";
|
||||
}
|
||||
else if ((tc->targetsZone(g->players[i]->game->inPlay) && dest == g->players[i]->game->library) || dest == g->players[i]->game->library )
|
||||
else if ((tc->targetsZone(g->players[i]->game->inPlay)
|
||||
&& dest == g->players[i]->game->library)
|
||||
|| dest == g->players[i]->game->library)
|
||||
{
|
||||
return "Put in Library";
|
||||
}
|
||||
@@ -1361,7 +1384,8 @@ int GenericTargetAbility::resolve()
|
||||
|
||||
int GenericTargetAbility::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
{
|
||||
if (limitPerTurn && counters >= limitPerTurn) return 0;
|
||||
if (limitPerTurn && counters >= limitPerTurn)
|
||||
return 0;
|
||||
return TargetAbility::isReactingToClick(card, mana);
|
||||
}
|
||||
|
||||
@@ -1376,8 +1400,10 @@ void GenericTargetAbility::Update(float dt)
|
||||
|
||||
int GenericTargetAbility::testDestroy()
|
||||
{
|
||||
if (!activeZone) return TargetAbility::testDestroy();
|
||||
if (activeZone->hasCard(source)) return 0;
|
||||
if (!activeZone)
|
||||
return TargetAbility::testDestroy();
|
||||
if (activeZone->hasCard(source))
|
||||
return 0;
|
||||
return 1;
|
||||
|
||||
}
|
||||
@@ -1388,7 +1414,8 @@ GenericTargetAbility * GenericTargetAbility::clone() const
|
||||
a->ability = ability->clone();
|
||||
a->cost = NEW ManaCost();
|
||||
a->cost->copy(cost);
|
||||
if (tc) a->tc = tc->clone();
|
||||
if (tc)
|
||||
a->tc = tc->clone();
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -1461,19 +1488,23 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t
|
||||
PopulateColorIndexVector(colors, sabilities);
|
||||
|
||||
remove = false;
|
||||
if (stypes == "removesubtypes") remove = true;
|
||||
if (stypes == "removesubtypes")
|
||||
remove = true;
|
||||
if (stypes == "allsubtypes" || stypes == "removesubtypes")
|
||||
{
|
||||
for (int i = Subtypes::LAST_TYPE + 1;; i++)
|
||||
{
|
||||
string s = Subtypes::subtypesList->find(i);
|
||||
{
|
||||
if (s == "") break;
|
||||
if (s.find(" ") != string::npos) continue;
|
||||
if (s == "Nothing" || s == "Swamp" || s == "Plains" || s == "Mountain" || s == "Forest" || s == "Island" || s
|
||||
== "Shrine" || s == "Basic" || s == "Colony" || s == "Desert" || s == "Dismiss" || s == "Equipment" || s
|
||||
== "Everglades" || s == "Grasslands" || s == "Lair" || s == "Level" || s == "Levelup" || s == "Mine" || s
|
||||
== "Oasis" || s == "World" || s == "Aura")
|
||||
if (s == "")
|
||||
break;
|
||||
if (s.find(" ") != string::npos)
|
||||
continue;
|
||||
if (s == "Nothing" || s == "Swamp" || s == "Plains" || s == "Mountain" || s == "Forest"
|
||||
|| s == "Island" || s == "Shrine" || s == "Basic" || s == "Colony" || s == "Desert"
|
||||
|| s == "Dismiss" || s == "Equipment" || s == "Everglades" || s == "Grasslands" || s == "Lair"
|
||||
|| s == "Level" || s == "Levelup" || s == "Mine" || s == "Oasis" || s == "World" || s == "Aura"
|
||||
)
|
||||
{//dont add "nothing" or land type to this card.
|
||||
}
|
||||
else
|
||||
@@ -1488,7 +1519,7 @@ ATransformer::ATransformer(int id, MTGCardInstance * source, MTGCardInstance * t
|
||||
PopulateSubtypesIndexVector(types, stypes);
|
||||
}
|
||||
|
||||
menu = stypes;
|
||||
menu = stypes;
|
||||
}
|
||||
|
||||
int ATransformer::addToGame()
|
||||
@@ -1500,13 +1531,16 @@ int ATransformer::addToGame()
|
||||
_target = _target->next;
|
||||
for (int j = 0; j < Constants::MTG_NB_COLORS; j++)
|
||||
{
|
||||
if (_target->hasColor(j)) oldcolors.push_back(j);
|
||||
if (_target->hasColor(j))
|
||||
oldcolors.push_back(j);
|
||||
}
|
||||
for (int j = Subtypes::LAST_TYPE + 1;; j++)
|
||||
{
|
||||
string otypes = Subtypes::subtypesList->find(j);
|
||||
if (otypes == "") break;
|
||||
if (otypes.find(" ") != string::npos) continue;
|
||||
if (otypes == "")
|
||||
break;
|
||||
if (otypes.find(" ") != string::npos)
|
||||
continue;
|
||||
if (_target->hasSubtype(j))
|
||||
{
|
||||
oldtypes.push_back(j);
|
||||
@@ -1554,7 +1588,8 @@ int ATransformer::destroy()
|
||||
list<int>::iterator it;
|
||||
for (it = types.begin(); it != types.end(); it++)
|
||||
{
|
||||
if (remove == false) _target->removeType(*it);
|
||||
if (remove == false)
|
||||
_target->removeType(*it);
|
||||
}
|
||||
for (it = colors.begin(); it != colors.end(); it++)
|
||||
{
|
||||
@@ -1572,7 +1607,8 @@ int ATransformer::destroy()
|
||||
{
|
||||
for (it = oldtypes.begin(); it != oldtypes.end(); it++)
|
||||
{
|
||||
if (!_target->hasSubtype(*it)) _target->addType(*it);
|
||||
if (!_target->hasSubtype(*it))
|
||||
_target->addType(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1608,7 +1644,7 @@ AForeverTransformer::AForeverTransformer(int id, MTGCardInstance * source, MTGCa
|
||||
PopulateAbilityIndexVector(abilities, sabilities);
|
||||
PopulateColorIndexVector(colors, sabilities);
|
||||
PopulateSubtypesIndexVector(types, stypes);
|
||||
menu = stypes;
|
||||
menu = stypes;
|
||||
}
|
||||
|
||||
int AForeverTransformer::addToGame()
|
||||
@@ -1673,7 +1709,7 @@ int ATransformerUEOT::resolve()
|
||||
}
|
||||
const char * ATransformerUEOT::getMenuText()
|
||||
{
|
||||
return ability->getMenuText();
|
||||
return ability->getMenuText();
|
||||
}
|
||||
|
||||
ATransformerUEOT * ATransformerUEOT::clone() const
|
||||
@@ -1707,7 +1743,7 @@ int ATransformerFOREVER::resolve()
|
||||
|
||||
const char * ATransformerFOREVER::getMenuText()
|
||||
{
|
||||
return ability->getMenuText();
|
||||
return ability->getMenuText();
|
||||
}
|
||||
|
||||
ATransformerFOREVER * ATransformerFOREVER::clone() const
|
||||
@@ -1740,7 +1776,7 @@ int ASwapPTUEOT::resolve()
|
||||
|
||||
const char * ASwapPTUEOT::getMenuText()
|
||||
{
|
||||
return ability->getMenuText();
|
||||
return ability->getMenuText();
|
||||
}
|
||||
|
||||
ASwapPTUEOT * ASwapPTUEOT::clone() const
|
||||
@@ -1766,7 +1802,7 @@ ABecomes::ABecomes(int id, MTGCardInstance * source, MTGCardInstance * target, s
|
||||
PopulateAbilityIndexVector(abilities, sabilities);
|
||||
PopulateColorIndexVector(colors, sabilities);
|
||||
PopulateSubtypesIndexVector(types, stypes);
|
||||
menu = stypes;
|
||||
menu = stypes;
|
||||
|
||||
}
|
||||
int ABecomes::addToGame()
|
||||
@@ -1824,7 +1860,8 @@ const char * ABecomes::getMenuText()
|
||||
ABecomes * ABecomes::clone() const
|
||||
{
|
||||
ABecomes * a = NEW ABecomes(*this);
|
||||
if (a->wppt) a->wppt = NEW WParsedPT(*(a->wppt));
|
||||
if (a->wppt)
|
||||
a->wppt = NEW WParsedPT(*(a->wppt));
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
@@ -1887,9 +1924,11 @@ int APreventDamageTypes::addToGame()
|
||||
}
|
||||
TargetChooserFactory tcf;
|
||||
TargetChooser *toTc = tcf.createTargetChooser(to, source, this);
|
||||
if (toTc) toTc->targetter = NULL;
|
||||
if (toTc)
|
||||
toTc->targetter = NULL;
|
||||
TargetChooser *fromTc = tcf.createTargetChooser(from, source, this);
|
||||
if (fromTc) fromTc->targetter = NULL;
|
||||
if (fromTc)
|
||||
fromTc->targetter = NULL;
|
||||
if (type != 1 && type != 2)
|
||||
{//not adding this creates a memory leak.
|
||||
re = NEW REDamagePrevention(this, fromTc, toTc, -1, false, DAMAGE_COMBAT);
|
||||
@@ -1974,7 +2013,7 @@ AUpkeep::AUpkeep(int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _co
|
||||
ActivatedAbility(_id, card, _cost, restrictions, _tap), NestedAbility(a), phase(_phase), once(_once)
|
||||
{
|
||||
paidThisTurn = 0;
|
||||
aType = MTGAbility::UPCOST;
|
||||
aType = MTGAbility::UPCOST;
|
||||
}
|
||||
|
||||
void AUpkeep::Update(float dt)
|
||||
@@ -1990,14 +2029,16 @@ void AUpkeep::Update(float dt)
|
||||
{
|
||||
ability->resolve();
|
||||
}
|
||||
if (newPhase == phase + 1 && once) once = 2;
|
||||
if (newPhase == phase + 1 && once)
|
||||
once = 2;
|
||||
}
|
||||
ActivatedAbility::Update(dt);
|
||||
}
|
||||
|
||||
int AUpkeep::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
{
|
||||
if (currentPhase != phase || paidThisTurn || once >= 2) return 0;
|
||||
if (currentPhase != phase || paidThisTurn || once >= 2)
|
||||
return 0;
|
||||
return ActivatedAbility::isReactingToClick(card, mana);
|
||||
}
|
||||
|
||||
@@ -2028,48 +2069,47 @@ AUpkeep * AUpkeep::clone() const
|
||||
AUpkeep::~AUpkeep()
|
||||
{
|
||||
if (!isClone)
|
||||
SAFE_DELETE(ability);
|
||||
SAFE_DELETE(ability);
|
||||
}
|
||||
|
||||
|
||||
// utility functions
|
||||
|
||||
// Given a delimited string of abilities, add the ones to the list that are "Basic" MTG abilities
|
||||
void PopulateAbilityIndexVector( list<int>& abilities, const string& abilityStringList, char delimiter )
|
||||
void PopulateAbilityIndexVector(list<int>& abilities, const string& abilityStringList, char delimiter)
|
||||
{
|
||||
vector<string> abilitiesList = split( abilityStringList, delimiter);
|
||||
for ( vector<string>::iterator iter = abilitiesList.begin(); iter != abilitiesList.end(); ++iter)
|
||||
vector<string> abilitiesList = split(abilityStringList, delimiter);
|
||||
for (vector<string>::iterator iter = abilitiesList.begin(); iter != abilitiesList.end(); ++iter)
|
||||
{
|
||||
int abilityIndex = Constants::GetBasicAbilityIndex( *iter );
|
||||
int abilityIndex = Constants::GetBasicAbilityIndex(*iter);
|
||||
|
||||
if (abilityIndex != -1)
|
||||
abilities.push_back( abilityIndex );
|
||||
abilities.push_back(abilityIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PopulateColorIndexVector( list<int>& colors, const string& colorStringList, char delimiter )
|
||||
void PopulateColorIndexVector(list<int>& colors, const string& colorStringList, char delimiter)
|
||||
{
|
||||
vector<string> abilitiesList = split( colorStringList, delimiter);
|
||||
for ( vector<string>::iterator iter = abilitiesList.begin(); iter != abilitiesList.end(); ++iter)
|
||||
vector<string> abilitiesList = split(colorStringList, delimiter);
|
||||
for (vector<string>::iterator iter = abilitiesList.begin(); iter != abilitiesList.end(); ++iter)
|
||||
{
|
||||
for (int colorIndex = Constants::MTG_COLOR_ARTIFACT; colorIndex < Constants::MTG_NB_COLORS; ++colorIndex)
|
||||
{
|
||||
// if the text is not a basic ability but contains a valid color add it to the color vector
|
||||
if ( (Constants::GetBasicAbilityIndex( *iter ) != -1) && ((*iter).find( Constants::MTGColorStrings[ colorIndex ] ) != string::npos) )
|
||||
if ((Constants::GetBasicAbilityIndex(*iter) != -1)
|
||||
&& ((*iter).find(Constants::MTGColorStrings[colorIndex]) != string::npos))
|
||||
colors.push_back(colorIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PopulateSubtypesIndexVector( list<int>& types, const string& subTypesStringList, char delimiter)
|
||||
void PopulateSubtypesIndexVector(list<int>& types, const string& subTypesStringList, char delimiter)
|
||||
{
|
||||
vector<string> subTypesList = split( subTypesStringList, delimiter);
|
||||
vector<string> subTypesList = split(subTypesStringList, delimiter);
|
||||
for (vector<string>::iterator it = subTypesList.begin(); it != subTypesList.end(); ++it)
|
||||
{
|
||||
string subtype = *it;
|
||||
size_t id = Subtypes::subtypesList->find( subtype );
|
||||
if ( id != string::npos )
|
||||
size_t id = Subtypes::subtypesList->find(subtype);
|
||||
if (id != string::npos)
|
||||
types.push_back(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,19 +72,19 @@ void GameObserver::nextPlayer()
|
||||
void GameObserver::nextGamePhase()
|
||||
{
|
||||
Phase * cPhaseOld = phaseRing->getCurrentPhase();
|
||||
if (cPhaseOld->id == Constants::MTG_PHASE_COMBATDAMAGE)
|
||||
if (FIRST_STRIKE == combatStep || END_FIRST_STRIKE == combatStep || DAMAGE == combatStep)
|
||||
{
|
||||
nextCombatStep();
|
||||
return;
|
||||
}
|
||||
if (cPhaseOld->id == Constants::MTG_PHASE_COMBATDAMAGE)
|
||||
if ((FIRST_STRIKE == combatStep) || (END_FIRST_STRIKE == combatStep) || (DAMAGE == combatStep))
|
||||
{
|
||||
nextCombatStep();
|
||||
return;
|
||||
}
|
||||
|
||||
if (cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS)
|
||||
if (BLOCKERS == combatStep || TRIGGERS == combatStep)
|
||||
{
|
||||
nextCombatStep();
|
||||
return;
|
||||
}
|
||||
if (cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS)
|
||||
if (BLOCKERS == combatStep || TRIGGERS == combatStep)
|
||||
{
|
||||
nextCombatStep();
|
||||
return;
|
||||
}
|
||||
|
||||
phaseRing->forward();
|
||||
|
||||
@@ -99,25 +99,25 @@ void GameObserver::nextGamePhase()
|
||||
currentGamePhase = cPhase->id;
|
||||
|
||||
if (Constants::MTG_PHASE_COMBATDAMAGE == currentGamePhase)
|
||||
nextCombatStep();
|
||||
nextCombatStep();
|
||||
|
||||
if (currentPlayer != cPhase->player)
|
||||
nextPlayer();
|
||||
nextPlayer();
|
||||
|
||||
//init begin of turn
|
||||
if (currentGamePhase == Constants::MTG_PHASE_BEFORE_BEGIN)
|
||||
{
|
||||
cleanupPhase();
|
||||
currentPlayer->canPutLandsIntoPlay = true;
|
||||
currentPlayer->landsPlayerCanStillPlay = 1;
|
||||
currentPlayer->castedspellsthisturn = 0;
|
||||
currentPlayer->opponent()->castedspellsthisturn = 0;
|
||||
currentPlayer->castcount = 0;
|
||||
currentPlayer->nocreatureinstant = false;
|
||||
currentPlayer->nospellinstant = false;
|
||||
currentPlayer->onlyoneinstant = false;
|
||||
currentPlayer->damageCount = 0;
|
||||
currentPlayer->preventable = 0;
|
||||
{
|
||||
cleanupPhase();
|
||||
currentPlayer->canPutLandsIntoPlay = true;
|
||||
currentPlayer->landsPlayerCanStillPlay = 1;
|
||||
currentPlayer->castedspellsthisturn = 0;
|
||||
currentPlayer->opponent()->castedspellsthisturn = 0;
|
||||
currentPlayer->castcount = 0;
|
||||
currentPlayer->nocreatureinstant = false;
|
||||
currentPlayer->nospellinstant = false;
|
||||
currentPlayer->onlyoneinstant = false;
|
||||
currentPlayer->damageCount = 0;
|
||||
currentPlayer->preventable = 0;
|
||||
mLayers->actionLayer()->cleanGarbage(); //clean abilities history for this turn;
|
||||
mLayers->stackLayer()->garbageCollect(); //clean stack history for this turn;
|
||||
mLayers->actionLayer()->Update(0);
|
||||
@@ -147,7 +147,7 @@ void GameObserver::nextGamePhase()
|
||||
switch (currentGamePhase)
|
||||
{
|
||||
case Constants::MTG_PHASE_UNTAP:
|
||||
DebugTrace("Untap Phase ------------- Turn " << turn );
|
||||
DebugTrace("Untap Phase ------------- Turn " << turn );
|
||||
untapPhase();
|
||||
break;
|
||||
case Constants::MTG_PHASE_DRAW:
|
||||
@@ -198,37 +198,39 @@ void GameObserver::nextCombatStep()
|
||||
|
||||
void GameObserver::userRequestNextGamePhase()
|
||||
{
|
||||
if (mLayers->stackLayer()->getNext(NULL, 0, NOT_RESOLVED))
|
||||
return;
|
||||
if (getCurrentTargetChooser())
|
||||
return;
|
||||
//if (mLayers->actionLayer()->isWaitingForAnswer())
|
||||
// return;
|
||||
if (mLayers->stackLayer()->getNext(NULL, 0, NOT_RESOLVED))
|
||||
return;
|
||||
if (getCurrentTargetChooser())
|
||||
return;
|
||||
//if (mLayers->actionLayer()->isWaitingForAnswer())
|
||||
// return;
|
||||
// Wil 12/5/10: additional check, not quite understanding why TargetChooser doesn't seem active at this point.
|
||||
// If we deem that an extra cost payment needs to be made, don't allow the next game phase to proceed.
|
||||
// Here's what I find weird - if the extra cost is something like a sacrifice, doesn't that imply a TargetChooser?
|
||||
if (WaitForExtraPayment(NULL))
|
||||
return;
|
||||
if (WaitForExtraPayment(NULL))
|
||||
return;
|
||||
|
||||
bool executeNextPhaseImmediately = true;
|
||||
bool executeNextPhaseImmediately = true;
|
||||
|
||||
Phase * cPhaseOld = phaseRing->getCurrentPhase();
|
||||
if ((cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS && combatStep == ORDER) || (cPhaseOld->id
|
||||
== Constants::MTG_PHASE_COMBATBLOCKERS && combatStep == TRIGGERS) || cPhaseOld->id
|
||||
== Constants::MTG_PHASE_COMBATDAMAGE || opponent()->isAI()
|
||||
|| options[Options::optionInterrupt(currentGamePhase)].number)
|
||||
{
|
||||
executeNextPhaseImmediately = false;
|
||||
}
|
||||
Phase * cPhaseOld = phaseRing->getCurrentPhase();
|
||||
if ((cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS && combatStep == ORDER)
|
||||
|| (cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS && combatStep == TRIGGERS)
|
||||
|| (cPhaseOld->id == Constants::MTG_PHASE_COMBATDAMAGE)
|
||||
|| opponent()->isAI()
|
||||
|| options[Options::optionInterrupt(currentGamePhase)].number
|
||||
)
|
||||
{
|
||||
executeNextPhaseImmediately = false;
|
||||
}
|
||||
|
||||
if (executeNextPhaseImmediately)
|
||||
{
|
||||
nextGamePhase();
|
||||
}
|
||||
else
|
||||
{
|
||||
mLayers->stackLayer()->AddNextGamePhase();
|
||||
}
|
||||
if (executeNextPhaseImmediately)
|
||||
{
|
||||
nextGamePhase();
|
||||
}
|
||||
else
|
||||
{
|
||||
mLayers->stackLayer()->AddNextGamePhase();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -254,8 +256,8 @@ void GameObserver::startGame(Rules * rules)
|
||||
{
|
||||
turn = 0;
|
||||
mRules = rules;
|
||||
if (rules)
|
||||
rules->initPlayers();
|
||||
if (rules)
|
||||
rules->initPlayers();
|
||||
|
||||
options.automaticStyle(players[0], players[1]);
|
||||
|
||||
@@ -266,8 +268,8 @@ void GameObserver::startGame(Rules * rules)
|
||||
currentPlayer = players[0];
|
||||
currentActionPlayer = currentPlayer;
|
||||
phaseRing = NEW PhaseRing(players, nbPlayers);
|
||||
if (rules)
|
||||
rules->initGame();
|
||||
if (rules)
|
||||
rules->initGame();
|
||||
|
||||
//Preload images from hand
|
||||
if (!players[0]->isAI())
|
||||
@@ -346,12 +348,12 @@ void GameObserver::Update(float dt)
|
||||
{
|
||||
Player * player = currentPlayer;
|
||||
|
||||
if (Constants::MTG_PHASE_COMBATBLOCKERS == currentGamePhase && BLOCKERS == combatStep)
|
||||
player = player->opponent();
|
||||
if (Constants::MTG_PHASE_COMBATBLOCKERS == currentGamePhase && BLOCKERS == combatStep)
|
||||
player = player->opponent();
|
||||
|
||||
currentActionPlayer = player;
|
||||
if (isInterrupting)
|
||||
player = isInterrupting;
|
||||
if (isInterrupting)
|
||||
player = isInterrupting;
|
||||
mLayers->Update(dt, player);
|
||||
|
||||
while (mLayers->actionLayer()->stuffHappened)
|
||||
@@ -359,8 +361,8 @@ void GameObserver::Update(float dt)
|
||||
mLayers->actionLayer()->Update(0);
|
||||
}
|
||||
|
||||
gameStateBasedEffects();
|
||||
oldGamePhase = currentGamePhase;
|
||||
gameStateBasedEffects();
|
||||
oldGamePhase = currentGamePhase;
|
||||
}
|
||||
|
||||
//applies damage to creatures after updates
|
||||
@@ -368,268 +370,269 @@ void GameObserver::Update(float dt)
|
||||
//Handles game state based effects
|
||||
void GameObserver::gameStateBasedEffects()
|
||||
{
|
||||
//check land playability at start; as we want this effect to happen reguardless of unresolved
|
||||
//effects or menus actions
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if(players[i]->landsPlayerCanStillPlay <= 0)
|
||||
{
|
||||
players[i]->canPutLandsIntoPlay = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
players[i]->canPutLandsIntoPlay = true;
|
||||
}
|
||||
}
|
||||
if (mLayers->stackLayer()->count(0, NOT_RESOLVED) != 0)
|
||||
return;
|
||||
if (mLayers->actionLayer()->menuObject)
|
||||
return;
|
||||
if (targetChooser || mLayers->actionLayer()->isWaitingForAnswer())
|
||||
return;
|
||||
//check land playability at start; as we want this effect to happen reguardless of unresolved
|
||||
//effects or menus actions
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (players[i]->landsPlayerCanStillPlay <= 0)
|
||||
{
|
||||
players[i]->canPutLandsIntoPlay = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
players[i]->canPutLandsIntoPlay = true;
|
||||
}
|
||||
}
|
||||
if (mLayers->stackLayer()->count(0, NOT_RESOLVED) != 0)
|
||||
return;
|
||||
if (mLayers->actionLayer()->menuObject)
|
||||
return;
|
||||
if (targetChooser || mLayers->actionLayer()->isWaitingForAnswer())
|
||||
return;
|
||||
|
||||
////////////////////////
|
||||
//---apply damage-----//
|
||||
//after combat effects//
|
||||
////////////////////////
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
MTGGameZone * zone = players[i]->game->inPlay;
|
||||
for (int j = zone->nb_cards - 1; j >= 0; j--)
|
||||
{
|
||||
MTGCardInstance * card = zone->cards[j];
|
||||
card->afterDamage();
|
||||
////////////////////////
|
||||
//---apply damage-----//
|
||||
//after combat effects//
|
||||
////////////////////////
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
MTGGameZone * zone = players[i]->game->inPlay;
|
||||
for (int j = zone->nb_cards - 1; j >= 0; j--)
|
||||
{
|
||||
MTGCardInstance * card = zone->cards[j];
|
||||
card->afterDamage();
|
||||
|
||||
//Remove auras that don't have a valid target anymore
|
||||
if (card->target && !isInPlay(card->target) && !card->hasType("equipment"))
|
||||
{
|
||||
players[i]->game->putInGraveyard(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
//-------------------------------------
|
||||
//Remove auras that don't have a valid target anymore
|
||||
if (card->target && !isInPlay(card->target) && !card->hasType("equipment"))
|
||||
{
|
||||
players[i]->game->putInGraveyard(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
//-------------------------------------
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
///////////////////////////////////////////////////////////
|
||||
//life checks/poison checks also checks cant win or lose.//
|
||||
///////////////////////////////////////////////////////////
|
||||
if (players[i]->life <= 0)
|
||||
{
|
||||
int cantlosers = 0;
|
||||
MTGGameZone * z = players[i]->game->inPlay;
|
||||
int nbcards = z->nb_cards;
|
||||
for (int j = 0; j < nbcards; ++j)
|
||||
{
|
||||
MTGCardInstance * c = z->cards[j];
|
||||
if (c->has(Constants::CANTLOSE) || c->has(Constants::CANTLIFELOSE))
|
||||
{
|
||||
cantlosers++;
|
||||
}
|
||||
}
|
||||
MTGGameZone * k = players[i]->opponent()->game->inPlay;
|
||||
int onbcards = k->nb_cards;
|
||||
for (int m = 0; m < onbcards; ++m)
|
||||
{
|
||||
MTGCardInstance * e = k->cards[m];
|
||||
if (e->has(Constants::CANTWIN))
|
||||
{
|
||||
cantlosers++;
|
||||
}
|
||||
}
|
||||
if (cantlosers < 1)
|
||||
{
|
||||
gameOver = players[i];
|
||||
}
|
||||
if (players[i]->poisonCount >= 10)
|
||||
{
|
||||
gameOver = players[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////
|
||||
//-------------card based states effects------------//
|
||||
//////////////////////////////////////////////////////
|
||||
//ie:cantcast; extra land; extra turn;no max hand;--//
|
||||
//////////////////////////////////////////////////////
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
///////////////////////////////////////////////////////////
|
||||
//life checks/poison checks also checks cant win or lose.//
|
||||
///////////////////////////////////////////////////////////
|
||||
if (players[i]->life <= 0)
|
||||
{
|
||||
int cantlosers = 0;
|
||||
MTGGameZone * z = players[i]->game->inPlay;
|
||||
int nbcards = z->nb_cards;
|
||||
for (int j = 0; j < nbcards; ++j)
|
||||
{
|
||||
MTGCardInstance * c = z->cards[j];
|
||||
if (c->has(Constants::CANTLOSE) || c->has(Constants::CANTLIFELOSE))
|
||||
{
|
||||
cantlosers++;
|
||||
}
|
||||
}
|
||||
MTGGameZone * k = players[i]->opponent()->game->inPlay;
|
||||
int onbcards = k->nb_cards;
|
||||
for (int m = 0; m < onbcards; ++m)
|
||||
{
|
||||
MTGCardInstance * e = k->cards[m];
|
||||
if (e->has(Constants::CANTWIN))
|
||||
{
|
||||
cantlosers++;
|
||||
}
|
||||
}
|
||||
if (cantlosers < 1)
|
||||
{
|
||||
gameOver = players[i];
|
||||
}
|
||||
if (players[i]->poisonCount >= 10)
|
||||
{
|
||||
gameOver = players[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////////////////////
|
||||
//-------------card based states effects------------//
|
||||
//////////////////////////////////////////////////////
|
||||
//ie:cantcast; extra land; extra turn;no max hand;--//
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
//checks if a player has a card which has the stated ability in play.
|
||||
Player * p = players[i];
|
||||
MTGGameZone * z = players[i]->game->inPlay;
|
||||
int nbcards = z->nb_cards;
|
||||
p->onlyonecast = false;
|
||||
p->opponent()->onlyonecast = false;
|
||||
//------------------------------
|
||||
if (z->hasAbility(Constants::NOMAXHAND))
|
||||
{
|
||||
p->nomaxhandsize = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->nomaxhandsize = false;
|
||||
}
|
||||
//------------------------------
|
||||
if (z->hasAbility(Constants::CANTCASTCREATURE))
|
||||
{
|
||||
p->castrestrictedcreature = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->castrestrictedcreature = false;
|
||||
}
|
||||
//------------------------------
|
||||
if (z->hasAbility(Constants::CANTCAST))
|
||||
{
|
||||
p->castrestrictedspell = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->castrestrictedspell = false;
|
||||
}
|
||||
//------------------------------
|
||||
if (z->hasAbility(Constants::CANTCASTTWO))
|
||||
{
|
||||
p->onlyonecast = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->onlyonecast = false;
|
||||
}
|
||||
//--------------------------------
|
||||
if (z->hasAbility(Constants::BOTHCANTCAST))
|
||||
{
|
||||
p->bothrestrictedspell = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->bothrestrictedspell = false;
|
||||
}
|
||||
//---------------------------------
|
||||
if (z->hasAbility(Constants::BOTHNOCREATURE))
|
||||
{
|
||||
p->bothrestrictedcreature = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->bothrestrictedcreature = false;
|
||||
}
|
||||
//-----------------------------------
|
||||
if (z->hasAbility(Constants::ONLYONEBOTH))
|
||||
{
|
||||
p->onlyoneboth = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->onlyoneboth = false;
|
||||
}
|
||||
//------------------------------------
|
||||
if(players[0]->bothrestrictedcreature)
|
||||
players[1]->castrestrictedcreature = true;
|
||||
//------------------------------------
|
||||
if(players[0]->bothrestrictedspell)
|
||||
players[1]->castrestrictedspell = true;
|
||||
//------------------------------------
|
||||
if(players[0]->onlyoneboth)
|
||||
players[1]->onlyoneboth = true;
|
||||
//------------------------------------
|
||||
if(players[1]->bothrestrictedcreature)
|
||||
players[0]->castrestrictedcreature = true;
|
||||
//------------------------------------
|
||||
if(players[1]->bothrestrictedspell)
|
||||
players[0]->castrestrictedspell = true;
|
||||
//------------------------------------
|
||||
if(players[1]->onlyoneboth)
|
||||
players[0]->onlyoneboth = true;
|
||||
//------------------------------------
|
||||
/////////////////////////////////////////////////
|
||||
//handle end of turn effects while we're at it.//
|
||||
/////////////////////////////////////////////////
|
||||
if( currentGamePhase == Constants::MTG_PHASE_ENDOFTURN)
|
||||
{
|
||||
for (int j = 0; j < nbcards; ++j)
|
||||
{
|
||||
MTGCardInstance * c = z->cards[j];
|
||||
while (c->flanked)
|
||||
{//undoes the flanking on a card
|
||||
c->power += 1;
|
||||
c->addToToughness(1);
|
||||
c->flanked -= 1;
|
||||
}
|
||||
if (c->has(Constants::TREASON))
|
||||
{
|
||||
WEvent * e = NEW WEventCardSacrifice(c);
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
game->receiveEvent(e);
|
||||
p->game->putInGraveyard(c);
|
||||
}
|
||||
if (c->has(Constants::UNEARTH))
|
||||
p->game->putInExile(c);
|
||||
if (c->fresh)
|
||||
c->fresh = 0;
|
||||
if (c->has(Constants::ONLYONEBOTH))
|
||||
{
|
||||
c->controller()->castcount = 0;
|
||||
c->controller()->opponent()->castcount = 0;
|
||||
}
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
//checks if a player has a card which has the stated ability in play.
|
||||
Player * p = players[i];
|
||||
MTGGameZone * z = players[i]->game->inPlay;
|
||||
int nbcards = z->nb_cards;
|
||||
p->onlyonecast = false;
|
||||
p->opponent()->onlyonecast = false;
|
||||
//------------------------------
|
||||
if (z->hasAbility(Constants::NOMAXHAND))
|
||||
{
|
||||
p->nomaxhandsize = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->nomaxhandsize = false;
|
||||
}
|
||||
//------------------------------
|
||||
if (z->hasAbility(Constants::CANTCASTCREATURE))
|
||||
{
|
||||
p->castrestrictedcreature = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->castrestrictedcreature = false;
|
||||
}
|
||||
//------------------------------
|
||||
if (z->hasAbility(Constants::CANTCAST))
|
||||
{
|
||||
p->castrestrictedspell = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->castrestrictedspell = false;
|
||||
}
|
||||
//------------------------------
|
||||
if (z->hasAbility(Constants::CANTCASTTWO))
|
||||
{
|
||||
p->onlyonecast = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->onlyonecast = false;
|
||||
}
|
||||
//--------------------------------
|
||||
if (z->hasAbility(Constants::BOTHCANTCAST))
|
||||
{
|
||||
p->bothrestrictedspell = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->bothrestrictedspell = false;
|
||||
}
|
||||
//---------------------------------
|
||||
if (z->hasAbility(Constants::BOTHNOCREATURE))
|
||||
{
|
||||
p->bothrestrictedcreature = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->bothrestrictedcreature = false;
|
||||
}
|
||||
//-----------------------------------
|
||||
if (z->hasAbility(Constants::ONLYONEBOTH))
|
||||
{
|
||||
p->onlyoneboth = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
p->onlyoneboth = false;
|
||||
}
|
||||
//------------------------------------
|
||||
if (players[0]->bothrestrictedcreature)
|
||||
players[1]->castrestrictedcreature = true;
|
||||
//------------------------------------
|
||||
if (players[0]->bothrestrictedspell)
|
||||
players[1]->castrestrictedspell = true;
|
||||
//------------------------------------
|
||||
if (players[0]->onlyoneboth)
|
||||
players[1]->onlyoneboth = true;
|
||||
//------------------------------------
|
||||
if (players[1]->bothrestrictedcreature)
|
||||
players[0]->castrestrictedcreature = true;
|
||||
//------------------------------------
|
||||
if (players[1]->bothrestrictedspell)
|
||||
players[0]->castrestrictedspell = true;
|
||||
//------------------------------------
|
||||
if (players[1]->onlyoneboth)
|
||||
players[0]->onlyoneboth = true;
|
||||
//------------------------------------
|
||||
/////////////////////////////////////////////////
|
||||
//handle end of turn effects while we're at it.//
|
||||
/////////////////////////////////////////////////
|
||||
if (currentGamePhase == Constants::MTG_PHASE_ENDOFTURN)
|
||||
{
|
||||
for (int j = 0; j < nbcards; ++j)
|
||||
{
|
||||
MTGCardInstance * c = z->cards[j];
|
||||
while (c->flanked)
|
||||
{//undoes the flanking on a card
|
||||
c->power += 1;
|
||||
c->addToToughness(1);
|
||||
c->flanked -= 1;
|
||||
}
|
||||
if (c->has(Constants::TREASON))
|
||||
{
|
||||
WEvent * e = NEW WEventCardSacrifice(c);
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
game->receiveEvent(e);
|
||||
p->game->putInGraveyard(c);
|
||||
}
|
||||
if (c->has(Constants::UNEARTH)) p->game->putInExile(c);
|
||||
if (c->fresh) c->fresh = 0;
|
||||
if (c->has(Constants::ONLYONEBOTH))
|
||||
{
|
||||
c->controller()->castcount = 0;
|
||||
c->controller()->opponent()->castcount = 0;
|
||||
}
|
||||
|
||||
}
|
||||
MTGGameZone * f = p->game->graveyard;
|
||||
for (int k = 0; k < f->nb_cards; k++)
|
||||
{
|
||||
MTGCardInstance * card = f->cards[k];
|
||||
card->fresh = 0;
|
||||
}
|
||||
}
|
||||
if(z->nb_cards == 0)
|
||||
{
|
||||
p->nomaxhandsize = false;
|
||||
if(!p->bothrestrictedcreature && !p->opponent()->bothrestrictedcreature)
|
||||
p->castrestrictedcreature = false;
|
||||
if(!p->bothrestrictedspell && !p->opponent()->bothrestrictedspell)
|
||||
p->castrestrictedspell = false;
|
||||
p->onlyonecast = false;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////
|
||||
//phase based state effects------//
|
||||
///////////////////////////////////
|
||||
if (combatStep == TRIGGERS)
|
||||
{
|
||||
if (!mLayers->stackLayer()->getNext(NULL, 0, NOT_RESOLVED) && !targetChooser && !mLayers->actionLayer()->isWaitingForAnswer())
|
||||
}
|
||||
MTGGameZone * f = p->game->graveyard;
|
||||
for (int k = 0; k < f->nb_cards; k++)
|
||||
{
|
||||
MTGCardInstance * card = f->cards[k];
|
||||
card->fresh = 0;
|
||||
}
|
||||
}
|
||||
if (z->nb_cards == 0)
|
||||
{
|
||||
p->nomaxhandsize = false;
|
||||
if (!p->bothrestrictedcreature && !p->opponent()->bothrestrictedcreature)
|
||||
p->castrestrictedcreature = false;
|
||||
if (!p->bothrestrictedspell && !p->opponent()->bothrestrictedspell)
|
||||
p->castrestrictedspell = false;
|
||||
p->onlyonecast = false;
|
||||
}
|
||||
}
|
||||
///////////////////////////////////
|
||||
//phase based state effects------//
|
||||
///////////////////////////////////
|
||||
if (combatStep == TRIGGERS)
|
||||
{
|
||||
if (!mLayers->stackLayer()->getNext(NULL, 0, NOT_RESOLVED) && !targetChooser
|
||||
&& !mLayers->actionLayer()->isWaitingForAnswer())
|
||||
mLayers->stackLayer()->AddNextCombatStep();
|
||||
}
|
||||
}
|
||||
|
||||
//Auto skip Phases
|
||||
GameObserver * game = game->GetInstance();
|
||||
int skipLevel = (game->currentPlayer->playMode == Player::MODE_TEST_SUITE) ? Constants::ASKIP_NONE : options[Options::ASPHASES].number;
|
||||
int nrCreatures = currentPlayer->game->inPlay->countByType("Creature");
|
||||
//Auto skip Phases
|
||||
GameObserver * game = game->GetInstance();
|
||||
int skipLevel = (game->currentPlayer->playMode == Player::MODE_TEST_SUITE) ? Constants::ASKIP_NONE
|
||||
: options[Options::ASPHASES].number;
|
||||
int nrCreatures = currentPlayer->game->inPlay->countByType("Creature");
|
||||
|
||||
if (skipLevel == Constants::ASKIP_SAFE || skipLevel == Constants::ASKIP_FULL)
|
||||
{
|
||||
if ((opponent()->isAI() && !(isInterrupting)) && (currentGamePhase == Constants::MTG_PHASE_UNTAP || currentGamePhase
|
||||
== Constants::MTG_PHASE_DRAW || currentGamePhase == Constants::MTG_PHASE_COMBATBEGIN || ((currentGamePhase
|
||||
== Constants::MTG_PHASE_COMBATATTACKERS) && (nrCreatures == 0)) || currentGamePhase
|
||||
== Constants::MTG_PHASE_COMBATEND || currentGamePhase == Constants::MTG_PHASE_ENDOFTURN
|
||||
|| ((currentGamePhase == Constants::MTG_PHASE_CLEANUP) && (currentPlayer->game->hand->nb_cards < 8))))
|
||||
if (skipLevel == Constants::ASKIP_SAFE || skipLevel == Constants::ASKIP_FULL)
|
||||
{
|
||||
if ((opponent()->isAI() && !(isInterrupting)) && ((currentGamePhase == Constants::MTG_PHASE_UNTAP)
|
||||
|| (currentGamePhase == Constants::MTG_PHASE_DRAW) || (currentGamePhase == Constants::MTG_PHASE_COMBATBEGIN)
|
||||
|| ((currentGamePhase == Constants::MTG_PHASE_COMBATATTACKERS) && (nrCreatures == 0))
|
||||
|| currentGamePhase == Constants::MTG_PHASE_COMBATEND || currentGamePhase == Constants::MTG_PHASE_ENDOFTURN
|
||||
|| ((currentGamePhase == Constants::MTG_PHASE_CLEANUP) && (currentPlayer->game->hand->nb_cards < 8))))
|
||||
userRequestNextGamePhase();
|
||||
}
|
||||
if (skipLevel == Constants::ASKIP_FULL)
|
||||
{
|
||||
if ((opponent()->isAI() && !(isInterrupting)) && (currentGamePhase == Constants::MTG_PHASE_UPKEEP || currentGamePhase
|
||||
== Constants::MTG_PHASE_COMBATDAMAGE))
|
||||
userRequestNextGamePhase();
|
||||
}
|
||||
}
|
||||
if (skipLevel == Constants::ASKIP_FULL)
|
||||
{
|
||||
if ((opponent()->isAI() && !(isInterrupting)) && (currentGamePhase == Constants::MTG_PHASE_UPKEEP
|
||||
|| currentGamePhase == Constants::MTG_PHASE_COMBATDAMAGE))
|
||||
userRequestNextGamePhase();
|
||||
}
|
||||
}
|
||||
|
||||
void GameObserver::Render()
|
||||
{
|
||||
mLayers->Render();
|
||||
if (targetChooser || mLayers->actionLayer()->isWaitingForAnswer())
|
||||
JRenderer::GetInstance()->DrawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(255,255,0,0));
|
||||
if (mExtraPayment)
|
||||
mExtraPayment->Render();
|
||||
if (targetChooser || mLayers->actionLayer()->isWaitingForAnswer())
|
||||
JRenderer::GetInstance()->DrawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(255,255,0,0));
|
||||
if (mExtraPayment)
|
||||
mExtraPayment->Render();
|
||||
|
||||
for (int i = 0; i < nbPlayers; ++i)
|
||||
{
|
||||
players[i]->Render();
|
||||
@@ -701,8 +704,8 @@ void GameObserver::stackObjectClicked(Interruptible * action)
|
||||
else
|
||||
{
|
||||
int reaction = mLayers->actionLayer()->isReactingToTargetClick(action);
|
||||
if (reaction == -1)
|
||||
mLayers->actionLayer()->reactToTargetClick(action);
|
||||
if (reaction == -1)
|
||||
mLayers->actionLayer()->reactToTargetClick(action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,8 +732,8 @@ bool GameObserver::WaitForExtraPayment(MTGCardInstance * card)
|
||||
int GameObserver::cardClick(MTGCardInstance * card, Targetable * object)
|
||||
{
|
||||
Player * clickedPlayer = NULL;
|
||||
if (!card)
|
||||
clickedPlayer = ((Player *) object);
|
||||
if (!card)
|
||||
clickedPlayer = ((Player *) object);
|
||||
if (targetChooser)
|
||||
{
|
||||
int result;
|
||||
@@ -763,10 +766,10 @@ int GameObserver::cardClick(MTGCardInstance * card, Targetable * object)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (WaitForExtraPayment(card))
|
||||
return 1;
|
||||
if (WaitForExtraPayment(card))
|
||||
return 1;
|
||||
|
||||
int reaction = 0;
|
||||
int reaction = 0;
|
||||
|
||||
if (ORDER == combatStep)
|
||||
{
|
||||
@@ -793,22 +796,22 @@ int GameObserver::cardClick(MTGCardInstance * card, Targetable * object)
|
||||
}
|
||||
|
||||
reaction = mLayers->actionLayer()->isReactingToClick(card);
|
||||
if (reaction == -1)
|
||||
return mLayers->actionLayer()->reactToClick(card);
|
||||
if (reaction == -1)
|
||||
return mLayers->actionLayer()->reactToClick(card);
|
||||
}
|
||||
else
|
||||
{//this handles abilities on a menu...not just when card is being played
|
||||
reaction = mLayers->actionLayer()->isReactingToTargetClick(object);
|
||||
if (reaction == -1)
|
||||
return mLayers->actionLayer()->reactToTargetClick(object);
|
||||
if (reaction == -1)
|
||||
return mLayers->actionLayer()->reactToTargetClick(object);
|
||||
}
|
||||
|
||||
if (!card)
|
||||
return 0;
|
||||
if (!card)
|
||||
return 0;
|
||||
|
||||
//Current player's hand
|
||||
if (currentPlayer->game->hand->hasCard(card) && currentGamePhase == Constants::MTG_PHASE_CLEANUP
|
||||
&& currentPlayer->game->hand->nb_cards > 7 && currentPlayer->nomaxhandsize == false)
|
||||
&& currentPlayer->game->hand->nb_cards > 7 && currentPlayer->nomaxhandsize == false)
|
||||
{
|
||||
currentPlayer->game->putInGraveyard(card);
|
||||
}
|
||||
@@ -840,9 +843,9 @@ int GameObserver::untap(MTGCardInstance * card)
|
||||
return 0;
|
||||
}
|
||||
if (card->has(Constants::DOESNOTUNTAP))
|
||||
return 0;
|
||||
if (card->frozen > 0)
|
||||
return 0;
|
||||
return 0;
|
||||
if (card->frozen > 0)
|
||||
return 0;
|
||||
card->attemptUntap();
|
||||
return 1;
|
||||
}
|
||||
@@ -850,8 +853,8 @@ int GameObserver::untap(MTGCardInstance * card)
|
||||
TargetChooser * GameObserver::getCurrentTargetChooser()
|
||||
{
|
||||
TargetChooser * _tc = mLayers->actionLayer()->getCurrentTargetChooser();
|
||||
if (_tc)
|
||||
return _tc;
|
||||
if (_tc)
|
||||
return _tc;
|
||||
return targetChooser;
|
||||
}
|
||||
|
||||
@@ -860,8 +863,8 @@ int GameObserver::isInPlay(MTGCardInstance * card)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (players[i]->game->isInPlay(card))
|
||||
return 1;
|
||||
if (players[i]->game->isInPlay(card))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -884,11 +887,11 @@ void GameObserver::untapPhase()
|
||||
|
||||
int GameObserver::receiveEvent(WEvent * e)
|
||||
{
|
||||
if (!e)
|
||||
return 0;
|
||||
if (!e)
|
||||
return 0;
|
||||
eventsQueue.push(e);
|
||||
if (eventsQueue.size() > 1)
|
||||
return -1; //resolving events can generate more events
|
||||
if (eventsQueue.size() > 1)
|
||||
return -1; //resolving events can generate more events
|
||||
int result = 0;
|
||||
while (eventsQueue.size())
|
||||
{
|
||||
@@ -906,8 +909,8 @@ int GameObserver::receiveEvent(WEvent * e)
|
||||
|
||||
Player * GameObserver::currentlyActing()
|
||||
{
|
||||
if (isInterrupting)
|
||||
return isInterrupting;
|
||||
if (isInterrupting)
|
||||
return isInterrupting;
|
||||
return currentActionPlayer;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ bool GuiStatic::Leaving(JButton key)
|
||||
|
||||
GuiAvatar::GuiAvatar(float x, float y, bool hasFocus, Player * player, Corner corner, GuiAvatars* parent) :
|
||||
GuiStatic(static_cast<float> (GuiAvatar::Height), x, y, hasFocus, parent), avatarRed(255), currentLife(player->life),
|
||||
currentpoisonCount(player->poisonCount), corner(corner), player(player)
|
||||
currentpoisonCount(player->poisonCount), corner(corner), player(player)
|
||||
{
|
||||
type = GUI_AVATAR;
|
||||
}
|
||||
@@ -135,7 +135,7 @@ void GuiAvatar::Render()
|
||||
ostream& GuiAvatar::toString(ostream& out) const
|
||||
{
|
||||
return out << "GuiAvatar ::: avatarRed : " << avatarRed << " ; currentLife : " << currentLife << " ; currentpoisonCount : "
|
||||
<< currentpoisonCount << " ; player : " << player;
|
||||
<< currentpoisonCount << " ; player : " << player;
|
||||
}
|
||||
|
||||
void GuiGameZone::toggleDisplay()
|
||||
@@ -166,7 +166,7 @@ void GuiGameZone::Render()
|
||||
|
||||
if (mHasFocus)
|
||||
JRenderer::GetInstance()->FillRect(actX, actY, quad->mWidth * scale * actZ, quad->mHeight * scale * actZ,
|
||||
ARGB(abs(128 - wave),255,255,255));
|
||||
ARGB(abs(128 - wave),255,255,255));
|
||||
|
||||
//Number of cards
|
||||
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
|
||||
|
||||
@@ -19,9 +19,11 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
Player * currentPlayer = game->currentPlayer;
|
||||
if (!player->game->hand->hasCard(card))
|
||||
return 0;
|
||||
if ((game->turn < 1) && (cardsinhand != 0) && (card->basicAbilities[Constants::LEYLINE]) && game->currentGamePhase
|
||||
== Constants::MTG_PHASE_FIRSTMAIN && game->players[0]->game->graveyard->nb_cards == 0
|
||||
&& game->players[0]->game->exile->nb_cards == 0)
|
||||
if ((game->turn < 1) && (cardsinhand != 0) && (card->basicAbilities[Constants::LEYLINE])
|
||||
&& game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN
|
||||
&& game->players[0]->game->graveyard->nb_cards == 0
|
||||
&& game->players[0]->game->exile->nb_cards == 0
|
||||
)
|
||||
{
|
||||
Player * p = game->currentPlayer;
|
||||
if (card->basicAbilities[Constants::LEYLINE])
|
||||
@@ -35,15 +37,18 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
}
|
||||
if (card->hasType("land"))
|
||||
{
|
||||
if (player == currentPlayer && currentPlayer->canPutLandsIntoPlay && (game->currentGamePhase
|
||||
== Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN))
|
||||
if (player == currentPlayer && currentPlayer->canPutLandsIntoPlay
|
||||
&& (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN)
|
||||
)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if ((card->hasType("instant")) || card->has(Constants::FLASH) || (player == currentPlayer && !game->isInterrupting
|
||||
&& (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase
|
||||
== Constants::MTG_PHASE_SECONDMAIN)))
|
||||
else if ((card->hasType("instant")) || card->has(Constants::FLASH)
|
||||
|| (player == currentPlayer && !game->isInterrupting
|
||||
&& (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN
|
||||
|| game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN))
|
||||
)
|
||||
{
|
||||
ManaCost * playerMana = player->getManaPool();
|
||||
ManaCost * cost = card->getManaCost();
|
||||
@@ -241,15 +246,17 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
|
||||
return 0;
|
||||
if (card->hasType("land"))
|
||||
{
|
||||
if (player == currentPlayer && currentPlayer->canPutLandsIntoPlay && (game->currentGamePhase
|
||||
== Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN))
|
||||
{
|
||||
if (player == currentPlayer && currentPlayer->canPutLandsIntoPlay
|
||||
&& (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN
|
||||
|| game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN)
|
||||
)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if ((card->hasType("instant")) || card->has(Constants::FLASH) || (player == currentPlayer && !game->isInterrupting
|
||||
&& (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase
|
||||
== Constants::MTG_PHASE_SECONDMAIN)))
|
||||
else if ((card->hasType("instant")) || card->has(Constants::FLASH) || (player == currentPlayer
|
||||
&& !game->isInterrupting
|
||||
&& (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN
|
||||
|| game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN))
|
||||
)
|
||||
{
|
||||
ManaCost * playerMana = player->getManaPool();
|
||||
ManaCost * cost = card->getManaCost();
|
||||
@@ -431,14 +438,14 @@ int MTGBuyBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
if (card->hasType("land"))
|
||||
{
|
||||
if (player == currentPlayer && currentPlayer->canPutLandsIntoPlay && (game->currentGamePhase
|
||||
== Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN))
|
||||
== Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if ((card->hasType("instant")) || card->has(Constants::FLASH) || (player == currentPlayer && !game->isInterrupting
|
||||
&& (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase
|
||||
== Constants::MTG_PHASE_SECONDMAIN)))
|
||||
&& (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase
|
||||
== Constants::MTG_PHASE_SECONDMAIN)))
|
||||
{
|
||||
ManaCost * playerMana = player->getManaPool();
|
||||
ManaCost * cost = card->getManaCost();
|
||||
@@ -455,11 +462,11 @@ int MTGBuyBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (player->nospellinstant == true )
|
||||
if (player->nospellinstant == true)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (player->onlyoneinstant == true )
|
||||
if (player->onlyoneinstant == true)
|
||||
{
|
||||
if (player->castcount >= 1)
|
||||
{
|
||||
@@ -621,9 +628,11 @@ int MTGFlashBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
return 0;
|
||||
if (!card->getManaCost()->FlashBack)
|
||||
return 0;
|
||||
if ((card->hasType("instant")) || card->has(Constants::FLASH) || (player == currentPlayer && !game->isInterrupting
|
||||
&& (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase
|
||||
== Constants::MTG_PHASE_SECONDMAIN)))
|
||||
if ((card->hasType("instant")) || card->has(Constants::FLASH)
|
||||
|| (player == currentPlayer && !game->isInterrupting
|
||||
&& (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN
|
||||
|| game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN))
|
||||
)
|
||||
{
|
||||
ManaCost * playerMana = player->getManaPool();
|
||||
ManaCost * cost = card->getManaCost();
|
||||
@@ -640,11 +649,11 @@ int MTGFlashBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (player->nospellinstant == true )
|
||||
if (player->nospellinstant == true)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (player->onlyoneinstant == true )
|
||||
if (player->onlyoneinstant == true)
|
||||
{
|
||||
if (player->castcount >= 1)
|
||||
{
|
||||
@@ -732,7 +741,7 @@ int MTGFlashBackRule::reactToClick(MTGCardInstance * card)
|
||||
game->targetChooser = NULL;
|
||||
player->castedspellsthisturn += 1;
|
||||
player->opponent()->castedspellsthisturn += 1;
|
||||
if (player->onlyonecast == true || player->onlyoneinstant == true )
|
||||
if (player->onlyonecast == true || player->onlyoneinstant == true)
|
||||
{
|
||||
player->castcount += 1;
|
||||
}
|
||||
@@ -805,9 +814,11 @@ int MTGRetraceRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
return 0;
|
||||
if (!card->getManaCost()->Retrace)
|
||||
return 0;
|
||||
if ((card->hasType("instant")) || card->has(Constants::FLASH) || (player == currentPlayer && !game->isInterrupting
|
||||
&& (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase
|
||||
== Constants::MTG_PHASE_SECONDMAIN)))
|
||||
if ((card->hasType("instant")) || card->has(Constants::FLASH)
|
||||
|| (player == currentPlayer && !game->isInterrupting
|
||||
&& (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN
|
||||
|| game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN))
|
||||
)
|
||||
{
|
||||
ManaCost * playerMana = player->getManaPool();
|
||||
ManaCost * cost = card->getManaCost();
|
||||
@@ -824,11 +835,11 @@ int MTGRetraceRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (player->nospellinstant == true )
|
||||
if (player->nospellinstant == true)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (player->onlyoneinstant == true )
|
||||
if (player->onlyoneinstant == true)
|
||||
{
|
||||
if (player->castcount >= 1)
|
||||
{
|
||||
@@ -874,7 +885,8 @@ int MTGRetraceRule::reactToClick(MTGCardInstance * card)
|
||||
{
|
||||
cost->Retrace->setExtraCostsAction(this, card);
|
||||
game->mExtraPayment = cost->Retrace->extraCosts;
|
||||
card->paymenttype = MTGAbility::RETRACE_COST;;
|
||||
card->paymenttype = MTGAbility::RETRACE_COST;
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -912,7 +924,7 @@ int MTGRetraceRule::reactToClick(MTGCardInstance * card)
|
||||
game->targetChooser = NULL;
|
||||
player->castedspellsthisturn += 1;
|
||||
player->opponent()->castedspellsthisturn += 1;
|
||||
if (player->onlyonecast == true || player->onlyoneinstant == true )
|
||||
if (player->onlyonecast == true || player->onlyoneinstant == true)
|
||||
{
|
||||
player->castcount += 1;
|
||||
}
|
||||
@@ -1013,8 +1025,10 @@ int MTGAttackRule::receiveEvent(WEvent *e)
|
||||
for (int i = 0; i < z->nb_cards; i++)
|
||||
{
|
||||
MTGCardInstance * card = z->cards[i];
|
||||
if (!card->isAttacker() && card->has(Constants::MUSTATTACK)) reactToClick(card);
|
||||
if (!card->isAttacker() && card->has(Constants::TREASON) && p->isAI()) reactToClick(card);
|
||||
if (!card->isAttacker() && card->has(Constants::MUSTATTACK))
|
||||
reactToClick(card);
|
||||
if (!card->isAttacker() && card->has(Constants::TREASON) && p->isAI())
|
||||
reactToClick(card);
|
||||
if (card->isAttacker() && card->isTapped())
|
||||
card->setAttacker(0);
|
||||
if (card->isAttacker() && !card->has(Constants::VIGILANCE))
|
||||
@@ -1223,8 +1237,9 @@ MTGBlockRule::MTGBlockRule(int _id) :
|
||||
|
||||
int MTGBlockRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
{
|
||||
if (currentPhase == Constants::MTG_PHASE_COMBATBLOCKERS && !game->isInterrupting && card->controller()
|
||||
== game->currentlyActing())
|
||||
if (currentPhase == Constants::MTG_PHASE_COMBATBLOCKERS && !game->isInterrupting
|
||||
&& card->controller() == game->currentlyActing()
|
||||
)
|
||||
{
|
||||
if (card->canBlock())
|
||||
return 1;
|
||||
@@ -1245,8 +1260,8 @@ int MTGBlockRule::reactToClick(MTGCardInstance * card)
|
||||
canDefend = card->toggleDefenser(currentOpponent);
|
||||
|
||||
DebugTrace("Defenser Toggle: " << card->getName() << endl
|
||||
<< "- canDefend: " << (canDefend == 0) << endl
|
||||
<< "- currentOpponent: " << currentOpponent);
|
||||
<< "- canDefend: " << (canDefend == 0) << endl
|
||||
<< "- currentOpponent: " << currentOpponent);
|
||||
result = (canDefend || currentOpponent == NULL);
|
||||
}
|
||||
return 1;
|
||||
@@ -1291,7 +1306,7 @@ MTGMomirRule::MTGMomirRule(int _id, MTGAllCards * _collection) :
|
||||
{
|
||||
MTGCard * card = collection->collection[collection->ids[i]];
|
||||
if (card->data->isCreature() && (card->getRarity() != Constants::RARITY_T) && //remove tokens
|
||||
card->setId != MTGSets::INTERNAL_SET //remove cards that are defined in primitives. Those are workarounds (usually tokens) and should only be used internally
|
||||
card->setId != MTGSets::INTERNAL_SET //remove cards that are defined in primitives. Those are workarounds (usually tokens) and should only be used internally
|
||||
)
|
||||
{
|
||||
int convertedCost = card->data->getManaCost()->getConvertedCost();
|
||||
@@ -1315,8 +1330,10 @@ int MTGMomirRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
Player * currentPlayer = game->currentPlayer;
|
||||
if (!player->game->hand->hasCard(card))
|
||||
return 0;
|
||||
if (player == currentPlayer && !game->isInterrupting && (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN
|
||||
|| game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN))
|
||||
if (player == currentPlayer && !game->isInterrupting
|
||||
&& (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN
|
||||
|| game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN)
|
||||
)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -1414,8 +1431,9 @@ void MTGMomirRule::Render()
|
||||
|
||||
ostream& MTGMomirRule::toString(ostream& out) const
|
||||
{
|
||||
out << "MTGMomirRule ::: pool : " << pool << " ; initialized : " << initialized << " ; textAlpha : " << textAlpha << " ; text "
|
||||
<< text << " ; alreadyplayed : " << alreadyplayed << " ; collection : " << collection << "(";
|
||||
out << "MTGMomirRule ::: pool : " << pool << " ; initialized : " << initialized << " ; textAlpha : " << textAlpha
|
||||
<< " ; text " << text << " ; alreadyplayed : " << alreadyplayed
|
||||
<< " ; collection : " << collection << "(";
|
||||
return MTGAbility::toString(out) << ")";
|
||||
}
|
||||
|
||||
@@ -1487,7 +1505,7 @@ int HUDDisplay::receiveEvent(WEvent * event)
|
||||
{
|
||||
char buffer[512];
|
||||
sprintf(buffer, "%s: %i -> %s", _(ed->damage->source->name).c_str(), ed->damage->damage, _(
|
||||
ed->damage->target->getDisplayName()).c_str());
|
||||
ed->damage->target->getDisplayName()).c_str());
|
||||
string s = buffer;
|
||||
return addEvent(s);
|
||||
}
|
||||
@@ -1615,23 +1633,23 @@ MTGUnearthRule::MTGUnearthRule(int _id) :
|
||||
int MTGUnearthRule::receiveEvent(WEvent * event)
|
||||
{
|
||||
if (event->type == WEvent::CHANGE_ZONE)
|
||||
{
|
||||
WEventZoneChange * e = (WEventZoneChange *) event;
|
||||
MTGCardInstance * card = e->card->previous;
|
||||
if (e->from == e->card->controller()->game->battlefield && e->to == e->card->controller()->game->graveyard)
|
||||
{
|
||||
e->card->fresh = 1;
|
||||
}
|
||||
if (e->to == e->card->controller()->game->battlefield)
|
||||
{
|
||||
e->card->fresh = 1;
|
||||
}
|
||||
{
|
||||
WEventZoneChange * e = (WEventZoneChange *) event;
|
||||
MTGCardInstance * card = e->card->previous;
|
||||
if (e->from == e->card->controller()->game->battlefield && e->to == e->card->controller()->game->graveyard)
|
||||
{
|
||||
e->card->fresh = 1;
|
||||
}
|
||||
if (e->to == e->card->controller()->game->battlefield)
|
||||
{
|
||||
e->card->fresh = 1;
|
||||
}
|
||||
|
||||
if (card && card->basicAbilities[Constants::UNEARTH])
|
||||
{
|
||||
int ok = 0;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (card && card->basicAbilities[Constants::UNEARTH])
|
||||
{
|
||||
int ok = 0;
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
Player * p = game->players[i];
|
||||
if (e->from == p->game->inPlay)
|
||||
ok = 1;
|
||||
@@ -1696,10 +1714,19 @@ int MTGAffinityRule::receiveEvent(WEvent * event)
|
||||
//when cards with affinity enter you hand from anywhere a redux is applied to them for the artifacts in play.
|
||||
if (ok == 1)
|
||||
{//enters play from anywhere
|
||||
if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from
|
||||
== p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield
|
||||
|| e->from == p->game->temp || e->from == p->game->battlefield)
|
||||
if (e->from == p->game->graveyard
|
||||
|| e->from == p->game->hand
|
||||
|| e->from == p->game->library
|
||||
|| e->from == p->game->exile
|
||||
|| e->from == p->game->stack
|
||||
|| e->from == p->opponent()->game->battlefield
|
||||
|| e->from == p->game->temp
|
||||
|| e->from == p->game->battlefield
|
||||
)
|
||||
{
|
||||
// TODO:
|
||||
// what happens if there are any cards with two or more affinity abilities? If no such card exist
|
||||
// then could this block be changed to use else if? That will save on the number of operations.
|
||||
MTGCardInstance * card = e->card->previous;
|
||||
if (card && card->has(Constants::AFFINITYARTIFACTS))
|
||||
{
|
||||
@@ -1743,13 +1770,14 @@ int MTGAffinityRule::receiveEvent(WEvent * event)
|
||||
{
|
||||
MTGCardInstance * c = z->cards[j];
|
||||
int check = e->card->getManaCost()->getConvertedCost();
|
||||
if ((e->card->has(Constants::AFFINITYARTIFACTS) && c->hasSubtype("artifact")) || (e->card->has(
|
||||
Constants::AFFINITYSWAMP) && c->hasSubtype("swamp")) || (e->card->has(
|
||||
Constants::AFFINITYMOUNTAIN) && c->hasSubtype("moutain")) || (e->card->has(
|
||||
Constants::AFFINITYPLAINS) && c->hasSubtype("plains")) || (e->card->has(
|
||||
Constants::AFFINITYISLAND) && c->hasSubtype("island")) || (e->card->has(
|
||||
Constants::AFFINITYFOREST) && c->hasSubtype("forest")) || (e->card->has(
|
||||
Constants::AFFINITYGREENCREATURES) && c->hasColor(1) && c->isCreature()))
|
||||
if ((e->card->has(Constants::AFFINITYARTIFACTS) && c->hasSubtype("artifact"))
|
||||
|| (e->card->has(Constants::AFFINITYSWAMP) && c->hasSubtype("swamp"))
|
||||
|| (e->card->has(Constants::AFFINITYMOUNTAIN) && c->hasSubtype("moutain"))
|
||||
|| (e->card->has(Constants::AFFINITYPLAINS) && c->hasSubtype("plains"))
|
||||
|| (e->card->has(Constants::AFFINITYISLAND) && c->hasSubtype("island"))
|
||||
|| (e->card->has(Constants::AFFINITYFOREST) && c->hasSubtype("forest"))
|
||||
|| (e->card->has(Constants::AFFINITYGREENCREATURES) && c->hasColor(1) && c->isCreature())
|
||||
)
|
||||
{
|
||||
if (check > 0)
|
||||
{
|
||||
@@ -1776,8 +1804,13 @@ int MTGAffinityRule::receiveEvent(WEvent * event)
|
||||
ok = 2;//card enters play
|
||||
if (ok == 2)
|
||||
{//enters play from anywhere
|
||||
if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from
|
||||
== p->game->exile || e->from == p->game->stack || e->from == p->game->temp)
|
||||
if (e->from == p->game->graveyard
|
||||
|| e->from == p->game->hand
|
||||
|| e->from == p->game->library
|
||||
|| e->from == p->game->exile
|
||||
|| e->from == p->game->stack
|
||||
|| e->from == p->game->temp
|
||||
)
|
||||
{
|
||||
//--redux effect
|
||||
MTGGameZone * z = card->controller()->game->hand;
|
||||
@@ -1817,13 +1850,14 @@ int MTGAffinityRule::receiveEvent(WEvent * event)
|
||||
for (int j = 0; j < nbcards; ++j)
|
||||
{
|
||||
MTGCardInstance * c = z->cards[j];
|
||||
if ((c->has(Constants::AFFINITYARTIFACTS) && etype.find("art") != string::npos) || (c->has(
|
||||
Constants::AFFINITYSWAMP) && etype.find("swa") != string::npos) || (c->has(
|
||||
Constants::AFFINITYMOUNTAIN) && etype.find("mou") != string::npos) || (c->has(
|
||||
Constants::AFFINITYPLAINS) && etype.find("pla") != string::npos) || (c->has(
|
||||
Constants::AFFINITYISLAND) && etype.find("isl") != string::npos) || (c->has(
|
||||
Constants::AFFINITYFOREST) && etype.find("for") != string::npos) || (c->has(
|
||||
Constants::AFFINITYGREENCREATURES) && etype.find("cre") != string::npos))
|
||||
if ((c->has(Constants::AFFINITYARTIFACTS) && etype.find("art") != string::npos)
|
||||
|| (c->has(Constants::AFFINITYSWAMP) && etype.find("swa") != string::npos)
|
||||
|| (c->has(Constants::AFFINITYMOUNTAIN) && etype.find("mou") != string::npos)
|
||||
|| (c->has(Constants::AFFINITYPLAINS) && etype.find("pla") != string::npos)
|
||||
|| (c->has(Constants::AFFINITYISLAND) && etype.find("isl") != string::npos)
|
||||
|| (c->has(Constants::AFFINITYFOREST) && etype.find("for") != string::npos)
|
||||
|| (c->has(Constants::AFFINITYGREENCREATURES) && etype.find("cre") != string::npos)
|
||||
)
|
||||
{
|
||||
if (c->getManaCost()->getConvertedCost() > 0)
|
||||
{
|
||||
@@ -1839,9 +1873,15 @@ int MTGAffinityRule::receiveEvent(WEvent * event)
|
||||
}//--end of redux bracket ok == 2
|
||||
//---------
|
||||
ok = 0;
|
||||
if (e->to == p->game->graveyard || e->to == p->game->hand || e->to == p->game->library || e->to == p->game->exile
|
||||
|| e->to == p->game->stack || e->to == p->opponent()->game->battlefield)
|
||||
if (e->to == p->game->graveyard
|
||||
|| e->to == p->game->hand
|
||||
|| e->to == p->game->library
|
||||
|| e->to == p->game->exile
|
||||
|| e->to == p->game->stack
|
||||
|| e->to == p->opponent()->game->battlefield
|
||||
)
|
||||
ok = 3;//card leaves play
|
||||
|
||||
if (ok == 3)
|
||||
{//leave play from your battlefield
|
||||
if (e->from == p->game->battlefield)
|
||||
@@ -1883,13 +1923,14 @@ int MTGAffinityRule::receiveEvent(WEvent * event)
|
||||
for (int j = 0; j < nbcards; ++j)
|
||||
{
|
||||
MTGCardInstance * c = z->cards[j];
|
||||
if (c && ((c->has(Constants::AFFINITYARTIFACTS) && etype.find("art") != string::npos) || (c->has(
|
||||
Constants::AFFINITYSWAMP) && etype.find("swa") != string::npos) || (c->has(
|
||||
Constants::AFFINITYMOUNTAIN) && etype.find("mou") != string::npos) || (c->has(
|
||||
Constants::AFFINITYPLAINS) && etype.find("pla") != string::npos) || (c->has(
|
||||
Constants::AFFINITYISLAND) && etype.find("isl") != string::npos) || (c->has(
|
||||
Constants::AFFINITYFOREST) && etype.find("for") != string::npos) || (c->has(
|
||||
Constants::AFFINITYGREENCREATURES) && etype.find("cre") != string::npos)))
|
||||
if (c && ((c->has(Constants::AFFINITYARTIFACTS) && etype.find("art") != string::npos)
|
||||
|| (c->has(Constants::AFFINITYSWAMP) && etype.find("swa") != string::npos)
|
||||
|| (c->has(Constants::AFFINITYMOUNTAIN) && etype.find("mou") != string::npos)
|
||||
|| (c->has(Constants::AFFINITYPLAINS) && etype.find("pla") != string::npos)
|
||||
|| (c->has(Constants::AFFINITYISLAND) && etype.find("isl") != string::npos)
|
||||
|| (c->has(Constants::AFFINITYFOREST) && etype.find("for") != string::npos)
|
||||
|| (c->has(Constants::AFFINITYGREENCREATURES) && etype.find("cre") != string::npos))
|
||||
)
|
||||
{
|
||||
if (c->reduxamount > 0)
|
||||
{
|
||||
@@ -1911,21 +1952,25 @@ int MTGAffinityRule::receiveEvent(WEvent * event)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ostream& MTGAffinityRule::toString(ostream& out) const
|
||||
{
|
||||
out << "MTGAffinityRule ::: (";
|
||||
return MTGAbility::toString(out) << ")";
|
||||
}
|
||||
|
||||
int MTGAffinityRule::testDestroy()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MTGAffinityRule * MTGAffinityRule::clone() const
|
||||
{
|
||||
MTGAffinityRule * a = NEW MTGAffinityRule(*this);
|
||||
a->isClone = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
MTGTokensCleanup::MTGTokensCleanup(int _id) :
|
||||
|
||||
Reference in New Issue
Block a user