* 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:
jean.chalard
2009-08-22 05:59:43 +00:00
parent bf4262c0a0
commit 3349f974f1
101 changed files with 2424 additions and 2361 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiCardsController.o objs/GuiLayers.o objs/GuiPhaseBar.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGGuiHand.o objs/MTGGuiPlay.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/PriceList.o objs/ReplacementEffects.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/TexturesCache.o objs/Token.o objs/Translate.o objs/utils.o objs/WEvent.o OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardSelector.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGGuiHand.o objs/MTGGuiPlay.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PriceList.o objs/ReplacementEffects.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/TexturesCache.o objs/Token.o objs/Translate.o objs/utils.o objs/WEvent.o
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS)) DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache) RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1019 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 830 B

+1 -1
View File
@@ -6,7 +6,7 @@
class AIMomirPlayer:public AIPlayerBaka{ class AIMomirPlayer:public AIPlayerBaka{
public: public:
AIMomirPlayer(MTGPlayerCards * _deck, char * file, const char * fileSmall, char * avatarFile); AIMomirPlayer(MTGPlayerCards * deck, string file, string fileSmall, string avatarFile);
int getEfficiency(AIAction * action); int getEfficiency(AIAction * action);
int momir(); int momir();
int computeActions(); int computeActions();
+2 -2
View File
@@ -65,7 +65,7 @@ class AIPlayer: public Player{
virtual int displayStack(){return 0;}; virtual int displayStack(){return 0;};
AIStats * stats; AIStats * stats;
ManaCost * getPotentialMana(); ManaCost * getPotentialMana();
AIPlayer(MTGPlayerCards * _deck, string deckFile, string deckFileSmall); AIPlayer(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
virtual ~AIPlayer(); virtual ~AIPlayer();
virtual MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0); virtual MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0);
virtual int chooseTarget(TargetChooser * tc = NULL); virtual int chooseTarget(TargetChooser * tc = NULL);
@@ -86,7 +86,7 @@ class AIPlayerBaka: public AIPlayer{
float timer; float timer;
MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type); MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type);
public: public:
AIPlayerBaka(MTGPlayerCards * _deck, char * deckFile, const char * deckfileSmall, char * avatarFile); AIPlayerBaka(MTGPlayerCards * deck, string deckFile, string deckfileSmall, string avatarFile);
virtual int Act(float dt); virtual int Act(float dt);
void initTimer(); void initTimer();
virtual int computeActions(); virtual int computeActions();
+2 -2
View File
@@ -25,12 +25,12 @@ class ActionLayer: public GuiLayer, public JGuiListener{
virtual void Update(float dt); virtual void Update(float dt);
int unstoppableRenderInProgress(); int unstoppableRenderInProgress();
bool CheckUserInput(u32 key); bool CheckUserInput(u32 key);
ActionLayer(int id, GameObserver* _game):GuiLayer(id, _game){ menuObject = NULL; abilitiesMenu = NULL; stuffHappened = 0;}; ActionLayer(){ menuObject = NULL; abilitiesMenu = NULL; stuffHappened = 0;};
~ActionLayer(); ~ActionLayer();
int cancelCurrentAction(); int cancelCurrentAction();
ActionElement * isWaitingForAnswer(); ActionElement * isWaitingForAnswer();
int isReactingToTargetClick(Targetable * card); int isReactingToTargetClick(Targetable * card);
int receiveEvent(WEvent * event); int receiveEventPlus(WEvent * event);
int reactToTargetClick(Targetable * card); int reactToTargetClick(Targetable * card);
int isReactingToClick(MTGCardInstance * card); int isReactingToClick(MTGCardInstance * card);
int reactToClick(MTGCardInstance * card); int reactToClick(MTGCardInstance * card);
+8 -4
View File
@@ -45,6 +45,9 @@ class TargetChooser;
class Interruptible: public PlayGuiObject, public Targetable{ class Interruptible: public PlayGuiObject, public Targetable{
public: public:
//TODO : remove these when they are back in PlayGuiObject
float x, y;
int state, display; int state, display;
MTGCardInstance * source; MTGCardInstance * source;
virtual void Entering(){mHasFocus = true;}; virtual void Entering(){mHasFocus = true;};
@@ -53,8 +56,8 @@ class Interruptible: public PlayGuiObject, public Targetable{
virtual int resolve(){return 0;}; virtual int resolve(){return 0;};
virtual void Render(){}; virtual void Render(){};
int typeAsTarget(){return TARGET_STACKACTION;}; int typeAsTarget(){return TARGET_STACKACTION;};
Interruptible(int id,bool hasFocus = false):PlayGuiObject(id,40,x,y,hasFocus){state=NOT_RESOLVED;display=0;source=NULL;}; Interruptible(bool hasFocus = false):PlayGuiObject(40,x,y,hasFocus){state=NOT_RESOLVED;display=0;source=NULL;};
virtual const char *getDisplayName(){return "stack object";}; virtual const string getDisplayName(){return "stack object";};
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
virtual void Dump(); virtual void Dump();
#endif #endif
@@ -79,7 +82,7 @@ class Spell: public Interruptible {
~Spell(); ~Spell();
int resolve(); int resolve();
void Render(); void Render();
const char *getDisplayName(); const string getDisplayName();
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
MTGCardInstance * getNextCardTarget(MTGCardInstance * previous = 0); MTGCardInstance * getNextCardTarget(MTGCardInstance * previous = 0);
Player * getNextPlayerTarget(Player * previous = 0); Player * getNextPlayerTarget(Player * previous = 0);
@@ -123,6 +126,7 @@ class DrawAction: public Interruptible {
class ActionStack :public GuiLayer{ class ActionStack :public GuiLayer{
protected: protected:
GameObserver* game;
int interruptDecision[2]; int interruptDecision[2];
float timer; float timer;
int currentState; int currentState;
@@ -165,7 +169,7 @@ class ActionStack :public GuiLayer{
void Update(float dt); void Update(float dt);
bool CheckUserInput(u32 key); bool CheckUserInput(u32 key);
virtual void Render(); virtual void Render();
ActionStack(int id, GameObserver* _game); ActionStack(GameObserver* game);
int resolve(); int resolve();
int CombatDamages(); int CombatDamages();
int CombatDamages(int firststrike); int CombatDamages(int firststrike);
+7 -7
View File
@@ -12,6 +12,7 @@
#include "Token.h" #include "Token.h"
#include "Counters.h" #include "Counters.h"
#include "WEvent.h" #include "WEvent.h"
#include "GuiStatic.h"
#include <JGui.h> #include <JGui.h>
#include <hge/hgeparticle.h> #include <hge/hgeparticle.h>
@@ -29,8 +30,7 @@ class TrCardAddedToZone:public TriggeredAbility{
public: public:
TargetChooser * toTc; TargetChooser * toTc;
TargetZoneChooser * fromTc; TargetZoneChooser * fromTc;
TrCardAddedToZone(int id,MTGCardInstance * source, TargetChooser * toTc, TargetZoneChooser * fromTc = NULL):TriggeredAbility(id,source), toTc(toTc),fromTc(fromTc){ TrCardAddedToZone(int id, MTGCardInstance * source, TargetChooser * toTc, TargetZoneChooser * fromTc = NULL):TriggeredAbility(id,source), toTc(toTc), fromTc(fromTc){}
}
int resolve(){ int resolve(){
return 0; //This is a trigger, this function should not be called return 0; //This is a trigger, this function should not be called
@@ -63,8 +63,8 @@ class AACounter: public ActivatedAbility{
int nb; int nb;
int power; int power;
int toughness; int toughness;
AACounter(int id, MTGCardInstance * _source, MTGCardInstance * _target, int _power, int _toughness, int nb,ManaCost * cost=NULL, int doTap = 0):ActivatedAbility(id,_source,cost,0,doTap),nb(nb),power(_power),toughness(_toughness){ AACounter(int id, MTGCardInstance * source, MTGCardInstance * target, int power, int toughness, int nb, ManaCost * cost = NULL, int doTap = 0) : ActivatedAbility(id, source, cost, 0, doTap), nb(nb), power(power), toughness(toughness) {
target=_target; target = target;
} }
@@ -1962,7 +1962,7 @@ class AAladdinsLamp: public TargetAbility{
int nbcards; int nbcards;
int init; int init;
AAladdinsLamp(int _id, MTGCardInstance * card):TargetAbility(_id,card){ AAladdinsLamp(int id, MTGCardInstance * card) : TargetAbility(id,card) {
cost = NEW ManaCost(); cost = NEW ManaCost();
cost->x(); cost->x();
cd = CardDisplay(1, game, SCREEN_WIDTH/2, SCREEN_HEIGHT/2, NULL); cd = CardDisplay(1, game, SCREEN_WIDTH/2, SCREEN_HEIGHT/2, NULL);
@@ -2979,7 +2979,7 @@ class APestilence: public ActivatedAbility{
for (int i = 0; i < 2 ; i++){ for (int i = 0; i < 2 ; i++){
MTGInPlay * inplay = game->players[i]->game->inPlay; MTGInPlay * inplay = game->players[i]->game->inPlay;
for (int j = inplay->nb_cards - 1 ; j >=0; j--){ for (int j = inplay->nb_cards - 1 ; j >=0; j--){
if (inplay->cards[j]->isACreature()) game->mLayers->stackLayer()->addDamage(source,inplay->cards[j],1); if (inplay->cards[j]->isCreature()) game->mLayers->stackLayer()->addDamage(source,inplay->cards[j],1);
} }
game->mLayers->stackLayer()->addDamage(source,game->players[i],1); game->mLayers->stackLayer()->addDamage(source,game->players[i],1);
} }
@@ -3489,7 +3489,7 @@ class ASoulNet:public ActivatedAbility{
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL){ int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL){
newDead = ((PutInGraveyard *) GameObserver::GetInstance()->mLayers->stackLayer()->getPrevious(NULL,ACTION_PUTINGRAVEYARD,RESOLVED_OK)); newDead = ((PutInGraveyard *) GameObserver::GetInstance()->mLayers->stackLayer()->getPrevious(NULL,ACTION_PUTINGRAVEYARD,RESOLVED_OK));
if (newDead && newDead != latest && newDead->card->isACreature()) if (newDead && newDead != latest && newDead->card->isCreature())
return ActivatedAbility::isReactingToClick(card,mana); return ActivatedAbility::isReactingToClick(card,mana);
return 0; return 0;
} }
+4 -2
View File
@@ -8,12 +8,14 @@ class MTGGameZone;
class MTGCardInstance; class MTGCardInstance;
class CardDisplay:public PlayGuiObjectController{ class CardDisplay:public PlayGuiObjectController{
int mId;
GameObserver* game;
public: public:
int x, y , start_item, nb_displayed_items; int x, y , start_item, nb_displayed_items;
TargetChooser * tc; TargetChooser * tc;
JGuiListener * listener; JGuiListener * listener;
CardDisplay(); CardDisplay();
CardDisplay(int id, GameObserver* _game, int _x, int _y, JGuiListener * _listener = NULL, TargetChooser * _tc = NULL, int _nb_displayed_items = 7 ); CardDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener = NULL, TargetChooser * tc = NULL, int nb_displayed_items = 7);
void AddCard(MTGCardInstance * _card); void AddCard(MTGCardInstance * _card);
void rotateLeft(); void rotateLeft();
void rotateRight(); void rotateRight();
@@ -27,7 +29,7 @@ class CardDisplay:public PlayGuiObjectController{
class DefaultTargetDisplay:CardDisplay{ class DefaultTargetDisplay:CardDisplay{
public: public:
DefaultTargetDisplay(int id, GameObserver* _game, int _x, int _y, JGuiListener * _listener, int _nb_displayed_items ); DefaultTargetDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener, int nb_displayed_items );
~DefaultTargetDisplay(); ~DefaultTargetDisplay();
}; };
+48 -1
View File
@@ -4,6 +4,7 @@
#define _CARD_GUI_H_ #define _CARD_GUI_H_
#include <JGui.h> #include <JGui.h>
#include "Pos.h"
#include "PlayGuiObject.h" #include "PlayGuiObject.h"
#include "MTGCardInstance.h" #include "MTGCardInstance.h"
#include <hge/hgeparticle.h> #include <hge/hgeparticle.h>
@@ -11,10 +12,53 @@
class MTGCardInstance; class MTGCardInstance;
class PlayGuiObject; class PlayGuiObject;
struct CardGui : public PlayGuiObject {
protected:
JQuad* quad;
public:
static const float Width = 28.0;
static const float Height = 40.0;
static const float BigWidth = 200.0;
static const float BigHeight = 285.0;
MTGCardInstance* card;
CardGui(MTGCardInstance* card, float x, float y);
CardGui(MTGCardInstance* card, const Pos& ref);
virtual void Render() = 0;
void RenderBig(const Pos&);
virtual void Update(float dt) = 0;
virtual ostream& toString(ostream&) const;
};
class CardView : public CardGui {
public:
MTGCardInstance* getCard(); // remove this when possible
CardView(MTGCardInstance* card, float x, float y);
CardView(MTGCardInstance* card, const Pos& ref);
virtual void Render();
void Render(JQuad* q){Pos::Render(q);};
void RenderSelected();
virtual void Update(float dt);
virtual ostream& toString(ostream&) const;
};
class TransientCardView : public CardView {
public:
TransientCardView(MTGCardInstance* card, float x, float y);
TransientCardView(MTGCardInstance* card, const Pos& ref);
virtual void Render();
};
/*
class CardGui: public PlayGuiObject{ class CardGui: public PlayGuiObject{
protected: protected:
hgeParticleSystem * mParticleSys; hgeParticleSystem * mParticleSys;
int alpha; int alpha;
float actX, actY;
public: public:
MTGCardInstance * card; MTGCardInstance * card;
CardGui(int id, MTGCardInstance * _card, float desiredHeight, float _x=0, float _y=0, bool hasFocus = false); CardGui(int id, MTGCardInstance * _card, float desiredHeight, float _x=0, float _y=0, bool hasFocus = false);
@@ -22,10 +66,13 @@ class CardGui: public PlayGuiObject{
virtual void Update(float dt); virtual void Update(float dt);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
float Height();
float Width();
void RenderBig(float x=-1, float y = -1, int alternate = 0); void RenderBig(float x=-1, float y = -1, int alternate = 0);
static void alternateRender(MTGCard * card, JQuad ** manaIcons, float x, float y, float rotation= 0, float scale=1); static void alternateRender(MTGCard * card, JQuad ** manaIcons, float x, float y, float rotation= 0, float scale=1);
~CardGui(); ~CardGui();
}; };
*/
#endif #endif
+5 -5
View File
@@ -28,13 +28,13 @@ class Damageable:public Targetable {
class Damage: public Interruptible { class Damage: public Interruptible {
protected: protected:
void init(MTGCardInstance * _source, Damageable * _target, int _damage); void init(MTGCardInstance * source, Damageable * target, int damage);
public: public:
Damageable * target; Damageable * target;
int damage; int damage;
void Render(); void Render();
Damage(int id, MTGCardInstance* _source, Damageable * _target); Damage(int id, MTGCardInstance* source, Damageable * target);
Damage(int id, MTGCardInstance* _source, Damageable * _target, int _damage); Damage(int id, MTGCardInstance* source, Damageable * target, int damage);
int resolve(); int resolve();
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
}; };
@@ -43,7 +43,7 @@ class Damage: public Interruptible {
class DamageStack :public GuiLayer, public Interruptible{ class DamageStack :public GuiLayer, public Interruptible{
protected: protected:
int currentState; int currentState;
GameObserver* game;
public: public:
int resolve(); int resolve();
@@ -51,7 +51,7 @@ class DamageStack :public GuiLayer, public Interruptible{
int CombatDamages();//Deprecated ? int CombatDamages();//Deprecated ?
int CombatDamages(int strike); int CombatDamages(int strike);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;
DamageStack(int id, GameObserver* _game); DamageStack(GameObserver* game);
}; };
+3 -1
View File
@@ -9,8 +9,10 @@ class DamageStack;
class DamageResolverLayer:public PlayGuiObjectController{ class DamageResolverLayer:public PlayGuiObjectController{
protected: protected:
GameObserver* game;
int trampleDamage(); int trampleDamage();
void updateAllCoordinates(); void updateAllCoordinates();
public: public:
int buttonOk; int buttonOk;
int orderingIsNeeded; int orderingIsNeeded;
@@ -21,7 +23,7 @@ class DamageResolverLayer:public PlayGuiObjectController{
DamageStack * damageStack; DamageStack * damageStack;
DamagerDamaged * currentSource; DamagerDamaged * currentSource;
DamageResolverLayer(int id, GameObserver* _game); DamageResolverLayer(GameObserver* game);
int init(); int init();
int initResolve(); int initResolve();
Player * whoSelectsDamagesDealtBy(MTGCardInstance * card); Player * whoSelectsDamagesDealtBy(MTGCardInstance * card);
+4 -7
View File
@@ -1,12 +1,12 @@
#ifndef _DAMAGERDAMAGED_H_ #ifndef _DAMAGERDAMAGED_H_
#define _DAMAGERDAMAGED_H_ #define _DAMAGERDAMAGED_H_
#include "../include/CardGui.h" #include "../include/MTGCardInstance.h"
class Player; class Player;
class DamagerDamaged:public CardGui{ struct DamagerDamaged {
public: MTGCardInstance* card;
Player * damageSelecter; Player * damageSelecter;
int mCount; int mCount;
Damage * damages[10]; Damage * damages[10];
@@ -18,12 +18,9 @@ class DamagerDamaged:public CardGui{
int removeDamagesFrom(DamagerDamaged * source); int removeDamagesFrom(DamagerDamaged * source);
int sumDamages(); int sumDamages();
int hasLethalDamage(); int hasLethalDamage();
DamagerDamaged(CardGui * cardg, Player * _damageSelecter, bool _hasFocus); DamagerDamaged(MTGCardInstance* card, Player * _damageSelecter, bool _hasFocus);
~DamagerDamaged(); ~DamagerDamaged();
void Render(Player * currentPlayer); void Render(Player * currentPlayer);
}; };
+29 -10
View File
@@ -1,32 +1,51 @@
#ifndef _DUELLAYERS_H_ #ifndef _DUELLAYERS_H_
#define _DUELLAYERS_H_ #define _DUELLAYERS_H_
#include "GuiLayers.h" #include "GuiLayers.h"
#include "CardSelector.h"
class MTGGuiHand; class MTGGuiHand;
class MTGGuiPlay; class MTGGuiPlay;
class ActionLayer; class ActionLayer;
class ActionStack; class ActionStack;
class DamageResolverLayer; class DamageResolverLayer;
class GuiHandSelf;
class GuiHandOpponent;
class GuiCombat;
class Pos;
class DuelLayers: public GuiLayers{ class DuelLayers {
protected:
int nbitems;
vector<GuiLayer*> objects;
vector<Pos*> waiters;
GuiCombat* combat;
ActionLayer* action;
ActionStack* stack;
GuiHandSelf *hand;
public: public:
ActionLayer * actionLayer(); DuelLayers();
MTGGuiHand * handLayer(); ~DuelLayers();
MTGGuiPlay * playLayer();
ActionStack * stackLayer();
DamageResolverLayer * combatLayer();
void init();
ActionLayer * actionLayer();
ActionStack * stackLayer();
void init();
virtual void Update(float dt, Player * player);
void Render();
void Add(GuiLayer * layer);
void Remove();
int unstoppableRenderInProgress();
int receiveEvent(WEvent * e);
float RightBoundary();
CardSelector* cs;
}; };
#include "ActionLayer.h" #include "ActionLayer.h"
#include "GameObserver.h" #include "GameObserver.h"
#include "MTGGamePhase.h" #include "MTGGamePhase.h"
#include "MTGGuiHand.h"
#include "MTGGuiPlay.h"
#include "ActionStack.h" #include "ActionStack.h"
#include "Damage.h" #include "Damage.h"
+1 -1
View File
@@ -94,6 +94,6 @@ class GameApp: public JApp
}; };
extern JQuad* manaIcons[7];
#endif #endif
+3 -3
View File
@@ -10,6 +10,7 @@
#include "TargetChooser.h" #include "TargetChooser.h"
#include "PhaseRing.h" #include "PhaseRing.h"
#include "ReplacementEffects.h" #include "ReplacementEffects.h"
#include "GuiStatic.h"
class MTGGamePhase; class MTGGamePhase;
class MTGAbility; class MTGAbility;
@@ -33,7 +34,6 @@ class GameObserver{
public: public:
int blockersSorted; int blockersSorted;
int forceShuffleLibrary[2];
int turn; int turn;
int forceShuffleLibraries(); int forceShuffleLibraries();
int targetListIsSet(MTGCardInstance * card); int targetListIsSet(MTGCardInstance * card);
@@ -78,11 +78,11 @@ class GameObserver{
void untapPhase(); void untapPhase();
void draw(); void draw();
int isInPlay(MTGCardInstance * card); int isInPlay(MTGCardInstance * card);
int isACreature(MTGCardInstance * card); bool isCreature(MTGCardInstance * card);
void Update(float dt); void Update(float dt);
void Render(); void Render();
void ButtonPressed(int, PlayGuiObject*); void ButtonPressed(PlayGuiObject*);
int receiveEvent(WEvent * event); int receiveEvent(WEvent * event);
}; };
+25 -31
View File
@@ -6,53 +6,47 @@
using std::map; using std::map;
using std::string; using std::string;
#define OPTIONS_MUSICVOLUME "musicVolume"
#define OPTIONS_SFXVOLUME "sfxVolume"
#define OPTIONS_DIFFICULTY_MODE_UNLOCKED "prx_handler" //huhu
#define OPTIONS_MOMIR_MODE_UNLOCKED "prx_rimom" //haha
#define OPTIONS_EVILTWIN_MODE_UNLOCKED "prx_eviltwin"
#define OPTIONS_RANDOMDECK_MODE_UNLOCKED "prx_rnddeck"
#define OPTIONS_DIFFICULTY "difficulty"
#define OPTIONS_CACHESIZE "cacheSize"
#define OPTIONS_PLASMAEFFECT "plasmaEffect"
#define OPTIONS_INTERRUPTMYSPELLS "interruptMySpells"
#define OPTIONS_INTERRUPTMYABILITIES "interruptMyAbilities"
#define OPTIONS_OSD "displayOSD"
// WALDORF - added
#define OPTIONS_INTERRUPT_SECONDS "interruptSeconds"
#define OPTIONS_SAVEFILE RESPATH"/settings/options.txt" #define OPTIONS_SAVEFILE RESPATH"/settings/options.txt"
struct Options {
static const string MUSICVOLUME;
static const string SFXVOLUME;
static const string DIFFICULTY_MODE_UNLOCKED;
static const string MOMIR_MODE_UNLOCKED;
static const string EVILTWIN_MODE_UNLOCKED;
static const string RANDOMDECK_MODE_UNLOCKED;
static const string DIFFICULTY;
static const string CACHESIZE;
static const string PLASMAEFFECT;
static const string INTERRUPT_SECONDS;
static const string INTERRUPTMYSPELLS;
static const string INTERRUPTMYABILITIES;
static const string OSD;
};
class GameOption { class GameOption {
public: public:
int value; int number;
string svalue; string str;
int getIntValue(); GameOption(int value = 0);
GameOption(int _value = 0); GameOption(string value);
}; };
class GameOptions { class GameOptions {
public: public:
map<string,GameOption> values;
static GameOptions * GetInstance();
static void Destroy();
int save(); int save();
int load(); int load();
static const char * phaseInterrupts[]; static const char * phaseInterrupts[];
GameOption& operator[](string);
private:
GameOptions(); GameOptions();
~GameOptions(); ~GameOptions();
static GameOptions* mInstance;
private:
static map <string,int> optionsTypes; static map <string,int> optionsTypes;
map<string,GameOption> values;
}; };
extern GameOptions options;
#endif #endif
+9 -8
View File
@@ -6,8 +6,9 @@
#include <JGE.h> #include <JGE.h>
#include "GameState.h" #include "../include/GameState.h"
#include "SimpleMenu.h" #include "../include/SimpleMenu.h"
#include "../include/TexturesCache.h"
#include "../include/CardGui.h" #include "../include/CardGui.h"
#include "../include/GameOptions.h" #include "../include/GameOptions.h"
#include "../include/PriceList.h" #include "../include/PriceList.h"
@@ -116,7 +117,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
char buf[4096]; char buf[4096];
sprintf(buf,"Loadindexes[%i] is NULL\n", i); sprintf(buf,"Loadindexes[%i] is NULL\n", i);
if(_current) sprintf(buf, "LoadIndexes[%i] : %s\n", i, _current->getName()); if(_current) sprintf(buf, "LoadIndexes[%i] : %s\n", i, _current->getName().c_str());
OutputDebugString(buf); OutputDebugString(buf);
#endif #endif
_current = displayed_deck->getNext(_current,colorFilter); _current = displayed_deck->getNext(_current,colorFilter);
@@ -187,7 +188,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
welcome_menu->Add(nbDecks+1, "--NEW--"); welcome_menu->Add(nbDecks+1, "--NEW--");
welcome_menu->Add(-1, "Cancel"); welcome_menu->Add(-1, "Cancel");
if (GameApp::HasMusic && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME].getIntValue() > 0){ if (GameApp::HasMusic && options[Options::MUSICVOLUME].number > 0){
if (GameApp::music){ if (GameApp::music){
JSoundSystem::GetInstance()->StopMusic(GameApp::music); JSoundSystem::GetInstance()->StopMusic(GameApp::music);
SAFE_DELETE(GameApp::music); SAFE_DELETE(GameApp::music);
@@ -617,7 +618,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
int showName = 1; int showName = 1;
if (mParent->cache->isInCache(card) || last_user_activity > (abs(2-id) + 1)* NO_USER_ACTIVITY_SHOWCARD_DELAY){ if (mParent->cache->isInCache(card) || last_user_activity > (abs(2-id) + 1)* NO_USER_ACTIVITY_SHOWCARD_DELAY){
quad = card->getQuad(mParent->cache); quad = cache.getQuad(card);
showName = 0; showName = 0;
} }
@@ -638,8 +639,8 @@ class GameStateDeckViewer: public GameState, public JGuiListener
mFont->SetScale(scaleBackup); mFont->SetScale(scaleBackup);
} }
}else{ }else{
CardGui::alternateRender(card, mIcons, x_center, y + 142.5*scale, 0, scale); // CardGui::alternateRender(card, mIcons, x_center, y + 142.5*scale, 0, scale);
quad = card->getThumb(); quad = cache.getThumb(card);
if (quad){ if (quad){
float _scale = 285 * scale / quad->mHeight; float _scale = 285 * scale / quad->mHeight;
quad->SetColor(ARGB(40,255,255,255)); quad->SetColor(ARGB(40,255,255,255));
@@ -782,7 +783,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
pricelist->setPrice(card->getMTGId(),price*2); pricelist->setPrice(card->getMTGId(),price*2);
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
char buf[4096]; char buf[4096];
sprintf(buf, "CARD'S NAME : %s", card->getName()); sprintf(buf, "CARD'S NAME : %s", card->getName().c_str());
OutputDebugString(buf); OutputDebugString(buf);
#endif #endif
playerdata->collection->remove(card->getMTGId()); playerdata->collection->remove(card->getMTGId());
+1 -1
View File
@@ -6,7 +6,7 @@
class GuiCardsController : public PlayGuiObjectController{ class GuiCardsController : public PlayGuiObjectController{
public: public:
GuiCardsController(int id, GameObserver* _game):PlayGuiObjectController(id, _game){}; GuiCardsController(){};
}; };
+3 -23
View File
@@ -1,8 +1,6 @@
#ifndef _GUI_LAYERS_H_ #ifndef _GUI_LAYERS_H_
#define _GUI_LAYERS_H_ #define _GUI_LAYERS_H_
#define MAX_GUI_LAYERS 7
#define DIR_DOWN 1 #define DIR_DOWN 1
#define DIR_UP 2 #define DIR_UP 2
#define DIR_LEFT 3 #define DIR_LEFT 3
@@ -14,11 +12,8 @@
class GameObserver; class GameObserver;
class Player; class Player;
class GuiLayer{ class GuiLayer{
protected: protected:
GameObserver * game;
int mId;
u32 mActionButton; u32 mActionButton;
public: public:
int mCount; int mCount;
@@ -32,7 +27,7 @@ class GuiLayer{
int getMaxId(); int getMaxId();
void RenderMessageBackground(float x0, float y0, float width, int height); void RenderMessageBackground(float x0, float y0, float width, int height);
void RenderMessageBackground(float y0, int height); void RenderMessageBackground(float y0, int height);
GuiLayer(int id, GameObserver* _game); GuiLayer();
virtual ~GuiLayer(); virtual ~GuiLayer();
virtual void Update(float dt); virtual void Update(float dt);
virtual bool CheckUserInput(u32 key){ return false; }; virtual bool CheckUserInput(u32 key){ return false; };
@@ -45,23 +40,8 @@ class GuiLayer{
return 1; return 1;
}; };
virtual int receiveEvent(WEvent * e){return 0;}; virtual int receiveEventPlus(WEvent * e){return 0;};
}; virtual int receiveEventMinus(WEvent * e){return 0;};
class GuiLayers{
protected:
int nbitems;
GuiLayer * objects[MAX_GUI_LAYERS];
public:
GuiLayers();
virtual void Update(float dt, Player * player);
void Render();
void Add(GuiLayer * layer);
void Remove();
int unstoppableRenderInProgress();
~GuiLayers();
int receiveEvent(WEvent * e);
}; };
#endif #endif
+2 -2
View File
@@ -17,11 +17,11 @@ class GuiPhaseBar : public GuiLayer
float angle; float angle;
public: public:
GuiPhaseBar(GameObserver* game); GuiPhaseBar();
~GuiPhaseBar(); ~GuiPhaseBar();
void Update(float dt); void Update(float dt);
virtual void Render(); virtual void Render();
virtual int receiveEvent(WEvent * e); virtual int receiveEventMinus(WEvent * e);
}; };
#endif // _GUIPHASEBAR_H_ #endif // _GUIPHASEBAR_H_
+15 -32
View File
@@ -10,51 +10,35 @@
#define MTG_MINIIMAGE_WIDTH 45 #define MTG_MINIIMAGE_WIDTH 45
#define MTG_MINIIMAGE_HEIGHT 64 #define MTG_MINIIMAGE_HEIGHT 64
#define MAX_TYPES_PER_CARD 10 #define MAX_TYPES_PER_CARD 10
#include "ManaCost.h"
class TexturesCache;
#include <string> #include <string>
#include <vector> #include <vector>
#include <map> #include <map>
#include "ManaCost.h"
using namespace std; using namespace std;
class MTGCard { class MTGCard {
protected: protected:
int mtgid; int mtgid;
ManaCost manaCost; ManaCost manaCost;
char rarity; char rarity;
char image_name[MTGCARD_NAME_SIZE]; char image_name[MTGCARD_NAME_SIZE];
vector<string> ftdText;
int init(); int init();
public: public:
TexturesCache * mCache;
string text; string text;
string name; string name;
int colors[Constants::MTG_NB_COLORS]; int colors[Constants::MTG_NB_COLORS];
map<int,int> basicAbilities; map<int,int> basicAbilities;
vector<string> formattedText;
string magicText; string magicText;
int alias; int alias;
string spellTargetType; string spellTargetType;
int formattedTextInit;
int power; int power;
int toughness; int toughness;
int setId; int setId;
@@ -62,11 +46,8 @@ class MTGCard {
int nb_types; int nb_types;
int types[MAX_TYPES_PER_CARD]; int types[MAX_TYPES_PER_CARD];
MTGCard(); MTGCard();
MTGCard(TexturesCache * cache, int set_id); MTGCard(int set_id);
MTGCard(MTGCard * source); MTGCard(MTGCard * source);
JQuad * getQuad(TexturesCache * cache);
JQuad * getQuad(int type=1);
JQuad * getThumb();
void setColor(int _color, int removeAllOthers = 0); void setColor(int _color, int removeAllOthers = 0);
int getColor(); int getColor();
@@ -93,7 +74,7 @@ class MTGCard {
void addMagicText(string value); void addMagicText(string value);
void setName(string value); void setName(string value);
const char * getName(); const string getName() const;
void addType(char * type_text); void addType(char * type_text);
void addType(int id); void addType(int id);
@@ -101,22 +82,24 @@ class MTGCard {
void setSubtype( string value); void setSubtype( string value);
int removeType(string value, int removeAll = 0); int removeType(string value, int removeAll = 0);
int removeType(int value, int removeAll = 0); int removeType(int value, int removeAll = 0);
int hasSubtype(int _subtype); bool hasSubtype(int _subtype);
int hasSubtype(const char * _subtype); bool hasSubtype(const char * _subtype);
int hasSubtype(string _subtype); bool hasSubtype(string _subtype);
int hasType(int _type); bool hasType(int _type);
int hasType(const char * type); bool hasType(const char * type);
void setManaCost(string value); void setManaCost(string value);
ManaCost * getManaCost(); ManaCost * getManaCost();
int isACreature(); bool isCreature();
bool isLand();
bool isSpell();
void setPower(int _power); void setPower(int _power);
int getPower(); int getPower();
void setToughness(int _toughness); void setToughness(int _toughness);
int getToughness(); int getToughness();
const vector<string>& formattedText();
}; };
+3 -2
View File
@@ -20,6 +20,7 @@ class ManaCost;
class UntapBlockers; class UntapBlockers;
class CardDescriptor; class CardDescriptor;
class Counters; class Counters;
class Pos;
#include <list> #include <list>
using namespace std; using namespace std;
@@ -41,6 +42,7 @@ class MTGCardInstance: public MTGCard, public Damageable {
int setDefenser(MTGCardInstance * c); int setDefenser(MTGCardInstance * c);
int setAttacker(int value); int setAttacker(int value);
public: public:
Pos* view;
int regenerateTokens; int regenerateTokens;
bool isToken; bool isToken;
int stillInUse(); int stillInUse();
@@ -58,7 +60,7 @@ class MTGCardInstance: public MTGCard, public Damageable {
Player * owner; Player * owner;
Counters * counters; Counters * counters;
int typeAsTarget(){return TARGET_CARD;} int typeAsTarget(){return TARGET_CARD;}
const char * getDisplayName(); const string getDisplayName();
MTGCardInstance * target; MTGCardInstance * target;
void addType(int type); void addType(int type);
@@ -94,7 +96,6 @@ class MTGCardInstance: public MTGCard, public Damageable {
int regenerate(); int regenerate();
int triggerRegenerate(); int triggerRegenerate();
Player * controller(); Player * controller();
JQuad * getIcon();
~MTGCardInstance(); ~MTGCardInstance();
int bury(); int bury();
-6
View File
@@ -4,12 +4,6 @@
#define MTG_ERROR -1 #define MTG_ERROR -1
#include "../include/MTGDefinitions.h" #include "../include/MTGDefinitions.h"
#include "../include/GameApp.h" #include "../include/GameApp.h"
#include "../include/TexturesCache.h" #include "../include/TexturesCache.h"
+1
View File
@@ -85,6 +85,7 @@ class MTGGameZone {
static MTGGameZone * stringToZone(string zoneName, MTGCardInstance * source, MTGCardInstance * target); static MTGGameZone * stringToZone(string zoneName, MTGCardInstance * source, MTGCardInstance * target);
static int zoneStringToId(string zoneName); static int zoneStringToId(string zoneName);
static MTGGameZone *intToZone(int zoneId, MTGCardInstance * source = NULL,MTGCardInstance * target = NULL); static MTGGameZone *intToZone(int zoneId, MTGCardInstance * source = NULL,MTGCardInstance * target = NULL);
bool needShuffle;
}; };
class MTGLibrary: public MTGGameZone { class MTGLibrary: public MTGGameZone {
+2 -1
View File
@@ -17,13 +17,14 @@ class GuiCardscontroller;
class MTGGuiHand: public GuiCardsController{ class MTGGuiHand: public GuiCardsController{
protected: protected:
GameObserver* game;
int currentId[2]; int currentId[2];
Player * currentPlayer; Player * currentPlayer;
int mShowHand; int mShowHand;
float mAnimState; float mAnimState;
JLBFont * mFont; JLBFont * mFont;
public: public:
MTGGuiHand(int id, GameObserver * _game); MTGGuiHand(GameObserver*);
void Update(float dt); void Update(float dt);
bool CheckUserInput(u32 key); bool CheckUserInput(u32 key);
virtual void Render(); virtual void Render();
+3 -2
View File
@@ -12,6 +12,7 @@ class CardGui;
class MTGGuiPlay: public PlayGuiObjectController { class MTGGuiPlay: public PlayGuiObjectController {
protected: protected:
GameObserver* game;
int offset; int offset;
Player * currentPlayer; Player * currentPlayer;
MTGCardInstance * cardsGrid[SCREEN_WIDTH/5][SCREEN_HEIGHT/5]; MTGCardInstance * cardsGrid[SCREEN_WIDTH/5][SCREEN_HEIGHT/5];
@@ -43,14 +44,14 @@ class MTGGuiPlay: public PlayGuiObjectController {
void adjustCardPosition(CardGui * cardg); void adjustCardPosition(CardGui * cardg);
public: public:
CardGui * getByCard(MTGCardInstance * card); CardGui * getByCard(MTGCardInstance * card);
MTGGuiPlay(int id, GameObserver * game); MTGGuiPlay(GameObserver * game);
~MTGGuiPlay(); ~MTGGuiPlay();
void Update(float dt); void Update(float dt);
bool CheckUserInput(u32 key); bool CheckUserInput(u32 key);
virtual void Render(); virtual void Render();
void forceUpdateCards(); void forceUpdateCards();
void updateCards(); void updateCards();
int receiveEvent(WEvent * e); int receiveEventPlus(WEvent * e);
}; };
+1 -1
View File
@@ -14,7 +14,7 @@ class Phase{
public: public:
int id; int id;
Player * player; Player * player;
Phase(int _id, Player * _player):id(_id),player(_player){}; Phase(int id, Player *player):id(id),player(player){};
}; };
class PhaseRing{ class PhaseRing{
+8 -51
View File
@@ -11,12 +11,11 @@
#define GUI_LIBRARY 4 #define GUI_LIBRARY 4
#include <JGui.h> #include <JGui.h>
#include "Effects.h"
#include "WEvent.h"
#include "Pos.h"
class MTGGameZone; class PlayGuiObject: public JGuiObject, public JGuiListener, public Pos{
class Player;
class CardDisplay;
class PlayGuiObject: public JGuiObject, public JGuiListener{
protected: protected:
public: public:
@@ -24,59 +23,17 @@ class PlayGuiObject: public JGuiObject, public JGuiListener{
float mHeight; float mHeight;
float defaultHeight; float defaultHeight;
bool mHasFocus; bool mHasFocus;
int x;
int y;
int type; int type;
virtual void Entering(){mHasFocus = true;}; virtual void Entering(){mHasFocus = true;};
virtual bool Leaving(u32 key){mHasFocus = false;return true;}; virtual bool Leaving(u32 key){mHasFocus = false;return true;};
virtual bool ButtonPressed(){return true;}; virtual bool ButtonPressed(){return true;};
virtual void Render(){}; virtual void Render();
virtual void Update(float dt); virtual void Update(float dt);
PlayGuiObject(int id, float desiredHeight,float _x, float _y, bool hasFocus); PlayGuiObject(float desiredHeight, float x, float y, bool hasFocus);
PlayGuiObject(float desiredHeight, const Pos& ref, bool hasFocus);
virtual void ButtonPressed(int controllerId, int controlId){}; virtual void ButtonPressed(int controllerId, int controlId){};
virtual ~PlayGuiObject(){}; virtual ~PlayGuiObject(){};
vector<Effect*> effects;
}; };
class GuiAvatar: public PlayGuiObject{
protected:
int avatarRed;
int currentLife;
public:
Player * player;
virtual void Render();
GuiAvatar(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * _player);
virtual ostream& toString(ostream& out) const;
};
class GuiGameZone: public PlayGuiObject{
protected:
MTGGameZone * zone;
public:
CardDisplay * cd;
int showCards;
virtual void Render();
virtual void Update(float dt);
GuiGameZone(int id, float desiredHeight,float _x, float _y, bool hasFocus,MTGGameZone * _zone);
~GuiGameZone();
virtual void ButtonPressed(int controllerId, int controlId);
void toggleDisplay();
virtual ostream& toString(ostream& out) const;
};
class GuiGraveyard: public GuiGameZone{
public:
GuiGraveyard(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * player);
virtual ostream& toString(ostream& out) const;
};
class GuiLibrary: public GuiGameZone{
public:
GuiLibrary(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * player);
virtual ostream& toString(ostream& out) const;
};
#endif #endif
@@ -14,7 +14,7 @@ class PlayGuiObjectController : public GuiLayer{
public: public:
virtual void Update(float dt); virtual void Update(float dt);
virtual bool CheckUserInput(u32 key); virtual bool CheckUserInput(u32 key);
PlayGuiObjectController(int id, GameObserver* _game):GuiLayer(id, _game){last_user_move=0;}; PlayGuiObjectController(){last_user_move=0;};
virtual void Render(){GuiLayer::Render();}; virtual void Render(){GuiLayer::Render();};
}; };
+3 -3
View File
@@ -17,14 +17,14 @@ class Player: public Damageable{
public: public:
virtual void End(); virtual void End();
int typeAsTarget(){return TARGET_PLAYER;} int typeAsTarget(){return TARGET_PLAYER;}
const char * getDisplayName(); const string getDisplayName();
virtual int displayStack(){return 1;} virtual int displayStack(){return 1;}
JTexture * mAvatarTex; JTexture * mAvatarTex;
JQuad * mAvatar; JQuad * mAvatar;
int canPutLandsIntoPlay; int canPutLandsIntoPlay;
MTGPlayerCards * game; MTGPlayerCards * game;
int afterDamage(); int afterDamage();
Player(MTGPlayerCards * _deck, string deckFile, string deckFileSmall); Player(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
virtual ~Player(); virtual ~Player();
void unTapPhase(); void unTapPhase();
MTGInPlay * inPlay(); MTGInPlay * inPlay();
@@ -41,7 +41,7 @@ class Player: public Damageable{
class HumanPlayer: public Player{ class HumanPlayer: public Player{
public: public:
HumanPlayer(MTGPlayerCards * _deck, char * _deckFile, string _deckFileSmall); HumanPlayer(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
}; };
+13 -15
View File
@@ -44,7 +44,7 @@ class TargetChooser: public TargetsList {
int ForceTargetListReady(); int ForceTargetListReady();
int targetsReadyCheck(); int targetsReadyCheck();
virtual int addTarget(Targetable * target); virtual int addTarget(Targetable * target);
virtual int canTarget(Targetable * _target); virtual bool canTarget(Targetable * _target);
virtual int full(){if (maxtargets != -1 && cursor>=maxtargets) {return 1;} else{return 0;}}; virtual int full(){if (maxtargets != -1 && cursor>=maxtargets) {return 1;} else{return 0;}};
virtual int ready(){return cursor;}; virtual int ready(){return cursor;};
virtual ~TargetChooser(){}; virtual ~TargetChooser(){};
@@ -61,7 +61,6 @@ class TargetChooserFactory{
}; };
class TargetZoneChooser:public TargetChooser{ class TargetZoneChooser:public TargetChooser{
public: public:
int zones[10]; int zones[10];
@@ -70,16 +69,15 @@ class TargetZoneChooser:public TargetChooser{
int targetsZone(MTGGameZone * z); int targetsZone(MTGGameZone * z);
TargetZoneChooser(MTGCardInstance * card = NULL, int _maxtargets = 1); TargetZoneChooser(MTGCardInstance * card = NULL, int _maxtargets = 1);
TargetZoneChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1); TargetZoneChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
virtual int canTarget(Targetable * _card); virtual bool canTarget(Targetable * _card);
}; };
class CardTargetChooser:public TargetZoneChooser { class CardTargetChooser:public TargetZoneChooser {
protected: protected:
MTGCardInstance * validTarget; MTGCardInstance * validTarget;
public: public:
CardTargetChooser(MTGCardInstance * _card, MTGCardInstance * source,int * _zones = NULL, int _nbzones = 0); CardTargetChooser(MTGCardInstance * card, MTGCardInstance * source, int * zones = NULL, int nbzones = 0);
virtual int canTarget(Targetable * target ); virtual bool canTarget(Targetable * target);
}; };
@@ -89,7 +87,7 @@ class CreatureTargetChooser:public TargetZoneChooser{
int maxtoughness; int maxtoughness;
CreatureTargetChooser(int * _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1); CreatureTargetChooser(int * _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1);
CreatureTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1); CreatureTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1);
virtual int canTarget(Targetable * _card); virtual bool canTarget(Targetable * _card);
}; };
@@ -98,7 +96,7 @@ class DamageableTargetChooser:public CreatureTargetChooser{
public: public:
DamageableTargetChooser(int * _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1):CreatureTargetChooser( _zones,_nbzones, card, _maxtargets){}; DamageableTargetChooser(int * _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1):CreatureTargetChooser( _zones,_nbzones, card, _maxtargets){};
DamageableTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1):CreatureTargetChooser(card, _maxtargets){}; DamageableTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1):CreatureTargetChooser(card, _maxtargets){};
virtual int canTarget(Targetable * target); virtual bool canTarget(Targetable * target);
}; };
@@ -107,7 +105,7 @@ protected:
Player * p; //In Case we can only target a specific player Player * p; //In Case we can only target a specific player
public: public:
PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, Player *_p = NULL); PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, Player *_p = NULL);
virtual int canTarget(Targetable * target); virtual bool canTarget(Targetable * target);
}; };
class TypeTargetChooser:public TargetZoneChooser{ class TypeTargetChooser:public TargetZoneChooser{
@@ -118,7 +116,7 @@ class TypeTargetChooser:public TargetZoneChooser{
TypeTargetChooser(const char * _type, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1); TypeTargetChooser(const char * _type, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
void addType(int type); void addType(int type);
void addType(const char * type); void addType(const char * type);
virtual int canTarget(Targetable * targe); virtual bool canTarget(Targetable * targe);
}; };
class DescriptorTargetChooser:public TargetZoneChooser{ class DescriptorTargetChooser:public TargetZoneChooser{
@@ -126,7 +124,7 @@ class DescriptorTargetChooser:public TargetZoneChooser{
CardDescriptor * cd; CardDescriptor * cd;
DescriptorTargetChooser(CardDescriptor * _cd, MTGCardInstance * card = NULL, int _maxtargets = 1); DescriptorTargetChooser(CardDescriptor * _cd, MTGCardInstance * card = NULL, int _maxtargets = 1);
DescriptorTargetChooser(CardDescriptor * _cd, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1); DescriptorTargetChooser(CardDescriptor * _cd, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
virtual int canTarget(Targetable * target); virtual bool canTarget(Targetable * target);
~DescriptorTargetChooser(); ~DescriptorTargetChooser();
}; };
@@ -135,14 +133,14 @@ class SpellTargetChooser:public TargetChooser{
public: public:
int color; int color;
SpellTargetChooser( MTGCardInstance * card = NULL,int _color = -1, int _maxtargets = 1 ); SpellTargetChooser( MTGCardInstance * card = NULL,int _color = -1, int _maxtargets = 1 );
virtual int canTarget(Targetable * target); virtual bool canTarget(Targetable * target);
}; };
class SpellOrPermanentTargetChooser:public TargetZoneChooser{ class SpellOrPermanentTargetChooser:public TargetZoneChooser{
public: public:
int color; int color;
SpellOrPermanentTargetChooser(MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1); SpellOrPermanentTargetChooser(MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1);
virtual int canTarget(Targetable * target); virtual bool canTarget(Targetable * target);
}; };
@@ -152,13 +150,13 @@ class DamageTargetChooser:public TargetChooser{
int color; int color;
int state; int state;
DamageTargetChooser( MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1, int state = NOT_RESOLVED); DamageTargetChooser( MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1, int state = NOT_RESOLVED);
virtual int canTarget(Targetable * target); virtual bool canTarget(Targetable * target);
}; };
class DamageOrPermanentTargetChooser:public TargetZoneChooser{ class DamageOrPermanentTargetChooser:public TargetZoneChooser{
public: public:
int color; int color;
DamageOrPermanentTargetChooser(MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1); DamageOrPermanentTargetChooser(MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1);
virtual int canTarget(Targetable * target); virtual bool canTarget(Targetable * target);
}; };
#endif #endif
+1 -1
View File
@@ -8,7 +8,7 @@
class Targetable{ class Targetable{
public: public:
virtual int typeAsTarget() = 0; virtual int typeAsTarget() = 0;
virtual const char * getDisplayName() =0; virtual const string getDisplayName() = 0;
}; };
#endif #endif
+1 -2
View File
@@ -43,7 +43,6 @@ class TexturesCache{
int nb_textures; int nb_textures;
int delete_previous; int delete_previous;
int totalsize; int totalsize;
int maxSize;
CardTexture * cache[MAX_CACHE_OBJECTS]; CardTexture * cache[MAX_CACHE_OBJECTS];
public: public:
int isInCache(MTGCard * card, int type=CACHE_CARD); int isInCache(MTGCard * card, int type=CACHE_CARD);
@@ -55,8 +54,8 @@ class TexturesCache{
int getCacheById(int id, int type=CACHE_CARD); int getCacheById(int id, int type=CACHE_CARD);
JQuad * getQuad(MTGCard * card, int type=CACHE_CARD); JQuad * getQuad(MTGCard * card, int type=CACHE_CARD);
JQuad * getThumb(MTGCard * card){return getQuad(card, CACHE_THUMB);}; JQuad * getThumb(MTGCard * card){return getQuad(card, CACHE_THUMB);};
}; };
extern TexturesCache cache;
class SampleCached{ class SampleCached{
+27 -23
View File
@@ -16,44 +16,39 @@ public:
CHANGE_PHASE = 3, CHANGE_PHASE = 3,
}; };
int type; //Deprecated, use dynamic casting instead int type; //Deprecated, use dynamic casting instead
WEvent(int _type = NOT_SPECIFIED); WEvent(int type = NOT_SPECIFIED);
virtual ~WEvent() {}; virtual ~WEvent() {};
}; };
class WEventZoneChange: public WEvent{ struct WEventZoneChange: public WEvent{
public:
MTGCardInstance * card; MTGCardInstance * card;
MTGGameZone * from; MTGGameZone * from;
MTGGameZone * to; MTGGameZone * to;
WEventZoneChange(MTGCardInstance * _card, MTGGameZone * _from, MTGGameZone *_to); WEventZoneChange(MTGCardInstance * card, MTGGameZone * from, MTGGameZone *to);
virtual ~WEventZoneChange() {}; virtual ~WEventZoneChange() {};
}; };
class WEventDamage: public WEvent{ struct WEventDamage: public WEvent{
public:
Damage * damage; Damage * damage;
WEventDamage(Damage * _damage); WEventDamage(Damage * damage);
}; };
class WEventPhaseChange: public WEvent{ struct WEventPhaseChange: public WEvent{
public:
Phase * from; Phase * from;
Phase * to; Phase * to;
WEventPhaseChange(Phase * _from, Phase * _to); WEventPhaseChange(Phase * from, Phase * to);
}; };
//Abstract class of event when a card's status changes //Abstract class of event when a card's status changes
class WEventCardUpdate: public WEvent{ struct WEventCardUpdate: public WEvent{
public:
MTGCardInstance * card; MTGCardInstance * card;
WEventCardUpdate(MTGCardInstance * card):WEvent(),card(card){}; WEventCardUpdate(MTGCardInstance * card);
}; };
//Event when a card is tapped/untapped //Event when a card is tapped/untapped
class WEventCardTap: public WEventCardUpdate{ struct WEventCardTap: public WEventCardUpdate{
public:
bool before; bool before;
bool after; bool after;
WEventCardTap(MTGCardInstance * card, bool before, bool after); WEventCardTap(MTGCardInstance * card, bool before, bool after);
@@ -62,35 +57,44 @@ public:
//Event when a card's "attacker" status changes //Event when a card's "attacker" status changes
//before:Player/Planeswalker that card was attacking previously //before:Player/Planeswalker that card was attacking previously
//after: Player/Planeswalker that card is attacking now //after: Player/Planeswalker that card is attacking now
class WEventCreatureAttacker: public WEventCardUpdate{ struct WEventCreatureAttacker: public WEventCardUpdate{
public:
Targetable * before; Targetable * before;
Targetable * after; Targetable * after;
WEventCreatureAttacker(MTGCardInstance * card, Targetable * from, Targetable * to); WEventCreatureAttacker(MTGCardInstance * card, Targetable * from, Targetable * to);
}; };
//Event when a card's "defenser" status changes //Event when a card's "defenser" status changes
//before : attacker that card was blocking previously //before : attacker that card was blocking previously
//after: attacker that card is blocking now //after: attacker that card is blocking now
class WEventCreatureBlocker: public WEventCardUpdate{ struct WEventCreatureBlocker: public WEventCardUpdate{
public:
MTGCardInstance * before; MTGCardInstance * before;
MTGCardInstance * after; MTGCardInstance * after;
WEventCreatureBlocker(MTGCardInstance * card,MTGCardInstance * from,MTGCardInstance * to); WEventCreatureBlocker(MTGCardInstance * card,MTGCardInstance * from,MTGCardInstance * to);
}; };
//Event when a blocker is reordered //Event when a blocker is reordered
//exchangeWith: exchange card's position with exchangeWith's position //exchangeWith: exchange card's position with exchangeWith's position
//attacker:both card and exchangeWith *should* be in attacker's "blockers" list. //attacker:both card and exchangeWith *should* be in attacker's "blockers" list.
class WEventCreatureBlockerRank: public WEventCardUpdate{ struct WEventCreatureBlockerRank: public WEventCardUpdate{
public:
MTGCardInstance * exchangeWith; MTGCardInstance * exchangeWith;
MTGCardInstance * attacker; MTGCardInstance * attacker;
WEventCreatureBlockerRank(MTGCardInstance * card,MTGCardInstance * exchangeWith, MTGCardInstance * attacker); WEventCreatureBlockerRank(MTGCardInstance * card,MTGCardInstance * exchangeWith, MTGCardInstance * attacker);
}; };
//Event when a mana is engaged
//color : color
struct WEventEngageMana : public WEvent {
int color;
MTGCardInstance* card;
WEventEngageMana(int color, MTGCardInstance* card);
};
//Event when a mana is consumed
//color : color
struct WEventConsumeMana : public WEvent {
int color;
WEventConsumeMana(int color);
};
#endif #endif
+7
View File
@@ -26,4 +26,11 @@
#define RESPATH "Res" #define RESPATH "Res"
#endif #endif
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#endif #endif
+1 -1
View File
@@ -9,7 +9,7 @@
MTGAbility * AIMomirPlayer::momirAbility = NULL; MTGAbility * AIMomirPlayer::momirAbility = NULL;
AIMomirPlayer::AIMomirPlayer(MTGPlayerCards * _deck, char * file, const char * fileSmall, char * avatarFile): AIPlayerBaka(_deck,file, fileSmall, avatarFile){ AIMomirPlayer::AIMomirPlayer(MTGPlayerCards * deck, string file, string fileSmall, string avatarFile) : AIPlayerBaka(deck, file, fileSmall, avatarFile) {
momirAbility = NULL; momirAbility = NULL;
agressivity = 100; agressivity = 100;
} }
+11 -10
View File
@@ -27,7 +27,7 @@ int AIAction::Act(){
return 0; return 0;
} }
AIPlayer::AIPlayer(MTGPlayerCards * _deck, string file, string fileSmall): Player(_deck, file, fileSmall){ AIPlayer::AIPlayer(MTGPlayerCards * deck, string file, string fileSmall) : Player(deck, file, fileSmall) {
potentialMana = NEW ManaCost(); potentialMana = NEW ManaCost();
nextCardToPlay = NULL; nextCardToPlay = NULL;
stats = NULL; stats = NULL;
@@ -245,7 +245,7 @@ int AIPlayer::selectAbility(){
} }
if (ranking.size()){ if (ranking.size()){
OutputDebugString("We have a winner\n"); OutputDebugString("We have a winrar\n");
AIAction * a = ranking.begin()->first; AIAction * a = ranking.begin()->first;
int chance = 1 + rand() % 100; int chance = 1 + rand() % 100;
if (getEfficiency(a) < chance){ if (getEfficiency(a) < chance){
@@ -491,11 +491,13 @@ int AIPlayer::chooseBlockers(){
int AIPlayer::orderBlockers(){ int AIPlayer::orderBlockers(){
GameObserver * g = GameObserver::GetInstance(); GameObserver * g = GameObserver::GetInstance();
/*
DamageResolverLayer * drl = g->mLayers->combatLayer(); DamageResolverLayer * drl = g->mLayers->combatLayer();
if (drl->orderingIsNeeded && g->currentPlayer==this){ if (drl->orderingIsNeeded && g->currentPlayer==this){
drl->blockersOrderingDone(); //TODO clever rank of blockers drl->blockersOrderingDone(); //TODO clever rank of blockers
return 1; return 1;
} }
*/
return 0; return 0;
} }
@@ -509,6 +511,7 @@ int AIPlayer::combatDamages(){
if (currentGamePhase == Constants::MTG_PHASE_COMBATBLOCKERS) return orderBlockers(); if (currentGamePhase == Constants::MTG_PHASE_COMBATBLOCKERS) return orderBlockers();
if (currentGamePhase != Constants::MTG_PHASE_COMBATDAMAGE) return 0; if (currentGamePhase != Constants::MTG_PHASE_COMBATDAMAGE) return 0;
/*
DamageResolverLayer * drl = gameObs->mLayers->combatLayer(); DamageResolverLayer * drl = gameObs->mLayers->combatLayer();
if (drl->currentChoosingPlayer == this){ if (drl->currentChoosingPlayer == this){
@@ -530,6 +533,7 @@ int AIPlayer::combatDamages(){
if (result) return drl->nextPlayer(); if (result) return drl->nextPlayer();
*/
return 0; return 0;
} }
@@ -621,12 +625,11 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * potentialMana, const c
return nextCardToPlay; return nextCardToPlay;
} }
AIPlayerBaka::AIPlayerBaka(MTGPlayerCards * _deck, char * file, const char * fileSmall, char * avatarFile): AIPlayer(_deck,file, fileSmall){ AIPlayerBaka::AIPlayerBaka(MTGPlayerCards * deck, string file, string fileSmall, string avatarFile) : AIPlayer(deck, file, fileSmall) {
if (fileExists(avatarFile)){ if (fileExists(avatarFile.c_str()))
mAvatarTex = JRenderer::GetInstance()->LoadTexture(avatarFile, TEX_TYPE_USE_VRAM); mAvatarTex = JRenderer::GetInstance()->LoadTexture(avatarFile.c_str(), TEX_TYPE_USE_VRAM);
}else{ else
mAvatarTex = JRenderer::GetInstance()->LoadTexture("ai/baka/avatar.jpg", TEX_TYPE_USE_VRAM); mAvatarTex = JRenderer::GetInstance()->LoadTexture("ai/baka/avatar.jpg", TEX_TYPE_USE_VRAM);
}
if (mAvatarTex) if (mAvatarTex)
mAvatar = NEW JQuad(mAvatarTex, 0, 0, 35, 50); mAvatar = NEW JQuad(mAvatarTex, 0, 0, 35, 50);
initTimer(); initTimer();
@@ -682,7 +685,7 @@ int AIPlayerBaka::computeActions(){
if (nextCardToPlay){ if (nextCardToPlay){
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
char buffe[4096]; char buffe[4096];
sprintf(buffe, "Putting Card Into Play: %s", nextCardToPlay->getName()); sprintf(buffe, "Putting Card Into Play: %s", nextCardToPlay->getName().c_str());
OutputDebugString(buffe); OutputDebugString(buffe);
#endif #endif
@@ -759,8 +762,6 @@ int AIPlayerBaka::Act(float dt){
SAFE_DELETE(action); SAFE_DELETE(action);
clickstream.pop(); clickstream.pop();
} }
return 1; return 1;
}; };
+5 -7
View File
@@ -67,16 +67,15 @@ void ActionLayer::Update(float dt){
return; return;
} }
modal = 0; modal = 0;
GameObserver * g = GameObserver::GetInstance(); GameObserver* game = GameObserver::GetInstance();
for (int i=mCount -1 ;i>=0;i--){ for (int i=mCount -1 ;i>=0;i--){
if (mObjects[i]!= NULL){ if (mObjects[i]!= NULL){
ActionElement * currentAction = (ActionElement *)mObjects[i]; ActionElement * currentAction = (ActionElement *)mObjects[i];
if (currentAction->testDestroy()){ if (currentAction->testDestroy())
g->removeObserver(currentAction); game->removeObserver(currentAction);
} }
} }
} int newPhase = game->getCurrentGamePhase();
int newPhase = g->getCurrentGamePhase();
for (int i=0;i<mCount;i++){ for (int i=0;i<mCount;i++){
if (mObjects[i]!=NULL){ if (mObjects[i]!=NULL){
ActionElement * currentAction = (ActionElement *)mObjects[i]; ActionElement * currentAction = (ActionElement *)mObjects[i];
@@ -138,7 +137,7 @@ int ActionLayer::stillInUse(MTGCardInstance * card){
return 0; return 0;
} }
int ActionLayer::receiveEvent(WEvent * event){ int ActionLayer::receiveEventPlus(WEvent * event){
int result = 0; int result = 0;
for (int i=0;i<mCount;i++){ for (int i=0;i<mCount;i++){
ActionElement * currentAction = (ActionElement *)mObjects[i]; ActionElement * currentAction = (ActionElement *)mObjects[i];
@@ -244,7 +243,6 @@ void ActionLayer::doReactTo(int menuIndex){
void ActionLayer::ButtonPressed(int controllerid, int controlid){ void ActionLayer::ButtonPressed(int controllerid, int controlid){
if (controlid == -1){ if (controlid == -1){
}else{ }else{
ActionElement * currentAction = (ActionElement *)mObjects[controlid]; ActionElement * currentAction = (ActionElement *)mObjects[controlid];
currentAction->reactToTargetClick(menuObject); currentAction->reactToTargetClick(menuObject);
+21 -26
View File
@@ -8,8 +8,8 @@
#include "../include/Damage.h" #include "../include/Damage.h"
#include "../include/ManaCost.h" #include "../include/ManaCost.h"
#include "../include/GameOptions.h" #include "../include/GameOptions.h"
#include "../include/TexturesCache.h"
#include "../include/TargetChooser.h" #include "../include/TargetChooser.h"
// WALDORF - added to support drawing big cards during interrupts
#include "../include/CardGui.h" #include "../include/CardGui.h"
#include "../include/Translate.h" #include "../include/Translate.h"
@@ -57,7 +57,7 @@ void StackAbility::Render(){
sprintf(buffer, "%s", _(ability->getMenuText()).c_str()); sprintf(buffer, "%s", _(ability->getMenuText()).c_str());
mFont->DrawString(buffer, x + 30 , y, JGETEXT_LEFT); mFont->DrawString(buffer, x + 30 , y, JGETEXT_LEFT);
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
JQuad * quad = ability->source->getThumb(); JQuad * quad = cache.getThumb(ability->source);
if (quad){ if (quad){
quad->SetColor(ARGB(255,255,255,255)); quad->SetColor(ARGB(255,255,255,255));
float scale = 30 / quad->mHeight; float scale = 30 / quad->mHeight;
@@ -115,7 +115,7 @@ Spell::Spell(int id, MTGCardInstance * _source, TargetChooser * tc, ManaCost * _
} }
const char * Spell::getDisplayName(){ const string Spell::getDisplayName(){
return source->getName(); return source->getName();
} }
@@ -136,7 +136,7 @@ int Spell::resolve(){
//Play SFX //Play SFX
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME].getIntValue() > 0){ if (options[Options::SFXVOLUME].number > 0){
JSample * sample = source->getSample(); JSample * sample = source->getSample();
if (sample){ if (sample){
JSoundSystem::GetInstance()->PlaySample(sample); JSoundSystem::GetInstance()->PlaySample(sample);
@@ -188,7 +188,7 @@ void Spell::Render(){
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->DrawString(_(source->name).c_str(), x + 30 , y, JGETEXT_LEFT); mFont->DrawString(_(source->name).c_str(), x + 30 , y, JGETEXT_LEFT);
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
JQuad * quad = source->getThumb(); JQuad * quad = cache.getThumb(source);
if (quad){ if (quad){
quad->SetColor(ARGB(255,255,255,255)); quad->SetColor(ARGB(255,255,255,255));
float scale = mHeight / quad->mHeight; float scale = mHeight / quad->mHeight;
@@ -205,7 +205,7 @@ void Spell::Render(){
// just overwrites it. // just overwrites it.
// I stole the render code from RenderBig() in CardGUI.cpp // I stole the render code from RenderBig() in CardGUI.cpp
quad = source->getQuad(); quad = cache.getQuad(source);
if (quad){ if (quad){
quad->SetColor(ARGB(220,255,255,255)); quad->SetColor(ARGB(220,255,255,255));
float scale = 257.f / quad->mHeight; float scale = 257.f / quad->mHeight;
@@ -214,9 +214,9 @@ void Spell::Render(){
else else
{ {
MTGCard * mtgcard = source->model; MTGCard * mtgcard = source->model;
CardGui::alternateRender(mtgcard, NULL, 10 + 90 , 20 + 130, 0.0f,0.9f); // CardGui::alternateRender(mtgcard, NULL, 10 + 90 , 20 + 130, 0.0f,0.9f);
quad = source->getThumb(); quad = cache.getThumb(source);
if (quad){ if (quad){
float scale = 250 / quad->mHeight; float scale = 250 / quad->mHeight;
quad->SetColor(ARGB(40,255,255,255)); quad->SetColor(ARGB(40,255,255,255));
@@ -276,7 +276,7 @@ void PutInGraveyard::Render(){
mFont->DrawString(_("is exiled").c_str(), x + 30 , y, JGETEXT_LEFT); mFont->DrawString(_("is exiled").c_str(), x + 30 , y, JGETEXT_LEFT);
} }
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
JQuad * quad = card->getThumb(); JQuad * quad = cache.getThumb(card);
if (quad){ if (quad){
quad->SetColor(ARGB(255,255,255,255)); quad->SetColor(ARGB(255,255,255,255));
float scale = 30 / quad->mHeight; float scale = 30 / quad->mHeight;
@@ -332,9 +332,8 @@ int ActionStack::addAbility(MTGAbility * ability){
int result = addAction(stackAbility); int result = addAction(stackAbility);
if (!game->players[0]->isAI() && if (!game->players[0]->isAI() &&
ability->source->controller()==game->players[0] && ability->source->controller()==game->players[0] &&
GameOptions::GetInstance()->values[OPTIONS_INTERRUPTMYABILITIES].getIntValue() == 0){ 0 == options[Options::INTERRUPTMYABILITIES].number)
interruptDecision[0] = DONT_INTERRUPT; interruptDecision[0] = DONT_INTERRUPT;
}
return result; return result;
} }
@@ -390,9 +389,8 @@ Spell * ActionStack::addSpell(MTGCardInstance * _source, TargetChooser * tc, Man
addAction(spell); addAction(spell);
if (!game->players[0]->isAI() && if (!game->players[0]->isAI() &&
_source->controller()==game->players[0] && _source->controller()==game->players[0] &&
GameOptions::GetInstance()->values[OPTIONS_INTERRUPTMYSPELLS].getIntValue() == 0){ 0 == options[Options::INTERRUPTMYSPELLS].number)
interruptDecision[0] = DONT_INTERRUPT; interruptDecision[0] = DONT_INTERRUPT;
}
return spell; return spell;
} }
@@ -403,10 +401,9 @@ Interruptible * ActionStack::getAt(int id){
return (Interruptible *)mObjects[id]; return (Interruptible *)mObjects[id];
} }
ActionStack::ActionStack(int id, GameObserver* _game):GuiLayer(id, _game){ ActionStack::ActionStack(GameObserver* 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;
timer = -1; timer = -1;
currentState = -1; currentState = -1;
@@ -644,9 +641,9 @@ void ActionStack::Update(float dt){
// WALDORF - added code to use a game option setting to determine how // WALDORF - added code to use a game option setting to determine how
// long the Interrupt timer should be. If it is set to zero (0), the // long the Interrupt timer should be. If it is set to zero (0), the
// game will wait for ever for the user to make a selection. // game will wait for ever for the user to make a selection.
if (GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue() > 0) if (options[Options::INTERRUPT_SECONDS].number > 0)
{ {
if (timer < 0) timer = GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue(); if (timer < 0) timer = options[Options::INTERRUPT_SECONDS].number;
timer -= dt; timer -= dt;
if (timer < 0) cancelInterruptOffer(); if (timer < 0) cancelInterruptOffer();
} }
@@ -736,7 +733,7 @@ bool ActionStack::CheckUserInput(u32 key){
return true; //Steal the input to other layers if we're visible return true; //Steal the input to other layers if we're visible
} }
if (PSP_CTRL_TRIANGLE == key){ if (PSP_CTRL_TRIANGLE == key){
if (modal) {modal = 0;} else {modal = 1;} if (modal) modal = 0; else modal = 1;
return true; return true;
} }
} }
@@ -753,13 +750,12 @@ int ActionStack::CombatDamages(){
} }
int ActionStack::CombatDamages(int strike){ int ActionStack::CombatDamages(int strike){
DamageStack * damages = NEW DamageStack(mCount,game); DamageStack * damages = NEW DamageStack(game);
int damageitems = damages->CombatDamages(strike); int damageitems = damages->CombatDamages(strike);
if (damageitems){ if (damageitems)
addAction(damages); addAction(damages);
}else{ else
SAFE_DELETE(damages); SAFE_DELETE(damages);
}
return damageitems; return damageitems;
} }
@@ -773,10 +769,9 @@ while( iter != mObjects.end() ){
iter = mObjects.erase( iter ) ; iter = mObjects.erase( iter ) ;
mCount--; mCount--;
SAFE_DELETE(current); SAFE_DELETE(current);
}else { } else
++iter; ++iter;
} }
}
return 1; return 1;
} }
@@ -842,7 +837,7 @@ void ActionStack::Render(){
// WALDORF - changed "interrupt ?" to "Interrupt?". Don't display count down // WALDORF - changed "interrupt ?" to "Interrupt?". Don't display count down
// seconds if the user disables auto progressing interrupts by setting the seconds // seconds if the user disables auto progressing interrupts by setting the seconds
// value to zero in Options. // value to zero in Options.
if (GameOptions::GetInstance()->values[OPTIONS_INTERRUPT_SECONDS].getIntValue() == 0) if (options[Options::INTERRUPT_SECONDS].number == 0)
sprintf(buffer, _("Interrupt?").c_str()); sprintf(buffer, _("Interrupt?").c_str());
else else
sprintf(buffer, "%s %i", _("Interrupt?").c_str(),static_cast<int>(timer)); sprintf(buffer, "%s %i", _("Interrupt?").c_str(),static_cast<int>(timer));
+1 -1
View File
@@ -45,7 +45,7 @@ void UntapBlocker::Update(float dt){
_target->getUntapBlockers()->Add(this); _target->getUntapBlockers()->Add(this);
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
char buf[4096]; char buf[4096];
sprintf(buf, "Adding Blocker to %s \n", _target->model->getName()); sprintf(buf, "Adding Blocker to %s \n", _target->model->getName().c_str());
OutputDebugString(buf); OutputDebugString(buf);
#endif #endif
} }
+6 -6
View File
@@ -4,7 +4,7 @@
#include "../include/TargetChooser.h" #include "../include/TargetChooser.h"
#include "../include/MTGGameZones.h" #include "../include/MTGGameZones.h"
CardDisplay::CardDisplay():PlayGuiObjectController(0, GameObserver::GetInstance()){ CardDisplay::CardDisplay() : mId(0), game(GameObserver::GetInstance()) {
tc = NULL; tc = NULL;
listener = NULL; listener = NULL;
nb_displayed_items = 7; nb_displayed_items = 7;
@@ -13,7 +13,7 @@ CardDisplay::CardDisplay():PlayGuiObjectController(0, GameObserver::GetInstance(
y= 0; y= 0;
} }
CardDisplay::CardDisplay(int id, GameObserver* _game, int _x, int _y, JGuiListener * _listener, TargetChooser * _tc, int _nb_displayed_items ):PlayGuiObjectController(id, _game), x(_x), y(_y){ 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) {
tc = _tc; tc = _tc;
listener = _listener; listener = _listener;
nb_displayed_items = _nb_displayed_items; nb_displayed_items = _nb_displayed_items;
@@ -22,7 +22,7 @@ CardDisplay::CardDisplay(int id, GameObserver* _game, int _x, int _y, JGuiListen
void CardDisplay::AddCard(MTGCardInstance * _card){ void CardDisplay::AddCard(MTGCardInstance * _card){
CardGui * card = NEW CardGui(mCount, _card, 40, x + 5 + (mCount - start_item) * 30, y + 5, (mCount == 0)); CardGui * card = NEW CardView(_card, x + 5 + (mCount - start_item) * 30, y + 5);
Add(card); Add(card);
} }
@@ -75,7 +75,7 @@ bool CardDisplay::CheckUserInput(u32 key){
tc->toggleTarget(cardg->card); tc->toggleTarget(cardg->card);
return true; return true;
}else{ }else{
if (game) game->ButtonPressed(mId, cardg); if (game) game->ButtonPressed(cardg);
return true; return true;
} }
} }
@@ -140,7 +140,7 @@ void CardDisplay::Render(){
if (mCount && mObjects[mCurr] != NULL){ if (mCount && mObjects[mCurr] != NULL){
mObjects[mCurr]->Render(); mObjects[mCurr]->Render();
CardGui * cardg = ((CardGui *)mObjects[mCurr]); CardGui * cardg = ((CardGui *)mObjects[mCurr]);
cardg->RenderBig(-1,-1,showBigCards-1); // cardg->RenderBig(-1,-1,showBigCards-1);
} }
} }
@@ -149,7 +149,7 @@ ostream& CardDisplay::toString(ostream& out) const
return (out << "CardDisplay ::: x,y : " << x << "," << y << " ; start_item : " << start_item << " ; nb_displayed_items " << nb_displayed_items << " ; tc : " << tc << " ; listener : " << listener); return (out << "CardDisplay ::: x,y : " << x << "," << y << " ; start_item : " << start_item << " ; nb_displayed_items " << nb_displayed_items << " ; tc : " << tc << " ; listener : " << listener);
} }
DefaultTargetDisplay::DefaultTargetDisplay(int id, GameObserver* _game, int _x, int _y,JGuiListener * _listener, int _nb_displayed_items ):CardDisplay(id, _game, _x, _y, _listener, NULL, _nb_displayed_items ){ DefaultTargetDisplay::DefaultTargetDisplay(int id, GameObserver* game, int x, int y, JGuiListener * listener, int nb_displayed_items ):CardDisplay(id, game, x, y, listener, NULL, nb_displayed_items ){
tc = NEW TargetChooser(); tc = NEW TargetChooser();
} }
+270 -154
View File
@@ -1,3 +1,4 @@
#include "JGE.h"
#include "../include/config.h" #include "../include/config.h"
#include "../include/CardGui.h" #include "../include/CardGui.h"
#include "../include/ManaCostHybrid.h" #include "../include/ManaCostHybrid.h"
@@ -6,6 +7,231 @@
#include "../include/MTGDefinitions.h" #include "../include/MTGDefinitions.h"
#include <Vector2D.h> #include <Vector2D.h>
CardGui::CardGui(MTGCardInstance* card, float x, float y) : PlayGuiObject(Height, x, y, false), quad(cache.getQuad(card)), card(card) {}
CardGui::CardGui(MTGCardInstance* card, const Pos& ref) : PlayGuiObject(Height, ref, false), quad(cache.getQuad(card)), card(card) {}
CardView::CardView(MTGCardInstance* card, float x, float y) : CardGui(card, x, y) {
card->view = this;
}
CardView::CardView(MTGCardInstance* card, const Pos& ref) : CardGui(card, ref) {
card->view = this;
}
void CardView::Update(float dt)
{
PlayGuiObject::Update(dt);
}
void CardView::Render()
{
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
JRenderer * renderer = JRenderer::GetInstance();
GameObserver * game = GameObserver::GetInstance();
TargetChooser * tc = NULL;
if (game) tc = game->getCurrentTargetChooser();
if (quad) {
const float scale = actZ * 40 / quad->mHeight;
renderer->RenderQuad(GameApp::CommonRes->GetQuad("shadow"), actX + (scale-1)*15, actY + (scale-1)*15, actT, 28*scale, 40*scale);
quad->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255));
renderer->RenderQuad(quad, actX, actY, actT, scale, scale);
}
else {
int color = card->getColor();
MTGCard * mtgcard = card->model;
const float scale = actZ;
renderer->RenderQuad(GameApp::CommonRes->GetQuad("shadow"), actX + (scale-1)*15, actY + (scale-1)*15, actT, 28*scale, 40*scale);
mFont->SetColor(ARGB(static_cast<unsigned char>(actA), 0, 0, 0));
JQuad * icon = NULL;
if (card->hasSubtype("plains"))
icon = GameApp::CommonRes->GetQuad("c_white");
else if (card->hasSubtype("swamp"))
icon = GameApp::CommonRes->GetQuad("c_black");
else if (card->hasSubtype("forest"))
icon = GameApp::CommonRes->GetQuad("c_green");
else if (card->hasSubtype("mountain"))
icon = GameApp::CommonRes->GetQuad("c_red");
else if (card->hasSubtype("island"))
icon = GameApp::CommonRes->GetQuad("c_blue");
if (icon) icon->SetHotSpot(16,16);
{
JQuad* q;
// Draw the "unknown" card model
switch(card->getColor())
{
case Constants::MTG_COLOR_GREEN: q = GameApp::CommonRes->GetQuad("green_thumb"); break;
case Constants::MTG_COLOR_BLUE : q = GameApp::CommonRes->GetQuad("blue_thumb"); break;
case Constants::MTG_COLOR_RED : q = GameApp::CommonRes->GetQuad("red_thumb"); break;
case Constants::MTG_COLOR_BLACK: q = GameApp::CommonRes->GetQuad("black_thumb"); break;
case Constants::MTG_COLOR_WHITE: q = GameApp::CommonRes->GetQuad("white_thumb"); break;
default: q = GameApp::CommonRes->GetQuad("black_thumb"); break;
}
q->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255));
renderer->RenderQuad(q, actX, actY, actT, scale, scale);
}
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE * 0.5 * actZ);
mFont->DrawString(card->getName().c_str(), actX - actZ * Width / 2 + 1, actY - actZ * Height / 2 + 1);
if (icon) { icon->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255)); renderer->RenderQuad(icon, actX, actY, 0); }
if (tc && !tc->canTarget(card)) renderer->FillRect(actX - actZ*Width/2, actY - actZ*Height/2, actZ*Width, actZ*Height, ARGB(200,0,0,0));
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
}
if (card->isCreature()){
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[200];
sprintf(buffer, "%i/%i",card->power,card->life);
renderer->FillRect(actX + 2, actY + 30 - 12, 25, 12, ARGB(((static_cast<unsigned char>(actA))/2),0,0,0));
mFont->SetColor(ARGB(static_cast<unsigned char>(actA),255,255,255));
mFont->DrawString(buffer, actX + 4, actY + 30 - 10);
}
PlayGuiObject::Render();
}
void CardGui::RenderBig(const Pos& pos){
JRenderer * renderer = JRenderer::GetInstance();
if (quad){
quad->SetColor(ARGB((int)pos.actA,255,255,255));
float scale = pos.actZ * 257.f / quad->mHeight;
renderer->RenderQuad(quad, pos.actX, pos.actY, pos.actT, scale, scale);
return;
}
JQuad * q;
if ((q = cache.getThumb(card)))
{
float scale = pos.actZ * 250 / q->mHeight;
q->SetColor(ARGB((int)pos.actA,255,255,255));
renderer->RenderQuad(q, pos.actX, pos.actY, pos.actT, scale, scale);
return;
}
// If we come here, we do not have the picture.
// Draw the "unknown" card model
MTGCard * mtgcard = card->model;
switch(card->getColor())
{
case Constants::MTG_COLOR_GREEN: q = GameApp::CommonRes->GetQuad("green"); break;
case Constants::MTG_COLOR_BLUE : q = GameApp::CommonRes->GetQuad("blue"); break;
case Constants::MTG_COLOR_RED : q = GameApp::CommonRes->GetQuad("red"); break;
case Constants::MTG_COLOR_BLACK: q = GameApp::CommonRes->GetQuad("black"); break;
case Constants::MTG_COLOR_WHITE: q = GameApp::CommonRes->GetQuad("white"); break;
default: q = GameApp::CommonRes->GetQuad("black"); break;
}
float scale = pos.actZ * 250 / q->mHeight;
q->SetColor(ARGB((int)pos.actA,255,255,255));
renderer->RenderQuad(q, pos.actX, pos.actY, pos.actT, scale, scale);
// Write the title
JLBFont * font = GameApp::CommonRes->GetJLBFont("graphics/magic");
float backup_scale = font->GetScale();
font->SetColor(ARGB((int)pos.actA, 0, 0, 0));
font->SetScale(0.8 * pos.actZ);
{
const char* name = _(card->getName()).c_str();
float w = font->GetStringWidth(name) * 0.8 * pos.actZ;
if (w > BigWidth - 30)
font->SetScale((BigWidth - 30) / w);
font->DrawString(name, pos.actX + 22 - BigWidth / 2, pos.actY + 22 - BigHeight / 2);
}
// Write the description
{
font->SetScale(0.8 * pos.actZ);
const std::vector<string> txt = card->formattedText();
unsigned i = 0;
for (std::vector<string>::const_iterator it = txt.begin(); it != txt.end(); ++it, ++i)
font->DrawString(it->c_str(), pos.actX + 22 - BigWidth / 2, pos.actY + 35 + 11 * i);
}
// Write the strength
if (card->isCreature())
{
char buffer[32];
sprintf(buffer, "%i/%i", card->power, card->life);
float w = font->GetStringWidth(buffer) * 0.8;
font->DrawString(buffer, pos.actX + 65 - w / 2, pos.actY + 106);
}
// Mana
{
ManaCost* manacost = card->getManaCost();
ManaCostHybrid* h;
unsigned int j = 0;
unsigned char t = (JGE::GetInstance()->GetTime() / 3) & 0xFF;
unsigned char v = t + 127;
while ((h = manacost->getHybridCost(j)))
{
float scale = pos.actZ * 0.05 * cosf(2*M_PI*((float)t)/256.0);
if (scale < 0)
{
renderer->RenderQuad(manaIcons[h->color1], pos.actX - 12 * j + 75 + 3 * sinf(2*M_PI*((float)t)/256.0), pos.actY - 115 + 3 * cosf(2*M_PI*((float)(t-35))/256.0), 0, 0.4 + scale, 0.4 + scale);
renderer->RenderQuad(manaIcons[h->color2], pos.actX - 12 * j + 75 + 3 * sinf(2*M_PI*((float)v)/256.0), pos.actY - 115 + 3 * cosf(2*M_PI*((float)(v-35))/256.0), 0, 0.4 - scale, 0.4 - scale);
}
else
{
renderer->RenderQuad(manaIcons[h->color2], pos.actX - 12 * j + 75 + 3 * sinf(2*M_PI*((float)v)/256.0), pos.actY - 115 + 3 * cosf(2*M_PI*((float)(v-35))/256.0), 0, 0.4 - scale, 0.4 - scale);
renderer->RenderQuad(manaIcons[h->color1], pos.actX - 12 * j + 75 + 3 * sinf(2*M_PI*((float)t)/256.0), pos.actY - 115 + 3 * cosf(2*M_PI*((float)(t-35))/256.0), 0, 0.4 + scale, 0.4 + scale);
}
++j;
}
for (int i = Constants::MTG_NB_COLORS - 2; i >= 1; --i)
{
for (int cost = manacost->getCost(i); cost > 0; --cost)
{
renderer->RenderQuad(manaIcons[i], pos.actX - 12*j + 75, pos.actY - 115, 0, 0.4 * pos.actZ, 0.4 * pos.actZ);
++j;
}
}
// Colorless mana
if (int cost = manacost->getCost(0))
{
char buffer[10];
sprintf(buffer, "%d", cost);
renderer->RenderQuad(manaIcons[0], pos.actX - 12*j + 75, pos.actY - 115, 0, 0.4 * pos.actZ, 0.4 * pos.actZ);
float w = font->GetStringWidth(buffer);
font->DrawString(buffer, pos.actX - 12*j + 76 - w/2, pos.actY - 120);
}
}
{
string s = "";
for (int i = card->nb_types - 1; i > 0; --i)
{
s += _(Subtypes::subtypesList->find(card->types[i]));
s += " - ";
}
s += _(Subtypes::subtypesList->find(card->types[0]));
font->DrawString(s.c_str(), pos.actX + 22 - BigWidth / 2, pos.actY + 17);
}
font->SetScale(backup_scale);
}
MTGCardInstance* CardView::getCard() { return card; }
TransientCardView::TransientCardView(MTGCardInstance* card, float x, float y) : CardView(card, x, y){}
TransientCardView::TransientCardView(MTGCardInstance* card, const Pos& ref) : CardView(card, ref.actX, ref.actY) {};
void TransientCardView::Render()
{
CardView::Render();
}
/*
void CardGui::alternateRender(MTGCard * card, JQuad ** manaIcons, float x, float y, float rotation, float scale){ void CardGui::alternateRender(MTGCard * card, JQuad ** manaIcons, float x, float y, float rotation, float scale){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAGIC_FONT); JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAGIC_FONT);
float backup = mFont->GetScale(); float backup = mFont->GetScale();
@@ -36,31 +262,6 @@ void CardGui::alternateRender(MTGCard * card, JQuad ** manaIcons, float x, float
mFont->SetScale(scale); mFont->SetScale(scale);
int color = card->getColor(); int color = card->getColor();
points[0].x = -width/2;
points[0].y = -height/2 ;
points[1].x = width/2;
points[1].y = -height/2;
points[2].x = width/2;
points[2].y = height/2;
points[3].x = -width/2;
points[3].y = height/2;
for (int i=0; i < 4; i++){
points[i].x *= scale;
points[i].y *= scale;
points[i].Rotate(rotation);
}
if (rotation == 0){
renderer->FillRoundRect(x+points[0].x + 2 ,y+points[0].y +2 ,width*scale-8,height*scale-8,2,ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color]));
renderer->FillRect(x+points[0].x + 6 ,y+points[0].y + 6 ,width*scale-12,height*scale-12,bgcolor2);
}else{
for (int i=0; i < 4; i++){
renderer->DrawLine(x + points[i].x,y + points[i].y,x + points[(i+1)%4].x,y + points[(i+1)%4].y,bgcolor);
}
}
ManaCost * manacost = card->getManaCost(); ManaCost * manacost = card->getManaCost();
int nbicons = 0; int nbicons = 0;
ManaCostHybrid * h; ManaCostHybrid * h;
@@ -110,77 +311,6 @@ void CardGui::alternateRender(MTGCard * card, JQuad ** manaIcons, float x, float
mFont->DrawString(buf,x+v.x,y+v.y); mFont->DrawString(buf,x+v.x,y+v.y);
} }
if (!card->formattedTextInit){
std::string s(card->getText());
s = _(s);
std::string::size_type found=s.find_first_of("{}");
while (found!=string::npos)
{
s[found]='/';
found=s.find_first_of("{}",found+1);
}
std::string::size_type len = 24;
while (s.length() > 0){
std::string::size_type cut = s.find_first_of("., \t)", 0);
if (cut >= len || cut == string::npos){
card->formattedText.push_back(s.substr(0,len));
if (s.length() > len){
s = s.substr(len,s.length()-len);
}else{
s = "";
}
}else{
std::string::size_type newcut = cut;
while (newcut < len && newcut != string::npos){
cut = newcut;
newcut = s.find_first_of("., \t)", newcut + 1);
}
card->formattedText.push_back(s.substr(0,cut+1));
if (s.length() > cut+1){
s = s.substr(cut+1,s.length() - cut - 1);
}else{
s = "";
}
}
}
card->formattedTextInit = 1;
}
for (std::vector<string>::size_type i=0; i < card->formattedText.size(); i++){
sprintf(buf, "%s", card->formattedText[i].c_str());
v.x = (-width/2 + 12 )*scale;
v.y = (50 + static_cast<signed int>(16*i - height/2)) * scale;
v.Rotate(rotation);
mFont->DrawString(buf,x+v.x,y+v.y);
}
v.x = ((-width/2)+10) * scale;
v.y = ((-height/2) + 25) * scale;
v.Rotate(rotation);
int over = strlen(_(card->getName()).c_str()) - 23;
float multiply = 1.4;
if (over > 0){
multiply = 1.1;
}
mFont->SetScale(scale * multiply);
mFont->SetColor(ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color]));
mFont->DrawString(_(card->getName()).c_str(),x+v.x,y+v.y);
mFont->SetScale(scale);
mFont->SetColor(ARGB(255,255,255,255));
if (card->isACreature()){
v.x = (width/2-40) * scale;
v.y = (height/2-30) * scale;
v.Rotate(rotation);
sprintf(buf,"%i/%i",card->power,card->toughness);
mFont->DrawString(buf,x+v.x,y+v.y);
}
for (int i = card->nb_types-1; i>=0; i--){ for (int i = card->nb_types-1; i>=0; i--){
v.x = ((-width/2)+10) * scale; v.x = ((-width/2)+10) * scale;
@@ -194,10 +324,13 @@ void CardGui::alternateRender(MTGCard * card, JQuad ** manaIcons, float x, float
} }
CardGui::CardGui(int id, MTGCardInstance * _card, float desiredHeight,float _x, float _y, bool hasFocus): PlayGuiObject(id, desiredHeight, _x, _y, hasFocus){ CardGui::CardGui(int id, MTGCardInstance * _card, float desiredHeight, float x, float y, bool hasFocus): PlayGuiObject(id, desiredHeight, x, y, hasFocus){
LOG("==Creating NEW CardGui Object. CardName:"); LOG("==Creating NEW CardGui Object. CardName:");
LOG(_card->getName()); LOG(_card->getName());
actX = x;
actY = y;
card = _card; card = _card;
type = GUI_CARD; type = GUI_CARD;
@@ -227,7 +360,7 @@ void CardGui::Update(float dt){
if (card->changedZoneRecently > 0) alpha = 255.f - 255.f * card->changedZoneRecently; if (card->changedZoneRecently > 0) alpha = 255.f - 255.f * card->changedZoneRecently;
if (mParticleSys && card->changedZoneRecently == 1.f){ if (mParticleSys && card->changedZoneRecently == 1.f){
mParticleSys->MoveTo(x+15, y+2*mHeight/3); mParticleSys->MoveTo(actX + 15, actY + 2 * mHeight / 3);
mParticleSys->Fire(); mParticleSys->Fire();
} }
if (card->changedZoneRecently){ if (card->changedZoneRecently){
@@ -242,29 +375,11 @@ void CardGui::Update(float dt){
mParticleSys = NULL; mParticleSys = NULL;
} }
} }
PlayGuiObject::Update(dt);
}
void CardGui::RenderBig(float xpos, float ypos, int alternate){ actX += 10 * dt * (x - actX);
JQuad * quad = NULL; actY += 10 * dt * (y - actY);
JRenderer * renderer = JRenderer::GetInstance();
if (xpos == -1){ PlayGuiObject::Update(dt);
xpos = 300;
if (x > SCREEN_WIDTH / 2)
xpos = 10;
}
if(ypos == -1)
ypos = 20;
if (!alternate){
quad = card->getQuad();
if (quad){
quad->SetColor(ARGB(220,255,255,255));
float scale = 257.f / quad->mHeight;
renderer->RenderQuad(quad, xpos , ypos , 0.0f,scale,scale);
}else{
quad = card->getThumb();
alternate = 1;
}
} }
@@ -303,40 +418,32 @@ void CardGui::Render(){
GameObserver * game = GameObserver::GetInstance(); GameObserver * game = GameObserver::GetInstance();
TargetChooser * tc = NULL; TargetChooser * tc = NULL;
if (game) tc = game->getCurrentTargetChooser(); if (game) tc = game->getCurrentTargetChooser();
float myX = x + (32 * tap * mScale); float myX = actX + (32 * tap * mScale);
float myY = y+(20 * tap * mScale); float myY = actY + (20 * tap * mScale);
if (quad){ if (quad){
mScale = mHeight / quad->mHeight; mScale = mHeight / quad->mHeight;
myH = mHeight; myH = mHeight;
myW = quad->mWidth * mScale; myW = quad->mWidth * mScale;
myX = x + (quad->mHeight/2 * tap * mScale); myX = actX + (quad->mHeight/2 * tap * mScale);
myY = y+(quad->mWidth/2 * tap * mScale); myY = actY + (quad->mWidth/2 * tap * mScale);
} }
if (mHeight-defaultHeight){ if (mHeight-defaultHeight){
if (card->isTapped()){ if (card->isTapped())
renderer->FillRect(myX + 1 * (mHeight - defaultHeight) - myH, myY + 1 * (mHeight - defaultHeight), myH, myW, ARGB(128,0,0,0)); renderer->FillRect(myX + 1 * (mHeight - defaultHeight) - myH, myY + 1 * (mHeight - defaultHeight), myH, myW, ARGB(128,0,0,0));
}else{ else
renderer->FillRect(myX + 1 * (mHeight - defaultHeight), myY + 1 * (mHeight-defaultHeight), myW, myH, ARGB(128,0,0,0)); renderer->FillRect(myX + 1 * (mHeight - defaultHeight), myY + 1 * (mHeight-defaultHeight), myW, myH, ARGB(128,0,0,0));
} }
}
if(quad){ if(quad){
quad->SetColor(ARGB(alpha, 255, 255, 255)); quad->SetColor(ARGB(alpha, 255, 255, 255));
if (tc){ if (tc && !tc->canTarget(card)) quad->SetColor(ARGB(alpha, 50, 50, 50));
if (!tc->canTarget(card)){
quad->SetColor(ARGB( alpha,50,50,50));
}
}
renderer->RenderQuad(quad, myX, myY ,rotation, mScale, mScale); renderer->RenderQuad(quad, myX, myY ,rotation, mScale, mScale);
quad->SetColor(ARGB(alpha, 255, 255, 255)); quad->SetColor(ARGB(alpha, 255, 255, 255));
}else{ }else{
int color = card->getColor(); int color = card->getColor();
char buffer[200]; char buffer[200];
sprintf(buffer, "%s",card->getName()); sprintf(buffer, "%s",card->getName());
mFont->SetColor(ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color])); mFont->SetColor(ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color]));
@@ -355,46 +462,39 @@ void CardGui::Render(){
} }
if (mIcon) mIcon->SetHotSpot(16,16); if (mIcon) mIcon->SetHotSpot(16,16);
if (card->isTapped()){ if (card->isTapped()){
renderer->FillRect(myX - myH , myY , myH, myW, ARGB(255,(Constants::_r[color]) /2 + 50,(Constants::_g[color]) /2 + 50,(Constants::_b[color])/ 2 + 50)); renderer->FillRect(myX - myH, myY, myH, myW, ARGB(255,Constants::_r[color]/2+50,Constants::_g[color]/2+50,Constants::_b[color]/2+50));
renderer->DrawRect(myX - myH, myY, myH, myW, ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color])); renderer->DrawRect(myX - myH, myY, myH, myW, ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color]));
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE * 0.8 * mScale); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE * 0.8 * mScale);
mFont->DrawString(buffer,myX - myH + 4, myY + 1); mFont->DrawString(buffer, myX - (myH) + 4, myY + 1);
if (mIcon) renderer->RenderQuad(mIcon, myX - myH / 2,myY + myW / 2, M_PI_2, mScale, mScale); if (mIcon) renderer->RenderQuad(mIcon, myX - myH / 2,myY + myW / 2, M_PI_2, mScale, mScale);
if (tc){ if (tc && !tc->canTarget(card))
if (!tc->canTarget(card)){
renderer->FillRect(myX - myH, myY, myH, myW, ARGB(200,0,0,0)); renderer->FillRect(myX - myH, myY, myH, myW, ARGB(200,0,0,0));
}
}
}else{ }else{
renderer->FillRect(myX , myY , myW, myH, ARGB(255,(Constants::_r[color]) /2 + 50,(Constants::_g[color]) /2 + 50,(Constants::_b[color]) /2 + 50)); renderer->FillRect(myX, myY , myW, myH, ARGB(255,Constants::_r[color]/2+50,Constants::_g[color]/2+50,Constants::_b[color]/2+50));
renderer->DrawRect(myX, myY , myW, myH, ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color])); renderer->DrawRect(myX, myY , myW, myH, ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color]));
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE * 0.5 * mScale); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE * 0.5 * mScale);
mFont->DrawString(buffer, myX + 4, myY + 1); mFont->DrawString(buffer, myX + 4, myY + 1);
if (mIcon) renderer->RenderQuad(mIcon,myX + myW/2, myY + myH / 2, 0, mScale, mScale); if (mIcon) renderer->RenderQuad(mIcon,myX + myW/2, myY + myH / 2, 0, mScale, mScale);
if (tc){ if (tc && !tc->canTarget(card))
if (!tc->canTarget(card)){
renderer->FillRect(myX, myY, myW, myH, ARGB(200,0,0,0)); renderer->FillRect(myX, myY, myW, myH, ARGB(200,0,0,0));
} }
}
}
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
} }
if (tc && tc->alreadyHasTarget(card)){ if (tc && tc->alreadyHasTarget(card)){
if (card->isTapped()){ if (card->isTapped())
renderer->FillRect(myX - myH, myY, myH, myW, ARGB(128,255,0,0)); renderer->FillRect(myX - myH, myY, myH, myW, ARGB(128,255,0,0));
}else{ else
renderer->FillRect(myX, myY, myW, myH, ARGB(128,255,0,0)); renderer->FillRect(myX, myY, myW, myH, ARGB(128,255,0,0));
} }
}
if (card->isACreature()){ if (card->isCreature()){
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[200]; char buffer[200];
sprintf(buffer, "%i/%i",card->power,card->life); sprintf(buffer, "%i/%i",card->power,card->life);
renderer->FillRect(x+2,y + mHeight - 12, 25 , 12 ,ARGB(128,0,0,0)); renderer->FillRect(actX + 2, actY + mHeight - 12, 25, 12, ARGB(128,0,0,0));
mFont->SetColor(ARGB(255,255,255,255)); mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(buffer,x+4,y + mHeight - 10); mFont->DrawString(buffer, actX + 4, actY + mHeight - 10);
} }
if (mParticleSys && card->changedZoneRecently > 0){ if (mParticleSys && card->changedZoneRecently > 0){
@@ -403,17 +503,33 @@ void CardGui::Render(){
// set normal blending // set normal blending
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA); renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
} }
PlayGuiObject::Render();
} }
float CardGui::Height()
{
return card->getQuad()->mHeight;
}
float CardGui::Width()
{
return card->getQuad()->mWidth;
}
CardGui::~CardGui(){ CardGui::~CardGui(){
LOG("==Destroying CardGui object"); LOG("==Destroying CardGui object");
LOG(this->card->getName()); LOG(this->card->getName());
LOG("==CardGui object destruction Successful"); LOG("==CardGui object destruction Successful");
} }
*/
ostream& CardView::toString(ostream& out) const
{
return (CardGui::toString(out) << " : CardView ::: card : " << card
<< "; actX,actY : " << actX << "," << actY << "; t : " << t
<< " ; actT : " << actT << " ; quad : " << quad);
}
ostream& CardGui::toString(ostream& out) const ostream& CardGui::toString(ostream& out) const
{ {
return (out << "CardGui ::: mParticleSys : " << mParticleSys << " ; alpha : " << alpha << " ; card : " << card); return (out << "CardGui ::: x,y " << x << "," << y);
} }
+19 -21
View File
@@ -42,11 +42,10 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
showMsg = (rand() % 5); showMsg = (rand() % 5);
GameObserver * g = GameObserver::GetInstance(); GameObserver * g = GameObserver::GetInstance();
if (!p1->isAI() && p2->isAI() && p1!= g->gameOver){ if (!p1->isAI() && p2->isAI() && p1!= g->gameOver){
GameOptions * go = GameOptions::GetInstance();
value = 400; value = 400;
if (app->gameType != GAME_TYPE_CLASSIC) value = 200; if (app->gameType != GAME_TYPE_CLASSIC) value = 200;
int difficulty = go->values[OPTIONS_DIFFICULTY].getIntValue(); int difficulty = options[Options::DIFFICULTY].number;
if (go->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue() && difficulty) { if (options[Options::DIFFICULTY_MODE_UNLOCKED].number && difficulty) {
CreditBonus * b = NEW CreditBonus(100*difficulty, _("Difficulty Bonus")); CreditBonus * b = NEW CreditBonus(100*difficulty, _("Difficulty Bonus"));
bonus.push_back(b); bonus.push_back(b);
} }
@@ -77,31 +76,31 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
if (unlocked){ if (unlocked){
unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/unlocked.png", TEX_TYPE_USE_VRAM); unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/unlocked.png", TEX_TYPE_USE_VRAM);
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96); unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED] = GameOption(1); options[Options::DIFFICULTY_MODE_UNLOCKED] = GameOption(1);
GameOptions::GetInstance()->save(); options.save();
} else if ((unlocked = isMomirUnlocked())) { } else if ((unlocked = isMomirUnlocked())) {
unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/momir_unlocked.png", TEX_TYPE_USE_VRAM); unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/momir_unlocked.png", TEX_TYPE_USE_VRAM);
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96); unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
GameOptions::GetInstance()->values[OPTIONS_MOMIR_MODE_UNLOCKED] = GameOption(1); options[Options::MOMIR_MODE_UNLOCKED] = GameOption(1);
GameOptions::GetInstance()->save(); options.save();
} else if ((unlocked = isEvilTwinUnlocked())) { } else if ((unlocked = isEvilTwinUnlocked())) {
unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/eviltwin_unlocked.png", TEX_TYPE_USE_VRAM); unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/eviltwin_unlocked.png", TEX_TYPE_USE_VRAM);
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96); unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
GameOptions::GetInstance()->values[OPTIONS_EVILTWIN_MODE_UNLOCKED] = GameOption(1); options[Options::EVILTWIN_MODE_UNLOCKED] = GameOption(1);
GameOptions::GetInstance()->save(); options.save();
}else if((unlocked = isRandomDeckUnlocked())) { }else if((unlocked = isRandomDeckUnlocked())) {
unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/randomdeck_unlocked.png", TEX_TYPE_USE_VRAM); unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/randomdeck_unlocked.png", TEX_TYPE_USE_VRAM);
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96); unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
GameOptions::GetInstance()->values[OPTIONS_RANDOMDECK_MODE_UNLOCKED] = GameOption(1); options[Options::RANDOMDECK_MODE_UNLOCKED] = GameOption(1);
GameOptions::GetInstance()->save(); options.save();
}else if((unlocked = unlockRandomSet())) { }else if((unlocked = unlockRandomSet())) {
unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/set_unlocked.png", TEX_TYPE_USE_VRAM); unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/set_unlocked.png", TEX_TYPE_USE_VRAM);
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96); unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
char buffer[4096]; char buffer[4096];
unlockedString = MtgSets::SetsList->values[unlocked -1]; unlockedString = MtgSets::SetsList->values[unlocked -1];
sprintf(buffer,"unlocked_%s", unlockedString.c_str()); sprintf(buffer,"unlocked_%s", unlockedString.c_str());
GameOptions::GetInstance()->values[buffer] = GameOption(1); options[buffer] = GameOption(1);
GameOptions::GetInstance()->save(); options.save();
} }
if (unlocked){ if (unlocked){
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/bonus.wav"); JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/bonus.wav");
@@ -113,10 +112,9 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
if (bonus.size()){ if (bonus.size()){
CreditBonus * b = NEW CreditBonus(value, _("Victory")); CreditBonus * b = NEW CreditBonus(value, _("Victory"));
bonus.insert(bonus.begin(),b); bonus.insert(bonus.begin(),b);
for ( it=bonus.begin()+1 ; it < bonus.end(); ++it){ for (it = bonus.begin() + 1; it < bonus.end(); ++it)
value += (*it)->value; value += (*it)->value;
} }
}
@@ -186,7 +184,7 @@ void Credits::Render(){
int Credits::isDifficultyUnlocked(){ int Credits::isDifficultyUnlocked(){
if (GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue()) return 0; if (options[Options::DIFFICULTY_MODE_UNLOCKED].number) return 0;
int nbAIDecks = 0; int nbAIDecks = 0;
int found = 1; int found = 1;
int wins = 0; int wins = 0;
@@ -210,20 +208,20 @@ int Credits::isDifficultyUnlocked(){
} }
int Credits::isMomirUnlocked(){ int Credits::isMomirUnlocked(){
if (GameOptions::GetInstance()->values[OPTIONS_MOMIR_MODE_UNLOCKED].getIntValue()) return 0; if (options[Options::MOMIR_MODE_UNLOCKED].number) return 0;
if (p1->game->inPlay->countByType("land") == 8) return 1; if (p1->game->inPlay->countByType("land") == 8) return 1;
return 0; return 0;
} }
int Credits::isEvilTwinUnlocked(){ int Credits::isEvilTwinUnlocked(){
if (GameOptions::GetInstance()->values[OPTIONS_EVILTWIN_MODE_UNLOCKED].getIntValue()) return 0; if (options[Options::EVILTWIN_MODE_UNLOCKED].number) return 0;
if (p1->game->inPlay->nb_cards && (p1->game->inPlay->nb_cards == p2->game->inPlay->nb_cards)) return 1; if (p1->game->inPlay->nb_cards && (p1->game->inPlay->nb_cards == p2->game->inPlay->nb_cards)) return 1;
return 0; return 0;
} }
int Credits::isRandomDeckUnlocked(){ int Credits::isRandomDeckUnlocked(){
if (GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY].getIntValue() == 0 ) return 0; if (0 == options[Options::DIFFICULTY].number) return 0;
if (GameOptions::GetInstance()->values[OPTIONS_RANDOMDECK_MODE_UNLOCKED].getIntValue()) return 0; if (options[Options::RANDOMDECK_MODE_UNLOCKED].number) return 0;
if (p1->life >= 20 ) return 1; if (p1->life >= 20 ) return 1;
return 0; return 0;
} }
@@ -234,6 +232,6 @@ int Credits::unlockRandomSet(){
char buffer[4096]; char buffer[4096];
string s = MtgSets::SetsList->values[setId]; string s = MtgSets::SetsList->values[setId];
sprintf(buffer,"unlocked_%s", s.c_str()); sprintf(buffer,"unlocked_%s", s.c_str());
if (GameOptions::GetInstance()->values[buffer].getIntValue() == 1 ) return 0; if (1 == options[buffer].number) return 0;
return setId + 1; return setId + 1;
} }
+7 -6
View File
@@ -4,13 +4,14 @@
#include "../include/Counters.h" #include "../include/Counters.h"
#include "../include/WEvent.h" #include "../include/WEvent.h"
#include "../include/Translate.h" #include "../include/Translate.h"
#include "../include/TexturesCache.h"
Damage::Damage(int id, MTGCardInstance * _source, Damageable * _target): Interruptible(id){ Damage::Damage(int id, MTGCardInstance * source, Damageable * target) {
init(_source, _target, _source->getPower()); init(source, target, source->getPower());
} }
Damage::Damage(int id, MTGCardInstance * _source, Damageable * _target, int _damage): Interruptible(id){ Damage::Damage(int id, MTGCardInstance * source, Damageable * target, int damage) {
init(_source, _target, _damage); init(source, target, damage);
} }
void Damage::init(MTGCardInstance * _source, Damageable * _target, int _damage){ void Damage::init(MTGCardInstance * _source, Damageable * _target, int _damage){
@@ -68,7 +69,7 @@ void Damage::Render(){
sprintf(buffer, _("Deals %i damage to").c_str(), damage); sprintf(buffer, _("Deals %i damage to").c_str(), damage);
mFont->DrawString(buffer, x + 20 , y, JGETEXT_LEFT); mFont->DrawString(buffer, x + 20 , y, JGETEXT_LEFT);
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
JQuad * quad = source->getThumb(); JQuad * quad = cache.getThumb(source);
if (quad){ if (quad){
float scale = 30 / quad->mHeight; float scale = 30 / quad->mHeight;
renderer->RenderQuad(quad, x , y , 0,scale,scale); renderer->RenderQuad(quad, x , y , 0,scale,scale);
@@ -92,7 +93,7 @@ ostream& Damage::toString(ostream& out) const
return out; return out;
} }
DamageStack::DamageStack(int id, GameObserver * _game):GuiLayer(id, _game), Interruptible(id){ DamageStack::DamageStack(GameObserver* game) : game(game){
currentState = -1; currentState = -1;
type = ACTION_DAMAGES; type = ACTION_DAMAGES;
} }
+73 -7
View File
@@ -6,7 +6,7 @@
#include "../include/Damage.h" #include "../include/Damage.h"
#include "../include/Translate.h" #include "../include/Translate.h"
DamageResolverLayer::DamageResolverLayer(int id, GameObserver * _game):PlayGuiObjectController(id, _game){ DamageResolverLayer::DamageResolverLayer(GameObserver * game) : game(game){
currentPhase = -1; currentPhase = -1;
remainingDamageSteps = 0; remainingDamageSteps = 0;
damageStack = NULL; damageStack = NULL;
@@ -106,9 +106,9 @@ DamagerDamaged * DamageResolverLayer::addIfNotExists(MTGCardInstance * card, Pla
DamagerDamaged * item = (DamagerDamaged *)mObjects[i]; DamagerDamaged * item = (DamagerDamaged *)mObjects[i];
if (item->card == card) return item; if (item->card == card) return item;
} }
CardGui * cardg = game->mLayers->playLayer()->getByCard(card); // CardGui * cardg = game->mLayers->playLayer()->getByCard(card);
DamagerDamaged * item = NEW DamagerDamaged(cardg, selecter, mCount == 0); DamagerDamaged * item = NEW DamagerDamaged(card, selecter, mCount == 0);
Add(item); // Add(NEW TransientCardView(card->gui));
mCurr = 0; mCurr = 0;
return item; return item;
} }
@@ -116,9 +116,11 @@ DamagerDamaged * DamageResolverLayer::addIfNotExists(MTGCardInstance * card, Pla
void DamageResolverLayer::updateAllCoordinates(){ void DamageResolverLayer::updateAllCoordinates(){
for (int i = 0; i < mCount; i++){ for (int i = 0; i < mCount; i++){
DamagerDamaged * item = (DamagerDamaged *)mObjects[i]; DamagerDamaged * item = (DamagerDamaged *)mObjects[i];
/*
CardGui * cardg = game->mLayers->playLayer()->getByCard(item->card); CardGui * cardg = game->mLayers->playLayer()->getByCard(item->card);
item->x = cardg->x; item->x = cardg->x;
item->y = cardg->y; item->y = cardg->y;
*/
} }
} }
@@ -129,9 +131,11 @@ int DamageResolverLayer::updateCoordinates(MTGCardInstance * card){
if (item->card != card) item = NULL ; if (item->card != card) item = NULL ;
} }
if (!item) return 0; if (!item) return 0;
/*
CardGui * cardg = game->mLayers->playLayer()->getByCard(card); CardGui * cardg = game->mLayers->playLayer()->getByCard(card);
item->x = cardg->x; item->x = cardg->x;
item->y = cardg->y; item->y = cardg->y;
*/
return 1; return 1;
} }
@@ -181,7 +185,7 @@ int DamageResolverLayer::initResolve(){
#endif #endif
currentSource = NULL; currentSource = NULL;
currentChoosingPlayer = game->currentPlayer; currentChoosingPlayer = game->currentPlayer;
damageStack = NEW DamageStack(mCount,game); damageStack = NEW DamageStack(game);
int strike = 0; int strike = 0;
if (remainingDamageSteps == 2) strike = 1; if (remainingDamageSteps == 2) strike = 1;
@@ -436,7 +440,69 @@ bool DamageResolverLayer::CheckUserInput(u32 key){
}else if (PSP_CTRL_SQUARE == key){ }else if (PSP_CTRL_SQUARE == key){
return nextPlayer(); return nextPlayer();
}else{ }else{
return PlayGuiObjectController::CheckUserInput(key); if (!mCount)
return false;
if (game != NULL){
if (mActionButton == key){
if (mObjects[mCurr] != NULL && mObjects[mCurr]->ButtonPressed()){
game->ButtonPressed((PlayGuiObject *)mObjects[mCurr]);
return true;
}
}
if (PSP_CTRL_CROSS == key){
game->cancelCurrentAction();
return true;
}
}
last_user_move = 0;
switch (key)
{
case PSP_CTRL_LEFT:
{
int n = getClosestItem(DIR_LEFT);
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_LEFT))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
return true;
}
case PSP_CTRL_RIGHT:
{
int n = getClosestItem(DIR_RIGHT);
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_RIGHT))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
return true;
}
case PSP_CTRL_UP:
{
int n = getClosestItem(DIR_UP);
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_UP))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
return true;
}
case PSP_CTRL_DOWN:
{
int n = getClosestItem(DIR_DOWN);
if (n != mCurr && mObjects[mCurr] != NULL && mObjects[mCurr]->Leaving(PSP_CTRL_DOWN))
{
mCurr = n;
mObjects[mCurr]->Entering();
}
return true;
}
case PSP_CTRL_TRIANGLE:
showBigCards = (showBigCards + 1) % 3;
return true;
}
return false;
} }
return false; return false;
} }
@@ -455,7 +521,7 @@ void DamageResolverLayer::Render(){
mFont->DrawString(_("Blocking Player").c_str(), 0,0); mFont->DrawString(_("Blocking Player").c_str(), 0,0);
} }
if (currentSource){ if (currentSource){
currentSource->RenderBig(10, 20); // currentSource->RenderBig(10, 20);
mFont->DrawString(_("Current Damager:").c_str(), 10, 5); mFont->DrawString(_("Current Damager:").c_str(), 10, 5);
} }
for (int i = 0; i < mCount; i++){ for (int i = 0; i < mCount; i++){
+5 -3
View File
@@ -6,7 +6,7 @@ Temporary objects that store the damages dealt to/from creatures during the comb
*/ */
DamagerDamaged::DamagerDamaged(CardGui * cardg, Player * _damageSelecter, bool _hasFocus):CardGui(0, cardg->card,cardg->defaultHeight,cardg->x,cardg->y, _hasFocus){ DamagerDamaged::DamagerDamaged(MTGCardInstance* card, Player * _damageSelecter, bool _hasFocus) : card(card){
mCount = 0; mCount = 0;
damageSelecter = _damageSelecter; damageSelecter = _damageSelecter;
damageToDeal = card->power; damageToDeal = card->power;
@@ -37,7 +37,7 @@ int DamagerDamaged::dealOneDamage(DamagerDamaged * target){
damageToDeal--; damageToDeal--;
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
char buf[4096]; char buf[4096];
sprintf(buf, "==========\n%s can still deal %i damages\n=============\n", card->getName(), damageToDeal); sprintf(buf, "==========\n%s can still deal %i damages\n=============\n", card->getName().c_str(), damageToDeal);
OutputDebugString(buf); OutputDebugString(buf);
#endif #endif
return target->addDamage(1, this); return target->addDamage(1, this);
@@ -76,9 +76,10 @@ int DamagerDamaged::removeDamagesFrom(DamagerDamaged * source){
void DamagerDamaged::Render(Player * currentPlayer){ void DamagerDamaged::Render(Player * currentPlayer){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT); JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetBase(0); mFont->SetBase(0);
CardGui::Render(); // CardGui::Render();
char buf[4096]; char buf[4096];
/*
if (currentPlayer != damageSelecter){ if (currentPlayer != damageSelecter){
if (hasLethalDamage()){ if (hasLethalDamage()){
mFont->DrawString("X",x,y); mFont->DrawString("X",x,y);
@@ -92,4 +93,5 @@ void DamagerDamaged::Render(Player * currentPlayer){
mFont->DrawString(buf,x+5, y+5); mFont->DrawString(buf,x+5, y+5);
} }
mFont->SetColor(ARGB(255,255,255,255)); mFont->SetColor(ARGB(255,255,255,255));
*/
} }
+121 -40
View File
@@ -1,65 +1,146 @@
#include "../include/config.h" #include "../include/config.h"
#include "../include/DuelLayers.h" #include "../include/DuelLayers.h"
#include "../include/MTGRules.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/GuiPhaseBar.h"
#include "../include/GuiAvatars.h"
#include "../include/GuiHand.h"
#include "../include/GuiPlay.h"
#include "../include/GuiMana.h"
void DuelLayers::init(){ void DuelLayers::init(){
GameObserver* go = GameObserver::GetInstance();
//0 Stack Layer cs = NEW CardSelector(this);
ActionStack * mActionStack = NEW ActionStack(0, GameObserver::GetInstance());
//Damage Resolver
DamageResolverLayer * mDamageResolver = NEW DamageResolverLayer(1, GameObserver::GetInstance());
//1 Action Layer //1 Action Layer
GuiLayer * actionLayer = NEW ActionLayer(2, GameObserver::GetInstance()); action = NEW ActionLayer();
MTGGamePhase * phaseManager = NEW MTGGamePhase(actionLayer->getMaxId()); action->Add(NEW MTGGamePhase(action->getMaxId()));
actionLayer->Add(phaseManager);
//Add Magic Specific Rules //Add Magic Specific Rules
actionLayer->Add(NEW MTGPutInPlayRule(-1)); action->Add(NEW MTGPutInPlayRule(-1));
actionLayer->Add(NEW MTGAttackRule(-1)); action->Add(NEW MTGAttackRule(-1));
actionLayer->Add(NEW MTGBlockRule(-1)); action->Add(NEW MTGBlockRule(-1));
actionLayer->Add(NEW MTGLegendRule(-1)); action->Add(NEW MTGLegendRule(-1));
actionLayer->Add(NEW MTGPersistRule(-1)); action->Add(NEW MTGPersistRule(-1));
actionLayer->Add(NEW MTGLifelinkRule(-1)); action->Add(NEW MTGLifelinkRule(-1));
//Other display elements //Other display elements
actionLayer->Add(NEW HUDDisplay(-1)); action->Add(NEW HUDDisplay(-1));
//2 Hand Layer Add(NEW GuiMana());
MTGGuiHand * mGuiHand = NEW MTGGuiHand(3, GameObserver::GetInstance()); 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 Add(NEW GuiAvatars(cs));
MTGGuiPlay * play = NEW MTGGuiPlay(4, GameObserver::GetInstance()); Add(NEW GuiPhaseBar());
Add(NEW GuiFrame());
//Add(NEW GuiPhaseBar(GameObserver::GetInstance())); Add(NEW GuiBackground());
Add(mActionStack);
Add(mDamageResolver);
Add(actionLayer);
Add(mGuiHand);
Add(play);
} }
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(){ ActionStack * DuelLayers::stackLayer(){
return ((ActionStack *) (objects[0])); return stack;
}
DamageResolverLayer * DuelLayers::combatLayer(){
return ((DamageResolverLayer *) (objects[1]));
} }
ActionLayer * DuelLayers::actionLayer(){ ActionLayer * DuelLayers::actionLayer(){
return ((ActionLayer *) (objects[2])); return action;
} }
MTGGuiHand * DuelLayers::handLayer(){ DuelLayers::DuelLayers() : nbitems(0) {}
return ((MTGGuiHand *) (objects[3]));
} DuelLayers::~DuelLayers(){
MTGGuiPlay * DuelLayers::playLayer(){ for (int i = 0; i < nbitems; ++i) delete objects[i];
return ((MTGGuiPlay *) (objects[4]));
} }
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();
}
+61 -12
View File
@@ -24,6 +24,8 @@ int GameApp::HasMusic = 1;
JMusic * GameApp::music = NULL; JMusic * GameApp::music = NULL;
string GameApp::systemError = ""; string GameApp::systemError = "";
JQuad* manaIcons[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
GameState::GameState(GameApp* parent): mParent(parent) GameState::GameState(GameApp* parent): mParent(parent)
{ {
mEngine = JGE::GetInstance(); mEngine = JGE::GetInstance();
@@ -64,19 +66,15 @@ void GameApp::Create()
//Test for Music files presence //Test for Music files presence
std::ifstream file(RESPATH"/sound/Track0.mp3"); std::ifstream file(RESPATH"/sound/Track0.mp3");
if(file){ if (file)
file.close(); file.close();
}else{ else
HasMusic = 0; HasMusic = 0;
}
std::ifstream file2(RESPATH"/sound/Track1.mp3"); std::ifstream file2(RESPATH"/sound/Track1.mp3");
if(file2){ if (file2)
file2.close(); file2.close();
}else{ else
HasMusic = 0; HasMusic = 0;
}
CommonRes->CreateTexture("graphics/menuicons.png"); CommonRes->CreateTexture("graphics/menuicons.png");
//Creating thes quad in this specific order allows us to have them in the correct order to call them by integer id //Creating thes quad in this specific order allows us to have them in the correct order to call them by integer id
@@ -87,6 +85,14 @@ void GameApp::Create()
CommonRes->CreateQuad("c_black", "graphics/menuicons.png", 2 + 2*36, 38, 32, 32); CommonRes->CreateQuad("c_black", "graphics/menuicons.png", 2 + 2*36, 38, 32, 32);
CommonRes->CreateQuad("c_white", "graphics/menuicons.png", 2 + 4*36, 38, 32, 32); CommonRes->CreateQuad("c_white", "graphics/menuicons.png", 2 + 4*36, 38, 32, 32);
CommonRes->CreateQuad("c_land", "graphics/menuicons.png", 2 + 5*36, 38, 32, 32); CommonRes->CreateQuad("c_land", "graphics/menuicons.png", 2 + 5*36, 38, 32, 32);
manaIcons[Constants::MTG_COLOR_ARTIFACT] = GameApp::CommonRes->GetQuad("c_artifact");
manaIcons[Constants::MTG_COLOR_LAND] = GameApp::CommonRes->GetQuad("c_land");
manaIcons[Constants::MTG_COLOR_WHITE] = GameApp::CommonRes->GetQuad("c_white");
manaIcons[Constants::MTG_COLOR_RED] = GameApp::CommonRes->GetQuad("c_red");
manaIcons[Constants::MTG_COLOR_BLACK] = GameApp::CommonRes->GetQuad("c_black");
manaIcons[Constants::MTG_COLOR_BLUE] = GameApp::CommonRes->GetQuad("c_blue");
manaIcons[Constants::MTG_COLOR_GREEN] = GameApp::CommonRes->GetQuad("c_green");
for (int i = sizeof(manaIcons)/sizeof(manaIcons[0]) - 1; i >= 0; --i) manaIcons[i]->SetHotSpot(16,16);
CommonRes->CreateTexture("sets/back.jpg"); CommonRes->CreateTexture("sets/back.jpg");
@@ -108,9 +114,54 @@ void GameApp::Create()
CommonRes->CreateTexture("graphics/phasebar.png"); CommonRes->CreateTexture("graphics/phasebar.png");
CommonRes->CreateTexture("graphics/background.png"); CommonRes->CreateTexture("graphics/wood.png");
CommonRes->CreateTexture("graphics/gold.png");
CommonRes->CreateTexture("graphics/goldglow.png");
CommonRes->CreateTexture("graphics/back.jpg"); CommonRes->CreateTexture("graphics/back.jpg");
CommonRes->CreateTexture("graphics/phasebar.png");
CommonRes->CreateTexture("graphics/handback.png");
CommonRes->CreateTexture("sets/red.jpg");
CommonRes->CreateTexture("sets/white.jpg");
CommonRes->CreateTexture("sets/blue.jpg");
CommonRes->CreateTexture("sets/black.jpg");
CommonRes->CreateTexture("sets/green.jpg");
CommonRes->CreateQuad("red", "sets/red.jpg", 0, 0, 200, 285);
CommonRes->CreateQuad("white", "sets/white.jpg", 0, 0, 200, 285);
CommonRes->CreateQuad("blue", "sets/blue.jpg", 0, 0, 200, 285);
CommonRes->CreateQuad("black", "sets/black.jpg", 0, 0, 200, 285);
CommonRes->CreateQuad("green", "sets/green.jpg", 0, 0, 200, 285);
CommonRes->GetQuad("red")->SetHotSpot(100, 145);
CommonRes->GetQuad("white")->SetHotSpot(100, 145);
CommonRes->GetQuad("blue")->SetHotSpot(100, 145);
CommonRes->GetQuad("black")->SetHotSpot(100, 145);
CommonRes->GetQuad("green")->SetHotSpot(100, 145);
CommonRes->CreateTexture("sets/red_thumb.jpg");
CommonRes->CreateTexture("sets/white_thumb.jpg");
CommonRes->CreateTexture("sets/blue_thumb.jpg");
CommonRes->CreateTexture("sets/black_thumb.jpg");
CommonRes->CreateTexture("sets/green_thumb.jpg");
CommonRes->CreateQuad("red_thumb", "sets/red_thumb.jpg", 0, 0, 28, 40);
CommonRes->CreateQuad("white_thumb", "sets/white_thumb.jpg", 0, 0, 28, 40);
CommonRes->CreateQuad("blue_thumb", "sets/blue_thumb.jpg", 0, 0, 28, 40);
CommonRes->CreateQuad("black_thumb", "sets/black_thumb.jpg", 0, 0, 28, 40);
CommonRes->CreateQuad("green_thumb", "sets/green_thumb.jpg", 0, 0, 28, 40);
CommonRes->GetQuad("red_thumb")->SetHotSpot(14, 20);
CommonRes->GetQuad("white_thumb")->SetHotSpot(14, 20);
CommonRes->GetQuad("blue_thumb")->SetHotSpot(14, 20);
CommonRes->GetQuad("black_thumb")->SetHotSpot(14, 20);
CommonRes->GetQuad("green_thumb")->SetHotSpot(14, 20);
CommonRes->CreateTexture("graphics/BattleIcon.png");
CommonRes->CreateTexture("graphics/DefenderIcon.png");
CommonRes->CreateTexture("graphics/shadow.png");
CommonRes->CreateQuad("BattleIcon", "graphics/BattleIcon.png", 0, 0, 25, 25);
CommonRes->CreateQuad("DefenderIcon", "graphics/DefenderIcon.png", 0, 0, 24, 23);
CommonRes->CreateQuad("shadow", "graphics/shadow.png", 0, 0, 1, 1);
CommonRes->GetQuad("BattleIcon")->SetHotSpot(12, 12);
CommonRes->GetQuad("DefenderIcon")->SetHotSpot(12, 12);
CommonRes->GetQuad("shadow")->SetHotSpot(0.5, 0.5);
//CommonRes->CreateTexture("graphics/interrupt.png"); //CommonRes->CreateTexture("graphics/interrupt.png");
//CommonRes->CreateQuad("interrupt", "graphics/interrupt.png", 0, 0, 256, 128); //CommonRes->CreateQuad("interrupt", "graphics/interrupt.png", 0, 0, 256, 128);
@@ -188,8 +239,6 @@ void GameApp::Destroy()
SAFE_DELETE(CommonRes); SAFE_DELETE(CommonRes);
GameOptions::Destroy(); //No delete ???
SAFE_DELETE(Subtypes::subtypesList); SAFE_DELETE(Subtypes::subtypesList);
SAFE_DELETE(MtgSets::SetsList); SAFE_DELETE(MtgSets::SetsList);
+38 -40
View File
@@ -88,10 +88,12 @@ void GameObserver::nextGamePhase(){
Phase * cPhaseOld = phaseRing->getCurrentPhase(); Phase * cPhaseOld = phaseRing->getCurrentPhase();
if (!blockersSorted && cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS){ if (!blockersSorted && cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS){
blockersAssigned = 1; blockersAssigned = 1;
/*
if (!mLayers->combatLayer()->autoOrderBlockers()){ if (!mLayers->combatLayer()->autoOrderBlockers()){
OutputDebugString("Player has To choose ordering!"); OutputDebugString("Player has To choose ordering!");
return; return;
} }
*/
} }
phaseRing->forward(); phaseRing->forward();
@@ -149,18 +151,20 @@ int GameObserver::cancelCurrentAction(){
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; // if (mLayers->combatLayer()->isDisplayed()) return;
Phase * cPhaseOld = phaseRing->getCurrentPhase(); Phase * cPhaseOld = phaseRing->getCurrentPhase();
if (!blockersSorted && cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS){ if (!blockersSorted && cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS){
blockersAssigned = 1; blockersAssigned = 1;
/*
if (!mLayers->combatLayer()->autoOrderBlockers()){ if (!mLayers->combatLayer()->autoOrderBlockers()){
OutputDebugString("Player has To choose ordering!"); OutputDebugString("Player has To choose ordering!");
return; return;
} }
*/
} }
if (cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS || if (cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS ||
opponent()->isAI() || opponent()->isAI() ||
GameOptions::GetInstance()->values[GameOptions::phaseInterrupts[currentGamePhase]].getIntValue()){ options[GameOptions::phaseInterrupts[currentGamePhase]].number){
mLayers->stackLayer()->AddNextGamePhase(); mLayers->stackLayer()->AddNextGamePhase();
}else{ }else{
nextGamePhase(); nextGamePhase();
@@ -170,30 +174,31 @@ void GameObserver::userRequestNextGamePhase(){
int GameObserver::forceShuffleLibraries(){ int GameObserver::forceShuffleLibraries(){
OutputDebugString("FORCING\n"); OutputDebugString("FORCING\n");
int result = 0; int result = 0;
for (int i=0; i<2; i++){ if (players[0]->game->library->needShuffle)
if (forceShuffleLibrary[i]) { {
forceShuffleLibrary[i] = 0; players[0]->game->library->shuffle();
players[i]->game->library->shuffle(); players[0]->game->library->needShuffle = false;
result++; ++result;
OutputDebugString("YAY\n");
} }
if (players[1]->game->library->needShuffle)
{
players[1]->game->library->shuffle();
players[1]->game->library->needShuffle = false;
++result;
} }
if (result) mLayers->playLayer()->forceUpdateCards();
return result; return result;
} }
void GameObserver::startGame(int shuffle, int draw){ void GameObserver::startGame(int shuffle, int draw){
int i; int i;
for (i=0; i<nbPlayers; i++){ for (i=0; i<nbPlayers; i++)
players[i]->game->initGame(shuffle, draw); players[i]->game->initGame(shuffle, draw);
forceShuffleLibrary[i] = 0;
}
//Preload images from hand //Preload images from hand
if (!players[0]->isAI()){ if (!players[0]->isAI()){
for (i=0; i< players[0]->game->hand->nb_cards; i++){ for (i=0; i< players[0]->game->hand->nb_cards; i++){
players[0]->game->hand->cards[i]->getThumb(); cache.getThumb(players[0]->game->hand->cards[i]);
players[0]->game->hand->cards[i]->getQuad(); cache.getQuad(players[0]->game->hand->cards[i]);
} }
} }
turn = 0; turn = 0;
@@ -202,9 +207,8 @@ void GameObserver::startGame(int shuffle, int draw){
//Difficult mode special stuff //Difficult mode special stuff
if (!players[0]->isAI() && players[1]->isAI()){ if (!players[0]->isAI() && players[1]->isAI()){
GameOptions * go = GameOptions::GetInstance(); int difficulty = options[Options::DIFFICULTY].number;
int difficulty = go->values[OPTIONS_DIFFICULTY].getIntValue(); if (options[Options::DIFFICULTY_MODE_UNLOCKED].number && difficulty) {
if (go->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue() && difficulty) {
Player * p = players[1]; Player * p = players[1];
for (int level=0; level < difficulty; level ++){ for (int level=0; level < difficulty; level ++){
MTGCardInstance * card = NULL; MTGCardInstance * card = NULL;
@@ -259,8 +263,8 @@ void GameObserver::Update(float dt){
if (currentGamePhase == Constants::MTG_PHASE_COMBATBLOCKERS && !blockersSorted){ if (currentGamePhase == Constants::MTG_PHASE_COMBATBLOCKERS && !blockersSorted){
player = opponent(); player = opponent();
}else if (currentGamePhase == Constants::MTG_PHASE_COMBATDAMAGE){ }else if (currentGamePhase == Constants::MTG_PHASE_COMBATDAMAGE){
DamageResolverLayer * drl = mLayers->combatLayer(); // DamageResolverLayer * drl = mLayers->combatLayer();
if (drl->currentChoosingPlayer && drl->mCount) player = drl->currentChoosingPlayer; // if (drl->currentChoosingPlayer && drl->mCount) player = drl->currentChoosingPlayer;
} }
currentActionPlayer = player; currentActionPlayer = player;
if (isInterrupting) player = isInterrupting; if (isInterrupting) player = isInterrupting;
@@ -309,39 +313,33 @@ void GameObserver::Render(){
void GameObserver::ButtonPressed (int controllerId, PlayGuiObject * _object){ void GameObserver::ButtonPressed(PlayGuiObject * target){
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
OutputDebugString("Click\n"); OutputDebugString("Click\n");
#endif #endif
int id = _object->GetId(); if (CardView* cardview = dynamic_cast<CardView*>(target)){
if (id >=0){ MTGCardInstance * card = cardview->getCard();
MTGCardInstance * card = ((CardGui *)_object)->card;
cardClick(card, card); cardClick(card, card);
} }
if (id== -6 || id == -4){ //libraries else if (GuiLibrary* library = dynamic_cast<GuiLibrary*>(target)){
GuiGameZone * zone = (GuiGameZone *)_object; if (library->showCards){
if (zone->showCards){ library->toggleDisplay();
zone->toggleDisplay();
forceShuffleLibraries(); forceShuffleLibraries();
} else { } else {
int pId = (-id - 4)/2;
TargetChooser * _tc = this->getCurrentTargetChooser(); TargetChooser * _tc = this->getCurrentTargetChooser();
if (_tc && _tc->targetsZone(players[pId]->game->library)){ if (_tc && _tc->targetsZone(library->zone)){
zone->toggleDisplay(); library->toggleDisplay();
forceShuffleLibrary[pId] = 1; library->zone->needShuffle = true;
} }
} }
} }
if (id== -5 || id == -3){ else if (GuiGraveyard* graveyard = dynamic_cast<GuiGraveyard*>(target))
GuiGameZone * zone = (GuiGameZone *)_object; graveyard->toggleDisplay();
zone->toggleDisplay(); else if (GuiAvatar* avatar = dynamic_cast<GuiAvatar*>(target)){
}
if (id == -1 || id == -2){
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
OutputDebugString("Click Player !\n"); OutputDebugString("Click Player !\n");
#endif #endif
cardClick(NULL, ((GuiAvatar *)_object)->player); cardClick(NULL, avatar->player);
} }
} }
@@ -468,8 +466,8 @@ int GameObserver::receiveEvent(WEvent * e){
} }
int GameObserver::isACreature(MTGCardInstance * card){ bool GameObserver::isCreature(MTGCardInstance * card){
return card->isACreature(); return card->isCreature();
} }
+20 -20
View File
@@ -22,22 +22,24 @@ const char* GameOptions::phaseInterrupts[] = {
"interrupt Cleanup", "interrupt Cleanup",
"interrupt ---" "interrupt ---"
}; };
const string Options::MUSICVOLUME = "musicVolume";
const string Options::SFXVOLUME = "sfxVolume";
const string Options::DIFFICULTY_MODE_UNLOCKED = "prx_handler"; //huhu
const string Options::MOMIR_MODE_UNLOCKED = "prx_rimom"; //haha
const string Options::DIFFICULTY = "difficulty";
const string Options::CACHESIZE = "cacheSize";
const string Options::PLASMAEFFECT = "plasmaEffect";
const string Options::INTERRUPT_SECONDS = "interruptSeconds";
const string Options::INTERRUPTMYSPELLS = "interruptMySpells";
const string Options::INTERRUPTMYABILITIES = "interruptMyAbilities";
const string Options::EVILTWIN_MODE_UNLOCKED = "prx_eviltwin";
const string Options::RANDOMDECK_MODE_UNLOCKED = "prx_rnddeck";
const string Options::OSD = "displayOSD";
GameOption::GameOption(int _value){
value = _value;
}
int GameOption::getIntValue(){
return value;
}
GameOptions* GameOptions::mInstance = NULL; GameOption::GameOption(int value) : number(value){}
GameOption::GameOption(string value) : str(value){}
GameOptions * GameOptions::GetInstance(){
if (mInstance == NULL)
mInstance = NEW GameOptions();
return mInstance;
}
GameOptions::GameOptions(){ GameOptions::GameOptions(){
load(); load();
@@ -63,7 +65,7 @@ int GameOptions::save(){
if (file){ if (file){
map<string, GameOption>::iterator it; map<string, GameOption>::iterator it;
for ( it=values.begin() ; it != values.end(); it++ ){ for ( it=values.begin() ; it != values.end(); it++ ){
sprintf(writer,"%s=%d\n", it->first.c_str(), it->second.getIntValue()); sprintf(writer,"%s=%d\n", it->first.c_str(), it->second.number);
file<<writer; file<<writer;
} }
file.close(); file.close();
@@ -71,13 +73,11 @@ int GameOptions::save(){
return 1; return 1;
} }
GameOption& GameOptions::operator[](string option_name) {
return values[option_name];
}
GameOptions::~GameOptions(){ GameOptions::~GameOptions(){
} }
void GameOptions::Destroy(){ GameOptions options;
if (mInstance){
delete mInstance;
mInstance = NULL;
}
}
+9 -13
View File
@@ -129,15 +129,14 @@ void GameStateDuel::loadPlayerRandom(int playerId, int isAI, int mode){
tempDeck->addRandomCards(2,0,0,-1,"instant",colors,nbcolors); tempDeck->addRandomCards(2,0,0,-1,"instant",colors,nbcolors);
tempDeck->addRandomCards(2,0,0,-1,"artifact",colors,nbcolors); tempDeck->addRandomCards(2,0,0,-1,"artifact",colors,nbcolors);
char * deckFile = "random"; string deckFile = "random";
string deckFileSmall = "random"; string deckFileSmall = "random";
deck[playerId] = NEW MTGPlayerCards(mParent->collection, tempDeck); deck[playerId] = NEW MTGPlayerCards(mParent->collection, tempDeck);
if (!isAI){ //Human Player if (!isAI) // Human Player
mPlayers[playerId] = NEW HumanPlayer(deck[playerId], deckFile, deckFileSmall); mPlayers[playerId] = NEW HumanPlayer(deck[playerId], deckFile, deckFileSmall);
}else{ else
mPlayers[playerId] = NEW AIPlayerBaka(deck[playerId],deckFile, deckFileSmall.c_str() , ""); mPlayers[playerId] = NEW AIPlayerBaka(deck[playerId],deckFile, deckFileSmall, "");
}
delete tempDeck; delete tempDeck;
} }
@@ -148,11 +147,10 @@ void GameStateDuel::loadPlayerMomir(int playerId, int isAI){
char empty[] = ""; char empty[] = "";
MTGDeck * tempDeck = NEW MTGDeck(deckFile, NULL, mParent->collection); MTGDeck * tempDeck = NEW MTGDeck(deckFile, NULL, mParent->collection);
deck[playerId] = NEW MTGPlayerCards(mParent->collection, tempDeck); deck[playerId] = NEW MTGPlayerCards(mParent->collection, tempDeck);
if (!isAI){ //Human Player if (!isAI) // Human Player
mPlayers[playerId] = NEW HumanPlayer(deck[playerId], deckFile, deckFileSmall); mPlayers[playerId] = NEW HumanPlayer(deck[playerId], deckFile, deckFileSmall);
}else{ else
mPlayers[playerId] = NEW AIMomirPlayer(deck[playerId],deckFile,deckFileSmall.c_str(), empty); mPlayers[playerId] = NEW AIMomirPlayer(deck[playerId], deckFile, deckFileSmall, empty);
}
delete tempDeck; delete tempDeck;
} }
@@ -295,17 +293,15 @@ void GameStateDuel::Update(float dt)
else deckmenu->Update(dt); else deckmenu->Update(dt);
break; break;
case DUEL_STATE_CHOOSE_DECK2: case DUEL_STATE_CHOOSE_DECK2:
if (mParent->players[1] == PLAYER_TYPE_HUMAN){ if (mParent->players[1] == PLAYER_TYPE_HUMAN)
deckmenu->Update(dt); deckmenu->Update(dt);
}
else{ else{
if (mParent->players[0] == PLAYER_TYPE_HUMAN){ if (mParent->players[0] == PLAYER_TYPE_HUMAN){
if (!opponentMenu){ if (!opponentMenu){
opponentMenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_OPPONENT, this, opponentMenuFont, 35, 25, "Choose Opponent"); opponentMenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_OPPONENT, this, opponentMenuFont, 35, 25, "Choose Opponent");
opponentMenu->Add(0,"Random"); opponentMenu->Add(0,"Random");
if (GameOptions::GetInstance()->values[OPTIONS_EVILTWIN_MODE_UNLOCKED].getIntValue()){ if (options[Options::EVILTWIN_MODE_UNLOCKED].number)
opponentMenu->Add(-1,"Evil Twin", "Can you play against yourself?"); opponentMenu->Add(-1,"Evil Twin", "Can you play against yourself?");
}
fillDeckMenu(opponentMenu,RESPATH"/ai/baka", "ai_baka", mPlayers[0]); fillDeckMenu(opponentMenu,RESPATH"/ai/baka", "ai_baka", mPlayers[0]);
} }
opponentMenu->Update(dt); opponentMenu->Update(dt);
+19 -30
View File
@@ -148,23 +148,19 @@ void GameStateMenu::Start(){
JRenderer::GetInstance()->EnableVSync(true); JRenderer::GetInstance()->EnableVSync(true);
subMenuController = NULL; subMenuController = NULL;
if (GameApp::HasMusic && !GameApp::music && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME].getIntValue() > 0){ if (GameApp::HasMusic && !GameApp::music && options[Options::MUSICVOLUME].number > 0){
GameApp::music = JSoundSystem::GetInstance()->LoadMusic("sound/Track0.mp3"); GameApp::music = JSoundSystem::GetInstance()->LoadMusic("sound/Track0.mp3");
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true); JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
} }
if (GameApp::HasMusic && GameApp::music && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME].getIntValue() == 0){ if (GameApp::HasMusic && GameApp::music && options[Options::MUSICVOLUME].number == 0){
JSoundSystem::GetInstance()->StopMusic(GameApp::music); JSoundSystem::GetInstance()->StopMusic(GameApp::music);
SAFE_DELETE(GameApp::music); SAFE_DELETE(GameApp::music);
} }
hasChosenGameType = 1; hasChosenGameType = 1;
if (GameOptions::GetInstance()->values[OPTIONS_MOMIR_MODE_UNLOCKED].getIntValue()) hasChosenGameType =0; if (options[Options::MOMIR_MODE_UNLOCKED].number) hasChosenGameType = 0;
if (GameOptions::GetInstance()->values[OPTIONS_RANDOMDECK_MODE_UNLOCKED].getIntValue()) hasChosenGameType =0; if (options[Options::RANDOMDECK_MODE_UNLOCKED].number) hasChosenGameType = 0;
} }
@@ -195,27 +191,25 @@ void GameStateMenu::fillScroller(){
scroller->Add(buff2); scroller->Add(buff2);
} }
GameOptions * go = GameOptions::GetInstance(); if (!options[Options::DIFFICULTY_MODE_UNLOCKED].number)
if (!go->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue()){
scroller->Add(_("Unlock the difficult mode for more challenging duels!")); scroller->Add(_("Unlock the difficult mode for more challenging duels!"));
} if (!options[Options::MOMIR_MODE_UNLOCKED].number)
if (!go->values[OPTIONS_MOMIR_MODE_UNLOCKED].getIntValue()){
scroller->Add(_("Interested in playing Momir Basic? You'll have to unlock it first :)")); scroller->Add(_("Interested in playing Momir Basic? You'll have to unlock it first :)"));
} if (!options[Options::RANDOMDECK_MODE_UNLOCKED].number)
if (!go->values[OPTIONS_RANDOMDECK_MODE_UNLOCKED].getIntValue()){ scroller->Add(_("You haven't locked the random deck mode yet"));
scroller->Add(_("You haven't unlocked the random deck mode yet")); if (!options[Options::EVILTWIN_MODE_UNLOCKED].number)
} scroller->Add(_("You haven't unlocked the evil twin mode yet"));
if (!go->values[OPTIONS_EVILTWIN_MODE_UNLOCKED].getIntValue()){ if (!options[Options::RANDOMDECK_MODE_UNLOCKED].number)
scroller->Add(_("You haven't unlocked the random deck mode yet"));
if (!options[Options::EVILTWIN_MODE_UNLOCKED].number)
scroller->Add(_("You haven't unlocked the evil twin mode yet")); scroller->Add(_("You haven't unlocked the evil twin mode yet"));
}
//Unlocked sets //Unlocked sets
int nbunlocked = 0; int nbunlocked = 0;
for (int i = 0; i < MtgSets::SetsList->nb_items; i++){ for (int i = 0; i < MtgSets::SetsList->nb_items; i++){
string s = MtgSets::SetsList->values[i]; string s = MtgSets::SetsList->values[i];
sprintf(buffer,"unlocked_%s", s.c_str()); sprintf(buffer,"unlocked_%s", s.c_str());
if (GameOptions::GetInstance()->values[buffer].getIntValue() == 1 ) nbunlocked++; if (1 == options[buffer].number) nbunlocked++;
} }
sprintf(buff2, _("You have unlocked %i expansions out of %i").c_str(),nbunlocked, MtgSets::SetsList->nb_items); sprintf(buff2, _("You have unlocked %i expansions out of %i").c_str(),nbunlocked, MtgSets::SetsList->nb_items);
scroller->Add(buff2); scroller->Add(buff2);
@@ -323,20 +317,16 @@ void GameStateMenu::Update(float dt)
string s = MtgSets::SetsList->values[setId]; string s = MtgSets::SetsList->values[setId];
char buffer[4096]; char buffer[4096];
sprintf(buffer,"unlocked_%s", s.c_str()); sprintf(buffer,"unlocked_%s", s.c_str());
GameOptions::GetInstance()->values[buffer] = GameOption(1); options[buffer] = GameOption(1);
GameOptions::GetInstance()->save(); options.save();
createUsersFirstDeck(setId); createUsersFirstDeck(setId);
} }
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE; currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
break; break;
case MENU_STATE_MAJOR_MAINMENU : case MENU_STATE_MAJOR_MAINMENU :
if (!scrollerSet) fillScroller(); if (!scrollerSet) fillScroller();
if (mGuiController!=NULL){ if (NULL != mGuiController)
mGuiController->Update(dt); mGuiController->Update(dt);
}
break; break;
case MENU_STATE_MAJOR_SUBMENU : case MENU_STATE_MAJOR_SUBMENU :
subMenuController->Update(dt); subMenuController->Update(dt);
@@ -351,10 +341,9 @@ void GameStateMenu::Update(float dt)
subMenuController = NEW SimpleMenu(102, this, mFont, 150,60); subMenuController = NEW SimpleMenu(102, this, mFont, 150,60);
if (subMenuController){ if (subMenuController){
subMenuController->Add(SUBMENUITEM_CLASSIC,"Classic"); subMenuController->Add(SUBMENUITEM_CLASSIC,"Classic");
if (GameOptions::GetInstance()->values[OPTIONS_MOMIR_MODE_UNLOCKED].getIntValue()){ if (options[Options::MOMIR_MODE_UNLOCKED].number)
subMenuController->Add(SUBMENUITEM_MOMIR, "Momir Basic"); subMenuController->Add(SUBMENUITEM_MOMIR, "Momir Basic");
} if (options[Options::RANDOMDECK_MODE_UNLOCKED].number){
if (GameOptions::GetInstance()->values[OPTIONS_RANDOMDECK_MODE_UNLOCKED].getIntValue()){
subMenuController->Add(SUBMENUITEM_RANDOM1, "Random 1 Color"); subMenuController->Add(SUBMENUITEM_RANDOM1, "Random 1 Color");
subMenuController->Add(SUBMENUITEM_RANDOM2, "Random 2 Colors"); subMenuController->Add(SUBMENUITEM_RANDOM2, "Random 2 Colors");
} }
+9 -12
View File
@@ -25,23 +25,20 @@ void GameStateOptions::Start()
JRenderer::GetInstance()->EnableVSync(true); JRenderer::GetInstance()->EnableVSync(true);
optionsList = NEW OptionsList(); optionsList = NEW OptionsList();
if (GameApp::HasMusic) optionsList->Add(NEW OptionItem(OPTIONS_MUSICVOLUME, "Music volume", 100, 10)); if (GameApp::HasMusic) optionsList->Add(NEW OptionItem(Options::MUSICVOLUME, "Music volume", 100, 10));
optionsList->Add(NEW OptionItem(OPTIONS_SFXVOLUME, "SFX volume", 100, 10)); optionsList->Add(NEW OptionItem(Options::SFXVOLUME, "SFX volume", 100, 10));
optionsList->Add(NEW OptionItem(OPTIONS_INTERRUPTMYSPELLS, "interrupt my spells")); optionsList->Add(NEW OptionItem(Options::INTERRUPTMYSPELLS, "interrupt my spells"));
optionsList->Add(NEW OptionItem(OPTIONS_INTERRUPTMYABILITIES, "interrupt my abilities")); optionsList->Add(NEW OptionItem(Options::INTERRUPTMYABILITIES, "interrupt my abilities"));
optionsList->Add(NEW OptionItem(OPTIONS_OSD, "Display InGame extra information")); optionsList->Add(NEW OptionItem(Options::INTERRUPT_SECONDS, "Seconds to pause for an Interrupt", 20, 1));
// WALDORF - added next line optionsList->Add(NEW OptionItem(Options::OSD, "Display InGame extra information"));
optionsList->Add(NEW OptionItem(OPTIONS_INTERRUPT_SECONDS, "Seconds to pause for an Interrupt", 20, 1)); if (options[Options::DIFFICULTY_MODE_UNLOCKED].number)
if (GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue()) { optionsList->Add(NEW OptionItem(Options::DIFFICULTY, "Difficulty", 3, 1));
optionsList->Add(NEW OptionItem(OPTIONS_DIFFICULTY, "Difficulty", 3, 1)); optionsList->Add(NEW OptionItem(Options::CACHESIZE, "Image Cache Size", 60, 5));
}
optionsList->Add(NEW OptionItem(OPTIONS_CACHESIZE, "Image Cache Size", 60, 5));
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3"); JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
optionsMenu = NEW SimpleMenu(102, this,mFont, 50,170); optionsMenu = NEW SimpleMenu(102, this,mFont, 50,170);
optionsMenu->Add(1, "Save & Back to Main Menu"); optionsMenu->Add(1, "Save & Back to Main Menu");
optionsMenu->Add(2, "Back to Main Menu"); optionsMenu->Add(2, "Back to Main Menu");
optionsMenu->Add(3, "Cancel"); optionsMenu->Add(3, "Cancel");
} }
+4 -5
View File
@@ -67,18 +67,17 @@ void GameStateShop::load(){
if (s.compare("10E") == 0) defaultSet = i; if (s.compare("10E") == 0) defaultSet = i;
char buffer[4096]; char buffer[4096];
sprintf(buffer,"unlocked_%s", s.c_str()); sprintf(buffer,"unlocked_%s", s.c_str());
unlocked[i] = GameOptions::GetInstance()->values[buffer].getIntValue(); unlocked[i] = options[buffer].number;
if ( unlocked[i] ){ if (unlocked[i])
ok = 1; ok = 1;
} }
}
if (!ok){ if (!ok){
unlocked[defaultSet] = 1; unlocked[defaultSet] = 1;
string s = MtgSets::SetsList->values[defaultSet]; string s = MtgSets::SetsList->values[defaultSet];
char buffer[4096]; char buffer[4096];
sprintf(buffer,"unlocked_%s", s.c_str()); sprintf(buffer,"unlocked_%s", s.c_str());
GameOptions::GetInstance()->values[buffer] = GameOption(1); options[buffer] = GameOption(1);
GameOptions::GetInstance()->save(); options.save();
} }
for (int i = 0; i < MtgSets::SetsList->nb_items; i++){ for (int i = 0; i < MtgSets::SetsList->nb_items; i++){
+1 -77
View File
@@ -2,9 +2,7 @@
#include "../include/GuiLayers.h" #include "../include/GuiLayers.h"
#include "../include/Player.h" #include "../include/Player.h"
GuiLayer::GuiLayer(int id, GameObserver* _game){ GuiLayer::GuiLayer(){
mId = id;
game = _game;
modal = 0; modal = 0;
hasFocus = false; hasFocus = false;
mCount = 0; mCount = 0;
@@ -103,77 +101,3 @@ JGuiObject * GuiLayer::getByIndex(int index){
return mObjects[index]; return mObjects[index];
} }
GuiLayers::GuiLayers(){
nbitems = 0;
}
GuiLayers::~GuiLayers(){
LOG("==Destroying GuiLayers==");
for (int i=0; i<nbitems; i++){
delete objects[i];
}
LOG("==Destroying GuiLayers Successful==");
}
int GuiLayers::unstoppableRenderInProgress(){
for (int i=0; i<nbitems; i++){
if (objects[i]->unstoppableRenderInProgress())
return 1;
}
return 0;
}
void GuiLayers::Add(GuiLayer * layer){
if (nbitems >=MAX_GUI_LAYERS || nbitems < 0){
LOG("OUT OF BOUND IN GuiLayers Add !!!");
return;
}
objects[nbitems] = layer;
nbitems++;
}
void GuiLayers::Remove(){
nbitems --;
}
void GuiLayers::Update(float dt, Player * currentPlayer){
for (int i=0; i<nbitems; i++){
objects[i]->Update(dt);
}
int isAI = currentPlayer->isAI();
u32 key;
while ((key = JGE::GetInstance()->ReadButton())){
for (int i=0; i<nbitems; i++){
if (!isAI){
if (0 != key)
if (objects[i]->CheckUserInput(key)) break;
}
}
}
if (isAI) currentPlayer->Act(dt);
}
void GuiLayers::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 GuiLayers::receiveEvent(WEvent * e){
for (int i = 0; i < nbitems; i++){
objects[i]->receiveEvent(e);
}
return 1;
}
+9 -10
View File
@@ -18,7 +18,7 @@ static int colors[] =
ARGB(255, 255, 255, 255) ARGB(255, 255, 255, 255)
}; };
GuiPhaseBar::GuiPhaseBar(GameObserver* game):GuiLayer(0,game), phase(GameObserver::GetInstance()->phaseRing->getCurrentPhase()), angle(0.0f) GuiPhaseBar::GuiPhaseBar() : phase(GameObserver::GetInstance()->phaseRing->getCurrentPhase()), angle(0.0f)
{ {
JTexture* texture = GameApp::CommonRes->GetTexture("graphics/phasebar.png"); JTexture* texture = GameApp::CommonRes->GetTexture("graphics/phasebar.png");
if (texture) if (texture)
@@ -45,24 +45,24 @@ void GuiPhaseBar::Render()
static const float ICONSCALE = 1.5; static const float ICONSCALE = 1.5;
static const unsigned CENTER = SCREEN_HEIGHT / 2 + 10; static const unsigned CENTER = SCREEN_HEIGHT / 2 + 10;
JRenderer* renderer = JRenderer::GetInstance(); JRenderer* renderer = JRenderer::GetInstance();
unsigned p = (phase->id + Phases - 4) * Width; unsigned p = (phase->id + Phases - 4) * (Width+1);
float scale; float scale;
float start = CENTER + (Width / 2) * angle * ICONSCALE / (M_PI / 6) - ICONSCALE * Width / 4; float start = CENTER + (Width / 2) * angle * ICONSCALE / (M_PI / 6) - ICONSCALE * Width / 4;
renderer->DrawLine(0, CENTER, SCREEN_WIDTH, CENTER, ARGB(255, 255, 255, 255)); renderer->DrawLine(0, CENTER, SCREEN_WIDTH, CENTER, ARGB(255, 255, 255, 255));
scale = ICONSCALE * sinf(angle + 3 * M_PI / 6) / 2; scale = ICONSCALE * sinf(angle + 3 * M_PI / 6) / 2;
quad->SetTextureRect((p + 3 * Width) % (Phases * Width), 0, Width, Height); quad->SetTextureRect((p + 3 * (Width+1)) % (Phases * (Width+1)), 0, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale); renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
start += Width * scale; start += Width * scale;
scale = ICONSCALE * sinf(angle + 4 * M_PI / 6) / 2; scale = ICONSCALE * sinf(angle + 4 * M_PI / 6) / 2;
quad->SetTextureRect((p + 4 * Width) % (Phases * Width), Height, Width, Height); quad->SetTextureRect((p + 4 * (Width+1)) % (Phases * (Width+1)), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale); renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
start += Width * scale; start += Width * scale;
scale = ICONSCALE * sinf(angle + 5 * M_PI / 6) / 2; scale = ICONSCALE * sinf(angle + 5 * M_PI / 6) / 2;
quad->SetTextureRect((p + 5 * Width) % (Phases * Width), Height, Width, Height); quad->SetTextureRect((p + 5 * (Width+1)) % (Phases * (Width+1)), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale); renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
start += Width * scale; start += Width * scale;
@@ -70,25 +70,24 @@ void GuiPhaseBar::Render()
scale = ICONSCALE * sinf(angle + 2 * M_PI / 6) / 2; scale = ICONSCALE * sinf(angle + 2 * M_PI / 6) / 2;
start -= Width * scale; start -= Width * scale;
quad->SetTextureRect((p + 2 * Width) % (Phases * Width), Height, Width, Height); quad->SetTextureRect((p + 2 * (Width+1)) % (Phases * (Width+1)), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale); renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
scale = ICONSCALE * sinf(angle + 1 * M_PI / 6) / 2; scale = ICONSCALE * sinf(angle + 1 * M_PI / 6) / 2;
start -= Width * scale; start -= Width * scale;
quad->SetTextureRect((p + 1 * Width) % (Phases * Width), Height, Width, Height); quad->SetTextureRect((p + 1 * (Width+1)) % (Phases * (Width+1)), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale); renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
if (angle > 0) if (angle > 0)
{ {
scale = ICONSCALE * sinf(angle)/2; scale = ICONSCALE * sinf(angle)/2;
start -= Width * scale; start -= Width * scale;
quad->SetTextureRect(p % (Phases * Width), Height, Width, Height); quad->SetTextureRect(p % (Phases * (Width+1)), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale); renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
} }
} }
int GuiPhaseBar::receiveEventMinus(WEvent *e)
int GuiPhaseBar::receiveEvent(WEvent *e)
{ {
WEventPhaseChange *event = dynamic_cast<WEventPhaseChange*>(e); WEventPhaseChange *event = dynamic_cast<WEventPhaseChange*>(e);
if (event) if (event)
+39 -25
View File
@@ -1311,7 +1311,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
game->mLayers->stackLayer()->addDamage(card, game->players[i], x); game->mLayers->stackLayer()->addDamage(card, game->players[i], x);
for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){ for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j]; MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
if (current->basicAbilities[Constants::FLYING] && current->isACreature()){ if (current->basicAbilities[Constants::FLYING] && current->isCreature()){
game->mLayers->stackLayer()->addDamage(card, current, x); game->mLayers->stackLayer()->addDamage(card, current, x);
} }
} }
@@ -1348,7 +1348,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
game->mLayers->stackLayer()->addDamage(card, game->players[i], x); game->mLayers->stackLayer()->addDamage(card, game->players[i], x);
for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){ for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j]; MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
if (current->isACreature()){ if (current->isCreature()){
game->mLayers->stackLayer()->addDamage(card, current, x); game->mLayers->stackLayer()->addDamage(card, current, x);
} }
} }
@@ -1375,7 +1375,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
game->mLayers->stackLayer()->addDamage(card, game->players[i], x); game->mLayers->stackLayer()->addDamage(card, game->players[i], x);
for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){ for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j]; MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
if (!current->basicAbilities[Constants::FLYING] && current->isACreature()){ if (!current->basicAbilities[Constants::FLYING] && current->isCreature()){
game->mLayers->stackLayer()->addDamage(card, current, x); game->mLayers->stackLayer()->addDamage(card, current, x);
} }
} }
@@ -2292,8 +2292,15 @@ other solutions need to be provided for abilities that add mana (ex: mana flare)
aType = MTGAbility::MANA_PRODUCER; aType = MTGAbility::MANA_PRODUCER;
cost = _cost; cost = _cost;
output = _output; output = _output;
x1 = 10; cout << "!" << card->view << endl;
y1 = 220; if (card->view)
{
x1 = card->view->actX; y1 = card->view->actY;
}
else
{
x1 = 10; y1 = 220;
}
Player * player = card->controller(); Player * player = card->controller();
if (player == game->players[1]) y1 = 100; if (player == game->players[1]) y1 = 100;
x = x1; x = x1;
@@ -2304,22 +2311,27 @@ other solutions need to be provided for abilities that add mana (ex: mana flare)
int landColor = output->getMainColor(); int landColor = output->getMainColor();
if (landColor == Constants::MTG_COLOR_RED){ switch (landColor)
{
case Constants::MTG_COLOR_RED :
mParticleSys = NEW hgeParticleSystem("graphics/manared.psi",GameApp::CommonRes->GetQuad("particles")); mParticleSys = NEW hgeParticleSystem("graphics/manared.psi",GameApp::CommonRes->GetQuad("particles"));
}else if (landColor == Constants::MTG_COLOR_BLUE){ break;
case Constants::MTG_COLOR_BLUE :
mParticleSys = NEW hgeParticleSystem("graphics/manablue.psi", GameApp::CommonRes->GetQuad("particles")); mParticleSys = NEW hgeParticleSystem("graphics/manablue.psi", GameApp::CommonRes->GetQuad("particles"));
}else if (landColor == Constants::MTG_COLOR_GREEN){ break;
case Constants::MTG_COLOR_GREEN :
mParticleSys = NEW hgeParticleSystem("graphics/managreen.psi", GameApp::CommonRes->GetQuad("particles")); mParticleSys = NEW hgeParticleSystem("graphics/managreen.psi", GameApp::CommonRes->GetQuad("particles"));
}else if (landColor == Constants::MTG_COLOR_BLACK){ break;
case Constants::MTG_COLOR_BLACK :
mParticleSys = NEW hgeParticleSystem("graphics/manablack.psi", GameApp::CommonRes->GetQuad("particles")); mParticleSys = NEW hgeParticleSystem("graphics/manablack.psi", GameApp::CommonRes->GetQuad("particles"));
}else if (landColor == Constants::MTG_COLOR_WHITE){ break;
case Constants::MTG_COLOR_WHITE :
mParticleSys = NEW hgeParticleSystem("graphics/manawhite.psi", GameApp::CommonRes->GetQuad("particles")); mParticleSys = NEW hgeParticleSystem("graphics/manawhite.psi", GameApp::CommonRes->GetQuad("particles"));
}else{ break;
default :
mParticleSys = NEW hgeParticleSystem("graphics/mana.psi", GameApp::CommonRes->GetQuad("particles")); mParticleSys = NEW hgeParticleSystem("graphics/mana.psi", GameApp::CommonRes->GetQuad("particles"));
} }
LOG("==ManaProducer Object Creation successful !"); LOG("==ManaProducer Object Creation successful !");
} }
@@ -2336,18 +2348,16 @@ other solutions need to be provided for abilities that add mana (ex: mana flare)
resolve(); resolve();
} }
} }
} }
void AManaProducer::Render(){ void AManaProducer::Render(){
JRenderer * renderer = JRenderer::GetInstance(); JRenderer * renderer = JRenderer::GetInstance();
if (animation){ if (animation){
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE); // renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
if (mParticleSys) mParticleSys->Render(); // if (mParticleSys) mParticleSys->Render();
// set normal blending // set normal blending
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA); // renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
} }
} }
int AManaProducer::isReactingToClick(MTGCardInstance * _card, ManaCost * mana){ int AManaProducer::isReactingToClick(MTGCardInstance * _card, ManaCost * mana){
@@ -2387,17 +2397,21 @@ other solutions need to be provided for abilities that add mana (ex: mana flare)
currentlyTapping++; currentlyTapping++;
animation = 1.f; animation = 1.f;
CardGui * cardg = game->mLayers->playLayer()->getByCard(source);
if (cardg){
x0 = cardg->x + 15;
y0 = cardg->y + 20;
}
if (options[Options::SFXVOLUME].number > 0 && currentlyTapping < 3){
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME].getIntValue() > 0 && currentlyTapping < 3){
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/mana.wav"); JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/mana.wav");
if (sample) JSoundSystem::GetInstance()->PlaySample(sample); if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
} }
for (int i = Constants::MTG_NB_COLORS - 2; i >= 1; --i)
{
for (int cost = output->getCost(i); cost > 0; --cost)
{
WEventEngageMana e(i, source);
GameObserver::GetInstance()->receiveEvent(&e);
}
}
return 1; return 1;
} }
+68 -49
View File
@@ -3,14 +3,15 @@
//------------------------------------------------- //-------------------------------------------------
//TODO Fill BasicAbilities //TODO Fill BasicAbilities
#include "../include/config.h"
#include "../include/MTGCard.h"
#include "../include/TexturesCache.h"
#include "../include/Subtypes.h"
#include <string> #include <string>
#include <stdlib.h> #include <stdlib.h>
#include "../include/MTGDeck.h"
#include "../include/config.h"
#include "../include/MTGCard.h"
#include "../include/Subtypes.h"
#include "../include/Translate.h"
using std::string; using std::string;
@@ -18,12 +19,10 @@ const char * const MTGCard::Colors_To_Text[] = {"Artifact", "Green", "Blue", "Re
MTGCard::MTGCard(){ MTGCard::MTGCard(){
init(); init();
mCache = NULL;
} }
MTGCard::MTGCard(TexturesCache * cache, int set_id){ MTGCard::MTGCard(int set_id){
init(); init();
mCache = cache;
setId = set_id; setId = set_id;
} }
@@ -32,7 +31,6 @@ const char * MTGCard::getSetName(){
} }
MTGCard::MTGCard(MTGCard * source){ MTGCard::MTGCard(MTGCard * source){
mCache = source->mCache;
for(map<int,int>::const_iterator it = source->basicAbilities.begin(); it != source->basicAbilities.end(); ++it){ for(map<int,int>::const_iterator it = source->basicAbilities.begin(); it != source->basicAbilities.end(); ++it){
basicAbilities[it->first] = source->basicAbilities[it->first]; basicAbilities[it->first] = source->basicAbilities[it->first];
} }
@@ -55,7 +53,6 @@ MTGCard::MTGCard(MTGCard * source){
toughness = source->toughness; toughness = source->toughness;
mtgid = source->mtgid; mtgid = source->mtgid;
setId = source->setId; setId = source->setId;
formattedTextInit = 0;
magicText = source->magicText; magicText = source->magicText;
spellTargetType = source->spellTargetType; spellTargetType = source->spellTargetType;
alias = source->alias; alias = source->alias;
@@ -72,34 +69,63 @@ int MTGCard::init(){
colors[i] = 0; colors[i] = 0;
} }
setId = 0; setId = 0;
formattedTextInit = 0;
magicText = ""; magicText = "";
spellTargetType = ""; spellTargetType = "";
alias = 0; alias = 0;
return 1; return 1;
} }
JQuad * MTGCard::getQuad(int type){ const vector<string>& MTGCard::formattedText()
if (mCache == NULL){ {
return NULL; if (ftdText.empty())
{
std::string s = _(text);
std::string::size_type found = s.find_first_of("{}");
while (found!=string::npos)
{
s[found] = '/';
found = s.find_first_of("{}", found + 1);
} }
return mCache->getQuad(this, type); std::string::size_type len = 30;
while (s.length() > 0)
{
std::string::size_type cut = s.find_first_of("., \t)", 0);
if (cut >= len || cut == string::npos)
{
ftdText.push_back(s.substr(0,len));
if (s.length() > len)
s = s.substr(len, s.length() - len);
else
s = "";
}
else
{
std::string::size_type newcut = cut;
while (newcut < len && newcut != string::npos)
{
cut = newcut;
newcut = s.find_first_of("., \t)", newcut + 1);
}
ftdText.push_back(s.substr(0,cut+1));
if (s.length() > cut+1)
s = s.substr(cut+1,s.length() - cut - 1);
else
s = "";
}
}
}
return ftdText;
} }
JQuad * MTGCard::getThumb(){ bool MTGCard::isCreature(){
return getQuad(CACHE_THUMB); return hasSubtype("creature");
} }
bool MTGCard::isLand(){
JQuad * MTGCard::getQuad(TexturesCache * cache){ return hasSubtype("land");
return cache->getQuad(this);
} }
bool MTGCard::isSpell(){
return (!isCreature() && !isLand());
int MTGCard::isACreature(){
return (hasSubtype("creature"));
} }
void MTGCard::setColor(int _color, int removeAllOthers){ void MTGCard::setColor(int _color, int removeAllOthers){
@@ -237,8 +263,8 @@ void MTGCard::setName( string value){
if (value.at(value.length()-1) == 's') Subtypes::subtypesList->Add(value); if (value.at(value.length()-1) == 's') Subtypes::subtypesList->Add(value);
} }
const char * MTGCard::getName(){ const string MTGCard::getName() const{
return name.c_str(); return name;
} }
@@ -248,37 +274,31 @@ ManaCost * MTGCard::getManaCost(){
int MTGCard::hasType(int _type){ bool MTGCard::hasType(int _type){
int i; for (int i = 0; i<nb_types; i++)
if (types[i] == _type)
return true;
for (i = 0; i<nb_types; i++){ return false;
if(types[i] == _type){
return 1;
} }
} bool MTGCard::hasSubtype(int _subtype){
return 0; return hasType(_subtype);
} }
int MTGCard::hasSubtype(int _subtype){ bool MTGCard::hasType(const char * _type){
return(hasType(_subtype));
}
int MTGCard::hasType(const char * _type){
int id = Subtypes::subtypesList->Add(_type); int id = Subtypes::subtypesList->Add(_type);
return(hasType(id)); return hasType(id);
} }
int MTGCard::hasSubtype(const char * _subtype){ bool MTGCard::hasSubtype(const char * _subtype){
int id = Subtypes::subtypesList->Add(_subtype); int id = Subtypes::subtypesList->Add(_subtype);
return(hasType(id)); return hasType(id);
} }
int MTGCard::hasSubtype(string _subtype){ bool MTGCard::hasSubtype(string _subtype){
int id = Subtypes::subtypesList->Add(_subtype); int id = Subtypes::subtypesList->Add(_subtype);
return(hasType(id)); return hasType(id);
} }
@@ -304,4 +324,3 @@ void MTGCard::setToughness(int _toughness){
int MTGCard::getToughness(){ int MTGCard::getToughness(){
return toughness; return toughness;
} }
+14 -19
View File
@@ -12,20 +12,20 @@
#include <algorithm> #include <algorithm>
using namespace std; using namespace std;
MTGCardInstance::MTGCardInstance(): MTGCard(), Damageable(0){ MTGCardInstance::MTGCardInstance(): MTGCard(), Damageable(0), view(NULL){
LOG("==Creating MTGCardInstance=="); LOG("==Creating MTGCardInstance==");
initMTGCI(); initMTGCI();
LOG("==Creating MTGCardInstance Successful=="); LOG("==Creating MTGCardInstance Successful==");
} }
MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * _belongs_to): MTGCard(card), Damageable(card->getToughness()){ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to): MTGCard(card), Damageable(card->getToughness()), view(NULL){
LOG("==Creating MTGCardInstance=="); LOG("==Creating MTGCardInstance==");
initMTGCI(); initMTGCI();
model = card; model = card;
attacker = 0; attacker = 0;
lifeOrig = life; lifeOrig = life;
belongs_to=_belongs_to; belongs_to = arg_belongs_to;
owner = NULL; owner = NULL;
if (_belongs_to) owner = _belongs_to->library->owner; if (arg_belongs_to) owner = arg_belongs_to->library->owner;
lastController = owner; lastController = owner;
defenser = NULL; defenser = NULL;
banding = NULL; banding = NULL;
@@ -60,7 +60,6 @@ void MTGCardInstance::copy(MTGCardInstance * card){
lifeOrig = life; lifeOrig = life;
//mtgid = source->mtgid; //mtgid = source->mtgid;
//setId = source->setId; //setId = source->setId;
formattedTextInit = 0;
magicText = source->magicText; magicText = source->magicText;
spellTargetType = source->spellTargetType; spellTargetType = source->spellTargetType;
alias = source->alias; alias = source->alias;
@@ -109,7 +108,7 @@ void MTGCardInstance::initMTGCI(){
} }
const char * MTGCardInstance::getDisplayName(){ const string MTGCardInstance::getDisplayName(){
return getName(); return getName();
} }
@@ -135,7 +134,7 @@ int MTGCardInstance::isInPlay(){
int MTGCardInstance::afterDamage(){ int MTGCardInstance::afterDamage(){
if (!doDamageTest) return 0; if (!doDamageTest) return 0;
doDamageTest = 0; doDamageTest = 0;
if (!isACreature()) return 0; if (!isCreature()) return 0;
if (life <=0 && isInPlay()){ if (life <=0 && isInPlay()){
return destroy(); return destroy();
} }
@@ -168,10 +167,6 @@ MTGGameZone * MTGCardInstance::getCurrentZone(){
return NULL; return NULL;
} }
JQuad * MTGCardInstance::getIcon(){
return getThumb();
}
int MTGCardInstance::has(int basicAbility){ int MTGCardInstance::has(int basicAbility){
return basicAbilities[basicAbility]; return basicAbilities[basicAbility];
} }
@@ -271,16 +266,16 @@ return previous->stillInUse();
} }
/* Summoning Sickness /* Summoning Sickness
* 212.3f A creaturefs activated ability with the tap symbol or the untap symbol in its activation cost * 212.3f A creature's activated ability with the tap symbol or the untap symbol in its activation cost
* canft be played unless the creature has been under its controllerfs control since the start of his or * can't be played unless the creature has been under its controller's control since the start of his or
* her most recent turn. A creature canft attack unless it has been under its controllerfs control * her most recent turn. A creature can't attack unless it has been under its controller's control
* since the start of his or her most recent turn. This rule is informally called the gsummoning * since the start of his or her most recent turn. This rule is informally called the "summoning
* sicknessh rule. Ignore this rule for creatures with haste (see rule 502.5). * sickness" rule. Ignore this rule for creatures with haste (see rule 502.5).
*/ */
int MTGCardInstance::hasSummoningSickness(){ int MTGCardInstance::hasSummoningSickness(){
if (!summoningSickness) return 0; if (!summoningSickness) return 0;
if (basicAbilities[Constants::HASTE]) return 0; if (basicAbilities[Constants::HASTE]) return 0;
if (!isACreature()) return 0; if (!isCreature()) return 0;
return 1; return 1;
} }
@@ -318,7 +313,7 @@ int MTGCardInstance::canAttack(){
if (tapped) return 0; if (tapped) return 0;
if (hasSummoningSickness()) return 0; if (hasSummoningSickness()) return 0;
if (basicAbilities[Constants::DEFENSER] || basicAbilities[Constants::CANTATTACK]) return 0; if (basicAbilities[Constants::DEFENSER] || basicAbilities[Constants::CANTATTACK]) return 0;
if (!isACreature()) return 0; if (!isCreature()) return 0;
if (!isInPlay()) return 0; if (!isInPlay()) return 0;
return 1; return 1;
} }
@@ -341,7 +336,7 @@ int MTGCardInstance::setToughness(int value){
int MTGCardInstance::canBlock(){ int MTGCardInstance::canBlock(){
if (tapped) return 0; if (tapped) return 0;
if (basicAbilities[Constants::CANTBLOCK]) return 0; if (basicAbilities[Constants::CANTBLOCK]) return 0;
if (!isACreature())return 0; if (!isCreature()) return 0;
if (!isInPlay()) return 0; if (!isInPlay()) return 0;
return 1; return 1;
} }
+1 -1
View File
@@ -275,7 +275,7 @@ int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
switch(conf_read_mode) { switch(conf_read_mode) {
case 0: case 0:
if (s[0] == '['){ if (s[0] == '['){
tempCard = NEW MTGCard(mCache,set_id); tempCard = NEW MTGCard(set_id);
conf_read_mode = 1; conf_read_mode = 1;
} }
break; break;
+7 -19
View File
@@ -14,7 +14,6 @@
//------------------------------ //------------------------------
MTGPlayerCards::MTGPlayerCards(MTGAllCards * _collection, int * idList, int idListSize){ MTGPlayerCards::MTGPlayerCards(MTGAllCards * _collection, int * idList, int idListSize){
init(); init();
int i; int i;
collection = _collection; collection = _collection;
@@ -25,13 +24,8 @@ MTGPlayerCards::MTGPlayerCards(MTGAllCards * _collection, int * idList, int idLi
library->addCard(newCard); library->addCard(newCard);
} }
} }
} }
MTGPlayerCards::MTGPlayerCards(MTGAllCards * _collection, MTGDeck * deck){ MTGPlayerCards::MTGPlayerCards(MTGAllCards * _collection, MTGDeck * deck){
init(); init();
collection = _collection; collection = _collection;
@@ -153,10 +147,9 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
} }
if ((copy = from->removeCard(card,doCopy))){ if ((copy = from->removeCard(card,doCopy))){
if (options[Options::SFXVOLUME].number > 0){
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME].getIntValue() > 0){
if (to == g->players[0]->game->graveyard || to == g->players[1]->game->graveyard){ if (to == g->players[0]->game->graveyard || to == g->players[1]->game->graveyard){
if (card->isACreature()){ if (card->isCreature()){
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/graveyard.wav"); JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/graveyard.wav");
if (sample) JSoundSystem::GetInstance()->PlaySample(sample); if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
} }
@@ -200,9 +193,7 @@ int MTGPlayerCards::isInPlay(MTGCardInstance * card){
// Zones specific code // Zones specific code
//-------------------------------------- //--------------------------------------
MTGGameZone::MTGGameZone(){ MTGGameZone::MTGGameZone() : nb_cards(0), lastCardDrawn(NULL), needShuffle(false) {
nb_cards= 0;
lastCardDrawn = NULL;
} }
MTGGameZone::~MTGGameZone(){ MTGGameZone::~MTGGameZone(){
@@ -227,13 +218,13 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy
nb_cards--; nb_cards--;
cards.erase(cards.begin()+i); cards.erase(cards.begin()+i);
MTGCardInstance * copy = card; MTGCardInstance * copy = card;
if (card->isToken){ //TODO better than this ? if (card->isToken) //TODO better than this ?
return card; return card;
}
//card->lastController = card->controller(); //card->lastController = card->controller();
if (createCopy) { if (createCopy) {
copy = NEW MTGCardInstance(card->model,card->owner->game); copy = NEW MTGCardInstance(card->model,card->owner->game);
copy->previous = card; copy->previous = card;
copy->view = card->view;
card->next = copy; card->next = copy;
} }
copy->previousZone = this; copy->previousZone = this;
@@ -313,11 +304,8 @@ MTGCardInstance * MTGLibrary::draw(){
} }
void MTGGameZone::debugPrint(){ void MTGGameZone::debugPrint(){
int i; for (int i = 0; i < nb_cards; i++)
for (i=0;i<nb_cards;i++){ std::cerr << cards[i]->getName() << endl;
MTGCard * card = cards[i];
fprintf(stderr, "%s", card->getName());
}
} }
+4 -4
View File
@@ -2,7 +2,7 @@
#include "../include/MTGGuiHand.h" #include "../include/MTGGuiHand.h"
#include "../include/CardGui.h" #include "../include/CardGui.h"
MTGGuiHand::MTGGuiHand(int id, GameObserver * _game):GuiCardsController(id, _game){ MTGGuiHand::MTGGuiHand(GameObserver* game) : game(game) {
mShowHand = HAND_HIDE; mShowHand = HAND_HIDE;
mAnimState = 0; mAnimState = 0;
currentPlayer = NULL; currentPlayer = NULL;
@@ -22,7 +22,7 @@ void MTGGuiHand::updateCards(){
resetObjects(); resetObjects();
if (currentId[player->getId()] >= nb_cards) currentId[player->getId()] = nb_cards - 1; if (currentId[player->getId()] >= nb_cards) currentId[player->getId()] = nb_cards - 1;
for (int i = 0;i<nb_cards; i++){ for (int i = 0;i<nb_cards; i++){
CardGui * object = NEW CardGui(i, player->game->hand->cards[i],(float)40, (float)450 - (nb_cards-i) *35, SCREEN_HEIGHT_F - mAnimState*60, i == currentId[player->getId()]); CardView* object = NEW CardView(player->game->hand->cards[i], (float)450 - (nb_cards-i) *35, SCREEN_HEIGHT_F - mAnimState*60);
Add(object); Add(object);
if ( i == currentId[player->getId()]) mCurr = i; if ( i == currentId[player->getId()]) mCurr = i;
} }
@@ -79,7 +79,7 @@ bool MTGGuiHand::CheckUserInput(u32 key){
if (mShowHand == HAND_HIDE || currentPlayer->isAI()){ if (mShowHand == HAND_HIDE || currentPlayer->isAI()){
return false; return false;
}else{ }else{
GuiCardsController::CheckUserInput(key); // GuiCardsController::CheckUserInput(key);
return true; return true;
} }
} }
@@ -98,7 +98,7 @@ void MTGGuiHand::Render(){
} }
if (mCount && mObjects[mCurr] != NULL){ if (mCount && mObjects[mCurr] != NULL){
mObjects[mCurr]->Render(); mObjects[mCurr]->Render();
if (showBigCards) ((CardGui *)mObjects[mCurr])->RenderBig(10,-1,showBigCards-1); // if (showBigCards) ((CardGui *)mObjects[mCurr])->RenderBig(10,-1,showBigCards-1);
} }
} }
} }
+22 -23
View File
@@ -23,7 +23,7 @@
MTGGuiPlay::MTGGuiPlay(int id, GameObserver * _game):PlayGuiObjectController(id, _game){ MTGGuiPlay::MTGGuiPlay(GameObserver* game) : game(game){
currentPlayer = NULL; currentPlayer = NULL;
offset = 0; offset = 0;
@@ -123,9 +123,9 @@ void MTGGuiPlay::setCardPosition(CardGui * cardg, int player, int playerTurn, in
if (!(cardg->x ==0 && cardg->y ==0)) return ; if (!(cardg->x ==0 && cardg->y ==0)) return ;
if (card->target) if (card->target)
return; return;
if (spellMode && (card->isACreature() || card->hasType("land"))) return; if (spellMode && (card->isCreature() || card->isLand())) return;
if (!spellMode && !card->isACreature() && !card->hasType("land")) return; if (!spellMode && !card->isCreature() && !card->isLand()) return;
if (card->isACreature()){ if (card->isCreature()){
int x_offset = nb_creatures[player] % cards_x_limit; int x_offset = nb_creatures[player] % cards_x_limit;
int y_offset = nb_creatures[player] / cards_x_limit; int y_offset = nb_creatures[player] / cards_x_limit;
cardg->x = ZX_MAIN + (Z_CARDWIDTH * x_offset); cardg->x = ZX_MAIN + (Z_CARDWIDTH * x_offset);
@@ -153,7 +153,6 @@ void MTGGuiPlay::setCardPosition(CardGui * cardg, int player, int playerTurn, in
} }
} }
} }
} }
}else{ }else{
if (card->isDefenser()){ if (card->isDefenser()){
@@ -196,7 +195,6 @@ void MTGGuiPlay::setTargettingCardPosition(CardGui * cardg, int player, int play
} }
void MTGGuiPlay::forceUpdateCards(){ void MTGGuiPlay::forceUpdateCards(){
GameObserver * game = GameObserver::GetInstance();
Player * player = game->players[0]; Player * player = game->players[0];
int player0Mode =(game->currentPlayer == player); int player0Mode =(game->currentPlayer == player);
int nb_cards = player->game->inPlay->nb_cards; int nb_cards = player->game->inPlay->nb_cards;
@@ -211,14 +209,14 @@ void MTGGuiPlay::forceUpdateCards(){
for (int i = 0;i<nb_cards; i++){ for (int i = 0;i<nb_cards; i++){
if (hasFocus) mCurr = mCount ; if (hasFocus) mCurr = mCount ;
CardGui * object = NEW CardGui(mCount, player->game->inPlay->cards[i],40, i*35 + 10, 200, hasFocus); CardView* object = NEW CardView(player->game->inPlay->cards[i], i*35 + 10, 200);
Add(object); Add(object);
hasFocus = false; hasFocus = false;
} }
hasFocus = !player0Mode; hasFocus = !player0Mode;
for (int i = 0;i<opponent_cards; i++){ for (int i = 0;i<opponent_cards; i++){
if (hasFocus) mCurr = mCount ; if (hasFocus) mCurr = mCount ;
CardGui * object = NEW CardGui(mCount, opponent->game->inPlay->cards[i],40, i*35 + 10, 10, hasFocus); CardView* object = NEW CardView(opponent->game->inPlay->cards[i], i*35 + 10, 10);
Add(object); Add(object);
hasFocus = false; hasFocus = false;
} }
@@ -226,16 +224,17 @@ void MTGGuiPlay::forceUpdateCards(){
currentPlayer = game->currentPlayer; currentPlayer = game->currentPlayer;
} }
int MTGGuiPlay::receiveEvent(WEvent *event){ int MTGGuiPlay::receiveEventPlus(WEvent *event){
WEventZoneChange * e = dynamic_cast<WEventZoneChange*>(event); WEventZoneChange * e = dynamic_cast<WEventZoneChange*>(event);
if (!e) return 0; if (!e) return 0;
int ok = 0; if (e->from == game->players[0]->game->inPlay || e->from == game->players[1]->game->inPlay)
for (int i = 0; i < 2 ; i++){ {
Player * p = game->players[i]; for (vector<JGuiObject*>::iterator it = mObjects.begin(); it != mObjects.end(); ++it)
if (e->from == p->game->inPlay || e->to == p->game->inPlay ) ok = 1; if (*it == (JGuiObject*)e->card) { mObjects.erase(it); delete(*it); return 1; }
} }
if (!ok) return 0; else if (e->to == game->players[0]->game->inPlay || e->to == game->players[1]->game->inPlay)
forceUpdateCards(); Add(NEW CardView(e->card, 500, 300));
// forceUpdateCards();
updateCards(); updateCards();
return 1; return 1;
} }
@@ -296,15 +295,15 @@ void MTGGuiPlay::updateCards(){
void MTGGuiPlay::AddPlayersGuiInfo(){ void MTGGuiPlay::AddPlayersGuiInfo(){
//init with the players objects //init with the players objects
if (mCount == 0){ if (mCount == 0){
Add(NEW GuiAvatar(-1,50,2,155,false, GameObserver::GetInstance()->players[0])); Add(NEW GuiAvatar(2,155,false, GameObserver::GetInstance()->players[0], GuiAvatar::BOTTOM_RIGHT, NULL));
Add(NEW GuiAvatar(-2,50,2,30,false,GameObserver::GetInstance()->players[1])); Add(NEW GuiAvatar(2,30,false,GameObserver::GetInstance()->players[1], GuiAvatar::BOTTOM_RIGHT, NULL));
Add(NEW GuiGraveyard(-3,30,40,150,false, GameObserver::GetInstance()->players[0])); Add(NEW GuiGraveyard(40,150,false, GameObserver::GetInstance()->players[0], NULL));
Add(NEW GuiLibrary(-4,30,40,180,false, GameObserver::GetInstance()->players[0])); Add(NEW GuiLibrary(40,180,false, GameObserver::GetInstance()->players[0], NULL));
Add(NEW GuiGraveyard(-5,30,40,30,false, GameObserver::GetInstance()->players[1])); Add(NEW GuiGraveyard(40,30,false, GameObserver::GetInstance()->players[1], NULL));
Add(NEW GuiLibrary(-6,30,40,60,false, GameObserver::GetInstance()->players[1])); Add(NEW GuiLibrary(40,60,false, GameObserver::GetInstance()->players[1], NULL));
} }
} }
@@ -322,7 +321,7 @@ bool MTGGuiPlay::CheckUserInput(u32 key){
return zone->cd->CheckUserInput(key); return zone->cd->CheckUserInput(key);
} }
} }
return PlayGuiObjectController::CheckUserInput(key); return true; //PlayGuiObjectController::CheckUserInput(key);
} }
@@ -439,7 +438,7 @@ void MTGGuiPlay::Render(){
if (hasFocus && mCurr >= offset && showBigCards && !game->currentlyActing()->isAI() ){ if (hasFocus && mCurr >= offset && showBigCards && !game->currentlyActing()->isAI() ){
//For some reason RenderBig crashes when the testsuite is playing, so we add a "isAI()" test...which was supposed to be there at some point anyways... //For some reason RenderBig crashes when the testsuite is playing, so we add a "isAI()" test...which was supposed to be there at some point anyways...
CardGui * cardg = ((CardGui *)mObjects[mCurr]); CardGui * cardg = ((CardGui *)mObjects[mCurr]);
cardg->RenderBig(-1,-1,showBigCards-1); //cardg->RenderBig(-1,-1,showBigCards-1);
} }
} }
LOG("End MTGGuiPlay Render\n"); LOG("End MTGGuiPlay Render\n");
+5 -6
View File
@@ -65,9 +65,8 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card){
if (game->targetChooser){ if (game->targetChooser){
spell = game->mLayers->stackLayer()->addSpell(card,game->targetChooser, spellCost); spell = game->mLayers->stackLayer()->addSpell(card,game->targetChooser, spellCost);
game->targetChooser = NULL; game->targetChooser = NULL;
}else{ }else
spell = game->mLayers->stackLayer()->addSpell(card,NULL, spellCost); spell = game->mLayers->stackLayer()->addSpell(card,NULL, spellCost);
}
MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->stack); MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->stack);
spell->source = copy; spell->source = copy;
} }
@@ -160,7 +159,7 @@ int MTGBlockRule::reactToClick(MTGCardInstance * card){
currentOpponent = game->currentPlayer->game->inPlay->getNextAttacker(currentOpponent); currentOpponent = game->currentPlayer->game->inPlay->getNextAttacker(currentOpponent);
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
char buf[4096]; char buf[4096];
sprintf(buf,"Defenser Toggle %s \n" ,card->model->getName()); sprintf(buf,"Defenser Toggle %s \n", card->model->getName().c_str());
OutputDebugString(buf); OutputDebugString(buf);
#endif #endif
candefend = card->toggleDefenser(currentOpponent); candefend = card->toggleDefenser(currentOpponent);
@@ -201,7 +200,7 @@ MTGMomirRule::MTGMomirRule(int _id, MTGAllCards * _collection):MTGAbility(_id, N
if (!initialized){ if (!initialized){
for (size_t i = 0; i < collection->ids.size(); i++){ for (size_t i = 0; i < collection->ids.size(); i++){
MTGCard * card = collection->collection[collection->ids[i]]; MTGCard * card = collection->collection[collection->ids[i]];
if (card->isACreature()){ if (card->isCreature()){
int convertedCost = card->getManaCost()->getConvertedCost(); int convertedCost = card->getManaCost()->getConvertedCost();
if (convertedCost>20) continue; if (convertedCost>20) continue;
pool[convertedCost].push_back(card->getMTGId()); pool[convertedCost].push_back(card->getMTGId());
@@ -372,7 +371,7 @@ int HUDDisplay::receiveEvent(WEvent * event){
return 0; return 0;
} }
void HUDDisplay::Render(){ void HUDDisplay::Render(){
if (!GameOptions::GetInstance()->values[OPTIONS_OSD].getIntValue()) return; if (!options[Options::OSD].number) return;
if (!events.size()) return; if (!events.size()) return;
f->SetColor(ARGB(255,255,255,255)); f->SetColor(ARGB(255,255,255,255));
@@ -473,7 +472,7 @@ HUDDisplay::~HUDDisplay(){
int destroy = 0; int destroy = 0;
for ( it=cards.begin() ; it != cards.end(); it++ ){ for ( it=cards.begin() ; it != cards.end(); it++ ){
MTGCardInstance * comparison = (*it).first; MTGCardInstance * comparison = (*it).first;
if (comparison!= card && !strcmp(comparison->getName(), card->getName())){ if (comparison != card && !(comparison->getName().compare(card->getName()))){
comparison->owner->game->putInGraveyard(comparison); comparison->owner->game->putInGraveyard(comparison);
destroy = 1; destroy = 1;
} }
+3 -5
View File
@@ -9,14 +9,14 @@ OptionItem::OptionItem(string _id, string _displayValue, int _maxValue, int _inc
maxValue = _maxValue; maxValue = _maxValue;
increment = _increment; increment = _increment;
displayValue = _(_displayValue); displayValue = _(_displayValue);
value = GameOptions::GetInstance()->values[id].getIntValue(); value = options[id].number;
hasFocus = 0; hasFocus = 0;
x = 0; x = 0;
y = 0; y = 0;
} }
void OptionItem::setData(){ void OptionItem::setData(){
GameOptions::GetInstance()->values[id] = GameOption(value); options[id] = GameOption(value);
} }
void OptionItem::Render(){ void OptionItem::Render(){
@@ -60,8 +60,6 @@ bool OptionItem::Leaving(){
} }
OptionItem * options[20];
int nbitems;
OptionsList::OptionsList(){ OptionsList::OptionsList(){
nbitems = 0; nbitems = 0;
current = -1; current = -1;
@@ -100,7 +98,7 @@ void OptionsList::save(){
for (int i = 0; i < nbitems; i++){ for (int i = 0; i < nbitems; i++){
options[i]->setData(); options[i]->setData();
} }
GameOptions::GetInstance()->save(); ::options.save();
} }
void OptionsList::Update(float dt){ void OptionsList::Update(float dt){
+16 -142
View File
@@ -1,15 +1,19 @@
#include <iostream>
#include "../include/config.h" #include "../include/config.h"
#include "../include/PlayGuiObject.h" #include "../include/PlayGuiObject.h"
#include "../include/Player.h" using namespace std;
#include "../include/MTGGameZones.h"
#include "../include/CardDisplay.h"
PlayGuiObject::PlayGuiObject(int id, float desiredHeight,float _x, float _y, bool hasFocus): JGuiObject(id){ PlayGuiObject::PlayGuiObject(float desiredHeight, float x, float y, bool hasFocus) : JGuiObject(0), Pos(x, y, 1.0, 0.0, 255) {
defaultHeight = desiredHeight;
mHeight = desiredHeight;
mHasFocus = hasFocus;
type = 0;
wave = 0;
}
PlayGuiObject::PlayGuiObject(float desiredHeight, const Pos& ref, bool hasFocus) : JGuiObject(0), Pos(ref) {
defaultHeight = desiredHeight; defaultHeight = desiredHeight;
mHeight = desiredHeight; mHeight = desiredHeight;
x = _x;
y = _y;
mHasFocus = hasFocus; mHasFocus = hasFocus;
type = 0; type = 0;
wave = 0; wave = 0;
@@ -32,143 +36,13 @@ void PlayGuiObject::Update(float dt){
mHeight = defaultHeight; mHeight = defaultHeight;
} }
wave = (wave +2) % 255; wave = (wave +2) % 255;
for (vector<Effect*>::iterator it = effects.begin(); it != effects.end(); ++it)
(*it)->Update(dt);
Pos::Update(dt);
} }
GuiAvatar::GuiAvatar(int id, float desiredHeight,float _x, float _y, bool hasFocus, Player * _player): PlayGuiObject(id, desiredHeight, _x, _y, hasFocus){ void PlayGuiObject::Render()
player= _player;
avatarRed = 255;
currentLife = player->life;
type = GUI_AVATAR;
}
void GuiAvatar::Render(){
GameObserver * game = GameObserver::GetInstance();
JRenderer * r = JRenderer::GetInstance();
int life = player->life;
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
//Avatar
int lifeDiff = life - currentLife;
if (lifeDiff < 0 && currentLife >0 ){
avatarRed = 192 + (3* 255 * lifeDiff)/ currentLife / 4;
if (avatarRed<0)
avatarRed = 0;
}
currentLife= life;
JQuad * quad = player->mAvatar;
if(quad){
quad->SetColor(ARGB(255,255,avatarRed,avatarRed));
r->RenderQuad(quad,x,y);
if (mHasFocus){
r->FillRect(x,y,quad->mWidth,quad->mHeight,ARGB(abs(wave-128), 255,255,255));
}
}
if (avatarRed < 255){
avatarRed+=3;
if (avatarRed >255)
avatarRed = 255;
}
if(game->currentPlayer == player){
r->DrawRect(x-1,y-1 ,37,52,ARGB(255,0,255,0));
}else if (game->currentActionPlayer == player){
r->DrawRect(x,y,35,50,ARGB(255,0,0,255));
}
if(game->isInterrupting == player){
r->DrawRect(x,y ,35,50,ARGB(255,255,0,0));
}
//Life
char buffer[5];
sprintf(buffer, "%i",life);
mFont->SetColor(ARGB(128,0,0,0));
mFont->DrawString(buffer, x+3,y+40);
mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(buffer, x+1,y+38);
}
ostream& GuiAvatar::toString(ostream& out) const
{ {
return out << "GuiAvatar ::: avatarRed : " << avatarRed for (vector<Effect*>::iterator it = effects.begin(); it != effects.end(); ++it)
<< " ; currentLife : " << currentLife (*it)->Render();
<< " ; player : " << player;
}
void GuiGameZone::toggleDisplay(){
if (showCards){
showCards = 0;
}else{
showCards = 1;
cd->init(zone);
}
}
void GuiGameZone::Render(){
//Texture
JQuad * quad = GameApp::CommonRes->GetQuad("back_thumb");
float scale = defaultHeight / quad->mHeight;
quad->SetColor(ARGB(255,255,255,255));
JRenderer::GetInstance()->RenderQuad(quad,x,y,0.0,scale, scale);
if (mHasFocus){
JRenderer::GetInstance()->FillRect(x,y,quad->mWidth*scale,quad->mHeight*scale,ARGB(abs(wave-128), 255,255,255));
}
//Number of cards
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[512];
sprintf(buffer,"%i", zone->nb_cards);
mFont->SetColor(ARGB(128,0,0,0));
mFont->DrawString(buffer, x+2, y+2);
mFont->SetColor(ARGB(255,255,255,255));
mFont->DrawString(buffer, x, y);
if (showCards) cd->Render();
}
void GuiGameZone::ButtonPressed(int controllerId, int controlId){
GameObserver::GetInstance()->ButtonPressed(GetId(), this);
}
void GuiGameZone::Update(float dt){
if (showCards) cd->Update(dt);
PlayGuiObject::Update(dt);
}
GuiGameZone::GuiGameZone(int id, float desiredHeight,float _x, float _y, bool hasFocus,MTGGameZone * _zone): PlayGuiObject(id, desiredHeight, _x, _y, hasFocus), zone(_zone){
cd = NEW CardDisplay(id, GameObserver::GetInstance(), _x, _y,this);
showCards = 0;
}
GuiGameZone::~GuiGameZone(){
if(cd) delete cd;
}
ostream& GuiGameZone::toString(ostream& out) const
{
return out << "GuiGameZone ::: zone : " << zone
<< " ; cd : " << cd
<< " ; showCards : " << showCards;
}
GuiGraveyard::GuiGraveyard(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * player):GuiGameZone(id, desiredHeight, _x, _y, hasFocus,player->game->graveyard){
type= GUI_GRAVEYARD;
}
ostream& GuiGraveyard::toString(ostream& out) const
{
return out << "GuiGraveyard :::";
}
GuiLibrary::GuiLibrary(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * player):GuiGameZone(id, desiredHeight, _x, _y, hasFocus,player->game->library){
type = GUI_LIBRARY;
}
ostream& GuiLibrary::toString(ostream& out) const
{
return out << "GuiLibrary :::";
} }
@@ -86,6 +86,7 @@ void PlayGuiObjectController::Update(float dt){
bool PlayGuiObjectController::CheckUserInput(u32 key){ bool PlayGuiObjectController::CheckUserInput(u32 key){
/*
if (!mCount) if (!mCount)
return false; return false;
if (game != NULL){ if (game != NULL){
@@ -148,5 +149,6 @@ bool PlayGuiObjectController::CheckUserInput(u32 key){
showBigCards = (showBigCards + 1) % 3; showBigCards = (showBigCards + 1) % 3;
return true; return true;
} }
*/
return false; return false;
} }
+4 -4
View File
@@ -4,10 +4,10 @@
#include "../include/DeckStats.h" #include "../include/DeckStats.h"
Player::Player(MTGPlayerCards * _deck, string file, string fileSmall): Damageable(20){ Player::Player(MTGPlayerCards * deck, string file, string fileSmall) : Damageable(20){
deckFile = file; deckFile = file;
deckFileSmall = fileSmall; deckFileSmall = fileSmall;
game = _deck; game = deck;
game->setOwner(this); game->setOwner(this);
manaPool = NEW ManaCost(); manaPool = NEW ManaCost();
canPutLandsIntoPlay = 1; canPutLandsIntoPlay = 1;
@@ -26,7 +26,7 @@ Player::~Player(){
if (mAvatar) delete mAvatar; if (mAvatar) delete mAvatar;
} }
const char * Player::getDisplayName(){ const string Player::getDisplayName(){
GameObserver * g = GameObserver::GetInstance(); GameObserver * g = GameObserver::GetInstance();
if (this == g->players[0]) return "Player 1"; if (this == g->players[0]) return "Player 1";
return "Player 2"; return "Player 2";
@@ -57,7 +57,7 @@ Player * Player::opponent(){
return NULL; return NULL;
} }
HumanPlayer::HumanPlayer(MTGPlayerCards * _deck, char * file, string fileSmall):Player(_deck, file, fileSmall){ HumanPlayer::HumanPlayer(MTGPlayerCards * deck, string file, string fileSmall) : Player(deck, file, fileSmall) {
mAvatarTex = JRenderer::GetInstance()->LoadTexture("player/avatar.jpg", TEX_TYPE_USE_VRAM); mAvatarTex = JRenderer::GetInstance()->LoadTexture("player/avatar.jpg", TEX_TYPE_USE_VRAM);
if (mAvatarTex) if (mAvatarTex)
mAvatar = NEW JQuad(mAvatarTex, 0, 0, 35, 50); mAvatar = NEW JQuad(mAvatarTex, 0, 0, 35, 50);
+1 -1
View File
@@ -5,7 +5,7 @@
#include "../include/Damage.h" #include "../include/Damage.h"
REDamagePrevention::REDamagePrevention(MTGAbility * _source, TargetChooser *_tcSource, TargetChooser *_tcTarget,int _damage, bool _oneShot):source(_source),tcSource(_tcSource), tcTarget(_tcTarget),damage(_damage), oneShot(_oneShot){ REDamagePrevention::REDamagePrevention(MTGAbility * source, TargetChooser *tcSource, TargetChooser *tcTarget, int damage, bool oneShot):source(source), tcSource(tcSource), tcTarget(tcTarget), damage(damage), oneShot(oneShot){
} }
WEvent * REDamagePrevention::replace (WEvent *event){ WEvent * REDamagePrevention::replace (WEvent *event){
+6 -8
View File
@@ -2,11 +2,11 @@
#include "../include/ShopItem.h" #include "../include/ShopItem.h"
#include "../include/GameStateShop.h" #include "../include/GameStateShop.h"
#include "../include/CardGui.h" #include "../include/CardGui.h"
#include "../include/TexturesCache.h"
#include "../include/Translate.h" #include "../include/Translate.h"
#include <hge/hgedistort.h> #include <hge/hgedistort.h>
float ShopItems::_x1[] = { 40, 3, 23, 99,142,182, 90,132,177,106,163}; float ShopItems::_x1[] = { 40, 3, 23, 99,142,182, 90,132,177,106,163};
float ShopItems::_y1[] = {156,174,194,166,166,162,184,185,180,211,208}; float ShopItems::_y1[] = {156,174,194,166,166,162,184,185,180,211,208};
@@ -66,8 +66,9 @@ ShopItem::ShopItem(int id, JLBFont *font, int _cardid, float _xy[], bool hasFocu
quantity = 1 + (rand() % 4); quantity = 1 + (rand() % 4);
if (card->getRarity() == Constants::RARITY_L) quantity = 50; if (card->getRarity() == Constants::RARITY_L) quantity = 50;
quad = NULL; quad = NULL;
thumb = card->getThumb(); // thumb = card->getThumb();
if (!thumb) thumb = GameApp::CommonRes->GetQuad("back_thumb"); // if (!thumb)
thumb = GameApp::CommonRes->GetQuad("back_thumb");
if (thumb){ if (thumb){
mesh=NEW hgeDistortionMesh(2,2); mesh=NEW hgeDistortionMesh(2,2);
mesh->SetTexture(thumb->mTex); mesh->SetTexture(thumb->mTex);
@@ -115,7 +116,6 @@ void ShopItem::Render(){
mFont->SetColor(ARGB(255,128,128,128)); mFont->SetColor(ARGB(255,128,128,128));
} }
if (card){ if (card){
if (nameCount){ if (nameCount){
char buffer[512]; char buffer[512];
@@ -153,14 +153,12 @@ void ShopItem::Render(){
//NOTHING //NOTHING
} }
if (mHasFocus){ if (mHasFocus){
if (card){ if (card) quad = cache.getQuad(card);
quad = card->getQuad();
}
if (quad){ if (quad){
quad->SetColor(ARGB(255,255,255,255)); quad->SetColor(ARGB(255,255,255,255));
renderer->RenderQuad(quad,SCREEN_WIDTH/2 + 50,5,0, 0.9f,0.9f); renderer->RenderQuad(quad,SCREEN_WIDTH/2 + 50,5,0, 0.9f,0.9f);
}else{ }else{
if (card) CardGui::alternateRender(card,NULL,SCREEN_WIDTH/2 + 100 + 20,133,0, 0.9f); // if (card) CardGui::alternateRender(card,NULL,SCREEN_WIDTH/2 + 100 + 20,133,0, 0.9f);
} }
mFont->DrawString(mText.c_str(), 100, SCREEN_HEIGHT - 30); mFont->DrawString(mText.c_str(), 100, SCREEN_HEIGHT - 30);
} }
+59 -76
View File
@@ -274,16 +274,16 @@ TargetChooser::TargetChooser(MTGCardInstance * card, int _maxtargets): TargetsLi
//Default targetter : every card can be targetted, unless it is protected from the targetter card //Default targetter : every card can be targetted, unless it is protected from the targetter card
// For spells that do not "target" a specific card, set targetter to NULL // For spells that do not "target" a specific card, set targetter to NULL
int TargetChooser::canTarget(Targetable * target){ bool TargetChooser::canTarget(Targetable * target){
if (target->typeAsTarget() == TARGET_CARD){ if (target->typeAsTarget() == TARGET_CARD){
MTGCardInstance * card = (MTGCardInstance *) target; MTGCardInstance * card = (MTGCardInstance *) target;
if (targetter && card->isInPlay() && (card->has(Constants::SHROUD)|| card->protectedAgainst(targetter) )) return 0; if (source && card->isInPlay() && (card->has(Constants::SHROUD)|| card->protectedAgainst(source) )) return false;
if (source && targetter && card->isInPlay() && (source->controller() != card->controller()) && (card->has(Constants::OPPONENTSHROUD)|| card->protectedAgainst(targetter) )) return 0; if (source && targetter && card->isInPlay() && (source->controller() != card->controller()) && (card->has(Constants::OPPONENTSHROUD) || card->protectedAgainst(targetter))) return false;
return 1; return true;
}else if (target->typeAsTarget() == TARGET_STACKACTION){
return 1;
} }
return 0; else if (target->typeAsTarget() == TARGET_STACKACTION)
return true;
return false;
} }
@@ -340,17 +340,17 @@ CardTargetChooser::CardTargetChooser(MTGCardInstance * _card, MTGCardInstance *
validTarget = _card; validTarget = _card;
} }
int CardTargetChooser::canTarget(Targetable * target ){ bool CardTargetChooser::canTarget(Targetable * target ){
if (!target) return 0; if (!target) return false;
if (target->typeAsTarget() != TARGET_CARD) return 0; if (target->typeAsTarget() != TARGET_CARD) return false;
if (!nbzones && !TargetChooser::canTarget(target)) return 0; if (!nbzones && !TargetChooser::canTarget(target)) return false;
if (nbzones && !TargetZoneChooser::canTarget(target)) return 0; if (nbzones && !TargetZoneChooser::canTarget(target)) return false;
MTGCardInstance * card = (MTGCardInstance *) target; MTGCardInstance * card = (MTGCardInstance *) target;
while (card) { while (card) {
if(card == validTarget) return 1; if (card == validTarget) return true;
card = card->previous; card = card->previous;
} }
return 0; return false;
} }
/** /**
@@ -386,28 +386,28 @@ void TypeTargetChooser::addType(int type){
nbtypes++; nbtypes++;
} }
int TypeTargetChooser::canTarget(Targetable * target ){ bool TypeTargetChooser::canTarget(Targetable * target){
if (!TargetZoneChooser::canTarget(target)) return 0; if (!TargetZoneChooser::canTarget(target)) return false;
if (target->typeAsTarget() == TARGET_CARD){ if (target->typeAsTarget() == TARGET_CARD){
MTGCardInstance * card = (MTGCardInstance *) target; MTGCardInstance * card = (MTGCardInstance *) target;
for (int i= 0; i < nbtypes; i++){ for (int i= 0; i < nbtypes; i++){
if (card->hasSubtype(types[i])) return 1; if (card->hasSubtype(types[i])) return true;
if (Subtypes::subtypesList->find(card->name) == types[i]) return 1; if (Subtypes::subtypesList->find(card->name) == types[i]) return true;
} }
return 0; return false;
}else if (target->typeAsTarget() == TARGET_STACKACTION){ }else if (target->typeAsTarget() == TARGET_STACKACTION){
Interruptible * action = (Interruptible *) target; Interruptible * action = (Interruptible *) target;
if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){ if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){
Spell * spell = (Spell *) action; Spell * spell = (Spell *) action;
MTGCardInstance * card = spell->source; MTGCardInstance * card = spell->source;
for (int i= 0; i < nbtypes; i++){ for (int i= 0; i < nbtypes; i++){
if (card->hasSubtype(types[i])) return 1; if (card->hasSubtype(types[i])) return true;
if (Subtypes::subtypesList->find(card->name) == types[i]) return 1; if (Subtypes::subtypesList->find(card->name) == types[i]) return true;
} }
return 0; return false;
} }
} }
return 0; return false;
} }
@@ -430,20 +430,20 @@ DescriptorTargetChooser::DescriptorTargetChooser(CardDescriptor * _cd, int * _zo
cd = _cd; cd = _cd;
} }
int DescriptorTargetChooser::canTarget(Targetable * target){ bool DescriptorTargetChooser::canTarget(Targetable * target){
if (!TargetZoneChooser::canTarget(target)) return 0; if (!TargetZoneChooser::canTarget(target)) return false;
if (target->typeAsTarget() == TARGET_CARD){ if (target->typeAsTarget() == TARGET_CARD){
MTGCardInstance * _target = (MTGCardInstance *) target; MTGCardInstance * _target = (MTGCardInstance *) target;
if (cd->match(_target)) return 1; if (cd->match(_target)) return true;
}else if (target->typeAsTarget() == TARGET_STACKACTION){ }else if (target->typeAsTarget() == TARGET_STACKACTION){
Interruptible * action = (Interruptible *) target; Interruptible * action = (Interruptible *) target;
if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){ if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){
Spell * spell = (Spell *) action; Spell * spell = (Spell *) action;
MTGCardInstance * card = spell->source; MTGCardInstance * card = spell->source;
if (cd->match(card)) return 1; if (cd->match(card)) return true;
} }
} }
return 0; return false;
} }
DescriptorTargetChooser::~DescriptorTargetChooser(){ DescriptorTargetChooser::~DescriptorTargetChooser(){
@@ -473,15 +473,15 @@ CreatureTargetChooser::CreatureTargetChooser(int * _zones, int nbzones, MTGCardI
} }
int CreatureTargetChooser::canTarget(Targetable * target){ bool CreatureTargetChooser::canTarget(Targetable * target){
if (!TargetZoneChooser::canTarget(target)) return 0; if (!TargetZoneChooser::canTarget(target)) return false;
if (target->typeAsTarget() == TARGET_CARD){ if (target->typeAsTarget() == TARGET_CARD){
MTGCardInstance * card = (MTGCardInstance *) target; MTGCardInstance * card = (MTGCardInstance *) target;
if (maxpower != -1 && card->power > maxpower) return 0; if (maxpower != -1 && card->power > maxpower) return false;
if (maxtoughness != -1 && card->toughness > maxtoughness) return 0; if (maxtoughness != -1 && card->toughness > maxtoughness) return false;
return card->isACreature(); return card->isCreature();
} }
return 0; return false;
} }
@@ -502,57 +502,47 @@ int TargetZoneChooser::init(int * _zones, int _nbzones){
return nbzones; return nbzones;
} }
int TargetZoneChooser::canTarget(Targetable * target){ bool TargetZoneChooser::canTarget(Targetable * target){
if (!TargetChooser::canTarget(target)) return 0; if (!TargetChooser::canTarget(target)) return false;
if (target->typeAsTarget() == TARGET_CARD){ if (target->typeAsTarget() == TARGET_CARD){
MTGCardInstance * card = (MTGCardInstance *) target; MTGCardInstance * card = (MTGCardInstance *) target;
for (int i = 0; i<nbzones; i++){ for (int i = 0; i<nbzones; i++)
if (MTGGameZone::intToZone(zones[i],source,card)->hasCard(card)) return 1; if (MTGGameZone::intToZone(zones[i],source,card)->hasCard(card)) return true;
}
}else if (target->typeAsTarget() == TARGET_STACKACTION){ }else if (target->typeAsTarget() == TARGET_STACKACTION){
OutputDebugString ("CHECKING INTERRUPTIBLE\n"); OutputDebugString ("CHECKING INTERRUPTIBLE\n");
Interruptible * action = (Interruptible *) target; Interruptible * action = (Interruptible *) target;
if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){ if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){
Spell * spell = (Spell *) action; Spell * spell = (Spell *) action;
MTGCardInstance * card = spell->source; MTGCardInstance * card = spell->source;
for (int i = 0; i<nbzones; i++){ for (int i = 0; i<nbzones; i++)
if (MTGGameZone::intToZone(zones[i],source,card)->hasCard(card)) return 1; if (MTGGameZone::intToZone(zones[i],source,card)->hasCard(card)) return true;
} }
} }
} return false;
return 0;
} }
int TargetZoneChooser::targetsZone(MTGGameZone * z){ int TargetZoneChooser::targetsZone(MTGGameZone * z){
for (int i = 0; i < nbzones; i++){ for (int i = 0; i < nbzones; i++)
if (MTGGameZone::intToZone(zones[i],source) == z) return 1; if (MTGGameZone::intToZone(zones[i],source) == z) return 1;
}
return 0; return 0;
} }
/* Player Target */ /* Player Target */
PlayerTargetChooser::PlayerTargetChooser(MTGCardInstance * card, int _maxtargets, Player *p):TargetChooser(card, _maxtargets), p(p){
PlayerTargetChooser::PlayerTargetChooser(MTGCardInstance * card, int _maxtargets, Player *_p):TargetChooser(card, _maxtargets){
p = _p;
} }
int PlayerTargetChooser::canTarget(Targetable * target){ bool PlayerTargetChooser::canTarget(Targetable * target){
if (target->typeAsTarget() == TARGET_PLAYER){ return (target->typeAsTarget() == TARGET_PLAYER) && (!p || p == (Player*)target);
Player * _target = (Player *) target;
if (!p || p == _target) return 1;
}
return 0;
} }
/*Damageable Target */ /*Damageable Target */
int DamageableTargetChooser::canTarget(Targetable * target){ bool DamageableTargetChooser::canTarget(Targetable * target){
if (target->typeAsTarget() == TARGET_PLAYER){ if (target->typeAsTarget() == TARGET_PLAYER){
#if defined (WIN32) || defined (LINUX) #if defined (WIN32) || defined (LINUX)
OutputDebugString("Targetting Player !!!\n"); OutputDebugString("Targetting Player !!!\n");
#endif #endif
return 1; return true;
} }
return CreatureTargetChooser::canTarget(target); return CreatureTargetChooser::canTarget(target);
} }
@@ -566,19 +556,18 @@ SpellTargetChooser::SpellTargetChooser(MTGCardInstance * card,int _color, int _m
color = _color; color = _color;
} }
int SpellTargetChooser::canTarget(Targetable * target){ bool SpellTargetChooser::canTarget(Targetable * target){
MTGCardInstance * card = NULL; MTGCardInstance * card = NULL;
if (target->typeAsTarget() == TARGET_STACKACTION){ if (target->typeAsTarget() == TARGET_STACKACTION){
Interruptible * action = (Interruptible *) target; Interruptible * action = (Interruptible *) target;
if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){ if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){
Spell * spell = (Spell *) action; Spell * spell = (Spell *) action;
card = spell->source; card = spell->source;
if (card && (color == -1 || card->hasColor(color))) return 1; if (card && (color == -1 || card->hasColor(color))) return true;
} }
} }
return 0; return false;
} }
@@ -589,7 +578,7 @@ SpellOrPermanentTargetChooser::SpellOrPermanentTargetChooser(MTGCardInstance * c
color = _color; color = _color;
} }
int SpellOrPermanentTargetChooser::canTarget(Targetable * target){ bool SpellOrPermanentTargetChooser::canTarget(Targetable * target){
MTGCardInstance * card = NULL; MTGCardInstance * card = NULL;
if (target->typeAsTarget() == TARGET_CARD){ if (target->typeAsTarget() == TARGET_CARD){
card = (MTGCardInstance *) target; card = (MTGCardInstance *) target;
@@ -599,12 +588,10 @@ int SpellOrPermanentTargetChooser::canTarget(Targetable * target){
if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){ if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){
Spell * spell = (Spell *) action; Spell * spell = (Spell *) action;
card = spell->source; card = spell->source;
if (card && (color == -1 || card->hasColor(color))) return 1; if (card && (color == -1 || card->hasColor(color))) return true;
} }
} }
return false;
return 0;
} }
@@ -615,19 +602,17 @@ DamageTargetChooser::DamageTargetChooser(MTGCardInstance * card,int _color, int
state = _state; state = _state;
} }
int DamageTargetChooser::canTarget(Targetable * target){ bool DamageTargetChooser::canTarget(Targetable * target){
MTGCardInstance * card = NULL; MTGCardInstance * card = NULL;
if (target->typeAsTarget() == TARGET_STACKACTION){ if (target->typeAsTarget() == TARGET_STACKACTION){
Interruptible * action = (Interruptible *) target; Interruptible * action = (Interruptible *) target;
if (action->type == ACTION_DAMAGE && (action->state == state || state == -1)){ if (action->type == ACTION_DAMAGE && (action->state == state || state == -1)){
Damage * damage = (Damage *) action; Damage * damage = (Damage *) action;
card = damage->source; card = damage->source;
if (card && (color == -1 || card->hasColor(color))) return 1; if (card && (color == -1 || card->hasColor(color))) return true;
} }
} }
return false;
return 0;
} }
@@ -638,7 +623,7 @@ DamageOrPermanentTargetChooser::DamageOrPermanentTargetChooser(MTGCardInstance *
color = _color; color = _color;
} }
int DamageOrPermanentTargetChooser::canTarget(Targetable * target){ bool DamageOrPermanentTargetChooser::canTarget(Targetable * target){
MTGCardInstance * card = NULL; MTGCardInstance * card = NULL;
if (target->typeAsTarget() == TARGET_CARD){ if (target->typeAsTarget() == TARGET_CARD){
card = (MTGCardInstance *) target; card = (MTGCardInstance *) target;
@@ -648,10 +633,8 @@ int DamageOrPermanentTargetChooser::canTarget(Targetable * target){
if (action->type == ACTION_DAMAGE){ if (action->type == ACTION_DAMAGE){
Damage * damage = (Damage *) action; Damage * damage = (Damage *) action;
card = damage->source; card = damage->source;
if (card && (color == -1 || card->hasColor(color))) return 1; if (card && (color == -1 || card->hasColor(color))) return true;
} }
} }
return false;
return 0;
} }
+8 -4
View File
@@ -64,7 +64,7 @@ int TestSuiteAI::Act(float dt){
string action = suite->getNextAction(); string action = suite->getNextAction();
g->mLayers->stackLayer()->Dump(); g->mLayers->stackLayer()->Dump();
DamageResolverLayer * drl = g->mLayers->combatLayer(); // DamageResolverLayer * drl = g->mLayers->combatLayer();
OutputDebugString(action.c_str()); OutputDebugString(action.c_str());
OutputDebugString("\n"); OutputDebugString("\n");
@@ -90,6 +90,7 @@ int TestSuiteAI::Act(float dt){
g->userRequestNextGamePhase(); g->userRequestNextGamePhase();
} }
else if (action.compare("next")==0){ else if (action.compare("next")==0){
/*
if (drl->orderingIsNeeded){ if (drl->orderingIsNeeded){
drl->blockersOrderingDone(); drl->blockersOrderingDone();
g->userRequestNextGamePhase(); g->userRequestNextGamePhase();
@@ -100,6 +101,7 @@ int TestSuiteAI::Act(float dt){
}else{ }else{
g->userRequestNextGamePhase(); g->userRequestNextGamePhase();
} }
*/
}else if (action.compare("yes")==0){ }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){
@@ -121,7 +123,7 @@ int TestSuiteAI::Act(float dt){
g->mLayers->actionLayer()->stuffHappened = 1; g->mLayers->actionLayer()->stuffHappened = 1;
}else if(action.find("p1")!=string::npos || action.find("p2")!=string::npos){ }else if(action.find("p1")!=string::npos || action.find("p2")!=string::npos){
Player * p = g->players[1]; Player * p = g->players[1];
int start = action.find("p1"); unsigned int start = action.find("p1");
if (start != string::npos) p = g->players[0]; if (start != string::npos) p = g->players[0];
g->cardClick(NULL, p); g->cardClick(NULL, p);
}else{ }else{
@@ -138,6 +140,7 @@ int TestSuiteAI::Act(float dt){
if (card) { if (card) {
OutputDebugString("Clicking ON: "); OutputDebugString("Clicking ON: ");
OutputDebugString(card->name.c_str()); OutputDebugString(card->name.c_str());
/*
if (drl->mCount){ if (drl->mCount){
if (drl->orderingIsNeeded){ if (drl->orderingIsNeeded){
OutputDebugString(" Ordering Card\n"); OutputDebugString(" Ordering Card\n");
@@ -149,6 +152,7 @@ int TestSuiteAI::Act(float dt){
}else{ }else{
g->cardClick(card,card); g->cardClick(card,card);
} }
*/
} }
} }
}else{ }else{
@@ -281,7 +285,7 @@ void TestSuite::initGame(){
for (int k = 0; k < initState.playerData[i].zones[j].nbitems; k++){ for (int k = 0; k < initState.playerData[i].zones[j].nbitems; k++){
MTGCardInstance * card = getCardByMTGId(initState.playerData[i].zones[j].cards[k]); MTGCardInstance * card = getCardByMTGId(initState.playerData[i].zones[j].cards[k]);
char buf[4096]; char buf[4096];
sprintf(buf, "QUAD : %p\n", card->getQuad()); sprintf(buf, "QUAD : %p\n", cache.getQuad(card));
OutputDebugString(buf); OutputDebugString(buf);
if (card && zone != p->game->library){ if (card && zone != p->game->library){
if (zone == p->game->inPlay){ if (zone == p->game->inPlay){
@@ -482,7 +486,7 @@ int TestSuite::load(const char * _filename){
int state = -1; int state = -1;
std::cout << std::endl << std::endl << "!!!" << file << std::endl << std::endl; // std::cout << std::endl << std::endl << "!!!" << file << std::endl << std::endl;
if(file){ if(file){
cleanup(); cleanup();
while(std::getline(file,s)){ while(std::getline(file,s)){
+6 -4
View File
@@ -3,16 +3,15 @@
#include "../include/GameOptions.h" #include "../include/GameOptions.h"
#include <JFileSystem.h> #include <JFileSystem.h>
TexturesCache cache;
TexturesCache::TexturesCache(){ TexturesCache::TexturesCache(){
nb_textures = 0; nb_textures = 0;
totalsize = 0; totalsize = 0;
delete_previous = 0; delete_previous = 0;
lastTime = 0; lastTime = 0;
for (int i=0; i<MAX_CACHE_OBJECTS;i++){ for (int i=0; i<MAX_CACHE_OBJECTS;i++)
cache[i] = NULL; cache[i] = NULL;
}
maxSize = GameOptions::GetInstance()->values[OPTIONS_CACHESIZE].getIntValue() * 100000;
if (!maxSize) maxSize = CACHE_SIZE_PIXELS;
#ifdef WIN32 #ifdef WIN32
char buf [4096]; char buf [4096];
sprintf(buf, " Init TextureCache : %p\n", this); sprintf(buf, " Init TextureCache : %p\n", this);
@@ -65,6 +64,8 @@ void TexturesCache::removeQuad(int id){
} }
int TexturesCache::cleanup(){ int TexturesCache::cleanup(){
int maxSize = options[Options::CACHESIZE].number * 100000;
if (!maxSize) maxSize = CACHE_SIZE_PIXELS;
while (nb_textures >= MAX_CACHE_OBJECTS - 1 || totalsize > maxSize){ while (nb_textures >= MAX_CACHE_OBJECTS - 1 || totalsize > maxSize){
int i = getOldestQuad(); int i = getOldestQuad();
if (i == -1) return 0; if (i == -1) return 0;
@@ -126,6 +127,7 @@ CardTexture::CardTexture(MTGCard * card, int _type): type(_type){
} }
if (tex){ if (tex){
quad = NEW JQuad(tex, 0.0f, 0.0f, tex->mWidth, tex->mHeight); quad = NEW JQuad(tex, 0.0f, 0.0f, tex->mWidth, tex->mHeight);
quad->SetHotSpot(tex->mWidth / 2, tex->mHeight / 2);
nbpixels = tex->mTexHeight * tex->mTexWidth; nbpixels = tex->mTexHeight * tex->mTexWidth;
} }
mtgid = card->getId(); mtgid = card->getId();
-2
View File
@@ -16,6 +16,4 @@ Token::Token(string _name, MTGCardInstance * source, int _power, int _toughness)
attacker = 0; attacker = 0;
defenser = NULL; defenser = NULL;
banding = NULL; banding = NULL;
mCache = source->mCache;
} }

Some files were not shown because too many files have changed in this diff Show More