Erwan
- fixed issue 595 (MaxCast not working). Root cause was the stupidest typo ever in the code (maxCost instead of maxCast...) - fixed an issue with Storm mentioned by zethfox (was counting only spells played by current player) - Moved "max lands per turn" rule outside of the code (yay!) Please be sure to update your Rules folder!
This commit is contained in:
@@ -1469,7 +1469,7 @@ public:
|
||||
abilitygranted = ability;
|
||||
nbTargets = 0;
|
||||
tc = _tc;
|
||||
if (!tc) tc = NEW CreatureTargetChooser(_source);
|
||||
if (!tc) tc = NEW TypeTargetChooser("creature",_source);
|
||||
}
|
||||
|
||||
void Update(float dt)
|
||||
@@ -4738,7 +4738,7 @@ public:
|
||||
counter = NEW TypeTargetChooser("land");
|
||||
landsPlayedThisTurn = source->controller()->game->inPlay->seenThisTurn(counter);
|
||||
PlayRestrictions * restrictions = source->controller()->game->playRestrictions;
|
||||
landsRestriction = (MaxPerTurnRestriction *) (restrictions->getRestrictionById(PlayRestriction::LANDS_RULE_ID));
|
||||
landsRestriction = restrictions->getMaxPerTurnRestrictionByTargetChooser(counter);
|
||||
restrictions->removeRestriction(landsRestriction);
|
||||
|
||||
}
|
||||
@@ -4773,7 +4773,7 @@ public:
|
||||
int destroy()
|
||||
{
|
||||
PlayRestrictions * restrictions = source->controller()->game->playRestrictions;
|
||||
if(restrictions->getRestrictionById(PlayRestriction::LANDS_RULE_ID))
|
||||
if(restrictions->getMaxPerTurnRestrictionByTargetChooser(counter))
|
||||
return 1;
|
||||
|
||||
restrictions->addRestriction(landsRestriction);
|
||||
@@ -5590,7 +5590,7 @@ class AMinionofLeshrac: public TargetAbility
|
||||
public:
|
||||
int paidThisTurn;
|
||||
AMinionofLeshrac(int _id, MTGCardInstance * source) :
|
||||
TargetAbility(_id, source, NEW CreatureTargetChooser(), 0, 1, 0)
|
||||
TargetAbility(_id, source, NEW TypeTargetChooser("creature"), 0, 1, 0)
|
||||
{
|
||||
paidThisTurn = 1;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,6 @@ class PlayRestriction
|
||||
{
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
LANDS_RULE_ID,
|
||||
UNDEF_ID
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -23,12 +18,11 @@ public:
|
||||
NO_OPINION
|
||||
};
|
||||
|
||||
unsigned int id;
|
||||
TargetChooser * tc;
|
||||
|
||||
virtual int canPutIntoZone(MTGCardInstance * card, MTGGameZone * destZone) = 0;
|
||||
|
||||
PlayRestriction(unsigned int id, TargetChooser * tc);
|
||||
PlayRestriction(TargetChooser * tc);
|
||||
~PlayRestriction();
|
||||
};
|
||||
|
||||
@@ -41,7 +35,7 @@ public:
|
||||
};
|
||||
int maxPerTurn;
|
||||
MTGGameZone * zone;
|
||||
MaxPerTurnRestriction(unsigned int id, TargetChooser * tc, int maxPerTurn, MTGGameZone * zone);
|
||||
MaxPerTurnRestriction(TargetChooser * tc, int maxPerTurn, MTGGameZone * zone);
|
||||
int canPutIntoZone(MTGCardInstance * card, MTGGameZone * destZone);
|
||||
};
|
||||
|
||||
@@ -51,7 +45,8 @@ class PlayRestrictions
|
||||
protected:
|
||||
vector<PlayRestriction *>restrictions;
|
||||
public:
|
||||
PlayRestriction * getRestrictionById(unsigned int id);
|
||||
MaxPerTurnRestriction * getMaxPerTurnRestrictionByTargetChooser(TargetChooser * tc);
|
||||
|
||||
void addRestriction(PlayRestriction * restriction);
|
||||
void removeRestriction(PlayRestriction * restriction);
|
||||
int canPutIntoZone(MTGCardInstance * card, MTGGameZone * destZone);
|
||||
|
||||
@@ -56,6 +56,11 @@ public:
|
||||
int targetsReadyCheck();
|
||||
virtual int addTarget(Targetable * target);
|
||||
virtual bool canTarget(Targetable * _target);
|
||||
|
||||
//returns true if tc is equivalent to this TargetChooser
|
||||
//Two targetchoosers are equivalent if they target exactly the same cards
|
||||
virtual bool equals(TargetChooser * tc);
|
||||
|
||||
virtual int full()
|
||||
{
|
||||
if (maxtargets != -1 && cursor >= maxtargets)
|
||||
@@ -100,6 +105,7 @@ public:
|
||||
virtual bool canTarget(Targetable * _card);
|
||||
int setAllZones();
|
||||
virtual TargetZoneChooser * clone() const;
|
||||
virtual bool equals(TargetChooser * tc);
|
||||
};
|
||||
|
||||
class CardTargetChooser: public TargetZoneChooser
|
||||
@@ -110,43 +116,7 @@ public:
|
||||
CardTargetChooser(MTGCardInstance * card, MTGCardInstance * source, int * zones = NULL, int nbzones = 0);
|
||||
virtual bool canTarget(Targetable * target);
|
||||
virtual CardTargetChooser * clone() const;
|
||||
};
|
||||
|
||||
class CreatureTargetChooser: public TargetZoneChooser
|
||||
{
|
||||
public:
|
||||
CreatureTargetChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
|
||||
CreatureTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false);
|
||||
virtual bool canTarget(Targetable * _card);
|
||||
virtual CreatureTargetChooser * clone() const;
|
||||
|
||||
};
|
||||
|
||||
class DamageableTargetChooser: public CreatureTargetChooser
|
||||
{
|
||||
public:
|
||||
DamageableTargetChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false) :
|
||||
CreatureTargetChooser(_zones, _nbzones, card, _maxtargets, other)
|
||||
{
|
||||
}
|
||||
;
|
||||
DamageableTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false) :
|
||||
CreatureTargetChooser(card, _maxtargets, other)
|
||||
{
|
||||
}
|
||||
;
|
||||
virtual bool canTarget(Targetable * target);
|
||||
virtual DamageableTargetChooser * clone() const;
|
||||
};
|
||||
|
||||
class PlayerTargetChooser: public TargetChooser
|
||||
{
|
||||
protected:
|
||||
Player * p; //In Case we can only target a specific player
|
||||
public:
|
||||
PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, Player *_p = NULL);
|
||||
virtual bool canTarget(Targetable * target);
|
||||
virtual PlayerTargetChooser * clone() const;
|
||||
virtual bool equals(TargetChooser * tc);
|
||||
};
|
||||
|
||||
class TypeTargetChooser: public TargetZoneChooser
|
||||
@@ -160,6 +130,36 @@ public:
|
||||
void addType(const char * type);
|
||||
virtual bool canTarget(Targetable * target);
|
||||
virtual TypeTargetChooser * clone() const;
|
||||
virtual bool equals(TargetChooser * tc);
|
||||
};
|
||||
|
||||
class DamageableTargetChooser: public TypeTargetChooser
|
||||
{
|
||||
public:
|
||||
DamageableTargetChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false) :
|
||||
TypeTargetChooser("creature",_zones, _nbzones, card, _maxtargets, other)
|
||||
{
|
||||
}
|
||||
;
|
||||
DamageableTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, bool other = false) :
|
||||
TypeTargetChooser("creature", card, _maxtargets, other)
|
||||
{
|
||||
}
|
||||
;
|
||||
virtual bool canTarget(Targetable * target);
|
||||
virtual DamageableTargetChooser * clone() const;
|
||||
virtual bool equals(TargetChooser * tc);
|
||||
};
|
||||
|
||||
class PlayerTargetChooser: public TargetChooser
|
||||
{
|
||||
protected:
|
||||
Player * p; //In Case we can only target a specific player
|
||||
public:
|
||||
PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, Player *_p = NULL);
|
||||
virtual bool canTarget(Targetable * target);
|
||||
virtual PlayerTargetChooser * clone() const;
|
||||
virtual bool equals(TargetChooser * tc);
|
||||
};
|
||||
|
||||
class DescriptorTargetChooser: public TargetZoneChooser
|
||||
@@ -171,6 +171,7 @@ public:
|
||||
virtual bool canTarget(Targetable * target);
|
||||
~DescriptorTargetChooser();
|
||||
virtual DescriptorTargetChooser * clone() const;
|
||||
virtual bool equals(TargetChooser * tc);
|
||||
};
|
||||
|
||||
class SpellTargetChooser: public TargetChooser
|
||||
@@ -180,6 +181,7 @@ public:
|
||||
SpellTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, bool other = false);
|
||||
virtual bool canTarget(Targetable * target);
|
||||
virtual SpellTargetChooser * clone() const;
|
||||
virtual bool equals(TargetChooser * tc);
|
||||
};
|
||||
|
||||
class SpellOrPermanentTargetChooser: public TargetZoneChooser
|
||||
@@ -189,6 +191,7 @@ public:
|
||||
SpellOrPermanentTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, bool other = false);
|
||||
virtual bool canTarget(Targetable * target);
|
||||
virtual SpellOrPermanentTargetChooser * clone() const;
|
||||
virtual bool equals(TargetChooser * tc);
|
||||
};
|
||||
|
||||
class DamageTargetChooser: public TargetChooser
|
||||
@@ -199,6 +202,7 @@ public:
|
||||
DamageTargetChooser(MTGCardInstance * card = NULL, int _color = -1, int _maxtargets = 1, int state = NOT_RESOLVED);
|
||||
virtual bool canTarget(Targetable * target);
|
||||
virtual DamageTargetChooser * clone() const;
|
||||
virtual bool equals(TargetChooser * tc);
|
||||
};
|
||||
|
||||
//Should only be used for triggered abilities.
|
||||
@@ -211,6 +215,7 @@ public:
|
||||
virtual bool targetsZone(MTGGameZone * z);
|
||||
virtual bool canTarget(Targetable * _target);
|
||||
virtual TriggerTargetChooser * clone() const;
|
||||
virtual bool equals(TargetChooser * tc);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user