Attack Cost Rule

Update your rules folder
This commit is contained in:
Anthony Calosa
2016-06-14 19:40:02 +08:00
parent 26346f5a42
commit 1f54c7933b
13 changed files with 172 additions and 9 deletions
@@ -16,6 +16,7 @@ auto=morphrule
auto=payzerorule
auto=overloadrule
auto=attackrule
auto=attackcostrule
auto=blockrule
auto=combattriggerrule
auto=legendrule
+1
View File
@@ -15,6 +15,7 @@ auto=morphrule
auto=payzerorule
auto=overloadrule
auto=attackrule
auto=attackcostrule
auto=blockrule
auto=combattriggerrule
auto=legendrule
+1
View File
@@ -19,6 +19,7 @@ auto=morphrule
auto=payzerorule
auto=overloadrule
auto=attackrule
auto=attackcostrule
auto=blockrule
auto=combattriggerrule
auto=legendrule
@@ -1,4 +1,17 @@
grade=borderline
#planeswalker and creature attack cost...
[card]
name=Archangel of Tithes
abilities=flying
auto=this(untapped) lord(creature|opponentbattlefield) transforms((,newability[@each mycombatbegins:pay[[{1}]] name(pay 1 mana) donothing?cantattack all(this)]))
auto=@combat(attacking) source(this):all(creature|opponentbattlefield) transforms((,newability[pay[[{1}]] name(pay 1 mana) donothing?cantblock all(this)]))
text=Flying -- As long as Archangel of Tithes is untapped, creatures can't attack you or a planeswalker you control unless their controller pays {1} for each of those creatures. -- As long as Archangel of Tithes is attacking, creatures can't block unless their controller pays {1} for each of those creatures.
mana={1}{W}{W}{W}
type=Creature
subtype=Angel
power=3
toughness=5
[/card]
[card]
name=Autumn Willow
abilities=opponentshroud,shroud
@@ -12123,12 +12123,6 @@ power=*
toughness=*
[/card]
[card]
name=Koskun Falls
text=At the beginning of your upkeep, sacrifice Koskun Falls unless you tap an untapped creature you control. -- Creatures can't attack you unless their controller pays {2} for each creature he or she controls that's attacking you.
mana={2}{B}{B}
type=World Enchantment
[/card]
[card]
name=Kozilek's Channeler
text={T}: Add {C}{C} to your mana pool.
mana={5}
+13
View File
@@ -4863,6 +4863,19 @@ public:
};
//AAttackSetCost
class AAttackSetCost: public MTGAbility
{
public:
string number;
AAttackSetCost(GameObserver* observer, int _id, MTGCardInstance * _source, string number);
void Update(float dt);
int addToGame();
int destroy();
const string getMenuText();
AAttackSetCost * clone() const;
};
//ABlink
class ABlink: public MTGAbility
{
+2
View File
@@ -216,6 +216,8 @@ public:
PAYZERO_COST = 33,
OVERLOAD_COST = 34,
BESTOW_COST = 35,
ATTACK_COST = 36,
ATTACKPLANESWALKER_COST = 37,
};
};
+3
View File
@@ -258,6 +258,9 @@ public:
ManaCost * computeNewCost(MTGCardInstance * card,ManaCost * oldCost, ManaCost * refCost,bool noTrinisphere = false);
int countTrini;
vector<MTGCardInstance*>imprintedCards;
int attackCost;
int attackCostBackup;
int attackPlaneswalkerCost;
int imprintG;
int imprintU;
int imprintR;
+12
View File
@@ -219,6 +219,18 @@ public:
virtual MTGSuspendRule * clone() const;
};
class MTGAttackCostRule: public PermanentAbility
{
public:
string scost;
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int reactToClick(MTGCardInstance * card);
virtual ostream& toString(ostream& out) const;
MTGAttackCostRule(GameObserver* observer, int _id);
const string getMenuText();
virtual MTGAttackCostRule * clone() const;
};
class MTGAttackRule: public PermanentAbility, public Limitor
{
public:
+45
View File
@@ -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)
+13
View File
@@ -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)
{
+3
View File
@@ -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;
+65 -3
View File
@@ -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;