added basic offering support

usage tap lands to produce mana then sacrifice an offering... example
you have Guttersnipe in play, it has a mana cost of {2}{R}, and you have
Patron of the Akki in hand that costs {4}{R}{R}. You need to produce
{2}{R} mana first before casting Patron of the Akki, then choose
Guttersnipe as an offering.
This commit is contained in:
Anthony Calosa
2015-09-08 12:26:03 +08:00
parent a57e919e44
commit ef707e6d5d
9 changed files with 169 additions and 49 deletions

View File

@@ -69645,6 +69645,66 @@ power=1
toughness=1
[/card]
[card]
name=Patron of the Akki
other={kgoblin} name(Goblin Offering)
abilities=offering
auto=@combat(attacking) source(this):all(creature[attacking]) 2/0 ueot
text=Goblin offering (You may cast this card any time you could cast an instant by sacrificing a Goblin and paying the difference in mana costs between this and the sacrificed Goblin. Mana cost includes color.) -- Whenever Patron of the Akki attacks, creatures you control get +2/+0 until end of turn.
mana={4}{R}{R}
type=Legendary Creature
subtype=Spirit
power=5
toughness=5
[/card]
[card]
name=Patron of the Kitsune
other={kfox} name(Fox Offering)
abilities=offering
auto=@each blockers:may life:type:creature[attacking]:battlefield controller
text=Fox offering (You may cast this card any time you could cast an instant by sacrificing a Fox and paying the difference in mana costs between this and the sacrificed Fox. Mana cost includes color.) -- Whenever a creature attacks, you may gain 1 life.
mana={4}{W}{W}
type=Legendary Creature
subtype=Spirit
power=5
toughness=6
[/card]
[card]
name=Patron of the Moon
other={kmoonfolk} name(Moonfolk Offering)
abilities=flying,offering
auto={1}:name(put 2 lands in play) moveto(mybattlefield) and!(tap)! notatarget(<upto:2>land|myhand)
text=Moonfolk offering (You may cast this card any time you could cast an instant by sacrificing a Moonfolk and paying the difference in mana costs between this and the sacrificed Moonfolk. Mana cost includes color.) -- Flying -- {1}: Put up to two land cards from your hand onto the battlefield tapped.
mana={5}{U}{U}
type=Legendary Creature
subtype=Spirit
power=5
toughness=4
[/card]
[card]
name=Patron of the Nezumi
other={krat} name(Rat Offering)
abilities=offering
auto=@movedto(*|opponentgraveyard) from(battlefield):life:-1 opponent
text=Rat offering (You may cast this card any time you could cast an instant by sacrificing a Rat and paying the difference in mana costs between this and the sacrificed Rat. Mana cost includes color.) -- Whenever a permanent is put into an opponent's graveyard, that player loses 1 life.
mana={5}{B}{B}
type=Legendary Creature
subtype=Spirit
power=6
toughness=6
[/card]
[card]
name=Patron of the Orochi
other={ksnake} name(Snake Offering)
abilities=offering
auto={T}:name(untap all green creatures and forests) untap all(forest) && untap all(creature[green]) limit:1
text=Snake offering (You may cast this card any time you could cast an instant by sacrificing a Snake and paying the difference in mana costs between this and the sacrificed Snake. Mana cost includes color.) -- {T}: Untap all Forests and all green creatures. Activate this ability only once each turn.
mana={6}{G}{G}
type=Legendary Creature
subtype=Spirit
power=7
toughness=7
[/card]
[card]
name=Patron of the Wild
facedown={3}
autofacedown={2}{G}:morph

View File

@@ -11637,51 +11637,6 @@ mana={3}{B}{B}
type=Sorcery
[/card]
[card]
name=Patron of the Akki
text=Goblin offering (You may cast this card any time you could cast an instant by sacrificing a Goblin and paying the difference in mana costs between this and the sacrificed Goblin. Mana cost includes color.) -- Whenever Patron of the Akki attacks, creatures you control get +2/+0 until end of turn.
mana={4}{R}{R}
type=Legendary Creature
subtype=Spirit
power=5
toughness=5
[/card]
[card]
name=Patron of the Kitsune
text=Fox offering (You may cast this card any time you could cast an instant by sacrificing a Fox and paying the difference in mana costs between this and the sacrificed Fox. Mana cost includes color.) -- Whenever a creature attacks, you may gain 1 life.
mana={4}{W}{W}
type=Legendary Creature
subtype=Spirit
power=5
toughness=6
[/card]
[card]
name=Patron of the Moon
text=Moonfolk offering (You may cast this card any time you could cast an instant by sacrificing a Moonfolk and paying the difference in mana costs between this and the sacrificed Moonfolk. Mana cost includes color.) -- Flying -- {1}: Put up to two land cards from your hand onto the battlefield tapped.
mana={5}{U}{U}
type=Legendary Creature
subtype=Spirit
power=5
toughness=4
[/card]
[card]
name=Patron of the Nezumi
text=Rat offering (You may cast this card any time you could cast an instant by sacrificing a Rat and paying the difference in mana costs between this and the sacrificed Rat. Mana cost includes color.) -- Whenever a permanent is put into an opponent's graveyard, that player loses 1 life.
mana={5}{B}{B}
type=Legendary Creature
subtype=Spirit
power=6
toughness=6
[/card]
[card]
name=Patron of the Orochi
text=Snake offering (You may cast this card any time you could cast an instant by sacrificing a Snake and paying the difference in mana costs between this and the sacrificed Snake. Mana cost includes color.) -- {T}: Untap all Forests and all green creatures. Activate this ability only once each turn.
mana={6}{G}{G}
type=Legendary Creature
subtype=Spirit
power=7
toughness=7
[/card]
[card]
name=Pay No Heed
text=Prevent all damage a source of your choice would deal this turn.
mana={W}

View File

@@ -254,6 +254,17 @@ public:
virtual Ninja * clone() const;
};
//offering cost
class Offering : public ExtraCost
{
public:
Offering(TargetChooser *_tc = NULL);
virtual int canPay();
virtual int isPaymentSet();
virtual int doPay();
virtual Offering * clone() const;
};
class CounterCost : public ExtraCost
{
public:

View File

@@ -224,7 +224,8 @@ class Constants
OPPGRAVEEXILER = 106,
LIBRARYDEATH = 107,
SHUFFLELIBRARYDEATH = 108,
NB_BASIC_ABILITIES = 109,
OFFERING = 109,
NB_BASIC_ABILITIES = 110,
RARITY_S = 'S', //Special Rarity

View File

@@ -762,6 +762,65 @@ int Ninja::doPay()
}
//endbouncetargetcostforninja
//Sacrifice target as cost for Offering
Offering * Offering::clone() const
{
Offering * ec = NEW Offering(*this);
if (tc)
ec->tc = tc->clone();
return ec;
}
Offering::Offering(TargetChooser *_tc) :
ExtraCost("Select creature to offer", _tc)
{
}
int Offering::canPay()
{
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
{
tc->removeTarget(target);
target = NULL;
return 0;
}
if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
return 1;
return 0;
}
int Offering::isPaymentSet()
{
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
{
tc->removeTarget(target);
target = NULL;
return 0;
}
if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
return 1;
return 0;
}
int Offering::doPay()
{
if (target)
{
target->controller()->getManaPool()->pay(source->getManaCost()->Diff(target->getManaCost()));
MTGCardInstance * beforeCard = target;
source->storedCard = target->createSnapShot();
target->controller()->game->putInGraveyard(target);
WEvent * e = NEW WEventCardSacrifice(beforeCard,target);
GameObserver * game = target->owner->getObserver();
game->receiveEvent(e);
target = NULL;
if (tc)
tc->initTargets();
return 1;
}
return 0;
}
//------------------------------------------------------------
SacrificeCost * SacrificeCost::clone() const

View File

@@ -447,6 +447,12 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
if(cPhase < MTG_PHASE_COMBATBEGIN ||cPhase > MTG_PHASE_COMBATEND )
return 0;
}
check = restriction[i].find("during my main phases");
if(check != string::npos)
{
if( player != observer->currentPlayer && (cPhase != MTG_PHASE_FIRSTMAIN ||cPhase != MTG_PHASE_SECONDMAIN) )
return 0;
}
check = restriction[i].find("during my turn");
if(check != string::npos)
{

View File

@@ -137,7 +137,8 @@ const char* Constants::MTGBasicAbilities[] = {
"mygraveexiler",
"oppgraveexiler",
"librarydeath",
"shufflelibrarydeath"
"shufflelibrarydeath",
"offering"
};
map<string,int> Constants::MTGBasicAbilitiesMap;

View File

@@ -317,7 +317,7 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
return 1;
}
}
else if ((card->hasType(Subtypes::TYPE_INSTANT)) || card->has(Constants::FLASH)
else if ((card->hasType(Subtypes::TYPE_INSTANT)) || card->has(Constants::FLASH)
|| (player == card->controller() && !game->isInterrupting
&& (game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN
|| game->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN))
@@ -651,7 +651,7 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
)
return 1;
}
else if ((card->hasType(Subtypes::TYPE_INSTANT)) || card->has(Constants::FLASH)
else if ((card->hasType(Subtypes::TYPE_INSTANT)) || card->has(Constants::FLASH) || card->has(Constants::OFFERING)
|| (player == card->controller() && !game->isInterrupting
&& (game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN
|| game->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN))

View File

@@ -193,6 +193,33 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
manaCost->addExtraCost(NEW Ninja(tc));
break;
}
case 'k': //kill offering
{
TargetChooserFactory tcf(g);
if (value == "kgoblin")
{
tc = tcf.createTargetChooser("creature[goblin]|myBattlefield", c);
}
else if (value == "kfox")
{
tc = tcf.createTargetChooser("creature[fox]|myBattlefield", c);
}
else if (value == "kmoonfolk")
{
tc = tcf.createTargetChooser("creature[moonfolk]|myBattlefield", c);
}
else if (value == "krat")
{
tc = tcf.createTargetChooser("creature[rat]|myBattlefield", c);
}
else if (value == "ksnake")
{
tc = tcf.createTargetChooser("creature[snake]|myBattlefield", c);
}
//TODO iterate subtypes of creatures
manaCost->addExtraCost(NEW Offering(tc));
break;
}
case 'p' :
{
SAFE_DELETE(tc);