@@ -161,12 +161,14 @@ public:
|
|||||||
MTGCardInstance * defenser;
|
MTGCardInstance * defenser;
|
||||||
list<MTGCardInstance *>blockers;
|
list<MTGCardInstance *>blockers;
|
||||||
int attacker;
|
int attacker;
|
||||||
|
int willattackplayer;
|
||||||
|
int willattackpw;
|
||||||
int toggleDefenser(MTGCardInstance * opponent);
|
int toggleDefenser(MTGCardInstance * opponent);
|
||||||
int raiseBlockerRankOrder(MTGCardInstance * blocker);
|
int raiseBlockerRankOrder(MTGCardInstance * blocker);
|
||||||
|
|
||||||
//Returns rank of the card in blockers if it is a blocker of this (starting at 1), 0 otherwise
|
//Returns rank of the card in blockers if it is a blocker of this (starting at 1), 0 otherwise
|
||||||
int getDefenserRank(MTGCardInstance * blocker);
|
int getDefenserRank(MTGCardInstance * blocker);
|
||||||
int toggleAttacker();
|
int toggleAttacker(bool pw = false);
|
||||||
MTGCardInstance * banding; // If belongs to a band when attacking
|
MTGCardInstance * banding; // If belongs to a band when attacking
|
||||||
int canBlock();
|
int canBlock();
|
||||||
int canBlock(MTGCardInstance * opponent);
|
int canBlock(MTGCardInstance * opponent);
|
||||||
|
|||||||
@@ -270,17 +270,14 @@ public:
|
|||||||
class MTGAttackRule: public PermanentAbility, public Limitor
|
class MTGAttackRule: public PermanentAbility, public Limitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
string attackmenu;
|
||||||
virtual bool select(Target*);
|
virtual bool select(Target*);
|
||||||
virtual bool greyout(Target*);
|
virtual bool greyout(Target*);
|
||||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||||
int reactToClick(MTGCardInstance * card);
|
int reactToClick(MTGCardInstance * card);
|
||||||
virtual ostream& toString(ostream& out) const;
|
virtual ostream& toString(ostream& out) const;
|
||||||
MTGAttackRule(GameObserver* observer, int _id);
|
MTGAttackRule(GameObserver* observer, int _id);
|
||||||
const string getMenuText()
|
const string getMenuText();
|
||||||
{
|
|
||||||
return "Attacker";
|
|
||||||
}
|
|
||||||
int receiveEvent(WEvent * event);
|
int receiveEvent(WEvent * event);
|
||||||
virtual MTGAttackRule * clone() const;
|
virtual MTGAttackRule * clone() const;
|
||||||
};
|
};
|
||||||
@@ -289,16 +286,13 @@ public:
|
|||||||
class MTGPlaneswalkerAttackRule: public PermanentAbility, public Limitor
|
class MTGPlaneswalkerAttackRule: public PermanentAbility, public Limitor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
string attackpwmenu;
|
||||||
virtual bool select(Target*);
|
virtual bool select(Target*);
|
||||||
virtual bool greyout(Target*);
|
virtual bool greyout(Target*);
|
||||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||||
int reactToClick(MTGCardInstance * card);
|
int reactToClick(MTGCardInstance * card);
|
||||||
MTGPlaneswalkerAttackRule(GameObserver* observer, int _id);
|
MTGPlaneswalkerAttackRule(GameObserver* observer, int _id);
|
||||||
const string getMenuText()
|
const string getMenuText();
|
||||||
{
|
|
||||||
return "Attack Planeswalker";
|
|
||||||
}
|
|
||||||
virtual MTGPlaneswalkerAttackRule * clone() const;
|
virtual MTGPlaneswalkerAttackRule * clone() const;
|
||||||
};
|
};
|
||||||
class AAPlaneswalkerAttacked: public InstantAbility
|
class AAPlaneswalkerAttacked: public InstantAbility
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
|
|||||||
initMTGCI();
|
initMTGCI();
|
||||||
model = card;
|
model = card;
|
||||||
attacker = 0;
|
attacker = 0;
|
||||||
|
willattackplayer = 0;
|
||||||
|
willattackpw = 0;
|
||||||
lifeOrig = life;
|
lifeOrig = life;
|
||||||
origpower = power;
|
origpower = power;
|
||||||
basepower = origpower;
|
basepower = origpower;
|
||||||
@@ -1338,17 +1340,27 @@ int MTGCardInstance::setAttacker(int value)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MTGCardInstance::toggleAttacker()
|
int MTGCardInstance::toggleAttacker(bool pw)
|
||||||
{
|
{
|
||||||
if (!attacker)
|
if (!attacker)
|
||||||
{
|
{
|
||||||
//if (!basicAbilities[Constants::VIGILANCE]) tap();
|
//if (!basicAbilities[Constants::VIGILANCE]) tap();
|
||||||
|
if(pw)
|
||||||
|
{
|
||||||
|
willattackpw = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
willattackplayer = 1;
|
||||||
|
}
|
||||||
setAttacker(1);
|
setAttacker(1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//untap();
|
//untap();
|
||||||
|
willattackpw = 0;
|
||||||
|
willattackplayer = 0;
|
||||||
setAttacker(0);
|
setAttacker(0);
|
||||||
isAttacking = NULL;
|
isAttacking = NULL;
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -1663,6 +1663,13 @@ int MTGAttackCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * aiCh
|
|||||||
return 0;
|
return 0;
|
||||||
if(card->attackCost < 1)
|
if(card->attackCost < 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
if(card->attackCost)
|
||||||
|
{
|
||||||
|
int number = card->attackCost;
|
||||||
|
WParsedInt parsedNum(number);
|
||||||
|
scost = _("Pay " + parsedNum.getStringValue() + " to attack").c_str();
|
||||||
|
}
|
||||||
|
|
||||||
ManaCost * playerMana = card->controller()->getManaPool();
|
ManaCost * playerMana = card->controller()->getManaPool();
|
||||||
ManaCost * attackcost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL));
|
ManaCost * attackcost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL));
|
||||||
attackcost->add(0,card->attackCostBackup);
|
attackcost->add(0,card->attackCostBackup);
|
||||||
@@ -1671,7 +1678,6 @@ int MTGAttackCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * aiCh
|
|||||||
{
|
{
|
||||||
attackcost->extraCosts->costs[i]->setSource(card);
|
attackcost->extraCosts->costs[i]->setSource(card);
|
||||||
}
|
}
|
||||||
scost = attackcost->getConvertedCost();
|
|
||||||
if ((aiCheck && aiCheck->canAfford(attackcost)) || playerMana->canAfford(attackcost))
|
if ((aiCheck && aiCheck->canAfford(attackcost)) || playerMana->canAfford(attackcost))
|
||||||
{
|
{
|
||||||
SAFE_DELETE(attackcost);
|
SAFE_DELETE(attackcost);
|
||||||
@@ -1711,7 +1717,7 @@ ostream& MTGAttackCostRule::toString(ostream& out) const
|
|||||||
|
|
||||||
const string MTGAttackCostRule::getMenuText()
|
const string MTGAttackCostRule::getMenuText()
|
||||||
{
|
{
|
||||||
sprintf(menuText, "Pay to attack");
|
sprintf(menuText, "%s", scost.c_str());
|
||||||
return menuText;
|
return menuText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1737,6 +1743,12 @@ int MTGBlockCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * aiChe
|
|||||||
return 0;
|
return 0;
|
||||||
if(card->blockCost < 1)
|
if(card->blockCost < 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
if(card->blockCost)
|
||||||
|
{
|
||||||
|
int number = card->blockCost;
|
||||||
|
WParsedInt parsedNum(number);
|
||||||
|
scost = _("Pay " + parsedNum.getStringValue() + " to block").c_str();
|
||||||
|
}
|
||||||
|
|
||||||
ManaCost * playerMana = card->controller()->getManaPool();
|
ManaCost * playerMana = card->controller()->getManaPool();
|
||||||
ManaCost * blockcost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL));
|
ManaCost * blockcost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL));
|
||||||
@@ -1746,7 +1758,6 @@ int MTGBlockCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * aiChe
|
|||||||
{
|
{
|
||||||
blockcost->extraCosts->costs[i]->setSource(card);
|
blockcost->extraCosts->costs[i]->setSource(card);
|
||||||
}
|
}
|
||||||
scost = blockcost->getConvertedCost();
|
|
||||||
if ((aiCheck && aiCheck->canAfford(blockcost)) || playerMana->canAfford(blockcost))
|
if ((aiCheck && aiCheck->canAfford(blockcost)) || playerMana->canAfford(blockcost))
|
||||||
{
|
{
|
||||||
SAFE_DELETE(blockcost);
|
SAFE_DELETE(blockcost);
|
||||||
@@ -1785,7 +1796,7 @@ ostream& MTGBlockCostRule::toString(ostream& out) const
|
|||||||
|
|
||||||
const string MTGBlockCostRule::getMenuText()
|
const string MTGBlockCostRule::getMenuText()
|
||||||
{
|
{
|
||||||
sprintf(menuText, "Pay to block");
|
sprintf(menuText, "%s", scost.c_str());
|
||||||
return menuText;
|
return menuText;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1814,6 +1825,7 @@ MTGAttackRule::MTGAttackRule(GameObserver* observer, int _id) :
|
|||||||
PermanentAbility(observer, _id)
|
PermanentAbility(observer, _id)
|
||||||
{
|
{
|
||||||
aType = MTGAbility::MTG_ATTACK_RULE;
|
aType = MTGAbility::MTG_ATTACK_RULE;
|
||||||
|
attackmenu = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
int MTGAttackRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
int MTGAttackRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
||||||
@@ -1822,11 +1834,19 @@ int MTGAttackRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
|||||||
{
|
{
|
||||||
if(card->isPhased)
|
if(card->isPhased)
|
||||||
return 0;
|
return 0;
|
||||||
if (card->isAttacker())
|
if ((card->isAttacker()) || (card->canAttack() && card->attackCost < 1))
|
||||||
return 1;
|
{
|
||||||
if (card->canAttack() && card->attackCost < 1)
|
if(!card->isAttacker())
|
||||||
|
attackmenu = "Attack Player";
|
||||||
|
else
|
||||||
|
attackmenu = "Remove Attacker";
|
||||||
|
|
||||||
|
if(card->willattackpw)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1904,10 +1924,16 @@ int MTGAttackRule::reactToClick(MTGCardInstance * card)
|
|||||||
game->getCardSelector()->Limit(NULL, CardView::playZone);
|
game->getCardSelector()->Limit(NULL, CardView::playZone);
|
||||||
game->getCardSelector()->PopLimitor();
|
game->getCardSelector()->PopLimitor();
|
||||||
}
|
}
|
||||||
|
|
||||||
card->toggleAttacker();
|
card->toggleAttacker();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string MTGAttackRule::getMenuText()
|
||||||
|
{
|
||||||
|
return attackmenu;
|
||||||
|
}
|
||||||
|
|
||||||
ostream& MTGAttackRule::toString(ostream& out) const
|
ostream& MTGAttackRule::toString(ostream& out) const
|
||||||
{
|
{
|
||||||
out << "MTGAttackRule ::: (";
|
out << "MTGAttackRule ::: (";
|
||||||
@@ -1923,6 +1949,7 @@ MTGPlaneswalkerAttackRule::MTGPlaneswalkerAttackRule(GameObserver* observer, int
|
|||||||
PermanentAbility(observer, _id)
|
PermanentAbility(observer, _id)
|
||||||
{
|
{
|
||||||
aType = MTGAbility::MTG_ATTACK_RULE;
|
aType = MTGAbility::MTG_ATTACK_RULE;
|
||||||
|
attackpwmenu = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
int MTGPlaneswalkerAttackRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
int MTGPlaneswalkerAttackRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
||||||
@@ -1933,11 +1960,19 @@ int MTGPlaneswalkerAttackRule::isReactingToClick(MTGCardInstance * card, ManaCos
|
|||||||
return 0;
|
return 0;
|
||||||
if(card->isPhased)
|
if(card->isPhased)
|
||||||
return 0;
|
return 0;
|
||||||
if (card->isAttacker())
|
if ((card->isAttacker()) || (card->canAttack(true) && card->attackPlaneswalkerCost < 1))
|
||||||
return 1;
|
{
|
||||||
if (card->canAttack(true) && card->attackPlaneswalkerCost < 1)
|
if(!card->isAttacker())
|
||||||
|
attackpwmenu = "Attack Planeswalker";
|
||||||
|
else
|
||||||
|
attackpwmenu = "Remove Attacker";
|
||||||
|
|
||||||
|
if(card->willattackplayer)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1955,6 +1990,12 @@ int MTGPlaneswalkerAttackRule::reactToClick(MTGCardInstance * card)
|
|||||||
game->getCardSelector()->PopLimitor();
|
game->getCardSelector()->PopLimitor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(card->willattackpw)
|
||||||
|
{
|
||||||
|
card->toggleAttacker(true);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
vector<MTGAbility*>selection;
|
vector<MTGAbility*>selection;
|
||||||
MTGCardInstance * check = NULL;
|
MTGCardInstance * check = NULL;
|
||||||
int checkWalkers = card->controller()->opponent()->game->battlefield->cards.size();
|
int checkWalkers = card->controller()->opponent()->game->battlefield->cards.size();
|
||||||
@@ -1982,6 +2023,11 @@ int MTGPlaneswalkerAttackRule::reactToClick(MTGCardInstance * card)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string MTGPlaneswalkerAttackRule::getMenuText()
|
||||||
|
{
|
||||||
|
return attackpwmenu;
|
||||||
|
}
|
||||||
|
|
||||||
MTGPlaneswalkerAttackRule * MTGPlaneswalkerAttackRule::clone() const
|
MTGPlaneswalkerAttackRule * MTGPlaneswalkerAttackRule::clone() const
|
||||||
{
|
{
|
||||||
return NEW MTGPlaneswalkerAttackRule(*this);
|
return NEW MTGPlaneswalkerAttackRule(*this);
|
||||||
@@ -2016,7 +2062,7 @@ int AAPlaneswalkerAttacked::resolve()
|
|||||||
if(!attacker)
|
if(!attacker)
|
||||||
return 0;
|
return 0;
|
||||||
attacker->isAttacking = this->target;
|
attacker->isAttacking = this->target;
|
||||||
attacker->toggleAttacker();
|
attacker->toggleAttacker(true);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user