Crew Ability Cost & Crewbonus

Revised cards to use {crew(targetchooser)} (modified taptargetcost) so
it can use crewbonus ability from other creatures.
This commit is contained in:
Anthony Calosa
2017-02-01 17:11:55 +08:00
parent c8dc416071
commit ea5e397595
10 changed files with 144 additions and 72 deletions
+12
View File
@@ -58,6 +58,7 @@ CardPrimitive::CardPrimitive(CardPrimitive * source)
setdoubleFaced(source->doubleFaced);
setAICustomCode(source->AICustomCode);
setCrewAbility(source->CrewAbility);
power = source->power;
toughness = source->toughness;
restrictions = source->restrictions ? source->restrictions->clone() : NULL;
@@ -353,6 +354,17 @@ const string& CardPrimitive::getAICustomCode() const
return AICustomCode;
}
void CardPrimitive::setCrewAbility(const string& value)
{
std::transform(CrewAbility.begin(), CrewAbility.end(), CrewAbility.begin(), ::tolower);
CrewAbility = value;
}
const string& CardPrimitive::getCrewAbility() const
{
return CrewAbility;
}
void CardPrimitive::setName(const string& value)
{
name = value;
+23 -2
View File
@@ -771,8 +771,8 @@ TapTargetCost * TapTargetCost::clone() const
return ec;
}
TapTargetCost::TapTargetCost(TargetChooser *_tc)
: ExtraCost("Tap Target", _tc)
TapTargetCost::TapTargetCost(TargetChooser *_tc, bool crew)
: ExtraCost("Tap Target", _tc), crew(crew)
{
}
@@ -785,6 +785,13 @@ int TapTargetCost::isPaymentSet()
target = NULL;
return 0;
}
if (crew && target && target->has(Constants::CANTCREW))
{
tc->removeTarget(target);
target->isExtraCostTarget = false;
target = NULL;
return 0;
}
if (target)
return 1;
return 0;
@@ -798,6 +805,20 @@ int TapTargetCost::doPay()
{
source->storedCard = target->createSnapShot();
_target->tap();
//crew ability
if(crew)
{
if(_target->getCrewAbility().size())
{
AbilityFactory af(_target->getObserver());
MTGAbility * crewAbility = af.parseMagicLine(_target->getCrewAbility(), -1, NULL, source,false,true);
crewAbility->oneShot = true;
crewAbility->canBeInterrupted = false;
crewAbility->target = source;
crewAbility->resolve();
}
}
//end
target = NULL;
if (tc)
tc->initTargets();
+1
View File
@@ -131,6 +131,7 @@ void MTGCardInstance::copy(MTGCardInstance * card)
copiedID = card->copiedID;
doubleFaced = data->doubleFaced;
AICustomCode = data->AICustomCode;
CrewAbility = data->CrewAbility;
origpower = card->origpower;//for flip
origtoughness = card->origtoughness;//for flip
TokenAndAbility = card->TokenAndAbility;//token andAbility
+11 -3
View File
@@ -131,9 +131,17 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
}
break;
case 'c': //color
if (!primitive) primitive = NEW CardPrimitive();
case 'c': //crew ability
if (key == "crewbonus")
{
if (!primitive) primitive = NEW CardPrimitive();
{
primitive->setCrewAbility(val);
break;
}
}
else if (!primitive) primitive = NEW CardPrimitive();
{//color
string value = val;
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
vector<string> values = split(value, ',');
@@ -143,8 +151,8 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
primitive->setColor(values[values_i], removeAllOthers);
removeAllOthers = 0;
}
break;
}
break;
case 'd'://double faced card /dredge
if (key == "doublefaced")
{
+4
View File
@@ -297,6 +297,10 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
{
manaCost->addExtraCost(NEW CycleCost(tc));
}
else if(value.substr(0,4) == "crew")
{//tap crew
manaCost->addExtraCost(NEW TapTargetCost(tc,true));
}
else if(value.find("(") != string::npos)
{
size_t counter_start = value.find("(");