Fix Segmentation Fault & Formatting
This commit is contained in:
@@ -128,7 +128,7 @@ int OrderedAIAction::getEfficiency()
|
||||
break;
|
||||
}
|
||||
case MTGAbility::STANDARD_PREVENT:
|
||||
{
|
||||
{
|
||||
efficiency = 0;//starts out low to avoid spamming it when its not needed.
|
||||
|
||||
if (!target)
|
||||
@@ -1521,12 +1521,12 @@ int AIPlayerBaka::chooseTarget(TargetChooser * _tc, Player * forceTarget,MTGCard
|
||||
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
|
||||
//so lets give the tc to its owner
|
||||
//todo:find the root cause of this.
|
||||
DebugTrace("AIPLAYER: Error, was asked to chose targets but I don't own the source of the targetController\n");
|
||||
return 0;
|
||||
}
|
||||
//this is a hack, but if we hit this condition we are locked in a infinate loop
|
||||
//so lets give the tc to its owner
|
||||
//todo:find the root cause of this.
|
||||
DebugTrace("AIPLAYER: Error, was asked to chose targets but I don't own the source of the targetController\n");
|
||||
return 0;
|
||||
}
|
||||
Player * target = forceTarget;
|
||||
int playerTargetedZone = 1;
|
||||
if (!target)
|
||||
|
||||
@@ -107,8 +107,8 @@ int AIStats::receiveEvent(WEvent * event)
|
||||
//the following tells ai if a creature should be blocked or targeted
|
||||
bool AIStats::isInTop(MTGCardInstance * card, unsigned int max, bool tooSmallCountsForTrue)
|
||||
{
|
||||
//return true;
|
||||
//uncomment the above return to make Ai always multiblock your creatures.
|
||||
//return true;
|
||||
//uncomment the above return to make Ai always multiblock your creatures.
|
||||
if (stats.size() < max)
|
||||
return tooSmallCountsForTrue;
|
||||
unsigned int n = 0;
|
||||
|
||||
@@ -361,8 +361,8 @@ int ActionLayer::reactToClick(MTGCardInstance * card)
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
// if we hit this, then something strange has happened with the click logic - reactToClick()
|
||||
// should never be called if isReactingToClick() previously didn't have an object return true
|
||||
// if we hit this, then something strange has happened with the click logic - reactToClick()
|
||||
// should never be called if isReactingToClick() previously didn't have an object return true
|
||||
assert(!mReactions.empty());
|
||||
#endif
|
||||
|
||||
|
||||
@@ -98,13 +98,13 @@ void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string
|
||||
if (!targetQuad)
|
||||
{
|
||||
/*if(source->controller()->isHuman() && source->controller()->opponent()->isAI() && !alt2.size() && _(action).c_str() == source->name)
|
||||
mFont->DrawString("You play ", x + 35, y-15 + GetVerticalTextOffset(), JGETEXT_LEFT);
|
||||
mFont->DrawString("You play ", x + 35, y-15 + GetVerticalTextOffset(), JGETEXT_LEFT);
|
||||
else if(source->controller()->isAI() && source->controller()->opponent()->isHuman() && !alt2.size() && _(action).c_str() == source->name)
|
||||
mFont->DrawString("Opponent plays ", x + 35, y-15 + GetVerticalTextOffset(), JGETEXT_LEFT);*/
|
||||
mFont->DrawString("Opponent plays ", x + 35, y-15 + GetVerticalTextOffset(), JGETEXT_LEFT);*/
|
||||
mFont->DrawString(_(action).c_str(), x + 35, y + GetVerticalTextOffset(), JGETEXT_LEFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
renderer->FillRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(235,10,10,10));
|
||||
/*if(source->controller()->isHuman() && source->controller()->opponent()->isAI())
|
||||
renderer->DrawRect(x-2,y-16 + GetVerticalTextOffset(), 73, 43, ARGB(245,0,255,0));
|
||||
@@ -351,13 +351,13 @@ int Spell::resolve()
|
||||
if (options[Options::SFXVOLUME].number > 0)
|
||||
{
|
||||
|
||||
if(observer->getResourceManager())
|
||||
observer->getResourceManager()->PlaySample(source->getSample());
|
||||
if(observer->getResourceManager())
|
||||
observer->getResourceManager()->PlaySample(source->getSample());
|
||||
}
|
||||
if(this->cost)
|
||||
{
|
||||
source->getManaCost()->setManaUsedToCast(NEW ManaCost(this->cost));
|
||||
}
|
||||
{
|
||||
source->getManaCost()->setManaUsedToCast(NEW ManaCost(this->cost));
|
||||
}
|
||||
AbilityFactory af(observer);
|
||||
af.addAbilities(observer->mLayers->actionLayer()->getMaxId(), this);
|
||||
return 1;
|
||||
@@ -757,7 +757,7 @@ int ActionStack::resolve()
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (interruptDecision[i] != 2)
|
||||
if (interruptDecision[i] != 2)
|
||||
interruptDecision[i] = NOT_DECIDED;
|
||||
}
|
||||
}
|
||||
@@ -821,7 +821,7 @@ int ActionStack::count(int type, int state, int display)
|
||||
Interruptible * ActionStack::getActionElementFromCard(MTGCardInstance * card)
|
||||
{
|
||||
|
||||
if(!card)
|
||||
if(!card)
|
||||
return 0;
|
||||
for (size_t i = 0; i < mObjects.size(); i++)
|
||||
{
|
||||
@@ -1005,7 +1005,7 @@ void ActionStack::Update(float dt)
|
||||
//and set the timer to 4 secs. BUG FIX //http://code.google.com/p/wagic/issues/detail?id=464
|
||||
extraTime = count(0, NOT_RESOLVED, 0);
|
||||
if (extraTime == 0)
|
||||
extraTime = 1;//we never want this int to be 0.
|
||||
extraTime = 1;//we never want this int to be 0.
|
||||
|
||||
if (timer < 0)
|
||||
timer = static_cast<float>(options[Options::INTERRUPT_SECONDS].number * extraTime);
|
||||
@@ -1253,7 +1253,7 @@ void ActionStack::Render()
|
||||
renderer->DrawRect(x0 - 6, y0+33, width + 15, height - 18, ARGB(255,89,89,89));
|
||||
//stack border
|
||||
renderer->DrawRect(x0 - 7, y0+2, width + 17, height + 14, ARGB(255,240,240,240));
|
||||
|
||||
|
||||
std::ostringstream stream;
|
||||
// WALDORF - changed "interrupt ?" to "Interrupt?". Don't display count down
|
||||
// seconds if the user disables auto progressing interrupts by setting the seconds
|
||||
|
||||
@@ -1236,7 +1236,7 @@ int GenericPaidAbility::resolve()
|
||||
}*/
|
||||
}
|
||||
if(asAlternate && nomenu && optionalCost->getConvertedCost() < 1)
|
||||
{
|
||||
{
|
||||
nomenuAbility->resolve();
|
||||
}
|
||||
else
|
||||
@@ -1414,7 +1414,7 @@ AAEPIC * AAEPIC::clone() const
|
||||
AAFizzler::AAFizzler(GameObserver* observer, int _id, MTGCardInstance * card, Spell * _target, ManaCost * _cost) :
|
||||
ActivatedAbility(observer, _id, card, _cost, 0)
|
||||
{
|
||||
aType = MTGAbility::STANDARD_FIZZLER;
|
||||
aType = MTGAbility::STANDARD_FIZZLER;
|
||||
target = _target;
|
||||
|
||||
// by default we put the spell to graveyard after fizzling
|
||||
@@ -1847,7 +1847,7 @@ int AANewTarget::resolve()
|
||||
}
|
||||
}
|
||||
if(!newhook)
|
||||
{
|
||||
{
|
||||
target = source;
|
||||
source = _target;
|
||||
}
|
||||
@@ -2528,7 +2528,7 @@ int AModifyHand::destroy()
|
||||
|
||||
if (!p)
|
||||
return 0;
|
||||
|
||||
|
||||
WParsedInt handmodifier(hand, NULL, source);
|
||||
p->handmodifier -= handmodifier.getValue();
|
||||
|
||||
@@ -4175,12 +4175,12 @@ ATransformer::ATransformer(GameObserver* observer, int id, MTGCardInstance * sou
|
||||
myCurrentTurn = 1000;
|
||||
//this subkeyword adds a color without removing the existing colors.
|
||||
addNewColors = (sabilities.find("newcolors") != string::npos);
|
||||
remove = (stypes.find("removealltypes") != string::npos);
|
||||
removeCreatureSubtypes = (stypes.find("removecreaturesubtypes") != string::npos);
|
||||
remove = (stypes.find("removealltypes") != string::npos);
|
||||
removeCreatureSubtypes = (stypes.find("removecreaturesubtypes") != string::npos);
|
||||
removeTypes = (stypes.find("removetypes") != string::npos);
|
||||
|
||||
if (stypes.find("allsubtypes") != string::npos || stypes.find("removecreaturesubtypes") != string::npos)
|
||||
{
|
||||
if (stypes.find("allsubtypes") != string::npos || stypes.find("removecreaturesubtypes") != string::npos)
|
||||
{
|
||||
const vector<string> values = MTGAllCards::getValuesById();
|
||||
for (size_t i = 0; i <values.size(); ++i)
|
||||
{
|
||||
@@ -4189,7 +4189,7 @@ ATransformer::ATransformer(GameObserver* observer, int id, MTGCardInstance * sou
|
||||
|
||||
types.push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(stypes.find("chosentype") != string::npos)
|
||||
@@ -4251,17 +4251,17 @@ int ATransformer::addToGame()
|
||||
for (int i = 0; i < Subtypes::LAST_TYPE; ++ i)
|
||||
_target->removeType(i,1);
|
||||
}
|
||||
else if (remove)
|
||||
{
|
||||
for (it = oldtypes.begin(); it != oldtypes.end(); it++)
|
||||
{
|
||||
_target->removeType(*it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else if (remove)
|
||||
{
|
||||
for (it = oldtypes.begin(); it != oldtypes.end(); it++)
|
||||
{
|
||||
_target->removeType(*it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (it = types.begin(); it != types.end(); it++)
|
||||
{
|
||||
{
|
||||
|
||||
if(removeCreatureSubtypes)
|
||||
{
|
||||
@@ -4280,8 +4280,8 @@ for (it = types.begin(); it != types.end(); it++)
|
||||
{
|
||||
_target->addType(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (it = colors.begin(); it != colors.end(); it++)
|
||||
{
|
||||
_target->setColor(*it);
|
||||
@@ -4361,7 +4361,7 @@ for (it = types.begin(); it != types.end(); it++)
|
||||
_target->switchPT(true);
|
||||
}
|
||||
else
|
||||
_target->addbaseT(val->getValue());
|
||||
_target->addbaseT(val->getValue());
|
||||
delete val;
|
||||
}
|
||||
|
||||
@@ -4446,7 +4446,7 @@ int ATransformer::destroy()
|
||||
{
|
||||
_target->setColor(*it);
|
||||
}
|
||||
|
||||
|
||||
if(newpowerfound || newtoughnessfound)
|
||||
_target->isSettingBase -= 1;
|
||||
|
||||
@@ -4473,22 +4473,22 @@ int ATransformer::destroy()
|
||||
newAbilities.erase(_target);
|
||||
}
|
||||
}
|
||||
if (remove || removeCreatureSubtypes)
|
||||
{
|
||||
for (it = oldtypes.begin(); it != oldtypes.end(); it++)
|
||||
{
|
||||
if (remove || removeCreatureSubtypes)
|
||||
{
|
||||
for (it = oldtypes.begin(); it != oldtypes.end(); it++)
|
||||
{
|
||||
if(!_target->hasSubtype(*it))
|
||||
_target->addType(*it);
|
||||
}
|
||||
}
|
||||
////in the case that we removed or added types to a card, so that it retains its original name when the effect is removed.
|
||||
//if(_target->model->data->name.size())//tokens don't have a model name.
|
||||
// _target->setName(_target->model->data->name.c_str());
|
||||
}
|
||||
}
|
||||
////in the case that we removed or added types to a card, so that it retains its original name when the effect is removed.
|
||||
//if(_target->model->data->name.size())//tokens don't have a model name.
|
||||
// _target->setName(_target->model->data->name.c_str());
|
||||
|
||||
//edit: this ability shouldn't have to reset the name on a card becuase removing a subtype changes the name of a land.
|
||||
//that should be handled in addType...not here.
|
||||
//im sure commenting this out will reintroduce a bug somewhere but it needs to be handled correctly. furthermore, why does adding and removing a type touch the name of a card?
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -4697,8 +4697,8 @@ int ALoseAbilities::addToGame()
|
||||
if (al->mObjects[i])
|
||||
{
|
||||
MTGAbility * currentAction = (MTGAbility *) al->mObjects[i];
|
||||
ALord * l = dynamic_cast<ALord*> (currentAction);
|
||||
if(l)
|
||||
ALord * l = dynamic_cast<ALord*> (currentAction);
|
||||
if(l)
|
||||
lordsInGame.push_back(l);
|
||||
}
|
||||
}
|
||||
@@ -4708,9 +4708,9 @@ int ALoseAbilities::addToGame()
|
||||
if (al->mObjects[i])
|
||||
{
|
||||
MTGAbility * currentAction = (MTGAbility *) al->mObjects[i];
|
||||
ALoseAbilities * la = dynamic_cast<ALoseAbilities*> (currentAction);
|
||||
if(la)
|
||||
continue;
|
||||
ALoseAbilities * la = dynamic_cast<ALoseAbilities*> (currentAction);
|
||||
if(la)
|
||||
continue;
|
||||
if (currentAction->source == _target)
|
||||
{
|
||||
bool canRemove = true;
|
||||
@@ -4751,20 +4751,20 @@ int ALoseAbilities::destroy()
|
||||
MTGAbility * a = storedAbilities[i];
|
||||
//OneShot abilities are not supposed to stay in the game for long.
|
||||
// If we copied one, something wrong probably happened
|
||||
if (a->oneShot)
|
||||
{
|
||||
if (a->oneShot)
|
||||
{
|
||||
DebugTrace("ALLABILITIES: Ability should not be one shot");
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
//Avoid inifinite loop of removing/putting back abilities
|
||||
if (dynamic_cast<ALoseAbilities*> (a))
|
||||
{
|
||||
DebugTrace("ALLABILITIES: loseability won't be put in the loseability list");
|
||||
continue;
|
||||
}
|
||||
DebugTrace("ALLABILITIES: loseability won't be put in the loseability list");
|
||||
continue;
|
||||
}
|
||||
|
||||
a->addToGame();
|
||||
a->addToGame();
|
||||
}
|
||||
storedAbilities.clear();
|
||||
return 1;
|
||||
@@ -5368,8 +5368,8 @@ void ABlink::resolveBlink()
|
||||
|
||||
void ABlink::returnCardIntoPlay(MTGCardInstance* _target) {
|
||||
MTGCardInstance * Blinker = NULL;
|
||||
if(!_target->blinked)
|
||||
{
|
||||
if(!_target->blinked)
|
||||
{
|
||||
this->forceDestroy = 1;
|
||||
return;
|
||||
}
|
||||
@@ -5659,7 +5659,7 @@ int AEquip::unequip()
|
||||
{
|
||||
MTGAbility * a = currentAbilities[i];
|
||||
if (dynamic_cast<AEquip *> (a) || dynamic_cast<ATeach *> (a) || dynamic_cast<AAConnect *> (a)
|
||||
|| dynamic_cast<AANewTarget *> (AbilityFactory::getCoreAbility(a))
|
||||
|| dynamic_cast<AANewTarget *> (AbilityFactory::getCoreAbility(a))
|
||||
|| (a->aType == MTGAbility::STANDARD_TOKENCREATOR && a->oneShot))
|
||||
{
|
||||
SAFE_DELETE(a);
|
||||
@@ -6013,7 +6013,7 @@ ATutorialMessage::ATutorialMessage(GameObserver* observer, MTGCardInstance * sou
|
||||
else
|
||||
{
|
||||
mMessage = _(message); //translate directly here, remove this and translate at rendering time if it bites us
|
||||
ReplaceString(mMessage, "\\n", "\n");
|
||||
ReplaceString(mMessage, "\\n", "\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6143,7 +6143,7 @@ void ATutorialMessage::Render()
|
||||
|
||||
if (options[Options::SFXVOLUME].number > 0)
|
||||
{
|
||||
game->getResourceManager()->PlaySample("tutorial.wav");
|
||||
game->getResourceManager()->PlaySample("tutorial.wav");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -43,11 +43,11 @@ namespace
|
||||
}
|
||||
|
||||
CardGui::CardGui(MTGCardInstance* card, float x, float y)
|
||||
: PlayGuiObject(Height, x, y, 0, false), card(card)
|
||||
: PlayGuiObject(Height, x, y, 0, false), card(card)
|
||||
{
|
||||
}
|
||||
CardGui::CardGui(MTGCardInstance* card, const Pos& ref)
|
||||
: PlayGuiObject(Height, ref, 0, false), card(card)
|
||||
: PlayGuiObject(Height, ref, 0, false), card(card)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ float CardView::GetCenterY()
|
||||
|
||||
|
||||
CardView::CardView(const SelectorZone owner, MTGCardInstance* card, float x, float y)
|
||||
: CardGui(card, x, y), owner(owner)
|
||||
: CardGui(card, x, y), owner(owner)
|
||||
{
|
||||
const Pos* ref = card->view;
|
||||
while (card)
|
||||
@@ -81,7 +81,7 @@ CardView::CardView(const SelectorZone owner, MTGCardInstance* card, float x, flo
|
||||
}
|
||||
|
||||
CardView::CardView(const SelectorZone owner, MTGCardInstance* card, const Pos& ref)
|
||||
: CardGui(card, ref), owner(owner)
|
||||
: CardGui(card, ref), owner(owner)
|
||||
{
|
||||
const Pos* r = card->view;
|
||||
while (card)
|
||||
@@ -238,14 +238,14 @@ void CardGui::Render()
|
||||
{
|
||||
quad->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255));
|
||||
//fake border...
|
||||
JQuadPtr fakeborder;
|
||||
JQuadPtr highlightborder;
|
||||
JQuadPtr fakeborder;
|
||||
JQuadPtr highlightborder;
|
||||
fakeborder = game? game->getResourceManager()->GetQuad("white"):WResourceManager::Instance()->GetQuad("white");
|
||||
highlightborder = game? game->getResourceManager()->GetQuad("white"):WResourceManager::Instance()->GetQuad("white");
|
||||
if(fakeborder)
|
||||
{
|
||||
if(fakeborder)
|
||||
{
|
||||
fakeborder->SetColor(ARGB((int)(actA),15,15,15));
|
||||
renderer->RenderQuad(fakeborder.get(), actX, actY, actT, (29 * actZ + 1) / 16, 42 * actZ / 16);
|
||||
renderer->RenderQuad(fakeborder.get(), actX, actY, actT, (29 * actZ + 1) / 16, 42 * actZ / 16);
|
||||
}
|
||||
//draw border for highlighting
|
||||
if (game)
|
||||
@@ -253,12 +253,12 @@ void CardGui::Render()
|
||||
if (card && card->isTargetted() && highlightborder)
|
||||
{
|
||||
highlightborder->SetColor(ARGB(95,255,0,0));
|
||||
renderer->RenderQuad(highlightborder.get(), actX, actY, actT, (30 * actZ + 1) / 16, 43 * actZ / 16);
|
||||
renderer->RenderQuad(highlightborder.get(), actX, actY, actT, (30 * actZ + 1) / 16, 43 * actZ / 16);
|
||||
}
|
||||
if (card && card->isTargetter() && highlightborder)
|
||||
{
|
||||
highlightborder->SetColor(ARGB(95,0,245,0));
|
||||
renderer->RenderQuad(highlightborder.get(), actX, actY, actT, (30 * actZ + 1) / 16, 43 * actZ / 16);
|
||||
renderer->RenderQuad(highlightborder.get(), actX, actY, actT, (30 * actZ + 1) / 16, 43 * actZ / 16);
|
||||
}
|
||||
}
|
||||
//draw the card image
|
||||
@@ -307,7 +307,7 @@ void CardGui::Render()
|
||||
{
|
||||
if (card && card->isTargetted())
|
||||
{
|
||||
if(card->isTapped())
|
||||
if(card->isTapped())
|
||||
{
|
||||
if(mHasFocus)
|
||||
renderer->DrawRoundRect(actX - (scale * quad->mWidth / 2)-10,actY - (scale * quad->mHeight / 2)+6.5f, (scale * quad->mHeight)-0.02f, (scale * quad->mWidth)-0.02f, 1.8f,ARGB(250,255,0,0));
|
||||
@@ -341,7 +341,7 @@ void CardGui::Render()
|
||||
ARGB(((static_cast<unsigned char>(actA))/2),0,0,0));
|
||||
renderer->DrawRect(actX - (13 * actZ), actY + 4 * actZ, 25.5f * actZ, 14 * actZ,
|
||||
ARGB(((static_cast<unsigned char>(actA))),20,20,20));
|
||||
//damaged or buffed or powered down
|
||||
//damaged or buffed or powered down
|
||||
if(card->wasDealtDamage && card->life <= 2)
|
||||
mFont->SetColor(ARGB(static_cast<unsigned char>(actA),255,0,0));//red critical and damaged
|
||||
else if(!card->wasDealtDamage && card->pbonus < 0)
|
||||
@@ -350,7 +350,7 @@ void CardGui::Render()
|
||||
mFont->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,0));//yellow buff
|
||||
else if(card->hasType("legendary") && card->hasType("eldrazi"))
|
||||
mFont->SetColor(ARGB(static_cast<unsigned char>(actA),238,130,238));//violet legendary eldrazi
|
||||
else
|
||||
else
|
||||
mFont->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255));//white default
|
||||
mFont->SetScale(actZ);
|
||||
mFont->SetScale(actZ);
|
||||
@@ -366,7 +366,7 @@ void CardGui::Render()
|
||||
if(!card->isToken && card->isACopier)
|
||||
buff = "C";
|
||||
if(game && card->has(Constants::PAYZERO) && ((card->currentZone == card->controller()->game->hand) || (card->has(Constants::CANPLAYFROMGRAVEYARD) && card->currentZone == card->controller()->game->graveyard) || (card->has(Constants::CANPLAYFROMEXILE) && card->currentZone == card->controller()->game->exile)))
|
||||
buff += "Z";
|
||||
buff += "Z";
|
||||
if(card->alias == 0000)
|
||||
{
|
||||
if(card->chooseacolor == 1)
|
||||
@@ -380,8 +380,8 @@ void CardGui::Render()
|
||||
else if(card->chooseacolor == 5)
|
||||
buff += "\n-White";
|
||||
}
|
||||
if(!alternate && buff != "" && game->gameType() == GAME_TYPE_CLASSIC)//it seems that other game modes makes cards as tokens!!! hmmm...
|
||||
{
|
||||
if(!alternate && buff != "" && game->gameType() == GAME_TYPE_CLASSIC)//it seems that other game modes makes cards as tokens!!! hmmm...
|
||||
{
|
||||
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
||||
char buffer[200];
|
||||
sprintf(buffer, "%s", buff.c_str());
|
||||
@@ -1101,7 +1101,7 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb, bool noborder
|
||||
//white thin line to simulate card edge
|
||||
renderer->DrawRoundRect(x-92,pos.actY-130, (scale * quad->mWidth)-10, (scale * quad->mHeight)-11, 9.0f,ARGB(50,240,240,240));
|
||||
}
|
||||
//render card image
|
||||
//render card image
|
||||
renderer->RenderQuad(quad.get(), x, pos.actY-2, pos.actT, scale-0.02f, scale-0.02f);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -69,7 +69,7 @@ bool Unlockable::tryToUnlock(GameObserver * game) {
|
||||
string id = getValue("id");
|
||||
assert(id.size() > 0);
|
||||
|
||||
GameOptionAward* goa = (GameOptionAward*) &options[id];
|
||||
GameOptionAward* goa = (GameOptionAward*) &options[id];
|
||||
goa->giveAward();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ int Damage::resolve()
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if ((_target)->protectedAgainst(source))
|
||||
damage = 0;
|
||||
//rulings = 10/4/2004 The damage prevention ability works even if it has no counters, as long as some effect keeps its toughness above zero.
|
||||
//rulings = 10/4/2004 The damage prevention ability works even if it has no counters, as long as some effect keeps its toughness above zero.
|
||||
//these creature are essentially immune to damage. however 0/-1 effects applied through lords or counters can kill them.
|
||||
if ((_target)->has(Constants::PROTECTIONFROMCOLOREDSPELLS))
|
||||
{//damage is prevented as long as the damage source is a spell on the stack...
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace DeckMenuConst
|
||||
const float kLineHeight = 25;
|
||||
const float kDescriptionVerticalBoxPadding = -5;
|
||||
const float kDescriptionHorizontalBoxPadding = 5;
|
||||
|
||||
|
||||
const float kVerticalScrollSpeed = 7.0f;
|
||||
|
||||
const int DETAILED_INFO_THRESHOLD = 20;
|
||||
@@ -69,7 +69,7 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc
|
||||
menuInitialized = false;
|
||||
|
||||
float scrollerWidth = 200.0f;
|
||||
float scrollerHeight = 28.0f;
|
||||
float scrollerHeight = 28.0f;
|
||||
mScroller = NEW VerticalTextScroller(Fonts::MAIN_FONT, 14, 235, scrollerWidth, scrollerHeight, DeckMenuConst::kVerticalScrollSpeed);
|
||||
|
||||
mAutoTranslate = true;
|
||||
@@ -94,7 +94,7 @@ JGuiController(JGE::GetInstance(), id, listener), fontId(fontId), mShowDetailsSc
|
||||
mSelectionTargetY = selectionY = DeckMenuConst::kVerticalMargin;
|
||||
|
||||
if (NULL == stars)
|
||||
stars = NEW hgeParticleSystem(WResourceManager::Instance()->RetrievePSI("stars.psi", WResourceManager::Instance()->GetQuad("stars").get()));
|
||||
stars = NEW hgeParticleSystem(WResourceManager::Instance()->RetrievePSI("stars.psi", WResourceManager::Instance()->GetQuad("stars").get()));
|
||||
stars->FireAt(mX, mY);
|
||||
|
||||
const string detailedInfoString = _("Detailed Info");
|
||||
@@ -248,11 +248,11 @@ void DeckMenu::Render()
|
||||
if (currentMenuItem->getY() - DeckMenuConst::kLineHeight * startId < mY + height - DeckMenuConst::kLineHeight + 7)
|
||||
{
|
||||
// only load stats for visible items in the list
|
||||
DeckMetaData* metaData = currentMenuItem->getMetaData();
|
||||
DeckMetaData* metaData = currentMenuItem->getMetaData();
|
||||
if (metaData && !metaData->mStatsLoaded)
|
||||
{
|
||||
metaData->LoadStats();
|
||||
}
|
||||
}
|
||||
|
||||
if (currentMenuItem->hasFocus())
|
||||
{
|
||||
@@ -291,7 +291,7 @@ void DeckMenu::Render()
|
||||
}
|
||||
|
||||
// fill in the description part of the screen
|
||||
string text = wordWrap(_(currentMenuItem->getDescription()), descWidth, descriptionFont->mFontID );
|
||||
string text = wordWrap(_(currentMenuItem->getDescription()), descWidth, descriptionFont->mFontID );
|
||||
descriptionFont->SetColor(ARGB(255,255,255,255));
|
||||
descriptionFont->DrawString(text.c_str(), descX, descY);
|
||||
|
||||
@@ -314,19 +314,19 @@ void DeckMenu::Render()
|
||||
}
|
||||
}
|
||||
|
||||
if (!title.empty())
|
||||
if (!title.empty())
|
||||
{
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
mFont->DrawString(title.c_str(), titleX, titleY, JGETEXT_CENTER);
|
||||
}
|
||||
|
||||
mScroller->Render();
|
||||
RenderBackground();
|
||||
RenderBackground();
|
||||
RenderDeckManaColors();
|
||||
|
||||
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
|
||||
stars->Render();
|
||||
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
|
||||
stars->Render();
|
||||
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
}
|
||||
|
||||
@@ -403,13 +403,13 @@ void DeckMenu::updateScroller()
|
||||
|
||||
for (vector<Task*>::iterator it = taskList.tasks.begin(); it != taskList.tasks.end(); it++)
|
||||
{
|
||||
ostringstream taskDescription;
|
||||
taskDescription << "Credits: " << setw(4) << (*it)->getReward() << " / "
|
||||
<< "Days Left: " << (*it)->getExpiration() << endl
|
||||
ostringstream taskDescription;
|
||||
taskDescription << "Credits: " << setw(4) << (*it)->getReward() << " / "
|
||||
<< "Days Left: " << (*it)->getExpiration() << endl
|
||||
<< (*it)->getDesc() << endl << endl;
|
||||
mScroller->Add(taskDescription.str());
|
||||
mScroller->Add(taskDescription.str());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void DeckMenu::Close()
|
||||
|
||||
@@ -16,33 +16,33 @@ float DeckMenuItem::mYOffset = 0;
|
||||
DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, float x, float y, bool hasFocus, bool autoTranslate, DeckMetaData *deckMetaData)
|
||||
: JGuiObject(id), parent(_parent), fontId(fontId), mX(x), mY(y)
|
||||
{
|
||||
WFont * mFont = WResourceManager::Instance()->GetWFont(fontId);
|
||||
WFont * mFont = WResourceManager::Instance()->GetWFont(fontId);
|
||||
mMetaData = deckMetaData;
|
||||
mText = trim(text);
|
||||
mText = trim(text);
|
||||
mIsValidSelection = false;
|
||||
|
||||
if (autoTranslate)
|
||||
mText = _(mText);
|
||||
if (autoTranslate)
|
||||
mText = _(mText);
|
||||
|
||||
|
||||
mHasFocus = hasFocus;
|
||||
float newImageWidth = 0.0f;
|
||||
float newImageWidth = 0.0f;
|
||||
if (mMetaData && !mMetaData->getGamesPlayed())
|
||||
{
|
||||
JTexture * tex = WResourceManager::Instance()->RetrieveTexture("new.png");
|
||||
if (tex)
|
||||
{
|
||||
JQuadPtr quad = WResourceManager::Instance()->RetrieveQuad("new.png", 2.0f, 2.0f, tex->mWidth - 4.0f, tex->mHeight - 4.0f); //avoids weird rectangle around the texture because of bilinear filtering
|
||||
newImageWidth = quad->mWidth;
|
||||
}
|
||||
}
|
||||
newImageWidth = quad->mWidth;
|
||||
}
|
||||
}
|
||||
|
||||
float titleStringWidth = mFont->GetStringWidth( mText.c_str() );
|
||||
mTitleResetWidth = (titleStringWidth - newImageWidth )/ 2;
|
||||
mScrollEnabled = titleStringWidth > ( ITEM_PX_WIDTH - newImageWidth );
|
||||
mScrollerOffset = 0.0f;
|
||||
float titleStringWidth = mFont->GetStringWidth( mText.c_str() );
|
||||
mTitleResetWidth = (titleStringWidth - newImageWidth )/ 2;
|
||||
mScrollEnabled = titleStringWidth > ( ITEM_PX_WIDTH - newImageWidth );
|
||||
mScrollerOffset = 0.0f;
|
||||
|
||||
if (hasFocus)
|
||||
if (hasFocus)
|
||||
{
|
||||
mIsValidSelection = true;
|
||||
Entering();
|
||||
@@ -67,7 +67,7 @@ DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, f
|
||||
break;
|
||||
}
|
||||
default:
|
||||
mImageFilename = "noavatar.jpg";
|
||||
mImageFilename = "noavatar.jpg";
|
||||
// do nothing.
|
||||
break;
|
||||
}
|
||||
@@ -75,15 +75,15 @@ DeckMenuItem::DeckMenuItem(DeckMenu* _parent, int id, int fontId, string text, f
|
||||
}
|
||||
|
||||
|
||||
mDisplayInitialized = false;
|
||||
mDisplayInitialized = false;
|
||||
|
||||
}
|
||||
|
||||
void DeckMenuItem::Update(float dt)
|
||||
{
|
||||
mScrollerOffset += kHorizontalScrollSpeed * dt;
|
||||
if ( (mScrollerOffset) > mTitleResetWidth )
|
||||
mScrollerOffset = -ITEM_PX_WIDTH;
|
||||
mScrollerOffset += kHorizontalScrollSpeed * dt;
|
||||
if ( (mScrollerOffset) > mTitleResetWidth )
|
||||
mScrollerOffset = -ITEM_PX_WIDTH;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,12 +92,12 @@ void DeckMenuItem::RenderWithOffset(float yOffset)
|
||||
mYOffset = yOffset;
|
||||
|
||||
WFont * mFont = WResourceManager::Instance()->GetWFont(fontId);
|
||||
|
||||
if (!( mHasFocus && mScrollEnabled ))
|
||||
mScrollerOffset = 0;
|
||||
if (!mHasFocus && mScrollEnabled)
|
||||
mScrollerOffset = -1 * ( getWidth() - ITEM_PX_WIDTH )/2;
|
||||
float offSet = mScrollerOffset;
|
||||
|
||||
if (!( mHasFocus && mScrollEnabled ))
|
||||
mScrollerOffset = 0;
|
||||
if (!mHasFocus && mScrollEnabled)
|
||||
mScrollerOffset = -1 * ( getWidth() - ITEM_PX_WIDTH )/2;
|
||||
float offSet = mScrollerOffset;
|
||||
|
||||
if (mHasFocus)
|
||||
mFont->SetScale(SCALE_SELECTED);
|
||||
@@ -105,8 +105,8 @@ void DeckMenuItem::RenderWithOffset(float yOffset)
|
||||
mFont->SetScale(SCALE_NORMAL);
|
||||
|
||||
mFont->DrawString(mText.c_str(), mX, mY + yOffset, JGETEXT_CENTER, offSet, ITEM_PX_WIDTH);
|
||||
mDisplayInitialized = true;
|
||||
//Render a "new" icon for decks that have never been played yet
|
||||
mDisplayInitialized = true;
|
||||
//Render a "new" icon for decks that have never been played yet
|
||||
if (mMetaData && !mMetaData->getGamesPlayed())
|
||||
{
|
||||
JTexture * tex = WResourceManager::Instance()->RetrieveTexture("new.png");
|
||||
@@ -128,7 +128,7 @@ void DeckMenuItem::Render()
|
||||
|
||||
void DeckMenuItem::checkUserClick()
|
||||
{
|
||||
int x1 = -1, y1 = -1;
|
||||
int x1 = -1, y1 = -1;
|
||||
if (mEngine->GetLeftClickCoordinates(x1, y1))
|
||||
{
|
||||
mIsValidSelection = false;
|
||||
@@ -136,8 +136,8 @@ void DeckMenuItem::checkUserClick()
|
||||
if ( (x1 >= x2) && (x1 <= (x2 + ITEM_PX_WIDTH)) && (y1 >= y2) && (y1 < (y2 + kItemYHeight)))
|
||||
mIsValidSelection = true;
|
||||
}
|
||||
else
|
||||
mIsValidSelection = true;
|
||||
else
|
||||
mIsValidSelection = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,14 +175,14 @@ float DeckMenuItem::getWidth() const
|
||||
|
||||
string DeckMenuItem::getDeckName() const
|
||||
{
|
||||
if (mMetaData)
|
||||
return mMetaData->getName();
|
||||
if (mMetaData)
|
||||
return mMetaData->getName();
|
||||
|
||||
std::string s;
|
||||
std::stringstream out;
|
||||
out << mMetaData->getDeckId();
|
||||
s = out.str();
|
||||
return "[deck" + s + "]";
|
||||
std::string s;
|
||||
std::stringstream out;
|
||||
out << mMetaData->getDeckId();
|
||||
s = out.str();
|
||||
return "[deck" + s + "]";
|
||||
}
|
||||
|
||||
ostream& DeckMenuItem::toString(ostream& out) const
|
||||
|
||||
@@ -394,9 +394,9 @@ void StatsWrapper::updateStats(string filename, MTGAllCards *collection)
|
||||
|
||||
void StatsWrapper::updateStats(DeckDataWrapper *myDeck)
|
||||
{
|
||||
if (!this->needUpdate || !myDeck) return;
|
||||
if (!this->needUpdate || !myDeck) return;
|
||||
|
||||
this->needUpdate = false;
|
||||
this->needUpdate = false;
|
||||
this->cardCount = myDeck->getCount(WSrcDeck::UNFILTERED_COPIES);
|
||||
this->countLands = myDeck->getCount(Constants::MTG_COLOR_LAND);
|
||||
this->totalPrice = myDeck->totalPrice();
|
||||
|
||||
@@ -89,7 +89,7 @@ DuelLayers::DuelLayers(GameObserver* go, int playerViewIndex) :
|
||||
nbitems(0), mPlayerViewIndex(playerViewIndex)
|
||||
{
|
||||
observer = go;
|
||||
observer->mLayers = this;
|
||||
observer->mLayers = this;
|
||||
mCardSelector = NEW CardSelector(go, this);
|
||||
//1 Action Layer
|
||||
action = NEW ActionLayer(go);
|
||||
@@ -98,8 +98,8 @@ DuelLayers::DuelLayers(GameObserver* go, int playerViewIndex) :
|
||||
//Other display elements
|
||||
action->Add(NEW HUDDisplay(go, -1));
|
||||
|
||||
Add(NEW GuiMana(20, 20, getRenderedPlayerOpponent()));
|
||||
Add(NEW GuiMana(440, 20, getRenderedPlayer()));
|
||||
Add(NEW GuiMana(20, 20, getRenderedPlayerOpponent()));
|
||||
Add(NEW GuiMana(440, 20, getRenderedPlayer()));
|
||||
Add(stack = NEW ActionStack(go));
|
||||
Add(combat = NEW GuiCombat(go));
|
||||
Add(action);
|
||||
@@ -216,10 +216,10 @@ float DuelLayers::RightBoundary()
|
||||
|
||||
Player* DuelLayers::getRenderedPlayer()
|
||||
{
|
||||
return observer->players[mPlayerViewIndex];
|
||||
return observer->players[mPlayerViewIndex];
|
||||
};
|
||||
|
||||
Player* DuelLayers::getRenderedPlayerOpponent()
|
||||
{
|
||||
return observer->players[mPlayerViewIndex]->opponent();
|
||||
return observer->players[mPlayerViewIndex]->opponent();
|
||||
};
|
||||
|
||||
@@ -77,7 +77,7 @@ GameApp::GameApp() :
|
||||
|
||||
mCurrentState = NULL;
|
||||
mNextState = NULL;
|
||||
rules = 0;
|
||||
rules = 0;
|
||||
music = NULL;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ void GameApp::Create()
|
||||
|
||||
|
||||
//Setup Cache before calling any gfx/sfx functions
|
||||
WResourceManager::Instance()->ResetCacheLimits();
|
||||
WResourceManager::Instance()->ResetCacheLimits();
|
||||
|
||||
|
||||
LOG("Checking for music files");
|
||||
|
||||
@@ -165,18 +165,18 @@ void GameObserver::nextGamePhase()
|
||||
{
|
||||
Phase * cPhaseOld = phaseRing->getCurrentPhase();
|
||||
if (cPhaseOld->id == MTG_PHASE_COMBATDAMAGE)
|
||||
if ((FIRST_STRIKE == combatStep) || (END_FIRST_STRIKE == combatStep) || (DAMAGE == combatStep))
|
||||
{
|
||||
nextCombatStep();
|
||||
return;
|
||||
}
|
||||
if ((FIRST_STRIKE == combatStep) || (END_FIRST_STRIKE == combatStep) || (DAMAGE == combatStep))
|
||||
{
|
||||
nextCombatStep();
|
||||
return;
|
||||
}
|
||||
|
||||
if (cPhaseOld->id == MTG_PHASE_COMBATBLOCKERS)
|
||||
if (BLOCKERS == combatStep || TRIGGERS == combatStep)
|
||||
{
|
||||
nextCombatStep();
|
||||
return;
|
||||
}
|
||||
if (BLOCKERS == combatStep || TRIGGERS == combatStep)
|
||||
{
|
||||
nextCombatStep();
|
||||
return;
|
||||
}
|
||||
|
||||
phaseRing->forward();
|
||||
|
||||
@@ -191,12 +191,12 @@ void GameObserver::nextGamePhase()
|
||||
mCurrentGamePhase = cPhase->id;
|
||||
|
||||
if (MTG_PHASE_COMBATDAMAGE == mCurrentGamePhase)
|
||||
nextCombatStep();
|
||||
nextCombatStep();
|
||||
if (MTG_PHASE_COMBATEND == mCurrentGamePhase)
|
||||
combatStep = BLOCKERS;
|
||||
|
||||
//if (currentPlayer != cPhase->player)
|
||||
// nextPlayer();//depreciated; we call this at EOT step now. unsure what the purpose of this was originally.fix for a bug?
|
||||
// nextPlayer();//depreciated; we call this at EOT step now. unsure what the purpose of this was originally.fix for a bug?
|
||||
|
||||
//init begin of turn
|
||||
if (mCurrentGamePhase == MTG_PHASE_BEFORE_BEGIN)
|
||||
@@ -229,8 +229,8 @@ void GameObserver::nextGamePhase()
|
||||
handmodified = currentPlayer->handsize+currentPlayer->handmodifier;
|
||||
//Auto Hand cleaning, in case the player didn't do it himself
|
||||
if(handmodified < 0)
|
||||
handmodified = 0;
|
||||
while (currentPlayer->game->hand->nb_cards > handmodified && currentPlayer->nomaxhandsize == false)
|
||||
handmodified = 0;
|
||||
while (currentPlayer->game->hand->nb_cards > handmodified && currentPlayer->nomaxhandsize == false)
|
||||
{
|
||||
WEvent * e = NEW WEventCardDiscard(currentPlayer->game->hand->cards[0]);
|
||||
receiveEvent(e);
|
||||
@@ -312,16 +312,16 @@ void GameObserver::userRequestNextGamePhase(bool allowInterrupt, bool log)
|
||||
cardClick(getCurrentTargetChooser()->source, 0, false);
|
||||
}
|
||||
if (allowInterrupt && mLayers->stackLayer()->getNext(NULL, 0, NOT_RESOLVED))
|
||||
return;
|
||||
return;
|
||||
if (getCurrentTargetChooser())
|
||||
return;
|
||||
return;
|
||||
//if (mLayers->actionLayer()->isWaitingForAnswer())
|
||||
// return;
|
||||
// return;
|
||||
// Wil 12/5/10: additional check, not quite understanding why TargetChooser doesn't seem active at this point.
|
||||
// If we deem that an extra cost payment needs to be made, don't allow the next game phase to proceed.
|
||||
// Here's what I find weird - if the extra cost is something like a sacrifice, doesn't that imply a TargetChooser?
|
||||
if (WaitForExtraPayment(NULL))
|
||||
return;
|
||||
return;
|
||||
|
||||
Phase * cPhaseOld = phaseRing->getCurrentPhase();
|
||||
if (allowInterrupt && ((cPhaseOld->id == MTG_PHASE_COMBATBLOCKERS && combatStep == ORDER)
|
||||
@@ -329,7 +329,7 @@ void GameObserver::userRequestNextGamePhase(bool allowInterrupt, bool log)
|
||||
|| (cPhaseOld->id == MTG_PHASE_COMBATDAMAGE)
|
||||
|| opponent()->isAI()
|
||||
|| options[Options::optionInterrupt(mCurrentGamePhase)].number
|
||||
|| currentPlayer->offerInterruptOnPhase - 1 == mCurrentGamePhase
|
||||
|| currentPlayer->offerInterruptOnPhase - 1 == mCurrentGamePhase
|
||||
))
|
||||
{
|
||||
mLayers->stackLayer()->AddNextGamePhase();
|
||||
@@ -577,7 +577,7 @@ void GameObserver::Update(float dt)
|
||||
}
|
||||
currentActionPlayer = player;
|
||||
if (isInterrupting)
|
||||
player = isInterrupting;
|
||||
player = isInterrupting;
|
||||
if(mLayers)
|
||||
{
|
||||
mLayers->Update(dt, player);
|
||||
@@ -597,7 +597,7 @@ void GameObserver::gameStateBasedEffects()
|
||||
{
|
||||
if(getCurrentTargetChooser() && int(getCurrentTargetChooser()->getNbTargets()) == getCurrentTargetChooser()->maxtargets)
|
||||
getCurrentTargetChooser()->done = true;
|
||||
/////////////////////////////////////
|
||||
/////////////////////////////////////
|
||||
for (int d = 0; d < 2; d++)
|
||||
{
|
||||
MTGGameZone * dzones[] = { players[d]->game->inPlay, players[d]->game->graveyard, players[d]->game->hand, players[d]->game->library, players[d]->game->exile };
|
||||
@@ -608,8 +608,8 @@ void GameObserver::gameStateBasedEffects()
|
||||
{
|
||||
for (int c = zone->nb_cards - 1; c >= 0; c--)
|
||||
{
|
||||
zone->cards[c]->cardistargetted = 0;
|
||||
zone->cards[c]->cardistargetter = 0;
|
||||
zone->cards[c]->cardistargetted = 0;
|
||||
zone->cards[c]->cardistargetter = 0;
|
||||
}
|
||||
}
|
||||
}//check for losers if its GAMEOVER clear the stack to allow gamestateeffects to continue
|
||||
@@ -1167,9 +1167,9 @@ void GameObserver::Render()
|
||||
if(mLayers)
|
||||
mLayers->Render();
|
||||
if (targetChooser || (mLayers && mLayers->actionLayer()->isWaitingForAnswer()))
|
||||
JRenderer::GetInstance()->DrawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(255,255,0,0));
|
||||
JRenderer::GetInstance()->DrawRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(255,255,0,0));
|
||||
if (mExtraPayment)
|
||||
mExtraPayment->Render();
|
||||
mExtraPayment->Render();
|
||||
|
||||
for (size_t i = 0; i < players.size(); ++i)
|
||||
{
|
||||
@@ -1253,7 +1253,7 @@ void GameObserver::stackObjectClicked(Interruptible * action)
|
||||
{
|
||||
int reaction = mLayers->actionLayer()->isReactingToTargetClick(action);
|
||||
if (reaction == -1)
|
||||
mLayers->actionLayer()->reactToTargetClick(action);
|
||||
mLayers->actionLayer()->reactToTargetClick(action);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1333,7 +1333,7 @@ int GameObserver::cardClick(MTGCardInstance * card, Targetable * object, bool lo
|
||||
MTGCardInstance* backup = NULL;
|
||||
|
||||
if (!card) {
|
||||
clickedPlayer = ((Player *) object);
|
||||
clickedPlayer = ((Player *) object);
|
||||
} else {
|
||||
backup = card;
|
||||
zone = card->currentZone;
|
||||
@@ -1447,7 +1447,7 @@ int GameObserver::cardClick(MTGCardInstance * card, Targetable * object, bool lo
|
||||
//Current player's hand
|
||||
handmodified = currentPlayer->handsize+currentPlayer->handmodifier;
|
||||
if(handmodified < 0)
|
||||
handmodified = 0;
|
||||
handmodified = 0;
|
||||
if (currentPlayer->game->hand->hasCard(card) && mCurrentGamePhase == MTG_PHASE_CLEANUP
|
||||
&& currentPlayer->game->hand->nb_cards > handmodified && currentPlayer->nomaxhandsize == false)
|
||||
{
|
||||
@@ -1487,9 +1487,9 @@ int GameObserver::untap(MTGCardInstance * card)
|
||||
return 0;
|
||||
}
|
||||
if (card->has(Constants::DOESNOTUNTAP))
|
||||
return 0;
|
||||
return 0;
|
||||
if (card->frozen > 0)
|
||||
return 0;
|
||||
return 0;
|
||||
card->attemptUntap();
|
||||
return 1;
|
||||
}
|
||||
@@ -1511,7 +1511,7 @@ int GameObserver::isInPlay(MTGCardInstance * card)
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
if (players[i]->game->isInPlay(card))
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1552,10 +1552,10 @@ void GameObserver::untapPhase()
|
||||
int GameObserver::receiveEvent(WEvent * e)
|
||||
{
|
||||
if (!e)
|
||||
return 0;
|
||||
return 0;
|
||||
eventsQueue.push(e);
|
||||
if (eventsQueue.size() > 1)
|
||||
return -1; //resolving events can generate more events
|
||||
return -1; //resolving events can generate more events
|
||||
int result = 0;
|
||||
while (eventsQueue.size())
|
||||
{
|
||||
@@ -1574,7 +1574,7 @@ int GameObserver::receiveEvent(WEvent * e)
|
||||
Player * GameObserver::currentlyActing()
|
||||
{
|
||||
if (isInterrupting)
|
||||
return isInterrupting;
|
||||
return isInterrupting;
|
||||
return currentActionPlayer;
|
||||
}
|
||||
|
||||
@@ -1667,7 +1667,7 @@ bool GameObserver::load(const string& ss, bool undo, int controlledPlayerIndex
|
||||
)
|
||||
{
|
||||
bool currentPlayerSet = false;
|
||||
int state = -1;
|
||||
int state = -1;
|
||||
string s;
|
||||
stringstream stream(ss);
|
||||
|
||||
@@ -1686,7 +1686,7 @@ bool GameObserver::load(const string& ss, bool undo, int controlledPlayerIndex
|
||||
if (s.find("seed ") == 0)
|
||||
{
|
||||
mSeed = atoi(s.substr(5).c_str());
|
||||
randomGenerator.setSeed(mSeed);
|
||||
randomGenerator.setSeed(mSeed);
|
||||
continue;
|
||||
}
|
||||
if (s.find("rvalues:") == 0)
|
||||
@@ -1755,7 +1755,7 @@ bool GameObserver::load(const string& ss, bool undo, int controlledPlayerIndex
|
||||
case 3:
|
||||
if (s.compare("[end]") == 0)
|
||||
{
|
||||
turn = 0;
|
||||
turn = 0;
|
||||
mLayers = NEW DuelLayers(this, controlledPlayerIndex);
|
||||
currentPlayer = players[currentPlayerId];
|
||||
phaseRing = NEW PhaseRing(this);
|
||||
@@ -1844,7 +1844,7 @@ bool GameObserver::processAction(const string& s)
|
||||
DebugTrace("no clue about: " + s);
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameObserver::processActions(bool undo
|
||||
@@ -1885,7 +1885,7 @@ bool GameObserver::processActions(bool undo
|
||||
|
||||
for(loadingite = loadingList.begin(); loadingite != loadingList.end(); loadingite++, cmdIndex++)
|
||||
{
|
||||
processAction(*loadingite);
|
||||
processAction(*loadingite);
|
||||
|
||||
size_t nb = actionsList.size();
|
||||
|
||||
@@ -1965,7 +1965,7 @@ Player* GameObserver::createPlayer(const string& playerMode
|
||||
)
|
||||
{
|
||||
Player::Mode aMode = (Player::Mode)atoi(playerMode.c_str());
|
||||
Player* pPlayer = 0;
|
||||
Player* pPlayer = 0;
|
||||
|
||||
switch(aMode)
|
||||
{
|
||||
@@ -1989,12 +1989,12 @@ Player* GameObserver::createPlayer(const string& playerMode
|
||||
break;
|
||||
}
|
||||
|
||||
if(pPlayer)
|
||||
{
|
||||
players.push_back(pPlayer);
|
||||
}
|
||||
if(pPlayer)
|
||||
{
|
||||
players.push_back(pPlayer);
|
||||
}
|
||||
|
||||
return pPlayer;
|
||||
return pPlayer;
|
||||
}
|
||||
|
||||
#ifdef TESTSUITE
|
||||
@@ -2040,7 +2040,7 @@ void GameObserver::loadPlayer(int playerId, PlayerType playerType, int decknb, b
|
||||
|
||||
loadPlayer(playerId, NEW HumanPlayer(this, deckFile, deckFileSmall, premadeDeck));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ //AI Player, chooses deck
|
||||
AIPlayerFactory playerCreator;
|
||||
@@ -2076,43 +2076,43 @@ void GameObserver::loadPlayer(int playerId, PlayerType playerType, int decknb, b
|
||||
|
||||
#ifdef NETWORK_SUPPORT
|
||||
NetworkGameObserver::NetworkGameObserver(JNetwork* pNetwork, WResourceManager* output, JGE* input)
|
||||
: GameObserver(output, input), mpNetworkSession(pNetwork), mSynchronized(false)
|
||||
: GameObserver(output, input), mpNetworkSession(pNetwork), mSynchronized(false)
|
||||
{
|
||||
mpNetworkSession->registerCommand("loadPlayer", this, loadPlayer, ignoreResponse);
|
||||
mpNetworkSession->registerCommand("synchronize", this, synchronize, checkSynchro);
|
||||
mpNetworkSession->registerCommand("sendAction", this, sendAction, checkSynchro);
|
||||
mpNetworkSession->registerCommand("disconnect", this, disconnect, ignoreResponse);
|
||||
mpNetworkSession->registerCommand("loadPlayer", this, loadPlayer, ignoreResponse);
|
||||
mpNetworkSession->registerCommand("synchronize", this, synchronize, checkSynchro);
|
||||
mpNetworkSession->registerCommand("sendAction", this, sendAction, checkSynchro);
|
||||
mpNetworkSession->registerCommand("disconnect", this, disconnect, ignoreResponse);
|
||||
}
|
||||
|
||||
NetworkGameObserver::~NetworkGameObserver()
|
||||
{
|
||||
mpNetworkSession->sendCommand("disconnect", "");
|
||||
mpNetworkSession->sendCommand("disconnect", "");
|
||||
}
|
||||
|
||||
void NetworkGameObserver::disconnect(void*pxThis, stringstream&, stringstream&)
|
||||
{
|
||||
NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis;
|
||||
pThis->setLoser(pThis->getView()->getRenderedPlayerOpponent());
|
||||
NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis;
|
||||
pThis->setLoser(pThis->getView()->getRenderedPlayerOpponent());
|
||||
}
|
||||
|
||||
void NetworkGameObserver::Update(float dt)
|
||||
{
|
||||
mpNetworkSession->Update();
|
||||
::GameObserver::Update(dt);
|
||||
mpNetworkSession->Update();
|
||||
::GameObserver::Update(dt);
|
||||
}
|
||||
|
||||
void NetworkGameObserver::loadPlayer(int playerId, Player* player)
|
||||
{
|
||||
GameObserver::loadPlayer(playerId, player);
|
||||
stringstream out;
|
||||
out << *player;
|
||||
mpNetworkSession->sendCommand("loadPlayer", out.str());
|
||||
GameObserver::loadPlayer(playerId, player);
|
||||
stringstream out;
|
||||
out << *player;
|
||||
mpNetworkSession->sendCommand("loadPlayer", out.str());
|
||||
}
|
||||
|
||||
void NetworkGameObserver::loadPlayer(void*pxThis, stringstream& in, stringstream&)
|
||||
{
|
||||
NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis;
|
||||
Player* pPlayer = 0;
|
||||
NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis;
|
||||
Player* pPlayer = 0;
|
||||
string s;
|
||||
|
||||
while(std::getline(in, s))
|
||||
@@ -2135,50 +2135,50 @@ void NetworkGameObserver::loadPlayer(void*pxThis, stringstream& in, stringstream
|
||||
|
||||
void NetworkGameObserver::synchronize()
|
||||
{
|
||||
if(!mSynchronized && mpNetworkSession->isServer())
|
||||
{
|
||||
stringstream out;
|
||||
out << *this;
|
||||
mpNetworkSession->sendCommand("synchronize", out.str());
|
||||
mSynchronized = true;
|
||||
}
|
||||
if(!mSynchronized && mpNetworkSession->isServer())
|
||||
{
|
||||
stringstream out;
|
||||
out << *this;
|
||||
mpNetworkSession->sendCommand("synchronize", out.str());
|
||||
mSynchronized = true;
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkGameObserver::synchronize(void*pxThis, stringstream& in, stringstream& out)
|
||||
{
|
||||
NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis;
|
||||
// now, we need to load the game from player 2's perspective
|
||||
pThis->load(in.str(), false, 1);
|
||||
out << *pThis;
|
||||
NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis;
|
||||
// now, we need to load the game from player 2's perspective
|
||||
pThis->load(in.str(), false, 1);
|
||||
out << *pThis;
|
||||
}
|
||||
|
||||
|
||||
void NetworkGameObserver::checkSynchro(void*pxThis, stringstream& in, stringstream&)
|
||||
{
|
||||
NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis;
|
||||
|
||||
GameObserver aGame;
|
||||
aGame.mRules = pThis->mRules;
|
||||
aGame.load(in.str());
|
||||
NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis;
|
||||
|
||||
GameObserver aGame;
|
||||
aGame.mRules = pThis->mRules;
|
||||
aGame.load(in.str());
|
||||
|
||||
assert(aGame == *pThis);
|
||||
assert(aGame == *pThis);
|
||||
}
|
||||
|
||||
void NetworkGameObserver::sendAction(void*pxThis, stringstream& in, stringstream&)
|
||||
{
|
||||
NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis;
|
||||
NetworkGameObserver* pThis = (NetworkGameObserver*)pxThis;
|
||||
|
||||
pThis->mForwardAction = false;
|
||||
pThis->processAction(in.str());
|
||||
pThis->processAction(in.str());
|
||||
pThis->mForwardAction = true;
|
||||
//out << *pThis;
|
||||
//out << *pThis;
|
||||
}
|
||||
|
||||
void NetworkGameObserver::logAction(const string& s)
|
||||
{
|
||||
GameObserver::logAction(s);
|
||||
if(mForwardAction)
|
||||
mpNetworkSession->sendCommand("sendAction", s);
|
||||
GameObserver::logAction(s);
|
||||
if(mForwardAction)
|
||||
mpNetworkSession->sendCommand("sendAction", s);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,8 +18,8 @@ const string Options::optionNames[] = {
|
||||
"sfxVolume",
|
||||
"difficulty",
|
||||
"cheatmode",
|
||||
"optimizedhand",
|
||||
"cheatmodedecks",
|
||||
"optimizedhand",
|
||||
"cheatmodedecks",
|
||||
"displayOSD",
|
||||
"closed_hand",
|
||||
"hand_direction",
|
||||
@@ -352,11 +352,11 @@ int GameOptions::load()
|
||||
}
|
||||
// (PSY) Make sure that cheatmode is switched off for ineligible profiles:
|
||||
if (options[Options::ACTIVE_PROFILE].str != SECRET_PROFILE)
|
||||
{
|
||||
{
|
||||
(*this)[Options::CHEATMODE].number = 0;
|
||||
(*this)[Options::OPTIMIZE_HAND].number = 0;
|
||||
(*this)[Options::CHEATMODEAIDECK].number = 0;
|
||||
}
|
||||
(*this)[Options::OPTIMIZE_HAND].number = 0;
|
||||
(*this)[Options::CHEATMODEAIDECK].number = 0;
|
||||
}
|
||||
|
||||
//Default values. Anywhere else to put those ?
|
||||
if (!(*this)[Options::MAX_GRADE].number)
|
||||
@@ -371,11 +371,11 @@ int GameOptions::save()
|
||||
{
|
||||
// (PSY) Make sure that cheatmode is switched off for ineligible profiles:
|
||||
if (options[Options::ACTIVE_PROFILE].str != SECRET_PROFILE)
|
||||
{
|
||||
{
|
||||
(*this)[Options::CHEATMODE].number = 0;
|
||||
(*this)[Options::OPTIMIZE_HAND].number = 0;
|
||||
(*this)[Options::CHEATMODEAIDECK].number = 0;
|
||||
}
|
||||
(*this)[Options::OPTIMIZE_HAND].number = 0;
|
||||
(*this)[Options::CHEATMODEAIDECK].number = 0;
|
||||
}
|
||||
|
||||
std::ofstream file;
|
||||
if (JFileSystem::GetInstance()->openForWrite(file, mFilename))
|
||||
@@ -997,9 +997,9 @@ OptionManaDisplay::OptionManaDisplay()
|
||||
{
|
||||
mDef.values.push_back(EnumDefinition::assoc(DYNAMIC, "Eye candy"));
|
||||
mDef.values.push_back(EnumDefinition::assoc(STATIC, "Simple"));
|
||||
mDef.values.push_back(EnumDefinition::assoc(NOSTARSDYNAMIC, "No Glitter"));
|
||||
mDef.values.push_back(EnumDefinition::assoc(NOSTARSDYNAMIC, "No Glitter"));
|
||||
mDef.values.push_back(EnumDefinition::assoc(BOTH, "Both"));//no luck in getting this to show up as an option.
|
||||
//Both should still work as always however the enum and this dont want to pair up, no "both" in options now.
|
||||
//Both should still work as always however the enum and this dont want to pair up, no "both" in options now.
|
||||
}
|
||||
;
|
||||
OptionVolume OptionVolume::mDef;
|
||||
|
||||
@@ -70,7 +70,7 @@ vector<DeckMetaData *> GameState::BuildDeckList(const string& path, const string
|
||||
{
|
||||
std::ostringstream aiStatsDeckName;
|
||||
aiStatsDeckName << smallDeckPrefix << "_deck" << nbDecks;
|
||||
meta->mStatsFilename = aiStatsDeckName.str();
|
||||
meta->mStatsFilename = aiStatsDeckName.str();
|
||||
meta->mIsAI = true;
|
||||
if (meta->mPlayerDeck != statsPlayer->GetCurrentDeckStatsFile())
|
||||
{
|
||||
@@ -100,7 +100,7 @@ vector<DeckMetaData *> GameState::BuildDeckList(const string& path, const string
|
||||
meta = NULL;
|
||||
}
|
||||
|
||||
std::sort(retList.begin(), retList.end(), sortByName);
|
||||
std::sort(retList.begin(), retList.end(), sortByName);
|
||||
return retList;
|
||||
|
||||
}
|
||||
|
||||
@@ -1095,7 +1095,7 @@ void GameStateDuel::Render()
|
||||
char buf[4096];
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
|
||||
int elapsedTime = testSuite->getElapsedTime();
|
||||
int elapsedTime = testSuite->getElapsedTime();
|
||||
sprintf(buf, "Time to run the tests: %is", elapsedTime/1000);
|
||||
mFont->DrawString(buf,0,SCREEN_HEIGHT/2 - 20);
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ void GameStateMenu::genNbCardsStr()
|
||||
PlayerData * playerdata = NEW PlayerData(MTGCollection());
|
||||
size_t totalUnique = MTGCollection()->primitives.size();
|
||||
size_t totalPrints = MTGCollection()->totalCards();
|
||||
|
||||
|
||||
if (totalUnique != totalPrints)
|
||||
{
|
||||
if (playerdata && !options[Options::ACTIVE_PROFILE].isDefault())
|
||||
@@ -481,7 +481,7 @@ void GameStateMenu::Update(float dt)
|
||||
mParent->mpNetwork->connect(mParent->mServerAddress);
|
||||
// we let the server choose the game mode
|
||||
mParent->gameType = GAME_TYPE_SLAVE;
|
||||
// just to select one, the HOST is in control here.
|
||||
// just to select one, the HOST is in control here.
|
||||
mParent->rules = Rules::getRulesByFilename("classic.txt");
|
||||
hasChosenGameType = true;
|
||||
subMenuController->Close();
|
||||
@@ -599,16 +599,16 @@ void GameStateMenu::Update(float dt)
|
||||
case MENU_STATE_NETWORK_DEFINE:
|
||||
if(MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR))
|
||||
{
|
||||
currentState = MENU_STATE_MAJOR_SUBMENU;
|
||||
currentState = MENU_STATE_MAJOR_SUBMENU;
|
||||
subMenuController = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60);
|
||||
if (subMenuController)
|
||||
{
|
||||
subMenuController->Add(SUBMENUITEM_HOST_GAME, "Host a game");
|
||||
subMenuController->Add(SUBMENUITEM_JOIN_GAME, "Join a game");
|
||||
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (subMenuController)
|
||||
{
|
||||
subMenuController->Add(SUBMENUITEM_HOST_GAME, "Host a game");
|
||||
subMenuController->Add(SUBMENUITEM_JOIN_GAME, "Join a game");
|
||||
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MENU_STATE_NETWORK_WAIT:
|
||||
if(MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR))
|
||||
{
|
||||
@@ -619,9 +619,9 @@ void GameStateMenu::Update(float dt)
|
||||
}
|
||||
else if(!subMenuController)
|
||||
{
|
||||
string aString;
|
||||
mParent->mpNetwork->getServerIp(aString);
|
||||
aString = "Waiting for connection to " + aString;
|
||||
string aString;
|
||||
mParent->mpNetwork->getServerIp(aString);
|
||||
aString = "Waiting for connection to " + aString;
|
||||
|
||||
subMenuController = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), MENU_FIRST_DUEL_SUBMENU, this, Fonts::MENU_FONT, 150, 60, aString.c_str());
|
||||
if (subMenuController)
|
||||
@@ -918,7 +918,7 @@ void GameStateMenu::ButtonPressed(int controllerId, int controlId)
|
||||
subMenuController->Close();
|
||||
}
|
||||
#ifdef NETWORK_SUPPORT
|
||||
SAFE_DELETE(mParent->mpNetwork);
|
||||
SAFE_DELETE(mParent->mpNetwork);
|
||||
#endif //NETWORK_SUPPORT
|
||||
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_SUBMENU_CLOSING;
|
||||
break;
|
||||
|
||||
@@ -81,8 +81,8 @@ void GameStateOptions::Start()
|
||||
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")));
|
||||
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODEAIDECK, "Unlock All Ai Decks")));
|
||||
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::OPTIMIZE_HAND, "Optimize Starting Hand")));
|
||||
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODEAIDECK, "Unlock All Ai Decks")));
|
||||
|
||||
optionsTabs->Add(optionsList);
|
||||
|
||||
|
||||
@@ -627,12 +627,12 @@ void GameStateShop::Update(float dt)
|
||||
else if (btn == JGE_BTN_CANCEL)
|
||||
options[Options::DISABLECARDS].number = !options[Options::DISABLECARDS].number;
|
||||
else if (btn == JGE_BTN_SEC)
|
||||
{
|
||||
{
|
||||
bListCards = !bListCards;
|
||||
disablePurchase = false;
|
||||
clearInput = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (shopMenu)
|
||||
{
|
||||
#if defined (IOS) || defined (ANDROID)
|
||||
@@ -770,7 +770,7 @@ void GameStateShop::Render()
|
||||
|
||||
#ifndef TOUCH_ENABLED
|
||||
float len = 4 + mFont->GetStringWidth(kOtherCardsString.c_str());
|
||||
r->RenderQuad(pspIcons[6].get(), SCREEN_WIDTH - len - 0.5 - 10, SCREEN_HEIGHT - 8, 0, kPspIconScaleFactor, kPspIconScaleFactor);
|
||||
r->RenderQuad(pspIcons[6].get(), SCREEN_WIDTH - len - 0.5 - 10, SCREEN_HEIGHT - 8, 0, kPspIconScaleFactor, kPspIconScaleFactor);
|
||||
mFont->DrawString(kOtherCardsString, SCREEN_WIDTH - len, SCREEN_HEIGHT - 14);
|
||||
#else
|
||||
enableButtons();
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
GuiAvatars::GuiAvatars(DuelLayers* duelLayers) :
|
||||
GuiLayer(duelLayers), active(NULL)
|
||||
{
|
||||
Add(self = NEW GuiAvatar(SCREEN_WIDTH, SCREEN_HEIGHT, false, mpDuelLayers->getRenderedPlayer(), GuiAvatar::BOTTOM_RIGHT, this));
|
||||
Add(self = NEW GuiAvatar(SCREEN_WIDTH, SCREEN_HEIGHT, false, mpDuelLayers->getRenderedPlayer(), GuiAvatar::BOTTOM_RIGHT, this));
|
||||
self->zoom = 0.9f;
|
||||
Add(selfGraveyard = NEW GuiGraveyard(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 1, false, mpDuelLayers->getRenderedPlayer(), this));
|
||||
Add(selfLibrary = NEW GuiLibrary(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 5 + GuiGameZone::Height + 5, false, mpDuelLayers->getRenderedPlayer(), this));
|
||||
//myexile
|
||||
//myexile
|
||||
Add(selfExile = NEW GuiExile(SCREEN_WIDTH - GuiAvatar::Width - GuiGameZone::Width / 2 - 11, SCREEN_HEIGHT - GuiAvatar::Height - 30, false, mpDuelLayers->getRenderedPlayer(), this));
|
||||
|
||||
Add(opponent = NEW GuiAvatar(0, 0, false, mpDuelLayers->getRenderedPlayerOpponent(), GuiAvatar::TOP_LEFT, this));
|
||||
|
||||
@@ -330,4 +330,4 @@ int GuiHandOpponent::receiveEventMinus(WEvent* e)
|
||||
|
||||
// I wanna write it like that. GCC doesn't want me to without -O.
|
||||
// I'm submitting a bug report.
|
||||
// it->x = (it->x + (flip ? RightRowX : LeftRowX)) / 2;
|
||||
// it->x = (it->x + (flip ? RightRowX : LeftRowX)) / 2;
|
||||
|
||||
@@ -106,14 +106,14 @@ ManaIcon::ManaIcon(int color, float x, float y, float destx, float desty) :
|
||||
|
||||
// if we want to throttle the amount of particles for mana,
|
||||
// here's where to do it - this is hardcoded to something like 114 in the psi file
|
||||
if(OptionManaDisplay::NOSTARSDYNAMIC == options[Options::MANADISPLAY].number)
|
||||
{
|
||||
if(OptionManaDisplay::NOSTARSDYNAMIC == options[Options::MANADISPLAY].number)
|
||||
{
|
||||
particleSys->info.nEmission = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
particleSys->info.nEmission = 60;
|
||||
}
|
||||
}
|
||||
icon = manaIcons[color];
|
||||
|
||||
particleSys->FireAt(x, y);
|
||||
@@ -193,7 +193,7 @@ void ManaIcon::Update(float dt, float shift)
|
||||
|
||||
if (particleSys && (fabs(destx - x) < 5) && (fabs(desty + shift - y) < 5))
|
||||
{
|
||||
if (OptionManaDisplay::STATIC == options[Options::MANADISPLAY].number)
|
||||
if (OptionManaDisplay::STATIC == options[Options::MANADISPLAY].number)
|
||||
{
|
||||
SAFE_DELETE(particleSys); //Static Mana Only: avoid expensive particle processing
|
||||
}
|
||||
@@ -305,7 +305,7 @@ void GuiMana::Render()
|
||||
for (vector<ManaIcon*>::iterator it = manas.begin(); it != manas.end(); ++it)
|
||||
(*it)->Render();
|
||||
|
||||
if (OptionManaDisplay::DYNAMIC != options[Options::MANADISPLAY].number && OptionManaDisplay::NOSTARSDYNAMIC != options[Options::MANADISPLAY].number )
|
||||
if (OptionManaDisplay::DYNAMIC != options[Options::MANADISPLAY].number && OptionManaDisplay::NOSTARSDYNAMIC != options[Options::MANADISPLAY].number )
|
||||
RenderStatic();
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ void GuiPlay::BattleField::reset(float x, float y)
|
||||
void GuiPlay::BattleField::EnstackAttacker(CardView* card)
|
||||
{
|
||||
card->x = CARD_WIDTH + 20 + (currentAttacker * (HORZWIDTH) / (attackers+1));
|
||||
card->y = baseY + (card->card->getObserver()->getView()->getRenderedPlayer() == card->card->controller() ? 20 + y : -20 - y);
|
||||
card->y = baseY + (card->card->getObserver()->getView()->getRenderedPlayer() == card->card->controller() ? 20 + y : -20 - y);
|
||||
++currentAttacker;
|
||||
// JRenderer::GetInstance()->RenderQuad(WResourceManager::Instance()->GetQuad("BattleIcon"), card->actX, card->actY, 0, 0.5 + 0.1 * sinf(JGE::GetInstance()->GetTime()), 0.5 + 0.1 * sinf(JGE::GetInstance()->GetTime()));
|
||||
}
|
||||
@@ -197,7 +197,7 @@ void GuiPlay::Replace()
|
||||
{
|
||||
if((!(*it)->card->hasSubtype(Subtypes::TYPE_AURA)|| ((*it)->card->hasSubtype(Subtypes::TYPE_AURA) && (*it)->card->playerTarget)) && !(*it)->card->hasType(Subtypes::TYPE_PLANESWALKER))
|
||||
{
|
||||
if (mpDuelLayers->getRenderedPlayer() == (*it)->card->controller())
|
||||
if (mpDuelLayers->getRenderedPlayer() == (*it)->card->controller())
|
||||
++selfSpellsN;
|
||||
else
|
||||
++opponentSpellsN;
|
||||
@@ -398,7 +398,7 @@ int GuiPlay::receiveEventPlus(WEvent * e)
|
||||
}
|
||||
else
|
||||
{
|
||||
// this should never happen, if you have a consistent repro case, ping Wil please
|
||||
// this should never happen, if you have a consistent repro case, ping Wil please
|
||||
assert(false);
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "WResourceManager.h"
|
||||
#include "WFont.h"
|
||||
|
||||
#define SCALE_SELECTED 1.2f
|
||||
#define SCALE_NORMAL 1.0f
|
||||
#define SCALE_SELECTED 1.2f
|
||||
#define SCALE_NORMAL 1.0f
|
||||
|
||||
IconButtonsController::IconButtonsController(JGE* jge, float x, float y): JGuiController(jge, 0, NULL), mX(x), mY(y)
|
||||
{
|
||||
|
||||
@@ -80,7 +80,7 @@ void InteractiveButton::Render()
|
||||
mYOffset += 2;
|
||||
#endif
|
||||
|
||||
float buttonXOffset = getX() - mXOffset;
|
||||
float buttonXOffset = getX() - mXOffset;
|
||||
float buttonYOffset = getY() + mYOffset;
|
||||
if (buttonImage != NULL)
|
||||
{
|
||||
|
||||
@@ -730,8 +730,8 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
|
||||
bool limitOnceATurn = (s.find("turnlimited") != string::npos);
|
||||
bool isSuspended = (s.find("suspended") != string::npos);
|
||||
bool opponentPoisoned = (s.find("opponentpoisoned") != string::npos);
|
||||
bool lifelost = (s.find("foelost(") != string::npos);
|
||||
int lifeamount = lifelost ? atoi(s.substr(s.find("foelost(") + 8,')').c_str()) : 0;
|
||||
bool lifelost = (s.find("foelost(") != string::npos);
|
||||
int lifeamount = lifelost ? atoi(s.substr(s.find("foelost(") + 8,')').c_str()) : 0;
|
||||
bool neverRemove = (s.find("dontremove") != string::npos);
|
||||
|
||||
//Card Changed Zone
|
||||
@@ -1063,12 +1063,12 @@ MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a)
|
||||
if (MultiAbility * abi = dynamic_cast<MultiAbility*>(a))
|
||||
return getCoreAbility(abi->abilities[0]);
|
||||
|
||||
if (NestedAbility * na = dynamic_cast<NestedAbility*> (a))
|
||||
{
|
||||
if(na->ability)
|
||||
//only atempt to return a nestedability if it contains a valid ability. example where this causes a bug otherwise. AEquip is considered nested, but contains no ability.
|
||||
return getCoreAbility(na->ability);
|
||||
}
|
||||
if (NestedAbility * na = dynamic_cast<NestedAbility*> (a))
|
||||
{
|
||||
if(na->ability)
|
||||
//only atempt to return a nestedability if it contains a valid ability. example where this causes a bug otherwise. AEquip is considered nested, but contains no ability.
|
||||
return getCoreAbility(na->ability);
|
||||
}
|
||||
|
||||
if (MenuAbility * ma = dynamic_cast<MenuAbility*>(a))
|
||||
return getCoreAbility(ma->abilities[0]);
|
||||
@@ -1093,8 +1093,8 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
MTGCardInstance * target = card->target;
|
||||
if (!target)
|
||||
target = card;
|
||||
//pay and castcard?
|
||||
if(s.find("castcard(restricted") != string::npos && (s.find("pay(") != string::npos || s.find("pay[[") != string::npos))
|
||||
//pay and castcard?
|
||||
if(s.find("castcard(restricted") != string::npos && (s.find("pay(") != string::npos || s.find("pay[[") != string::npos))
|
||||
asAlternate = true;
|
||||
//MTG Specific rules
|
||||
//adds the bonus credit system
|
||||
@@ -1826,7 +1826,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
|
||||
found = string::npos;
|
||||
i = -1;
|
||||
for (size_t j = 0; j < kLordKeywordsCount; ++j)
|
||||
for (size_t j = 0; j < kLordKeywordsCount; ++j)
|
||||
{
|
||||
size_t found2 = s.find(kLordKeywords[j]);
|
||||
if (found2 != string::npos && ((found == string::npos) || found2 < found))
|
||||
@@ -2602,16 +2602,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
return a;
|
||||
}
|
||||
|
||||
//set hand size
|
||||
vector<string> splitSetHand = parseBetween(s, "sethand:", " ", false);
|
||||
if (splitSetHand.size())
|
||||
{
|
||||
int hand = atoi(splitSetHand[1].c_str());
|
||||
Damageable * t = spell ? spell->getNextDamageableTarget() : NULL;
|
||||
//set hand size
|
||||
vector<string> splitSetHand = parseBetween(s, "sethand:", " ", false);
|
||||
if (splitSetHand.size())
|
||||
{
|
||||
int hand = atoi(splitSetHand[1].c_str());
|
||||
Damageable * t = spell ? spell->getNextDamageableTarget() : NULL;
|
||||
MTGAbility * a = NEW AASetHand(observer, id, card, t, hand, NULL, who);
|
||||
a->oneShot = 1;
|
||||
return a;
|
||||
}
|
||||
a->oneShot = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
//set life total
|
||||
vector<string> splitLifeset = parseBetween(s, "lifeset:", " ", false);
|
||||
@@ -2723,7 +2723,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
}
|
||||
|
||||
//Cast/Play Restrictions
|
||||
for (size_t i = 0; i < kMaxCastKeywordsCount; ++i)
|
||||
for (size_t i = 0; i < kMaxCastKeywordsCount; ++i)
|
||||
{
|
||||
vector<string> splitCast = parseBetween(s, kMaxCastKeywords[i], ")");
|
||||
if (splitCast.size())
|
||||
@@ -2939,9 +2939,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
{
|
||||
vector<string> becomesParameters = split(splitBecomes[1], ',');
|
||||
string stypes = becomesParameters[0];
|
||||
string newPower = "";
|
||||
string newPower = "";
|
||||
string newToughness = "";
|
||||
bool ptFound = false;
|
||||
bool ptFound = false;
|
||||
if(becomesParameters.size() >1)
|
||||
{
|
||||
vector<string> pt = split(becomesParameters[1], '/');
|
||||
@@ -2952,17 +2952,17 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
ptFound = true;
|
||||
}
|
||||
}
|
||||
string sabilities = "";
|
||||
string sabilities = "";
|
||||
unsigned int becomesSize = ptFound?2:1;
|
||||
if(becomesParameters.size() > becomesSize)
|
||||
{
|
||||
for(unsigned int i = becomesSize;i < becomesParameters.size();i++)
|
||||
{
|
||||
sabilities.append(becomesParameters[i].c_str());
|
||||
if(i+1 < becomesParameters.size())
|
||||
sabilities.append(",");
|
||||
}
|
||||
}
|
||||
if(becomesParameters.size() > becomesSize)
|
||||
{
|
||||
for(unsigned int i = becomesSize;i < becomesParameters.size();i++)
|
||||
{
|
||||
sabilities.append(becomesParameters[i].c_str());
|
||||
if(i+1 < becomesParameters.size())
|
||||
sabilities.append(",");
|
||||
}
|
||||
}
|
||||
if (oneShot || forceUEOT || forceForever)
|
||||
return NEW ATransformerInstant(observer, id, card, target, stypes, sabilities,newPower,ptFound,newToughness,ptFound,vector<string>(),false,forceForever,untilYourNextTurn);
|
||||
|
||||
@@ -3044,14 +3044,14 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
newtoughnessfound = true;
|
||||
newtoughness = splitToughness[1];
|
||||
}
|
||||
if(abilities[j].find("newability[") != string::npos)
|
||||
{
|
||||
size_t NewSkill = abilities[j].find("newability[");
|
||||
size_t NewSkillEnd = abilities[j].find_last_of("]");
|
||||
string newAbilities = abilities[j].substr(NewSkill + 11,NewSkillEnd - NewSkill - 11);
|
||||
newAbilitiesList.push_back(newAbilities);
|
||||
newAbilityFound = true;
|
||||
}
|
||||
if(abilities[j].find("newability[") != string::npos)
|
||||
{
|
||||
size_t NewSkill = abilities[j].find("newability[");
|
||||
size_t NewSkillEnd = abilities[j].find_last_of("]");
|
||||
string newAbilities = abilities[j].substr(NewSkill + 11,NewSkillEnd - NewSkill - 11);
|
||||
newAbilitiesList.push_back(newAbilities);
|
||||
newAbilityFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (oneShot || forceUEOT || forceForever)
|
||||
@@ -3088,7 +3088,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
{
|
||||
return NEW PTInstant(observer, id, card, target, wppt,s,nonstatic);
|
||||
}
|
||||
else if(s.find("cdaactive") != string::npos)
|
||||
else if(s.find("cdaactive") != string::npos)
|
||||
{
|
||||
MTGAbility * a = NEW APowerToughnessModifier(observer, id, card, target, wppt,s,true);
|
||||
a->forcedAlive = 1;
|
||||
@@ -3096,7 +3096,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
return a;
|
||||
//return NEW APowerToughnessModifier(observer, id, card, target, wppt,s,true);
|
||||
}
|
||||
else
|
||||
else
|
||||
return NEW APowerToughnessModifier(observer, id, card, target, wppt,s,nonstatic);
|
||||
}
|
||||
return NEW PTInstant(observer, id, card, target, wppt,s,nonstatic);
|
||||
|
||||
@@ -753,7 +753,7 @@ bool MTGCardInstance::StackIsEmptyandSorcerySpeed()
|
||||
controller() == getObserver()->currentPlayer &&
|
||||
!getObserver()->isInterrupting)
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -777,10 +777,10 @@ bool MTGCardInstance::isTargetted()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(cardistargetted)
|
||||
return true;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
//check targetter?
|
||||
@@ -802,10 +802,10 @@ bool MTGCardInstance::isTargetter()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(cardistargetter)
|
||||
return true;
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
int MTGCardInstance::canBlock()
|
||||
@@ -927,7 +927,7 @@ ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * old
|
||||
return oldCost;
|
||||
//use forcedalive//
|
||||
//pay zero costs//
|
||||
//kicker???...//
|
||||
//kicker???...//
|
||||
//morph cost todo//
|
||||
//trinisphere must be here below//
|
||||
if(card->has(Constants::TRINISPHERE))
|
||||
|
||||
@@ -281,7 +281,7 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
{
|
||||
string value = val;
|
||||
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
|
||||
cost->setSuspend(ManaCost::parseManaCost(value));
|
||||
cost->setSuspend(ManaCost::parseManaCost(value));
|
||||
primitive->suspendedTime = suspendTime;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ const string Constants::kManaRed = "red";
|
||||
const string Constants::kManaBlack = "black";
|
||||
const string Constants::kManaWhite = "white";
|
||||
|
||||
int Constants::_r[7] = {75, 20, 20, 200,50,255,128};
|
||||
int Constants::_g[7] = {30, 140, 30, 15, 50,255,128};
|
||||
int Constants::_b[7] = {20, 0, 140,15, 50,255,128};
|
||||
int Constants::_r[7] = {75,20,20,200,50,255,128};
|
||||
int Constants::_g[7] = {30,140,30,15,50,255,128};
|
||||
int Constants::_b[7] = {20,0,140,15,50,255,128};
|
||||
|
||||
|
||||
const string Constants::kAlternativeKeyword = "alternative";
|
||||
@@ -184,36 +184,36 @@ int Constants::GetColorStringIndex(string mtgColor)
|
||||
|
||||
const string Constants::MTGPhaseNames[] =
|
||||
{
|
||||
"---",
|
||||
"Untap",
|
||||
"Upkeep",
|
||||
"Draw",
|
||||
"Main phase 1",
|
||||
"Combat begins",
|
||||
"Attackers",
|
||||
"Blockers",
|
||||
"Combat damage",
|
||||
"Combat ends",
|
||||
"Main phase 2",
|
||||
"End",
|
||||
"Cleanup",
|
||||
"---"
|
||||
"---",
|
||||
"Untap",
|
||||
"Upkeep",
|
||||
"Draw",
|
||||
"Main phase 1",
|
||||
"Combat begins",
|
||||
"Attackers",
|
||||
"Blockers",
|
||||
"Combat damage",
|
||||
"Combat ends",
|
||||
"Main phase 2",
|
||||
"End",
|
||||
"Cleanup",
|
||||
"---"
|
||||
};
|
||||
|
||||
const char* Constants::MTGPhaseCodeNames[] =
|
||||
{
|
||||
"beginofturn",
|
||||
"untap",
|
||||
"upkeep",
|
||||
"draw",
|
||||
"firstmain",
|
||||
"combatbegins",
|
||||
"attackers",
|
||||
"blockers",
|
||||
"combatdamage",
|
||||
"combatends",
|
||||
"secondmain",
|
||||
"end",
|
||||
"cleanup",
|
||||
"beforenextturn"
|
||||
"beginofturn",
|
||||
"untap",
|
||||
"upkeep",
|
||||
"draw",
|
||||
"firstmain",
|
||||
"combatbegins",
|
||||
"attackers",
|
||||
"blockers",
|
||||
"combatdamage",
|
||||
"combatends",
|
||||
"secondmain",
|
||||
"end",
|
||||
"cleanup",
|
||||
"beforenextturn"
|
||||
};
|
||||
|
||||
@@ -323,12 +323,12 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
||||
int doCopy = 1;
|
||||
bool shufflelibrary = card->basicAbilities[(int)Constants::SHUFFLELIBRARYDEATH];
|
||||
bool inplaytoinplay = false;
|
||||
bool ripToken = false;
|
||||
if (g->players[0]->game->battlefield->hasName("Rest in Peace")||g->players[1]->game->battlefield->hasName("Rest in Peace"))
|
||||
bool ripToken = false;
|
||||
if (g->players[0]->game->battlefield->hasName("Rest in Peace")||g->players[1]->game->battlefield->hasName("Rest in Peace"))
|
||||
ripToken = true;
|
||||
//Madness or Put in Play...
|
||||
for(int i = 0; i < 2; ++i)
|
||||
{
|
||||
{
|
||||
if (card->discarded && (to == g->players[i]->game->graveyard) && (from == g->players[i]->game->hand))
|
||||
{
|
||||
if(card->basicAbilities[(int)Constants::MADNESS])
|
||||
@@ -337,7 +337,7 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
||||
}
|
||||
//Darksteel Colossus, Legacy Weapon ... top priority since we replace destination directly automatically...
|
||||
for(int i = 0; i < 2; ++i)
|
||||
{
|
||||
{
|
||||
if ((to == g->players[i]->game->graveyard) && (
|
||||
card->basicAbilities[(int)Constants::LIBRARYDEATH]||
|
||||
card->basicAbilities[(int)Constants::SHUFFLELIBRARYDEATH]))
|
||||
@@ -347,13 +347,13 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
||||
}
|
||||
//Leyline of the Void, Yawgmoth's Agenda... effect...
|
||||
for(int i = 0; i < 2; ++i)
|
||||
{
|
||||
{
|
||||
if ((to == g->players[i]->game->graveyard) && (
|
||||
(g->players[i]->game->battlefield->hasAbility(Constants::MYGCREATUREEXILER) && card->isCreature()) ||
|
||||
(g->players[i]->opponent()->game->battlefield->hasAbility(Constants::OPPGCREATUREEXILER) && card->isCreature())||
|
||||
g->players[i]->game->battlefield->hasAbility(Constants::MYGRAVEEXILER) ||
|
||||
g->players[i]->opponent()->game->battlefield->hasAbility(Constants::OPPGRAVEEXILER)))
|
||||
{
|
||||
{
|
||||
if ((card->isToken && ripToken))
|
||||
to = g->players[i]->game->exile;
|
||||
if (!card->isToken)
|
||||
@@ -379,7 +379,7 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
||||
{//set discarded for madness...
|
||||
if(from == g->players[0]->game->hand || from == g->players[1]->game->hand)
|
||||
copy->discarded = true;
|
||||
else//turn off discarded if its previous zone is not in hand...
|
||||
else//turn off discarded if its previous zone is not in hand...
|
||||
copy->discarded = false;
|
||||
}
|
||||
if (options[Options::SFXVOLUME].number > 0)
|
||||
@@ -742,7 +742,7 @@ bool MTGGameZone::hasColor(int value)
|
||||
{
|
||||
for (int i = 0; i < (nb_cards); i++)
|
||||
{
|
||||
if (cards[i]->getManaCost()->hasColor(value) && cards[i]->getManaCost()->getConvertedCost() > 0)
|
||||
if (cards[i]->getManaCost()->hasColor(value) && cards[i]->getManaCost()->getConvertedCost() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ int MTGPackEntryRandom::addCard(WSrcCards *pool, MTGDeck *to)
|
||||
}
|
||||
int MTGPackEntrySpecific::addCard(WSrcCards *, MTGDeck *to)
|
||||
{
|
||||
if (!card)
|
||||
if (!card)
|
||||
return copies;
|
||||
for (int i = 0; i < copies; i++)
|
||||
to->add(card);
|
||||
|
||||
@@ -58,8 +58,8 @@ int MTGEventBonus::receiveEvent(WEvent * event)
|
||||
//bonus for chain chain casting without tapping for mana or being interupted;
|
||||
//note gaining mana from other sources is still possible.
|
||||
//only spells going to the stack are counted.
|
||||
if(game->turn <2)//this shouldnt trigger on first turn, chances are they are cheating.
|
||||
return 0;
|
||||
if(game->turn <2)//this shouldnt trigger on first turn, chances are they are cheating.
|
||||
return 0;
|
||||
if (dynamic_cast<WEventCardTappedForMana*>(event))
|
||||
{
|
||||
|
||||
@@ -285,9 +285,9 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
||||
int cardsinhand = game->players[0]->game->hand->nb_cards;
|
||||
Player * player = game->currentlyActing();
|
||||
if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card))
|
||||
return 0;
|
||||
if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
|
||||
return 0;
|
||||
return 0;
|
||||
if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
|
||||
return 0;
|
||||
if ((game->turn < 1) && (cardsinhand != 0) && (card->basicAbilities[(int)Constants::LEYLINE])
|
||||
&& game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN
|
||||
&& game->players[0]->game->graveyard->nb_cards == 0
|
||||
@@ -478,13 +478,13 @@ int MTGKickerRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
||||
return 0;
|
||||
Player * player = game->currentlyActing();
|
||||
if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card))
|
||||
return 0;
|
||||
if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
|
||||
return 0;
|
||||
return 0;
|
||||
if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
|
||||
return 0;
|
||||
ManaCost * kicker = card->getManaCost()->getKicker();
|
||||
if(!kicker)
|
||||
{
|
||||
SAFE_DELETE(kicker);
|
||||
SAFE_DELETE(kicker);
|
||||
return 0;
|
||||
}
|
||||
ManaCost * playerMana = player->getManaPool();
|
||||
@@ -627,13 +627,13 @@ PermanentAbility(observer, _id)
|
||||
|
||||
int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
{
|
||||
ManaCost * alternateCost = card->getManaCost()->getAlternative();
|
||||
if (!game->currentlyActing()->game->hand->hasCard(card) && !game->currentlyActing()->game->graveyard->hasCard(card) && !game->currentlyActing()->game->exile->hasCard(card))
|
||||
return 0;
|
||||
if ((game->currentlyActing()->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (game->currentlyActing()->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
|
||||
return 0;
|
||||
if (card->alias == 110000)
|
||||
return 0;//overload has its own rule
|
||||
ManaCost * alternateCost = card->getManaCost()->getAlternative();
|
||||
if (!game->currentlyActing()->game->hand->hasCard(card) && !game->currentlyActing()->game->graveyard->hasCard(card) && !game->currentlyActing()->game->exile->hasCard(card))
|
||||
return 0;
|
||||
if ((game->currentlyActing()->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (game->currentlyActing()->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
|
||||
return 0;
|
||||
return isReactingToClick( card, mana, alternateCost );
|
||||
}
|
||||
|
||||
@@ -647,7 +647,7 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
|
||||
return 0;
|
||||
|
||||
|
||||
if(card->has(Constants::CANPLAYFROMGRAVEYARD))
|
||||
if(card->has(Constants::CANPLAYFROMGRAVEYARD))
|
||||
alternativeName = "Alternate Cast From Graveyard";
|
||||
else if(card->has(Constants::CANPLAYFROMEXILE))
|
||||
alternativeName = "Alternate Cast From Exile";
|
||||
@@ -686,11 +686,11 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
|
||||
|
||||
int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card)
|
||||
{
|
||||
if ( !isReactingToClick(card))
|
||||
return 0;
|
||||
if ( !isReactingToClick(card))
|
||||
return 0;
|
||||
|
||||
ManaCost *alternateCost = card->getManaCost()->getAlternative();
|
||||
card->paymenttype = MTGAbility::ALTERNATIVE_COST;
|
||||
ManaCost *alternateCost = card->getManaCost()->getAlternative();
|
||||
card->paymenttype = MTGAbility::ALTERNATIVE_COST;
|
||||
|
||||
return reactToClick(card, alternateCost, ManaCost::MANA_PAID_WITH_ALTERNATIVE);
|
||||
}
|
||||
@@ -703,15 +703,15 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter
|
||||
|
||||
if(overload)
|
||||
card->spellTargetType = "";
|
||||
else if(card->model->data->spellTargetType.size())
|
||||
else if(card->model->data->spellTargetType.size())
|
||||
card->spellTargetType = card->model->data->spellTargetType;
|
||||
|
||||
assert(alternateCost);
|
||||
if (alternateCost->isExtraPaymentSet() )
|
||||
{
|
||||
if (!game->targetListIsSet(card))
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
alternateCost->setExtraCostsAction(this, card);
|
||||
@@ -790,9 +790,9 @@ int MTGBuyBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
{
|
||||
Player * player = game->currentlyActing();
|
||||
if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card))
|
||||
return 0;
|
||||
if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
|
||||
return 0;
|
||||
return 0;
|
||||
if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
|
||||
return 0;
|
||||
if(!allowedToCast(card,player))
|
||||
return 0;
|
||||
return MTGAlternativeCostRule::isReactingToClick( card, mana, card->getManaCost()->getBuyback() );
|
||||
@@ -1180,7 +1180,7 @@ int MTGPayZeroRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
return 0;
|
||||
if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
|
||||
return 0;
|
||||
if(card->has(Constants::CANPLAYFROMGRAVEYARD))
|
||||
if(card->has(Constants::CANPLAYFROMGRAVEYARD))
|
||||
CustomName = "Zero Cast From Graveyard";
|
||||
else if(card->has(Constants::CANPLAYFROMEXILE))
|
||||
CustomName = "Zero Cast From Exile";
|
||||
@@ -1225,6 +1225,8 @@ MTGAlternativeCostRule(observer, _id)
|
||||
|
||||
int MTGOverloadRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
{
|
||||
if (card->alias != 110000)
|
||||
return 0;
|
||||
Player * player = game->currentlyActing();
|
||||
ManaCost * cost = NEW ManaCost(card->model->data->getManaCost()->getAlternative());
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
@@ -1234,8 +1236,6 @@ int MTGOverloadRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
|
||||
if (card->isLand())
|
||||
return 0;
|
||||
if (card->alias != 110000)
|
||||
return 0;
|
||||
if (!player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card))
|
||||
return 0;
|
||||
if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
|
||||
@@ -1912,7 +1912,7 @@ MTGStoneHewerRule::MTGStoneHewerRule(GameObserver* observer, int _id, MTGAllCard
|
||||
for (size_t i = 0; i < collection->ids.size(); i++)
|
||||
{
|
||||
MTGCard * card = collection->collection[collection->ids[i]];
|
||||
if (card->data->hasSubtype("equipment") && (card->getRarity() != Constants::RARITY_T) && //remove tokens
|
||||
if (card->data->hasSubtype("equipment") && (card->getRarity() != Constants::RARITY_T) && //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
|
||||
)
|
||||
{
|
||||
@@ -1928,32 +1928,32 @@ MTGStoneHewerRule::MTGStoneHewerRule(GameObserver* observer, int _id, MTGAllCard
|
||||
|
||||
int MTGStoneHewerRule::receiveEvent(WEvent * event)
|
||||
{
|
||||
WEventZoneChange * e = (WEventZoneChange *) event;
|
||||
if (e->to == game->currentlyActing()->game->inPlay && e->card->isCreature())
|
||||
{
|
||||
int eId = genRandomEquipId(e->card->getManaCost()->getConvertedCost());
|
||||
MTGCardInstance * card = genEquip(eId);
|
||||
if(card)
|
||||
{
|
||||
game->currentlyActing()->game->temp->addCard(card);
|
||||
WEventZoneChange * e = (WEventZoneChange *) event;
|
||||
if (e->to == game->currentlyActing()->game->inPlay && e->card->isCreature())
|
||||
{
|
||||
int eId = genRandomEquipId(e->card->getManaCost()->getConvertedCost());
|
||||
MTGCardInstance * card = genEquip(eId);
|
||||
if(card)
|
||||
{
|
||||
game->currentlyActing()->game->temp->addCard(card);
|
||||
Spell * spell = NEW Spell(game, card);
|
||||
spell->resolve();
|
||||
spell->source->isToken = 1;
|
||||
spell->resolve();
|
||||
spell->source->isToken = 1;
|
||||
for (size_t i = 1; i < game->mLayers->actionLayer()->mObjects.size(); i++)
|
||||
{
|
||||
{
|
||||
MTGAbility * a = ((MTGAbility *) game->mLayers->actionLayer()->mObjects[i]);
|
||||
AEquip * eq = dynamic_cast<AEquip*> (a);
|
||||
if (eq && eq->source == spell->source)
|
||||
{
|
||||
((AEquip*)a)->unequip();
|
||||
((AEquip*)a)->equip(e->card);
|
||||
}
|
||||
}
|
||||
SAFE_DELETE(spell);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
AEquip * eq = dynamic_cast<AEquip*> (a);
|
||||
if (eq && eq->source == spell->source)
|
||||
{
|
||||
((AEquip*)a)->unequip();
|
||||
((AEquip*)a)->equip(e->card);
|
||||
}
|
||||
}
|
||||
SAFE_DELETE(spell);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
MTGCardInstance * MTGStoneHewerRule::genEquip(int id)
|
||||
@@ -1967,8 +1967,8 @@ MTGCardInstance * MTGStoneHewerRule::genEquip(int id)
|
||||
|
||||
int MTGStoneHewerRule::genRandomEquipId(int convertedCost)
|
||||
{
|
||||
if (convertedCost >= 20)
|
||||
convertedCost = 19;
|
||||
if (convertedCost >= 20)
|
||||
convertedCost = 19;
|
||||
int total_cards = 0;
|
||||
int i = (game->getRandomGenerator()->random() % int(convertedCost+1));//+1 becuase we want to generate a random "<=" the coverted.
|
||||
while (!total_cards && i >= 0)
|
||||
@@ -2004,29 +2004,29 @@ PermanentAbility(observer, _id)
|
||||
|
||||
int MTGHermitRule::receiveEvent(WEvent * event)
|
||||
{
|
||||
WEventPhaseChange * e = dynamic_cast<WEventPhaseChange*>(event);
|
||||
WEventPhaseChange * e = dynamic_cast<WEventPhaseChange*>(event);
|
||||
if (e && e->from->id == MTG_PHASE_UNTAP)
|
||||
{
|
||||
MTGCardInstance * lcard = NULL;
|
||||
vector<MTGCardInstance*>lands = vector<MTGCardInstance*>();
|
||||
for(int i = 0; i < game->currentPlayer->game->library->nb_cards-1; i++)
|
||||
{
|
||||
MTGCardInstance * temp = game->currentPlayer->game->library->cards[i];
|
||||
if(temp && temp->isLand())
|
||||
lands.push_back(temp);
|
||||
}
|
||||
if(lands.size())
|
||||
{
|
||||
MTGCardInstance * lcard = NULL;
|
||||
vector<MTGCardInstance*>lands = vector<MTGCardInstance*>();
|
||||
for(int i = 0; i < game->currentPlayer->game->library->nb_cards-1; i++)
|
||||
{
|
||||
MTGCardInstance * temp = game->currentPlayer->game->library->cards[i];
|
||||
if(temp && temp->isLand())
|
||||
lands.push_back(temp);
|
||||
}
|
||||
if(lands.size())
|
||||
lcard = lands[game->getRandomGenerator()->random() % lands.size()];
|
||||
if(lcard)
|
||||
{
|
||||
MTGCardInstance * copy = game->currentPlayer->game->putInZone(lcard,game->currentPlayer->game->library, game->currentPlayer->game->temp);
|
||||
if(lcard)
|
||||
{
|
||||
MTGCardInstance * copy = game->currentPlayer->game->putInZone(lcard,game->currentPlayer->game->library, game->currentPlayer->game->temp);
|
||||
Spell * spell = NEW Spell(game, copy);
|
||||
spell->resolve();
|
||||
delete spell;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
MTGHermitRule * MTGHermitRule::clone() const
|
||||
|
||||
@@ -94,7 +94,7 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
|
||||
}
|
||||
|
||||
//switch on the first letter. If two costs share their first letter, add an "if" within the switch
|
||||
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
|
||||
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
|
||||
switch (value[0])
|
||||
{
|
||||
case 'x':
|
||||
@@ -695,7 +695,7 @@ ManaCostHybrid * ManaCost::getHybridCost(unsigned int i)
|
||||
ExtraCost * ManaCost::getExtraCost(unsigned int i)
|
||||
{
|
||||
if(extraCosts && extraCosts->costs.size())
|
||||
{
|
||||
{
|
||||
if (extraCosts->costs.size() <= i)
|
||||
return NULL;
|
||||
return extraCosts->costs[i];
|
||||
@@ -1055,7 +1055,7 @@ ostream& operator<<(ostream& out, ManaCost m)
|
||||
|
||||
void ManaPool::Empty()
|
||||
{
|
||||
SAFE_DELETE(extraCosts);
|
||||
SAFE_DELETE(extraCosts);
|
||||
SAFE_DELETE(kicker);
|
||||
SAFE_DELETE(alternative);
|
||||
SAFE_DELETE(BuyBack);
|
||||
|
||||
@@ -301,12 +301,12 @@ ModRulesRenderCardGuiItem::ModRulesRenderCardGuiItem(string name, int posX, int
|
||||
mFormattedData = formattedData;
|
||||
mFilter = filter;
|
||||
mFontSize = fontSize;
|
||||
mFont = font;
|
||||
mFont = font;
|
||||
mFontColor = fontColor;
|
||||
mSizeIcon = SizeIcon;
|
||||
mIconPosX = IconPosX;
|
||||
mIconPosY = IconPosY;
|
||||
mFileName = FileName;
|
||||
mIconPosX = IconPosX;
|
||||
mIconPosY = IconPosY;
|
||||
mFileName = FileName;
|
||||
|
||||
}
|
||||
|
||||
@@ -318,12 +318,12 @@ void ModRulesCardGui::parse(TiXmlElement* element)
|
||||
string _FormattedText;
|
||||
string _Filter;
|
||||
int _FontSize;
|
||||
bool _Font;
|
||||
PIXEL_TYPE _FontColor;
|
||||
int _SizeIcon;
|
||||
int _IconPosX;
|
||||
int _IconPosY;
|
||||
string _FileName;
|
||||
bool _Font;
|
||||
PIXEL_TYPE _FontColor;
|
||||
int _SizeIcon;
|
||||
int _IconPosX;
|
||||
int _IconPosY;
|
||||
string _FileName;
|
||||
|
||||
|
||||
|
||||
@@ -353,12 +353,12 @@ void ModRulesCardGui::parse(TiXmlElement* element)
|
||||
_FormattedText = "";
|
||||
_Filter = "";
|
||||
_FontSize = 0;
|
||||
_Font = false;
|
||||
_Font = false;
|
||||
_FontColor = 0;
|
||||
_SizeIcon = 0;
|
||||
_IconPosX = 0;
|
||||
_IconPosY = 0 ;
|
||||
_FileName = "";
|
||||
_IconPosX = 0;
|
||||
_IconPosY = 0 ;
|
||||
_FileName = "";
|
||||
|
||||
|
||||
TiXmlElement* ItemElement = node->ToElement();
|
||||
@@ -379,11 +379,11 @@ void ModRulesCardGui::parse(TiXmlElement* element)
|
||||
}
|
||||
|
||||
ChildNode = ItemElement->FirstChild("font");
|
||||
if (ChildNode) {
|
||||
_Font = true;
|
||||
_FontSize = atoi(ChildNode->ToElement()->Attribute("size"));
|
||||
vector<string> argb = split( ChildNode->ToElement()->Attribute("color"), ',');
|
||||
_FontColor = ARGB(
|
||||
if (ChildNode) {
|
||||
_Font = true;
|
||||
_FontSize = atoi(ChildNode->ToElement()->Attribute("size"));
|
||||
vector<string> argb = split( ChildNode->ToElement()->Attribute("color"), ',');
|
||||
_FontColor = ARGB(
|
||||
atoi(argb[0].c_str()),
|
||||
atoi(argb[1].c_str()),
|
||||
atoi(argb[2].c_str()),
|
||||
@@ -392,7 +392,7 @@ void ModRulesCardGui::parse(TiXmlElement* element)
|
||||
|
||||
}
|
||||
ChildNode = ItemElement->FirstChild("iconposition");
|
||||
if (ChildNode) {
|
||||
if (ChildNode) {
|
||||
_IconPosX = atoi(ChildNode->ToElement()->Attribute("x"));
|
||||
_IconPosY = atoi(ChildNode->ToElement()->Attribute("y"));
|
||||
}
|
||||
@@ -408,7 +408,7 @@ void ModRulesCardGui::parse(TiXmlElement* element)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
renderbig.push_back(NEW ModRulesRenderCardGuiItem( _Name, _Posx, _Posy, _FormattedText, _Filter,_Font, _FontSize, _FontColor,_SizeIcon,_IconPosX,_IconPosY,_FileName ));
|
||||
}
|
||||
}
|
||||
@@ -423,12 +423,12 @@ void ModRulesCardGui::parse(TiXmlElement* element)
|
||||
_FormattedText = "";
|
||||
_Filter = "";
|
||||
_FontSize = 0;
|
||||
_Font = false;
|
||||
_Font = false;
|
||||
_FontColor = 0;
|
||||
_SizeIcon = 0;
|
||||
_IconPosX = 0;
|
||||
_IconPosY = 0 ;
|
||||
_FileName = "";
|
||||
_IconPosX = 0;
|
||||
_IconPosY = 0 ;
|
||||
_FileName = "";
|
||||
|
||||
|
||||
TiXmlElement* ItemElement = node->ToElement();
|
||||
@@ -449,11 +449,11 @@ void ModRulesCardGui::parse(TiXmlElement* element)
|
||||
}
|
||||
|
||||
ChildNode = ItemElement->FirstChild("font");
|
||||
if (ChildNode) {
|
||||
_Font = true;
|
||||
_FontSize = atoi(ChildNode->ToElement()->Attribute("size"));
|
||||
vector<string> argb = split( ChildNode->ToElement()->Attribute("color"), ',');
|
||||
_FontColor = ARGB(
|
||||
if (ChildNode) {
|
||||
_Font = true;
|
||||
_FontSize = atoi(ChildNode->ToElement()->Attribute("size"));
|
||||
vector<string> argb = split( ChildNode->ToElement()->Attribute("color"), ',');
|
||||
_FontColor = ARGB(
|
||||
atoi(argb[0].c_str()),
|
||||
atoi(argb[1].c_str()),
|
||||
atoi(argb[2].c_str()),
|
||||
@@ -462,7 +462,7 @@ void ModRulesCardGui::parse(TiXmlElement* element)
|
||||
|
||||
}
|
||||
ChildNode = ItemElement->FirstChild("iconposition");
|
||||
if (ChildNode) {
|
||||
if (ChildNode) {
|
||||
_IconPosX = atoi(ChildNode->ToElement()->Attribute("x"));
|
||||
_IconPosY = atoi(ChildNode->ToElement()->Attribute("y"));
|
||||
}
|
||||
@@ -478,7 +478,7 @@ void ModRulesCardGui::parse(TiXmlElement* element)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
rendertinycrop.push_back(NEW ModRulesRenderCardGuiItem( _Name, _Posx, _Posy, _FormattedText, _Filter,_Font, _FontSize, _FontColor,_SizeIcon,_IconPosX,_IconPosY,_FileName ));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ bool Player::DeadLifeState(bool check)
|
||||
if (cantlosers < 1)
|
||||
{
|
||||
if(!check)
|
||||
{
|
||||
{
|
||||
ActionStack * stack = getObserver()->mLayers->stackLayer();
|
||||
for (int i = stack->mObjects.size() - 1; i >= 0; i--)
|
||||
{
|
||||
@@ -320,7 +320,7 @@ bool Player::parseLine(const string& s)
|
||||
}
|
||||
else if (areaS.compare("mode") == 0)
|
||||
{
|
||||
this->playMode = (Player::Mode)atoi(s.substr(limiter + 1).c_str());
|
||||
this->playMode = (Player::Mode)atoi(s.substr(limiter + 1).c_str());
|
||||
return true;
|
||||
}
|
||||
else if (areaS.compare("avatar") == 0)
|
||||
@@ -406,12 +406,12 @@ ostream& operator<<(ostream& out, const Player& p)
|
||||
{
|
||||
out << "mode=" << p.playMode << endl;
|
||||
out << *(Damageable*)&p;
|
||||
if(p.manaPool)
|
||||
{
|
||||
string manapoolstring = p.manaPool->toString();
|
||||
if(manapoolstring != "")
|
||||
out << "manapool=" << manapoolstring << endl;
|
||||
}
|
||||
if(p.manaPool)
|
||||
{
|
||||
string manapoolstring = p.manaPool->toString();
|
||||
if(manapoolstring != "")
|
||||
out << "manapool=" << manapoolstring << endl;
|
||||
}
|
||||
if(p.mAvatarName != "")
|
||||
out << "avatar=" << p.mAvatarName << endl;
|
||||
if(p.phaseRing != "")
|
||||
|
||||
+10
-10
@@ -18,9 +18,9 @@ vector<Rules *> Rules::RulesList = vector<Rules *>();
|
||||
|
||||
//Sorting by displayName
|
||||
struct RulesMenuCmp{
|
||||
bool operator()(const Rules * a,const Rules * b) const{
|
||||
bool operator()(const Rules * a,const Rules * b) const{
|
||||
return a->displayName < b->displayName;
|
||||
}
|
||||
}
|
||||
} RulesMenuCmp_;
|
||||
|
||||
Rules * Rules::getRulesByFilename(string _filename)
|
||||
@@ -391,12 +391,12 @@ void Rules::initGame(GameObserver *g, bool currentPlayerSet)
|
||||
if(OptionWhosFirst::WHO_O == options[Options::FIRSTPLAYER].number)
|
||||
initState.player = 1;
|
||||
}
|
||||
if(!currentPlayerSet)
|
||||
{
|
||||
g->currentPlayerId = initState.player;
|
||||
}
|
||||
g->currentPlayer = g->players[g->currentPlayerId];
|
||||
g->currentActionPlayer = g->currentPlayer;
|
||||
if(!currentPlayerSet)
|
||||
{
|
||||
g->currentPlayerId = initState.player;
|
||||
}
|
||||
g->currentPlayer = g->players[g->currentPlayerId];
|
||||
g->currentActionPlayer = g->currentPlayer;
|
||||
g->phaseRing->goToPhase(0, g->currentPlayer, false);
|
||||
g->phaseRing->goToPhase(initState.phase, g->currentPlayer);
|
||||
g->setCurrentGamePhase(initState.phase);
|
||||
@@ -623,7 +623,7 @@ GameType Rules::strToGameMode(string s)
|
||||
if (s.compare("random1") == 0) return GAME_TYPE_RANDOM1;
|
||||
if (s.compare("random2") == 0) return GAME_TYPE_RANDOM2;
|
||||
if (s.compare("story") == 0) return GAME_TYPE_STORY;
|
||||
if (s.compare("stonehewer") == 0) return GAME_TYPE_STONEHEWER;
|
||||
if (s.compare("hermit") == 0) return GAME_TYPE_HERMIT;
|
||||
if (s.compare("stonehewer") == 0) return GAME_TYPE_STONEHEWER;
|
||||
if (s.compare("hermit") == 0) return GAME_TYPE_HERMIT;
|
||||
return GAME_TYPE_CLASSIC;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ JGuiObject(id), mX(x), mY(y), parent(_parent), mFontId(fontId)
|
||||
|
||||
mXOffset = mX;
|
||||
|
||||
if (hasFocus)
|
||||
if (hasFocus)
|
||||
{
|
||||
setIsSelectionValid(true);
|
||||
Entering();
|
||||
|
||||
@@ -144,7 +144,7 @@ void SimpleMenu::Render()
|
||||
float scaleFactor = titleFont->GetScale();
|
||||
titleFont->SetScale(SCALE_NORMAL);
|
||||
if ((!title.empty()) && (mWidth < titleFont->GetStringWidth(title.c_str())))
|
||||
mWidth = titleFont->GetStringWidth(title.c_str());
|
||||
mWidth = titleFont->GetStringWidth(title.c_str());
|
||||
titleFont->SetScale(scaleFactor);
|
||||
mWidth += 2 * SimpleMenuConst::kHorizontalMargin;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ SimplePopup::SimplePopup(int id, JGuiListener* listener, const int fontId, const
|
||||
{
|
||||
mX = 19;
|
||||
mY = 66;
|
||||
mWidth = 180.0f;
|
||||
mWidth = 180.0f;
|
||||
mTitle = _title;
|
||||
mMaxLines = 12;
|
||||
|
||||
@@ -41,11 +41,11 @@ void SimplePopup::Render()
|
||||
const float textHeight = mTextFont->GetHeight() * mMaxLines;
|
||||
r->FillRoundRect(mX, mY + 2, mWidth + 11, textHeight - 12, 2.0f, ARGB( 255, 0, 0, 0 ) );
|
||||
|
||||
// currently causes a crash on the PSP when drawing the corners.
|
||||
// TODO: clean up the image ot make it loook cleaner. Find solution to load gfx to not crash PSP
|
||||
// currently causes a crash on the PSP when drawing the corners.
|
||||
// TODO: clean up the image ot make it loook cleaner. Find solution to load gfx to not crash PSP
|
||||
#if 0
|
||||
r->DrawRoundRect(mX, mY + 2, mWidth + 11, textHeight - 12, 2.0f, ARGB( 255, 125, 255, 0) );
|
||||
drawBoundingBox( mX-3, mY, mWidth + 3, textHeight );
|
||||
drawBoundingBox( mX-3, mY, mWidth + 3, textHeight );
|
||||
#endif
|
||||
mTextFont->DrawString(detailedInformation.c_str(), mX + 9 , mY + 10);
|
||||
|
||||
@@ -58,22 +58,22 @@ void SimplePopup::drawBoundingBox( float x, float y, float width, float height )
|
||||
//draw the corners
|
||||
string topCornerImageName = "top_corner.png";
|
||||
string bottomCornerImageName = "bottom_corner.png";
|
||||
string verticalBarImageName = "vert_bar.png";
|
||||
string verticalBarImageName = "vert_bar.png";
|
||||
string horizontalBarImageName = "top_bar.png";
|
||||
|
||||
const float boxWidth = ( width + 15 ) / 3.0f;
|
||||
const float boxHeight = ( height + 15 ) / 3.0f;
|
||||
const float boxWidth = ( width + 15 ) / 3.0f;
|
||||
const float boxHeight = ( height + 15 ) / 3.0f;
|
||||
|
||||
drawHorzPole( horizontalBarImageName, false, false, x, y, boxWidth );
|
||||
drawHorzPole( horizontalBarImageName, false, true, x, y + height, boxWidth );
|
||||
|
||||
drawVertPole( verticalBarImageName, false, false, x, y, boxHeight );
|
||||
drawVertPole( verticalBarImageName, true, false, x + width, y, boxHeight );
|
||||
drawHorzPole( horizontalBarImageName, false, false, x, y, boxWidth );
|
||||
drawHorzPole( horizontalBarImageName, false, true, x, y + height, boxWidth );
|
||||
|
||||
drawVertPole( verticalBarImageName, false, false, x, y, boxHeight );
|
||||
drawVertPole( verticalBarImageName, true, false, x + width, y, boxHeight );
|
||||
|
||||
drawCorner( topCornerImageName, false, false, x, y );
|
||||
drawCorner( topCornerImageName, true, false, x + width, y );
|
||||
drawCorner( bottomCornerImageName, false, false, x, y + height );
|
||||
drawCorner( bottomCornerImageName, true, false, x + width, y + height );
|
||||
drawCorner( topCornerImageName, false, false, x, y );
|
||||
drawCorner( topCornerImageName, true, false, x + width, y );
|
||||
drawCorner( bottomCornerImageName, false, false, x, y + height );
|
||||
drawCorner( bottomCornerImageName, true, false, x + width, y + height );
|
||||
}
|
||||
|
||||
void SimplePopup::Update(DeckMetaData* selectedDeck)
|
||||
@@ -130,52 +130,52 @@ void SimplePopup::Update(float)
|
||||
// drawing routines
|
||||
void SimplePopup::drawCorner(string imageName, bool flipX, bool flipY, float x, float y)
|
||||
{
|
||||
LOG(" Drawing a Corner! ");
|
||||
LOG(" Drawing a Corner! ");
|
||||
JRenderer* r = JRenderer::GetInstance();
|
||||
JQuadPtr horizontalBarImage = WResourceManager::Instance()->RetrieveTempQuad( imageName, TEXTURE_SUB_5551);
|
||||
horizontalBarImage->SetHFlip(flipX);
|
||||
horizontalBarImage->SetVFlip(flipY);
|
||||
horizontalBarImage->SetHFlip(flipX);
|
||||
horizontalBarImage->SetVFlip(flipY);
|
||||
|
||||
r->RenderQuad(horizontalBarImage.get(), x, y);
|
||||
LOG(" Done Drawing a Corner! ");
|
||||
r->RenderQuad(horizontalBarImage.get(), x, y);
|
||||
LOG(" Done Drawing a Corner! ");
|
||||
}
|
||||
|
||||
void SimplePopup::drawHorzPole(string imageName, bool flipX = false, bool flipY = false, float x = 0, float y = 0, float width = SCREEN_WIDTH_F)
|
||||
{
|
||||
LOG(" Drawing a horizontal border! ");
|
||||
LOG(" Drawing a horizontal border! ");
|
||||
JRenderer* r = JRenderer::GetInstance();
|
||||
JQuadPtr horizontalBarImage = WResourceManager::Instance()->RetrieveTempQuad( imageName, TEXTURE_SUB_5551);
|
||||
if ( horizontalBarImage != NULL )
|
||||
{
|
||||
horizontalBarImage->SetHFlip(flipX);
|
||||
horizontalBarImage->SetVFlip(flipY);
|
||||
if ( horizontalBarImage != NULL )
|
||||
{
|
||||
horizontalBarImage->SetHFlip(flipX);
|
||||
horizontalBarImage->SetVFlip(flipY);
|
||||
|
||||
r->RenderQuad(horizontalBarImage.get(), x, y, 0, width);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG ( "ERROR: Error trying to render horizontal edge! ");
|
||||
}
|
||||
LOG(" Done Drawing a horizontal border! ");
|
||||
r->RenderQuad(horizontalBarImage.get(), x, y, 0, width);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG ( "ERROR: Error trying to render horizontal edge! ");
|
||||
}
|
||||
LOG(" Done Drawing a horizontal border! ");
|
||||
}
|
||||
|
||||
void SimplePopup::drawVertPole(string imageName, bool flipX = false, bool flipY = false, float x = 0, float y = 0, float height = SCREEN_HEIGHT_F)
|
||||
{
|
||||
LOG(" Drawing a Vertical border! ");
|
||||
LOG(" Drawing a Vertical border! ");
|
||||
JRenderer* r = JRenderer::GetInstance();
|
||||
JQuadPtr verticalBarImage = WResourceManager::Instance()->RetrieveTempQuad( imageName, TEXTURE_SUB_5551);
|
||||
if ( verticalBarImage != NULL )
|
||||
{
|
||||
verticalBarImage->SetHFlip(flipX);
|
||||
verticalBarImage->SetVFlip(flipY);
|
||||
if ( verticalBarImage != NULL )
|
||||
{
|
||||
verticalBarImage->SetHFlip(flipX);
|
||||
verticalBarImage->SetVFlip(flipY);
|
||||
|
||||
r->RenderQuad(verticalBarImage.get(), x, y, 0, 1.0f, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG ( "ERROR: Error trying to render vertical edge! ");
|
||||
}
|
||||
LOG(" DONE Drawing a horizontal border! ");
|
||||
r->RenderQuad(verticalBarImage.get(), x, y, 0, 1.0f, height);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG ( "ERROR: Error trying to render vertical edge! ");
|
||||
}
|
||||
LOG(" DONE Drawing a horizontal border! ");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1094,13 +1094,13 @@ bool TypeTargetChooser::canTarget(Targetable * target,bool withoutProtections)
|
||||
|
||||
return true;
|
||||
}
|
||||
if(card->getLCName().size())
|
||||
{
|
||||
if(card->getLCName().size())
|
||||
{
|
||||
if (MTGAllCards::findType(card->getLCName()) == types[i])
|
||||
return true;
|
||||
if (MTGAllCards::findType(card->getName()) == types[i])
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ void TestSuiteGame::assertGame()
|
||||
int error = 0;
|
||||
bool wasAI = false;
|
||||
|
||||
if (observer->getCurrentGamePhase() != endState.phase)
|
||||
if (observer->getCurrentGamePhase() != endState.phase)
|
||||
{
|
||||
sprintf(result, "<span class=\"error\">==phase problem. Expected [ %s ](%i), got [ %s ](%i)==</span><br />",
|
||||
Constants::MTGPhaseNames[endState.phase].c_str(),endState.phase,
|
||||
@@ -577,7 +577,7 @@ int TestSuite::loadNext()
|
||||
#elif defined(IOS)
|
||||
thread_count = 6;
|
||||
#else
|
||||
thread_count = 4;
|
||||
thread_count = 4;
|
||||
#endif
|
||||
for(size_t i = 0; i < (thread_count-1); i++)
|
||||
mWorkerThread.push_back(new boost::thread(ThreadProc, this));
|
||||
|
||||
@@ -32,7 +32,7 @@ void TextScroller::setRandom(int mode)
|
||||
void TextScroller::Add(string text)
|
||||
{
|
||||
if (!strings.size())
|
||||
mText = text;
|
||||
mText = text;
|
||||
strings.push_back(text);
|
||||
}
|
||||
|
||||
@@ -67,21 +67,21 @@ void TextScroller::Update(float dt)
|
||||
void TextScroller::Render()
|
||||
{
|
||||
WFont * mFont = WResourceManager::Instance()->GetWFont(fontId);
|
||||
mFont->DrawString(mText.c_str(), mX, mY, JGETEXT_LEFT, start, mWidth);
|
||||
mFont->DrawString(mText.c_str(), mX, mY, JGETEXT_LEFT, start, mWidth);
|
||||
}
|
||||
|
||||
ostream& TextScroller::toString(ostream& out) const
|
||||
{
|
||||
return out << "TextScroller ::: mText : " << mText
|
||||
<< " ; tempText : " << tempText
|
||||
<< " ; mWidth : " << mWidth
|
||||
<< " ; tempText : " << tempText
|
||||
<< " ; mWidth : " << mWidth
|
||||
<< " ; mSpeed : " << mScrollSpeed
|
||||
<< " ; mX,mY : " << mX << "," << mY
|
||||
<< " ; start : " << start
|
||||
<< " ; timer : " << timer
|
||||
<< " ; strings : ?"
|
||||
<< " ; currentId : " << currentId
|
||||
<< " ; mRandom : " << mRandom;
|
||||
<< " ; mX,mY : " << mX << "," << mY
|
||||
<< " ; start : " << start
|
||||
<< " ; timer : " << timer
|
||||
<< " ; strings : ?"
|
||||
<< " ; currentId : " << currentId
|
||||
<< " ; mRandom : " << mRandom;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,28 +93,28 @@ ostream& TextScroller::toString(ostream& out) const
|
||||
VerticalTextScroller::VerticalTextScroller(int fontId, float x, float y, float width, float height, float scrollSpeed, size_t numItemsShown) :
|
||||
TextScroller( fontId, x, y, width, scrollSpeed)
|
||||
{
|
||||
mHeight = height;
|
||||
mNbItemsShown = numItemsShown;
|
||||
mMarginX = 0;
|
||||
timer=0;
|
||||
WFont *mFont = WResourceManager::Instance()->GetWFont(fontId);
|
||||
mOriginalY = mY;
|
||||
mMarginY = mY - mFont->GetHeight();
|
||||
Add("\n"); // initialize the scroller with a blank line
|
||||
mHeight = height;
|
||||
mNbItemsShown = numItemsShown;
|
||||
mMarginX = 0;
|
||||
timer=0;
|
||||
WFont *mFont = WResourceManager::Instance()->GetWFont(fontId);
|
||||
mOriginalY = mY;
|
||||
mMarginY = mY - mFont->GetHeight();
|
||||
Add("\n"); // initialize the scroller with a blank line
|
||||
|
||||
}
|
||||
|
||||
|
||||
void VerticalTextScroller::Add( string text )
|
||||
{
|
||||
strings.push_back( text );
|
||||
string wrappedText = wordWrap(text, mWidth, fontId);
|
||||
mText.append(wrappedText);
|
||||
strings.push_back( text );
|
||||
string wrappedText = wordWrap(text, mWidth, fontId);
|
||||
mText.append(wrappedText);
|
||||
}
|
||||
|
||||
/*
|
||||
Updates happen everytime the top line disappears from view.
|
||||
The top line is then moved to the end of the file and the scrolling resumes where it left off
|
||||
Updates happen everytime the top line disappears from view.
|
||||
The top line is then moved to the end of the file and the scrolling resumes where it left off
|
||||
|
||||
*/
|
||||
void VerticalTextScroller::Update(float dt)
|
||||
@@ -145,5 +145,5 @@ void VerticalTextScroller::Update(float dt)
|
||||
void VerticalTextScroller::Render()
|
||||
{
|
||||
WFont * mFont = WResourceManager::Instance()->GetWFont(fontId);
|
||||
mFont->DrawString(mText.c_str(), mX, mY);
|
||||
mFont->DrawString(mText.c_str(), mX, mY);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ WCachedTexture::WCachedTexture()
|
||||
WCachedTexture::~WCachedTexture()
|
||||
{
|
||||
if (texture)
|
||||
SAFE_DELETE(texture);
|
||||
SAFE_DELETE(texture);
|
||||
}
|
||||
|
||||
JTexture * WCachedTexture::Actual()
|
||||
@@ -113,27 +113,27 @@ JQuadPtr WCachedTexture::GetQuad(float offX, float offY, float width, float heig
|
||||
resource = kPlaceholderID;
|
||||
}
|
||||
|
||||
std::map<string, JQuadPtr>::iterator iter = mTrackedQuads.find(resource);
|
||||
if (iter != mTrackedQuads.end())
|
||||
return iter->second;
|
||||
std::map<string, JQuadPtr>::iterator iter = mTrackedQuads.find(resource);
|
||||
if (iter != mTrackedQuads.end())
|
||||
return iter->second;
|
||||
|
||||
JQuadPtr quad(NEW JQuad(texture, offX, offY, width, height));
|
||||
JQuadPtr quad(NEW JQuad(texture, offX, offY, width, height));
|
||||
|
||||
//Update JQ's values to what we called this with.
|
||||
quad->SetTextureRect(offX, offY, width, height);
|
||||
mTrackedQuads.insert(std::pair<string, JQuadPtr>(resource, quad));
|
||||
mTrackedQuads.insert(std::pair<string, JQuadPtr>(resource, quad));
|
||||
return quad;
|
||||
|
||||
}
|
||||
|
||||
JQuadPtr WCachedTexture::GetQuad(const string& resname)
|
||||
{
|
||||
JQuadPtr result;
|
||||
std::map<string, JQuadPtr>::iterator iter = mTrackedQuads.find(resname);
|
||||
if (iter != mTrackedQuads.end())
|
||||
result = iter->second;
|
||||
JQuadPtr result;
|
||||
std::map<string, JQuadPtr>::iterator iter = mTrackedQuads.find(resname);
|
||||
if (iter != mTrackedQuads.end())
|
||||
result = iter->second;
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
JQuadPtr WCachedTexture::GetCard(float offX, float offY, float width, float height, const string& resname)
|
||||
@@ -192,7 +192,7 @@ bool WCachedTexture::Attempt(const string& filename, int submode, int & error)
|
||||
string realname = filename;
|
||||
|
||||
//Form correct filename.
|
||||
if (submode & TEXTURE_SUB_CARD)
|
||||
if (submode & TEXTURE_SUB_CARD)
|
||||
{
|
||||
if (submode & TEXTURE_SUB_THUMB)
|
||||
{
|
||||
|
||||
@@ -56,13 +56,13 @@ WSrcCards::WSrcCards(float delay)
|
||||
|
||||
JQuadPtr WSrcCards::getImage(int offset)
|
||||
{
|
||||
if (!WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
if (!WResourceManager::Instance()->IsThreaded())
|
||||
{
|
||||
if (mDelay && mLastInput < mDelay)
|
||||
{
|
||||
return WResourceManager::Instance()->RetrieveCard(getCard(offset), RETRIEVE_EXISTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return WResourceManager::Instance()->RetrieveCard(getCard(offset));
|
||||
}
|
||||
|
||||
@@ -359,7 +359,7 @@ int WFBFont::PreCacheChar(const u8 *ch)
|
||||
#else
|
||||
x = (int)mSprites[index]->mX;
|
||||
y = (int)mSprites[index]->mY;
|
||||
mTexture->UpdateBits(x, y, mFontSize, mFontSize, mCharBuffer);
|
||||
mTexture->UpdateBits(x, y, mFontSize, mFontSize, mCharBuffer);
|
||||
#endif
|
||||
return index;
|
||||
}
|
||||
@@ -758,7 +758,7 @@ int WGBKFont::PreCacheChar(const u8 *ch)
|
||||
#else
|
||||
x = (int)mSprites[index]->mX;
|
||||
y = (int)mSprites[index]->mY;
|
||||
mTexture->UpdateBits(x, y, mFontSize, mFontSize, mCharBuffer);
|
||||
mTexture->UpdateBits(x, y, mFontSize, mFontSize, mCharBuffer);
|
||||
#endif
|
||||
return index;
|
||||
}
|
||||
|
||||
@@ -37,18 +37,18 @@ WResourceManager* WResourceManager::sInstance = NULL;
|
||||
|
||||
WResourceManager* WResourceManager::Instance()
|
||||
{
|
||||
if (sInstance == NULL)
|
||||
{
|
||||
sInstance = NEW ResourceManagerImpl;
|
||||
}
|
||||
if (sInstance == NULL)
|
||||
{
|
||||
sInstance = NEW ResourceManagerImpl;
|
||||
}
|
||||
|
||||
return sInstance;
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
void WResourceManager::Terminate()
|
||||
{
|
||||
if (sInstance)
|
||||
SAFE_DELETE(sInstance);
|
||||
if (sInstance)
|
||||
SAFE_DELETE(sInstance);
|
||||
}
|
||||
|
||||
|
||||
@@ -1040,12 +1040,12 @@ cacheItem* WCache<cacheItem, cacheActual>::AttemptNew(const string& filename, in
|
||||
SAFE_DELETE(item);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
DebugTrace("AttemptNew failed to load (not a 404 error). Deleting cache item " << ToHex(item));
|
||||
SAFE_DELETE(item);
|
||||
mError = CACHE_ERROR_BAD;
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -328,13 +328,13 @@ std::string wordWrap(const std::string& sentence, float width, int fontId)
|
||||
string currentSentence = sentence.substr(breakIdx, idx - breakIdx);
|
||||
float stringLength = mFont->GetStringWidth( currentSentence.c_str() );
|
||||
if (stringLength >= width)
|
||||
{
|
||||
{
|
||||
if ( stringLength > width )
|
||||
{
|
||||
while ( sentence[idx-1] != ' ' )
|
||||
idx--;
|
||||
}
|
||||
retVal[idx-1] = '\n';
|
||||
retVal[idx-1] = '\n';
|
||||
breakIdx = idx;
|
||||
numLines++;
|
||||
}
|
||||
@@ -344,12 +344,12 @@ std::string wordWrap(const std::string& sentence, float width, int fontId)
|
||||
string currentSentence = sentence.substr(breakIdx, idx - breakIdx);
|
||||
float stringLength = mFont->GetStringWidth( currentSentence.c_str() );
|
||||
if (stringLength >= width)
|
||||
{
|
||||
{
|
||||
if ( stringLength > width )
|
||||
{
|
||||
while ( sentence[idx-1] != ' ' )
|
||||
idx--;
|
||||
retVal[idx-1] = '\n';
|
||||
retVal[idx-1] = '\n';
|
||||
}
|
||||
numLines++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user