refactored the typemin: cast restriction, there was a reported bug with it and while debugging it screamed refactor.

so i converted it from string comparisons and counting the battlefield..into targetchoosers with declarable operator.
simplified the code from the mess it was before into something alot easier to card code with.

example before:
mytypemin:less type(land),opponenttypemin:* type(land)
becomes
type(land|mybattlefield)~lessthan~type(land|opponentbattlefield)

the new syntax is:
type(targetchooser)~operator~number
type(targetchooser)~operator~type(targetchooser)
the operator are:
morethan
lessthan
equalto
This commit is contained in:
omegablast2002@yahoo.com
2011-07-07 11:39:06 +00:00
parent 463a64521f
commit f88178f2cf
3 changed files with 60 additions and 54 deletions

View File

@@ -832,6 +832,28 @@ bool TargetChooser::validTargetsExist()
return false;
}
int TargetChooser::countValidTargets()
{
int result = 0;
for (int i = 0; i < 2; ++i)
{
Player *p = GameObserver::GetInstance()->players[i];
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->exile };
for (int k = 0; k < 5; k++)
{
MTGGameZone * z = zones[k];
if (targetsZone(z))
{
for (int j = 0; j < z->nb_cards; j++)
{
if (canTarget(z->cards[j])) result++;
}
}
}
}
return result;
}
bool TargetChooser::equals(TargetChooser * tc)
{