Fix some cppcheck warnings (mostly style and postfix vs prefix iteration)
This commit is contained in:
@@ -307,14 +307,13 @@ bool AIHints::canWeCombo(GameObserver* observer,MTGCardInstance * card,AIPlayerB
|
||||
TargetChooserFactory tfc(observer);
|
||||
TargetChooser * hintTc = NULL;
|
||||
bool gotCombo = false;
|
||||
int comboPartsHold = 0;
|
||||
int comboPartsUntil = 0;
|
||||
int comboPartsRestriction = 0;
|
||||
|
||||
for(unsigned int i = 0; i < hints.size();i++)
|
||||
{
|
||||
comboPartsHold = 0;
|
||||
comboPartsUntil = 0;
|
||||
comboPartsRestriction = 0;
|
||||
int comboPartsHold = 0;
|
||||
int comboPartsUntil = 0;
|
||||
int comboPartsRestriction = 0;
|
||||
|
||||
if(gotCombo)
|
||||
return gotCombo;//because more then one might be possible at any time.
|
||||
if (hints[i]->hold.size())
|
||||
|
||||
@@ -90,13 +90,13 @@ int AIMomirPlayer::computeActions()
|
||||
}
|
||||
else if (p == this && observer->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0)
|
||||
{ //standard actions
|
||||
CardDescriptor cd;
|
||||
MTGCardInstance * card = NULL;
|
||||
|
||||
switch (currentGamePhase)
|
||||
{
|
||||
case MTG_PHASE_FIRSTMAIN:
|
||||
{
|
||||
CardDescriptor cd;
|
||||
MTGCardInstance * card = NULL;
|
||||
ManaCost * potentialMana = getPotentialMana();
|
||||
int converted = potentialMana->getConvertedCost();
|
||||
SAFE_DELETE(potentialMana);
|
||||
@@ -118,15 +118,12 @@ int AIMomirPlayer::computeActions()
|
||||
}
|
||||
momir();
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case MTG_PHASE_SECONDMAIN:
|
||||
selectAbility();
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
return AIPlayerBaka::computeActions();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return AIPlayerBaka::computeActions();
|
||||
|
||||
@@ -97,7 +97,7 @@ int AIAction::clickMultiAct(vector<Targetable*>& actionTargets)
|
||||
ite = actionTargets.erase(ite);
|
||||
continue;
|
||||
}
|
||||
ite++;
|
||||
++ite;
|
||||
}
|
||||
|
||||
//shuffle to make it less predictable, otherwise ai will always seem to target from right to left. making it very obvious.
|
||||
@@ -167,7 +167,7 @@ int AIPlayer::clickMultiTarget(TargetChooser * tc, vector<Targetable*>& potentia
|
||||
ite = potentialTargets.erase(ite);
|
||||
continue;
|
||||
}
|
||||
ite++;
|
||||
++ite;
|
||||
}
|
||||
|
||||
randomGenerator.random_shuffle(potentialTargets.begin(), potentialTargets.end());
|
||||
|
||||
@@ -134,10 +134,9 @@ int OrderedAIAction::getEfficiency()
|
||||
if (!target)
|
||||
break;
|
||||
|
||||
bool NeedPreventing;
|
||||
NeedPreventing = false;
|
||||
if (currentPhase == MTG_PHASE_COMBATBLOCKERS)
|
||||
{
|
||||
bool NeedPreventing = false;
|
||||
MTGCardInstance * nextOpponent = target->getNextOpponent();
|
||||
if(!nextOpponent)
|
||||
break;
|
||||
@@ -152,12 +151,10 @@ int OrderedAIAction::getEfficiency()
|
||||
//small bonus added for the poor 1/1s, if we can save them, we will unless something else took precidence.
|
||||
//note is the target is being blocked or blocking a creature with wither or deathtouch, it is not even considered for preventing as it is a waste.
|
||||
//if its combat blockers, it is being blocked or blocking, and has less prevents the the amount of damage it will be taking, the effeincy is increased slightly and totalled by the danger rank multiplier for final result.
|
||||
int calculateAfterDamage = 0;
|
||||
int damages = 0;
|
||||
if((target->defenser || target->blockers.size()) && target->controller() == p)
|
||||
{
|
||||
damages = nextOpponent->power;
|
||||
calculateAfterDamage = int(target->toughness - damages);
|
||||
int damages = nextOpponent->power;
|
||||
int calculateAfterDamage = target->toughness - damages;
|
||||
if((calculateAfterDamage + target->preventable) > 0)
|
||||
{
|
||||
efficiency = 0;
|
||||
@@ -588,8 +585,7 @@ int OrderedAIAction::getEfficiency()
|
||||
efficiency = 80;
|
||||
if(atc->name.length() && atc->sabilities.length() && atc->types.size() && p->game->inPlay->findByName(atc->name))
|
||||
{
|
||||
list<int>::iterator it;
|
||||
for (it = atc->types.begin(); it != atc->types.end(); it++)
|
||||
for (list<int>::const_iterator it = atc->types.begin(); it != atc->types.end(); ++it)
|
||||
{
|
||||
if(*it == Subtypes::TYPE_LEGENDARY)//ai please stop killing voja!!! :P
|
||||
efficiency = 0;
|
||||
@@ -978,11 +974,10 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
}
|
||||
}
|
||||
ManaCostHybrid * hybridCost;
|
||||
int hyb;
|
||||
hyb = 0;
|
||||
hybridCost = cost->getHybridCost(0);
|
||||
if(hybridCost)
|
||||
{
|
||||
int hyb = 0;
|
||||
while ((hybridCost = cost->getHybridCost(hyb)) != NULL)
|
||||
{
|
||||
//here we try to find one of the colors in the hybrid cost, it is done 1 at a time unfortunately
|
||||
@@ -1046,7 +1041,6 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
{
|
||||
|
||||
ManaCost * withKickerCost= NEW ManaCost(cost->getKicker());
|
||||
int canKick = 0;
|
||||
vector<MTGAbility*>kickerPayment;
|
||||
bool keepLooking = true;
|
||||
while(keepLooking)
|
||||
@@ -1061,7 +1055,6 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
payments.push_back(kickerPayment[w]);
|
||||
}
|
||||
}
|
||||
canKick += 1;
|
||||
keepLooking = cost->getKicker()->isMulti;
|
||||
}
|
||||
else
|
||||
@@ -1297,12 +1290,10 @@ int AIPlayerBaka::createAbilityTargets(MTGAbility * a, MTGCardInstance * c, Rank
|
||||
|
||||
TargetChooser * AIPlayerBaka::GetComboTc( GameObserver * observer,TargetChooser * tc)
|
||||
{
|
||||
TargetChooser * gathertc = NULL;
|
||||
TargetChooserFactory tcf(observer);
|
||||
map<string, string>::iterator it = comboHint->cardTargets.begin();
|
||||
for(map<string, string>::iterator it = comboHint->cardTargets.begin();it != comboHint->cardTargets.end();it++)
|
||||
for(map<string, string>::iterator it = comboHint->cardTargets.begin();it != comboHint->cardTargets.end();++it)
|
||||
{
|
||||
gathertc = tcf.createTargetChooser(it->first.c_str(),tc->source);
|
||||
TargetChooser *gathertc = tcf.createTargetChooser(it->first.c_str(),tc->source);
|
||||
gathertc->setAllZones();
|
||||
if(gathertc->canTarget(tc->source))
|
||||
{
|
||||
@@ -1402,7 +1393,6 @@ int AIPlayerBaka::selectAbility()
|
||||
MTGCardInstance * card = game->inPlay->cards[j];
|
||||
if(a->getCost() && !a->isReactingToClick(card, totalPotentialMana))//for performance reason only look for specific mana if the payment couldnt be made with potential.
|
||||
{
|
||||
abilityPayment = vector<MTGAbility*>();
|
||||
abilityPayment = canPayMana(card,a->getCost());
|
||||
}
|
||||
if (a->isReactingToClick(card, totalPotentialMana) || abilityPayment.size())
|
||||
@@ -1410,10 +1400,9 @@ int AIPlayerBaka::selectAbility()
|
||||
if(a->getCost() && a->getCost()->hasX() && totalPotentialMana->getConvertedCost() < a->getCost()->getConvertedCost()+1)
|
||||
continue;
|
||||
//don't even bother to play an ability with {x} if you can't even afford x=1.
|
||||
ManaCost * fullPayment = NULL;
|
||||
if (abilityPayment.size())
|
||||
{
|
||||
fullPayment = NEW ManaCost();
|
||||
ManaCost *fullPayment = NEW ManaCost();
|
||||
for(int ch = 0; ch < int(abilityPayment.size());ch++)
|
||||
{
|
||||
AManaProducer * ampp = dynamic_cast<AManaProducer*> (abilityPayment[ch]);
|
||||
@@ -1525,7 +1514,7 @@ int AIPlayerBaka::chooseTarget(TargetChooser * _tc, Player * forceTarget,MTGCard
|
||||
}
|
||||
//Make sure we own the decision to choose the targets
|
||||
assert(tc->Owner == observer->currentlyActing());
|
||||
if (tc && tc->Owner != observer->currentlyActing())
|
||||
if (tc->Owner != observer->currentlyActing())
|
||||
{
|
||||
observer->currentActionPlayer = tc->Owner;
|
||||
//this is a hack, but if we hit this condition we are locked in a infinate loop
|
||||
@@ -1905,12 +1894,11 @@ MTGCardInstance * AIPlayerBaka::activateCombo()
|
||||
{
|
||||
if(!comboHint)
|
||||
return NULL;
|
||||
TargetChooser * hintTc = NULL;
|
||||
TargetChooserFactory tfc(observer);
|
||||
ManaCost * totalCost = ManaCost::parseManaCost(comboHint->manaNeeded);
|
||||
for(unsigned int k = 0;k < comboHint->casting.size(); k++)
|
||||
{
|
||||
hintTc = tfc.createTargetChooser(comboHint->casting[k],nextCardToPlay);
|
||||
TargetChooser *hintTc = tfc.createTargetChooser(comboHint->casting[k],nextCardToPlay);
|
||||
int combohand = game->hand->cards.size();
|
||||
for(int j = 0; j < combohand;j++)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ AIStats::AIStats(Player * _player, char * _filename)
|
||||
AIStats::~AIStats()
|
||||
{
|
||||
list<AIStat *>::iterator it;
|
||||
for (it = stats.begin(); it != stats.end(); it++)
|
||||
for (it = stats.begin(); it != stats.end(); ++it)
|
||||
{
|
||||
AIStat * stat = *it;
|
||||
delete stat;
|
||||
@@ -115,7 +115,7 @@ bool AIStats::isInTop(MTGCardInstance * card, unsigned int max, bool tooSmallCou
|
||||
MTGCard * source = card->model;
|
||||
int id = source->getMTGId();
|
||||
list<AIStat *>::iterator it;
|
||||
for (it = stats.begin(); it != stats.end(); it++)
|
||||
for (it = stats.begin(); it != stats.end(); ++it)
|
||||
{
|
||||
if (n >= max)
|
||||
return false;
|
||||
@@ -135,7 +135,7 @@ AIStat * AIStats::find(MTGCard * source)
|
||||
{
|
||||
int id = source->getMTGId();
|
||||
list<AIStat *>::iterator it;
|
||||
for (it = stats.begin(); it != stats.end(); it++)
|
||||
for (it = stats.begin(); it != stats.end(); ++it)
|
||||
{
|
||||
AIStat * stat = *it;
|
||||
if (stat->source == id)
|
||||
@@ -174,7 +174,7 @@ void AIStats::save()
|
||||
{
|
||||
char writer[128];
|
||||
list<AIStat *>::iterator it;
|
||||
for (it = stats.begin(); it != stats.end(); it++)
|
||||
for (it = stats.begin(); it != stats.end(); ++it)
|
||||
{
|
||||
AIStat * stat = *it;
|
||||
if (stat->value > 0)
|
||||
|
||||
@@ -165,8 +165,6 @@ void ActionLayer::Update(float dt)
|
||||
if (cantCancel)
|
||||
{
|
||||
ActionElement * ae = isWaitingForAnswer();
|
||||
int countTargets = 0;
|
||||
int maxTargets = 0;
|
||||
if(ae && ae->getActionTc())
|
||||
{
|
||||
if (!ae->getActionTc()->validTargetsExist())
|
||||
@@ -175,8 +173,8 @@ void ActionLayer::Update(float dt)
|
||||
cancelCurrentAction();
|
||||
return;
|
||||
}
|
||||
countTargets = ae->getActionTc()->countValidTargets();
|
||||
maxTargets = ae->getActionTc()->maxtargets;
|
||||
int countTargets = ae->getActionTc()->countValidTargets();
|
||||
int maxTargets = ae->getActionTc()->maxtargets;
|
||||
if (countTargets < maxTargets)
|
||||
{
|
||||
/*
|
||||
@@ -440,10 +438,9 @@ void ActionLayer::setCustomMenuObject(Targetable * object, bool must,vector<MTGA
|
||||
if(abilities.size())
|
||||
{
|
||||
abilitiesMenu->isMultipleChoice = true;
|
||||
ActionElement * currentAction = NULL;
|
||||
for(int w = 0; w < int(abilities.size());w++)
|
||||
{
|
||||
currentAction = (ActionElement*)abilities[w];
|
||||
ActionElement *currentAction = (ActionElement*)abilities[w];
|
||||
currentActionCard = (MTGCardInstance*)abilities[0]->target;
|
||||
abilitiesMenu->Add(mObjects.size()-1, currentAction->getMenuText(),"",false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user