Merge branch 'master' into minmax
This commit is contained in:
@@ -76,8 +76,7 @@ AIHint::AIHint(string _line)
|
||||
|
||||
if(action.find( "combo ") != string::npos)
|
||||
{
|
||||
string Combo = "";
|
||||
Combo = action.c_str() + 6;
|
||||
string Combo = action.c_str() + 6;
|
||||
combos.push_back(Combo);
|
||||
}
|
||||
|
||||
@@ -309,14 +308,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())
|
||||
@@ -587,4 +585,4 @@ AIAction * AIHints::suggestAbility(ManaCost * potentialMana)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -92,13 +92,12 @@ 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;
|
||||
ManaCost * potentialMana = getPotentialMana();
|
||||
int converted = potentialMana->getConvertedCost();
|
||||
SAFE_DELETE(potentialMana);
|
||||
@@ -108,7 +107,7 @@ int AIMomirPlayer::computeActions()
|
||||
//Attempt to put land into play
|
||||
cd.init();
|
||||
cd.setColor(Constants::MTG_COLOR_LAND);
|
||||
card = cd.match(game->hand);
|
||||
MTGCardInstance *card = cd.match(game->hand);
|
||||
int canPutLandsIntoPlay = game->playRestrictions->canPutIntoZone(card, game->inPlay);
|
||||
if (card && (canPutLandsIntoPlay == PlayRestriction::CAN_PLAY))
|
||||
{
|
||||
@@ -120,15 +119,12 @@ int AIMomirPlayer::computeActions()
|
||||
}
|
||||
momir();
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
case MTG_PHASE_SECONDMAIN:
|
||||
selectAbility();
|
||||
return 1;
|
||||
break;
|
||||
default:
|
||||
return AIPlayerBaka::computeActions();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return AIPlayerBaka::computeActions();
|
||||
|
||||
@@ -122,7 +122,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.
|
||||
@@ -219,7 +219,7 @@ int AIPlayer::clickMultiTarget(TargetChooser * tc, vector<Targetable*>& potentia
|
||||
ite = potentialTargets.erase(ite);
|
||||
continue;
|
||||
}
|
||||
ite++;
|
||||
++ite;
|
||||
}
|
||||
|
||||
randomGenerator.random_shuffle(potentialTargets.begin(), potentialTargets.end());
|
||||
@@ -571,4 +571,4 @@ int AIPlayer::createAbilityPotentialsActions(MTGAbility * a, MTGCardInstance * c
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,10 +135,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;
|
||||
@@ -153,12 +152,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;
|
||||
@@ -589,8 +586,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;
|
||||
@@ -979,11 +975,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
|
||||
@@ -1047,7 +1042,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)
|
||||
@@ -1062,7 +1056,6 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
payments.push_back(kickerPayment[w]);
|
||||
}
|
||||
}
|
||||
canKick += 1;
|
||||
keepLooking = cost->getKicker()->isMulti;
|
||||
}
|
||||
else
|
||||
@@ -1298,12 +1291,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))
|
||||
{
|
||||
@@ -1403,7 +1394,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())
|
||||
@@ -1411,10 +1401,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]);
|
||||
@@ -1526,7 +1515,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
|
||||
@@ -1906,12 +1895,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++)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,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;
|
||||
@@ -50,7 +50,7 @@ void AIStats::updateStatsCard(MTGCardInstance * cardInstance, Damage * damage, f
|
||||
{
|
||||
stat->value += static_cast<int>(multiplier * STATS_PLAYER_MULTIPLIER * damage->damage);
|
||||
}
|
||||
else if (damage->target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
else if (damage->target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
MTGCardInstance * target = (MTGCardInstance *) damage->target;
|
||||
if (target->controller() == player && !target->isInPlay(player->getObserver()))
|
||||
@@ -118,7 +118,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;
|
||||
@@ -138,7 +138,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)
|
||||
@@ -177,7 +177,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)
|
||||
@@ -221,4 +221,4 @@ void AIStats::Render()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
ActionElement::ActionElement(int id) :
|
||||
JGuiObject(id)
|
||||
{
|
||||
activeState = INACTIVE;
|
||||
activity = Inactive;
|
||||
modal = 0;
|
||||
waitingForAnswer = 0;
|
||||
currentPhase = MTG_PHASE_INVALID;
|
||||
@@ -18,7 +18,7 @@ ActionElement::ActionElement(int id) :
|
||||
|
||||
ActionElement::ActionElement(const ActionElement& a): JGuiObject(a)
|
||||
{
|
||||
activeState = a.activeState;
|
||||
activity = a.activity;
|
||||
tc = a.tc ? a.tc->clone() : NULL;
|
||||
currentPhase = a.currentPhase;
|
||||
newPhase = a.newPhase;
|
||||
@@ -31,12 +31,6 @@ ActionElement::~ActionElement()
|
||||
SAFE_DELETE(tc);
|
||||
}
|
||||
|
||||
int ActionElement::getActivity()
|
||||
{
|
||||
|
||||
return activeState;
|
||||
}
|
||||
|
||||
int ActionElement::isReactingToTargetClick(Targetable * object)
|
||||
{
|
||||
if (MTGCardInstance * cObject = dynamic_cast<MTGCardInstance *>(object))
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
/*
|
||||
@@ -266,7 +264,7 @@ int ActionLayer::receiveEventPlus(WEvent * event)
|
||||
ActionElement * currentAction = (ActionElement *) mObjects[i];
|
||||
result += currentAction->receiveEvent(event);
|
||||
}
|
||||
return 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
int ActionLayer::isReactingToTargetClick(Targetable * card)
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ void NextGamePhase::Render()
|
||||
if (observer->currentActionPlayer == observer->players[1])
|
||||
playerId = 2;
|
||||
|
||||
sprintf(buffer, "%s %i : %s", _("Player").c_str(), playerId, observer->getNextGamePhaseName());
|
||||
sprintf(buffer, "%s %i : %s", _("Player").c_str(), playerId, observer->getNextGamePhaseName().c_str());
|
||||
|
||||
mFont->DrawString(buffer, x + 15, y+10, JGETEXT_LEFT);
|
||||
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
||||
@@ -161,7 +161,7 @@ void StackAbility::Render()
|
||||
if (target)
|
||||
{
|
||||
quad = target->getIcon();
|
||||
if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
alt2 = ((MTGCardInstance *) target)->name;
|
||||
}
|
||||
@@ -400,7 +400,7 @@ void Spell::Render()
|
||||
if (target)
|
||||
{
|
||||
quad = target->getIcon();
|
||||
if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
alt2 = ((MTGCardInstance *) target)->name;
|
||||
}
|
||||
@@ -675,6 +675,7 @@ ActionStack::ActionStack(GameObserver* game)
|
||||
currentState = -1;
|
||||
mode = ACTIONSTACK_STANDARD;
|
||||
checked = 0;
|
||||
lastActionController = NULL;
|
||||
|
||||
if(!observer->getResourceManager()) return;
|
||||
for (int i = 0; i < 8; ++i)
|
||||
|
||||
@@ -55,6 +55,12 @@ GenericActivatedAbility::GenericActivatedAbility(GameObserver* observer, string
|
||||
target = ability->target;
|
||||
}
|
||||
|
||||
GenericActivatedAbility::GenericActivatedAbility(const GenericActivatedAbility &other):
|
||||
ActivatedAbility(other), NestedAbility(other), activeZone(other.activeZone), newName(other.newName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int GenericActivatedAbility::resolve()
|
||||
{
|
||||
//Note: I've seen a similar block in some other MTGAbility, can this be refactored .
|
||||
@@ -71,7 +77,7 @@ int GenericActivatedAbility::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * GenericActivatedAbility::getMenuText()
|
||||
const string GenericActivatedAbility::getMenuText()
|
||||
{
|
||||
if(newName.size())
|
||||
return newName.c_str();
|
||||
@@ -105,6 +111,7 @@ int GenericActivatedAbility::testDestroy()
|
||||
GenericActivatedAbility * GenericActivatedAbility::clone() const
|
||||
{
|
||||
GenericActivatedAbility * a = NEW GenericActivatedAbility(*this);
|
||||
|
||||
a->ability = ability->clone();
|
||||
return a;
|
||||
}
|
||||
@@ -133,7 +140,7 @@ int AAAlterPoison::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AAAlterPoison::getMenuText()
|
||||
const string AAAlterPoison::getMenuText()
|
||||
{
|
||||
return "Poison";
|
||||
}
|
||||
@@ -165,7 +172,7 @@ int AADamagePrevent::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AADamagePrevent::getMenuText()
|
||||
const string AADamagePrevent::getMenuText()
|
||||
{
|
||||
return "Prevent Damage";
|
||||
}
|
||||
@@ -237,7 +244,7 @@ AADamager::AADamager(GameObserver* observer, int _id, MTGCardInstance * _source,
|
||||
return damage.getValue();
|
||||
}
|
||||
|
||||
const char * AADamager::getMenuText()
|
||||
const string AADamager::getMenuText()
|
||||
{
|
||||
MTGCardInstance * _target = dynamic_cast<MTGCardInstance*>(target);
|
||||
if(_target && _target->hasType(Subtypes::TYPE_PLANESWALKER))
|
||||
@@ -276,7 +283,7 @@ AADepleter::AADepleter(GameObserver* observer, int _id, MTGCardInstance * card,
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AADepleter::getMenuText()
|
||||
const string AADepleter::getMenuText()
|
||||
{
|
||||
return "Deplete";
|
||||
}
|
||||
@@ -311,7 +318,7 @@ AAModTurn::AAModTurn(GameObserver* observer, int _id, MTGCardInstance * card, Ta
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AAModTurn::getMenuText()
|
||||
const string AAModTurn::getMenuText()
|
||||
{
|
||||
WParsedInt numTurns(nbTurnStr, NULL, source);
|
||||
if(numTurns.getValue() > 0)
|
||||
@@ -354,7 +361,7 @@ int AALibraryBottom::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AALibraryBottom::getMenuText()
|
||||
const string AALibraryBottom::getMenuText()
|
||||
{
|
||||
return "Bottom Of Library";
|
||||
}
|
||||
@@ -382,7 +389,7 @@ int AACopier::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AACopier::getMenuText()
|
||||
const string AACopier::getMenuText()
|
||||
{
|
||||
return "Copy";
|
||||
}
|
||||
@@ -415,7 +422,7 @@ int AAPhaseOut::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AAPhaseOut::getMenuText()
|
||||
const string AAPhaseOut::getMenuText()
|
||||
{
|
||||
return "Phase Out";
|
||||
}
|
||||
@@ -506,7 +513,7 @@ AACounter::AACounter(GameObserver* observer, int id, MTGCardInstance * source, M
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* AACounter::getMenuText()
|
||||
const string AACounter::getMenuText()
|
||||
{
|
||||
if (menu.size())
|
||||
{
|
||||
@@ -695,7 +702,7 @@ int AARemoveAllCounter::resolve()
|
||||
return nb;
|
||||
}
|
||||
|
||||
const char* AARemoveAllCounter::getMenuText()
|
||||
const string AARemoveAllCounter::getMenuText()
|
||||
{
|
||||
if (menu.size())
|
||||
{
|
||||
@@ -773,7 +780,7 @@ int AAProliferate::resolve()
|
||||
|
||||
}
|
||||
|
||||
const char* AAProliferate::getMenuText()
|
||||
const string AAProliferate::getMenuText()
|
||||
{
|
||||
return "Proliferate";
|
||||
}
|
||||
@@ -816,13 +823,13 @@ int GenericChooseTypeColor::resolve()
|
||||
for (size_t i = 0; i < values.size(); ++i)
|
||||
{
|
||||
string menu = values[i];
|
||||
if(!ANonWall || (menu != "wall" && menu != "Wall"))
|
||||
if (!ANonWall || (menu != "wall" && menu != "Wall"))
|
||||
{
|
||||
setType = NEW AASetTypeChosen(game, game->mLayers->actionLayer()->getMaxId(), source,(MTGCardInstance*)target, i,menu,baseAbility);
|
||||
MTGAbility * set = setType->clone();
|
||||
set->oneShot = true;
|
||||
selection.push_back(set);
|
||||
SAFE_DELETE(setType);
|
||||
setType = NEW AASetTypeChosen(game, game->mLayers->actionLayer()->getMaxId(), source,(MTGCardInstance*)target, i,menu,baseAbility);
|
||||
MTGAbility * set = setType->clone();
|
||||
set->oneShot = true;
|
||||
selection.push_back(set);
|
||||
SAFE_DELETE(setType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -837,7 +844,7 @@ int GenericChooseTypeColor::resolve()
|
||||
|
||||
}
|
||||
|
||||
const char* GenericChooseTypeColor::getMenuText()
|
||||
const string GenericChooseTypeColor::getMenuText()
|
||||
{
|
||||
if(chooseColor)
|
||||
return "Choose a color";
|
||||
@@ -899,7 +906,7 @@ int AASetColorChosen::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* AASetColorChosen::getMenuText()
|
||||
const string AASetColorChosen::getMenuText()
|
||||
{
|
||||
return Constants::MTGColorStrings[color];
|
||||
}
|
||||
@@ -956,7 +963,7 @@ int AASetTypeChosen::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* AASetTypeChosen::getMenuText()
|
||||
const string AASetTypeChosen::getMenuText()
|
||||
{
|
||||
return menutext.c_str();
|
||||
}
|
||||
@@ -1003,7 +1010,7 @@ int GenericFlipACoin::resolve()
|
||||
|
||||
}
|
||||
|
||||
const char* GenericFlipACoin::getMenuText()
|
||||
const string GenericFlipACoin::getMenuText()
|
||||
{
|
||||
return "Flip A Coin";
|
||||
}
|
||||
@@ -1095,7 +1102,7 @@ int AASetCoin::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* AASetCoin::getMenuText()
|
||||
const string AASetCoin::getMenuText()
|
||||
{
|
||||
if(side == 1)
|
||||
return "Tails";
|
||||
@@ -1186,7 +1193,7 @@ int GenericPaidAbility::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* GenericPaidAbility::getMenuText()
|
||||
const string GenericPaidAbility::getMenuText()
|
||||
{
|
||||
if (newName.size())
|
||||
return newName.c_str();
|
||||
@@ -1288,7 +1295,7 @@ int AAResetDamage::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* AAResetDamage::getMenuText()
|
||||
const string AAResetDamage::getMenuText()
|
||||
{
|
||||
return "Reset Damages";
|
||||
}
|
||||
@@ -1309,7 +1316,7 @@ int AAFakeAbility::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* AAFakeAbility::getMenuText()
|
||||
const string AAFakeAbility::getMenuText()
|
||||
{
|
||||
if(named.size())
|
||||
return named.c_str();
|
||||
@@ -1356,7 +1363,7 @@ int AAFizzler::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AAFizzler::getMenuText()
|
||||
const string AAFizzler::getMenuText()
|
||||
{
|
||||
return "Fizzle";
|
||||
}
|
||||
@@ -1403,7 +1410,7 @@ int AABuryCard::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AABuryCard::getMenuText()
|
||||
const string AABuryCard::getMenuText()
|
||||
{
|
||||
if(menu.size())
|
||||
return menu.c_str();
|
||||
@@ -1459,7 +1466,7 @@ int AADestroyCard::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AADestroyCard::getMenuText()
|
||||
const string AADestroyCard::getMenuText()
|
||||
{
|
||||
return "Destroy";
|
||||
}
|
||||
@@ -1515,7 +1522,7 @@ int AASacrificeCard::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AASacrificeCard::getMenuText()
|
||||
const string AASacrificeCard::getMenuText()
|
||||
{
|
||||
return "Sacrifice";
|
||||
}
|
||||
@@ -1570,7 +1577,7 @@ int AADiscardCard::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AADiscardCard::getMenuText()
|
||||
const string AADiscardCard::getMenuText()
|
||||
{
|
||||
return "Discard";
|
||||
}
|
||||
@@ -1634,7 +1641,7 @@ AADrawer::AADrawer(GameObserver* observer, int _id, MTGCardInstance * card, Targ
|
||||
return numCards.getValue();
|
||||
}
|
||||
|
||||
const char * AADrawer::getMenuText()
|
||||
const string AADrawer::getMenuText()
|
||||
{
|
||||
return "Draw";
|
||||
}
|
||||
@@ -1663,7 +1670,7 @@ int AAFrozen::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AAFrozen::getMenuText()
|
||||
const string AAFrozen::getMenuText()
|
||||
{
|
||||
return "Freeze";
|
||||
}
|
||||
@@ -1728,7 +1735,7 @@ int AANewTarget::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AANewTarget::getMenuText()
|
||||
const string AANewTarget::getMenuText()
|
||||
{
|
||||
return "New Target";
|
||||
}
|
||||
@@ -1809,7 +1816,7 @@ int AAMorph::testDestroy()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AAMorph::getMenuText()
|
||||
const string AAMorph::getMenuText()
|
||||
{
|
||||
return "Morph";
|
||||
}
|
||||
@@ -1946,7 +1953,7 @@ int AAFlip::testDestroy()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AAFlip::getMenuText()
|
||||
const string AAFlip::getMenuText()
|
||||
{
|
||||
string s = flipStats;
|
||||
sprintf(menuText, "Transform:%s", s.c_str());
|
||||
@@ -2252,7 +2259,7 @@ int AADynamic::activateStored()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AADynamic::getMenuText()
|
||||
const string AADynamic::getMenuText()
|
||||
{
|
||||
if (menu.size())
|
||||
{
|
||||
@@ -2351,7 +2358,7 @@ int AALifer::resolve()
|
||||
return 0;
|
||||
|
||||
WParsedInt life(life_s, NULL, source);
|
||||
if (_target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (_target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
_target = ((MTGCardInstance *) _target)->controller();
|
||||
}
|
||||
@@ -2367,7 +2374,7 @@ int AALifer::getLife()
|
||||
return life.getValue();
|
||||
}
|
||||
|
||||
const char * AALifer::getMenuText()
|
||||
const string AALifer::getMenuText()
|
||||
{
|
||||
if(getLife() < 0)
|
||||
return "Life Loss";
|
||||
@@ -2400,7 +2407,7 @@ int AASetHand::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AASetHand::getMenuText()
|
||||
const string AASetHand::getMenuText()
|
||||
{
|
||||
return "Set Hand Size";
|
||||
}
|
||||
@@ -2431,7 +2438,7 @@ int AALifeSet::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AALifeSet::getMenuText()
|
||||
const string AALifeSet::getMenuText()
|
||||
{
|
||||
return "Set Life";
|
||||
}
|
||||
@@ -2513,7 +2520,7 @@ int AACloner::resolve()
|
||||
|
||||
}
|
||||
|
||||
const char * AACloner::getMenuText()
|
||||
const string AACloner::getMenuText()
|
||||
{
|
||||
if (who == 1)
|
||||
return "Clone For Opponent";
|
||||
@@ -2588,7 +2595,7 @@ int ACastRestriction::destroy()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * ACastRestriction::getMenuText()
|
||||
const string ACastRestriction::getMenuText()
|
||||
{
|
||||
if (modifyExisting)
|
||||
return "Additional Lands"; //hardoced because only the lands rule allows to modify existing rule for now
|
||||
@@ -2623,7 +2630,7 @@ int AInstantCastRestrictionUEOT::resolve()
|
||||
wrapper->addToGame();
|
||||
return 1;
|
||||
}
|
||||
const char * AInstantCastRestrictionUEOT::getMenuText()
|
||||
const string AInstantCastRestrictionUEOT::getMenuText()
|
||||
{
|
||||
return ability->getMenuText();
|
||||
}
|
||||
@@ -2717,14 +2724,14 @@ int AAMover::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AAMover::getMenuText()
|
||||
const string AAMover::getMenuText()
|
||||
{
|
||||
if(named.size())
|
||||
return named.c_str();
|
||||
return "Move";
|
||||
}
|
||||
|
||||
const char * AAMover::getMenuText(TargetChooser * tc)
|
||||
const char* AAMover::getMenuText(TargetChooser * tc)
|
||||
{
|
||||
if(named.size())
|
||||
return named.c_str();
|
||||
@@ -2864,7 +2871,7 @@ int AARandomMover::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AARandomMover::getMenuText()
|
||||
const string AARandomMover::getMenuText()
|
||||
{
|
||||
return "Dig";
|
||||
}
|
||||
@@ -2902,7 +2909,7 @@ int AARandomDiscarder::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AARandomDiscarder::getMenuText()
|
||||
const string AARandomDiscarder::getMenuText()
|
||||
{
|
||||
return "Discard Random";
|
||||
}
|
||||
@@ -2929,7 +2936,7 @@ int AAShuffle::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AAShuffle::getMenuText()
|
||||
const string AAShuffle::getMenuText()
|
||||
{
|
||||
return "Shuffle";
|
||||
}
|
||||
@@ -3027,7 +3034,7 @@ int AARemoveMana::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AARemoveMana::getMenuText()
|
||||
const string AARemoveMana::getMenuText()
|
||||
{
|
||||
if (mRemoveAll && !mManaDesc)
|
||||
return "Empty Manapool";
|
||||
@@ -3066,7 +3073,7 @@ int AATapper::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AATapper::getMenuText()
|
||||
const string AATapper::getMenuText()
|
||||
{
|
||||
return "Tap";
|
||||
}
|
||||
@@ -3096,7 +3103,7 @@ int AAUntapper::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AAUntapper::getMenuText()
|
||||
const string AAUntapper::getMenuText()
|
||||
{
|
||||
return "Untap";
|
||||
}
|
||||
@@ -3177,7 +3184,7 @@ int AAWinGame::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AAWinGame::getMenuText()
|
||||
const string AAWinGame::getMenuText()
|
||||
{
|
||||
return "Win Game";
|
||||
}
|
||||
@@ -3268,7 +3275,7 @@ int IfThenAbility::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * IfThenAbility::getMenuText()
|
||||
const string IfThenAbility::getMenuText()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
@@ -3320,7 +3327,7 @@ void MayAbility::Update(float dt)
|
||||
}
|
||||
}
|
||||
|
||||
const char * MayAbility::getMenuText()
|
||||
const string MayAbility::getMenuText()
|
||||
{
|
||||
return ability->getMenuText();
|
||||
}
|
||||
@@ -3456,7 +3463,7 @@ int MenuAbility::resolve()
|
||||
return a->addToGame();
|
||||
}
|
||||
|
||||
const char * MenuAbility::getMenuText()
|
||||
const string MenuAbility::getMenuText()
|
||||
{
|
||||
if((abilities.size() > 1 && must)||(abilities.size() > 2 && !must))
|
||||
return "choose one";
|
||||
@@ -3657,7 +3664,7 @@ int MultiAbility::destroy()
|
||||
return ActivatedAbility::destroy();
|
||||
}
|
||||
|
||||
const char * MultiAbility::getMenuText()
|
||||
const string MultiAbility::getMenuText()
|
||||
{
|
||||
if (abilities.size() && abilities[0])
|
||||
return abilities[0]->getMenuText();
|
||||
@@ -3696,7 +3703,7 @@ GenericTargetAbility::GenericTargetAbility(GameObserver* observer, string newNam
|
||||
counters = 0;
|
||||
}
|
||||
|
||||
const char * GenericTargetAbility::getMenuText()
|
||||
const string GenericTargetAbility::getMenuText()
|
||||
{
|
||||
if (!ability)
|
||||
return "Error";
|
||||
@@ -4249,7 +4256,7 @@ int ATransformer::destroy()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * ATransformer::getMenuText()
|
||||
const string ATransformer::getMenuText()
|
||||
{
|
||||
if(menutext.size())
|
||||
return menutext.c_str();
|
||||
@@ -4282,7 +4289,7 @@ int ATransformerInstant::resolve()
|
||||
wrapper->addToGame();
|
||||
return 1;
|
||||
}
|
||||
const char * ATransformerInstant::getMenuText()
|
||||
const string ATransformerInstant::getMenuText()
|
||||
{
|
||||
if(menu.size())
|
||||
return menu.c_str();
|
||||
@@ -4316,7 +4323,7 @@ int PTInstant::resolve()
|
||||
wrapper->addToGame();
|
||||
return 1;
|
||||
}
|
||||
const char * PTInstant::getMenuText()
|
||||
const string PTInstant::getMenuText()
|
||||
{
|
||||
return ability->getMenuText();
|
||||
}
|
||||
@@ -4347,7 +4354,7 @@ int ASwapPTUEOT::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * ASwapPTUEOT::getMenuText()
|
||||
const string ASwapPTUEOT::getMenuText()
|
||||
{
|
||||
return ability->getMenuText();
|
||||
}
|
||||
@@ -4380,7 +4387,7 @@ int AAExchangeLife::resolve()
|
||||
int oldlife = player->getLife();
|
||||
int targetOldLife = _target->getLife();
|
||||
int modifier = oldlife > targetOldLife? oldlife - targetOldLife:targetOldLife - oldlife;
|
||||
if (_target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (_target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
int increaser = 0;
|
||||
MTGCardInstance * card = ((MTGCardInstance*)_target);
|
||||
@@ -4417,7 +4424,7 @@ int AAExchangeLife::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AAExchangeLife::getMenuText()
|
||||
const string AAExchangeLife::getMenuText()
|
||||
{
|
||||
return "Exchange life";
|
||||
}
|
||||
@@ -4597,15 +4604,15 @@ int APreventDamageTypes::addToGame()
|
||||
fromTc->targetter = NULL;
|
||||
if (type != 1 && type != 2)
|
||||
{//not adding this creates a memory leak.
|
||||
re = NEW REDamagePrevention(this, fromTc, toTc, -1, false, DAMAGE_COMBAT);
|
||||
re = NEW REDamagePrevention(this, fromTc, toTc, -1, false, Damage::DAMAGE_COMBAT);
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
re = NEW REDamagePrevention(this, fromTc, toTc, -1, false, DAMAGE_ALL_TYPES);
|
||||
re = NEW REDamagePrevention(this, fromTc, toTc, -1, false, Damage::DAMAGE_ALL_TYPES);
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
re = NEW REDamagePrevention(this, fromTc, toTc, -1, false, DAMAGE_OTHER);
|
||||
re = NEW REDamagePrevention(this, fromTc, toTc, -1, false, Damage::DAMAGE_OTHER);
|
||||
}
|
||||
game->replacementEffects->add(re);
|
||||
return MTGAbility::addToGame();
|
||||
@@ -4655,7 +4662,7 @@ int APreventDamageTypesUEOT::destroy()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * APreventDamageTypesUEOT::getMenuText()
|
||||
const string APreventDamageTypesUEOT::getMenuText()
|
||||
{
|
||||
return ability->getMenuText();
|
||||
}
|
||||
@@ -4725,7 +4732,7 @@ int AVanishing::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AVanishing::getMenuText()
|
||||
const string AVanishing::getMenuText()
|
||||
{
|
||||
if(counterName.find("fade") != string::npos)
|
||||
return "Fading";
|
||||
@@ -4821,7 +4828,7 @@ int AUpkeep::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * AUpkeep::getMenuText()
|
||||
const string AUpkeep::getMenuText()
|
||||
{
|
||||
return "Upkeep";
|
||||
}
|
||||
@@ -4921,7 +4928,7 @@ int APhaseAction::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * APhaseAction::getMenuText()
|
||||
const string APhaseAction::getMenuText()
|
||||
{
|
||||
if(psMenuText.size())
|
||||
return psMenuText.c_str();
|
||||
@@ -4958,7 +4965,7 @@ int APhaseActionGeneric::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * APhaseActionGeneric::getMenuText()
|
||||
const string APhaseActionGeneric::getMenuText()
|
||||
{
|
||||
return ability->getMenuText();
|
||||
}
|
||||
@@ -5116,7 +5123,7 @@ int ABlink::resolve()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
const char * ABlink::getMenuText()
|
||||
const string ABlink::getMenuText()
|
||||
{
|
||||
return "Blink";
|
||||
}
|
||||
@@ -5147,7 +5154,7 @@ int ABlinkGeneric::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * ABlinkGeneric::getMenuText()
|
||||
const string ABlinkGeneric::getMenuText()
|
||||
{
|
||||
return "Blink";
|
||||
}
|
||||
@@ -5291,6 +5298,116 @@ AAConnect * AAConnect::clone() const
|
||||
return NEW AAConnect(*this);
|
||||
}
|
||||
|
||||
AEquip::AEquip(GameObserver* observer, int _id, MTGCardInstance * _source, ManaCost * _cost, int restrictions) :
|
||||
TargetAbility(observer, _id, _source, NULL, _cost, restrictions)
|
||||
{
|
||||
aType = MTGAbility::STANDARD_EQUIP;
|
||||
isAttach = restrictions != ActivatedAbility::AS_SORCERY;
|
||||
}
|
||||
|
||||
int AEquip::unequip()
|
||||
{
|
||||
if (source->target)
|
||||
{
|
||||
source->target->equipment -= 1;
|
||||
source->parentCards.clear();
|
||||
for (unsigned int w = 0; w < source->target->childrenCards.size(); w++)
|
||||
{
|
||||
MTGCardInstance * child = source->target->childrenCards[w];
|
||||
if (child == source)
|
||||
source->target->childrenCards.erase(source->target->childrenCards.begin() + w);
|
||||
}
|
||||
}
|
||||
source->target = NULL;
|
||||
for (size_t i = 0; i < currentAbilities.size(); ++i)
|
||||
{
|
||||
MTGAbility * a = currentAbilities[i];
|
||||
if (dynamic_cast<AEquip *> (a) || dynamic_cast<ATeach *> (a) || dynamic_cast<AAConnect *> (a)
|
||||
|| dynamic_cast<AANewTarget *> (AbilityFactory::getCoreAbility(a))
|
||||
|| (a->aType == MTGAbility::STANDARD_TOKENCREATOR && a->oneShot))
|
||||
{
|
||||
SAFE_DELETE(a);
|
||||
continue;
|
||||
}
|
||||
game->removeObserver(currentAbilities[i]);
|
||||
}
|
||||
currentAbilities.clear();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AEquip::equip(MTGCardInstance * equipped)
|
||||
{
|
||||
source->target = equipped;
|
||||
source->target->equipment += 1;
|
||||
source->parentCards.push_back(equipped);
|
||||
source->target->childrenCards.push_back((MTGCardInstance*)source);
|
||||
AbilityFactory af(game);
|
||||
af.getAbilities(¤tAbilities, NULL, source);
|
||||
for (size_t i = 0; i < currentAbilities.size(); ++i)
|
||||
{
|
||||
MTGAbility * a = currentAbilities[i];
|
||||
if (dynamic_cast<AEquip *> (a)) continue;
|
||||
if (dynamic_cast<ATeach *> (a)) continue;
|
||||
if (dynamic_cast<AAConnect *> (a)) continue;
|
||||
if (dynamic_cast<AANewTarget *> (af.getCoreAbility(a))) continue;
|
||||
if (a->aType == MTGAbility::STANDARD_TOKENCREATOR && a->oneShot)
|
||||
{
|
||||
a->forceDestroy = 1;
|
||||
continue;
|
||||
}
|
||||
if (dynamic_cast<AACopier *> (af.getCoreAbility(a)))
|
||||
{
|
||||
a->forceDestroy = 1;
|
||||
continue;
|
||||
}
|
||||
//we generally dont want to pass oneShot tokencreators to the cards
|
||||
//we equip...
|
||||
a->addToGame();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AEquip::resolve()
|
||||
{
|
||||
MTGCardInstance * mTarget = tc->getNextCardTarget();
|
||||
if (!mTarget) return 0;
|
||||
if (mTarget == source) return 0;
|
||||
unequip();
|
||||
equip(mTarget);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const string AEquip::getMenuText()
|
||||
{
|
||||
if (isAttach)
|
||||
return "Attach";
|
||||
else
|
||||
return "Equip";
|
||||
}
|
||||
|
||||
int AEquip::testDestroy()
|
||||
{
|
||||
if (source->target && !game->isInPlay(source->target))
|
||||
unequip();
|
||||
if (!game->connectRule)
|
||||
{
|
||||
if (source->target && TargetAbility::tc && !TargetAbility::tc->canTarget((Targetable *)source->target,true))
|
||||
unequip();
|
||||
}
|
||||
return TargetAbility::testDestroy();
|
||||
}
|
||||
|
||||
int AEquip::destroy()
|
||||
{
|
||||
unequip();
|
||||
return TargetAbility::destroy();
|
||||
}
|
||||
|
||||
AEquip * AEquip::clone() const
|
||||
{
|
||||
return NEW AEquip(*this);
|
||||
}
|
||||
|
||||
// casting a card for free, or casting a copy of a card.
|
||||
AACastCard::AACastCard(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target,bool _restricted,bool _copied,bool asNormal,string _namedCard,string _name,bool _noEvent) :
|
||||
MTGAbility(observer, _id, _source),restricted(_restricted),asCopy(_copied),normal(asNormal),cardNamed(_namedCard),nameThis(_name),noEvent(_noEvent)
|
||||
@@ -5474,7 +5591,7 @@ int AACastCard::resolveSpell()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * AACastCard::getMenuText()
|
||||
const string AACastCard::getMenuText()
|
||||
{
|
||||
if(nameThis.size())
|
||||
return nameThis.c_str();
|
||||
|
||||
@@ -160,7 +160,8 @@ MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card)
|
||||
|
||||
if (mColorExclusions)
|
||||
{
|
||||
if ((mColorExclusions & card->colors) == mColorExclusions)
|
||||
// if any of forbidden colors intersect with card colors
|
||||
if ((mColorExclusions & card->colors) != 0)
|
||||
match = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#include "../include/GameApp.h"
|
||||
#include "../include/MTGCard.h"
|
||||
#include "../include/GameOptions.h"
|
||||
#include "../include/CardEffect.h"
|
||||
|
||||
CardEffect::CardEffect(CardGui* target) :
|
||||
target(target)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CardEffect::~CardEffect()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CardEffect::Render()
|
||||
{
|
||||
// std::cout << "Rendering effect" << std::endl;
|
||||
}
|
||||
@@ -1013,7 +1013,7 @@ bool CardGui::FilterCard(MTGCard * _card,string filter)
|
||||
CardDescriptor cd;
|
||||
MTGCardInstance * card = (MTGCardInstance*) _card->data;
|
||||
cd.init();
|
||||
cd.mode = CD_OR;
|
||||
cd.mode = CardDescriptor::CD_OR;
|
||||
while (filter.size())
|
||||
{
|
||||
|
||||
@@ -1033,13 +1033,13 @@ bool CardGui::FilterCard(MTGCard * _card,string filter)
|
||||
string attribute;
|
||||
if (found2 != string::npos)
|
||||
{
|
||||
cd.mode = CD_OR;
|
||||
cd.mode = CardDescriptor::CD_OR;
|
||||
attribute = attributes.substr(0, found2);
|
||||
attributes = attributes.substr(found2 + 1);
|
||||
}
|
||||
else if (foundAnd != string::npos)
|
||||
{
|
||||
cd.mode = CD_AND;
|
||||
cd.mode = CardDescriptor::CD_AND;
|
||||
attribute = attributes.substr(0, foundAnd);
|
||||
attributes = attributes.substr(foundAnd + 1);
|
||||
}
|
||||
@@ -1302,7 +1302,7 @@ bool CardGui::FilterCard(MTGCard * _card,string filter)
|
||||
}
|
||||
}
|
||||
if (nbminuses)
|
||||
cd.mode = CD_AND;
|
||||
cd.mode = CardDescriptor::CD_AND;
|
||||
filter = filter.substr(0, found);
|
||||
}
|
||||
else
|
||||
@@ -1312,7 +1312,7 @@ bool CardGui::FilterCard(MTGCard * _card,string filter)
|
||||
|
||||
if (found != string::npos)
|
||||
{
|
||||
cd.mode = CD_OR;
|
||||
cd.mode = CardDescriptor::CD_OR;
|
||||
typeName = filter.substr(0, found);
|
||||
filter = filter.substr(found + 1);
|
||||
}
|
||||
|
||||
@@ -84,6 +84,9 @@ int CardPrimitive::init()
|
||||
alias = 0;
|
||||
restrictions = NULL;
|
||||
dredgeAmount = 0;
|
||||
|
||||
power = 0;
|
||||
toughness = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -225,6 +228,9 @@ void CardPrimitive::setSubtype(const string& value)
|
||||
}
|
||||
}
|
||||
|
||||
// "Artifact Creature" should have "Creature" as parent type
|
||||
if (parentType == Subtypes::TYPE_ARTIFACT && isCreature())
|
||||
parentType = Subtypes::TYPE_CREATURE;
|
||||
|
||||
int id = MTGAllCards::add(value, parentType);
|
||||
addType(id);
|
||||
@@ -344,18 +350,12 @@ bool CardPrimitive::hasSubtype(int _subtype)
|
||||
return hasType(_subtype);
|
||||
}
|
||||
|
||||
bool CardPrimitive::hasType(const char * _type)
|
||||
bool CardPrimitive::hasType(const string& _type)
|
||||
{
|
||||
int id = MTGAllCards::findType(_type);
|
||||
return hasType(id);
|
||||
}
|
||||
|
||||
bool CardPrimitive::hasSubtype(const char * _subtype)
|
||||
{
|
||||
int id = MTGAllCards::findType(_subtype);
|
||||
return hasType(id);
|
||||
}
|
||||
|
||||
bool CardPrimitive::hasSubtype(const string& _subtype)
|
||||
{
|
||||
int id = MTGAllCards::findType(_subtype);
|
||||
|
||||
@@ -7,42 +7,42 @@
|
||||
#include "Closest.cpp"
|
||||
#include "GameObserver.h"
|
||||
|
||||
struct Left: public Exp
|
||||
struct CardSelectorLeft: public Exp
|
||||
{
|
||||
static inline bool test(CardSelector::Target* ref, CardSelector::Target* test)
|
||||
{
|
||||
return ref->x - test->x > fabs(ref->y - test->y);
|
||||
}
|
||||
};
|
||||
struct Right: public Exp
|
||||
struct CardSelectorRight: public Exp
|
||||
{
|
||||
static inline bool test(CardSelector::Target* ref, CardSelector::Target* test)
|
||||
{
|
||||
return test->x - ref->x > fabs(ref->y - test->y);
|
||||
}
|
||||
};
|
||||
struct Up: public Exp
|
||||
struct CardSelectorUp: public Exp
|
||||
{
|
||||
static inline bool test(CardSelector::Target* ref, CardSelector::Target* test)
|
||||
{
|
||||
return ref->y - test->y > fabs(ref->x - test->x);
|
||||
}
|
||||
};
|
||||
struct Down: public Exp
|
||||
struct CardSelectorDown: public Exp
|
||||
{
|
||||
static inline bool test(CardSelector::Target* ref, CardSelector::Target* test)
|
||||
{
|
||||
return test->y - ref->y > fabs(ref->x - test->x);
|
||||
}
|
||||
};
|
||||
struct Diff: public Exp
|
||||
struct CardSelectorDiff: public Exp
|
||||
{
|
||||
static inline bool test(CardSelector::Target* ref, CardSelector::Target* test)
|
||||
{
|
||||
return ref != test;
|
||||
}
|
||||
};
|
||||
struct True: public Exp
|
||||
struct CardSelectorTrue: public Exp
|
||||
{
|
||||
static inline bool test(CardSelector::Target*, CardSelector::Target*)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ CardSelector::SelectorMemory::SelectorMemory()
|
||||
}
|
||||
|
||||
CardSelector::CardSelector(GameObserver *observer, DuelLayers* duel) :
|
||||
CardSelectorBase(observer), active(NULL), duel(duel), limitor(NULL), bigpos(300, 145, 1.0, 0.0, 220)
|
||||
CardSelectorBase(observer), active(NULL), duel(duel), limitor(NULL), bigpos(300, 145, 1.0, 0.0, 220), timer(0.0f)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ void CardSelector::Remove(CardSelector::Target* card)
|
||||
CardView* c = dynamic_cast<CardView*> (active);
|
||||
if (c)
|
||||
c->zoom = 1.0f;
|
||||
active = closest<Diff> (cards, limitor, active);
|
||||
active = closest<CardSelectorDiff> (cards, limitor, active);
|
||||
c = dynamic_cast<CardView*> (active);
|
||||
if (c)
|
||||
c->zoom = 1.4f;
|
||||
@@ -120,7 +120,7 @@ CardSelector::Target* CardSelector::fetchMemory(SelectorMemory& memory)
|
||||
}
|
||||
// We come here if the card is not in the selector any more, or if
|
||||
// it is there but it is now refused by the limitor.
|
||||
return closest<True> (cards, limitor, memory.x, memory.y);
|
||||
return closest<CardSelectorTrue> (cards, limitor, memory.x, memory.y);
|
||||
}
|
||||
|
||||
void CardSelector::Push()
|
||||
@@ -182,7 +182,7 @@ bool CardSelector::CheckUserInput(JButton key)
|
||||
if(!jge) return false;
|
||||
if(jge->GetLeftClickCoordinates(x, y))
|
||||
{
|
||||
active = closest<True> (cards, limitor, static_cast<float> (x), static_cast<float> (y));
|
||||
active = closest<CardSelectorTrue> (cards, limitor, static_cast<float> (x), static_cast<float> (y));
|
||||
}
|
||||
|
||||
switch (key)
|
||||
@@ -196,16 +196,16 @@ bool CardSelector::CheckUserInput(JButton key)
|
||||
goto switch_active;
|
||||
break;
|
||||
case JGE_BTN_LEFT:
|
||||
active = closest<Left> (cards, limitor, active);
|
||||
active = closest<CardSelectorLeft> (cards, limitor, active);
|
||||
break;
|
||||
case JGE_BTN_RIGHT:
|
||||
active = closest<Right> (cards, limitor, active);
|
||||
active = closest<CardSelectorRight> (cards, limitor, active);
|
||||
break;
|
||||
case JGE_BTN_UP:
|
||||
active = closest<Up> (cards, limitor, active);
|
||||
active = closest<CardSelectorUp> (cards, limitor, active);
|
||||
break;
|
||||
case JGE_BTN_DOWN:
|
||||
active = closest<Down> (cards, limitor, active);
|
||||
active = closest<CardSelectorDown> (cards, limitor, active);
|
||||
break;
|
||||
case JGE_BTN_CANCEL:
|
||||
mDrawMode = (mDrawMode + 1) % DrawMode::kNumDrawModes;
|
||||
|
||||
+15
-25
@@ -14,13 +14,13 @@ Damage::Damage(GameObserver* observer, MTGCardInstance * source, Damageable * ta
|
||||
init(source, target, source->getPower(), DAMAGE_OTHER);
|
||||
}
|
||||
|
||||
Damage::Damage(GameObserver* observer, MTGCardInstance * source, Damageable * target, int damage, int _typeOfDamage)
|
||||
Damage::Damage(GameObserver* observer, MTGCardInstance * source, Damageable * target, int damage, DamageType _typeOfDamage)
|
||||
: Interruptible(observer)
|
||||
{
|
||||
init(source, target, damage, _typeOfDamage);
|
||||
}
|
||||
|
||||
void Damage::init(MTGCardInstance * _source, Damageable * _target, int _damage, int _typeOfDamage)
|
||||
void Damage::init(MTGCardInstance * _source, Damageable * _target, int _damage, DamageType _typeOfDamage)
|
||||
{
|
||||
typeOfDamage = _typeOfDamage;
|
||||
target = _target;
|
||||
@@ -59,29 +59,19 @@ int Damage::resolve()
|
||||
//reserved for culmulitive absorb ability coding
|
||||
|
||||
//prevent next damage-----------------------------
|
||||
if ((target)->preventable >= 1)
|
||||
if (target->preventable > 0)
|
||||
{
|
||||
int preventing = (target)->preventable;
|
||||
for (int k = preventing; k > 0; k--)
|
||||
{
|
||||
//the following keeps preventable from ADDING toughness/life if damage was less then preventable amount.
|
||||
for (int i = damage; i >= 1; i--)
|
||||
{
|
||||
(target)->preventable -= 1;
|
||||
damage -= 1;
|
||||
break;//does the redux of damage 1 time, breaks the loop to deincrement preventing and start the loop over.
|
||||
}
|
||||
}
|
||||
int preventing = MIN(target->preventable, damage);
|
||||
damage -= preventing;
|
||||
target->preventable -= preventing;
|
||||
}
|
||||
|
||||
//set prevent next damage back to 0 if it is equal to less then 0
|
||||
if ((target)->preventable < 0)
|
||||
else
|
||||
{
|
||||
(target)->preventable = 0;
|
||||
target->preventable = 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if ((_target)->protectedAgainst(source))
|
||||
@@ -134,7 +124,7 @@ int Damage::resolve()
|
||||
|
||||
int a = damage;
|
||||
|
||||
if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE && (source->has(Constants::WITHER) || source->has(
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE && (source->has(Constants::WITHER) || source->has(
|
||||
Constants::INFECT)))
|
||||
{
|
||||
// Damage for WITHER or poison on creatures. This should probably go in replacement effects
|
||||
@@ -146,7 +136,7 @@ int Damage::resolve()
|
||||
if(_target->toughness <= 0 && _target->has(Constants::INDESTRUCTIBLE))
|
||||
_target->controller()->game->putInGraveyard(_target);
|
||||
}
|
||||
else if (target->type_as_damageable == DAMAGEABLE_PLAYER && (source->has(Constants::INFECT)||source->has(Constants::POISONDAMAGER)))
|
||||
else if (target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER && (source->has(Constants::INFECT)||source->has(Constants::POISONDAMAGER)))
|
||||
{
|
||||
// Poison on player
|
||||
Player * _target = (Player *) target;
|
||||
@@ -163,7 +153,7 @@ int Damage::resolve()
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (target->type_as_damageable == DAMAGEABLE_PLAYER && (source->has(Constants::POISONTOXIC) ||
|
||||
else if (target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER && (source->has(Constants::POISONTOXIC) ||
|
||||
source->has(Constants::POISONTWOTOXIC) || source->has(Constants::POISONTHREETOXIC)))
|
||||
{
|
||||
//Damage + 1, 2, or 3 poison counters on player
|
||||
@@ -202,9 +192,9 @@ int Damage::resolve()
|
||||
//return the left over amount after effects have been applied to them.
|
||||
a = target->dealDamage(damage);
|
||||
target->damageCount += damage;//the amount must be the actual damage so i changed this from 1 to damage, this fixes pdcount and odcount
|
||||
if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
((MTGCardInstance*)target)->wasDealtDamage = true;
|
||||
if (target->type_as_damageable == DAMAGEABLE_PLAYER)
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER)
|
||||
{
|
||||
if(target == source->controller())
|
||||
{
|
||||
@@ -260,7 +250,7 @@ void Damage::Render()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
mFont->DrawString(_(((MTGCardInstance *) target)->getName()).c_str(), x + 120, y);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ void DamagerDamaged::addDamage(int damage, DamagerDamaged* source)
|
||||
return;
|
||||
}
|
||||
if (0 < damage)
|
||||
damages.push_back(Damage(card->getObserver(), source->card, card, damage, DAMAGE_COMBAT));
|
||||
damages.push_back(Damage(card->getObserver(), source->card, card, damage, Damage::DAMAGE_COMBAT));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <iomanip>
|
||||
#include "Translate.h"
|
||||
|
||||
DeckEditorMenu::DeckEditorMenu(int id, JGuiListener* listener, int fontId, const char * _title, DeckDataWrapper *_selectedDeck, StatsWrapper *stats) :
|
||||
DeckEditorMenu::DeckEditorMenu(int id, JGuiListener* listener, int fontId, const string& _title, DeckDataWrapper *_selectedDeck, StatsWrapper *stats) :
|
||||
DeckMenu(id, listener, fontId, _title), selectedDeck(_selectedDeck), stw(stats)
|
||||
{
|
||||
backgroundName = "DeckEditorMenuBackdrop";
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
namespace
|
||||
namespace DeckMenuConst
|
||||
{
|
||||
const float kVerticalMargin = 16;
|
||||
const float kHorizontalMargin = 20;
|
||||
const float kLineHeight = 25;
|
||||
const float kDescriptionVerticalBoxPadding = -5;
|
||||
const float kDescriptionVerticalBoxPadding = -5;
|
||||
const float kDescriptionHorizontalBoxPadding = 5;
|
||||
|
||||
const float kDefaultFontScale = 1.0f;
|
||||
const float kVerticalScrollSpeed = 7.0f;
|
||||
const float kVerticalScrollSpeed = 7.0f;
|
||||
|
||||
const int DETAILED_INFO_THRESHOLD = 20;
|
||||
const int kDetailedInfoButtonId = 10000;
|
||||
@@ -52,8 +52,8 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc
|
||||
titleY = 15;
|
||||
titleWidth = 180; // width of inner box of title
|
||||
|
||||
descX = 260 + kDescriptionHorizontalBoxPadding;
|
||||
descY = 100 + kDescriptionVerticalBoxPadding;
|
||||
descX = 260 + DeckMenuConst::kDescriptionHorizontalBoxPadding;
|
||||
descY = 100 + DeckMenuConst::kDescriptionVerticalBoxPadding;
|
||||
descHeight = 145;
|
||||
descWidth = 195;
|
||||
|
||||
@@ -73,11 +73,11 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc
|
||||
|
||||
float scrollerWidth = 200.0f;
|
||||
float scrollerHeight = 28.0f;
|
||||
mScroller = NEW VerticalTextScroller(Fonts::MAIN_FONT, 14, 235, scrollerWidth, scrollerHeight, kVerticalScrollSpeed);
|
||||
mScroller = NEW VerticalTextScroller(Fonts::MAIN_FONT, 14, 235, scrollerWidth, scrollerHeight, DeckMenuConst::kVerticalScrollSpeed);
|
||||
|
||||
mAutoTranslate = true;
|
||||
maxItems = 6;
|
||||
mHeight = 2 * kVerticalMargin + (maxItems * kLineHeight);
|
||||
mHeight = 2 * DeckMenuConst::kVerticalMargin + (maxItems * DeckMenuConst::kLineHeight);
|
||||
|
||||
// we want to cap the deck titles to 15 characters to avoid overflowing deck names
|
||||
title = _(_title);
|
||||
@@ -94,7 +94,7 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc
|
||||
else
|
||||
titleFontScale = SCALE_NORMAL;
|
||||
|
||||
mSelectionTargetY = selectionY = kVerticalMargin;
|
||||
mSelectionTargetY = selectionY = DeckMenuConst::kVerticalMargin;
|
||||
|
||||
if (NULL == stars)
|
||||
stars = NEW hgeParticleSystem(WResourceManager::Instance()->RetrievePSI("stars.psi", WResourceManager::Instance()->GetQuad("stars").get()));
|
||||
@@ -106,7 +106,7 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc
|
||||
float stringWidth = descriptionFont->GetStringWidth(detailedInfoString.c_str());
|
||||
float boxStartX = detailedInfoBoxX - stringWidth / 2 + 20;
|
||||
|
||||
dismissButton = NEW InteractiveButton( this, kDetailedInfoButtonId, Fonts::MAIN_FONT, detailedInfoString, boxStartX, detailedInfoBoxY, JGE_BTN_CANCEL);
|
||||
dismissButton = NEW InteractiveButton( this, DeckMenuConst::kDetailedInfoButtonId, Fonts::MAIN_FONT, detailedInfoString, boxStartX, detailedInfoBoxY, JGE_BTN_CANCEL);
|
||||
JGuiController::Add(dismissButton, true);
|
||||
|
||||
updateScroller();
|
||||
@@ -181,7 +181,7 @@ bool DeckMenu::showDetailsScreen()
|
||||
if (currentMenuItem)
|
||||
{
|
||||
if (mAlwaysShowDetailsButton) return true;
|
||||
if (mShowDetailsScreen && currentMenuItem->getVictories() > DETAILED_INFO_THRESHOLD) return true;
|
||||
if (mShowDetailsScreen && currentMenuItem->getVictories() > DeckMenuConst::DETAILED_INFO_THRESHOLD) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -189,10 +189,10 @@ bool DeckMenu::showDetailsScreen()
|
||||
|
||||
void DeckMenu::initMenuItems()
|
||||
{
|
||||
float sY = mY + kVerticalMargin;
|
||||
float sY = mY + DeckMenuConst::kVerticalMargin;
|
||||
for (int i = startId; i < mCount; ++i)
|
||||
{
|
||||
float y = mY + kVerticalMargin + i * kLineHeight;
|
||||
float y = mY + DeckMenuConst::kVerticalMargin + i * DeckMenuConst::kLineHeight;
|
||||
DeckMenuItem * currentMenuItem = static_cast<DeckMenuItem*> (mObjects[i]);
|
||||
currentMenuItem->Relocate(mX, y);
|
||||
if (currentMenuItem->hasFocus()) sY = y;
|
||||
@@ -248,7 +248,7 @@ void DeckMenu::Render()
|
||||
{
|
||||
if (i > mCount - 1) break;
|
||||
DeckMenuItem *currentMenuItem = static_cast<DeckMenuItem*> (mObjects[i]);
|
||||
if (currentMenuItem->getY() - kLineHeight * startId < mY + height - kLineHeight + 7)
|
||||
if (currentMenuItem->getY() - DeckMenuConst::kLineHeight * startId < mY + height - DeckMenuConst::kLineHeight + 7)
|
||||
{
|
||||
// only load stats for visible items in the list
|
||||
DeckMetaData* metaData = currentMenuItem->getMetaData();
|
||||
@@ -293,6 +293,7 @@ void DeckMenu::Render()
|
||||
|
||||
// fill in the description part of the screen
|
||||
string text = wordWrap(_(currentMenuItem->getDescription()), descWidth, descriptionFont->mFontID );
|
||||
descriptionFont->SetColor(ARGB(255,255,255,255));
|
||||
descriptionFont->DrawString(text.c_str(), descX, descY);
|
||||
|
||||
// fill in the statistical portion
|
||||
@@ -301,6 +302,7 @@ void DeckMenu::Render()
|
||||
ostringstream oss;
|
||||
oss << _("Deck: ") << currentMenuItem->getDeckName() << endl;
|
||||
oss << currentMenuItem->getDeckStatsSummary();
|
||||
descriptionFont->SetColor(ARGB(255,255,255,255));
|
||||
descriptionFont->DrawString(oss.str(), statsX, statsY);
|
||||
}
|
||||
|
||||
@@ -309,7 +311,7 @@ void DeckMenu::Render()
|
||||
}
|
||||
else // reset the font color to be slightly muted
|
||||
mFont->SetColor(ARGB(150,255,255,255));
|
||||
currentMenuItem->RenderWithOffset(-kLineHeight * startId);
|
||||
currentMenuItem->RenderWithOffset(-DeckMenuConst::kLineHeight * startId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,8 +344,8 @@ void DeckMenu::Update(float dt)
|
||||
selectionT += 3 * dt;
|
||||
selectionY += (mSelectionTargetY - selectionY) * 8 * dt;
|
||||
|
||||
float starsX = starsOffsetX + ((mWidth - 2 * kHorizontalMargin) * (1 + cos(selectionT)) / 2);
|
||||
float starsY = selectionY + 5 * cos(selectionT * 2.35f) + kLineHeight / 2 - kLineHeight * startId;
|
||||
float starsX = starsOffsetX + ((mWidth - 2 * DeckMenuConst::kHorizontalMargin) * (1 + cos(selectionT)) / 2);
|
||||
float starsY = selectionY + 5 * cos(selectionT * 2.35f) + DeckMenuConst::kLineHeight / 2 - DeckMenuConst::kLineHeight * startId;
|
||||
stars->MoveTo(starsX, starsY);
|
||||
|
||||
//
|
||||
@@ -368,10 +370,10 @@ void DeckMenu::Update(float dt)
|
||||
|
||||
}
|
||||
|
||||
void DeckMenu::Add(int id, const char * text, string desc, bool forceFocus, DeckMetaData * deckMetaData)
|
||||
void DeckMenu::Add(int id, const string& text, const string& desc, bool forceFocus, DeckMetaData * deckMetaData)
|
||||
{
|
||||
DeckMenuItem * menuItem = NEW DeckMenuItem(this, id, fontId, text, 0,
|
||||
mY + kVerticalMargin + mCount * kLineHeight, (mCount == 0), mAutoTranslate, deckMetaData);
|
||||
mY + DeckMenuConst::kVerticalMargin + mCount * DeckMenuConst::kLineHeight, (mCount == 0), mAutoTranslate, deckMetaData);
|
||||
Translator * t = Translator::GetInstance();
|
||||
map<string, string>::iterator it = t->deckValues.find(text);
|
||||
string deckDescription = "";
|
||||
@@ -384,7 +386,7 @@ void DeckMenu::Add(int id, const char * text, string desc, bool forceFocus, Deck
|
||||
menuItem->setDescription(deckDescription);
|
||||
|
||||
JGuiController::Add(menuItem);
|
||||
if (mCount <= maxItems) mHeight += kLineHeight;
|
||||
if (mCount <= maxItems) mHeight += DeckMenuConst::kLineHeight;
|
||||
|
||||
if (forceFocus)
|
||||
{
|
||||
|
||||
@@ -271,22 +271,6 @@ void DeckStats::EndInstance()
|
||||
|
||||
|
||||
// StatsWrapper
|
||||
|
||||
float noLandsProbInTurn[Constants::STATS_FOR_TURNS] = {0.0f};
|
||||
float noCreaturesProbInTurn[Constants::STATS_FOR_TURNS] = {0.0f};
|
||||
|
||||
int countCardsPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1] = {{0,0}};
|
||||
int countCreaturesPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1] = {{0,0}};
|
||||
int countSpellsPerCostAndColor[Constants::STATS_MAX_MANA_COST + 1][Constants::MTG_NB_COLORS + 1] = {{0,0}};
|
||||
|
||||
int countCardsPerCost[Constants::STATS_MAX_MANA_COST + 1] = {0};
|
||||
int countCreaturesPerCost[Constants::STATS_MAX_MANA_COST + 1] = {0};
|
||||
int countSpellsPerCost[Constants::STATS_MAX_MANA_COST + 1] = {0};
|
||||
int countLandsPerColor[Constants::MTG_NB_COLORS + 1] = {0};
|
||||
int countBasicLandsPerColor[Constants::MTG_NB_COLORS + 1] = {0};
|
||||
int countNonLandProducersPerColor[Constants::MTG_NB_COLORS + 1] = {0};
|
||||
int totalCostPerColor[Constants::MTG_NB_COLORS + 1] = {0};
|
||||
|
||||
void StatsWrapper::initValues()
|
||||
{
|
||||
// initilize all member values to 0
|
||||
@@ -301,7 +285,24 @@ void StatsWrapper::initValues()
|
||||
avgManaCost = avgCreatureCost = avgSpellCost = 0.0f;
|
||||
|
||||
countCreatures = countSpells = countInstants = countEnchantments = countSorceries = countArtifacts = 0;
|
||||
|
||||
|
||||
//this works only with 0.0f on floats
|
||||
memset(noLandsProbInTurn, (int)0.0f, sizeof(float) * Constants::STATS_FOR_TURNS);
|
||||
memset(noCreaturesProbInTurn, (int)0.0f, sizeof(float) * Constants::STATS_FOR_TURNS);
|
||||
|
||||
memset(countCardsPerCost, 0, sizeof(int) * (Constants::STATS_MAX_MANA_COST + 1));
|
||||
memset(countCreaturesPerCost, 0, sizeof(int) * (Constants::STATS_MAX_MANA_COST + 1));
|
||||
memset(countSpellsPerCost, 0, sizeof(int) * (Constants::STATS_MAX_MANA_COST + 1));
|
||||
|
||||
memset(countCardsPerCostAndColor, 0, sizeof(int) * (Constants::STATS_MAX_MANA_COST + 1)*(Constants::MTG_NB_COLORS + 1));
|
||||
memset(countCreaturesPerCostAndColor, 0, sizeof(int) * (Constants::STATS_MAX_MANA_COST + 1)*(Constants::MTG_NB_COLORS + 1));
|
||||
memset(countSpellsPerCostAndColor, 0, sizeof(int) * (Constants::STATS_MAX_MANA_COST + 1)*(Constants::MTG_NB_COLORS + 1));
|
||||
|
||||
memset(countLandsPerColor, 0, sizeof(int) * (Constants::MTG_NB_COLORS + 1));
|
||||
memset(countBasicLandsPerColor, 0, sizeof(int) * (Constants::MTG_NB_COLORS + 1));
|
||||
memset(countNonLandProducersPerColor, 0, sizeof(int) * (Constants::MTG_NB_COLORS + 1));
|
||||
memset(totalCostPerColor, 0, sizeof(int) * (Constants::MTG_NB_COLORS + 1));
|
||||
|
||||
}
|
||||
|
||||
StatsWrapper::StatsWrapper(int deckId)
|
||||
@@ -586,7 +587,7 @@ void StatsWrapper::updateStats(DeckDataWrapper *myDeck)
|
||||
|
||||
// This should probably be cached in DeckDataWrapper
|
||||
// or at least be calculated for all common types in one go
|
||||
int StatsWrapper::countCardsByType(const char * _type, DeckDataWrapper * myDeck)
|
||||
int StatsWrapper::countCardsByType(const string& _type, DeckDataWrapper * myDeck)
|
||||
{
|
||||
int result = 0;
|
||||
for (int i = 0; i < myDeck->Size(true); i++)
|
||||
|
||||
@@ -110,12 +110,12 @@ GamePhase GameObserver::getCurrentGamePhase()
|
||||
return mCurrentGamePhase;
|
||||
}
|
||||
|
||||
const char* GameObserver::getCurrentGamePhaseName()
|
||||
const string& GameObserver::getCurrentGamePhaseName()
|
||||
{
|
||||
return phaseRing->phaseName(mCurrentGamePhase);
|
||||
}
|
||||
|
||||
const char* GameObserver::getNextGamePhaseName()
|
||||
const string& GameObserver::getNextGamePhaseName()
|
||||
{
|
||||
return phaseRing->phaseName((mCurrentGamePhase + 1) % MTG_PHASE_CLEANUP);
|
||||
}
|
||||
@@ -1042,7 +1042,7 @@ void GameObserver::Affinity()
|
||||
}
|
||||
else
|
||||
{
|
||||
reduce = card->controller()->game->battlefield->countByType(type.c_str());
|
||||
reduce = card->controller()->game->battlefield->countByType(type);
|
||||
}
|
||||
for(int i = 0; i < reduce;i++)
|
||||
{
|
||||
|
||||
@@ -818,9 +818,9 @@ void GameSettings::createUsersFirstDeck(int setId)
|
||||
mCollection->addRandomCards(10, 0, 0, Constants::RARITY_L, "Island");
|
||||
|
||||
//Starter Deck
|
||||
mCollection->addRandomCards(3, sets, 1, Constants::RARITY_R, NULL);
|
||||
mCollection->addRandomCards(9, sets, 1, Constants::RARITY_U, NULL);
|
||||
mCollection->addRandomCards(48, sets, 1, Constants::RARITY_C, NULL);
|
||||
mCollection->addRandomCards(3, sets, 1, Constants::RARITY_R);
|
||||
mCollection->addRandomCards(9, sets, 1, Constants::RARITY_U);
|
||||
mCollection->addRandomCards(48, sets, 1, Constants::RARITY_C);
|
||||
|
||||
//Boosters
|
||||
for (int i = 0; i < 2; i++)
|
||||
@@ -956,7 +956,7 @@ OptionMaxGrade::OptionMaxGrade()
|
||||
|
||||
// MARK: OptionASkipPhase
|
||||
|
||||
OptionASkipPhase OptionASkipPhase::mDef;
|
||||
OptionASkipPhase OptionASkipPhase::mDef = OptionASkipPhase();
|
||||
OptionASkipPhase::OptionASkipPhase()
|
||||
{
|
||||
mDef.values.push_back(EnumDefinition::assoc(Constants::ASKIP_NONE, "Off"));
|
||||
@@ -1188,10 +1188,11 @@ bool GameOptionKeyBindings::read(string input)
|
||||
iss.get(*(s.rdbuf()), ',');
|
||||
iss.get();
|
||||
|
||||
LocalKeySym local;
|
||||
char sep;
|
||||
u32 button;
|
||||
LocalKeySym local = 0;
|
||||
char sep = 0;
|
||||
u32 button = 0;
|
||||
s >> local >> sep >> button;
|
||||
|
||||
if (':' != sep)
|
||||
return false;
|
||||
assoc.push_back(make_pair(local, u32_to_button(button)));
|
||||
|
||||
@@ -134,7 +134,7 @@ void GameState::renderDeckMenu(DeckMenu * _menu, const vector<DeckMetaData *>& d
|
||||
// deck sorting routines
|
||||
bool sortByName(DeckMetaData * d1, DeckMetaData * d2)
|
||||
{
|
||||
return strcmp(d1->getName().c_str(), d2->getName().c_str()) < 0;
|
||||
return d1->getName() < d2->getName();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ enum ENUM_AWARDS_STATE
|
||||
|
||||
};
|
||||
|
||||
namespace
|
||||
namespace GameStateAwardsConst
|
||||
{
|
||||
const int kBackToTrophiesID = 2;
|
||||
const int kBackToMainMenuID = 1;
|
||||
@@ -186,8 +186,8 @@ void GameStateAwards::Update(float dt)
|
||||
SAFE_DELETE(menu);
|
||||
menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), EXIT_AWARDS_MENU, this, Fonts::MENU_FONT, 50, 170);
|
||||
if (mState == STATE_DETAILS)
|
||||
menu->Add(kBackToTrophiesID, "Back to Trophies");
|
||||
menu->Add(kBackToMainMenuID, "Back to Main Menu");
|
||||
menu->Add(GameStateAwardsConst::kBackToTrophiesID, "Back to Trophies");
|
||||
menu->Add(GameStateAwardsConst::kBackToMainMenuID, "Back to Main Menu");
|
||||
menu->Add(kCancelMenuID, "Cancel");
|
||||
break;
|
||||
case JGE_BTN_PREV:
|
||||
@@ -359,11 +359,11 @@ void GameStateAwards::ButtonPressed(int controllerId, int controlId)
|
||||
if (controllerId == EXIT_AWARDS_MENU)
|
||||
switch (controlId)
|
||||
{
|
||||
case kBackToMainMenuID:
|
||||
case GameStateAwardsConst::kBackToMainMenuID:
|
||||
mParent->DoTransition(TRANSITION_FADE, GAME_STATE_MENU);
|
||||
showMenu = false;
|
||||
break;
|
||||
case kBackToTrophiesID:
|
||||
case GameStateAwardsConst::kBackToTrophiesID:
|
||||
mState = STATE_LISTVIEW;
|
||||
SAFE_DELETE(detailview);
|
||||
showMenu = false;
|
||||
|
||||
@@ -23,22 +23,6 @@
|
||||
#include "AIPlayer.h"
|
||||
|
||||
|
||||
|
||||
//!! helper function; this is probably handled somewhere in the code already.
|
||||
// If not, should be placed in general library
|
||||
void StringExplode(string str, string separator, vector<string>* results)
|
||||
{
|
||||
size_t found;
|
||||
found = str.find_first_of(separator);
|
||||
while (found != string::npos)
|
||||
{
|
||||
if (found > 0) results->push_back(str.substr(0, found));
|
||||
str = str.substr(found + 1);
|
||||
found = str.find_first_of(separator);
|
||||
}
|
||||
if (str.length() > 0) results->push_back(str);
|
||||
}
|
||||
|
||||
GameStateDeckViewer::GameStateDeckViewer(GameApp* parent) :
|
||||
GameState(parent, "deckeditor")
|
||||
{
|
||||
|
||||
@@ -65,6 +65,7 @@ GameStateMenu::GameStateMenu(GameApp* parent) :
|
||||
scroller = NULL;
|
||||
langChoices = false;
|
||||
primitivesLoadCounter = -1;
|
||||
bgTexture = NULL;
|
||||
}
|
||||
|
||||
GameStateMenu::~GameStateMenu()
|
||||
|
||||
@@ -7,13 +7,12 @@
|
||||
#include "SimplePad.h"
|
||||
#include "Translate.h"
|
||||
|
||||
namespace
|
||||
namespace GameStateOptionsConst
|
||||
{
|
||||
const int kSaveAndBackToMainMenuID = 1;
|
||||
const int kBackToMainMenuID = 2;
|
||||
const int kNewProfileID = 4;
|
||||
const int kReloadID = 5;
|
||||
|
||||
}
|
||||
|
||||
GameStateOptions::GameStateOptions(GameApp* parent) :
|
||||
@@ -78,7 +77,7 @@ void GameStateOptions::Start()
|
||||
|
||||
optionsList->Add(NEW WGuiSplit(cPrf, cThm));
|
||||
optionsList->Add(cStyle);
|
||||
optionsList->Add(NEW WGuiButton(NEW WGuiHeader("New Profile"), -102, kNewProfileID, this));
|
||||
optionsList->Add(NEW WGuiButton(NEW WGuiHeader("New Profile"), -102, GameStateOptionsConst::kNewProfileID, this));
|
||||
|
||||
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODE, "Enable Cheat Mode")));
|
||||
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::OPTIMIZE_HAND, "Optimize Starting Hand")));
|
||||
@@ -118,8 +117,8 @@ void GameStateOptions::Start()
|
||||
optionsTabs->Add(optionsList);
|
||||
|
||||
optionsMenu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), -102, this, Fonts::MAIN_FONT, 50, 170);
|
||||
optionsMenu->Add(kBackToMainMenuID, "Back to Main Menu");
|
||||
optionsMenu->Add(kSaveAndBackToMainMenuID, "Save And Exit");
|
||||
optionsMenu->Add(GameStateOptionsConst::kBackToMainMenuID, "Back to Main Menu");
|
||||
optionsMenu->Add(GameStateOptionsConst::kSaveAndBackToMainMenuID, "Save And Exit");
|
||||
optionsMenu->Add(kCancelMenuID, "Cancel");
|
||||
|
||||
optionsTabs->Entering(JGE_BTN_NONE);
|
||||
@@ -285,21 +284,21 @@ void GameStateOptions::ButtonPressed(int controllerId, int controlId)
|
||||
if (controllerId == -102)
|
||||
switch (controlId)
|
||||
{
|
||||
case kSaveAndBackToMainMenuID:
|
||||
case GameStateOptionsConst::kSaveAndBackToMainMenuID:
|
||||
mState = SAVE;
|
||||
break;
|
||||
//Set Audio volume
|
||||
case kBackToMainMenuID:
|
||||
case GameStateOptionsConst::kBackToMainMenuID:
|
||||
mParent->DoTransition(TRANSITION_FADE, GAME_STATE_MENU);
|
||||
break;
|
||||
case kCancelMenuID:
|
||||
mState = SHOW_OPTIONS;
|
||||
break;
|
||||
case kNewProfileID:
|
||||
case GameStateOptionsConst::kNewProfileID:
|
||||
options.keypadStart("", &newProfile);
|
||||
options.keypadTitle("New Profile");
|
||||
break;
|
||||
case kReloadID:
|
||||
case GameStateOptionsConst::kReloadID:
|
||||
mReload = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ void GameStateStory::Update(float dt)
|
||||
if (!menu && mEngine->GetButtonClick(JGE_BTN_MENU))
|
||||
{
|
||||
menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), 100, this, Fonts::MENU_FONT, SCREEN_WIDTH / 2 - 100, 25);
|
||||
menu->Add(0, "Back to main menu");
|
||||
menu->Add(0, string("Back to main menu"));
|
||||
menu->Add(kCancelMenuID, "Cancel");
|
||||
}
|
||||
if (menu)
|
||||
|
||||
@@ -16,21 +16,21 @@ const float kZoom_level1 = 1.4f;
|
||||
const float kZoom_level2 = 2.2f;
|
||||
const float kZoom_level3 = 2.7f;
|
||||
|
||||
struct True: public Exp
|
||||
struct GuiCombatTrue: public Exp
|
||||
{
|
||||
static inline bool test(DamagerDamaged*, DamagerDamaged*)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
struct Left: public Exp
|
||||
struct GuiCombatLeft: public Exp
|
||||
{
|
||||
static inline bool test(DamagerDamaged* ref, DamagerDamaged* test)
|
||||
{
|
||||
return ref->y == test->y && ref->x > test->x && test->show;
|
||||
}
|
||||
};
|
||||
struct Right: public Exp
|
||||
struct GuiCombatRight: public Exp
|
||||
{
|
||||
static inline bool test(DamagerDamaged* ref, DamagerDamaged* test)
|
||||
{
|
||||
@@ -217,7 +217,7 @@ void GuiCombat::shiftLeft()
|
||||
case ATK:
|
||||
{
|
||||
DamagerDamaged* old = active;
|
||||
active = closest<Left> (attackers, NULL, static_cast<AttackerDamaged*> (active));
|
||||
active = closest<GuiCombatLeft> (attackers, NULL, static_cast<AttackerDamaged*> (active));
|
||||
activeAtk = static_cast<AttackerDamaged*> (active);
|
||||
if (old != active)
|
||||
{
|
||||
@@ -231,7 +231,7 @@ void GuiCombat::shiftLeft()
|
||||
case BLK:
|
||||
{
|
||||
DamagerDamaged* old = active;
|
||||
active = closest<Left> (activeAtk->blockers, NULL, static_cast<DefenserDamaged*> (active));
|
||||
active = closest<GuiCombatLeft> (activeAtk->blockers, NULL, static_cast<DefenserDamaged*> (active));
|
||||
if (old != active)
|
||||
{
|
||||
if (old)
|
||||
@@ -255,7 +255,7 @@ void GuiCombat::shiftRight( DamagerDamaged* oldActive )
|
||||
case BLK:
|
||||
{
|
||||
DamagerDamaged* old = active;
|
||||
active = closest<Right> (activeAtk->blockers, NULL, static_cast<DefenserDamaged*> (active));
|
||||
active = closest<GuiCombatRight> (activeAtk->blockers, NULL, static_cast<DefenserDamaged*> (active));
|
||||
if (old != active)
|
||||
{
|
||||
if (old)
|
||||
@@ -268,7 +268,7 @@ void GuiCombat::shiftRight( DamagerDamaged* oldActive )
|
||||
case ATK:
|
||||
{
|
||||
DamagerDamaged* old = active;
|
||||
active = closest<Right> (attackers, NULL, static_cast<AttackerDamaged*> (active));
|
||||
active = closest<GuiCombatRight> (attackers, NULL, static_cast<AttackerDamaged*> (active));
|
||||
if (active == oldActive)
|
||||
{
|
||||
active = activeAtk = NULL;
|
||||
@@ -321,7 +321,7 @@ bool GuiCombat::CheckUserInput(JButton key)
|
||||
// position selected card
|
||||
if (BLK == cursor_pos)
|
||||
{
|
||||
DamagerDamaged* selectedCard = closest<True> (activeAtk->blockers, NULL, static_cast<float> (x), static_cast<float> (y));
|
||||
DamagerDamaged* selectedCard = closest<GuiCombatTrue> (activeAtk->blockers, NULL, static_cast<float> (x), static_cast<float> (y));
|
||||
// find the index into the vector where the current selected card is.
|
||||
int c1 = 0, c2 = 0;
|
||||
int i = 0;
|
||||
@@ -526,7 +526,7 @@ int GuiCombat::resolve() // Returns the number of damage objects dealt this turn
|
||||
}
|
||||
|
||||
if (dmg > 0 && ((!attacker->isBlocked()) || attacker->has(Constants::TRAMPLE)))
|
||||
stack->Add(NEW Damage(observer, (*it)->card, (Damageable*)attacker->isAttacking?(Damageable*)attacker->isAttacking:observer->opponent(), dmg, DAMAGE_COMBAT));
|
||||
stack->Add(NEW Damage(observer, (*it)->card, (Damageable*)attacker->isAttacking?(Damageable*)attacker->isAttacking:observer->opponent(), dmg, Damage::DAMAGE_COMBAT));
|
||||
|
||||
for (vector<Damage>::iterator d = (*it)->damages.begin(); d != (*it)->damages.end(); ++d)
|
||||
stack->Add(NEW Damage(*d));
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
#include "GuiMessageBox.h"
|
||||
|
||||
bool GuiMessageBox::CheckUserInput(JButton key)
|
||||
{
|
||||
if (mActionButton == key)
|
||||
{
|
||||
if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed())
|
||||
{
|
||||
if (mListener != NULL)
|
||||
{
|
||||
mListener->ButtonPressed(mId, mObjects[mCurr]->GetId());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((PSP_CTRL_LEFT == key) || (PSP_CTRL_UP == key)) // || mEngine->GetAnalogY()<64)
|
||||
{
|
||||
int n = mCurr;
|
||||
n--;
|
||||
if (n < 0)
|
||||
{
|
||||
if ((mStyle & JGUI_STYLE_WRAPPING))
|
||||
n = mCount - 1;
|
||||
else
|
||||
n = 0;
|
||||
}
|
||||
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_UP))
|
||||
{
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if ((PSP_CTRL_RIGHT == key) || (PSP_CTRL_DOWN == key)) // || mEngine->GetAnalogY()>192)
|
||||
{
|
||||
int n = mCurr;
|
||||
n++;
|
||||
if (n > mCount - 1)
|
||||
{
|
||||
if ((mStyle & JGUI_STYLE_WRAPPING))
|
||||
n = 0;
|
||||
else
|
||||
n = mCount - 1;
|
||||
}
|
||||
|
||||
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_DOWN))
|
||||
{
|
||||
mCurr = n;
|
||||
mObjects[mCurr]->Entering();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1145,7 +1145,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
}
|
||||
|
||||
|
||||
if(strncmp(s.c_str(), "chooseacolor ", strlen("chooseacolor ")) == 0 || strncmp(s.c_str(), "chooseatype ", strlen("chooseatype ")) == 0)
|
||||
if (StartsWith(s, "chooseacolor ") || StartsWith(s, "chooseatype "))
|
||||
{
|
||||
MTGAbility * choose = parseChooseActionAbility(s,card,spell,target,0,id);
|
||||
choose = NEW GenericActivatedAbility(observer, "","",id, card,choose,NULL);
|
||||
@@ -2163,6 +2163,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
return NEW AEquip(observer, id, card);
|
||||
}
|
||||
|
||||
// TODO: deprecate this ability in favor of retarget
|
||||
//Equipment (attach)
|
||||
found = s.find("attach");
|
||||
if (found != string::npos)
|
||||
@@ -3271,7 +3272,7 @@ MTGAbility * AbilityFactory::parseChooseActionAbility(string s,MTGCardInstance *
|
||||
a->canBeInterrupted = false;
|
||||
return a;
|
||||
}
|
||||
//choose a color
|
||||
//choose a color
|
||||
vector<string> splitChooseAColor = parseBetween(s, "chooseacolor ", " chooseend");
|
||||
if (splitChooseAColor.size())
|
||||
{
|
||||
@@ -4367,6 +4368,7 @@ MTGAbility::MTGAbility(GameObserver* observer, int id, MTGCardInstance * card) :
|
||||
aType = MTGAbility::UNKNOWN;
|
||||
mCost = NULL;
|
||||
forceDestroy = 0;
|
||||
forcedAlive = 0;
|
||||
oneShot = 0;
|
||||
canBeInterrupted = true;
|
||||
}
|
||||
@@ -4380,6 +4382,7 @@ MTGAbility::MTGAbility(GameObserver* observer, int id, MTGCardInstance * _source
|
||||
aType = MTGAbility::UNKNOWN;
|
||||
mCost = NULL;
|
||||
forceDestroy = 0;
|
||||
forcedAlive = 0;
|
||||
oneShot = 0;
|
||||
canBeInterrupted = true;
|
||||
}
|
||||
@@ -4476,7 +4479,7 @@ Player * MTGAbility::getPlayerFromDamageable(Damageable * target)
|
||||
if (!target)
|
||||
return NULL;
|
||||
|
||||
if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
return ((MTGCardInstance *) target)->controller();
|
||||
|
||||
return (Player *) target;
|
||||
@@ -4892,7 +4895,7 @@ int TargetAbility::resolve()
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char * TargetAbility::getMenuText()
|
||||
const string TargetAbility::getMenuText()
|
||||
{
|
||||
if (ability)
|
||||
return ability->getMenuText();
|
||||
@@ -5422,7 +5425,7 @@ GenericTriggeredAbility::~GenericTriggeredAbility()
|
||||
SAFE_DELETE(destroyCondition);
|
||||
}
|
||||
|
||||
const char * GenericTriggeredAbility::getMenuText()
|
||||
const string GenericTriggeredAbility::getMenuText()
|
||||
{
|
||||
return ability->getMenuText();
|
||||
}
|
||||
@@ -5450,6 +5453,7 @@ AManaProducer::AManaProducer(GameObserver* observer, int id, MTGCardInstance * c
|
||||
aType = MTGAbility::MANA_PRODUCER;
|
||||
setCost(_cost);
|
||||
output = _output;
|
||||
tap = 0;
|
||||
Producing = producing;
|
||||
menutext = "";
|
||||
DoesntEmpty = doesntEmpty;
|
||||
@@ -5515,7 +5519,7 @@ int AManaProducer::reactToClick(MTGCardInstance * _card)
|
||||
return ActivatedAbility::activateAbility();
|
||||
}
|
||||
|
||||
const char * AManaProducer::getMenuText()
|
||||
const string AManaProducer::getMenuText()
|
||||
{
|
||||
if (menutext.size())
|
||||
return menutext.c_str();
|
||||
|
||||
@@ -125,6 +125,7 @@ int MTGCardInstance::init()
|
||||
|
||||
void MTGCardInstance::initMTGCI()
|
||||
{
|
||||
X = 0;
|
||||
sample = "";
|
||||
model = NULL;
|
||||
isToken = false;
|
||||
@@ -195,6 +196,8 @@ void MTGCardInstance::initMTGCI()
|
||||
lastController = NULL;
|
||||
regenerateTokens = 0;
|
||||
blocked = false;
|
||||
graveEffects = false;
|
||||
exileEffects = false;
|
||||
currentZone = NULL;
|
||||
cardsAbilities = vector<MTGAbility *>();
|
||||
data = this; //an MTGCardInstance point to itself for data, allows to update it without killing the underlying database item
|
||||
@@ -254,22 +257,22 @@ void MTGCardInstance::addType(int type)
|
||||
SAFE_DELETE(e);
|
||||
}
|
||||
|
||||
void MTGCardInstance::addType(char * type_text)
|
||||
void MTGCardInstance::addType(const string& type_text)
|
||||
{
|
||||
setSubtype(type_text);
|
||||
}
|
||||
|
||||
void MTGCardInstance::setType(const char * type_text)
|
||||
void MTGCardInstance::setType(const string& type_text)
|
||||
{
|
||||
setSubtype(type_text);
|
||||
}
|
||||
|
||||
void MTGCardInstance::setSubtype(string value)
|
||||
void MTGCardInstance::setSubtype(const string& value)
|
||||
{
|
||||
int id = MTGAllCards::findType(value);
|
||||
addType(id);
|
||||
}
|
||||
int MTGCardInstance::removeType(string value, int removeAll)
|
||||
int MTGCardInstance::removeType(const string& value, int removeAll)
|
||||
{
|
||||
int id = MTGAllCards::findType(value);
|
||||
return removeType(id, removeAll);
|
||||
|
||||
@@ -47,33 +47,33 @@ static inline int getGrade(int v)
|
||||
int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primitive)
|
||||
{
|
||||
if ('#' == s[0]) return 1; // a comment shouldn't be treated as an error condition
|
||||
size_t i = s.find_first_of('=');
|
||||
if (i == string::npos || 0 == i)
|
||||
size_t del_pos = s.find_first_of('=');
|
||||
if (del_pos == string::npos || 0 == del_pos)
|
||||
return 0;
|
||||
|
||||
char* key = const_cast<char*> (s.c_str()); // I know what I'm doing, let me do it
|
||||
key[i] = 0;
|
||||
char* val = key + i + 1;
|
||||
|
||||
s[del_pos] = '\0';
|
||||
const string key = s.substr(0, del_pos);
|
||||
const string val = s.substr(del_pos + 1);
|
||||
|
||||
switch (key[0])
|
||||
{
|
||||
case 'a':
|
||||
if (0 == strcmp("auto", key))
|
||||
if (key == "auto")
|
||||
{
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->addMagicText(val);
|
||||
}
|
||||
else if (0 == strncmp("auto", key, 4))
|
||||
else if (StartsWith(key, "auto"))
|
||||
{
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->addMagicText(val, key + 4);
|
||||
primitive->addMagicText(val, key.substr(4));
|
||||
}
|
||||
else if (0 == strcmp("alias", key))
|
||||
else if (key == "alias")
|
||||
{
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->alias = atoi(val);
|
||||
primitive->alias = atoi(val.c_str());
|
||||
}
|
||||
else if (0 == strcmp("abilities", key))
|
||||
else if (key == "abilities")
|
||||
{
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
string value = val;
|
||||
@@ -152,12 +152,12 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
}
|
||||
|
||||
case 'g': //grade
|
||||
if (s.size() - i - 1 > 2) currentGrade = getGrade(val[2]);
|
||||
if (s.size() - del_pos - 1 > 2) currentGrade = getGrade(val[2]);
|
||||
break;
|
||||
|
||||
case 'i': //id
|
||||
if (!card) card = NEW MTGCard();
|
||||
card->setMTGId(atoi(val));
|
||||
card->setMTGId(atoi(val.c_str()));
|
||||
break;
|
||||
|
||||
case 'k': //kicker
|
||||
@@ -222,7 +222,7 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
if ('r' == key[1])
|
||||
if (key[1] == 'r')
|
||||
{ // primitive
|
||||
if (!card) card = NEW MTGCard();
|
||||
map<string, CardPrimitive*>::iterator it = primitives.find(val);
|
||||
@@ -231,18 +231,18 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
else
|
||||
{ //power
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->setPower(atoi(val));
|
||||
primitive->setPower(atoi(val.c_str()));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'r': //retrace/rarity//restrictions
|
||||
if('s' == key[2] && 't' == key[3])//restrictions
|
||||
if(key[2] == 's' && key[3] == 't')//restrictions
|
||||
{
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
string value = val;
|
||||
primitive->setRestrictions(value);
|
||||
}
|
||||
else if ('e' == key[1] && 't' == key[2])
|
||||
else if (key[1] == 'e' && key[2] == 't')
|
||||
{ //retrace
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
if (ManaCost * cost = primitive->getManaCost())
|
||||
@@ -279,7 +279,7 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
else
|
||||
{
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
vector<string> values = split(val, ' ');
|
||||
vector<string> values = split(val.c_str(), ' ');
|
||||
for (size_t values_i = 0; values_i < values.size(); ++values_i)
|
||||
primitive->setSubtype(values[values_i]);
|
||||
}
|
||||
@@ -288,21 +288,21 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
|
||||
case 't':
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
if (0 == strcmp("target", key))
|
||||
if (key == "target")
|
||||
{
|
||||
string value = val;
|
||||
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
|
||||
primitive->spellTargetType = value;
|
||||
}
|
||||
else if (0 == strcmp("text", key))
|
||||
else if (key == "text")
|
||||
primitive->setText(val);
|
||||
else if (0 == strcmp("type", key))
|
||||
else if (key == "type")
|
||||
{
|
||||
vector<string> values = split(val, ' ');
|
||||
for (size_t values_i = 0; values_i < values.size(); ++values_i)
|
||||
primitive->setType(values[values_i]);
|
||||
}
|
||||
else if (0 == strcmp("toughness", key)) primitive->setToughness(atoi(val));
|
||||
else if (key == "toughness") primitive->setToughness(atoi(val.c_str()));
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -317,7 +317,7 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
tempPrimitive = primitive;
|
||||
tempCard = card;
|
||||
|
||||
return i;
|
||||
return del_pos;
|
||||
|
||||
}
|
||||
|
||||
@@ -381,10 +381,20 @@ void MTGAllCards::loadFolder(const string& infolder, const string& filename )
|
||||
}
|
||||
}
|
||||
|
||||
int MTGAllCards::load(const char * config_file, const char * set_name, int)
|
||||
int MTGAllCards::load(const string &config_file)
|
||||
{
|
||||
return load(config_file, MTGSets::INTERNAL_SET);
|
||||
}
|
||||
|
||||
int MTGAllCards::load(const string& config_file, const string &set_name)
|
||||
{
|
||||
const int set_id = setlist.Add(set_name);
|
||||
return load(config_file, set_id);
|
||||
}
|
||||
|
||||
int MTGAllCards::load(const string &config_file, int set_id)
|
||||
{
|
||||
conf_read_mode = 0;
|
||||
const int set_id = set_name ? setlist.Add(set_name) : MTGSets::INTERNAL_SET;
|
||||
MTGSetInfo *si = setlist.getInfo(set_id);
|
||||
|
||||
int lineNumber = 0;
|
||||
@@ -532,14 +542,16 @@ int MTGAllCards::countBySet(int setId)
|
||||
}
|
||||
|
||||
//TODO more efficient way ?
|
||||
int MTGAllCards::countByType(const char * _type)
|
||||
int MTGAllCards::countByType(const string &_type)
|
||||
{
|
||||
int type_id = findType(_type);
|
||||
|
||||
int result = 0;
|
||||
map<int, MTGCard *>::iterator it;
|
||||
for (it = collection.begin(); it != collection.end(); it++)
|
||||
{
|
||||
MTGCard * c = it->second;
|
||||
if (c->data->hasType(_type))
|
||||
if (c->data->hasType(type_id))
|
||||
{
|
||||
result++;
|
||||
}
|
||||
@@ -772,7 +784,7 @@ int MTGDeck::totalPrice()
|
||||
return total;
|
||||
}
|
||||
|
||||
MTGDeck::MTGDeck(const char * config_file, MTGAllCards * _allcards, int meta_only,int difficultyRating)
|
||||
MTGDeck::MTGDeck(const string& config_file, MTGAllCards * _allcards, int meta_only, int difficultyRating)
|
||||
{
|
||||
total_cards = 0;
|
||||
database = _allcards;
|
||||
@@ -879,7 +891,7 @@ MTGCard * MTGDeck::getCardById(int mtgId)
|
||||
return database->getCardById(mtgId);
|
||||
}
|
||||
|
||||
int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, const char * _subtype, int * colors, int nbcolors)
|
||||
int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, const string &_subtype, int * colors, int nbcolors)
|
||||
{
|
||||
if (howmany <= 0) return 1;
|
||||
|
||||
@@ -900,8 +912,8 @@ int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, c
|
||||
int collectionTotal = database->totalCards();
|
||||
if (!collectionTotal) return 0;
|
||||
|
||||
char subtype[4096];
|
||||
if (_subtype) sprintf(subtype, "%s", _subtype);
|
||||
string subtype;
|
||||
if (_subtype.size()) subtype = _subtype;
|
||||
|
||||
vector<int> subcollection;
|
||||
int subtotal = 0;
|
||||
@@ -911,7 +923,7 @@ int MTGDeck::addRandomCards(int howmany, int * setIds, int nbSets, int rarity, c
|
||||
int r = card->getRarity();
|
||||
if (r != Constants::RARITY_T && (rarity == -1 || r == rarity) && // remove tokens
|
||||
card->setId != MTGSets::INTERNAL_SET && //remove cards that are defined in primitives. Those are workarounds (usually tokens) and should only be used internally
|
||||
(!_subtype || card->data->hasSubtype(subtype)))
|
||||
(!_subtype.size() || card->data->hasSubtype(subtype)))
|
||||
{
|
||||
int ok = 0;
|
||||
|
||||
@@ -1265,7 +1277,7 @@ MTGSetInfo* MTGSets::randomSet(int blockId, int atleast)
|
||||
|
||||
int blockSize(int blockId);
|
||||
|
||||
int MTGSets::Add(const char * name)
|
||||
int MTGSets::Add(const string& name)
|
||||
{
|
||||
int setid = findSet(name);
|
||||
if (setid != -1) return setid;
|
||||
@@ -1344,7 +1356,7 @@ MTGSetInfo::~MTGSetInfo()
|
||||
SAFE_DELETE(mPack);
|
||||
}
|
||||
|
||||
MTGSetInfo::MTGSetInfo(string _id)
|
||||
MTGSetInfo::MTGSetInfo(const string& _id)
|
||||
{
|
||||
string whitespaces(" \t\f\v\n\r");
|
||||
id = _id;
|
||||
|
||||
@@ -162,7 +162,7 @@ int Constants::GetColorStringIndex(string mtgColor)
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char* Constants::MTGPhaseNames[] =
|
||||
const string Constants::MTGPhaseNames[] =
|
||||
{
|
||||
"---",
|
||||
"Untap",
|
||||
|
||||
@@ -17,7 +17,7 @@ void MTGGamePhase::Update(float)
|
||||
int newState = observer->getCurrentGamePhase();
|
||||
if (newState != currentState)
|
||||
{
|
||||
activeState = ACTIVE;
|
||||
activity = Active;
|
||||
animation = 4;
|
||||
currentState = newState;
|
||||
}
|
||||
@@ -28,18 +28,18 @@ void MTGGamePhase::Update(float)
|
||||
}
|
||||
else
|
||||
{
|
||||
activeState = INACTIVE;
|
||||
activity = Inactive;
|
||||
animation = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool MTGGamePhase::NextGamePhase()
|
||||
{
|
||||
if (activeState == INACTIVE)
|
||||
if (activity == Inactive)
|
||||
{
|
||||
if (observer->currentActionPlayer == observer->currentlyActing())
|
||||
{
|
||||
activeState = ACTIVE;
|
||||
activity = Active;
|
||||
observer->userRequestNextGamePhase();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ size_t MTGGameZone::getIndex(MTGCardInstance * card)
|
||||
}
|
||||
|
||||
|
||||
unsigned int MTGGameZone::countByType(const char * value)
|
||||
unsigned int MTGGameZone::countByType(const string &value)
|
||||
{
|
||||
int result = 0;
|
||||
int subTypeId = MTGAllCards::findType(value);
|
||||
@@ -539,7 +539,7 @@ unsigned int MTGGameZone::countByType(const char * value)
|
||||
{
|
||||
result++;
|
||||
}
|
||||
else if(strcmp(value, "token") == 0 && cards[i]->isToken)
|
||||
else if(value == "token" && cards[i]->isToken)
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -293,7 +293,7 @@ void MTGPacks::loadAll()
|
||||
sprintf(myFilename, "packs/%s",relative.c_str());
|
||||
if (relative[0] == '.')
|
||||
continue;
|
||||
if (!strcmp(relative.c_str(), "default_booster.txt"))
|
||||
if (relative == "default_booster.txt")
|
||||
continue;
|
||||
MTGPack * p = NEW MTGPack(myFilename);
|
||||
if (!p->isValid())
|
||||
|
||||
@@ -997,9 +997,9 @@ int MTGSuspendRule::reactToClick(MTGCardInstance * card)
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * MTGSuspendRule::getMenuText()
|
||||
const string MTGSuspendRule::getMenuText()
|
||||
{
|
||||
return suspendmenu.c_str();
|
||||
return suspendmenu;
|
||||
}
|
||||
|
||||
ostream& MTGSuspendRule::toString(ostream& out) const
|
||||
@@ -1333,9 +1333,9 @@ int AAPlaneswalkerAttacked::resolve()
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* AAPlaneswalkerAttacked::getMenuText()
|
||||
const string AAPlaneswalkerAttacked::getMenuText()
|
||||
{
|
||||
return menuText.c_str();
|
||||
return menuText;
|
||||
}
|
||||
|
||||
AAPlaneswalkerAttacked * AAPlaneswalkerAttacked::clone() const
|
||||
@@ -1597,9 +1597,9 @@ int MTGBlockRule::reactToClick(MTGCardInstance * card)
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char * MTGBlockRule::getMenuText()
|
||||
const string MTGBlockRule::getMenuText()
|
||||
{
|
||||
return blockmenu.c_str();
|
||||
return blockmenu;
|
||||
}
|
||||
|
||||
ostream& MTGBlockRule::toString(ostream& out) const
|
||||
@@ -2700,7 +2700,7 @@ int MTGDeathtouchRule::receiveEvent(WEvent * event)
|
||||
if (!card)
|
||||
return 0;
|
||||
|
||||
if (d->target->type_as_damageable != DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (d->target->type_as_damageable != Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
return 0;
|
||||
MTGCardInstance * _target = (MTGCardInstance *) (d->target);
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#include "MTGSpellStack.h"
|
||||
|
||||
MTGSpellStack::MTGSpellStack()
|
||||
{
|
||||
cursor = -1;
|
||||
}
|
||||
|
||||
void MTGSpellStack::addSpell(Ability * ability)
|
||||
{
|
||||
cursor++;
|
||||
spellStack[cursor] ability;
|
||||
}
|
||||
|
||||
int MTGSpellStack::resolve()
|
||||
{
|
||||
if (cursor < 0)
|
||||
return 0;
|
||||
int result = cursor;
|
||||
cursor--;
|
||||
(spellStack[cursor + 1])->resolve();
|
||||
return (result + 1);
|
||||
}
|
||||
@@ -25,23 +25,23 @@ bool ModRules::load(string filename)
|
||||
TiXmlElement* element = node->ToElement();
|
||||
if (element != NULL)
|
||||
{
|
||||
if (strcmp(element->Value(), "menu") == 0)
|
||||
if (element->ValueStr() == "menu")
|
||||
{
|
||||
menu.parse(element);
|
||||
}
|
||||
else if (strcmp(element->Value(), "general") == 0)
|
||||
else if (element->ValueStr() == "general")
|
||||
{
|
||||
general.parse(element);
|
||||
}
|
||||
else if (strcmp(element->Value(), "cards") == 0)
|
||||
else if (element->ValueStr() == "cards")
|
||||
{
|
||||
cards.parse(element);
|
||||
}
|
||||
else if (strcmp(element->Value(), "game") == 0)
|
||||
else if (element->ValueStr() == "game")
|
||||
{
|
||||
game.parse(element);
|
||||
}
|
||||
else if (strcmp(element->Value(), "cardgui") == 0)
|
||||
else if (element->ValueStr() == "cardgui")
|
||||
{
|
||||
cardgui.parse(element);
|
||||
}
|
||||
|
||||
@@ -142,9 +142,10 @@ bool PhaseRing::extraDamagePhase(int id)
|
||||
return false;
|
||||
}
|
||||
|
||||
const char * PhaseRing::phaseName(int id)
|
||||
const string& PhaseRing::phaseName(int id)
|
||||
{
|
||||
if (extraDamagePhase(id)) return "Combat Damage (2)";
|
||||
static const string combatPhase2("Combat Damage (2)");
|
||||
if (extraDamagePhase(id)) return combatPhase2;
|
||||
return Constants::MTGPhaseNames[id];
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "AllAbilities.h"
|
||||
|
||||
REDamagePrevention::REDamagePrevention(MTGAbility * source, TargetChooser *tcSource, TargetChooser *tcTarget, int damage,
|
||||
bool oneShot, int typeOfDamage) :
|
||||
bool oneShot, Damage::DamageType typeOfDamage) :
|
||||
source(source), tcSource(tcSource), tcTarget(tcTarget), damage(damage), oneShot(oneShot), typeOfDamage(typeOfDamage)
|
||||
{
|
||||
}
|
||||
@@ -18,7 +18,7 @@ WEvent * REDamagePrevention::replace(WEvent *event)
|
||||
WEventDamage * e = dynamic_cast<WEventDamage*> (event);
|
||||
if (!e) return event;
|
||||
Damage *d = e->damage;
|
||||
if (d->typeOfDamage != typeOfDamage && typeOfDamage != DAMAGE_ALL_TYPES) return event;
|
||||
if (d->typeOfDamage != typeOfDamage && typeOfDamage != Damage::DAMAGE_ALL_TYPES) return event;
|
||||
if ((!tcSource || tcSource->canTarget(d->source)) && (!tcTarget || tcTarget->canTarget(d->target)))
|
||||
{
|
||||
if (damage == -1)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "GameApp.h"
|
||||
#include "Translate.h"
|
||||
|
||||
namespace
|
||||
namespace SimpleMenuConst
|
||||
{
|
||||
const float kPoleWidth = 7;
|
||||
const float kVerticalMargin = 20;
|
||||
@@ -38,7 +38,7 @@ SimpleMenu::SimpleMenu(JGE* jge, WResourceManager* resourceManager, int id, JGui
|
||||
{
|
||||
autoTranslate = true;
|
||||
isMultipleChoice = false;
|
||||
mHeight = 2 * kVerticalMargin;
|
||||
mHeight = 2 * SimpleMenuConst::kVerticalMargin;
|
||||
mWidth = 0;
|
||||
mX = x;
|
||||
mY = y;
|
||||
@@ -48,7 +48,7 @@ SimpleMenu::SimpleMenu(JGE* jge, WResourceManager* resourceManager, int id, JGui
|
||||
selectionT = 0;
|
||||
timeOpen = 0;
|
||||
mClosed = false;
|
||||
selectionTargetY = selectionY = y + kVerticalMargin;
|
||||
selectionTargetY = selectionY = y + SimpleMenuConst::kVerticalMargin;
|
||||
|
||||
if(resourceManager)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ SimpleMenu::SimpleMenu(JGE* jge, WResourceManager* resourceManager, int id, JGui
|
||||
spadeL = resourceManager->RetrieveQuad("spade_ul.png", 0, 0, 0, 0, "spade_ul", RETRIEVE_MANAGE);
|
||||
spadeR = resourceManager->RetrieveQuad("spade_ur.png", 0, 0, 0, 0, "spade_ur", RETRIEVE_MANAGE);
|
||||
jewel.reset(NEW JQuad(jewelTex, 1, 1, 3, 3));
|
||||
side = resourceManager->RetrieveQuad("menuside.png", 1, 1, 1, kPoleWidth, "menuside", RETRIEVE_MANAGE);
|
||||
side = resourceManager->RetrieveQuad("menuside.png", 1, 1, 1, SimpleMenuConst::kPoleWidth, "menuside", RETRIEVE_MANAGE);
|
||||
|
||||
stars = NEW hgeParticleSystem(resourceManager->RetrievePSI("stars.psi", resourceManager->GetQuad("stars").get()));
|
||||
|
||||
@@ -78,16 +78,16 @@ void SimpleMenu::drawHorzPole(float x, float y, float width)
|
||||
{
|
||||
JRenderer* renderer = JRenderer::GetInstance();
|
||||
|
||||
float leftXOffset = (spadeR->mWidth - kPoleWidth) / 2;
|
||||
float leftXOffset = (spadeR->mWidth - SimpleMenuConst::kPoleWidth) / 2;
|
||||
float rightXOffset = leftXOffset;
|
||||
float yOffset = leftXOffset;
|
||||
if (spadeR->mWidth != spadeR->mHeight)
|
||||
{
|
||||
//We have a weird case to deal with in the "Classic" theme, the spades graphics need to be aligned specifically,
|
||||
// While the ones in the "Final Saga" theme need to be centered
|
||||
leftXOffset = kSpadeWidthOffset;
|
||||
yOffset = kSpadeHeightOffset;
|
||||
rightXOffset = kSpadeRightBottomOffset;
|
||||
leftXOffset = SimpleMenuConst::kSpadeWidthOffset;
|
||||
yOffset = SimpleMenuConst::kSpadeHeightOffset;
|
||||
rightXOffset = SimpleMenuConst::kSpadeRightBottomOffset;
|
||||
}
|
||||
|
||||
renderer->RenderQuad(side.get(), x, y, 0, width);
|
||||
@@ -104,23 +104,23 @@ void SimpleMenu::drawVertPole(float x, float y, float height)
|
||||
{
|
||||
JRenderer* renderer = JRenderer::GetInstance();
|
||||
|
||||
float xOffset = (spadeR->mWidth - kPoleWidth) / 2;
|
||||
float xOffset = (spadeR->mWidth - SimpleMenuConst::kPoleWidth) / 2;
|
||||
float topYOffset = xOffset;
|
||||
float bottomYOffset = xOffset;
|
||||
if (spadeR->mWidth != spadeR->mHeight)
|
||||
{
|
||||
//We have a weird case to deal with in the "Classic" theme, the spades graphics need to be aligned specifically,
|
||||
// While the ones in the "Final Saga" theme need to be centered
|
||||
xOffset = kSpadeHeightOffset;
|
||||
topYOffset = kSpadeWidthOffset;
|
||||
bottomYOffset = kSpadeRightBottomOffset;
|
||||
xOffset = SimpleMenuConst::kSpadeHeightOffset;
|
||||
topYOffset = SimpleMenuConst::kSpadeWidthOffset;
|
||||
bottomYOffset = SimpleMenuConst::kSpadeRightBottomOffset;
|
||||
}
|
||||
|
||||
renderer->RenderQuad(side.get(), x + kPoleWidth, y, M_PI / 2, height);
|
||||
renderer->RenderQuad(side.get(), x + SimpleMenuConst::kPoleWidth, y, M_PI / 2, height);
|
||||
spadeR->SetHFlip(true);
|
||||
spadeL->SetHFlip(false);
|
||||
renderer->RenderQuad(spadeR.get(), x + kPoleWidth + xOffset, y - topYOffset, M_PI / 2);
|
||||
renderer->RenderQuad(spadeL.get(), x + kPoleWidth + xOffset, y + height - bottomYOffset, M_PI / 2);
|
||||
renderer->RenderQuad(spadeR.get(), x + SimpleMenuConst::kPoleWidth + xOffset, y - topYOffset, M_PI / 2);
|
||||
renderer->RenderQuad(spadeL.get(), x + SimpleMenuConst::kPoleWidth + xOffset, y + height - bottomYOffset, M_PI / 2);
|
||||
|
||||
renderer->RenderQuad(jewel.get(), x - 1, y - 1);
|
||||
renderer->RenderQuad(jewel.get(), x - 1, y + height - 1);
|
||||
@@ -133,7 +133,7 @@ void SimpleMenu::Render()
|
||||
WFont * mFont = WResourceManager::Instance()->GetWFont(fontId);
|
||||
if (0 == mWidth)
|
||||
{
|
||||
float sY = mY + kVerticalMargin;
|
||||
float sY = mY + SimpleMenuConst::kVerticalMargin;
|
||||
|
||||
for (int i = 0; i < mCount; ++i)
|
||||
{
|
||||
@@ -146,7 +146,7 @@ void SimpleMenu::Render()
|
||||
if ((!title.empty()) && (mWidth < titleFont->GetStringWidth(title.c_str())))
|
||||
mWidth = titleFont->GetStringWidth(title.c_str());
|
||||
titleFont->SetScale(scaleFactor);
|
||||
mWidth += 2 * kHorizontalMargin;
|
||||
mWidth += 2 * SimpleMenuConst::kHorizontalMargin;
|
||||
|
||||
if (mCenterHorizontal)
|
||||
mX = (SCREEN_WIDTH_F - mWidth) / 2;
|
||||
@@ -156,7 +156,7 @@ void SimpleMenu::Render()
|
||||
|
||||
for (int i = 0; i < mCount; ++i)
|
||||
{
|
||||
float y = mY + kVerticalMargin + i * kLineHeight;
|
||||
float y = mY + SimpleMenuConst::kVerticalMargin + i * SimpleMenuConst::kLineHeight;
|
||||
SimpleMenuItem * smi = static_cast<SimpleMenuItem*> (mObjects[i]);
|
||||
smi->Relocate(mX + mWidth / 2, y);
|
||||
if (smi->hasFocus()) sY = y;
|
||||
@@ -171,7 +171,7 @@ void SimpleMenu::Render()
|
||||
float height = mHeight;
|
||||
if (timeOpen < 1) height *= timeOpen > 0 ? timeOpen : -timeOpen;
|
||||
|
||||
float heightPadding = kLineHeight/2; // this to reduce the bottom padding of the menu
|
||||
float heightPadding = SimpleMenuConst::kLineHeight/2; // this to reduce the bottom padding of the menu
|
||||
renderer->FillRect(mX, mY, mWidth, height - heightPadding, ARGB(180,0,0,0));
|
||||
|
||||
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
|
||||
@@ -200,8 +200,8 @@ void SimpleMenu::Render()
|
||||
{
|
||||
if (i > mCount - 1) break;
|
||||
SimpleMenuItem *currentMenuItem = static_cast<SimpleMenuItem*>(mObjects[i]);
|
||||
float currentY = currentMenuItem->getY() - kLineHeight * startId;
|
||||
float menuBottomEdge = mY + height - kLineHeight + 7;
|
||||
float currentY = currentMenuItem->getY() - SimpleMenuConst::kLineHeight * startId;
|
||||
float menuBottomEdge = mY + height - SimpleMenuConst::kLineHeight + 7;
|
||||
if (currentY < menuBottomEdge)
|
||||
{
|
||||
if (currentMenuItem->hasFocus())
|
||||
@@ -214,7 +214,7 @@ void SimpleMenu::Render()
|
||||
{
|
||||
mFont->SetColor(ARGB(150,255,255,255));
|
||||
}
|
||||
(static_cast<SimpleMenuItem*> (mObjects[i]))->RenderWithOffset(-kLineHeight * startId);
|
||||
(static_cast<SimpleMenuItem*> (mObjects[i]))->RenderWithOffset(-SimpleMenuConst::kLineHeight * startId);
|
||||
}
|
||||
mFont->SetScale(SCALE_NORMAL);
|
||||
}
|
||||
@@ -244,8 +244,8 @@ bool SimpleMenu::CheckUserInput(JButton key)
|
||||
if (mObjects.size())
|
||||
{
|
||||
float top, left;
|
||||
float menuTopEdge = mY + kLineHeight;
|
||||
float menuBottomEdge = mY + mHeight - (kLineHeight/2);
|
||||
float menuTopEdge = mY + SimpleMenuConst::kLineHeight;
|
||||
float menuBottomEdge = mY + mHeight - (SimpleMenuConst::kLineHeight/2);
|
||||
|
||||
if (y < menuTopEdge)
|
||||
n = (mCurr - 1) > 0 ? mCurr -1 : 0;
|
||||
@@ -257,7 +257,7 @@ bool SimpleMenu::CheckUserInput(JButton key)
|
||||
{
|
||||
if (mObjects[i]->getTopLeft(top, left))
|
||||
{
|
||||
if ( (y > top) && (y <= (top + kLineHeight)) )
|
||||
if ( (y > top) && (y <= (top + SimpleMenuConst::kLineHeight)) )
|
||||
n = i;
|
||||
}
|
||||
}
|
||||
@@ -308,8 +308,8 @@ void SimpleMenu::Update(float dt)
|
||||
selectionT += 3 * dt;
|
||||
selectionY += (selectionTargetY - selectionY) * 8 * dt;
|
||||
if(stars)
|
||||
stars->MoveTo(mX + kHorizontalMargin + ((mWidth - 2 * kHorizontalMargin) * (1 + cos(selectionT)) / 2), selectionY + 5 * cos(
|
||||
selectionT * 2.35f) + kLineHeight / 2 - kLineHeight * startId);
|
||||
stars->MoveTo(mX + SimpleMenuConst::kHorizontalMargin + ((mWidth - 2 * SimpleMenuConst::kHorizontalMargin) * (1 + cos(selectionT)) / 2), selectionY + 5 * cos(
|
||||
selectionT * 2.35f) + SimpleMenuConst::kLineHeight / 2 - SimpleMenuConst::kLineHeight * startId);
|
||||
if (timeOpen < 0)
|
||||
{
|
||||
timeOpen += dt * 10;
|
||||
@@ -328,14 +328,14 @@ void SimpleMenu::Update(float dt)
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleMenu::Add(int id, const char * text, string desc, bool forceFocus)
|
||||
void SimpleMenu::Add(int id, const string& text, string desc, bool forceFocus)
|
||||
{
|
||||
SimpleMenuItem * smi = NEW SimpleMenuItem(this, id, fontId, text, 0, mY + kVerticalMargin + mCount * kLineHeight,
|
||||
SimpleMenuItem * smi = NEW SimpleMenuItem(this, id, fontId, text, 0, mY + SimpleMenuConst::kVerticalMargin + mCount * SimpleMenuConst::kLineHeight,
|
||||
(mCount == 0), autoTranslate);
|
||||
|
||||
smi->setDescription(desc);
|
||||
JGuiController::Add(smi);
|
||||
if (mCount <= maxItems) mHeight += kLineHeight;
|
||||
if (mCount <= maxItems) mHeight += SimpleMenuConst::kLineHeight;
|
||||
if (forceFocus)
|
||||
{
|
||||
mObjects[mCurr]->Leaving(JGE_BTN_DOWN);
|
||||
|
||||
@@ -333,15 +333,15 @@ StoryDuel::StoryDuel(TiXmlElement* root, StoryFlow * mParent) :
|
||||
if (element)
|
||||
{
|
||||
const char* textC = element->GetText();
|
||||
if (strcmp(element->Value(), "onwin") == 0)
|
||||
if (element->ValueStr() == "onwin")
|
||||
{
|
||||
onWin = textC;
|
||||
}
|
||||
else if (strcmp(element->Value(), "onlose") == 0)
|
||||
else if (element->ValueStr() == "onlose")
|
||||
{
|
||||
onLose = textC;
|
||||
}
|
||||
else if (strcmp(element->Value(), "bg") == 0)
|
||||
else if (element->ValueStr() == "bg")
|
||||
{
|
||||
string text = textC;
|
||||
bg = string("campaigns/").append(mParent->folder).append("/").append(text);
|
||||
@@ -396,10 +396,10 @@ int StoryPage::loadElement(TiXmlElement* element)
|
||||
if (!element) return 0;
|
||||
const char* textC = element->GetText();
|
||||
string text = textC;
|
||||
if (strcmp(element->Value(), "music") == 0)
|
||||
if (element->ValueStr() == "music")
|
||||
{
|
||||
musicFile = string("campaigns/").append(mParent->folder).append("/").append(text);
|
||||
if (!fileExists(musicFile.c_str())) musicFile = text;
|
||||
if (!FileExists(musicFile)) musicFile = text;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -434,15 +434,15 @@ StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent) :
|
||||
string sFont = safeAttribute(element, "font");
|
||||
int font = atoi(sFont.c_str());
|
||||
|
||||
if (strcmp(element->Value(), "text") == 0)
|
||||
if (element->ValueStr() == "text")
|
||||
{
|
||||
graphics.push_back(NEW StoryText(text, x, y, align, font));
|
||||
}
|
||||
else if (strcmp(element->Value(), "title") == 0)
|
||||
else if (element->ValueStr() == "title")
|
||||
{
|
||||
graphics.push_back(NEW StoryText(text, x, y, "center", Fonts::MENU_FONT));
|
||||
}
|
||||
else if (strcmp(element->Value(), "img") == 0)
|
||||
else if (element->ValueStr() == "img")
|
||||
{
|
||||
//special case to force center
|
||||
if (sX.compare("") == 0)
|
||||
@@ -452,7 +452,7 @@ StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent) :
|
||||
string img = string("campaigns/").append(mParent->folder).append("/").append(text);
|
||||
graphics.push_back(NEW StoryImage(img, x, y));
|
||||
}
|
||||
else if (strcmp(element->Value(), "answer") == 0)
|
||||
else if (element->ValueStr() == "answer")
|
||||
{
|
||||
string id = element->Attribute("goto");
|
||||
if (!align.size()) align = "center";
|
||||
@@ -461,7 +461,7 @@ StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent) :
|
||||
graphics.push_back(sc);
|
||||
Add(sc);
|
||||
}
|
||||
else if (strcmp(element->Value(), "reward") == 0)
|
||||
else if (element->ValueStr() == "reward")
|
||||
{
|
||||
string type = safeAttribute(element, "type");
|
||||
string value = safeAttribute(element, "value");
|
||||
@@ -553,7 +553,7 @@ StoryPage * StoryFlow::loadPage(TiXmlElement* element)
|
||||
if (!typeNode) return NULL;
|
||||
StoryPage * result = NULL;
|
||||
const char* type = typeNode->ToElement()->GetText();
|
||||
if (strcmp(type, "duel") == 0)
|
||||
if (string("duel") == type)
|
||||
{
|
||||
result = NEW StoryDuel(element, this);
|
||||
}
|
||||
@@ -615,7 +615,7 @@ bool StoryFlow::parse(string path)
|
||||
TiXmlElement* element = node->ToElement();
|
||||
if (element != NULL)
|
||||
{
|
||||
if (strcmp(element->Value(), "page") == 0)
|
||||
if (element->ValueStr() == "page")
|
||||
{
|
||||
string id = element->Attribute("id");
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ void StyleManager::killRules()
|
||||
styles.clear();
|
||||
}
|
||||
|
||||
StyleManager::StyleManager()
|
||||
StyleManager::StyleManager(): topRule(0), topSize(0), playerSrc(0)
|
||||
{
|
||||
loadRules();
|
||||
}
|
||||
|
||||
@@ -54,7 +54,9 @@ int Subtypes::add(string value, unsigned int parentType)
|
||||
}
|
||||
if (isSubType(subtype) && (parentType == TYPE_CREATURE))
|
||||
{
|
||||
if(value != "forest" && value != "Forest")//http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=136196 one creature with a land subtype exist, but the card has special ruling.
|
||||
if (value != "forest" && value != "Forest")
|
||||
//http://gatherer.wizards.com/Pages/Card/Details.aspx?multiverseid=136196
|
||||
//one creature with a land subtype exist, but the card has special ruling.
|
||||
subtypesCreature.push_back(value);
|
||||
}
|
||||
return subtype;
|
||||
@@ -115,8 +117,7 @@ void Subtypes::sortSubTypes()
|
||||
|
||||
const vector<string>& Subtypes::getCreatureValuesById()
|
||||
{
|
||||
sort(subtypesCreature.begin(),subtypesCreature.end());
|
||||
subtypesCreature.erase(unique(subtypesCreature.begin(),subtypesCreature.end()),subtypesCreature.end());
|
||||
sortSubTypes();
|
||||
return subtypesCreature;
|
||||
}
|
||||
|
||||
|
||||
@@ -294,13 +294,13 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
string attribute;
|
||||
if (found2 != string::npos)
|
||||
{
|
||||
cd->mode = CD_OR;
|
||||
cd->mode = CardDescriptor::CD_OR;
|
||||
attribute = attributes.substr(0, found2);
|
||||
attributes = attributes.substr(found2 + 1);
|
||||
}
|
||||
else if (foundAnd != string::npos)
|
||||
{
|
||||
cd->mode = CD_AND;
|
||||
cd->mode = CardDescriptor::CD_AND;
|
||||
attribute = attributes.substr(0, foundAnd);
|
||||
attributes = attributes.substr(foundAnd + 1);
|
||||
}
|
||||
@@ -550,7 +550,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
else
|
||||
cd->colors = card->colors;
|
||||
|
||||
cd->mode = CD_OR;
|
||||
cd->mode = CardDescriptor::CD_OR;
|
||||
}
|
||||
else if( CDtype.find("types") != string::npos )
|
||||
{
|
||||
@@ -572,7 +572,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
cd->removeType("creature");
|
||||
cd->removeType("planeswalker");
|
||||
cd->removeType("tribal");
|
||||
cd->mode = CD_OR;
|
||||
cd->mode = CardDescriptor::CD_OR;
|
||||
}
|
||||
}
|
||||
else if (attribute.find("counter") != string::npos)
|
||||
@@ -629,7 +629,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
{
|
||||
cd->SetExclusionColor(cid);
|
||||
}
|
||||
cd->mode = CD_OR;
|
||||
cd->mode = CardDescriptor::CD_OR;
|
||||
}
|
||||
|
||||
if (attribute.find("chosencolor") != string::npos)
|
||||
@@ -685,7 +685,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
}
|
||||
}
|
||||
if (nbminuses)
|
||||
cd->mode = CD_AND;
|
||||
cd->mode = CardDescriptor::CD_AND;
|
||||
typeName = typeName.substr(0, found);
|
||||
}
|
||||
if (cd)
|
||||
|
||||
@@ -350,8 +350,8 @@ void TestSuiteGame::assertGame()
|
||||
if (observer->getCurrentGamePhase() != endState.phase)
|
||||
{
|
||||
sprintf(result, "<span class=\"error\">==phase problem. Expected [ %s ](%i), got [ %s ](%i)==</span><br />",
|
||||
Constants::MTGPhaseNames[endState.phase],endState.phase,
|
||||
Constants::MTGPhaseNames[observer->getCurrentGamePhase()], observer->getCurrentGamePhase());
|
||||
Constants::MTGPhaseNames[endState.phase].c_str(),endState.phase,
|
||||
Constants::MTGPhaseNames[observer->getCurrentGamePhase()].c_str(), observer->getCurrentGamePhase());
|
||||
Log(result);
|
||||
error++;
|
||||
}
|
||||
@@ -433,6 +433,15 @@ void TestSuiteGame::assertGame()
|
||||
Log("<span class=\"success\">==Test Succesful !==</span>");
|
||||
else
|
||||
Log("<span class=\"error\">==Test Failed !==</span>");
|
||||
#ifdef CAPTURE_STDERR
|
||||
if (error)
|
||||
{
|
||||
OutputCapturer::debugAndClear();
|
||||
} else
|
||||
{
|
||||
OutputCapturer::clear();
|
||||
}
|
||||
#endif
|
||||
mMutex.unlock();
|
||||
}
|
||||
|
||||
@@ -585,6 +594,9 @@ void TestSuite::ThreadProc(void* inParam)
|
||||
{
|
||||
LOG("Entering TestSuite::ThreadProc");
|
||||
TestSuite* instance = reinterpret_cast<TestSuite*>(inParam);
|
||||
#ifdef CAPTURE_STDERR
|
||||
OutputCapturer::debugAndClear();
|
||||
#endif
|
||||
if (instance)
|
||||
{
|
||||
string filename;
|
||||
|
||||
@@ -399,3 +399,13 @@ void ReplaceString(std::string& subject, const std::string& search, const std::s
|
||||
}
|
||||
}
|
||||
|
||||
bool StartsWith(const std::string& base, const char *start)
|
||||
{
|
||||
return base.compare(0, strlen(start), start) == 0;
|
||||
}
|
||||
|
||||
bool StartsWith(const std::string& base, const std::string& start)
|
||||
{
|
||||
return base.compare(0, start.length(), start) == 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user