Ran VS formatting on this file, as the indentation was all over the place. No actual code changes here.
This commit is contained in:
+190
-190
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
The Action Stack contains all information for Game Events that can be interrupted (Interruptible)
|
The Action Stack contains all information for Game Events that can be interrupted (Interruptible)
|
||||||
*/
|
*/
|
||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
|
|
||||||
#include "ActionStack.h"
|
#include "ActionStack.h"
|
||||||
@@ -18,8 +18,8 @@
|
|||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
NextGamePhase requested by user
|
NextGamePhase requested by user
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int NextGamePhase::resolve()
|
int NextGamePhase::resolve()
|
||||||
{
|
{
|
||||||
@@ -55,7 +55,7 @@ void NextGamePhase::Render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NextGamePhase::NextGamePhase(int id) :
|
NextGamePhase::NextGamePhase(int id) :
|
||||||
Interruptible(id)
|
Interruptible(id)
|
||||||
{
|
{
|
||||||
mHeight = 40;
|
mHeight = 40;
|
||||||
type = ACTION_NEXTGAMEPHASE;
|
type = ACTION_NEXTGAMEPHASE;
|
||||||
@@ -70,11 +70,11 @@ ostream& NextGamePhase::toString(ostream& out) const
|
|||||||
const string Interruptible::getDisplayName() const
|
const string Interruptible::getDisplayName() const
|
||||||
{
|
{
|
||||||
return typeid(*this).name();
|
return typeid(*this).name();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action,
|
void Interruptible::Render(MTGCardInstance * source, JQuad * targetQuad, string alt1, string alt2, string action,
|
||||||
bool bigQuad)
|
bool bigQuad)
|
||||||
{
|
{
|
||||||
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
|
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
|
||||||
mFont->SetColor(ARGB(255,255,255,255));
|
mFont->SetColor(ARGB(255,255,255,255));
|
||||||
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
||||||
@@ -114,15 +114,15 @@ const string Interruptible::getDisplayName() const
|
|||||||
{
|
{
|
||||||
mFont->DrawString(_(alt2).c_str(), x + 120, y);
|
mFont->DrawString(_(alt2).c_str(), x + 120, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ability */
|
/* Ability */
|
||||||
int StackAbility::resolve()
|
int StackAbility::resolve()
|
||||||
{
|
{
|
||||||
return (ability->resolve());
|
return (ability->resolve());
|
||||||
}
|
}
|
||||||
void StackAbility::Render()
|
void StackAbility::Render()
|
||||||
{
|
{
|
||||||
string action = ability->getMenuText();
|
string action = ability->getMenuText();
|
||||||
MTGCardInstance * source = ability->source;
|
MTGCardInstance * source = ability->source;
|
||||||
string alt1 = source->getName();
|
string alt1 = source->getName();
|
||||||
@@ -153,67 +153,67 @@ const string Interruptible::getDisplayName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
Interruptible::Render(source, quad, alt1, alt2, action);
|
Interruptible::Render(source, quad, alt1, alt2, action);
|
||||||
}
|
}
|
||||||
StackAbility::StackAbility(int id, MTGAbility * _ability) :
|
StackAbility::StackAbility(int id, MTGAbility * _ability) :
|
||||||
Interruptible(id), ability(_ability)
|
Interruptible(id), ability(_ability)
|
||||||
{
|
{
|
||||||
type = ACTION_ABILITY;
|
type = ACTION_ABILITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& StackAbility::toString(ostream& out) const
|
ostream& StackAbility::toString(ostream& out) const
|
||||||
{
|
{
|
||||||
out << "StackAbility ::: ability : " << ability;
|
out << "StackAbility ::: ability : " << ability;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string StackAbility::getDisplayName() const
|
const string StackAbility::getDisplayName() const
|
||||||
{
|
{
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
stream << "StackAbility. (Source: " << ability->source->getDisplayName() << ")";
|
stream << "StackAbility. (Source: " << ability->source->getDisplayName() << ")";
|
||||||
|
|
||||||
return stream.str();
|
return stream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Spell Cast */
|
/* Spell Cast */
|
||||||
|
|
||||||
Spell::Spell(MTGCardInstance * _source) :
|
Spell::Spell(MTGCardInstance * _source) :
|
||||||
Interruptible(0)
|
Interruptible(0)
|
||||||
{
|
{
|
||||||
source = _source;
|
source = _source;
|
||||||
mHeight = 40;
|
mHeight = 40;
|
||||||
type = ACTION_SPELL;
|
type = ACTION_SPELL;
|
||||||
cost = NEW ManaCost();
|
cost = NEW ManaCost();
|
||||||
tc = NULL;
|
tc = NULL;
|
||||||
from = _source->getCurrentZone();
|
from = _source->getCurrentZone();
|
||||||
}
|
}
|
||||||
|
|
||||||
Spell::Spell(int id, MTGCardInstance * _source, TargetChooser * tc, ManaCost * _cost, int payResult) :
|
Spell::Spell(int id, MTGCardInstance * _source, TargetChooser * tc, ManaCost * _cost, int payResult) :
|
||||||
Interruptible(id), tc(tc), cost(_cost), payResult(payResult)
|
Interruptible(id), tc(tc), cost(_cost), payResult(payResult)
|
||||||
{
|
{
|
||||||
source = _source;
|
source = _source;
|
||||||
mHeight = 40;
|
mHeight = 40;
|
||||||
type = ACTION_SPELL;
|
type = ACTION_SPELL;
|
||||||
from = _source->getCurrentZone();
|
from = _source->getCurrentZone();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Spell::computeX(MTGCardInstance * card)
|
int Spell::computeX(MTGCardInstance * card)
|
||||||
{
|
{
|
||||||
ManaCost * c = cost->Diff(card->getManaCost());
|
ManaCost * c = cost->Diff(card->getManaCost());
|
||||||
int x = c->getCost(Constants::MTG_NB_COLORS);
|
int x = c->getCost(Constants::MTG_NB_COLORS);
|
||||||
delete c;
|
delete c;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Spell::computeXX(MTGCardInstance * card)
|
int Spell::computeXX(MTGCardInstance * card)
|
||||||
{
|
{
|
||||||
ManaCost * c = cost->Diff(card->getManaCost());
|
ManaCost * c = cost->Diff(card->getManaCost());
|
||||||
int xx = c->getCost(Constants::MTG_NB_COLORS) / 2;
|
int xx = c->getCost(Constants::MTG_NB_COLORS) / 2;
|
||||||
delete c;
|
delete c;
|
||||||
return xx;
|
return xx;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Spell::FullfilledAlternateCost(const int &costType)
|
bool Spell::FullfilledAlternateCost(const int &costType)
|
||||||
{
|
{
|
||||||
bool hasFullfilledAlternateCost = false;
|
bool hasFullfilledAlternateCost = false;
|
||||||
|
|
||||||
switch (costType)
|
switch (costType)
|
||||||
@@ -236,20 +236,20 @@ const string Interruptible::getDisplayName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return hasFullfilledAlternateCost;
|
return hasFullfilledAlternateCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
const string Spell::getDisplayName() const
|
const string Spell::getDisplayName() const
|
||||||
{
|
{
|
||||||
return source->getName();
|
return source->getName();
|
||||||
}
|
}
|
||||||
Spell::~Spell()
|
Spell::~Spell()
|
||||||
{
|
{
|
||||||
SAFE_DELETE(cost);
|
SAFE_DELETE(cost);
|
||||||
SAFE_DELETE(tc);
|
SAFE_DELETE(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Spell::resolve()
|
int Spell::resolve()
|
||||||
{
|
{
|
||||||
GameObserver * game = GameObserver::GetInstance();
|
GameObserver * game = GameObserver::GetInstance();
|
||||||
if (!source->hasType("instant") && !source->hasType("sorcery"))
|
if (!source->hasType("instant") && !source->hasType("sorcery"))
|
||||||
{
|
{
|
||||||
@@ -271,60 +271,60 @@ const string Interruptible::getDisplayName() const
|
|||||||
AbilityFactory af;
|
AbilityFactory af;
|
||||||
af.addAbilities(game->mLayers->actionLayer()->getMaxId(), this);
|
af.addAbilities(game->mLayers->actionLayer()->getMaxId(), this);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MTGCardInstance * Spell::getNextCardTarget(MTGCardInstance * previous)
|
MTGCardInstance * Spell::getNextCardTarget(MTGCardInstance * previous)
|
||||||
{
|
{
|
||||||
if (!tc)
|
if (!tc)
|
||||||
return NULL;
|
return NULL;
|
||||||
return tc->getNextCardTarget(previous);
|
return tc->getNextCardTarget(previous);
|
||||||
}
|
}
|
||||||
Player * Spell::getNextPlayerTarget(Player * previous)
|
Player * Spell::getNextPlayerTarget(Player * previous)
|
||||||
{
|
{
|
||||||
if (!tc)
|
if (!tc)
|
||||||
return NULL;
|
return NULL;
|
||||||
return tc->getNextPlayerTarget(previous);
|
return tc->getNextPlayerTarget(previous);
|
||||||
}
|
}
|
||||||
Damageable * Spell::getNextDamageableTarget(Damageable * previous)
|
Damageable * Spell::getNextDamageableTarget(Damageable * previous)
|
||||||
{
|
{
|
||||||
if (!tc)
|
if (!tc)
|
||||||
return NULL;
|
return NULL;
|
||||||
return tc->getNextDamageableTarget(previous);
|
return tc->getNextDamageableTarget(previous);
|
||||||
}
|
}
|
||||||
Interruptible * Spell::getNextInterruptible(Interruptible * previous, int type)
|
Interruptible * Spell::getNextInterruptible(Interruptible * previous, int type)
|
||||||
{
|
{
|
||||||
if (!tc)
|
if (!tc)
|
||||||
return NULL;
|
return NULL;
|
||||||
return tc->getNextInterruptible(previous, type);
|
return tc->getNextInterruptible(previous, type);
|
||||||
}
|
}
|
||||||
Spell * Spell::getNextSpellTarget(Spell * previous)
|
Spell * Spell::getNextSpellTarget(Spell * previous)
|
||||||
{
|
{
|
||||||
if (!tc)
|
if (!tc)
|
||||||
return NULL;
|
return NULL;
|
||||||
return tc->getNextSpellTarget(previous);
|
return tc->getNextSpellTarget(previous);
|
||||||
}
|
}
|
||||||
Damage * Spell::getNextDamageTarget(Damage * previous)
|
Damage * Spell::getNextDamageTarget(Damage * previous)
|
||||||
{
|
{
|
||||||
if (!tc)
|
if (!tc)
|
||||||
return NULL;
|
return NULL;
|
||||||
return tc->getNextDamageTarget(previous);
|
return tc->getNextDamageTarget(previous);
|
||||||
}
|
}
|
||||||
Targetable * Spell::getNextTarget(Targetable * previous, int type)
|
Targetable * Spell::getNextTarget(Targetable * previous, int type)
|
||||||
{
|
{
|
||||||
if (!tc)
|
if (!tc)
|
||||||
return NULL;
|
return NULL;
|
||||||
return tc->getNextTarget(previous, type);
|
return tc->getNextTarget(previous, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Spell::getNbTargets()
|
int Spell::getNbTargets()
|
||||||
{
|
{
|
||||||
if (!tc)
|
if (!tc)
|
||||||
return 0;
|
return 0;
|
||||||
return tc->cursor;
|
return tc->cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Spell::Render()
|
void Spell::Render()
|
||||||
{
|
{
|
||||||
string action = source->getName();
|
string action = source->getName();
|
||||||
string alt1 = "";
|
string alt1 = "";
|
||||||
|
|
||||||
@@ -340,26 +340,26 @@ const string Interruptible::getDisplayName() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Interruptible::Render(source, quad, alt1, alt2, action, true);
|
Interruptible::Render(source, quad, alt1, alt2, action, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& Spell::toString(ostream& out) const
|
ostream& Spell::toString(ostream& out) const
|
||||||
{
|
{
|
||||||
out << "Spell ::: cost : " << cost;
|
out << "Spell ::: cost : " << cost;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Put a card in graveyard */
|
/* Put a card in graveyard */
|
||||||
|
|
||||||
PutInGraveyard::PutInGraveyard(int id, MTGCardInstance * _card) :
|
PutInGraveyard::PutInGraveyard(int id, MTGCardInstance * _card) :
|
||||||
Interruptible(id)
|
Interruptible(id)
|
||||||
{
|
{
|
||||||
card = _card;
|
card = _card;
|
||||||
removeFromGame = 0;
|
removeFromGame = 0;
|
||||||
type = ACTION_PUTINGRAVEYARD;
|
type = ACTION_PUTINGRAVEYARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PutInGraveyard::resolve()
|
int PutInGraveyard::resolve()
|
||||||
{
|
{
|
||||||
GameObserver * g = GameObserver::GetInstance();
|
GameObserver * g = GameObserver::GetInstance();
|
||||||
MTGGameZone * zone = card->getCurrentZone();
|
MTGGameZone * zone = card->getCurrentZone();
|
||||||
if (zone == g->players[0]->game->inPlay || zone == g->players[1]->game->inPlay)
|
if (zone == g->players[0]->game->inPlay || zone == g->players[1]->game->inPlay)
|
||||||
@@ -368,10 +368,10 @@ const string Interruptible::getDisplayName() const
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PutInGraveyard::Render()
|
void PutInGraveyard::Render()
|
||||||
{
|
{
|
||||||
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
|
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
|
||||||
mFont->SetBase(0);
|
mFont->SetBase(0);
|
||||||
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
||||||
@@ -395,31 +395,31 @@ const string Interruptible::getDisplayName() const
|
|||||||
{
|
{
|
||||||
mFont->DrawString(_(card->name).c_str(), x, y - 15);
|
mFont->DrawString(_(card->name).c_str(), x, y - 15);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& PutInGraveyard::toString(ostream& out) const
|
ostream& PutInGraveyard::toString(ostream& out) const
|
||||||
{
|
{
|
||||||
out << "PutInGraveyard ::: removeFromGame : " << removeFromGame;
|
out << "PutInGraveyard ::: removeFromGame : " << removeFromGame;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw a Card */
|
/* Draw a Card */
|
||||||
DrawAction::DrawAction(int id, Player * _player, int _nbcards) :
|
DrawAction::DrawAction(int id, Player * _player, int _nbcards) :
|
||||||
Interruptible(id), nbcards(_nbcards), player(_player)
|
Interruptible(id), nbcards(_nbcards), player(_player)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int DrawAction::resolve()
|
int DrawAction::resolve()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < nbcards; i++)
|
for (int i = 0; i < nbcards; i++)
|
||||||
{
|
{
|
||||||
player->game->drawFromLibrary();
|
player->game->drawFromLibrary();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawAction::Render()
|
void DrawAction::Render()
|
||||||
{
|
{
|
||||||
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
|
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAIN_FONT);
|
||||||
mFont->SetBase(0);
|
mFont->SetBase(0);
|
||||||
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
||||||
@@ -429,51 +429,51 @@ const string Interruptible::getDisplayName() const
|
|||||||
playerId = 2;
|
playerId = 2;
|
||||||
sprintf(buffer, _("Player %i draws %i card").c_str(), playerId, nbcards);
|
sprintf(buffer, _("Player %i draws %i card").c_str(), playerId, nbcards);
|
||||||
mFont->DrawString(buffer, x + 20, y, JGETEXT_LEFT);
|
mFont->DrawString(buffer, x + 20, y, JGETEXT_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
ostream& DrawAction::toString(ostream& out) const
|
ostream& DrawAction::toString(ostream& out) const
|
||||||
{
|
{
|
||||||
out << "DrawAction ::: nbcards : " << nbcards << " ; player : " << player;
|
out << "DrawAction ::: nbcards : " << nbcards << " ; player : " << player;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The Action Stack itself */
|
/* The Action Stack itself */
|
||||||
int ActionStack::addPutInGraveyard(MTGCardInstance * card)
|
int ActionStack::addPutInGraveyard(MTGCardInstance * card)
|
||||||
{
|
{
|
||||||
PutInGraveyard * death = NEW PutInGraveyard(mCount, card);
|
PutInGraveyard * death = NEW PutInGraveyard(mCount, card);
|
||||||
addAction(death);
|
addAction(death);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionStack::addAbility(MTGAbility * ability)
|
int ActionStack::addAbility(MTGAbility * ability)
|
||||||
{
|
{
|
||||||
StackAbility * stackAbility = NEW StackAbility(mCount, ability);
|
StackAbility * stackAbility = NEW StackAbility(mCount, ability);
|
||||||
int result = addAction(stackAbility);
|
int result = addAction(stackAbility);
|
||||||
if (!game->players[0]->isAI() && ability->source->controller() == game->players[0] && 0
|
if (!game->players[0]->isAI() && ability->source->controller() == game->players[0] && 0
|
||||||
== options[Options::INTERRUPTMYABILITIES].number)
|
== options[Options::INTERRUPTMYABILITIES].number)
|
||||||
interruptDecision[0] = DONT_INTERRUPT;
|
interruptDecision[0] = DONT_INTERRUPT;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionStack::addDraw(Player * player, int nb_cards)
|
int ActionStack::addDraw(Player * player, int nb_cards)
|
||||||
{
|
{
|
||||||
DrawAction * draw = NEW DrawAction(mCount, player, nb_cards);
|
DrawAction * draw = NEW DrawAction(mCount, player, nb_cards);
|
||||||
addAction(draw);
|
addAction(draw);
|
||||||
GameObserver *g = GameObserver::GetInstance();
|
GameObserver *g = GameObserver::GetInstance();
|
||||||
WEvent * e = NEW WEventcardDraw(player, nb_cards);
|
WEvent * e = NEW WEventcardDraw(player, nb_cards);
|
||||||
g->receiveEvent(e);
|
g->receiveEvent(e);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionStack::addDamage(MTGCardInstance * _source, Damageable * _target, int _damage)
|
int ActionStack::addDamage(MTGCardInstance * _source, Damageable * _target, int _damage)
|
||||||
{
|
{
|
||||||
Damage * damage = NEW Damage(_source, _target, _damage);
|
Damage * damage = NEW Damage(_source, _target, _damage);
|
||||||
addAction(damage);
|
addAction(damage);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionStack::AddNextGamePhase()
|
int ActionStack::AddNextGamePhase()
|
||||||
{
|
{
|
||||||
if (getNext(NULL, NOT_RESOLVED))
|
if (getNext(NULL, NOT_RESOLVED))
|
||||||
return 0;
|
return 0;
|
||||||
NextGamePhase * next = NEW NextGamePhase(mCount);
|
NextGamePhase * next = NEW NextGamePhase(mCount);
|
||||||
@@ -486,19 +486,19 @@ const string Interruptible::getDisplayName() const
|
|||||||
}
|
}
|
||||||
interruptDecision[playerId] = 1;
|
interruptDecision[playerId] = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionStack::AddNextCombatStep()
|
int ActionStack::AddNextCombatStep()
|
||||||
{
|
{
|
||||||
if (getNext(NULL, NOT_RESOLVED))
|
if (getNext(NULL, NOT_RESOLVED))
|
||||||
return 0;
|
return 0;
|
||||||
NextGamePhase * next = NEW NextGamePhase(mCount);
|
NextGamePhase * next = NEW NextGamePhase(mCount);
|
||||||
addAction(next);
|
addAction(next);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionStack::setIsInterrupting(Player * player)
|
int ActionStack::setIsInterrupting(Player * player)
|
||||||
{
|
{
|
||||||
if (player == game->players[0])
|
if (player == game->players[0])
|
||||||
{
|
{
|
||||||
interruptDecision[0] = -1;
|
interruptDecision[0] = -1;
|
||||||
@@ -510,10 +510,10 @@ const string Interruptible::getDisplayName() const
|
|||||||
game->isInterrupting = player;
|
game->isInterrupting = player;
|
||||||
askIfWishesToInterrupt = NULL;
|
askIfWishesToInterrupt = NULL;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionStack::addAction(Interruptible * action)
|
int ActionStack::addAction(Interruptible * action)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
interruptDecision[i] = 0;
|
interruptDecision[i] = 0;
|
||||||
@@ -522,11 +522,11 @@ const string Interruptible::getDisplayName() const
|
|||||||
DebugTrace("Action added to stack: " << action->getDisplayName());
|
DebugTrace("Action added to stack: " << action->getDisplayName());
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Spell * ActionStack::addSpell(MTGCardInstance * _source, TargetChooser * tc, ManaCost * mana, int payResult,
|
Spell * ActionStack::addSpell(MTGCardInstance * _source, TargetChooser * tc, ManaCost * mana, int payResult,
|
||||||
int storm)
|
int storm)
|
||||||
{
|
{
|
||||||
DebugTrace("ACTIONSTACK Add spell");
|
DebugTrace("ACTIONSTACK Add spell");
|
||||||
if (storm > 0)
|
if (storm > 0)
|
||||||
{
|
{
|
||||||
@@ -542,20 +542,20 @@ const string Interruptible::getDisplayName() const
|
|||||||
== options[Options::INTERRUPTMYSPELLS].number)
|
== options[Options::INTERRUPTMYSPELLS].number)
|
||||||
interruptDecision[0] = DONT_INTERRUPT;
|
interruptDecision[0] = DONT_INTERRUPT;
|
||||||
return spell;
|
return spell;
|
||||||
}
|
}
|
||||||
|
|
||||||
Interruptible * ActionStack::getAt(int id)
|
Interruptible * ActionStack::getAt(int id)
|
||||||
{
|
{
|
||||||
if (id < 0)
|
if (id < 0)
|
||||||
id = mCount + id;
|
id = mCount + id;
|
||||||
if (id > mCount - 1)
|
if (id > mCount - 1)
|
||||||
return NULL;
|
return NULL;
|
||||||
return (Interruptible *) mObjects[id];
|
return (Interruptible *) mObjects[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionStack::ActionStack(GameObserver* game) :
|
ActionStack::ActionStack(GameObserver* game) :
|
||||||
game(game)
|
game(game)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
interruptDecision[i] = 0;
|
interruptDecision[i] = 0;
|
||||||
askIfWishesToInterrupt = NULL;
|
askIfWishesToInterrupt = NULL;
|
||||||
@@ -564,10 +564,10 @@ const string Interruptible::getDisplayName() const
|
|||||||
mode = ACTIONSTACK_STANDARD;
|
mode = ACTIONSTACK_STANDARD;
|
||||||
checked = 0;
|
checked = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionStack::has(MTGAbility * ability)
|
int ActionStack::has(MTGAbility * ability)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mCount; i++)
|
for (int i = 0; i < mCount; i++)
|
||||||
{
|
{
|
||||||
if (((Interruptible *) mObjects[i])->type == ACTION_ABILITY)
|
if (((Interruptible *) mObjects[i])->type == ACTION_ABILITY)
|
||||||
@@ -578,20 +578,20 @@ const string Interruptible::getDisplayName() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionStack::has(Interruptible * action)
|
int ActionStack::has(Interruptible * action)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mCount; i++)
|
for (int i = 0; i < mCount; i++)
|
||||||
{
|
{
|
||||||
if (mObjects[i] == action)
|
if (mObjects[i] == action)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionStack::resolve()
|
int ActionStack::resolve()
|
||||||
{
|
{
|
||||||
Interruptible * action = getLatest(NOT_RESOLVED);
|
Interruptible * action = getLatest(NOT_RESOLVED);
|
||||||
|
|
||||||
if (!action)
|
if (!action)
|
||||||
@@ -627,18 +627,18 @@ const string Interruptible::getDisplayName() const
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Interruptible * ActionStack::getPrevious(Interruptible * next, int type, int state, int display)
|
Interruptible * ActionStack::getPrevious(Interruptible * next, int type, int state, int display)
|
||||||
{
|
{
|
||||||
int n = getPreviousIndex(next, type, state, display);
|
int n = getPreviousIndex(next, type, state, display);
|
||||||
if (n == -1)
|
if (n == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
return ((Interruptible *) mObjects[n]);
|
return ((Interruptible *) mObjects[n]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionStack::getPreviousIndex(Interruptible * next, int type, int state, int display)
|
int ActionStack::getPreviousIndex(Interruptible * next, int type, int state, int display)
|
||||||
{
|
{
|
||||||
int found = 0;
|
int found = 0;
|
||||||
if (!next)
|
if (!next)
|
||||||
found = 1;
|
found = 1;
|
||||||
@@ -656,10 +656,10 @@ const string Interruptible::getDisplayName() const
|
|||||||
if (!found)
|
if (!found)
|
||||||
return getPreviousIndex(NULL, type, state, display);
|
return getPreviousIndex(NULL, type, state, display);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionStack::count(int type, int state, int display)
|
int ActionStack::count(int type, int state, int display)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for (int i = 0; i < mCount; i++)
|
for (int i = 0; i < mCount; i++)
|
||||||
{
|
{
|
||||||
@@ -671,18 +671,18 @@ const string Interruptible::getDisplayName() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Interruptible * ActionStack::getNext(Interruptible * previous, int type, int state, int display)
|
Interruptible * ActionStack::getNext(Interruptible * previous, int type, int state, int display)
|
||||||
{
|
{
|
||||||
int n = getNextIndex(previous, type, state, display);
|
int n = getNextIndex(previous, type, state, display);
|
||||||
if (n == -1)
|
if (n == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
return ((Interruptible *) mObjects[n]);
|
return ((Interruptible *) mObjects[n]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionStack::getNextIndex(Interruptible * previous, int type, int state, int display)
|
int ActionStack::getNextIndex(Interruptible * previous, int type, int state, int display)
|
||||||
{
|
{
|
||||||
int found = 0;
|
int found = 0;
|
||||||
if (!previous)
|
if (!previous)
|
||||||
found = 1;
|
found = 1;
|
||||||
@@ -700,10 +700,10 @@ const string Interruptible::getDisplayName() const
|
|||||||
if (!found)
|
if (!found)
|
||||||
return getNextIndex(NULL, type, state, display);
|
return getNextIndex(NULL, type, state, display);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Interruptible * ActionStack::getLatest(int state)
|
Interruptible * ActionStack::getLatest(int state)
|
||||||
{
|
{
|
||||||
for (int i = mCount - 1; i >= 0; i--)
|
for (int i = mCount - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
Interruptible * action = ((Interruptible *) mObjects[i]);
|
Interruptible * action = ((Interruptible *) mObjects[i]);
|
||||||
@@ -711,10 +711,10 @@ const string Interruptible::getDisplayName() const
|
|||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ActionStack::receiveEventPlus(WEvent * event)
|
int ActionStack::receiveEventPlus(WEvent * event)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for (int i = 0; i < mCount; ++i)
|
for (int i = 0; i < mCount; ++i)
|
||||||
{
|
{
|
||||||
@@ -722,10 +722,10 @@ const string Interruptible::getDisplayName() const
|
|||||||
result += current->receiveEvent(event);
|
result += current->receiveEvent(event);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionStack::Update(float dt)
|
void ActionStack::Update(float dt)
|
||||||
{
|
{
|
||||||
askIfWishesToInterrupt = NULL;
|
askIfWishesToInterrupt = NULL;
|
||||||
//modal = 0;
|
//modal = 0;
|
||||||
GameObserver * game = GameObserver::GetInstance();
|
GameObserver * game = GameObserver::GetInstance();
|
||||||
@@ -827,10 +827,10 @@ const string Interruptible::getDisplayName() const
|
|||||||
cancelInterruptOffer();
|
cancelInterruptOffer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionStack::cancelInterruptOffer(int cancelMode)
|
void ActionStack::cancelInterruptOffer(int cancelMode)
|
||||||
{
|
{
|
||||||
if (game->isInterrupting == game->players[0])
|
if (game->isInterrupting == game->players[0])
|
||||||
{
|
{
|
||||||
interruptDecision[0] = cancelMode;
|
interruptDecision[0] = cancelMode;
|
||||||
@@ -842,10 +842,10 @@ const string Interruptible::getDisplayName() const
|
|||||||
askIfWishesToInterrupt = NULL;
|
askIfWishesToInterrupt = NULL;
|
||||||
game->isInterrupting = NULL;
|
game->isInterrupting = NULL;
|
||||||
timer = -1;
|
timer = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionStack::endOfInterruption()
|
void ActionStack::endOfInterruption()
|
||||||
{
|
{
|
||||||
if (game->isInterrupting == game->players[0])
|
if (game->isInterrupting == game->players[0])
|
||||||
{
|
{
|
||||||
interruptDecision[0] = 0;
|
interruptDecision[0] = 0;
|
||||||
@@ -855,10 +855,10 @@ const string Interruptible::getDisplayName() const
|
|||||||
interruptDecision[1] = 0;
|
interruptDecision[1] = 0;
|
||||||
}
|
}
|
||||||
game->isInterrupting = NULL;
|
game->isInterrupting = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ActionStack::CheckUserInput(JButton key)
|
bool ActionStack::CheckUserInput(JButton key)
|
||||||
{
|
{
|
||||||
JButton trigger = (options[Options::REVERSETRIGGERS].number ? JGE_BTN_NEXT : JGE_BTN_PREV);
|
JButton trigger = (options[Options::REVERSETRIGGERS].number ? JGE_BTN_NEXT : JGE_BTN_PREV);
|
||||||
if (mode == ACTIONSTACK_STANDARD)
|
if (mode == ACTIONSTACK_STANDARD)
|
||||||
{
|
{
|
||||||
@@ -903,7 +903,7 @@ const string Interruptible::getDisplayName() const
|
|||||||
{
|
{
|
||||||
mCurr = n;
|
mCurr = n;
|
||||||
mObjects[mCurr]->Entering();
|
mObjects[mCurr]->Entering();
|
||||||
DebugTrace ("ACTIONSTACK UP TO mCurr = " << mCurr);
|
DebugTrace ("ACTIONSTACK UP TO mCurr = " << mCurr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -939,9 +939,9 @@ DebugTrace ("ACTIONSTACK UP TO mCurr = " << m
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Cleans history of last turn
|
//Cleans history of last turn
|
||||||
int ActionStack::garbageCollect()
|
int ActionStack::garbageCollect()
|
||||||
{
|
{
|
||||||
std::vector<JGuiObject *>::iterator iter = mObjects.begin();
|
std::vector<JGuiObject *>::iterator iter = mObjects.begin();
|
||||||
|
|||||||
Reference in New Issue
Block a user