J :
* New interface. * This breaks a lot of things. It is not feature-equivalent. It probably doesn't compile under windows and doesn't work on PSP. * Damage is not resolved any more. This will have to be fixed. * Blockers can't be ordered any more. This will have to be fixed. * A lot of new art is included.
This commit is contained in:
@@ -1,65 +1,146 @@
|
||||
#include "../include/config.h"
|
||||
#include "../include/DuelLayers.h"
|
||||
#include "../include/MTGRules.h"
|
||||
#include "../include/DamageResolverLayer.h"
|
||||
#include "../include/GuiCombat.h"
|
||||
#include "../include/GuiBackground.h"
|
||||
#include "../include/GuiFrame.h"
|
||||
#include "../include/GuiPhaseBar.h"
|
||||
|
||||
#include "../include/GuiAvatars.h"
|
||||
#include "../include/GuiHand.h"
|
||||
#include "../include/GuiPlay.h"
|
||||
#include "../include/GuiMana.h"
|
||||
|
||||
void DuelLayers::init(){
|
||||
|
||||
GameObserver* go = GameObserver::GetInstance();
|
||||
|
||||
//0 Stack Layer
|
||||
ActionStack * mActionStack = NEW ActionStack(0, GameObserver::GetInstance());
|
||||
|
||||
//Damage Resolver
|
||||
DamageResolverLayer * mDamageResolver = NEW DamageResolverLayer(1, GameObserver::GetInstance());
|
||||
|
||||
cs = NEW CardSelector(this);
|
||||
//1 Action Layer
|
||||
GuiLayer * actionLayer = NEW ActionLayer(2, GameObserver::GetInstance());
|
||||
MTGGamePhase * phaseManager = NEW MTGGamePhase(actionLayer->getMaxId());
|
||||
actionLayer->Add(phaseManager);
|
||||
action = NEW ActionLayer();
|
||||
action->Add(NEW MTGGamePhase(action->getMaxId()));
|
||||
//Add Magic Specific Rules
|
||||
actionLayer->Add(NEW MTGPutInPlayRule(-1));
|
||||
actionLayer->Add(NEW MTGAttackRule(-1));
|
||||
actionLayer->Add(NEW MTGBlockRule(-1));
|
||||
actionLayer->Add(NEW MTGLegendRule(-1));
|
||||
actionLayer->Add(NEW MTGPersistRule(-1));
|
||||
actionLayer->Add(NEW MTGLifelinkRule(-1));
|
||||
action->Add(NEW MTGPutInPlayRule(-1));
|
||||
action->Add(NEW MTGAttackRule(-1));
|
||||
action->Add(NEW MTGBlockRule(-1));
|
||||
action->Add(NEW MTGLegendRule(-1));
|
||||
action->Add(NEW MTGPersistRule(-1));
|
||||
action->Add(NEW MTGLifelinkRule(-1));
|
||||
//Other display elements
|
||||
actionLayer->Add(NEW HUDDisplay(-1));
|
||||
action->Add(NEW HUDDisplay(-1));
|
||||
|
||||
//2 Hand Layer
|
||||
MTGGuiHand * mGuiHand = NEW MTGGuiHand(3, GameObserver::GetInstance());
|
||||
Add(NEW GuiMana());
|
||||
Add(stack = NEW ActionStack(go));
|
||||
Add(combat = NEW GuiCombat(cs));
|
||||
Add(action);
|
||||
Add(cs);
|
||||
Add(hand = NEW GuiHandSelf(cs, go->players[0]->game->hand));
|
||||
Add(NEW GuiHandOpponent(cs, go->players[1]->game->hand));
|
||||
Add(NEW GuiPlay(go, cs));
|
||||
|
||||
//3 Game
|
||||
MTGGuiPlay * play = NEW MTGGuiPlay(4, GameObserver::GetInstance());
|
||||
|
||||
//Add(NEW GuiPhaseBar(GameObserver::GetInstance()));
|
||||
Add(mActionStack);
|
||||
Add(mDamageResolver);
|
||||
Add(actionLayer);
|
||||
Add(mGuiHand);
|
||||
Add(play);
|
||||
Add(NEW GuiAvatars(cs));
|
||||
Add(NEW GuiPhaseBar());
|
||||
Add(NEW GuiFrame());
|
||||
Add(NEW GuiBackground());
|
||||
}
|
||||
|
||||
void DuelLayers::Update(float dt, Player * currentPlayer)
|
||||
{
|
||||
for (int i = 0; i < nbitems; ++i) objects[i]->Update(dt);
|
||||
int isAI = currentPlayer->isAI();
|
||||
u32 key;
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
while ((key = JGE::GetInstance()->ReadButton())){
|
||||
if ((!isAI) && (0 != key))
|
||||
{
|
||||
if (stack->CheckUserInput(key)) break;
|
||||
// if (combat->CheckUserInput(key)) break;
|
||||
if (action->CheckUserInput(key)) break;
|
||||
if (hand->CheckUserInput(key)) break;
|
||||
if (cs->CheckUserInput(key)) break;
|
||||
}
|
||||
}
|
||||
if (isAI) currentPlayer->Act(dt);
|
||||
}
|
||||
|
||||
ActionStack * DuelLayers::stackLayer(){
|
||||
return ((ActionStack *) (objects[0]));
|
||||
}
|
||||
|
||||
DamageResolverLayer * DuelLayers::combatLayer(){
|
||||
return ((DamageResolverLayer *) (objects[1]));
|
||||
return stack;
|
||||
}
|
||||
|
||||
ActionLayer * DuelLayers::actionLayer(){
|
||||
return ((ActionLayer *) (objects[2]));
|
||||
return action;
|
||||
}
|
||||
|
||||
MTGGuiHand * DuelLayers::handLayer(){
|
||||
return ((MTGGuiHand *) (objects[3]));
|
||||
}
|
||||
MTGGuiPlay * DuelLayers::playLayer(){
|
||||
return ((MTGGuiPlay *) (objects[4]));
|
||||
DuelLayers::DuelLayers() : nbitems(0) {}
|
||||
|
||||
DuelLayers::~DuelLayers(){
|
||||
for (int i = 0; i < nbitems; ++i) delete objects[i];
|
||||
}
|
||||
|
||||
int DuelLayers::unstoppableRenderInProgress(){
|
||||
for (int i = 0; i < nbitems; ++i)
|
||||
if (objects[i]->unstoppableRenderInProgress())
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DuelLayers::Add(GuiLayer * layer){
|
||||
objects.push_back(layer);
|
||||
nbitems++;
|
||||
}
|
||||
|
||||
void DuelLayers::Remove(){
|
||||
--nbitems;
|
||||
}
|
||||
|
||||
void DuelLayers::Render(){
|
||||
bool focusMakesItThrough = true;
|
||||
for (int i = 0; i < nbitems; ++i)
|
||||
{
|
||||
objects[i]->hasFocus = focusMakesItThrough;
|
||||
if (objects[i]->modal) focusMakesItThrough = false;
|
||||
}
|
||||
for (int i = nbitems - 1; i >= 0; --i)
|
||||
objects[i]->Render();
|
||||
}
|
||||
|
||||
int DuelLayers::receiveEvent(WEvent * e){
|
||||
|
||||
#if 0
|
||||
#define PRINT_IF(type) { type *foo = dynamic_cast<type*>(e); if (foo) cout << "Is a " << #type << endl; }
|
||||
cout << "Received event " << e << endl;
|
||||
PRINT_IF(WEventZoneChange);
|
||||
PRINT_IF(WEventDamage);
|
||||
PRINT_IF(WEventPhaseChange);
|
||||
PRINT_IF(WEventCardUpdate);
|
||||
PRINT_IF(WEventCardTap);
|
||||
PRINT_IF(WEventCreatureAttacker);
|
||||
PRINT_IF(WEventCreatureBlocker);
|
||||
PRINT_IF(WEventCreatureBlockerRank);
|
||||
PRINT_IF(WEventEngageMana);
|
||||
PRINT_IF(WEventConsumeMana);
|
||||
#endif
|
||||
|
||||
int used = 0;
|
||||
for (int i = 0; i < nbitems; ++i)
|
||||
used |= objects[i]->receiveEventPlus(e);
|
||||
if (!used)
|
||||
{
|
||||
Pos* p;
|
||||
if (WEventZoneChange *event = dynamic_cast<WEventZoneChange*>(e))
|
||||
{
|
||||
if (event->card->view)
|
||||
waiters.push_back(p = new Pos(*(event->card->view)));
|
||||
else
|
||||
waiters.push_back(p = new Pos(0, 0, 0, 0, 255));
|
||||
event->card->view = p;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < nbitems; ++i)
|
||||
objects[i]->receiveEventMinus(e);
|
||||
return 1;
|
||||
}
|
||||
|
||||
float DuelLayers::RightBoundary()
|
||||
{
|
||||
return hand->LeftBoundary();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user