refactored a little of a token gen, enumed the who and removed redundent code, also the new method allows you to token cards by id to WHO.
This commit is contained in:
@@ -2721,6 +2721,12 @@ public:
|
|||||||
class ATokenCreator: public ActivatedAbility
|
class ATokenCreator: public ActivatedAbility
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ATOKEN_WHO_CONTROLLER = 0,
|
||||||
|
ATOKEN_WHO_OPPONENT = 1,
|
||||||
|
ATOKEN_WHO_TARGETCONTROLLER = 2
|
||||||
|
};
|
||||||
list<int> abilities;
|
list<int> abilities;
|
||||||
list<int> types;
|
list<int> types;
|
||||||
list<int> colors;
|
list<int> colors;
|
||||||
@@ -2736,6 +2742,7 @@ public:
|
|||||||
bool battleReady;
|
bool battleReady;
|
||||||
MTGCardInstance * myToken;
|
MTGCardInstance * myToken;
|
||||||
vector<MTGAbility *> currentAbilities;
|
vector<MTGAbility *> currentAbilities;
|
||||||
|
Player * tokenReciever;
|
||||||
ATokenCreator(int _id, MTGCardInstance * _source, Targetable * _target, ManaCost * _cost, int tokenId, int _doTap,string starfound, WParsedInt * multiplier = NULL,
|
ATokenCreator(int _id, MTGCardInstance * _source, Targetable * _target, ManaCost * _cost, int tokenId, int _doTap,string starfound, WParsedInt * multiplier = NULL,
|
||||||
int who = 0,bool aLivingWeapon = false) :
|
int who = 0,bool aLivingWeapon = false) :
|
||||||
ActivatedAbility(_id, _source, _cost, 0, _doTap), tokenId(tokenId), starfound(starfound),multiplier(multiplier), who(who),aLivingWeapon(aLivingWeapon)
|
ActivatedAbility(_id, _source, _cost, 0, _doTap), tokenId(tokenId), starfound(starfound),multiplier(multiplier), who(who),aLivingWeapon(aLivingWeapon)
|
||||||
@@ -2809,13 +2816,13 @@ public:
|
|||||||
}
|
}
|
||||||
if(!spt.empty())
|
if(!spt.empty())
|
||||||
{
|
{
|
||||||
vector<string> powertoughness = split( spt, '/');
|
vector<string> powertoughness = split( spt, '/');
|
||||||
WParsedInt * NewPow = NEW WParsedInt(powertoughness[0].c_str(),NULL,source);
|
WParsedInt * NewPow = NEW WParsedInt(powertoughness[0].c_str(),NULL,source);
|
||||||
WParsedInt * NewTou = NEW WParsedInt(powertoughness[1].c_str(),NULL,source);
|
WParsedInt * NewTou = NEW WParsedInt(powertoughness[1].c_str(),NULL,source);
|
||||||
power = NewPow->getValue();
|
power = NewPow->getValue();
|
||||||
toughness = NewTou->getValue();
|
toughness = NewTou->getValue();
|
||||||
SAFE_DELETE(NewPow);
|
SAFE_DELETE(NewPow);
|
||||||
SAFE_DELETE(NewTou);
|
SAFE_DELETE(NewTou);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < multiplier->getValue(); ++i)
|
for (int i = 0; i < multiplier->getValue(); ++i)
|
||||||
{
|
{
|
||||||
@@ -2823,8 +2830,8 @@ public:
|
|||||||
if (tokenId)
|
if (tokenId)
|
||||||
{
|
{
|
||||||
MTGCard * card = MTGCollection()->getCardById(tokenId);
|
MTGCard * card = MTGCollection()->getCardById(tokenId);
|
||||||
myToken = NEW MTGCardInstance(card, source->controller()->game);
|
setTokenOwner();
|
||||||
|
myToken = NEW MTGCardInstance(card, tokenReciever->game);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2855,64 +2862,49 @@ public:
|
|||||||
tokenText.append( sourcename);
|
tokenText.append( sourcename);
|
||||||
myToken->text = tokenText;
|
myToken->text = tokenText;
|
||||||
}
|
}
|
||||||
if (who == 0 && who != 1 && who != 2)
|
setTokenOwner();
|
||||||
|
tokenReciever->game->temp->addCard(myToken);
|
||||||
|
Spell * spell = NEW Spell(myToken);
|
||||||
|
spell->resolve();
|
||||||
|
myToken = spell->source;
|
||||||
|
spell->source->owner = tokenReciever;
|
||||||
|
spell->source->isToken = 1;
|
||||||
|
spell->source->fresh = 1;
|
||||||
|
if(aLivingWeapon)
|
||||||
{
|
{
|
||||||
source->controller()->game->temp->addCard(myToken);
|
livingWeaponToken(spell->source);
|
||||||
Spell * spell = NEW Spell(myToken);
|
|
||||||
spell->resolve();
|
|
||||||
spell->source->isToken = 1;
|
|
||||||
spell->source->fresh = 1;
|
|
||||||
if(aLivingWeapon)
|
|
||||||
{
|
|
||||||
livingWeaponToken(spell->source);
|
|
||||||
}
|
|
||||||
if(battleReady)
|
|
||||||
{
|
|
||||||
battleReadyToken(spell->source);
|
|
||||||
}
|
|
||||||
delete spell;
|
|
||||||
}
|
}
|
||||||
else if (who == 1 && who != 0 && who != 2)
|
if(battleReady)
|
||||||
{
|
{
|
||||||
source->controller()->opponent()->game->temp->addCard(myToken);
|
battleReadyToken(spell->source);
|
||||||
Spell * spell = NEW Spell(myToken);
|
|
||||||
spell->resolve();
|
|
||||||
spell->source->owner = spell->source->controller();
|
|
||||||
spell->source->isToken = 1;
|
|
||||||
spell->source->fresh = 1;
|
|
||||||
if(aLivingWeapon)
|
|
||||||
{
|
|
||||||
livingWeaponToken(spell->source);
|
|
||||||
}
|
|
||||||
if(battleReady)
|
|
||||||
{
|
|
||||||
battleReadyToken(spell->source);
|
|
||||||
}
|
|
||||||
delete spell;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
((MTGCardInstance*)target)->controller()->game->temp->addCard(myToken);
|
|
||||||
Spell * spell = NEW Spell(myToken);
|
|
||||||
spell->resolve();
|
|
||||||
spell->source->owner = ((MTGCardInstance*)target)->controller();
|
|
||||||
spell->source->isToken = 1;
|
|
||||||
spell->source->fresh = 1;
|
|
||||||
myToken = spell->source;
|
|
||||||
if(aLivingWeapon)
|
|
||||||
{
|
|
||||||
livingWeaponToken(spell->source);
|
|
||||||
}
|
|
||||||
if(battleReady)
|
|
||||||
{
|
|
||||||
battleReadyToken(spell->source);
|
|
||||||
}
|
|
||||||
delete spell;
|
|
||||||
}
|
}
|
||||||
|
delete spell;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setTokenOwner()
|
||||||
|
{
|
||||||
|
switch(who)
|
||||||
|
{
|
||||||
|
case ATokenCreator::ATOKEN_WHO_CONTROLLER:
|
||||||
|
tokenReciever = source->controller();
|
||||||
|
break;
|
||||||
|
case ATokenCreator::ATOKEN_WHO_OPPONENT:
|
||||||
|
tokenReciever = source->controller()->opponent();
|
||||||
|
break;
|
||||||
|
case ATokenCreator::ATOKEN_WHO_TARGETCONTROLLER:
|
||||||
|
if(target)
|
||||||
|
{
|
||||||
|
tokenReciever = ((MTGCardInstance*)target)->controller();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
tokenReciever = source->controller();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void livingWeaponToken(MTGCardInstance * card)
|
void livingWeaponToken(MTGCardInstance * card)
|
||||||
{
|
{
|
||||||
GameObserver * g = g->GetInstance();
|
GameObserver * g = g->GetInstance();
|
||||||
@@ -2936,7 +2928,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char * getMenuText()
|
const char * getMenuText()
|
||||||
{
|
{
|
||||||
sprintf(menuText, "Create %s", name.c_str());
|
sprintf(menuText, "Create %s", name.c_str());
|
||||||
return menuText;
|
return menuText;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1798,16 +1798,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
size_t opponent = s.find("opponent");
|
size_t opponent = s.find("opponent");
|
||||||
if (opponent != string::npos)
|
if (opponent != string::npos)
|
||||||
{
|
{
|
||||||
who = 1;
|
who = ATokenCreator::ATOKEN_WHO_OPPONENT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
who = 0;
|
who = ATokenCreator::ATOKEN_WHO_CONTROLLER;
|
||||||
}
|
}
|
||||||
size_t targetcontroller = s.find("targetcontroller");
|
size_t targetcontroller = s.find("targetcontroller");
|
||||||
if (targetcontroller != string::npos)
|
if (targetcontroller != string::npos)
|
||||||
{
|
{
|
||||||
who = 2;
|
who = ATokenCreator::ATOKEN_WHO_TARGETCONTROLLER;
|
||||||
}
|
}
|
||||||
if (tokenId)
|
if (tokenId)
|
||||||
{
|
{
|
||||||
@@ -1848,22 +1848,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
}
|
}
|
||||||
parsePowerToughness(spt, &power, &toughness);
|
parsePowerToughness(spt, &power, &toughness);
|
||||||
string sabilities = s.substr(end + 1);
|
string sabilities = s.substr(end + 1);
|
||||||
if (s.find("opponent"))
|
|
||||||
{
|
|
||||||
if (opponent != string::npos)
|
|
||||||
{
|
|
||||||
who = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
who = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
targetcontroller = s.find("targetcontroller");
|
|
||||||
if (targetcontroller != string::npos)
|
|
||||||
{
|
|
||||||
who = 2;
|
|
||||||
}
|
|
||||||
ATokenCreator * tok = NEW ATokenCreator(id, card,target, NULL, sname, stypes, power + value, toughness + value, sabilities, 0,starfound,
|
ATokenCreator * tok = NEW ATokenCreator(id, card,target, NULL, sname, stypes, power + value, toughness + value, sabilities, 0,starfound,
|
||||||
multiplier, who,aLivingWeapon,spt);
|
multiplier, who,aLivingWeapon,spt);
|
||||||
tok->oneShot = 1;
|
tok->oneShot = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user