more fixes from the review...

This commit is contained in:
omegablast2002@yahoo.com
2011-01-22 16:48:55 +00:00
parent 27e60fc605
commit 07802134e8
10 changed files with 59 additions and 61 deletions
+7 -7
View File
@@ -223,7 +223,7 @@ public:
if(source->isPhased) return 0; if(source->isPhased) return 0;
WEventZoneChange * e = dynamic_cast<WEventZoneChange*> (event); WEventZoneChange * e = dynamic_cast<WEventZoneChange*> (event);
if (!e) return 0; if (!e) return 0;
if(sourceUntapped == true && source->isTapped() == 1) if(sourceUntapped && source->isTapped() == 1)
return 0; return 0;
if(activeTrigger == false) if(activeTrigger == false)
return 0; return 0;
@@ -239,7 +239,7 @@ public:
{ {
return 0; return 0;
} }
if(once == true && activeTrigger == true) if(once && activeTrigger)
activeTrigger = false; activeTrigger = false;
return 1; return 1;
} }
@@ -437,7 +437,7 @@ public:
if(source->isPhased) return 0; if(source->isPhased) return 0;
WEventCardAttacked * e = dynamic_cast<WEventCardAttacked *> (event); WEventCardAttacked * e = dynamic_cast<WEventCardAttacked *> (event);
if (!e) return 0; if (!e) return 0;
if (sourceUntapped == true && source->isTapped() == 1) if (sourceUntapped && source->isTapped() == 1)
return 0; return 0;
if (e->card->didattacked < 1) return 0; if (e->card->didattacked < 1) return 0;
if (!tc->canTarget(e->card)) return 0; if (!tc->canTarget(e->card)) return 0;
@@ -522,7 +522,7 @@ public:
//if(e->card->didblocked < 1) return 0; //if(e->card->didblocked < 1) return 0;
if (fromTc && !fromTc->canTarget(e->card->getNextOpponent())) return 0; if (fromTc && !fromTc->canTarget(e->card->getNextOpponent())) return 0;
if (!tc->canTarget(e->card)) return 0; if (!tc->canTarget(e->card)) return 0;
if(once == true && activeTrigger == true) if(once && activeTrigger )
activeTrigger = false; activeTrigger = false;
return 1; return 1;
} }
@@ -668,7 +668,7 @@ public:
if(source->isPhased) return 0; if(source->isPhased) return 0;
WEventDamage * e = dynamic_cast<WEventDamage *> (event); WEventDamage * e = dynamic_cast<WEventDamage *> (event);
if (!e) return 0; if (!e) return 0;
if (sourceUntapped == true && source->isTapped() == 1) if (sourceUntapped && source->isTapped() == 1)
return 0; return 0;
if (!tc->canTarget(e->damage->target)) return 0; if (!tc->canTarget(e->damage->target)) return 0;
if (fromTc && !fromTc->canTarget(e->damage->source)) return 0; if (fromTc && !fromTc->canTarget(e->damage->source)) return 0;
@@ -715,7 +715,7 @@ public:
if(source->isPhased) return 0; if(source->isPhased) return 0;
WEventLife * e = dynamic_cast<WEventLife *> (event); WEventLife * e = dynamic_cast<WEventLife *> (event);
if (!e) return 0; if (!e) return 0;
if (sourceUntapped == true && source->isTapped() == 1) if (sourceUntapped && source->isTapped() == 1)
return 0; return 0;
if (!tc->canTarget(e->player)) return 0; if (!tc->canTarget(e->player)) return 0;
if (fromTc && !fromTc->canTarget(e->player)) return 0; if (fromTc && !fromTc->canTarget(e->player)) return 0;
@@ -5737,7 +5737,7 @@ public:
{ {
WEventDamage * e = (WEventDamage *) event; WEventDamage * e = (WEventDamage *) event;
Damage * d = e->damage; Damage * d = e->damage;
if (combatonly == true && e->damage->typeOfDamage != DAMAGE_COMBAT) if (combatonly && e->damage->typeOfDamage != DAMAGE_COMBAT)
return 0; return 0;
MTGCardInstance * card = d->source; MTGCardInstance * card = d->source;
if (d->damage > 0 && card && (card == source || card == source->target)) if (d->damage > 0 && card && (card == source || card == source->target))
-2
View File
@@ -419,7 +419,5 @@ class AManaProducer: public ActivatedAbilityTP{
virtual AManaProducer * clone() const; virtual AManaProducer * clone() const;
}; };
#include "MTGCardInstance.h"
#endif #endif
+7 -7
View File
@@ -110,7 +110,7 @@ bool AIPlayer::tapLandsForMana(ManaCost * cost, MTGCardInstance * target)
MTGCardInstance * card = amp->source; MTGCardInstance * card = amp->source;
if (card == target) if (card == target)
used[card] = true; //http://code.google.com/p/wagic/issues/detail?id=76 used[card] = true; //http://code.google.com/p/wagic/issues/detail?id=76
if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() == 1) if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() >= 1)
{ {
used[card] = true; used[card] = true;
int doTap = 1; int doTap = 1;
@@ -291,7 +291,7 @@ int AIAction::getEfficiency()
{ {
if ((target->defenser || target->blockers.size()) && target->preventable < target->getNextOpponent()->power) if ((target->defenser || target->blockers.size()) && target->preventable < target->getNextOpponent()->power)
NeedPreventing = true; NeedPreventing = true;
if (p == target->controller() && target->controller()->isAI() && NeedPreventing == true && !(target->getNextOpponent()->has(Constants::DEATHTOUCH) if (p == target->controller() && target->controller()->isAI() && NeedPreventing && !(target->getNextOpponent()->has(Constants::DEATHTOUCH)
|| target->getNextOpponent()->has(Constants::WITHER))) || target->getNextOpponent()->has(Constants::WITHER)))
{ {
efficiency = 20 * (target->DangerRanking());//increase this chance to be used in combat if the creature blocking/blocked could kill the creature this chance is taking into consideration how good the creature is, best creature will always be the first "saved".. efficiency = 20 * (target->DangerRanking());//increase this chance to be used in combat if the creature blocking/blocked could kill the creature this chance is taking into consideration how good the creature is, best creature will always be the first "saved"..
@@ -1189,15 +1189,15 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
{ {
if (!CanHandleCost(card->getManaCost())) if (!CanHandleCost(card->getManaCost()))
continue; continue;
if (card->hasType(Subtypes::TYPE_CREATURE) && this->castrestrictedcreature == true && this->castrestrictedspell == true) if (card->hasType(Subtypes::TYPE_CREATURE) && this->castrestrictedcreature && this->castrestrictedspell )
continue; continue;
if (card->hasType(Subtypes::TYPE_ENCHANTMENT) && this->castrestrictedspell == true) if (card->hasType(Subtypes::TYPE_ENCHANTMENT) && this->castrestrictedspell )
continue; continue;
if (card->hasType(Subtypes::TYPE_ARTIFACT) && this->castrestrictedspell == true) if (card->hasType(Subtypes::TYPE_ARTIFACT) && this->castrestrictedspell )
continue; continue;
if (card->hasType(Subtypes::TYPE_SORCERY) && this->castrestrictedspell == true) if (card->hasType(Subtypes::TYPE_SORCERY) && this->castrestrictedspell )
continue; continue;
if (card->hasType(Subtypes::TYPE_INSTANT) && this->castrestrictedspell == true) if (card->hasType(Subtypes::TYPE_INSTANT) && this->castrestrictedspell )
continue; continue;
if (card->hasType(Subtypes::TYPE_LAND) && !this->canPutLandsIntoPlay) if (card->hasType(Subtypes::TYPE_LAND) && !this->canPutLandsIntoPlay)
continue; continue;
+14 -14
View File
@@ -387,7 +387,7 @@ AARemoveAllCounter::AARemoveAllCounter(int id, MTGCardInstance * source, MTGCard
if (target) if (target)
{ {
MTGCardInstance * _target = (MTGCardInstance *) target; MTGCardInstance * _target = (MTGCardInstance *) target;
if (all == true) if (all )
{ {
for(int amount = 0;amount < _target->counters->mCount;amount++) for(int amount = 0;amount < _target->counters->mCount;amount++)
{ {
@@ -914,13 +914,13 @@ int AADynamic::resolve()
case 0: case 0:
sourceamount = ((MTGCardInstance *) source)->power; sourceamount = ((MTGCardInstance *) source)->power;
targetamount = ((MTGCardInstance *) _target)->power; targetamount = ((MTGCardInstance *) _target)->power;
if(eachother == true) if(eachother )
sourceamount = ((MTGCardInstance *) source)->power; sourceamount = ((MTGCardInstance *) source)->power;
break; break;
case 1: case 1:
sourceamount = ((MTGCardInstance *) source)->toughness; sourceamount = ((MTGCardInstance *) source)->toughness;
targetamount = ((MTGCardInstance *) _target)->toughness; targetamount = ((MTGCardInstance *) _target)->toughness;
if(eachother == true) if(eachother )
sourceamount = ((MTGCardInstance *) source)->toughness; sourceamount = ((MTGCardInstance *) source)->toughness;
break; break;
case 2: case 2:
@@ -1030,7 +1030,7 @@ int AADynamic::resolve()
game->mLayers->stackLayer()->addDamage((MTGCardInstance *)source, _target, sourceamount); game->mLayers->stackLayer()->addDamage((MTGCardInstance *)source, _target, sourceamount);
else else
game->mLayers->stackLayer()->addDamage((MTGCardInstance *)source, OriginalSrc, sourceamount); game->mLayers->stackLayer()->addDamage((MTGCardInstance *)source, OriginalSrc, sourceamount);
if(eachother == true) if(eachother )
{ {
game->mLayers->stackLayer()->addDamage((MTGCardInstance *)_target, source, targetamount); game->mLayers->stackLayer()->addDamage((MTGCardInstance *)_target, source, targetamount);
} }
@@ -2277,7 +2277,7 @@ int ATransformer::addToGame()
for (it = types.begin(); it != types.end(); it++) for (it = types.begin(); it != types.end(); it++)
{ {
if (remove == true) if (remove )
{ {
_target->removeType(*it); _target->removeType(*it);
} }
@@ -2297,13 +2297,13 @@ int ATransformer::addToGame()
for (it = oldcolors.begin(); it != oldcolors.end(); it++) for (it = oldcolors.begin(); it != oldcolors.end(); it++)
{ {
} }
if(newpowerfound == true) if(newpowerfound )
{ {
oldpower = _target->power; oldpower = _target->power;
_target->power += newpower; _target->power += newpower;
_target->power -= oldpower; _target->power -= oldpower;
} }
if(newtoughnessfound == true) if(newtoughnessfound )
{ {
oldtoughness = _target->toughness; oldtoughness = _target->toughness;
_target->addToToughness(newtoughness); _target->addToToughness(newtoughness);
@@ -2338,7 +2338,7 @@ int ATransformer::destroy()
{ {
_target->setColor(*it); _target->setColor(*it);
} }
if (remove == true) if (remove )
{ {
for (it = oldtypes.begin(); it != oldtypes.end(); it++) for (it = oldtypes.begin(); it != oldtypes.end(); it++)
{ {
@@ -2346,11 +2346,11 @@ int ATransformer::destroy()
_target->addType(*it); _target->addType(*it);
} }
} }
if(newpowerfound == true) if(newpowerfound )
{ {
_target->power = oldpower; _target->power = oldpower;
} }
if(newtoughnessfound == true) if(newtoughnessfound )
{ {
_target->toughness = oldtoughness; _target->toughness = oldtoughness;
} }
@@ -2429,13 +2429,13 @@ int AForeverTransformer::addToGame()
{ {
_target->basicAbilities[*it]++; _target->basicAbilities[*it]++;
} }
if(newpowerfound == true) if(newpowerfound )
{ {
oldpower = _target->power -= oldpower; oldpower = _target->power -= oldpower;
_target->power += newpower; _target->power += newpower;
_target->power -= oldpower; _target->power -= oldpower;
} }
if(newtoughnessfound == true) if(newtoughnessfound )
{ {
oldtoughness = _target->toughness; oldtoughness = _target->toughness;
_target->addToToughness(newtoughness); _target->addToToughness(newtoughness);
@@ -2795,7 +2795,7 @@ void AUpkeep::Update(float dt)
{ {
paidThisTurn = 0; paidThisTurn = 0;
} }
else if(newPhase == Constants::MTG_PHASE_UPKEEP && Cumulative == true) else if(newPhase == Constants::MTG_PHASE_UPKEEP && Cumulative )
{ {
source->counters->addCounter("age",0,0); source->counters->addCounter("age",0,0);
Counter * targetCounter = NULL; Counter * targetCounter = NULL;
@@ -2867,7 +2867,7 @@ void APhaseAction::Update(float dt)
{ {
if (newPhase != currentPhase) if (newPhase != currentPhase)
{ {
if(newPhase == phase && next == true) if(newPhase == phase && next )
{ {
MTGCardInstance * _target = (MTGCardInstance *) target; MTGCardInstance * _target = (MTGCardInstance *) target;
if (_target) if (_target)
+1 -1
View File
@@ -162,7 +162,7 @@ void CardGui::Render()
renderer->RenderQuad(shadow, actX + (actZ - 1) * 15, actY + (actZ - 1) * 15, actT, 28 * actZ / 16, 40 * actZ / 16); renderer->RenderQuad(shadow, actX + (actZ - 1) * 15, actY + (actZ - 1) * 15, actT, 28 * actZ / 16, 40 * actZ / 16);
} }
JQuad* extracostshadow = NULL; JQuad* extracostshadow = NULL;
if(card->isExtraCostTarget == true) if(card->isExtraCostTarget )
{ {
extracostshadow = WResourceManager::Instance()->GetQuad("extracostshadow"); extracostshadow = WResourceManager::Instance()->GetQuad("extracostshadow");
extracostshadow->SetColor(ARGB(static_cast<unsigned char>(actA)/2,100,0,0)); extracostshadow->SetColor(ARGB(static_cast<unsigned char>(actA)/2,100,0,0));
+1 -1
View File
@@ -371,7 +371,7 @@ int Ninja::isPaymentSet()
{ {
GameObserver * g = GameObserver::GetInstance(); GameObserver * g = GameObserver::GetInstance();
int currentPhase = g->getCurrentGamePhase(); int currentPhase = g->getCurrentGamePhase();
if (target && ((target->isAttacker() && target->blocked == true) || target->isAttacker() < 1 || currentPhase if (target && ((target->isAttacker() && target->blocked) || target->isAttacker() < 1 || currentPhase
!= Constants::MTG_PHASE_COMBATBLOCKERS)) != Constants::MTG_PHASE_COMBATBLOCKERS))
{ {
tc->removeTarget(target); tc->removeTarget(target);
+5 -5
View File
@@ -173,9 +173,9 @@ int MTGAbility::allowedToAltCast(MTGCardInstance * card,Player * player)
if(opponenttypemin < opponentmin && less == false && more == false) if(opponenttypemin < opponentmin && less == false && more == false)
return 0; return 0;
} }
if(less == true && more == false && opponenttypemin <= mytypemin) if(less && more == false && opponenttypemin <= mytypemin)
return 0; return 0;
if(less == false && more == true && opponenttypemin >= mytypemin) if(less == false && more && opponenttypemin >= mytypemin)
return 0; return 0;
return 1; return 1;
} }
@@ -4276,13 +4276,13 @@ TriggerAtPhase::TriggerAtPhase(int id, MTGCardInstance * source, Targetable * ta
int TriggerAtPhase::trigger() int TriggerAtPhase::trigger()
{ {
if(source->isPhased) return 0; if(source->isPhased) return 0;
if(lifelost == true && source->controller()->opponent()->lifeLostThisTurn < lifeamount) if(lifelost && source->controller()->opponent()->lifeLostThisTurn < lifeamount)
{ {
return 0; return 0;
} }
if (sourceUntapped == true && source->isTapped() == 1) if (sourceUntapped && source->isTapped() == 1)
return 0; return 0;
if (sourceTap == true && !source->isTapped()) if (sourceTap && !source->isTapped())
return 0; return 0;
if (testDestroy()) if (testDestroy())
return 0; // http://code.google.com/p/wagic/issues/detail?id=426 return 0; // http://code.google.com/p/wagic/issues/detail?id=426
+1 -1
View File
@@ -209,7 +209,7 @@ void MTGCardInstance::initMTGCI()
isBlueAndGreen = 1; isBlueAndGreen = 1;
if(this->hasColor(Constants::MTG_COLOR_RED) && this->hasColor(Constants::MTG_COLOR_WHITE)) if(this->hasColor(Constants::MTG_COLOR_RED) && this->hasColor(Constants::MTG_COLOR_WHITE))
isRedAndWhite = 1; isRedAndWhite = 1;
if(previous && previous->morphed == true && !turningOver) if(previous && previous->morphed && !turningOver)
{ {
morphed = true; morphed = true;
isMorphed = true; isMorphed = true;
+1 -1
View File
@@ -895,7 +895,7 @@ int MTGDeck::complete()
{ {
StypeIsNothing = true; StypeIsNothing = true;
} }
if (!StypeIsNothing == true) if (!StypeIsNothing )
{ {
if (cards.find(id) == cards.end()) if (cards.find(id) == cards.end())
{ {
+22 -22
View File
@@ -58,30 +58,30 @@ if(!allowedToCast(card,player))
#ifdef WIN32 #ifdef WIN32
cost->Dump(); cost->Dump();
#endif #endif
if (player->castrestrictedspell == true && !card->hasType("land")) if (player->castrestrictedspell && !card->hasType("land"))
{ {
return 0; return 0;
} }
if (player->onlyonecast == true && player->castcount >= 1) if (player->onlyonecast && player->castcount >= 1)
{ {
return 0; return 0;
} }
if (player->nospellinstant == true) if (player->nospellinstant)
{ {
return 0; return 0;
} }
if (player->onlyoneinstant == true) if (player->onlyoneinstant)
{ {
if (player->castcount >= 1) if (player->castcount >= 1)
{ {
return 0; return 0;
} }
} }
if (player->nocreatureinstant == true && card->hasType("creature")) if (player->nocreatureinstant && card->hasType("creature"))
{ {
return 0; return 0;
} }
if (player->castrestrictedcreature == true && card->hasType("creature")) if (player->castrestrictedcreature && card->hasType("creature"))
{ {
return 0; return 0;
} }
@@ -166,7 +166,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card)
game->targetChooser = NULL; game->targetChooser = NULL;
player->castedspellsthisturn += 1; player->castedspellsthisturn += 1;
player->opponent()->castedspellsthisturn += 1; player->opponent()->castedspellsthisturn += 1;
if (player->onlyonecast == true || player->onlyoneinstant == true) if (player->onlyonecast || player->onlyoneinstant)
{ {
player->castcount += 1; player->castcount += 1;
} }
@@ -176,7 +176,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card)
spell = game->mLayers->stackLayer()->addSpell(copy, NULL, spellCost, payResult, 0); spell = game->mLayers->stackLayer()->addSpell(copy, NULL, spellCost, payResult, 0);
player->castedspellsthisturn += 1; player->castedspellsthisturn += 1;
player->opponent()->castedspellsthisturn += 1; player->opponent()->castedspellsthisturn += 1;
if (player->onlyonecast == true || player->onlyoneinstant == true) if (player->onlyonecast || player->onlyoneinstant)
{ {
player->castcount += 1; player->castcount += 1;
} }
@@ -277,30 +277,30 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
ManaCost * cost = card->getManaCost(); ManaCost * cost = card->getManaCost();
cost->Dump(); cost->Dump();
#endif #endif
if (player->castrestrictedspell == true && !card->hasType("land")) if (player->castrestrictedspell && !card->hasType("land"))
{ {
return 0; return 0;
} }
if (player->onlyonecast == true && player->castcount >= 1) if (player->onlyonecast && player->castcount >= 1)
{ {
return 0; return 0;
} }
if (player->nospellinstant == true) if (player->nospellinstant )
{ {
return 0; return 0;
} }
if (player->onlyoneinstant == true) if (player->onlyoneinstant )
{ {
if (player->castcount >= 1) if (player->castcount >= 1)
{ {
return 0; return 0;
} }
} }
if (player->nocreatureinstant == true && card->hasType("creature")) if (player->nocreatureinstant && card->hasType("creature"))
{ {
return 0; return 0;
} }
if (player->castrestrictedcreature == true && card->hasType("creature")) if (player->castrestrictedcreature && card->hasType("creature"))
{ {
return 0; return 0;
} }
@@ -381,7 +381,7 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter
game->targetChooser = NULL; game->targetChooser = NULL;
player->castedspellsthisturn += 1; player->castedspellsthisturn += 1;
player->opponent()->castedspellsthisturn += 1; player->opponent()->castedspellsthisturn += 1;
if (player->onlyonecast == true || player->onlyoneinstant == true) if (player->onlyonecast || player->onlyoneinstant)
player->castcount += 1; player->castcount += 1;
if (card->has(Constants::STORM)) if (card->has(Constants::STORM))
@@ -627,30 +627,30 @@ int MTGMorphCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
#ifdef WIN32 #ifdef WIN32
cost->Dump(); cost->Dump();
#endif #endif
if (player->castrestrictedspell == true && !card->hasType("land")) if (player->castrestrictedspell && !card->hasType("land"))
{ {
return 0; return 0;
} }
if (player->onlyonecast == true && player->castcount >= 1) if (player->onlyonecast && player->castcount >= 1)
{ {
return 0; return 0;
} }
if (player->nospellinstant == true) if (player->nospellinstant )
{ {
return 0; return 0;
} }
if (player->onlyoneinstant == true) if (player->onlyoneinstant )
{ {
if (player->castcount >= 1) if (player->castcount >= 1)
{ {
return 0; return 0;
} }
} }
if (player->nocreatureinstant == true && card->hasType("creature")) if (player->nocreatureinstant && card->hasType("creature"))
{ {
return 0; return 0;
} }
if (player->castrestrictedcreature == true && card->hasType("creature")) if (player->castrestrictedcreature && card->hasType("creature"))
{ {
return 0; return 0;
} }
@@ -720,7 +720,7 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card)
copy->toughness = 2; copy->toughness = 2;
player->castedspellsthisturn += 1; player->castedspellsthisturn += 1;
player->opponent()->castedspellsthisturn += 1; player->opponent()->castedspellsthisturn += 1;
if (player->onlyonecast == true || player->onlyoneinstant == true) if (player->onlyonecast || player->onlyoneinstant)
{ {
player->castcount += 1; player->castcount += 1;