fixed last check in. Test suite passes. Added comments on possible null pointer exceptions.
Updated XCode project file to include AIPlayerBaka classes. Added test suite to iOS build
This commit is contained in:
@@ -87,7 +87,6 @@ int AIAction::clickMultiAct(vector<Targetable*>& actionTargets)
|
||||
{
|
||||
GameObserver * g = owner->getObserver();
|
||||
TargetChooser * tc = g->getCurrentTargetChooser();
|
||||
|
||||
if(!tc) return 0;
|
||||
for(size_t f = 0;f < actionTargets.size();f++)
|
||||
{
|
||||
@@ -198,7 +197,6 @@ int AIPlayer::clickSingleTarget(TargetChooser * tc, vector<Targetable*>& potenti
|
||||
{
|
||||
MTGCardInstance * card = ((MTGCardInstance *) potentialTargets[i]);
|
||||
clickstream.push(NEW AIAction(this, card));
|
||||
chosenCard = card;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@ int OrderedAIAction::getEfficiency(AADamager * aad)
|
||||
if(p == target->controller())
|
||||
return 0;
|
||||
|
||||
if (aad->getDamage() >= dTarget->toughness)
|
||||
if (dTarget && aad && (aad->getDamage() >= dTarget->toughness))
|
||||
return 100;
|
||||
|
||||
if (dTarget->toughness)
|
||||
if (dTarget && dTarget->toughness)
|
||||
return (50 * aad->getDamage()) / dTarget->toughness;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -3519,18 +3519,25 @@ void APhaseAction::Update(float dt)
|
||||
if(newPhase == phase && next )
|
||||
{
|
||||
MTGCardInstance * _target = NULL;
|
||||
bool isTargetable = false;
|
||||
|
||||
if(target)
|
||||
_target = (MTGCardInstance *) target;
|
||||
if(!sAbility.size() || (!target || _target != this->source))
|
||||
{
|
||||
_target = static_cast<MTGCardInstance *>(target);
|
||||
isTargetable = (_target && !_target->currentZone && _target != this->source);
|
||||
}
|
||||
|
||||
if(!sAbility.size() || (!target || isTargetable))
|
||||
{
|
||||
this->forceDestroy = 1;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
while(_target->next)
|
||||
while(_target && _target->next)
|
||||
_target = _target->next;
|
||||
}
|
||||
|
||||
AbilityFactory af(game);
|
||||
MTGAbility * ability = af.parseMagicLine(sAbility, abilityId, NULL, _target);
|
||||
|
||||
|
||||
@@ -392,7 +392,7 @@ void StatsWrapper::updateStats(DeckDataWrapper *myDeck)
|
||||
this->totalManaCost = 0;
|
||||
this->totalCreatureCost = 0;
|
||||
this->totalSpellCost = 0;
|
||||
MTGCard * current = myDeck->getCard();
|
||||
MTGCard * current = NULL;
|
||||
|
||||
// Clearing arrays
|
||||
for (int i = 0; i <= Constants::STATS_MAX_MANA_COST; i++)
|
||||
|
||||
@@ -568,9 +568,14 @@ CounterCost * CounterCost::clone() const
|
||||
CounterCost * ec = NEW CounterCost(*this);
|
||||
if (tc)
|
||||
ec->tc = tc->clone();
|
||||
|
||||
if (counter)
|
||||
ec->counter = NEW Counter(counter->target, counter->name.c_str(), counter->power, counter->toughness);
|
||||
ec->counter->nb = counter->nb;
|
||||
|
||||
//TODO: counter can be NULL at this point, what do we set ec->counter->nb to if it is?
|
||||
if (ec->counter != NULL)
|
||||
ec->counter->nb = counter->nb;
|
||||
|
||||
return ec;
|
||||
}
|
||||
|
||||
|
||||
@@ -932,6 +932,7 @@ int GameObserver::cardClick(MTGCardInstance * card, Targetable * object)
|
||||
|
||||
if (ORDER == combatStep)
|
||||
{
|
||||
//TODO it is possible at this point that card is NULL. if so, what do we return since card->defenser would result in a crash?
|
||||
card->defenser->raiseBlockerRankOrder(card);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#include "NetworkPlayer.h"
|
||||
#endif
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
#if defined (WIN32) || defined (LINUX) || defined(IOS)
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -747,7 +747,6 @@ void GameStateMenu::Render()
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
PIXEL_TYPE colors[] = {
|
||||
|
||||
ARGB(255,3,3,0), ARGB(255,8,8,0), ARGB(255,21,21,10), ARGB(255,50,50,30), };
|
||||
|
||||
@@ -759,7 +759,7 @@ void MTGLibrary::shuffleTopToBottom(int nbcards)
|
||||
{
|
||||
_cards[i] = cards[i - nb_cards];
|
||||
}
|
||||
// Logic error here: the final value of cards[i] will always be garbage. possible optimization: use vectors to push and pop
|
||||
//TODO Logic error here: the final value of cards[i] will always be garbage. possible optimization: use vectors to push and pop
|
||||
for (int i = 0; i < nb_cards; i++)
|
||||
{
|
||||
cards[i] = _cards[i];
|
||||
@@ -845,6 +845,7 @@ MTGGameZone * MTGGameZone::intToZone(GameObserver *g, int zoneId, MTGCardInstanc
|
||||
p = source->controller();
|
||||
if (!target)
|
||||
{
|
||||
//TODO source may be NULL, need to handle the case when it is NULL. method declaration has NULL being default value of source and target.
|
||||
if(source->target)
|
||||
{
|
||||
//bug case, this is a patchwork fix for now
|
||||
|
||||
@@ -1123,9 +1123,9 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card)
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
|
||||
int payResult = player->getManaPool()->pay(card->getManaCost()->morph);
|
||||
player->getManaPool()->pay(card->getManaCost()->morph);
|
||||
card->getManaCost()->morph->doPayExtra();
|
||||
payResult = ManaCost::MANA_PAID_WITH_MORPH;
|
||||
int payResult = ManaCost::MANA_PAID_WITH_MORPH;
|
||||
//if morph has a extra payment thats set, this code pays it.the if statement is 100% needed as it would cause a crash on cards that dont have the morph cost.
|
||||
if (morph)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
vector<Rules *> Rules::RulesList = vector<Rules *>();
|
||||
|
||||
//Sorting by dissplayName
|
||||
//Sorting by displayName
|
||||
struct RulesMenuCmp{
|
||||
bool operator()(const Rules * a,const Rules * b) const{
|
||||
return a->displayName < b->displayName;
|
||||
@@ -305,6 +305,7 @@ Player * Rules::initPlayer(GameObserver *g, int playerId)
|
||||
return loadPlayerRandom(g, isAI, GAME_TYPE_RANDOM2);
|
||||
}
|
||||
}
|
||||
//TODO p may still be NULL, what do we do to handle this? Above switch has no default case to handle the case where p is NULL
|
||||
p->phaseRing = initState.playerData[playerId].player->phaseRing;
|
||||
p->offerInterruptOnPhase = initState.playerData[playerId].player->offerInterruptOnPhase;
|
||||
return p;
|
||||
@@ -345,8 +346,10 @@ void Rules::initPlayers(GameObserver *g)
|
||||
if(p && g->getPlayersNumber() < 2)
|
||||
g->players.push_back(p);
|
||||
MTGDeck * deck = buildDeck(i);
|
||||
|
||||
if (deck)
|
||||
{
|
||||
// TODO: p may be NULL, initPlayer(g, i) may return NULL, what do we do in this case?
|
||||
p->game->initDeck(deck);
|
||||
SAFE_DELETE(deck);
|
||||
p->game->setOwner(p);
|
||||
|
||||
@@ -727,11 +727,17 @@ bool TargetChooser::canTarget(Targetable * target,bool withoutProtections)
|
||||
tempcard = tempcard->previous;
|
||||
}
|
||||
}
|
||||
|
||||
if(source && ((source->hasSubtype(Subtypes::TYPE_AURA) || source->hasSubtype(Subtypes::TYPE_EQUIPMENT)) && source->target && source->target == card && source->target->isPhased && targetter->target == card))
|
||||
return true;
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//this is kinda cheating but by default we let auras and equipments always continue to target a phased creature.
|
||||
else if(card->isPhased)
|
||||
return false;
|
||||
else if (card && card->isPhased)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (source && targetter && card->isInPlay(observer) && !withoutProtections)
|
||||
{
|
||||
if (card->has(Constants::SHROUD)) return false;
|
||||
|
||||
@@ -899,13 +899,12 @@ bool WGuiSplit::yieldFocus()
|
||||
}
|
||||
|
||||
//WGuiMenu
|
||||
WGuiMenu::WGuiMenu(JButton next = JGE_BTN_RIGHT, JButton prev = JGE_BTN_LEFT, bool m, WSyncable * syncme) :
|
||||
WGuiItem("")
|
||||
WGuiMenu::WGuiMenu(JButton next, JButton prev, bool dPad, WSyncable * syncme) : WGuiItem("")
|
||||
{
|
||||
buttonNext = next;
|
||||
buttonPrev = prev;
|
||||
currentItem = -1;
|
||||
mDPad = m;
|
||||
mDPad = dPad;
|
||||
sync = syncme;
|
||||
held = JGE_BTN_NONE;
|
||||
}
|
||||
@@ -1100,7 +1099,6 @@ bool WGuiMenu::nextItem()
|
||||
|
||||
while (potential < nbitems - 1 && items[potential]->Selectable() == false)
|
||||
potential++;
|
||||
|
||||
if (potential != currentItem && (!now || now->Leaving(buttonNext)))
|
||||
{
|
||||
currentItem = potential;
|
||||
@@ -1130,9 +1128,9 @@ bool WGuiMenu::prevItem()
|
||||
|
||||
while (potential > 0 && items[potential]->Selectable() == false)
|
||||
potential--;
|
||||
if (potential < 0 || !items[potential]->Selectable())
|
||||
potential = -1;
|
||||
else if (potential != currentItem && (!now || now->Leaving(buttonNext)))
|
||||
|
||||
if ( (!(potential < 0 || !items[potential]->Selectable()))
|
||||
&& (potential != currentItem && (!now || now->Leaving(buttonNext))))
|
||||
{
|
||||
currentItem = potential;
|
||||
items[currentItem]->Entering(buttonPrev);
|
||||
|
||||
Reference in New Issue
Block a user