3 changes

1st 
had to revise the syntax for my "type:" variable it is now type:blah:location, using the pipe line created nasty returns in some combinations of abilities as the parser confused the pipeline in type: with the one in TC.
2nd
more of a correction then a bug fix, i noticed that upcost had instances where it could still trigger its effect in the draw phase becuase the condiational for the ability resolve was in the update, i left the class mostly untouched but move the resolve out of update and into a receiveEvent for upcost, which triggers only once after you declared that you are leaving the upkeep before draw step begins.
3rd
reworked the construction of multiability to only produce a single multiability with all the abilities in the string instead of nested multiabilities, it is considerabily easier to debug and creates 1/3 less objects for the engine to deal with in comparison to the old method.
This commit is contained in:
omegablast2002@yahoo.com
2011-03-30 01:01:11 +00:00
parent 696237310f
commit d25424cb6c
3 changed files with 33 additions and 15 deletions
+8 -3
View File
@@ -84,13 +84,17 @@ public:
} }
else if (s.find("type:") != string::npos) else if (s.find("type:") != string::npos)
{ {
size_t begins = s.find(":"); size_t begins = s.find("type:");
string theType = s.substr(begins + 1); string theType = s.substr(begins + 5);
size_t zoned = theType.find("|"); size_t zoned = theType.find(":");
if(zoned == string::npos) if(zoned == string::npos)
{ {
theType.append("|mybattlefield"); theType.append("|mybattlefield");
} }
else
{
replace(theType.begin(), theType.end(), ':', '|');
}
TargetChooserFactory tf; TargetChooserFactory tf;
TargetChooser * tc = tf.createTargetChooser(theType.c_str(),NULL); TargetChooser * tc = tf.createTargetChooser(theType.c_str(),NULL);
GameObserver * game = game->GetInstance(); GameObserver * game = game->GetInstance();
@@ -4090,6 +4094,7 @@ public:
AUpkeep(int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _cost, int _tap = 0, int restrictions = 0, int _phase = AUpkeep(int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _cost, int _tap = 0, int restrictions = 0, int _phase =
Constants::MTG_PHASE_UPKEEP, int _once = 0,bool Cumulative = false); Constants::MTG_PHASE_UPKEEP, int _once = 0,bool Cumulative = false);
int receiveEvent(WEvent * event);
void Update(float dt); void Update(float dt);
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL); int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
int resolve(); int resolve();
+15 -4
View File
@@ -2921,6 +2921,21 @@ AUpkeep::AUpkeep(int _id, MTGCardInstance * card, MTGAbility * a, ManaCost * _co
aType = MTGAbility::UPCOST; aType = MTGAbility::UPCOST;
} }
int AUpkeep::receiveEvent(WEvent * event)
{
if (WEventPhaseChange* pe = dynamic_cast<WEventPhaseChange*>(event))
{
if (Constants::MTG_PHASE_DRAW == pe->to->id)
{
if (source->controller() == game->currentPlayer && once < 2 && paidThisTurn < 1)
{
ability->resolve();
}
}
}
return 1;
}
void AUpkeep::Update(float dt) void AUpkeep::Update(float dt)
{ {
// once: 0 means always go off, 1 means go off only once, 2 means go off only once and already has. // once: 0 means always go off, 1 means go off only once, 2 means go off only once and already has.
@@ -2944,10 +2959,6 @@ void AUpkeep::Update(float dt)
if(currentage) if(currentage)
paidThisTurn -= currentage; paidThisTurn -= currentage;
} }
else if (newPhase == phase + 1 && paidThisTurn < 1)
{
ability->resolve();
}
if (newPhase == phase + 1 && once) if (newPhase == phase + 1 && once)
once = 2; once = 2;
} }
+9 -7
View File
@@ -1136,18 +1136,20 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
if (found != string::npos) if (found != string::npos)
{ {
SAFE_DELETE(tc); SAFE_DELETE(tc);
string s1 = s.substr(0, found); vector<string> multiEffects = split(s,'&');
string s2 = s.substr(found + 2);
MultiAbility * multi = NEW MultiAbility(id, card, target, NULL, NULL); MultiAbility * multi = NEW MultiAbility(id, card, target, NULL, NULL);
MTGAbility * a1 = parseMagicLine(s1, id, spell, card, activated); for(unsigned int i = 0;i < multiEffects.size();i++)
MTGAbility * a2 = parseMagicLine(s2, id, spell, card, activated); {
multi->Add(a1); if(!multiEffects[i].empty())
multi->Add(a2); {
MTGAbility * addAbility = parseMagicLine(multiEffects[i], id, spell, card, activated);
multi->Add(addAbility);
}
}
multi->oneShot = 1; multi->oneShot = 1;
return multi; return multi;
} }
//rather dirty way to stop thises and lords from conflicting with each other. //rather dirty way to stop thises and lords from conflicting with each other.
size_t lord = string::npos; size_t lord = string::npos;
for (size_t j = 0; j < kLordKeywordsCount; ++j) for (size_t j = 0; j < kLordKeywordsCount; ++j)