autoformatted the spaces in MTGRules.cpp since i pretty much made it look like a mess..very pretty now :D

This commit is contained in:
omegablast2002@yahoo.com
2010-09-24 20:04:19 +00:00
parent 75c0733a38
commit e94d39e115
+161 -161
View File
@@ -11,7 +11,7 @@ MTGPutInPlayRule::MTGPutInPlayRule(int _id):MTGAbility(_id, NULL){
} }
int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){
int cardsinhand = game->players[0]->game->hand->nb_cards; int cardsinhand = game->players[0]->game->hand->nb_cards;
Player * player = game->currentlyActing(); Player * player = game->currentlyActing();
Player * currentPlayer = game->currentPlayer; Player * currentPlayer = game->currentPlayer;
if (!player->game->hand->hasCard(card)) return 0; if (!player->game->hand->hasCard(card)) return 0;
@@ -58,7 +58,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card){
Player * player = game->currentlyActing(); Player * player = game->currentlyActing();
ManaCost * cost = card->getManaCost(); ManaCost * cost = card->getManaCost();
ManaCost * playerMana = player->getManaPool(); ManaCost * playerMana = player->getManaPool();
//this handles extra cost payments at the moment a card is played. //this handles extra cost payments at the moment a card is played.
if (cost->isExtraPaymentSet()){ if (cost->isExtraPaymentSet()){
if (!game->targetListIsSet(card)){ if (!game->targetListIsSet(card)){
@@ -127,25 +127,25 @@ ostream& MTGPutInPlayRule::toString(ostream& out) const
return MTGAbility::toString(out) << ")"; return MTGAbility::toString(out) << ")";
} }
MTGPutInPlayRule * MTGPutInPlayRule::clone() const{ MTGPutInPlayRule * MTGPutInPlayRule::clone() const{
MTGPutInPlayRule * a = NEW MTGPutInPlayRule(*this); MTGPutInPlayRule * a = NEW MTGPutInPlayRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
//cast from anywhere possible with this?? //cast from anywhere possible with this??
//Alternative cost rules //Alternative cost rules
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
MTGAlternativeCostRule::MTGAlternativeCostRule(int _id):MTGAbility(_id, NULL){ MTGAlternativeCostRule::MTGAlternativeCostRule(int _id):MTGAbility(_id, NULL){
aType=MTGAbility::ALTERNATIVE_COST; aType=MTGAbility::ALTERNATIVE_COST;
} }
int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){
int cardsinhand = game->players[0]->game->hand->nb_cards; int cardsinhand = game->players[0]->game->hand->nb_cards;
Player * player = game->currentlyActing(); Player * player = game->currentlyActing();
Player * currentPlayer = game->currentPlayer; Player * currentPlayer = game->currentPlayer;
if (!player->game->hand->hasCard(card)) return 0; if (!player->game->hand->hasCard(card)) return 0;
@@ -181,7 +181,7 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card){
ManaCost * cost = card->getManaCost(); ManaCost * cost = card->getManaCost();
ManaCost * alternative = card->getManaCost()->alternative; ManaCost * alternative = card->getManaCost()->alternative;
ManaCost * playerMana = player->getManaPool(); ManaCost * playerMana = player->getManaPool();
//this handles extra cost payments at the moment a card is played. //this handles extra cost payments at the moment a card is played.
if(playerMana->canAfford(alternative)){ if(playerMana->canAfford(alternative)){
if (cost->alternative->isExtraPaymentSet()){ if (cost->alternative->isExtraPaymentSet()){
card->paymenttype = 1; card->paymenttype = 1;
@@ -195,16 +195,16 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card){
return 0; return 0;
} }
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool()); ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
int payResult = player->getManaPool()->pay(card->getManaCost()->alternative); int payResult = player->getManaPool()->pay(card->getManaCost()->alternative);
card->getManaCost()->alternative->doPayExtra(); card->getManaCost()->alternative->doPayExtra();
payResult = ManaCost::MANA_PAID_WITH_ALTERNATIVE; payResult = ManaCost::MANA_PAID_WITH_ALTERNATIVE;
//if alternative has a extra payment thats set, this code pays it.the if statement is 100% needed as it would cause a crash on cards that dont have the alternative cost. //if alternative has a extra payment thats set, this code pays it.the if statement is 100% needed as it would cause a crash on cards that dont have the alternative cost.
if(alternative){ if(alternative){
card->getManaCost()->alternative->doPayExtra(); card->getManaCost()->alternative->doPayExtra();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
ManaCost * spellCost = previousManaPool->Diff(player->getManaPool()); ManaCost * spellCost = previousManaPool->Diff(player->getManaPool());
delete previousManaPool; delete previousManaPool;
if (card->hasType("land")){ if (card->hasType("land")){
@@ -258,23 +258,23 @@ ostream& MTGAlternativeCostRule::toString(ostream& out) const
out << "MTGAlternativeCostRule ::: ("; out << "MTGAlternativeCostRule ::: (";
return MTGAbility::toString(out) << ")"; return MTGAbility::toString(out) << ")";
} }
MTGAlternativeCostRule * MTGAlternativeCostRule::clone() const{ MTGAlternativeCostRule * MTGAlternativeCostRule::clone() const{
MTGAlternativeCostRule * a = NEW MTGAlternativeCostRule(*this); MTGAlternativeCostRule * a = NEW MTGAlternativeCostRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//buyback follows its own resolving rules //buyback follows its own resolving rules
MTGBuyBackRule::MTGBuyBackRule(int _id):MTGAbility(_id, NULL){ MTGBuyBackRule::MTGBuyBackRule(int _id):MTGAbility(_id, NULL){
aType=MTGAbility::BUYBACK_COST; aType=MTGAbility::BUYBACK_COST;
} }
int MTGBuyBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){ int MTGBuyBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){
int cardsinhand = game->players[0]->game->hand->nb_cards; int cardsinhand = game->players[0]->game->hand->nb_cards;
Player * player = game->currentlyActing(); Player * player = game->currentlyActing();
Player * currentPlayer = game->currentPlayer; Player * currentPlayer = game->currentPlayer;
if (!player->game->hand->hasCard(card)) return 0; if (!player->game->hand->hasCard(card)) return 0;
@@ -310,7 +310,7 @@ int MTGBuyBackRule::reactToClick(MTGCardInstance * card){
ManaCost * cost = card->getManaCost(); ManaCost * cost = card->getManaCost();
ManaCost * BuyBack = card->getManaCost()->BuyBack; ManaCost * BuyBack = card->getManaCost()->BuyBack;
ManaCost * playerMana = player->getManaPool(); ManaCost * playerMana = player->getManaPool();
//this handles extra cost payments at the moment a card is played. //this handles extra cost payments at the moment a card is played.
if(playerMana->canAfford(BuyBack)){ if(playerMana->canAfford(BuyBack)){
if (cost->BuyBack->isExtraPaymentSet()){ if (cost->BuyBack->isExtraPaymentSet()){
card->paymenttype = 2; card->paymenttype = 2;
@@ -324,16 +324,16 @@ int MTGBuyBackRule::reactToClick(MTGCardInstance * card){
return 0; return 0;
} }
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool()); ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
int payResult = player->getManaPool()->pay(card->getManaCost()->BuyBack); int payResult = player->getManaPool()->pay(card->getManaCost()->BuyBack);
card->getManaCost()->doPayExtra(); card->getManaCost()->doPayExtra();
payResult = ManaCost::MANA_PAID_WITH_BUYBACK; payResult = ManaCost::MANA_PAID_WITH_BUYBACK;
//if BuyBack has a extra payment thats set, this code pays it.the if statement is 100% needed as it would cause a crash on cards that dont have the BuyBack cost. //if BuyBack has a extra payment thats set, this code pays it.the if statement is 100% needed as it would cause a crash on cards that dont have the BuyBack cost.
if(BuyBack){ if(BuyBack){
card->getManaCost()->BuyBack->doPayExtra(); card->getManaCost()->BuyBack->doPayExtra();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
ManaCost * spellCost = previousManaPool->Diff(player->getManaPool()); ManaCost * spellCost = previousManaPool->Diff(player->getManaPool());
card->boughtback = 1; card->boughtback = 1;
delete previousManaPool; delete previousManaPool;
@@ -392,23 +392,23 @@ ostream& MTGBuyBackRule::toString(ostream& out) const
out << "MTGBuyBackRule ::: ("; out << "MTGBuyBackRule ::: (";
return MTGAbility::toString(out) << ")"; return MTGAbility::toString(out) << ")";
} }
MTGBuyBackRule * MTGBuyBackRule::clone() const{ MTGBuyBackRule * MTGBuyBackRule::clone() const{
MTGBuyBackRule * a = NEW MTGBuyBackRule(*this); MTGBuyBackRule * a = NEW MTGBuyBackRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//flashback follows its own resolving rules //flashback follows its own resolving rules
MTGFlashBackRule::MTGFlashBackRule(int _id):MTGAbility(_id, NULL){ MTGFlashBackRule::MTGFlashBackRule(int _id):MTGAbility(_id, NULL){
aType=MTGAbility::FLASHBACK_COST; aType=MTGAbility::FLASHBACK_COST;
} }
int MTGFlashBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){ int MTGFlashBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){
int cardsingraveyard = game->players[0]->game->graveyard->nb_cards; int cardsingraveyard = game->players[0]->game->graveyard->nb_cards;
Player * player = game->currentlyActing(); Player * player = game->currentlyActing();
Player * currentPlayer = game->currentPlayer; Player * currentPlayer = game->currentPlayer;
if (!player->game->graveyard->hasCard(card)) return 0; if (!player->game->graveyard->hasCard(card)) return 0;
@@ -440,7 +440,7 @@ int MTGFlashBackRule::reactToClick(MTGCardInstance * card){
ManaCost * cost = card->getManaCost(); ManaCost * cost = card->getManaCost();
ManaCost * FlashBack = card->getManaCost()->FlashBack; ManaCost * FlashBack = card->getManaCost()->FlashBack;
ManaCost * playerMana = player->getManaPool(); ManaCost * playerMana = player->getManaPool();
//this handles extra cost payments at the moment a card is played. //this handles extra cost payments at the moment a card is played.
if(playerMana->canAfford(FlashBack)){ if(playerMana->canAfford(FlashBack)){
if (cost->FlashBack->isExtraPaymentSet()){ if (cost->FlashBack->isExtraPaymentSet()){
card->paymenttype = 3; card->paymenttype = 3;
@@ -454,16 +454,16 @@ int MTGFlashBackRule::reactToClick(MTGCardInstance * card){
return 0; return 0;
} }
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool()); ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
int payResult = player->getManaPool()->pay(card->getManaCost()->FlashBack); int payResult = player->getManaPool()->pay(card->getManaCost()->FlashBack);
card->getManaCost()->doPayExtra(); card->getManaCost()->doPayExtra();
payResult = ManaCost::MANA_PAID_WITH_FLASHBACK; payResult = ManaCost::MANA_PAID_WITH_FLASHBACK;
//if flashBack has a extra payment thats set, this code pays it.the if statement is 100% needed as it would cause a crash on cards that dont have the flashBack cost. //if flashBack has a extra payment thats set, this code pays it.the if statement is 100% needed as it would cause a crash on cards that dont have the flashBack cost.
if(FlashBack){ if(FlashBack){
card->getManaCost()->FlashBack->doPayExtra(); card->getManaCost()->FlashBack->doPayExtra();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
ManaCost * spellCost = previousManaPool->Diff(player->getManaPool()); ManaCost * spellCost = previousManaPool->Diff(player->getManaPool());
card->flashedback = 1; card->flashedback = 1;
delete previousManaPool; delete previousManaPool;
@@ -522,24 +522,24 @@ ostream& MTGFlashBackRule::toString(ostream& out) const
out << "MTGFlashBackRule ::: ("; out << "MTGFlashBackRule ::: (";
return MTGAbility::toString(out) << ")"; return MTGAbility::toString(out) << ")";
} }
MTGFlashBackRule * MTGFlashBackRule::clone() const{ MTGFlashBackRule * MTGFlashBackRule::clone() const{
MTGFlashBackRule * a = NEW MTGFlashBackRule(*this); MTGFlashBackRule * a = NEW MTGFlashBackRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//retrace //retrace
MTGRetraceRule::MTGRetraceRule(int _id):MTGAbility(_id, NULL){ MTGRetraceRule::MTGRetraceRule(int _id):MTGAbility(_id, NULL){
aType=MTGAbility::RETRACE_COST; aType=MTGAbility::RETRACE_COST;
} }
int MTGRetraceRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){ int MTGRetraceRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){
int cardsingraveyard = game->players[0]->game->graveyard->nb_cards; int cardsingraveyard = game->players[0]->game->graveyard->nb_cards;
Player * player = game->currentlyActing(); Player * player = game->currentlyActing();
Player * currentPlayer = game->currentPlayer; Player * currentPlayer = game->currentPlayer;
if (!player->game->graveyard->hasCard(card)) return 0; if (!player->game->graveyard->hasCard(card)) return 0;
@@ -571,7 +571,7 @@ int MTGRetraceRule::reactToClick(MTGCardInstance * card){
ManaCost * cost = card->getManaCost(); ManaCost * cost = card->getManaCost();
ManaCost * Retrace = card->getManaCost()->Retrace; ManaCost * Retrace = card->getManaCost()->Retrace;
ManaCost * playerMana = player->getManaPool(); ManaCost * playerMana = player->getManaPool();
//this handles extra cost payments at the moment a card is played. //this handles extra cost payments at the moment a card is played.
if(playerMana->canAfford(Retrace)){ if(playerMana->canAfford(Retrace)){
if (cost->Retrace->isExtraPaymentSet()){ if (cost->Retrace->isExtraPaymentSet()){
card->paymenttype = 4; card->paymenttype = 4;
@@ -585,16 +585,16 @@ int MTGRetraceRule::reactToClick(MTGCardInstance * card){
return 0; return 0;
} }
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool()); ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
int payResult = player->getManaPool()->pay(card->getManaCost()->Retrace); int payResult = player->getManaPool()->pay(card->getManaCost()->Retrace);
card->getManaCost()->doPayExtra(); card->getManaCost()->doPayExtra();
payResult = ManaCost::MANA_PAID_WITH_RETRACE; payResult = ManaCost::MANA_PAID_WITH_RETRACE;
//if Retrace has a extra payment thats set, this code pays it.the if statement is 100% needed as it would cause a crash on cards that dont have the Retrace cost. //if Retrace has a extra payment thats set, this code pays it.the if statement is 100% needed as it would cause a crash on cards that dont have the Retrace cost.
if(Retrace){ if(Retrace){
card->getManaCost()->Retrace->doPayExtra(); card->getManaCost()->Retrace->doPayExtra();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
ManaCost * spellCost = previousManaPool->Diff(player->getManaPool()); ManaCost * spellCost = previousManaPool->Diff(player->getManaPool());
delete previousManaPool; delete previousManaPool;
if (card->hasType("land")){ if (card->hasType("land")){
@@ -649,17 +649,17 @@ ostream& MTGRetraceRule::toString(ostream& out) const
out << "MTGRetraceRule ::: ("; out << "MTGRetraceRule ::: (";
return MTGAbility::toString(out) << ")"; return MTGAbility::toString(out) << ")";
} }
MTGRetraceRule * MTGRetraceRule::clone() const{ MTGRetraceRule * MTGRetraceRule::clone() const{
MTGRetraceRule * a = NEW MTGRetraceRule(*this); MTGRetraceRule * a = NEW MTGRetraceRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//----------------------------- //-----------------------------
bool MTGAttackRule::select(Target* t) bool MTGAttackRule::select(Target* t)
{ {
if (CardView* c = dynamic_cast<CardView*>(t)) { if (CardView* c = dynamic_cast<CardView*>(t)) {
@@ -727,11 +727,11 @@ ostream& MTGAttackRule::toString(ostream& out) const
return MTGAbility::toString(out) << ")"; return MTGAbility::toString(out) << ")";
} }
MTGAttackRule * MTGAttackRule::clone() const{ MTGAttackRule * MTGAttackRule::clone() const{
MTGAttackRule * a = NEW MTGAttackRule(*this); MTGAttackRule * a = NEW MTGAttackRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
OtherAbilitiesEventReceiver::OtherAbilitiesEventReceiver(int _id):MTGAbility(_id,NULL){ OtherAbilitiesEventReceiver::OtherAbilitiesEventReceiver(int _id):MTGAbility(_id,NULL){
@@ -757,11 +757,11 @@ int OtherAbilitiesEventReceiver::testDestroy(){
return 0; return 0;
} }
OtherAbilitiesEventReceiver * OtherAbilitiesEventReceiver::clone() const{ OtherAbilitiesEventReceiver * OtherAbilitiesEventReceiver::clone() const{
OtherAbilitiesEventReceiver * a = NEW OtherAbilitiesEventReceiver(*this); OtherAbilitiesEventReceiver * a = NEW OtherAbilitiesEventReceiver(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
MTGBlockRule::MTGBlockRule(int _id):MTGAbility(_id,NULL){ MTGBlockRule::MTGBlockRule(int _id):MTGAbility(_id,NULL){
@@ -806,11 +806,11 @@ ostream& MTGBlockRule::toString(ostream& out) const
return MTGAbility::toString(out) << ")"; return MTGAbility::toString(out) << ")";
} }
MTGBlockRule * MTGBlockRule::clone() const{ MTGBlockRule * MTGBlockRule::clone() const{
MTGBlockRule * a = NEW MTGBlockRule(*this); MTGBlockRule * a = NEW MTGBlockRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
// //
// Attacker chooses blockers order // Attacker chooses blockers order
// //
@@ -938,11 +938,11 @@ ostream& MTGMomirRule::toString(ostream& out) const
} }
MTGMomirRule * MTGMomirRule::clone() const{ MTGMomirRule * MTGMomirRule::clone() const{
MTGMomirRule * a = NEW MTGMomirRule(*this); MTGMomirRule * a = NEW MTGMomirRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
//HUDDisplay //HUDDisplay
int HUDDisplay::testDestroy(){ int HUDDisplay::testDestroy(){
@@ -1034,17 +1034,17 @@ HUDDisplay::~HUDDisplay(){
events.clear(); events.clear();
} }
HUDDisplay * HUDDisplay::clone() const{ HUDDisplay * HUDDisplay::clone() const{
HUDDisplay * a = NEW HUDDisplay(*this); HUDDisplay * a = NEW HUDDisplay(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
/* Persist */ /* Persist */
MTGPersistRule::MTGPersistRule(int _id):MTGAbility(_id,NULL){}; MTGPersistRule::MTGPersistRule(int _id):MTGAbility(_id,NULL){};
int MTGPersistRule::receiveEvent(WEvent * event){ int MTGPersistRule::receiveEvent(WEvent * event){
if (event->type == WEvent::CHANGE_ZONE){ if (event->type == WEvent::CHANGE_ZONE){
WEventZoneChange * e = (WEventZoneChange *) event; WEventZoneChange * e = (WEventZoneChange *) event;
MTGCardInstance * card = e->card->previous; MTGCardInstance * card = e->card->previous;
@@ -1069,23 +1069,23 @@ HUDDisplay::~HUDDisplay(){
} }
} }
return 0; return 0;
} }
ostream& MTGPersistRule::toString(ostream& out) const ostream& MTGPersistRule::toString(ostream& out) const
{ {
out << "MTGPersistRule ::: ("; out << "MTGPersistRule ::: (";
return MTGAbility::toString(out) << ")"; return MTGAbility::toString(out) << ")";
} }
int MTGPersistRule::testDestroy(){return 0;} int MTGPersistRule::testDestroy(){return 0;}
MTGPersistRule * MTGPersistRule::clone() const{ MTGPersistRule * MTGPersistRule::clone() const{
MTGPersistRule * a = NEW MTGPersistRule(*this); MTGPersistRule * a = NEW MTGPersistRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
//putting cards with restricting effects inplay //putting cards with restricting effects inplay
MTGCantCasterstart::MTGCantCasterstart(int _id):MTGAbility(_id,NULL){}; MTGCantCasterstart::MTGCantCasterstart(int _id):MTGAbility(_id,NULL){};
int MTGCantCasterstart::receiveEvent(WEvent * event){ int MTGCantCasterstart::receiveEvent(WEvent * event){
if (event->type == WEvent::CHANGE_ZONE){ if (event->type == WEvent::CHANGE_ZONE){
WEventZoneChange * e = (WEventZoneChange *) event; WEventZoneChange * e = (WEventZoneChange *) event;
MTGCardInstance * card = e->card->previous; MTGCardInstance * card = e->card->previous;
@@ -1141,7 +1141,7 @@ HUDDisplay::~HUDDisplay(){
card->controller()->onlyonecast = 1; card->controller()->onlyonecast = 1;
} }
} }
//any on other side? //any on other side?
for (int j = 0; j < onbcards; ++j){ for (int j = 0; j < onbcards; ++j){
MTGCardInstance * c = y->cards[j]; MTGCardInstance * c = y->cards[j];
if (c->has(Constants::NOMAXHAND)){ if (c->has(Constants::NOMAXHAND)){
@@ -1169,7 +1169,7 @@ HUDDisplay::~HUDDisplay(){
card->controller()->opponent()->castrestrictedspell = 1; card->controller()->opponent()->castrestrictedspell = 1;
} }
} }
//-----if a card with both*restrict* was found then the players are still restricted, if one player is still restricted he stays restricted. //-----if a card with both*restrict* was found then the players are still restricted, if one player is still restricted he stays restricted.
} }
} }
} }
@@ -1177,27 +1177,27 @@ HUDDisplay::~HUDDisplay(){
} }
} }
return 1; return 1;
} }
ostream& MTGCantCasterstart::toString(ostream& out) const ostream& MTGCantCasterstart::toString(ostream& out) const
{ {
out << "MTGCantCasterstart ::: ("; out << "MTGCantCasterstart ::: (";
return MTGAbility::toString(out) << ")"; return MTGAbility::toString(out) << ")";
} }
int MTGCantCasterstart::testDestroy(){return 0;} int MTGCantCasterstart::testDestroy(){return 0;}
MTGCantCasterstart * MTGCantCasterstart::clone() const{ MTGCantCasterstart * MTGCantCasterstart::clone() const{
MTGCantCasterstart * a = NEW MTGCantCasterstart(*this); MTGCantCasterstart * a = NEW MTGCantCasterstart(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
//the end of this very complex code line. //the end of this very complex code line.
//unearth rule---------------------------------- //unearth rule----------------------------------
//if the card leaves play, exile it instead. //if the card leaves play, exile it instead.
MTGUnearthRule::MTGUnearthRule(int _id):MTGAbility(_id,NULL){}; MTGUnearthRule::MTGUnearthRule(int _id):MTGAbility(_id,NULL){};
int MTGUnearthRule::receiveEvent(WEvent * event){ int MTGUnearthRule::receiveEvent(WEvent * event){
if (event->type == WEvent::CHANGE_ZONE){ if (event->type == WEvent::CHANGE_ZONE){
WEventZoneChange * e = (WEventZoneChange *) event; WEventZoneChange * e = (WEventZoneChange *) event;
MTGCardInstance * card = e->card->previous; MTGCardInstance * card = e->card->previous;
@@ -1218,26 +1218,26 @@ HUDDisplay::~HUDDisplay(){
} }
} }
return 0; return 0;
} }
ostream& MTGUnearthRule::toString(ostream& out) const ostream& MTGUnearthRule::toString(ostream& out) const
{ {
out << "MTGUnearthRule ::: ("; out << "MTGUnearthRule ::: (";
return MTGAbility::toString(out) << ")"; return MTGAbility::toString(out) << ")";
} }
int MTGUnearthRule::testDestroy(){return 0;} int MTGUnearthRule::testDestroy(){return 0;}
MTGUnearthRule * MTGUnearthRule::clone() const{ MTGUnearthRule * MTGUnearthRule::clone() const{
MTGUnearthRule * a = NEW MTGUnearthRule(*this); MTGUnearthRule * a = NEW MTGUnearthRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
//sneakattack rule------------------------------------------------------ //sneakattack rule------------------------------------------------------
//this rule also handles the exile of unearth cards at end of turn. //this rule also handles the exile of unearth cards at end of turn.
MTGSneakAttackRule::MTGSneakAttackRule(int _id):MTGAbility(_id,NULL){}; MTGSneakAttackRule::MTGSneakAttackRule(int _id):MTGAbility(_id,NULL){};
int MTGSneakAttackRule::receiveEvent(WEvent *e){ int MTGSneakAttackRule::receiveEvent(WEvent *e){
if (WEventPhaseChange* event = dynamic_cast<WEventPhaseChange*>(e)) { if (WEventPhaseChange* event = dynamic_cast<WEventPhaseChange*>(e)) {
if (Constants::MTG_PHASE_ENDOFTURN == event->from->id) { if (Constants::MTG_PHASE_ENDOFTURN == event->from->id) {
for (int j = 0; j < 2 ; j++){ for (int j = 0; j < 2 ; j++){
@@ -1253,24 +1253,24 @@ HUDDisplay::~HUDDisplay(){
return 1; return 1;
} }
return 1; return 1;
} }
ostream& MTGSneakAttackRule::toString(ostream& out) const ostream& MTGSneakAttackRule::toString(ostream& out) const
{ {
out << "MTGSneakAttackRule ::: ("; out << "MTGSneakAttackRule ::: (";
return MTGAbility::toString(out) << ")"; return MTGAbility::toString(out) << ")";
} }
int MTGSneakAttackRule::testDestroy(){return 0;} int MTGSneakAttackRule::testDestroy(){return 0;}
MTGSneakAttackRule * MTGSneakAttackRule::clone() const{ MTGSneakAttackRule * MTGSneakAttackRule::clone() const{
MTGSneakAttackRule * a = NEW MTGSneakAttackRule(*this); MTGSneakAttackRule * a = NEW MTGSneakAttackRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
//Affinity rule------------------------------------------------------ //Affinity rule------------------------------------------------------
//this rule is for Affinity cards. //this rule is for Affinity cards.
MTGAffinityRule::MTGAffinityRule(int _id):MTGAbility(_id,NULL){}; MTGAffinityRule::MTGAffinityRule(int _id):MTGAbility(_id,NULL){};
int MTGAffinityRule::receiveEvent(WEvent * event){ int MTGAffinityRule::receiveEvent(WEvent * event){
if (event->type == WEvent::CHANGE_ZONE){ if (event->type == WEvent::CHANGE_ZONE){
WEventZoneChange * e = (WEventZoneChange *) event; WEventZoneChange * e = (WEventZoneChange *) event;
MTGCardInstance * card = e->card->previous; MTGCardInstance * card = e->card->previous;
@@ -1283,8 +1283,8 @@ HUDDisplay::~HUDDisplay(){
if (e->to == p->game->hand) ok = 1;//affinity card enters hand if (e->to == p->game->hand) ok = 1;//affinity card enters hand
if (e->to == p->game->battlefield) ok = 2;//card enters play if (e->to == p->game->battlefield) ok = 2;//card enters play
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 (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
//--------- //---------
//when cards with affinity enter you hand from anywhere a redux is applied to them for the artifacts in play. //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(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){ 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){
MTGCardInstance * card = e->card->previous; MTGCardInstance * card = e->card->previous;
@@ -1312,7 +1312,7 @@ HUDDisplay::~HUDDisplay(){
}//--end of redux bracket }//--end of redux bracket
} }
}//if ok == 1 }//if ok == 1
//-------------maintaining cost---------------------------------------------------------------- //-------------maintaining cost----------------------------------------------------------------
if(ok == 2){//enters play from anywhere 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->opponent()->game->battlefield || 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->opponent()->game->battlefield || e->from == p->game->temp){
//--redux effect //--redux effect
@@ -1340,9 +1340,9 @@ HUDDisplay::~HUDDisplay(){
} }
} }
}//--end of redux bracket ok == 2 }//--end of redux bracket ok == 2
//--------- //---------
if(ok == 3){//leave play from your battlefield if(ok == 3){//leave play from your battlefield
if (e->from == p->game->battlefield){ if (e->from == p->game->battlefield){
int colored = 0; int colored = 0;
MTGGameZone * z = card->controller()->game->hand; MTGGameZone * z = card->controller()->game->hand;
int nbcards = z->nb_cards; int nbcards = z->nb_cards;
@@ -1365,35 +1365,35 @@ if (e->from == p->game->battlefield){
} }
} }
} }
//------------------------------- //-------------------------------
} }
}//---ok == 3 }//---ok == 3
//---------------------------------------- //----------------------------------------
} }
} }
return 0; return 0;
} }
return 0; return 0;
} }
ostream& MTGAffinityRule::toString(ostream& out) const ostream& MTGAffinityRule::toString(ostream& out) const
{ {
out << "MTGAffinityRule ::: ("; out << "MTGAffinityRule ::: (";
return MTGAbility::toString(out) << ")"; return MTGAbility::toString(out) << ")";
} }
int MTGAffinityRule::testDestroy(){return 0;} int MTGAffinityRule::testDestroy(){return 0;}
MTGAffinityRule * MTGAffinityRule::clone() const{ MTGAffinityRule * MTGAffinityRule::clone() const{
MTGAffinityRule * a = NEW MTGAffinityRule(*this); MTGAffinityRule * a = NEW MTGAffinityRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
MTGTokensCleanup::MTGTokensCleanup(int _id):MTGAbility(_id, NULL){} MTGTokensCleanup::MTGTokensCleanup(int _id):MTGAbility(_id, NULL){}
int MTGTokensCleanup::receiveEvent(WEvent * e){ int MTGTokensCleanup::receiveEvent(WEvent * e){
if (WEventZoneChange* event = dynamic_cast<WEventZoneChange*>(e)){ if (WEventZoneChange* event = dynamic_cast<WEventZoneChange*>(e)){
if (!event->card->isToken) return 0; if (!event->card->isToken) return 0;
if (event->to == game->players[0]->game->inPlay || event->to == game->players[1]->game->inPlay) return 0; if (event->to == game->players[0]->game->inPlay || event->to == game->players[1]->game->inPlay) return 0;
@@ -1402,36 +1402,36 @@ if (e->from == p->game->battlefield){
return 1; return 1;
} }
return 0; return 0;
} }
int MTGTokensCleanup::testDestroy(){return 0;} int MTGTokensCleanup::testDestroy(){return 0;}
void MTGTokensCleanup::Update(float dt){ void MTGTokensCleanup::Update(float dt){
MTGAbility::Update(dt); MTGAbility::Update(dt);
for(size_t i= 0; i < list.size(); ++i){ for(size_t i= 0; i < list.size(); ++i){
MTGCardInstance * c = list[i]; MTGCardInstance * c = list[i];
c->controller()->game->putInZone(c,c->currentZone, c->controller()->game->garbage); c->controller()->game->putInZone(c,c->currentZone, c->controller()->game->garbage);
} }
list.clear(); list.clear();
} }
MTGTokensCleanup * MTGTokensCleanup::clone() const{ MTGTokensCleanup * MTGTokensCleanup::clone() const{
MTGTokensCleanup * a = NEW MTGTokensCleanup(*this); MTGTokensCleanup * a = NEW MTGTokensCleanup(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
/* Legend Rule */ /* Legend Rule */
MTGLegendRule::MTGLegendRule(int _id):ListMaintainerAbility(_id){}; MTGLegendRule::MTGLegendRule(int _id):ListMaintainerAbility(_id){};
int MTGLegendRule::canBeInList(MTGCardInstance * card){ int MTGLegendRule::canBeInList(MTGCardInstance * card){
if (card->hasType(Subtypes::TYPE_LEGENDARY) && game->isInPlay(card)){ if (card->hasType(Subtypes::TYPE_LEGENDARY) && game->isInPlay(card)){
return 1; return 1;
} }
return 0; return 0;
} }
int MTGLegendRule::added(MTGCardInstance * card){ int MTGLegendRule::added(MTGCardInstance * card){
map<MTGCardInstance *,bool>::iterator it; map<MTGCardInstance *,bool>::iterator it;
int destroy = 0; int destroy = 0;
for ( it=cards.begin() ; it != cards.end(); it++ ){ for ( it=cards.begin() ; it != cards.end(); it++ ){
@@ -1445,26 +1445,26 @@ if (e->from == p->game->battlefield){
card->owner->game->putInGraveyard(card); card->owner->game->putInGraveyard(card);
} }
return 1; return 1;
} }
int MTGLegendRule::removed(MTGCardInstance * card){return 0;} int MTGLegendRule::removed(MTGCardInstance * card){return 0;}
int MTGLegendRule::testDestroy(){return 0;} int MTGLegendRule::testDestroy(){return 0;}
ostream& MTGLegendRule::toString(ostream& out) const ostream& MTGLegendRule::toString(ostream& out) const
{ {
return out << "MTGLegendRule :::"; return out << "MTGLegendRule :::";
} }
MTGLegendRule * MTGLegendRule::clone() const{ MTGLegendRule * MTGLegendRule::clone() const{
MTGLegendRule * a = NEW MTGLegendRule(*this); MTGLegendRule * a = NEW MTGLegendRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
/* Lifelink */ /* Lifelink */
MTGLifelinkRule::MTGLifelinkRule(int _id):MTGAbility(_id,NULL){}; MTGLifelinkRule::MTGLifelinkRule(int _id):MTGAbility(_id,NULL){};
int MTGLifelinkRule::receiveEvent(WEvent * event){ int MTGLifelinkRule::receiveEvent(WEvent * event){
if (event->type == WEvent::DAMAGE){ if (event->type == WEvent::DAMAGE){
WEventDamage * e = (WEventDamage *) event; WEventDamage * e = (WEventDamage *) event;
Damage * d = e->damage; Damage * d = e->damage;
@@ -1475,26 +1475,26 @@ if (e->from == p->game->battlefield){
} }
} }
return 0; return 0;
} }
int MTGLifelinkRule::testDestroy(){return 0;} int MTGLifelinkRule::testDestroy(){return 0;}
ostream& MTGLifelinkRule::toString(ostream& out) const ostream& MTGLifelinkRule::toString(ostream& out) const
{ {
out << "MTGLifelinkRule ::: ("; out << "MTGLifelinkRule ::: (";
return MTGAbility::toString(out) << ")"; return MTGAbility::toString(out) << ")";
} }
MTGLifelinkRule * MTGLifelinkRule::clone() const{ MTGLifelinkRule * MTGLifelinkRule::clone() const{
MTGLifelinkRule * a = NEW MTGLifelinkRule(*this); MTGLifelinkRule * a = NEW MTGLifelinkRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
/* Deathtouch */ /* Deathtouch */
MTGDeathtouchRule::MTGDeathtouchRule(int _id):MTGAbility(_id,NULL){}; MTGDeathtouchRule::MTGDeathtouchRule(int _id):MTGAbility(_id,NULL){};
int MTGDeathtouchRule::receiveEvent(WEvent * event){ int MTGDeathtouchRule::receiveEvent(WEvent * event){
if (event->type == WEvent::DAMAGE){ if (event->type == WEvent::DAMAGE){
WEventDamage * e = (WEventDamage *) event; WEventDamage * e = (WEventDamage *) event;
@@ -1513,13 +1513,13 @@ if (e->from == p->game->battlefield){
} }
} }
return 0; return 0;
} }
int MTGDeathtouchRule::testDestroy(){return 0;} int MTGDeathtouchRule::testDestroy(){return 0;}
MTGDeathtouchRule * MTGDeathtouchRule::clone() const{ MTGDeathtouchRule * MTGDeathtouchRule::clone() const{
MTGDeathtouchRule * a = NEW MTGDeathtouchRule(*this); MTGDeathtouchRule * a = NEW MTGDeathtouchRule(*this);
a->isClone = 1; a->isClone = 1;
return a; return a;
} }