Coded the initiative ability from CLB set, added some condition to test if a card has been casted from exile or sideboard or commandzone.
This commit is contained in:
@@ -607,6 +607,35 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TrplayerInitiative: public Trigger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool thiscontroller, thisopponent;
|
||||||
|
TrplayerInitiative(GameObserver* observer, int id, MTGCardInstance * source, TargetChooser * tc, bool once = false, bool thiscontroller = false, bool thisopponent = false) :
|
||||||
|
Trigger(observer, id, source, once, tc), thiscontroller(thiscontroller), thisopponent(thisopponent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int triggerOnEventImpl(WEvent * event)
|
||||||
|
{
|
||||||
|
WEventplayerInitiative * e = dynamic_cast<WEventplayerInitiative *> (event);
|
||||||
|
if (!e) return 0;
|
||||||
|
if (!tc->canTarget(e->player)) return 0;
|
||||||
|
if(thiscontroller)
|
||||||
|
if(e->player != source->controller())
|
||||||
|
return 0;
|
||||||
|
if(thisopponent)
|
||||||
|
if(e->player == source->controller())
|
||||||
|
return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TrplayerInitiative * clone() const
|
||||||
|
{
|
||||||
|
return NEW TrplayerInitiative(*this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class TrplayerShuffled: public Trigger
|
class TrplayerShuffled: public Trigger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -4367,6 +4396,18 @@ public:
|
|||||||
AAAlterMonarch * clone() const;
|
AAAlterMonarch * clone() const;
|
||||||
~AAAlterMonarch();
|
~AAAlterMonarch();
|
||||||
};
|
};
|
||||||
|
//Initiative
|
||||||
|
class AAAlterInitiative: public ActivatedAbilityTP
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
AAAlterInitiative(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, ManaCost * _cost = NULL,
|
||||||
|
int who = TargetChooser::UNSET);
|
||||||
|
int resolve();
|
||||||
|
const string getMenuText();
|
||||||
|
AAAlterInitiative * clone() const;
|
||||||
|
~AAAlterInitiative();
|
||||||
|
};
|
||||||
//Surveil Offset
|
//Surveil Offset
|
||||||
class AAAlterSurveilOffset: public ActivatedAbilityTP
|
class AAAlterSurveilOffset: public ActivatedAbilityTP
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
int dungeonCompleted;
|
int dungeonCompleted;
|
||||||
int numOfCommandCast;
|
int numOfCommandCast;
|
||||||
int monarch;
|
int monarch;
|
||||||
|
int initiative;
|
||||||
int surveilOffset;
|
int surveilOffset;
|
||||||
int devotionOffset;
|
int devotionOffset;
|
||||||
int lastShuffleTurn;
|
int lastShuffleTurn;
|
||||||
|
|||||||
@@ -385,6 +385,14 @@ struct WEventplayerMonarch : public WEvent {
|
|||||||
virtual Targetable * getTarget(Player * player);
|
virtual Targetable * getTarget(Player * player);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//initiative event
|
||||||
|
struct WEventplayerInitiative : public WEvent {
|
||||||
|
WEventplayerInitiative(Player * player);
|
||||||
|
Player * player;
|
||||||
|
using WEvent::getTarget;
|
||||||
|
virtual Targetable * getTarget(Player * player);
|
||||||
|
};
|
||||||
|
|
||||||
//shuffle event
|
//shuffle event
|
||||||
struct WEventplayerShuffled : public WEvent {
|
struct WEventplayerShuffled : public WEvent {
|
||||||
WEventplayerShuffled(Player * player);
|
WEventplayerShuffled(Player * player);
|
||||||
|
|||||||
@@ -1370,6 +1370,46 @@ AAAlterMonarch::~AAAlterMonarch()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//AA Initiative
|
||||||
|
AAAlterInitiative::AAAlterInitiative(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, ManaCost * _cost,
|
||||||
|
int who) :
|
||||||
|
ActivatedAbilityTP(observer, _id, _source, _target, _cost, who)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int AAAlterInitiative::resolve()
|
||||||
|
{
|
||||||
|
Damageable * _target = (Damageable *) getTarget();
|
||||||
|
if (_target)
|
||||||
|
{
|
||||||
|
Player * pTarget = (Player*)_target;
|
||||||
|
if(pTarget)
|
||||||
|
{
|
||||||
|
if(!pTarget->initiative){
|
||||||
|
pTarget->initiative = 1;
|
||||||
|
pTarget->opponent()->initiative = 0;
|
||||||
|
WEvent * e = NEW WEventplayerInitiative(pTarget);
|
||||||
|
game->receiveEvent(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const string AAAlterInitiative::getMenuText()
|
||||||
|
{
|
||||||
|
return _("A player takes the Initiative").c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
AAAlterInitiative * AAAlterInitiative::clone() const
|
||||||
|
{
|
||||||
|
return NEW AAAlterInitiative(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
AAAlterInitiative::~AAAlterInitiative()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
//AA Energy Counters
|
//AA Energy Counters
|
||||||
AAAlterEnergy::AAAlterEnergy(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, int energy, ManaCost * _cost,
|
AAAlterEnergy::AAAlterEnergy(GameObserver* observer, int _id, MTGCardInstance * _source, Targetable * _target, int energy, ManaCost * _cost,
|
||||||
int who) :
|
int who) :
|
||||||
|
|||||||
@@ -344,6 +344,51 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
|
|||||||
if(!count)
|
if(!count)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
check = restriction[i].find("exilecast");
|
||||||
|
if(check != string::npos)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for(unsigned int k = 0; k < player->game->stack->cardsSeenThisTurn.size(); k++)
|
||||||
|
{
|
||||||
|
MTGCardInstance * stackCard = player->game->stack->cardsSeenThisTurn[k];
|
||||||
|
if(stackCard->next && stackCard->next == card && (card->previousZone == card->controller()->game->exile||card->previousZone == card->controller()->opponent()->game->exile))
|
||||||
|
count++;
|
||||||
|
if(stackCard == card && (card->previousZone == card->controller()->game->exile||card->previousZone == card->controller()->opponent()->game->exile))
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if(!count)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
check = restriction[i].find("sidecast");
|
||||||
|
if(check != string::npos)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for(unsigned int k = 0; k < player->game->stack->cardsSeenThisTurn.size(); k++)
|
||||||
|
{
|
||||||
|
MTGCardInstance * stackCard = player->game->stack->cardsSeenThisTurn[k];
|
||||||
|
if(stackCard->next && stackCard->next == card && (card->previousZone == card->controller()->game->sideboard||card->previousZone == card->controller()->opponent()->game->sideboard))
|
||||||
|
count++;
|
||||||
|
if(stackCard == card && (card->previousZone == card->controller()->game->sideboard||card->previousZone == card->controller()->opponent()->game->sideboard))
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if(!count)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
check = restriction[i].find("commandzonecast");
|
||||||
|
if(check != string::npos)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for(unsigned int k = 0; k < player->game->stack->cardsSeenThisTurn.size(); k++)
|
||||||
|
{
|
||||||
|
MTGCardInstance * stackCard = player->game->stack->cardsSeenThisTurn[k];
|
||||||
|
if(stackCard->next && stackCard->next == card && (card->previousZone == card->controller()->game->commandzone||card->previousZone == card->controller()->opponent()->game->commandzone))
|
||||||
|
count++;
|
||||||
|
if(stackCard == card && (card->previousZone == card->controller()->game->commandzone||card->previousZone == card->controller()->opponent()->game->commandzone))
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if(!count)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
check = restriction[i].find("rebound");
|
check = restriction[i].find("rebound");
|
||||||
if(check != string::npos)
|
if(check != string::npos)
|
||||||
{
|
{
|
||||||
@@ -1275,6 +1320,14 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
|
|||||||
if (TargetChooser * tc = parseSimpleTC(s, "becomesmonarchfoeof", card))
|
if (TargetChooser * tc = parseSimpleTC(s, "becomesmonarchfoeof", card))
|
||||||
return NEW TrplayerMonarch(observer, id, card, tc, once, false, true);
|
return NEW TrplayerMonarch(observer, id, card, tc, once, false, true);
|
||||||
|
|
||||||
|
//takes the initiative - controller of card
|
||||||
|
if (TargetChooser * tc = parseSimpleTC(s, "takesinitiativeof", card))
|
||||||
|
return NEW TrplayerInitiative(observer, id, card, tc, once, true, false);
|
||||||
|
|
||||||
|
//takes the initiative - opponent of card controller
|
||||||
|
if (TargetChooser * tc = parseSimpleTC(s, "takesinitiativefoeof", card))
|
||||||
|
return NEW TrplayerInitiative(observer, id, card, tc, once, false, true);
|
||||||
|
|
||||||
//shuffled library - controller of card
|
//shuffled library - controller of card
|
||||||
if (TargetChooser * tc = parseSimpleTC(s, "shuffledof", card))
|
if (TargetChooser * tc = parseSimpleTC(s, "shuffledof", card))
|
||||||
return NEW TrplayerShuffled(observer, id, card, tc, once, true, false);
|
return NEW TrplayerShuffled(observer, id, card, tc, once, true, false);
|
||||||
@@ -3912,6 +3965,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//takes the initiative
|
||||||
|
vector<string> splitInitiative = parseBetween(s, "takesinitiative", " ", false);
|
||||||
|
if (splitInitiative.size())
|
||||||
|
{
|
||||||
|
Targetable * t = spell ? spell->getNextTarget() : NULL;
|
||||||
|
MTGAbility * a = NEW AAAlterInitiative(observer, id, card, t, NULL, who);
|
||||||
|
a->oneShot = 1;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
//alter mutation counter on target card with trigger activation
|
//alter mutation counter on target card with trigger activation
|
||||||
vector<string> splitMutated = parseBetween(s, "altermutationcounter:", " ", false);
|
vector<string> splitMutated = parseBetween(s, "altermutationcounter:", " ", false);
|
||||||
if (splitMutated.size())
|
if (splitMutated.size())
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ Player::Player(GameObserver *observer, string file, string fileSmall, MTGDeck *
|
|||||||
dungeonCompleted = 0;
|
dungeonCompleted = 0;
|
||||||
numOfCommandCast = 0;
|
numOfCommandCast = 0;
|
||||||
monarch = 0;
|
monarch = 0;
|
||||||
|
initiative = 0;
|
||||||
surveilOffset = 0;
|
surveilOffset = 0;
|
||||||
devotionOffset = 0;
|
devotionOffset = 0;
|
||||||
lastShuffleTurn = -1;
|
lastShuffleTurn = -1;
|
||||||
|
|||||||
@@ -666,6 +666,7 @@ void Rules::initGame(GameObserver *g, bool currentPlayerSet)
|
|||||||
p->dungeonCompleted = initState.playerData[i].player->dungeonCompleted;
|
p->dungeonCompleted = initState.playerData[i].player->dungeonCompleted;
|
||||||
p->numOfCommandCast = initState.playerData[i].player->numOfCommandCast;
|
p->numOfCommandCast = initState.playerData[i].player->numOfCommandCast;
|
||||||
p->monarch = initState.playerData[i].player->monarch;
|
p->monarch = initState.playerData[i].player->monarch;
|
||||||
|
p->initiative = initState.playerData[i].player->initiative;
|
||||||
p->surveilOffset = initState.playerData[i].player->surveilOffset;
|
p->surveilOffset = initState.playerData[i].player->surveilOffset;
|
||||||
p->devotionOffset = initState.playerData[i].player->devotionOffset;
|
p->devotionOffset = initState.playerData[i].player->devotionOffset;
|
||||||
p->lastChosenName = initState.playerData[i].player->lastChosenName;
|
p->lastChosenName = initState.playerData[i].player->lastChosenName;
|
||||||
|
|||||||
@@ -307,6 +307,11 @@ WEventplayerMonarch::WEventplayerMonarch(Player * player) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WEventplayerInitiative::WEventplayerInitiative(Player * player) :
|
||||||
|
player(player)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
WEventplayerShuffled::WEventplayerShuffled(Player * player) :
|
WEventplayerShuffled::WEventplayerShuffled(Player * player) :
|
||||||
player(player)
|
player(player)
|
||||||
{
|
{
|
||||||
@@ -663,6 +668,12 @@ Targetable * WEventplayerMonarch::getTarget(Player * player)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Targetable * WEventplayerInitiative::getTarget(Player * player)
|
||||||
|
{
|
||||||
|
if (player) return player;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Targetable * WEventplayerShuffled::getTarget(Player * player)
|
Targetable * WEventplayerShuffled::getTarget(Player * player)
|
||||||
{
|
{
|
||||||
if (player) return player;
|
if (player) return player;
|
||||||
|
|||||||
@@ -1373,6 +1373,10 @@ void WParsedInt::extendedParse(string s, Spell * spell, MTGCardInstance * card)
|
|||||||
{
|
{
|
||||||
intValue = (s == "pdungeoncompleted")?card->controller()->dungeonCompleted:card->controller()->opponent()->dungeonCompleted;
|
intValue = (s == "pdungeoncompleted")?card->controller()->dungeonCompleted:card->controller()->opponent()->dungeonCompleted;
|
||||||
}
|
}
|
||||||
|
else if (s == "pinitiative" || s == "oinitiative") // Which player has the initiative
|
||||||
|
{
|
||||||
|
intValue = (s == "pinitiative")?card->controller()->initiative:card->controller()->opponent()->initiative;
|
||||||
|
}
|
||||||
else if (s == "pwrtotatt" || s == "thstotatt")//count Total Power or toughness of attacking creatures (e.g. Battle Cry Goblin)
|
else if (s == "pwrtotatt" || s == "thstotatt")//count Total Power or toughness of attacking creatures (e.g. Battle Cry Goblin)
|
||||||
{
|
{
|
||||||
intValue = 0;
|
intValue = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user