Erwan
- refactor of MTGRules.cpp (buyback/flashback/retrace/alternative). This change has been reviewed by myself, Wil, and Mike. The test suite passes. More cleanup can be done, I will work on that later on.
This commit is contained in:
@@ -45,8 +45,7 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
|
|||||||
Pos* view;
|
Pos* view;
|
||||||
int X;
|
int X;
|
||||||
int XX;
|
int XX;
|
||||||
int boughtback;
|
int alternateCostPaid[ManaCost::MANA_PAID_WITH_RETRACE + 1];
|
||||||
int flashedback;
|
|
||||||
int paymenttype;
|
int paymenttype;
|
||||||
int frozen;
|
int frozen;
|
||||||
int sunburst;
|
int sunburst;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "Counters.h"
|
#include "Counters.h"
|
||||||
#include "WEvent.h"
|
#include "WEvent.h"
|
||||||
#include "CardSelector.h"
|
#include "CardSelector.h"
|
||||||
|
#include "ManaCost.h"
|
||||||
|
|
||||||
class OtherAbilitiesEventReceiver: public MTGAbility
|
class OtherAbilitiesEventReceiver: public MTGAbility
|
||||||
{
|
{
|
||||||
@@ -37,7 +38,11 @@ class MTGAlternativeCostRule: public MTGAbility
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||||
|
int isReactingToClick(MTGCardInstance * card, ManaCost * mana, ManaCost *alternateManaCost);
|
||||||
|
|
||||||
|
int reactToClick(MTGCardInstance * card, ManaCost * alternateManaCost, int paymentType = ManaCost::MANA_PAID);
|
||||||
int reactToClick(MTGCardInstance * card);
|
int reactToClick(MTGCardInstance * card);
|
||||||
|
|
||||||
int testDestroy();
|
int testDestroy();
|
||||||
virtual ostream& toString(ostream& out) const;
|
virtual ostream& toString(ostream& out) const;
|
||||||
MTGAlternativeCostRule(int _id);
|
MTGAlternativeCostRule(int _id);
|
||||||
@@ -48,7 +53,7 @@ public:
|
|||||||
virtual MTGAlternativeCostRule * clone() const;
|
virtual MTGAlternativeCostRule * clone() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MTGBuyBackRule: public MTGAbility
|
class MTGBuyBackRule: public MTGAlternativeCostRule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||||
@@ -63,7 +68,7 @@ public:
|
|||||||
virtual MTGBuyBackRule * clone() const;
|
virtual MTGBuyBackRule * clone() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MTGFlashBackRule: public MTGAbility
|
class MTGFlashBackRule: public MTGAlternativeCostRule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||||
@@ -78,7 +83,7 @@ public:
|
|||||||
virtual MTGFlashBackRule * clone() const;
|
virtual MTGFlashBackRule * clone() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MTGRetraceRule: public MTGAbility
|
class MTGRetraceRule: public MTGAlternativeCostRule
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class ManaCost{
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
enum{
|
enum{
|
||||||
|
MANA_UNPAID = 0,
|
||||||
MANA_PAID = 1,
|
MANA_PAID = 1,
|
||||||
MANA_PAID_WITH_KICKER = 2,
|
MANA_PAID_WITH_KICKER = 2,
|
||||||
MANA_PAID_WITH_ALTERNATIVE = 3,
|
MANA_PAID_WITH_ALTERNATIVE = 3,
|
||||||
|
|||||||
@@ -2827,11 +2827,11 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
|
|||||||
if (card->hasType("instant") || card->hasType("sorcery"))
|
if (card->hasType("instant") || card->hasType("sorcery"))
|
||||||
{
|
{
|
||||||
MTGPlayerCards * zones = card->controller()->game;
|
MTGPlayerCards * zones = card->controller()->game;
|
||||||
if (card->boughtback > 0)
|
if (card->alternateCostPaid[ManaCost::MANA_PAID_WITH_BUYBACK] > 0)
|
||||||
{
|
{
|
||||||
zones->putInZone(card, zones->stack, zones->hand);
|
zones->putInZone(card, zones->stack, zones->hand);
|
||||||
}
|
}
|
||||||
else if (card->flashedback > 0)
|
else if (card->alternateCostPaid[ManaCost::MANA_PAID_WITH_FLASHBACK] > 0)
|
||||||
{
|
{
|
||||||
zones->putInZone(card, zones->stack, zones->exile);
|
zones->putInZone(card, zones->stack, zones->exile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,8 +122,10 @@ void MTGCardInstance::initMTGCI()
|
|||||||
notblocked = 0;
|
notblocked = 0;
|
||||||
sunburst = NULL;
|
sunburst = NULL;
|
||||||
equipment = NULL;
|
equipment = NULL;
|
||||||
boughtback = 0;
|
|
||||||
flashedback = 0;
|
for (int i = 0; i < ManaCost::MANA_PAID_WITH_RETRACE +1; i++)
|
||||||
|
alternateCostPaid[i] = 0;
|
||||||
|
|
||||||
paymenttype = MTGAbility::PUT_INTO_PLAY;
|
paymenttype = MTGAbility::PUT_INTO_PLAY;
|
||||||
reduxamount = 0;
|
reduxamount = 0;
|
||||||
summoningSickness = 1;
|
summoningSickness = 1;
|
||||||
|
|||||||
+183
-583
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user