Attack Cost Rule
Update your rules folder
This commit is contained in:
@@ -5371,6 +5371,51 @@ APhaseActionGeneric::~APhaseActionGeneric()
|
||||
SAFE_DELETE(ability);
|
||||
}
|
||||
|
||||
//AAttackSetCost
|
||||
AAttackSetCost::AAttackSetCost(GameObserver* observer, int _id, MTGCardInstance * _source, string number) :
|
||||
MTGAbility(observer, _id, _source), number(number)
|
||||
{
|
||||
}
|
||||
|
||||
void AAttackSetCost::Update(float dt)
|
||||
{
|
||||
if(game->getCurrentGamePhase() != MTG_PHASE_COMBATATTACKERS)
|
||||
{
|
||||
source->attackCost = source->attackCostBackup;
|
||||
MTGAbility::Update(dt);
|
||||
}
|
||||
}
|
||||
|
||||
int AAttackSetCost::addToGame()
|
||||
{
|
||||
WParsedInt attackcost(number, NULL, source);
|
||||
source->attackCost += attackcost.getValue();
|
||||
source->attackCostBackup += attackcost.getValue();
|
||||
|
||||
return MTGAbility::addToGame();
|
||||
}
|
||||
|
||||
int AAttackSetCost::destroy()
|
||||
{
|
||||
|
||||
WParsedInt attackcost(number, NULL, source);
|
||||
source->attackCost -= attackcost.getValue();
|
||||
source->attackCostBackup -= attackcost.getValue();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
const string AAttackSetCost::getMenuText()
|
||||
{
|
||||
return "Attack Cost";
|
||||
}
|
||||
|
||||
AAttackSetCost * AAttackSetCost::clone() const
|
||||
{
|
||||
return NEW AAttackSetCost(*this);
|
||||
}
|
||||
|
||||
|
||||
//a blink
|
||||
ABlink::ABlink(GameObserver* observer, int _id, MTGCardInstance * card, MTGCardInstance * _target, bool blinkueot, bool blinkForSource, bool blinkhand, MTGAbility * stored) :
|
||||
MTGAbility(observer, _id, card),blinkueot(blinkueot),blinkForSource(blinkForSource),blinkhand(blinkhand),stored(stored)
|
||||
|
||||
@@ -1179,6 +1179,13 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
observer->addObserver(NEW MTGAttackRule(observer, -1));
|
||||
return NULL;
|
||||
}
|
||||
//this rule handles attacking cost ability during attacker phase
|
||||
found = s.find("attackcostrule");
|
||||
if(found != string::npos)
|
||||
{
|
||||
observer->addObserver(NEW MTGAttackCostRule(observer, -1));
|
||||
return NULL;
|
||||
}
|
||||
//this rule handles blocking ability during blocker phase
|
||||
found = s.find("blockrule");
|
||||
if(found != string::npos)
|
||||
@@ -2829,6 +2836,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
return NEW AReduceToAbility(observer, id, card,s.substr(9));
|
||||
}
|
||||
|
||||
//attack cost
|
||||
if (s.find("attackcost:") != string::npos)
|
||||
{
|
||||
return NEW AAttackSetCost(observer, id, card, s.substr(11));
|
||||
}
|
||||
|
||||
//flanking
|
||||
if (s.find("flanker") != string::npos)
|
||||
{
|
||||
|
||||
@@ -209,6 +209,9 @@ void MTGCardInstance::initMTGCI()
|
||||
miracle = false;
|
||||
countTrini = 0;
|
||||
imprintedCards.clear();
|
||||
attackCost = 0;
|
||||
attackCostBackup = 0;
|
||||
attackPlaneswalkerCost = 0;
|
||||
imprintG = 0;
|
||||
imprintU = 0;
|
||||
imprintR = 0;
|
||||
|
||||
@@ -1348,12 +1348,74 @@ MTGOverloadRule * MTGOverloadRule::clone() const
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
MTGAttackCostRule::MTGAttackCostRule(GameObserver* observer, int _id) :
|
||||
PermanentAbility(observer, _id)
|
||||
{
|
||||
aType = MTGAbility::ATTACK_COST;
|
||||
scost = "Pay to attack";
|
||||
}
|
||||
|
||||
int MTGAttackCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
||||
{
|
||||
|
||||
if (currentPhase == MTG_PHASE_COMBATATTACKERS && card->controller() == game->currentPlayer && card->controller() == game->currentlyActing())//on my turn and when I am the acting player.
|
||||
{
|
||||
if(card->isPhased)
|
||||
return 0;
|
||||
if(card->attackCost < 1)
|
||||
return 0;
|
||||
ManaCost * playerMana = card->controller()->getManaPool();
|
||||
ManaCost * attackcost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL));
|
||||
attackcost->add(0,card->attackCostBackup);
|
||||
if(attackcost->extraCosts)
|
||||
for(unsigned int i = 0; i < attackcost->extraCosts->costs.size();i++)
|
||||
{
|
||||
attackcost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
scost = attackcost->getConvertedCost();
|
||||
if (playerMana->canAfford(attackcost))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MTGAttackCostRule::reactToClick(MTGCardInstance * card)
|
||||
{
|
||||
if (!isReactingToClick(card))
|
||||
return 0;
|
||||
Player * player = game->currentlyActing();
|
||||
ManaCost * attackcost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL));
|
||||
attackcost->add(0,card->attackCostBackup);
|
||||
ManaCost * playerMana = player->getManaPool();
|
||||
player->getManaPool()->pay(attackcost);
|
||||
card->attackCost = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
ostream& MTGAttackCostRule::toString(ostream& out) const
|
||||
{
|
||||
out << "MTGAttackCostRule ::: (";
|
||||
return MTGAbility::toString(out) << ")";
|
||||
}
|
||||
|
||||
const string MTGAttackCostRule::getMenuText()
|
||||
{
|
||||
sprintf(menuText, "Pay to attack");
|
||||
return menuText;
|
||||
}
|
||||
|
||||
MTGAttackCostRule * MTGAttackCostRule::clone() const
|
||||
{
|
||||
return NEW MTGAttackCostRule(*this);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool MTGAttackRule::select(Target* t)
|
||||
{
|
||||
if (CardView* c = dynamic_cast<CardView*>(t))
|
||||
{
|
||||
MTGCardInstance * card = c->getCard();
|
||||
if (card->canAttack() && !card->isPhased)
|
||||
if (card->canAttack() && !card->isPhased && card->attackCost < 1)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1377,7 +1439,7 @@ int MTGAttackRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
||||
return 0;
|
||||
if (card->isAttacker())
|
||||
return 1;
|
||||
if (card->canAttack())
|
||||
if (card->canAttack() && card->attackCost < 1)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -1453,7 +1515,7 @@ int MTGPlaneswalkerAttackRule::isReactingToClick(MTGCardInstance * card, ManaCos
|
||||
return 0;
|
||||
if (card->isAttacker())
|
||||
return 1;
|
||||
if (card->canAttack())
|
||||
if (card->canAttack() && card->attackPlaneswalkerCost < 1)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user