Erwan
- fix issue 22 (Graveyard display messed up) - fix issue 38 (graveyard and library unusable) - fix issue 59 (can't cancel a spell with a target)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
20
projects/mtg/bin/Res/test/manual/library.txt
Normal file
20
projects/mtg/bin/Res/test/manual/library.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
#Bug:graveyard access
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
library:plains,mountain,grizzly bears,swamp,island,forest,raging goblin,royal assassin,fireball
|
||||
hand:demonic tutor,diabolic tutor
|
||||
manapool:{B}{B}{B}{B}{B}{B}{B}{B}{B}{B}{B}
|
||||
[PLAYER2]
|
||||
[DO]
|
||||
human
|
||||
human
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
inplay:Wildslayer Elves,Armadillo Cloak
|
||||
life:25
|
||||
[PLAYER2]
|
||||
graveyard:grizzly bears
|
||||
life:17
|
||||
[END]
|
||||
@@ -12,6 +12,7 @@ class CardDisplay:public PlayGuiObjectController{
|
||||
GameObserver* game;
|
||||
public:
|
||||
int x, y , start_item, nb_displayed_items;
|
||||
MTGGameZone * zone;
|
||||
TargetChooser * tc;
|
||||
JGuiListener * listener;
|
||||
CardDisplay();
|
||||
@@ -20,6 +21,7 @@ class CardDisplay:public PlayGuiObjectController{
|
||||
void rotateLeft();
|
||||
void rotateRight();
|
||||
bool CheckUserInput(u32 key);
|
||||
virtual void Update(float dt);
|
||||
void Render();
|
||||
void init(MTGGameZone * zone);
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
|
||||
@@ -12,6 +12,7 @@ class DamageResolverLayer;
|
||||
class GuiHandSelf;
|
||||
class GuiHandOpponent;
|
||||
class GuiCombat;
|
||||
class GuiAvatars;
|
||||
struct Pos;
|
||||
|
||||
class DuelLayers {
|
||||
@@ -23,6 +24,7 @@ class DuelLayers {
|
||||
ActionLayer* action;
|
||||
ActionStack* stack;
|
||||
GuiHandSelf *hand;
|
||||
GuiAvatars * avatars;
|
||||
|
||||
public:
|
||||
DuelLayers();
|
||||
|
||||
@@ -26,6 +26,7 @@ class GuiAvatars : public GuiLayer
|
||||
void Deactivate(PlayGuiObject* c);
|
||||
int receiveEventPlus(WEvent*);
|
||||
int receiveEventMinus(WEvent*);
|
||||
bool CheckUserInput(u32 key);
|
||||
};
|
||||
|
||||
#endif // _GUIAVATARS_H_
|
||||
|
||||
@@ -42,6 +42,7 @@ struct GuiGameZone : public GuiStatic{
|
||||
CardDisplay * cd;
|
||||
int showCards;
|
||||
virtual void Render();
|
||||
virtual bool CheckUserInput(u32 key);
|
||||
virtual void Update(float dt);
|
||||
GuiGameZone(float x, float y, bool hasFocus, MTGGameZone * zone, GuiAvatars* parent);
|
||||
~GuiGameZone();
|
||||
|
||||
@@ -24,8 +24,9 @@ class PlayGuiObject: public JGuiObject, public JGuiListener, public Pos{
|
||||
float defaultHeight;
|
||||
bool mHasFocus;
|
||||
int type;
|
||||
virtual void Entering(){mHasFocus = true;};
|
||||
virtual bool Leaving(u32 key){mHasFocus = false;return true;};
|
||||
virtual void Entering(){mHasFocus = true; zoom = 1.4;};
|
||||
virtual bool Leaving(u32 key){mHasFocus = false; zoom = 1.0; return true;};
|
||||
virtual bool CheckUserInput(u32 key) {return false;};
|
||||
virtual bool ButtonPressed(){return true;};
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
|
||||
@@ -11,6 +11,7 @@ CardDisplay::CardDisplay() : mId(0), game(GameObserver::GetInstance()) {
|
||||
start_item = 0;
|
||||
x= 0;
|
||||
y= 0;
|
||||
zone = NULL;
|
||||
}
|
||||
|
||||
CardDisplay::CardDisplay(int id, GameObserver* game, int _x, int _y, JGuiListener * _listener, TargetChooser * _tc, int _nb_displayed_items ) : mId(id), game(game), x(_x), y(_y) {
|
||||
@@ -18,21 +19,26 @@ CardDisplay::CardDisplay(int id, GameObserver* game, int _x, int _y, JGuiListene
|
||||
listener = _listener;
|
||||
nb_displayed_items = _nb_displayed_items;
|
||||
start_item = 0;
|
||||
if (x + nb_displayed_items * 30 + 25 > SCREEN_WIDTH) x = SCREEN_WIDTH - (nb_displayed_items * 30 + 25);
|
||||
if (y + 55 > SCREEN_HEIGHT) y = SCREEN_HEIGHT - 55;
|
||||
zone = NULL;
|
||||
}
|
||||
|
||||
|
||||
void CardDisplay::AddCard(MTGCardInstance * _card){
|
||||
CardGui * card = NEW CardView(CardSelector::nullZone, _card, x + 5 + (mCount - start_item) * 30, y + 5);
|
||||
CardGui * card = NEW CardView(CardSelector::nullZone, _card, x + 20 + (mCount - start_item) * 30, y + 25);
|
||||
Add(card);
|
||||
}
|
||||
|
||||
|
||||
void CardDisplay::init(MTGGameZone * zone){
|
||||
resetObjects();
|
||||
if (!zone) return;
|
||||
start_item = 0;
|
||||
for (int i= 0; i< zone->nb_cards; i++){
|
||||
AddCard(zone->cards[i]);
|
||||
}
|
||||
if (mObjects[0]) mObjects[0]->Entering();
|
||||
}
|
||||
|
||||
void CardDisplay::rotateLeft(){
|
||||
@@ -54,6 +60,22 @@ void CardDisplay::rotateRight(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CardDisplay::Update(float dt){
|
||||
bool update = false;
|
||||
|
||||
if (zone){
|
||||
size_t size = zone->cards.size();
|
||||
for (int i = start_item; i< start_item + nb_displayed_items && i < mCount; i++){
|
||||
if (i > size - 1) {update = true; break;}
|
||||
CardGui * cardg = (CardGui *)mObjects[i];
|
||||
if (cardg->card != zone->cards[i]) update = true;
|
||||
}
|
||||
}
|
||||
PlayGuiObjectController::Update(dt);
|
||||
if (update) init(zone);
|
||||
}
|
||||
|
||||
bool CardDisplay::CheckUserInput(u32 key){
|
||||
if (PSP_CTRL_CROSS == key)
|
||||
{
|
||||
|
||||
@@ -99,8 +99,8 @@ void CardSelector::Pop()
|
||||
}
|
||||
if (active != oldactive)
|
||||
{
|
||||
{ CardView* c = dynamic_cast<CardView*>(oldactive); if (c) c->zoom = 1.0; }
|
||||
{ CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4; }
|
||||
{ CardView* c = dynamic_cast<CardView*>(oldactive); if (c) c->zoom = 1.0; } //Is this needed, I think it is one in Leaving(0) ?
|
||||
{ CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4; } //Is this needed, I think it is one in Entering() ?
|
||||
if (oldactive) oldactive->Leaving(0);
|
||||
if (active) active->Entering();
|
||||
}
|
||||
@@ -123,6 +123,9 @@ bool CardSelector::CheckUserInput(u32 key)
|
||||
Target* oldactive = active;
|
||||
switch (key)
|
||||
{
|
||||
case PSP_CTRL_CROSS:
|
||||
GameObserver::GetInstance()->cancelCurrentAction();
|
||||
return true;
|
||||
case PSP_CTRL_CIRCLE:
|
||||
GameObserver::GetInstance()->ButtonPressed(active);
|
||||
return true;
|
||||
@@ -160,8 +163,8 @@ bool CardSelector::CheckUserInput(u32 key)
|
||||
}
|
||||
if (active != oldactive)
|
||||
{
|
||||
{ CardView* c = dynamic_cast<CardView*>(oldactive); if (c) c->zoom = 1.0; }
|
||||
{ CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4; }
|
||||
{ CardView* c = dynamic_cast<CardView*>(oldactive); if (c) c->zoom = 1.0; } //Is this needed, I think it is one in Leaving(0) ?
|
||||
{ CardView* c = dynamic_cast<CardView*>(active); if (c) c->zoom = 1.4; } //Is this needed, I think it is one in Entering() ?
|
||||
if (oldactive) oldactive->Leaving(0);
|
||||
if (active) active->Entering();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ void DuelLayers::init(){
|
||||
Add(NEW GuiHandOpponent(cs, go->players[1]->game->hand));
|
||||
Add(NEW GuiPlay(go, cs));
|
||||
|
||||
Add(NEW GuiAvatars(cs));
|
||||
Add(avatars = NEW GuiAvatars(cs));
|
||||
Add(NEW GuiPhaseBar());
|
||||
Add(NEW GuiFrame());
|
||||
Add(NEW GuiBackground());
|
||||
@@ -53,6 +53,7 @@ void DuelLayers::CheckUserInput(int isAI){
|
||||
if (stack->CheckUserInput(key)) break;
|
||||
if (combat->CheckUserInput(key)) break;
|
||||
if (action->CheckUserInput(key)) break;
|
||||
if (avatars->CheckUserInput(key)) break;
|
||||
if (hand->CheckUserInput(key)) break;
|
||||
if (cs->CheckUserInput(key)) break;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "../include/GameApp.h"
|
||||
#include "../include/GuiAvatars.h"
|
||||
|
||||
#define LIB_GRAVE_OFFSET 230
|
||||
|
||||
GuiAvatars::GuiAvatars(CardSelector* cs) : cs(cs), active(NULL)
|
||||
{
|
||||
Add(self = NEW GuiAvatar (SCREEN_WIDTH, SCREEN_HEIGHT, false,
|
||||
@@ -52,6 +54,15 @@ int GuiAvatars::receiveEventMinus(WEvent* e)
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool GuiAvatars::CheckUserInput(u32 key){
|
||||
if (self->CheckUserInput(key)) return true;
|
||||
if (opponent->CheckUserInput(key)) return true;
|
||||
if (selfGraveyard->CheckUserInput(key)) return true;
|
||||
if (opponentGraveyard->CheckUserInput(key)) return true;
|
||||
if (selfLibrary->CheckUserInput(key)) return true;
|
||||
if (opponentLibrary->CheckUserInput(key)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void GuiAvatars::Update(float dt)
|
||||
{
|
||||
|
||||
@@ -124,6 +124,11 @@ void GuiGameZone::ButtonPressed(int controllerId, int controlId){
|
||||
GameObserver::GetInstance()->ButtonPressed(this);
|
||||
}
|
||||
|
||||
bool GuiGameZone::CheckUserInput(u32 key){
|
||||
if (showCards) return cd->CheckUserInput(key);
|
||||
return false;
|
||||
}
|
||||
|
||||
void GuiGameZone::Update(float dt){
|
||||
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
|
||||
(*it)->Update(dt);
|
||||
@@ -133,6 +138,7 @@ void GuiGameZone::Update(float dt){
|
||||
|
||||
GuiGameZone::GuiGameZone(float x, float y, bool hasFocus, MTGGameZone* zone, GuiAvatars* parent): GuiStatic(GuiGameZone::Height, x, y, hasFocus, parent), zone(zone){
|
||||
cd = NEW CardDisplay(0, GameObserver::GetInstance(), x, y, this);
|
||||
cd->zone = zone;
|
||||
showCards = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,15 +54,12 @@ void MTGCardInstance::copy(MTGCardInstance * card){
|
||||
|
||||
text = source->text;
|
||||
name = source->name;
|
||||
//strcpy(image_name, source->image_name);
|
||||
|
||||
//rarity = source->rarity;
|
||||
power = source->power;
|
||||
toughness = source->toughness;
|
||||
life = toughness;
|
||||
lifeOrig = life;
|
||||
//mtgid = source->mtgid;
|
||||
//setId = source->setId;
|
||||
|
||||
magicText = source->magicText;
|
||||
spellTargetType = source->spellTargetType;
|
||||
alias = source->alias;
|
||||
|
||||
Reference in New Issue
Block a user