J :
* Fix almost all tests. * This version "nearly" works.
This commit is contained in:
@@ -14,6 +14,7 @@ generic/legendary.txt
|
|||||||
generic/lifelink.txt
|
generic/lifelink.txt
|
||||||
generic/persist.txt
|
generic/persist.txt
|
||||||
generic/persist2.txt
|
generic/persist2.txt
|
||||||
|
generic/phases.txt
|
||||||
generic/rampage.txt
|
generic/rampage.txt
|
||||||
generic/regenerate.txt
|
generic/regenerate.txt
|
||||||
generic/sacrifice.txt
|
generic/sacrifice.txt
|
||||||
@@ -201,4 +202,4 @@ zombify.txt
|
|||||||
#Momir Basic Tests
|
#Momir Basic Tests
|
||||||
########################
|
########################
|
||||||
momir/keldon_warlord.txt
|
momir/keldon_warlord.txt
|
||||||
momir/overcost.txt
|
momir/overcost.txt
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ belligerent hatchling
|
|||||||
next
|
next
|
||||||
#blockers
|
#blockers
|
||||||
next
|
next
|
||||||
|
#first strike
|
||||||
|
next
|
||||||
#damage
|
#damage
|
||||||
next
|
next
|
||||||
#end of combat
|
#end of combat
|
||||||
@@ -27,4 +29,4 @@ inplay:belligerent hatchling
|
|||||||
graveyard:shock
|
graveyard:shock
|
||||||
[PLAYER2]
|
[PLAYER2]
|
||||||
life:15
|
life:15
|
||||||
[END]
|
[END]
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ swamp
|
|||||||
benalish knight
|
benalish knight
|
||||||
benalish knight
|
benalish knight
|
||||||
next
|
next
|
||||||
|
#first strike
|
||||||
|
next
|
||||||
#damage
|
#damage
|
||||||
next
|
next
|
||||||
#end
|
#end
|
||||||
@@ -25,4 +27,4 @@ COMBATEND
|
|||||||
graveyard:grizzly bears
|
graveyard:grizzly bears
|
||||||
[PLAYER2]
|
[PLAYER2]
|
||||||
inplay:plains,mountain,swamp,benalish knight
|
inplay:plains,mountain,swamp,benalish knight
|
||||||
[END]
|
[END]
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ next
|
|||||||
1250
|
1250
|
||||||
next
|
next
|
||||||
next
|
next
|
||||||
|
next
|
||||||
1370
|
1370
|
||||||
[ASSERT]
|
[ASSERT]
|
||||||
COMBATEND
|
COMBATEND
|
||||||
@@ -18,4 +19,4 @@ COMBATEND
|
|||||||
inplay:1370
|
inplay:1370
|
||||||
[PLAYER2]
|
[PLAYER2]
|
||||||
graveyard:1250
|
graveyard:1250
|
||||||
[END]
|
[END]
|
||||||
|
|||||||
@@ -2,20 +2,20 @@
|
|||||||
[INIT]
|
[INIT]
|
||||||
COMBATATTACKERS
|
COMBATATTACKERS
|
||||||
[PLAYER1]
|
[PLAYER1]
|
||||||
inplay:1370
|
inplay:white knight
|
||||||
[PLAYER2]
|
[PLAYER2]
|
||||||
inplay:1290
|
inplay:fire elemental
|
||||||
[DO]
|
[DO]
|
||||||
1370
|
white knight
|
||||||
next
|
next
|
||||||
1290
|
fire elemental
|
||||||
next
|
next
|
||||||
next
|
next
|
||||||
1370
|
fire elemental
|
||||||
[ASSERT]
|
[ASSERT]
|
||||||
COMBATEND
|
COMBATEND
|
||||||
[PLAYER1]
|
[PLAYER1]
|
||||||
graveyard:1370
|
graveyard:white knight
|
||||||
[PLAYER2]
|
[PLAYER2]
|
||||||
inplay:1290
|
inplay:fire elemental
|
||||||
[END]
|
[END]
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ graveyard:Puppeteer
|
|||||||
[PLAYER2]
|
[PLAYER2]
|
||||||
graveyard:Drudge Skeletons
|
graveyard:Drudge Skeletons
|
||||||
inplay:raging goblin
|
inplay:raging goblin
|
||||||
[END]
|
[END]
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Drudge Skeletons
|
|||||||
next
|
next
|
||||||
#blockers order
|
#blockers order
|
||||||
dragon engine
|
dragon engine
|
||||||
dragon engine
|
Drudge Skeletons
|
||||||
next
|
next
|
||||||
#combat damage
|
#combat damage
|
||||||
next
|
next
|
||||||
@@ -27,4 +27,4 @@ graveyard:grizzly bears
|
|||||||
[PLAYER2]
|
[PLAYER2]
|
||||||
graveyard:Drudge Skeletons,raging goblin
|
graveyard:Drudge Skeletons,raging goblin
|
||||||
inplay:dragon engine
|
inplay:dragon engine
|
||||||
[END]
|
[END]
|
||||||
|
|||||||
23
projects/mtg/bin/Res/test/generic/phases.txt
Normal file
23
projects/mtg/bin/Res/test/generic/phases.txt
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#Pass phases
|
||||||
|
[INIT]
|
||||||
|
FIRSTMAIN
|
||||||
|
[PLAYER1]
|
||||||
|
[PLAYER2]
|
||||||
|
[DO]
|
||||||
|
next
|
||||||
|
#combat begin
|
||||||
|
next
|
||||||
|
#attackers
|
||||||
|
next
|
||||||
|
#blockers
|
||||||
|
next
|
||||||
|
#damage
|
||||||
|
next
|
||||||
|
#combat end
|
||||||
|
[ASSERT]
|
||||||
|
COMBATEND
|
||||||
|
[PLAYER1]
|
||||||
|
life:20
|
||||||
|
[PLAYER2]
|
||||||
|
life:20
|
||||||
|
[END]
|
||||||
@@ -19,11 +19,12 @@ class GuiCombat : public GuiLayer
|
|||||||
DamagerDamaged* current;
|
DamagerDamaged* current;
|
||||||
enum { BLK, ATK, OK, NONE } cursor_pos;
|
enum { BLK, ATK, OK, NONE } cursor_pos;
|
||||||
CombatStep step;
|
CombatStep step;
|
||||||
|
void validateDamage();
|
||||||
void addOne(DefenserDamaged* blocker, CombatStep);
|
void addOne(DefenserDamaged* blocker, CombatStep);
|
||||||
void removeOne(DefenserDamaged* blocker, CombatStep);
|
void removeOne(DefenserDamaged* blocker, CombatStep);
|
||||||
void autoaffectDamage(AttackerDamaged* attacker, CombatStep);
|
void autoaffectDamage(AttackerDamaged* attacker, CombatStep);
|
||||||
void remaskBlkViews(AttackerDamaged* before, AttackerDamaged* after);
|
void remaskBlkViews(AttackerDamaged* before, AttackerDamaged* after);
|
||||||
void resolve();
|
int resolve();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GuiCombat(GameObserver* go);
|
GuiCombat(GameObserver* go);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ using std::list;
|
|||||||
|
|
||||||
class Player;
|
class Player;
|
||||||
|
|
||||||
typedef enum { BLOCKERS, ORDER, FIRST_STRIKE, DAMAGE } CombatStep;
|
typedef enum { BLOCKERS, ORDER, FIRST_STRIKE, END_FIRST_STRIKE, DAMAGE, END_DAMAGE } CombatStep;
|
||||||
class Phase{
|
class Phase{
|
||||||
public:
|
public:
|
||||||
int id;
|
int id;
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ struct WEventZoneChange : public WEvent {
|
|||||||
struct WEventDamage : public WEvent {
|
struct WEventDamage : public WEvent {
|
||||||
Damage * damage;
|
Damage * damage;
|
||||||
WEventDamage(Damage * damage);
|
WEventDamage(Damage * damage);
|
||||||
|
virtual std::ostream& toString(std::ostream& out) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WEventPhaseChange : public WEvent {
|
struct WEventPhaseChange : public WEvent {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int NextGamePhase::resolve(){
|
int NextGamePhase::resolve(){
|
||||||
GameObserver::GetInstance()->nextGamePhase();
|
GameObserver::GetInstance()->userRequestNextGamePhase();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,9 @@ void DamagerDamaged::Render(CombatStep mode)
|
|||||||
mFont->SetColor(ARGB(92,255,255,255));
|
mFont->SetColor(ARGB(92,255,255,255));
|
||||||
break;
|
break;
|
||||||
case FIRST_STRIKE :
|
case FIRST_STRIKE :
|
||||||
|
case END_FIRST_STRIKE :
|
||||||
case DAMAGE :
|
case DAMAGE :
|
||||||
|
case END_DAMAGE :
|
||||||
mFont->SetColor(ARGB(255, 255, 64, 0));
|
mFont->SetColor(ARGB(255, 255, 64, 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,8 +124,10 @@ int DuelLayers::receiveEvent(WEvent * e){
|
|||||||
PRINT_IF(WEventCreatureAttacker);
|
PRINT_IF(WEventCreatureAttacker);
|
||||||
PRINT_IF(WEventCreatureBlocker);
|
PRINT_IF(WEventCreatureBlocker);
|
||||||
PRINT_IF(WEventCreatureBlockerRank);
|
PRINT_IF(WEventCreatureBlockerRank);
|
||||||
|
PRINT_IF(WEventCombatStepChange);
|
||||||
PRINT_IF(WEventEngageMana);
|
PRINT_IF(WEventEngageMana);
|
||||||
PRINT_IF(WEventConsumeMana);
|
PRINT_IF(WEventConsumeMana);
|
||||||
|
PRINT_IF(WEventEmptyManaPool);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int used = 0;
|
int used = 0;
|
||||||
|
|||||||
@@ -82,11 +82,11 @@ void GameObserver::nextPlayer(){
|
|||||||
}
|
}
|
||||||
void GameObserver::nextGamePhase(){
|
void GameObserver::nextGamePhase(){
|
||||||
Phase * cPhaseOld = phaseRing->getCurrentPhase();
|
Phase * cPhaseOld = phaseRing->getCurrentPhase();
|
||||||
if (cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS)
|
|
||||||
if (DAMAGE != combatStep) { nextCombatStep(); return; }
|
|
||||||
phaseRing->forward();
|
phaseRing->forward();
|
||||||
Phase * cPhase = phaseRing->getCurrentPhase();
|
Phase * cPhase = phaseRing->getCurrentPhase();
|
||||||
currentGamePhase = cPhase->id;
|
currentGamePhase = cPhase->id;
|
||||||
|
if (Constants::MTG_PHASE_COMBATDAMAGE == currentGamePhase)
|
||||||
|
nextCombatStep();
|
||||||
if (currentPlayer != cPhase->player) nextPlayer();
|
if (currentPlayer != cPhase->player) nextPlayer();
|
||||||
|
|
||||||
|
|
||||||
@@ -99,16 +99,14 @@ void GameObserver::nextGamePhase(){
|
|||||||
return nextGamePhase();
|
return nextGamePhase();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i < 2; i++){
|
for (int i = 0; i < 2; ++i)
|
||||||
players[i]->getManaPool()->init();
|
players[i]->getManaPool()->init();
|
||||||
}
|
|
||||||
|
|
||||||
//After End of turn
|
//After End of turn
|
||||||
if (currentGamePhase == Constants::MTG_PHASE_AFTER_EOT){
|
if (currentGamePhase == Constants::MTG_PHASE_AFTER_EOT){
|
||||||
//Auto Hand cleaning, in case the player didn't do it himself
|
//Auto Hand cleaning, in case the player didn't do it himself
|
||||||
while(currentPlayer->game->hand->nb_cards > 7){
|
while(currentPlayer->game->hand->nb_cards > 7)
|
||||||
currentPlayer->game->putInGraveyard(currentPlayer->game->hand->cards[0]);
|
currentPlayer->game->putInGraveyard(currentPlayer->game->hand->cards[0]);
|
||||||
}
|
|
||||||
mLayers->stackLayer()->garbageCollect(); //clean stack history for this turn;
|
mLayers->stackLayer()->garbageCollect(); //clean stack history for this turn;
|
||||||
mLayers->actionLayer()->Update(0);
|
mLayers->actionLayer()->Update(0);
|
||||||
for (int i=0; i < 2; i++){
|
for (int i=0; i < 2; i++){
|
||||||
@@ -141,26 +139,24 @@ void GameObserver::nextCombatStep()
|
|||||||
{
|
{
|
||||||
switch (combatStep)
|
switch (combatStep)
|
||||||
{
|
{
|
||||||
case BLOCKERS : receiveEvent(NEW WEventCombatStepChange(combatStep = ORDER)); return;
|
case BLOCKERS : receiveEvent(NEW WEventCombatStepChange(combatStep = ORDER)); return;
|
||||||
case ORDER : receiveEvent(NEW WEventCombatStepChange(combatStep = FIRST_STRIKE)); return;
|
case ORDER : receiveEvent(NEW WEventCombatStepChange(combatStep = FIRST_STRIKE)); return;
|
||||||
case FIRST_STRIKE : receiveEvent(NEW WEventCombatStepChange(combatStep = DAMAGE)); return;
|
case FIRST_STRIKE : receiveEvent(NEW WEventCombatStepChange(combatStep = END_FIRST_STRIKE)); return;
|
||||||
case DAMAGE : ; // Nothing : go to next phase
|
case END_FIRST_STRIKE : receiveEvent(NEW WEventCombatStepChange(combatStep = DAMAGE)); return;
|
||||||
|
case DAMAGE : receiveEvent(NEW WEventCombatStepChange(combatStep = END_DAMAGE)); return;
|
||||||
|
case END_DAMAGE : ; // Nothing : go to next phase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameObserver::userRequestNextGamePhase(){
|
void GameObserver::userRequestNextGamePhase(){
|
||||||
if (mLayers->stackLayer()->getNext(NULL,0,NOT_RESOLVED)) return;
|
if (mLayers->stackLayer()->getNext(NULL,0,NOT_RESOLVED)) return;
|
||||||
if (getCurrentTargetChooser()) return;
|
if (getCurrentTargetChooser()) return;
|
||||||
// if (mLayers->combatLayer()->isDisplayed()) return;
|
|
||||||
Phase * cPhaseOld = phaseRing->getCurrentPhase();
|
Phase * cPhaseOld = phaseRing->getCurrentPhase();
|
||||||
|
if (cPhaseOld->id == Constants::MTG_PHASE_COMBATDAMAGE)
|
||||||
|
if (FIRST_STRIKE == combatStep || END_FIRST_STRIKE == combatStep || DAMAGE == combatStep) { nextCombatStep(); return; }
|
||||||
if (cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS)
|
if (cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS)
|
||||||
if (DAMAGE != combatStep) { nextCombatStep(); return; }
|
if (BLOCKERS == combatStep) { nextCombatStep(); return; }
|
||||||
if (cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS ||
|
nextGamePhase();
|
||||||
opponent()->isAI() ||
|
|
||||||
options[GameOptions::phaseInterrupts[currentGamePhase]].number)
|
|
||||||
mLayers->stackLayer()->AddNextGamePhase();
|
|
||||||
else
|
|
||||||
nextGamePhase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int GameObserver::forceShuffleLibraries(){
|
int GameObserver::forceShuffleLibraries(){
|
||||||
@@ -356,11 +352,10 @@ void GameObserver::cardClick (MTGCardInstance * card, Targetable * object){
|
|||||||
}else{
|
}else{
|
||||||
result = targetChooser->toggleTarget(clickedPlayer);
|
result = targetChooser->toggleTarget(clickedPlayer);
|
||||||
}
|
}
|
||||||
if (result == TARGET_OK_FULL){
|
if (result == TARGET_OK_FULL)
|
||||||
card = cardWaitingForTargets;
|
card = cardWaitingForTargets;
|
||||||
}else{
|
else
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (waitForExtraPayment){
|
if (waitForExtraPayment){
|
||||||
@@ -374,6 +369,12 @@ void GameObserver::cardClick (MTGCardInstance * card, Targetable * object){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ORDER == combatStep)
|
||||||
|
{
|
||||||
|
card->defenser->raiseBlockerRankOrder(card);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (card){
|
if (card){
|
||||||
reaction = mLayers->actionLayer()->isReactingToClick(card);
|
reaction = mLayers->actionLayer()->isReactingToClick(card);
|
||||||
if (reaction == -1) mLayers->actionLayer()->reactToClick(card);
|
if (reaction == -1) mLayers->actionLayer()->reactToClick(card);
|
||||||
@@ -468,4 +469,3 @@ int GameObserver::targetListIsSet(MTGCardInstance * card){
|
|||||||
}
|
}
|
||||||
return (targetChooser->targetListSet());
|
return (targetChooser->targetListSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,16 @@ void GuiCombat::remaskBlkViews(AttackerDamaged* before, AttackerDamaged* after)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuiCombat::validateDamage()
|
||||||
|
{
|
||||||
|
switch (step)
|
||||||
|
{
|
||||||
|
case FIRST_STRIKE : resolve(); go->nextCombatStep(); break;
|
||||||
|
case DAMAGE : resolve(); go->userRequestNextGamePhase(); break;
|
||||||
|
default: cout << "COMBAT : Cannot validate damage in this phase" << endl; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GuiCombat::autoaffectDamage(AttackerDamaged* attacker, CombatStep step)
|
void GuiCombat::autoaffectDamage(AttackerDamaged* attacker, CombatStep step)
|
||||||
{
|
{
|
||||||
attacker->clearDamage();
|
attacker->clearDamage();
|
||||||
@@ -115,18 +125,20 @@ bool GuiCombat::CheckUserInput(u32 key)
|
|||||||
{
|
{
|
||||||
case PSP_CTRL_CIRCLE:
|
case PSP_CTRL_CIRCLE:
|
||||||
if (BLK == cursor_pos)
|
if (BLK == cursor_pos)
|
||||||
if (ORDER == step) { activeAtk->card->raiseBlockerRankOrder(active->card); }
|
{
|
||||||
else
|
if (ORDER == step) go->cardClick(active->card); // { activeAtk->card->raiseBlockerRankOrder(active->card); }
|
||||||
{
|
else
|
||||||
signed damage = activeAtk->card->stepPower(step);
|
{
|
||||||
for (vector<DamagerDamaged*>::iterator it = activeAtk->blockers.begin(); *it != active; ++it)
|
signed damage = activeAtk->card->stepPower(step);
|
||||||
damage -= (*it)->sumDamages();
|
for (vector<DamagerDamaged*>::iterator it = activeAtk->blockers.begin(); *it != active; ++it)
|
||||||
signed now = active->sumDamages();
|
damage -= (*it)->sumDamages();
|
||||||
damage -= now;
|
signed now = active->sumDamages();
|
||||||
if (damage > 0) addOne(active, step);
|
damage -= now;
|
||||||
else
|
if (damage > 0) addOne(active, step);
|
||||||
for (now -= active->card->toughness; now >= 0; --now) removeOne(active, step);
|
else
|
||||||
}
|
for (now -= active->card->toughness; now >= 0; --now) removeOne(active, step);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (ATK == cursor_pos)
|
else if (ATK == cursor_pos)
|
||||||
{
|
{
|
||||||
active = activeAtk->blockers.front();
|
active = activeAtk->blockers.front();
|
||||||
@@ -137,10 +149,12 @@ bool GuiCombat::CheckUserInput(u32 key)
|
|||||||
{
|
{
|
||||||
switch (step)
|
switch (step)
|
||||||
{
|
{
|
||||||
case BLOCKERS : assert(false); break; // that should not happen
|
case BLOCKERS : assert(false); break; // that should not happen
|
||||||
case ORDER : go->receiveEvent(NEW WEventCombatStepChange(FIRST_STRIKE)); break;
|
case ORDER : go->userRequestNextGamePhase(); break;
|
||||||
case FIRST_STRIKE : resolve(); go->receiveEvent(NEW WEventCombatStepChange(DAMAGE)); break;
|
case FIRST_STRIKE :
|
||||||
case DAMAGE : resolve(); cursor_pos = NONE; go->userRequestNextGamePhase(); break;
|
case DAMAGE : validateDamage(); break;
|
||||||
|
case END_FIRST_STRIKE :
|
||||||
|
case END_DAMAGE : break; // nothing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -239,13 +253,17 @@ void GuiCombat::Render()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiCombat::resolve()
|
int GuiCombat::resolve() // Returns the number of damage objects dealt this turn.
|
||||||
{
|
{
|
||||||
DamageStack* stack = NEW DamageStack();
|
DamageStack* stack = NEW DamageStack();
|
||||||
for (inner_iterator it = attackers.begin(); it != attackers.end(); ++it)
|
for (inner_iterator it = attackers.begin(); it != attackers.end(); ++it)
|
||||||
{
|
{
|
||||||
if ((*it)->blockers.empty())
|
if ((*it)->blockers.empty())
|
||||||
stack->Add(NEW Damage((*it)->card, go->opponent(), (*it)->card->stepPower(step)));
|
{
|
||||||
|
int dmg = (*it)->card->stepPower(step);
|
||||||
|
if (dmg > 0)
|
||||||
|
stack->Add(NEW Damage((*it)->card, go->opponent(), dmg));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
for (vector<DefenserDamaged*>::iterator q = (*it)->blockers.begin(); q != (*it)->blockers.end(); ++q)
|
for (vector<DefenserDamaged*>::iterator q = (*it)->blockers.begin(); q != (*it)->blockers.end(); ++q)
|
||||||
for (vector<Damage>::iterator d = (*q)->damages.begin(); d != (*q)->damages.end(); ++d)
|
for (vector<Damage>::iterator d = (*q)->damages.begin(); d != (*q)->damages.end(); ++d)
|
||||||
@@ -254,7 +272,9 @@ void GuiCombat::resolve()
|
|||||||
stack->Add(NEW Damage(*d));
|
stack->Add(NEW Damage(*d));
|
||||||
}
|
}
|
||||||
go->mLayers->stackLayer()->Add(stack);
|
go->mLayers->stackLayer()->Add(stack);
|
||||||
go->mLayers->stackLayer()->resolve(); // This will delete the damage stack which will in turn delete the Damage it contains
|
int v = stack->mCount;
|
||||||
|
if (v > 0) go->mLayers->stackLayer()->resolve(); // This will delete the damage stack which will in turn delete the Damage it contains
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GuiCombat::receiveEventPlus(WEvent* e)
|
int GuiCombat::receiveEventPlus(WEvent* e)
|
||||||
@@ -307,9 +327,10 @@ int GuiCombat::receiveEventMinus(WEvent* e)
|
|||||||
if (go->players[0]->game->inPlay == event->from || go->players[1]->game->inPlay == event->from)
|
if (go->players[0]->game->inPlay == event->from || go->players[1]->game->inPlay == event->from)
|
||||||
{
|
{
|
||||||
for (inner_iterator it = attackers.begin(); it != attackers.end(); ++it)
|
for (inner_iterator it = attackers.begin(); it != attackers.end(); ++it)
|
||||||
if ((*it)->card == event->card)
|
if ((*it)->card == event->card->previous)
|
||||||
{
|
{
|
||||||
AttackerDamaged* d = *it;
|
AttackerDamaged* d = *it;
|
||||||
|
if (activeAtk == *it) activeAtk = NULL;
|
||||||
attackers.erase(it);
|
attackers.erase(it);
|
||||||
SAFE_DELETE(d);
|
SAFE_DELETE(d);
|
||||||
return 1;
|
return 1;
|
||||||
@@ -352,8 +373,11 @@ int GuiCombat::receiveEventMinus(WEvent* e)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (dynamic_cast<WEventPhaseChange*>(e))
|
else if (WEventPhaseChange* event = dynamic_cast<WEventPhaseChange*>(e))
|
||||||
step = BLOCKERS;
|
{
|
||||||
|
if (Constants::MTG_PHASE_COMBATDAMAGE == event->to->id) step = BLOCKERS;
|
||||||
|
else cursor_pos = NONE;
|
||||||
|
}
|
||||||
else if (WEventCombatStepChange* event = dynamic_cast<WEventCombatStepChange*>(e))
|
else if (WEventCombatStepChange* event = dynamic_cast<WEventCombatStepChange*>(e))
|
||||||
switch (event->step)
|
switch (event->step)
|
||||||
{
|
{
|
||||||
@@ -379,25 +403,33 @@ int GuiCombat::receiveEventMinus(WEvent* e)
|
|||||||
repos<AttackerDamaged>(attackers.begin(), attackers.end(), 0);
|
repos<AttackerDamaged>(attackers.begin(), attackers.end(), 0);
|
||||||
if (active)
|
if (active)
|
||||||
{
|
{
|
||||||
active->zoom = 2.7; // We know there is at least one, so this cannot be NULL
|
active->zoom = 2.7;
|
||||||
activeAtk = static_cast<AttackerDamaged*>(active);
|
activeAtk = static_cast<AttackerDamaged*>(active);
|
||||||
remaskBlkViews(NULL, static_cast<AttackerDamaged*>(active));
|
remaskBlkViews(NULL, static_cast<AttackerDamaged*>(active));
|
||||||
cursor_pos = ATK;
|
cursor_pos = ATK;
|
||||||
step = ORDER;
|
step = ORDER;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
go->nextCombatStep();
|
go->userRequestNextGamePhase();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
case FIRST_STRIKE:
|
case FIRST_STRIKE:
|
||||||
step = FIRST_STRIKE;
|
step = FIRST_STRIKE;
|
||||||
for (inner_iterator attacker = attackers.begin(); attacker != attackers.end(); ++attacker)
|
for (inner_iterator attacker = attackers.begin(); attacker != attackers.end(); ++attacker)
|
||||||
if ((*attacker)->card->has(Constants::FIRSTSTRIKE) || (*attacker)->card->has(Constants::DOUBLESTRIKE)) goto DAMAGE;
|
if ((*attacker)->card->has(Constants::FIRSTSTRIKE) || (*attacker)->card->has(Constants::DOUBLESTRIKE)) goto DAMAGE;
|
||||||
cout << "FIRST STRIKE" << endl;
|
go->nextCombatStep();
|
||||||
|
break;
|
||||||
|
case END_FIRST_STRIKE:
|
||||||
|
step = END_FIRST_STRIKE;
|
||||||
for (inner_iterator attacker = attackers.begin(); attacker != attackers.end(); ++attacker)
|
for (inner_iterator attacker = attackers.begin(); attacker != attackers.end(); ++attacker)
|
||||||
autoaffectDamage(*attacker, FIRST_STRIKE);
|
autoaffectDamage(*attacker, FIRST_STRIKE);
|
||||||
resolve();
|
if (0 == resolve())
|
||||||
go->nextCombatStep();
|
go->nextCombatStep();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cout << "ASK INTERRUPT" << endl;
|
||||||
|
go->mLayers->stackLayer()->AddNextGamePhase();
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
case DAMAGE: DAMAGE:
|
case DAMAGE: DAMAGE:
|
||||||
step = event->step;
|
step = event->step;
|
||||||
@@ -417,11 +449,11 @@ int GuiCombat::receiveEventMinus(WEvent* e)
|
|||||||
cursor_pos = ATK;
|
cursor_pos = ATK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
go->nextCombatStep();
|
||||||
resolve();
|
return 1;
|
||||||
if (FIRST_STRIKE == step) go->nextCombatStep();
|
case END_DAMAGE:
|
||||||
else go->userRequestNextGamePhase();
|
step = END_DAMAGE;
|
||||||
}
|
if (resolve()) go->userRequestNextGamePhase();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -630,8 +630,10 @@ int MTGCardInstance::stepPower(CombatStep step)
|
|||||||
switch (step)
|
switch (step)
|
||||||
{
|
{
|
||||||
case FIRST_STRIKE :
|
case FIRST_STRIKE :
|
||||||
|
case END_FIRST_STRIKE :
|
||||||
if (has(Constants::FIRSTSTRIKE) || has(Constants::DOUBLESTRIKE)) return MAX(0, power); else return 0;
|
if (has(Constants::FIRSTSTRIKE) || has(Constants::DOUBLESTRIKE)) return MAX(0, power); else return 0;
|
||||||
case DAMAGE :
|
case DAMAGE :
|
||||||
|
case END_DAMAGE :
|
||||||
default :
|
default :
|
||||||
if (has(Constants::FIRSTSTRIKE)) return 0; else return MAX(0, power);
|
if (has(Constants::FIRSTSTRIKE)) return 0; else return MAX(0, power);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,27 +100,15 @@ int TestSuiteAI::Act(float dt){
|
|||||||
humanMode = 1;
|
humanMode = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if (action.compare("next")==0){
|
else if (action.compare("next")==0)
|
||||||
/*
|
|
||||||
if (drl->orderingIsNeeded){
|
|
||||||
drl->blockersOrderingDone();
|
|
||||||
g->userRequestNextGamePhase();
|
g->userRequestNextGamePhase();
|
||||||
}else if (drl->mCount){
|
else if (action.compare("yes")==0)
|
||||||
OutputDebugString("End of combat damage!\n");
|
|
||||||
drl->nextPlayer();
|
|
||||||
g->userRequestNextGamePhase();
|
|
||||||
}else{ */
|
|
||||||
g->userRequestNextGamePhase();
|
|
||||||
/*}
|
|
||||||
*/
|
|
||||||
}else if (action.compare("yes")==0){
|
|
||||||
g->mLayers->stackLayer()->setIsInterrupting(this);
|
g->mLayers->stackLayer()->setIsInterrupting(this);
|
||||||
}else if (action.compare("endinterruption")==0){
|
else if (action.compare("endinterruption")==0)
|
||||||
g->mLayers->stackLayer()->endOfInterruption();
|
g->mLayers->stackLayer()->endOfInterruption();
|
||||||
}else if(action.compare("no")==0){
|
else if(action.compare("no")==0){
|
||||||
if (g->mLayers->stackLayer()->askIfWishesToInterrupt == this){
|
if (g->mLayers->stackLayer()->askIfWishesToInterrupt == this)
|
||||||
g->mLayers->stackLayer()->cancelInterruptOffer();
|
g->mLayers->stackLayer()->cancelInterruptOffer();
|
||||||
}
|
|
||||||
}else if(action.find("choice ")!=string::npos){
|
}else if(action.find("choice ")!=string::npos){
|
||||||
OutputDebugString("TESTSUITE choice !!!\n");
|
OutputDebugString("TESTSUITE choice !!!\n");
|
||||||
int choice = atoi(action.substr(action.find("choice ") + 7).c_str());
|
int choice = atoi(action.substr(action.find("choice ") + 7).c_str());
|
||||||
@@ -144,27 +132,15 @@ int TestSuiteAI::Act(float dt){
|
|||||||
sprintf(buffe, "TESTSUITE CARD ID : %i\n", mtgid);
|
sprintf(buffe, "TESTSUITE CARD ID : %i\n", mtgid);
|
||||||
OutputDebugString(buffe);
|
OutputDebugString(buffe);
|
||||||
Interruptible * toInterrupt = suite->getActionByMTGId(mtgid);
|
Interruptible * toInterrupt = suite->getActionByMTGId(mtgid);
|
||||||
if (toInterrupt){
|
if (toInterrupt)
|
||||||
g->stackObjectClicked(toInterrupt);
|
g->stackObjectClicked(toInterrupt);
|
||||||
}else{
|
else{
|
||||||
MTGCardInstance * card = suite->getCardByMTGId(mtgid);
|
MTGCardInstance * card = suite->getCardByMTGId(mtgid);
|
||||||
if (card) {
|
if (card) {
|
||||||
OutputDebugString("TESTSUITE Clicking ON: ");
|
OutputDebugString("TESTSUITE Clicking ON: ");
|
||||||
OutputDebugString(card->name.c_str());
|
OutputDebugString(card->name.c_str());
|
||||||
OutputDebugString("\n");
|
OutputDebugString("\n");
|
||||||
/*
|
g->cardClick(card,card);
|
||||||
if (drl->mCount){
|
|
||||||
if (drl->orderingIsNeeded){
|
|
||||||
OutputDebugString(" Ordering Card\n");
|
|
||||||
drl->clickReorderBlocker(card);
|
|
||||||
}else{
|
|
||||||
OutputDebugString(" Damaging Card\n");
|
|
||||||
drl->clickDamage(card);
|
|
||||||
}
|
|
||||||
}else{*/
|
|
||||||
g->cardClick(card,card);
|
|
||||||
/* }
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -414,7 +390,9 @@ TestSuite::TestSuite(const char * filename,MTGAllCards* _collection){
|
|||||||
ofstream file2 (RESPATH"/test/results.html");
|
ofstream file2 (RESPATH"/test/results.html");
|
||||||
if (file2){
|
if (file2){
|
||||||
file2 << "<html><head>";
|
file2 << "<html><head>";
|
||||||
|
#ifdef WIN32
|
||||||
file2 << "<meta http-equiv=\"refresh\" content=\"10\" >";
|
file2 << "<meta http-equiv=\"refresh\" content=\"10\" >";
|
||||||
|
#endif
|
||||||
file2 << "<STYLE type='text/css'>";
|
file2 << "<STYLE type='text/css'>";
|
||||||
file2 << ".success {color:green}\n";
|
file2 << ".success {color:green}\n";
|
||||||
file2 << ".error {color:red}\n";
|
file2 << ".error {color:red}\n";
|
||||||
|
|||||||
@@ -34,7 +34,14 @@ std::ostream& WEvent::toString(std::ostream& out) const
|
|||||||
}
|
}
|
||||||
std::ostream& WEventZoneChange::toString(std::ostream& out) const
|
std::ostream& WEventZoneChange::toString(std::ostream& out) const
|
||||||
{
|
{
|
||||||
return out << "EVENT " << *card << " : " << *from << " → " << *to;
|
return out << "ZONEEVENT " << *card << " : " << *from << " -> " << *to;
|
||||||
|
}
|
||||||
|
std::ostream& WEventDamage::toString(std::ostream& out) const
|
||||||
|
{
|
||||||
|
if (MTGCardInstance* m = dynamic_cast<MTGCardInstance*>(damage->target))
|
||||||
|
return out << "DAMAGEEVENT " << damage->damage << " >> " << *m;
|
||||||
|
else
|
||||||
|
return out << "DAMAGEEVENT " << damage->damage << " >> " << damage->target;
|
||||||
}
|
}
|
||||||
std::ostream& operator<<(std::ostream& out, const WEvent& m)
|
std::ostream& operator<<(std::ostream& out, const WEvent& m)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user