* 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

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))
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.

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

View File

@@ -1,17 +1,17 @@
#ifndef _AIMOMIRPLAYER_H_
#define _AIMOMIRPLAYER_H_
#include "AIPlayer.h"
class AIMomirPlayer:public AIPlayerBaka{
public:
AIMomirPlayer(MTGPlayerCards * _deck, char * file, const char * fileSmall, char * avatarFile);
int getEfficiency(AIAction * action);
int momir();
int computeActions();
static MTGAbility * momirAbility;
static MTGAbility * getMomirAbility();
};
#endif
#ifndef _AIMOMIRPLAYER_H_
#define _AIMOMIRPLAYER_H_
#include "AIPlayer.h"
class AIMomirPlayer:public AIPlayerBaka{
public:
AIMomirPlayer(MTGPlayerCards * deck, string file, string fileSmall, string avatarFile);
int getEfficiency(AIAction * action);
int momir();
int computeActions();
static MTGAbility * momirAbility;
static MTGAbility * getMomirAbility();
};
#endif

View File

@@ -61,11 +61,11 @@ class AIPlayer: public Player{
int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0);
AIStats * getStats();
public:
void End(){};
void End(){};
virtual int displayStack(){return 0;};
AIStats * stats;
ManaCost * getPotentialMana();
AIPlayer(MTGPlayerCards * _deck, string deckFile, string deckFileSmall);
AIPlayer(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
virtual ~AIPlayer();
virtual MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0);
virtual int chooseTarget(TargetChooser * tc = NULL);
@@ -86,7 +86,7 @@ class AIPlayerBaka: public AIPlayer{
float timer;
MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type);
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);
void initTimer();
virtual int computeActions();

View File

@@ -25,12 +25,12 @@ class ActionLayer: public GuiLayer, public JGuiListener{
virtual void Update(float dt);
int unstoppableRenderInProgress();
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();
int cancelCurrentAction();
ActionElement * isWaitingForAnswer();
int isReactingToTargetClick(Targetable * card);
int receiveEvent(WEvent * event);
int receiveEventPlus(WEvent * event);
int reactToTargetClick(Targetable * card);
int isReactingToClick(MTGCardInstance * card);
int reactToClick(MTGCardInstance * card);

View File

@@ -45,6 +45,9 @@ class TargetChooser;
class Interruptible: public PlayGuiObject, public Targetable{
public:
//TODO : remove these when they are back in PlayGuiObject
float x, y;
int state, display;
MTGCardInstance * source;
virtual void Entering(){mHasFocus = true;};
@@ -53,8 +56,8 @@ class Interruptible: public PlayGuiObject, public Targetable{
virtual int resolve(){return 0;};
virtual void Render(){};
int typeAsTarget(){return TARGET_STACKACTION;};
Interruptible(int id,bool hasFocus = false):PlayGuiObject(id,40,x,y,hasFocus){state=NOT_RESOLVED;display=0;source=NULL;};
virtual const char *getDisplayName(){return "stack object";};
Interruptible(bool hasFocus = false):PlayGuiObject(40,x,y,hasFocus){state=NOT_RESOLVED;display=0;source=NULL;};
virtual const string getDisplayName(){return "stack object";};
#if defined (WIN32) || defined (LINUX)
virtual void Dump();
#endif
@@ -79,7 +82,7 @@ class Spell: public Interruptible {
~Spell();
int resolve();
void Render();
const char *getDisplayName();
const string getDisplayName();
virtual ostream& toString(ostream& out) const;
MTGCardInstance * getNextCardTarget(MTGCardInstance * previous = 0);
Player * getNextPlayerTarget(Player * previous = 0);
@@ -123,6 +126,7 @@ class DrawAction: public Interruptible {
class ActionStack :public GuiLayer{
protected:
GameObserver* game;
int interruptDecision[2];
float timer;
int currentState;
@@ -165,7 +169,7 @@ class ActionStack :public GuiLayer{
void Update(float dt);
bool CheckUserInput(u32 key);
virtual void Render();
ActionStack(int id, GameObserver* _game);
ActionStack(GameObserver* game);
int resolve();
int CombatDamages();
int CombatDamages(int firststrike);

View File

@@ -12,6 +12,7 @@
#include "Token.h"
#include "Counters.h"
#include "WEvent.h"
#include "GuiStatic.h"
#include <JGui.h>
#include <hge/hgeparticle.h>
@@ -29,8 +30,7 @@ class TrCardAddedToZone:public TriggeredAbility{
public:
TargetChooser * toTc;
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(){
return 0; //This is a trigger, this function should not be called
@@ -63,8 +63,8 @@ class AACounter: public ActivatedAbility{
int nb;
int power;
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){
target=_target;
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;
}
@@ -1962,10 +1962,10 @@ class AAladdinsLamp: public TargetAbility{
int nbcards;
int init;
AAladdinsLamp(int _id, MTGCardInstance * card):TargetAbility(_id,card){
AAladdinsLamp(int id, MTGCardInstance * card) : TargetAbility(id,card) {
cost = NEW ManaCost();
cost->x();
cd = CardDisplay(1,game,SCREEN_WIDTH/2, SCREEN_HEIGHT/2,NULL);
cd = CardDisplay(1, game, SCREEN_WIDTH/2, SCREEN_HEIGHT/2, NULL);
int zones[] = {MTGGameZone::MY_LIBRARY};
tc = NEW TargetZoneChooser(zones,1,source);
nbcards = 0;
@@ -2485,7 +2485,7 @@ class AGlassesOfUrza:public MTGAbility{
CardDisplay * display;
bool isActive;
AGlassesOfUrza(int _id, MTGCardInstance * _source):MTGAbility(_id, _source),isActive(false){
display = NEW CardDisplay(0, game,SCREEN_WIDTH/2, SCREEN_HEIGHT/2,NULL);
display = NEW CardDisplay(0, game, SCREEN_WIDTH/2, SCREEN_HEIGHT/2,NULL);
}
void Update(float dt){
@@ -2979,7 +2979,7 @@ class APestilence: public ActivatedAbility{
for (int i = 0; i < 2 ; i++){
MTGInPlay * inplay = game->players[i]->game->inPlay;
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);
}
@@ -3489,7 +3489,7 @@ class ASoulNet:public ActivatedAbility{
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL){
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 0;
}

View File

@@ -8,12 +8,14 @@ class MTGGameZone;
class MTGCardInstance;
class CardDisplay:public PlayGuiObjectController{
int mId;
GameObserver* game;
public:
int x, y , start_item, nb_displayed_items;
TargetChooser * tc;
JGuiListener * listener;
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 rotateLeft();
void rotateRight();
@@ -27,7 +29,7 @@ class CardDisplay:public PlayGuiObjectController{
class DefaultTargetDisplay:CardDisplay{
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();
};

View File

@@ -4,6 +4,7 @@
#define _CARD_GUI_H_
#include <JGui.h>
#include "Pos.h"
#include "PlayGuiObject.h"
#include "MTGCardInstance.h"
#include <hge/hgeparticle.h>
@@ -11,10 +12,53 @@
class MTGCardInstance;
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{
protected:
hgeParticleSystem * mParticleSys;
int alpha;
float actX, actY;
public:
MTGCardInstance * card;
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 ostream& toString(ostream& out) const;
float Height();
float Width();
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);
~CardGui();
};
*/
#endif

View File

@@ -28,13 +28,13 @@ class Damageable:public Targetable {
class Damage: public Interruptible {
protected:
void init(MTGCardInstance * _source, Damageable * _target, int _damage);
void init(MTGCardInstance * source, Damageable * target, int damage);
public:
Damageable * target;
int damage;
void Render();
Damage(int id, MTGCardInstance* _source, Damageable * _target);
Damage(int id, MTGCardInstance* _source, Damageable * _target, int _damage);
Damage(int id, MTGCardInstance* source, Damageable * target);
Damage(int id, MTGCardInstance* source, Damageable * target, int damage);
int resolve();
virtual ostream& toString(ostream& out) const;
};
@@ -43,7 +43,7 @@ class Damage: public Interruptible {
class DamageStack :public GuiLayer, public Interruptible{
protected:
int currentState;
GameObserver* game;
public:
int resolve();
@@ -51,7 +51,7 @@ class DamageStack :public GuiLayer, public Interruptible{
int CombatDamages();//Deprecated ?
int CombatDamages(int strike);
virtual ostream& toString(ostream& out) const;
DamageStack(int id, GameObserver* _game);
DamageStack(GameObserver* game);
};

View File

@@ -9,8 +9,10 @@ class DamageStack;
class DamageResolverLayer:public PlayGuiObjectController{
protected:
GameObserver* game;
int trampleDamage();
void updateAllCoordinates();
public:
int buttonOk;
int orderingIsNeeded;
@@ -21,7 +23,7 @@ class DamageResolverLayer:public PlayGuiObjectController{
DamageStack * damageStack;
DamagerDamaged * currentSource;
DamageResolverLayer(int id, GameObserver* _game);
DamageResolverLayer(GameObserver* game);
int init();
int initResolve();
Player * whoSelectsDamagesDealtBy(MTGCardInstance * card);

View File

@@ -1,12 +1,12 @@
#ifndef _DAMAGERDAMAGED_H_
#define _DAMAGERDAMAGED_H_
#include "../include/CardGui.h"
#include "../include/MTGCardInstance.h"
class Player;
class DamagerDamaged:public CardGui{
public:
struct DamagerDamaged {
MTGCardInstance* card;
Player * damageSelecter;
int mCount;
Damage * damages[10];
@@ -18,12 +18,9 @@ class DamagerDamaged:public CardGui{
int removeDamagesFrom(DamagerDamaged * source);
int sumDamages();
int hasLethalDamage();
DamagerDamaged(CardGui * cardg, Player * _damageSelecter, bool _hasFocus);
DamagerDamaged(MTGCardInstance* card, Player * _damageSelecter, bool _hasFocus);
~DamagerDamaged();
void Render(Player * currentPlayer);
};

View File

@@ -1,32 +1,51 @@
#ifndef _DUELLAYERS_H_
#define _DUELLAYERS_H_
#include "GuiLayers.h"
#include "CardSelector.h"
class MTGGuiHand;
class MTGGuiPlay;
class ActionLayer;
class ActionStack;
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:
DuelLayers();
~DuelLayers();
public :
ActionLayer * actionLayer();
MTGGuiHand * handLayer();
MTGGuiPlay * playLayer();
ActionStack * stackLayer();
DamageResolverLayer * combatLayer();
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 "GameObserver.h"
#include "MTGGamePhase.h"
#include "MTGGuiHand.h"
#include "MTGGuiPlay.h"
#include "ActionStack.h"
#include "Damage.h"

View File

@@ -94,6 +94,6 @@ class GameApp: public JApp
};
extern JQuad* manaIcons[7];
#endif

View File

@@ -10,6 +10,7 @@
#include "TargetChooser.h"
#include "PhaseRing.h"
#include "ReplacementEffects.h"
#include "GuiStatic.h"
class MTGGamePhase;
class MTGAbility;
@@ -30,10 +31,9 @@ class GameObserver{
int currentRound;
int blockersAssigned;
public:
int blockersSorted;
int forceShuffleLibrary[2];
int turn;
int forceShuffleLibraries();
int targetListIsSet(MTGCardInstance * card);
@@ -78,11 +78,11 @@ class GameObserver{
void untapPhase();
void draw();
int isInPlay(MTGCardInstance * card);
int isACreature(MTGCardInstance * card);
bool isCreature(MTGCardInstance * card);
void Update(float dt);
void Render();
void ButtonPressed(int, PlayGuiObject*);
void ButtonPressed(PlayGuiObject*);
int receiveEvent(WEvent * event);
};

View File

@@ -6,53 +6,47 @@
using std::map;
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"
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 {
public:
int value;
string svalue;
int getIntValue();
GameOption(int _value = 0);
int number;
string str;
GameOption(int value = 0);
GameOption(string value);
};
class GameOptions {
public:
map<string,GameOption> values;
static GameOptions * GetInstance();
static void Destroy();
int save();
int load();
static const char * phaseInterrupts[];
private:
static const char * phaseInterrupts[];
GameOption& operator[](string);
GameOptions();
~GameOptions();
static GameOptions* mInstance;
private:
static map <string,int> optionsTypes;
map<string,GameOption> values;
};
extern GameOptions options;
#endif

View File

@@ -6,8 +6,9 @@
#include <JGE.h>
#include "GameState.h"
#include "SimpleMenu.h"
#include "../include/GameState.h"
#include "../include/SimpleMenu.h"
#include "../include/TexturesCache.h"
#include "../include/CardGui.h"
#include "../include/GameOptions.h"
#include "../include/PriceList.h"
@@ -116,7 +117,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
#if defined (WIN32) || defined (LINUX)
char buf[4096];
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);
#endif
_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(-1, "Cancel");
if (GameApp::HasMusic && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME].getIntValue() > 0){
if (GameApp::HasMusic && options[Options::MUSICVOLUME].number > 0){
if (GameApp::music){
JSoundSystem::GetInstance()->StopMusic(GameApp::music);
SAFE_DELETE(GameApp::music);
@@ -617,7 +618,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
int showName = 1;
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;
}
@@ -638,8 +639,8 @@ class GameStateDeckViewer: public GameState, public JGuiListener
mFont->SetScale(scaleBackup);
}
}else{
CardGui::alternateRender(card, mIcons, x_center, y + 142.5*scale, 0, scale);
quad = card->getThumb();
// CardGui::alternateRender(card, mIcons, x_center, y + 142.5*scale, 0, scale);
quad = cache.getThumb(card);
if (quad){
float _scale = 285 * scale / quad->mHeight;
quad->SetColor(ARGB(40,255,255,255));
@@ -782,7 +783,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
pricelist->setPrice(card->getMTGId(),price*2);
#if defined (WIN32) || defined (LINUX)
char buf[4096];
sprintf(buf, "CARD'S NAME : %s", card->getName());
sprintf(buf, "CARD'S NAME : %s", card->getName().c_str());
OutputDebugString(buf);
#endif
playerdata->collection->remove(card->getMTGId());

View File

@@ -6,7 +6,7 @@
class GuiCardsController : public PlayGuiObjectController{
public:
GuiCardsController(int id, GameObserver* _game):PlayGuiObjectController(id, _game){};
GuiCardsController(){};
};

View File

@@ -1,8 +1,6 @@
#ifndef _GUI_LAYERS_H_
#define _GUI_LAYERS_H_
#define MAX_GUI_LAYERS 7
#define DIR_DOWN 1
#define DIR_UP 2
#define DIR_LEFT 3
@@ -14,16 +12,13 @@
class GameObserver;
class Player;
class GuiLayer{
protected:
GameObserver * game;
int mId;
u32 mActionButton;
public:
int mCount;
int mCurr;
vector<JGuiObject *>mObjects;
vector<JGuiObject *> mObjects;
void Add(JGuiObject * object);
int Remove(JGuiObject * object);
int modal;
@@ -32,7 +27,7 @@ class GuiLayer{
int getMaxId();
void RenderMessageBackground(float x0, float y0, float width, int height);
void RenderMessageBackground(float y0, int height);
GuiLayer(int id, GameObserver* _game);
GuiLayer();
virtual ~GuiLayer();
virtual void Update(float dt);
virtual bool CheckUserInput(u32 key){ return false; };
@@ -45,23 +40,8 @@ class GuiLayer{
return 1;
};
virtual int receiveEvent(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);
virtual int receiveEventPlus(WEvent * e){return 0;};
virtual int receiveEventMinus(WEvent * e){return 0;};
};
#endif

View File

@@ -17,11 +17,11 @@ class GuiPhaseBar : public GuiLayer
float angle;
public:
GuiPhaseBar(GameObserver* game);
GuiPhaseBar();
~GuiPhaseBar();
void Update(float dt);
virtual void Render();
virtual int receiveEvent(WEvent * e);
virtual int receiveEventMinus(WEvent * e);
};
#endif // _GUIPHASEBAR_H_

View File

@@ -10,51 +10,35 @@
#define MTG_MINIIMAGE_WIDTH 45
#define MTG_MINIIMAGE_HEIGHT 64
#define MAX_TYPES_PER_CARD 10
#include "ManaCost.h"
class TexturesCache;
#include <string>
#include <vector>
#include <map>
#include "ManaCost.h"
using namespace std;
class MTGCard {
protected:
int mtgid;
ManaCost manaCost;
char rarity;
char image_name[MTGCARD_NAME_SIZE];
vector<string> ftdText;
int init();
public:
TexturesCache * mCache;
string text;
string name;
int colors[Constants::MTG_NB_COLORS];
map<int,int> basicAbilities;
vector<string> formattedText;
string magicText;
int alias;
string spellTargetType;
int formattedTextInit;
int power;
int toughness;
int setId;
@@ -62,11 +46,8 @@ class MTGCard {
int nb_types;
int types[MAX_TYPES_PER_CARD];
MTGCard();
MTGCard(TexturesCache * cache, int set_id);
MTGCard(int set_id);
MTGCard(MTGCard * source);
JQuad * getQuad(TexturesCache * cache);
JQuad * getQuad(int type=1);
JQuad * getThumb();
void setColor(int _color, int removeAllOthers = 0);
int getColor();
@@ -87,13 +68,13 @@ class MTGCard {
//void setImageName( char * value);
char * getImageName ();
void setText( string value);
void setText(string value);
const char * getText();
void addMagicText(string value);
void setName( string value);
const char * getName();
void setName(string value);
const string getName() const;
void addType(char * type_text);
void addType(int id);
@@ -101,22 +82,24 @@ class MTGCard {
void setSubtype( string value);
int removeType(string value, int removeAll = 0);
int removeType(int value, int removeAll = 0);
int hasSubtype(int _subtype);
int hasSubtype(const char * _subtype);
int hasSubtype(string _subtype);
int hasType(int _type);
int hasType(const char * type);
bool hasSubtype(int _subtype);
bool hasSubtype(const char * _subtype);
bool hasSubtype(string _subtype);
bool hasType(int _type);
bool hasType(const char * type);
void setManaCost(string value);
ManaCost * getManaCost();
int isACreature();
bool isCreature();
bool isLand();
bool isSpell();
void setPower(int _power);
int getPower();
void setToughness(int _toughness);
int getToughness();
const vector<string>& formattedText();
};

View File

@@ -20,6 +20,7 @@ class ManaCost;
class UntapBlockers;
class CardDescriptor;
class Counters;
class Pos;
#include <list>
using namespace std;
@@ -41,6 +42,7 @@ class MTGCardInstance: public MTGCard, public Damageable {
int setDefenser(MTGCardInstance * c);
int setAttacker(int value);
public:
Pos* view;
int regenerateTokens;
bool isToken;
int stillInUse();
@@ -58,7 +60,7 @@ class MTGCardInstance: public MTGCard, public Damageable {
Player * owner;
Counters * counters;
int typeAsTarget(){return TARGET_CARD;}
const char * getDisplayName();
const string getDisplayName();
MTGCardInstance * target;
void addType(int type);
@@ -94,7 +96,6 @@ class MTGCardInstance: public MTGCard, public Damageable {
int regenerate();
int triggerRegenerate();
Player * controller();
JQuad * getIcon();
~MTGCardInstance();
int bury();

View File

@@ -4,12 +4,6 @@
#define MTG_ERROR -1
#include "../include/MTGDefinitions.h"
#include "../include/GameApp.h"
#include "../include/TexturesCache.h"

View File

@@ -16,7 +16,7 @@ class Player;
class MTGGameZone {
protected:
public:
enum{
@@ -65,26 +65,27 @@ class MTGGameZone {
};
Player * owner;
//Both cards and cardsMap contain the cards of a zone. The long term objective is to get rid of the array
vector<MTGCardInstance *> cards; //[MTG_MAX_PLAYER_CARDS];
map<MTGCardInstance *,int> cardsMap;
int nb_cards;
MTGGameZone();
~MTGGameZone();
void shuffle();
virtual MTGCardInstance * draw();
void addCard(MTGCardInstance * card);
void debugPrint();
MTGCardInstance * removeCard(MTGCardInstance * card, int createCopy = 1);
MTGCardInstance * hasCard(MTGCardInstance * card);
void cleanupPhase();
int countByType(const char * value);
int hasType(const char * value);
void setOwner(Player * player);
MTGCardInstance * lastCardDrawn;
static MTGGameZone * stringToZone(string zoneName, MTGCardInstance * source, MTGCardInstance * target);
static int zoneStringToId(string zoneName);
static MTGGameZone *intToZone(int zoneId, MTGCardInstance * source = NULL,MTGCardInstance * target = NULL);
//Both cards and cardsMap contain the cards of a zone. The long term objective is to get rid of the array
vector<MTGCardInstance *> cards; //[MTG_MAX_PLAYER_CARDS];
map<MTGCardInstance *,int> cardsMap;
int nb_cards;
MTGGameZone();
~MTGGameZone();
void shuffle();
virtual MTGCardInstance * draw();
void addCard(MTGCardInstance * card);
void debugPrint();
MTGCardInstance * removeCard(MTGCardInstance * card, int createCopy = 1);
MTGCardInstance * hasCard(MTGCardInstance * card);
void cleanupPhase();
int countByType(const char * value);
int hasType(const char * value);
void setOwner(Player * player);
MTGCardInstance * lastCardDrawn;
static MTGGameZone * stringToZone(string zoneName, MTGCardInstance * source, MTGCardInstance * target);
static int zoneStringToId(string zoneName);
static MTGGameZone *intToZone(int zoneId, MTGCardInstance * source = NULL,MTGCardInstance * target = NULL);
bool needShuffle;
};
class MTGLibrary: public MTGGameZone {

View File

@@ -17,17 +17,18 @@ class GuiCardscontroller;
class MTGGuiHand: public GuiCardsController{
protected:
GameObserver* game;
int currentId[2];
Player * currentPlayer;
int mShowHand;
float mAnimState;
JLBFont * mFont;
public:
MTGGuiHand(int id, GameObserver * _game);
MTGGuiHand(GameObserver*);
void Update(float dt);
bool CheckUserInput(u32 key);
virtual void Render();
void updateCards();
void updateCards();
void showHand (bool show);// WALDORF - added
};

View File

@@ -12,6 +12,7 @@ class CardGui;
class MTGGuiPlay: public PlayGuiObjectController {
protected:
GameObserver* game;
int offset;
Player * currentPlayer;
MTGCardInstance * cardsGrid[SCREEN_WIDTH/5][SCREEN_HEIGHT/5];
@@ -43,14 +44,14 @@ class MTGGuiPlay: public PlayGuiObjectController {
void adjustCardPosition(CardGui * cardg);
public:
CardGui * getByCard(MTGCardInstance * card);
MTGGuiPlay(int id, GameObserver * game);
MTGGuiPlay(GameObserver * game);
~MTGGuiPlay();
void Update(float dt);
bool CheckUserInput(u32 key);
virtual void Render();
void forceUpdateCards();
void updateCards();
int receiveEvent(WEvent * e);
int receiveEventPlus(WEvent * e);
};

View File

@@ -14,7 +14,7 @@ class Phase{
public:
int id;
Player * player;
Phase(int _id, Player * _player):id(_id),player(_player){};
Phase(int id, Player *player):id(id),player(player){};
};
class PhaseRing{

View File

@@ -11,12 +11,11 @@
#define GUI_LIBRARY 4
#include <JGui.h>
#include "Effects.h"
#include "WEvent.h"
#include "Pos.h"
class MTGGameZone;
class Player;
class CardDisplay;
class PlayGuiObject: public JGuiObject, public JGuiListener{
class PlayGuiObject: public JGuiObject, public JGuiListener, public Pos{
protected:
public:
@@ -24,59 +23,17 @@ class PlayGuiObject: public JGuiObject, public JGuiListener{
float mHeight;
float defaultHeight;
bool mHasFocus;
int x;
int y;
int type;
virtual void Entering(){mHasFocus = true;};
virtual bool Leaving(u32 key){mHasFocus = false;return true;};
virtual bool ButtonPressed(){return true;};
virtual void Render(){};
virtual void Render();
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 ~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

View File

@@ -14,7 +14,7 @@ class PlayGuiObjectController : public GuiLayer{
public:
virtual void Update(float dt);
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();};
};

View File

@@ -17,14 +17,14 @@ class Player: public Damageable{
public:
virtual void End();
int typeAsTarget(){return TARGET_PLAYER;}
const char * getDisplayName();
const string getDisplayName();
virtual int displayStack(){return 1;}
JTexture * mAvatarTex;
JQuad * mAvatar;
int canPutLandsIntoPlay;
MTGPlayerCards * game;
int afterDamage();
Player(MTGPlayerCards * _deck, string deckFile, string deckFileSmall);
Player(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
virtual ~Player();
void unTapPhase();
MTGInPlay * inPlay();
@@ -41,7 +41,7 @@ class Player: public Damageable{
class HumanPlayer: public Player{
public:
HumanPlayer(MTGPlayerCards * _deck, char * _deckFile, string _deckFileSmall);
HumanPlayer(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
};

View File

@@ -37,14 +37,14 @@ class TargetChooser: public TargetsList {
TargetChooser(MTGCardInstance * card = NULL, int _maxtargets = -1);
MTGCardInstance * source;
MTGCardInstance * source;
MTGCardInstance * targetter; //Optional, usually equals source, used for protection from...
int maxtargets; //Set to -1 for "unlimited"
virtual int targetsZone(MTGGameZone * z){return 0;};
int ForceTargetListReady();
int targetsReadyCheck();
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 ready(){return cursor;};
virtual ~TargetChooser(){};
@@ -61,7 +61,6 @@ class TargetChooserFactory{
};
class TargetZoneChooser:public TargetChooser{
public:
int zones[10];
@@ -70,16 +69,15 @@ class TargetZoneChooser:public TargetChooser{
int targetsZone(MTGGameZone * z);
TargetZoneChooser(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 {
protected:
MTGCardInstance * validTarget;
public:
CardTargetChooser(MTGCardInstance * _card, MTGCardInstance * source,int * _zones = NULL, int _nbzones = 0);
virtual int canTarget(Targetable * target );
CardTargetChooser(MTGCardInstance * card, MTGCardInstance * source, int * zones = NULL, int nbzones = 0);
virtual bool canTarget(Targetable * target);
};
@@ -89,7 +87,7 @@ class CreatureTargetChooser:public TargetZoneChooser{
int maxtoughness;
CreatureTargetChooser(int * _zones, int _nbzones,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:
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){};
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
public:
PlayerTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1, Player *_p = NULL);
virtual int canTarget(Targetable * target);
virtual bool canTarget(Targetable * target);
};
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);
void addType(int type);
void addType(const char * type);
virtual int canTarget(Targetable * targe);
virtual bool canTarget(Targetable * targe);
};
class DescriptorTargetChooser:public TargetZoneChooser{
@@ -126,7 +124,7 @@ class DescriptorTargetChooser:public TargetZoneChooser{
CardDescriptor * cd;
DescriptorTargetChooser(CardDescriptor * _cd, 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();
};
@@ -135,14 +133,14 @@ class SpellTargetChooser:public TargetChooser{
public:
int color;
SpellTargetChooser( MTGCardInstance * card = NULL,int _color = -1, int _maxtargets = 1 );
virtual int canTarget(Targetable * target);
virtual bool canTarget(Targetable * target);
};
class SpellOrPermanentTargetChooser:public TargetZoneChooser{
public:
int color;
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 state;
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{
public:
int color;
DamageOrPermanentTargetChooser(MTGCardInstance * card = NULL,int _color = -1 , int _maxtargets = 1);
virtual int canTarget(Targetable * target);
virtual bool canTarget(Targetable * target);
};
#endif

View File

@@ -8,7 +8,7 @@
class Targetable{
public:
virtual int typeAsTarget() = 0;
virtual const char * getDisplayName() =0;
virtual const string getDisplayName() = 0;
};
#endif

View File

@@ -43,7 +43,6 @@ class TexturesCache{
int nb_textures;
int delete_previous;
int totalsize;
int maxSize;
CardTexture * cache[MAX_CACHE_OBJECTS];
public:
int isInCache(MTGCard * card, int type=CACHE_CARD);
@@ -55,8 +54,8 @@ class TexturesCache{
int getCacheById(int id, int type=CACHE_CARD);
JQuad * getQuad(MTGCard * card, int type=CACHE_CARD);
JQuad * getThumb(MTGCard * card){return getQuad(card, CACHE_THUMB);};
};
extern TexturesCache cache;
class SampleCached{

View File

@@ -1,96 +1,100 @@
#ifndef _WEVENT_H_
#define _WEVENT_H_
class MTGCardInstance;
class MTGGameZone;
class Damage;
class Phase;
class Targetable;
class WEvent{
public:
enum{
NOT_SPECIFIED = 0,
CHANGE_ZONE = 1,
DAMAGE = 2,
CHANGE_PHASE = 3,
};
int type; //Deprecated, use dynamic casting instead
WEvent(int _type = NOT_SPECIFIED);
virtual ~WEvent() {};
};
class WEventZoneChange: public WEvent{
public:
MTGCardInstance * card;
MTGGameZone * from;
MTGGameZone * to;
WEventZoneChange(MTGCardInstance * _card, MTGGameZone * _from, MTGGameZone *_to);
virtual ~WEventZoneChange() {};
};
class WEventDamage: public WEvent{
public:
Damage * damage;
WEventDamage(Damage * _damage);
};
class WEventPhaseChange: public WEvent{
public:
Phase * from;
Phase * to;
WEventPhaseChange(Phase * _from, Phase * _to);
};
//Abstract class of event when a card's status changes
class WEventCardUpdate: public WEvent{
public:
MTGCardInstance * card;
WEventCardUpdate(MTGCardInstance * card):WEvent(),card(card){};
};
//Event when a card is tapped/untapped
class WEventCardTap: public WEventCardUpdate{
public:
bool before;
bool after;
WEventCardTap(MTGCardInstance * card, bool before, bool after);
};
//Event when a card's "attacker" status changes
//before:Player/Planeswalker that card was attacking previously
//after: Player/Planeswalker that card is attacking now
class WEventCreatureAttacker: public WEventCardUpdate{
public:
Targetable * before;
Targetable * after;
WEventCreatureAttacker(MTGCardInstance * card,Targetable * from, Targetable * to);
};
//Event when a card's "defenser" status changes
//before : attacker that card was blocking previously
//after: attacker that card is blocking now
class WEventCreatureBlocker: public WEventCardUpdate{
public:
MTGCardInstance * before;
MTGCardInstance * after;
WEventCreatureBlocker(MTGCardInstance * card,MTGCardInstance * from,MTGCardInstance * to);
};
//Event when a blocker is reordered
//exchangeWith: exchange card's position with exchangeWith's position
//attacker:both card and exchangeWith *should* be in attacker's "blockers" list.
class WEventCreatureBlockerRank: public WEventCardUpdate{
public:
MTGCardInstance * exchangeWith;
MTGCardInstance * attacker;
WEventCreatureBlockerRank(MTGCardInstance * card,MTGCardInstance * exchangeWith, MTGCardInstance * attacker);
};
#endif
#ifndef _WEVENT_H_
#define _WEVENT_H_
class MTGCardInstance;
class MTGGameZone;
class Damage;
class Phase;
class Targetable;
class WEvent{
public:
enum{
NOT_SPECIFIED = 0,
CHANGE_ZONE = 1,
DAMAGE = 2,
CHANGE_PHASE = 3,
};
int type; //Deprecated, use dynamic casting instead
WEvent(int type = NOT_SPECIFIED);
virtual ~WEvent() {};
};
struct WEventZoneChange: public WEvent{
MTGCardInstance * card;
MTGGameZone * from;
MTGGameZone * to;
WEventZoneChange(MTGCardInstance * card, MTGGameZone * from, MTGGameZone *to);
virtual ~WEventZoneChange() {};
};
struct WEventDamage: public WEvent{
Damage * damage;
WEventDamage(Damage * damage);
};
struct WEventPhaseChange: public WEvent{
Phase * from;
Phase * to;
WEventPhaseChange(Phase * from, Phase * to);
};
//Abstract class of event when a card's status changes
struct WEventCardUpdate: public WEvent{
MTGCardInstance * card;
WEventCardUpdate(MTGCardInstance * card);
};
//Event when a card is tapped/untapped
struct WEventCardTap: public WEventCardUpdate{
bool before;
bool after;
WEventCardTap(MTGCardInstance * card, bool before, bool after);
};
//Event when a card's "attacker" status changes
//before:Player/Planeswalker that card was attacking previously
//after: Player/Planeswalker that card is attacking now
struct WEventCreatureAttacker: public WEventCardUpdate{
Targetable * before;
Targetable * after;
WEventCreatureAttacker(MTGCardInstance * card, Targetable * from, Targetable * to);
};
//Event when a card's "defenser" status changes
//before : attacker that card was blocking previously
//after: attacker that card is blocking now
struct WEventCreatureBlocker: public WEventCardUpdate{
MTGCardInstance * before;
MTGCardInstance * after;
WEventCreatureBlocker(MTGCardInstance * card,MTGCardInstance * from,MTGCardInstance * to);
};
//Event when a blocker is reordered
//exchangeWith: exchange card's position with exchangeWith's position
//attacker:both card and exchangeWith *should* be in attacker's "blockers" list.
struct WEventCreatureBlockerRank: public WEventCardUpdate{
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

View File

@@ -26,4 +26,11 @@
#define RESPATH "Res"
#endif
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#endif

View File

@@ -9,7 +9,7 @@
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;
agressivity = 100;
}

File diff suppressed because it is too large Load Diff

View File

@@ -67,16 +67,15 @@ void ActionLayer::Update(float dt){
return;
}
modal = 0;
GameObserver * g = GameObserver::GetInstance();
GameObserver* game = GameObserver::GetInstance();
for (int i=mCount -1 ;i>=0;i--){
if (mObjects[i]!= NULL){
ActionElement * currentAction = (ActionElement *)mObjects[i];
if (currentAction->testDestroy()){
g->removeObserver(currentAction);
}
if (currentAction->testDestroy())
game->removeObserver(currentAction);
}
}
int newPhase = g->getCurrentGamePhase();
int newPhase = game->getCurrentGamePhase();
for (int i=0;i<mCount;i++){
if (mObjects[i]!=NULL){
ActionElement * currentAction = (ActionElement *)mObjects[i];
@@ -138,7 +137,7 @@ int ActionLayer::stillInUse(MTGCardInstance * card){
return 0;
}
int ActionLayer::receiveEvent(WEvent * event){
int ActionLayer::receiveEventPlus(WEvent * event){
int result = 0;
for (int i=0;i<mCount;i++){
ActionElement * currentAction = (ActionElement *)mObjects[i];
@@ -180,7 +179,7 @@ int ActionLayer::reactToTargetClick(Targetable * card){
int ActionLayer::isReactingToClick(MTGCardInstance * card){
int result = 0;
if (isWaitingForAnswer()) return -1;
if (isWaitingForAnswer()) return -1;
for (int i=0;i<mCount;i++){
@@ -244,7 +243,6 @@ void ActionLayer::doReactTo(int menuIndex){
void ActionLayer::ButtonPressed(int controllerid, int controlid){
if (controlid == -1){
}else{
ActionElement * currentAction = (ActionElement *)mObjects[controlid];
currentAction->reactToTargetClick(menuObject);

View File

@@ -8,8 +8,8 @@
#include "../include/Damage.h"
#include "../include/ManaCost.h"
#include "../include/GameOptions.h"
#include "../include/TexturesCache.h"
#include "../include/TargetChooser.h"
// WALDORF - added to support drawing big cards during interrupts
#include "../include/CardGui.h"
#include "../include/Translate.h"
@@ -57,7 +57,7 @@ void StackAbility::Render(){
sprintf(buffer, "%s", _(ability->getMenuText()).c_str());
mFont->DrawString(buffer, x + 30 , y, JGETEXT_LEFT);
JRenderer * renderer = JRenderer::GetInstance();
JQuad * quad = ability->source->getThumb();
JQuad * quad = cache.getThumb(ability->source);
if (quad){
quad->SetColor(ARGB(255,255,255,255));
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();
}
@@ -133,10 +133,10 @@ int Spell::resolve(){
if (!source->hasType("instant") && !source->hasType("sorcery")){
source = source->controller()->game->putInPlay(source);
}
//Play SFX
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME].getIntValue() > 0){
if (options[Options::SFXVOLUME].number > 0){
JSample * sample = source->getSample();
if (sample){
JSoundSystem::GetInstance()->PlaySample(sample);
@@ -188,7 +188,7 @@ void Spell::Render(){
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->DrawString(_(source->name).c_str(), x + 30 , y, JGETEXT_LEFT);
JRenderer * renderer = JRenderer::GetInstance();
JQuad * quad = source->getThumb();
JQuad * quad = cache.getThumb(source);
if (quad){
quad->SetColor(ARGB(255,255,255,255));
float scale = mHeight / quad->mHeight;
@@ -205,7 +205,7 @@ void Spell::Render(){
// just overwrites it.
// I stole the render code from RenderBig() in CardGUI.cpp
quad = source->getQuad();
quad = cache.getQuad(source);
if (quad){
quad->SetColor(ARGB(220,255,255,255));
float scale = 257.f / quad->mHeight;
@@ -214,9 +214,9 @@ void Spell::Render(){
else
{
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){
float scale = 250 / quad->mHeight;
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);
}
JRenderer * renderer = JRenderer::GetInstance();
JQuad * quad = card->getThumb();
JQuad * quad = cache.getThumb(card);
if (quad){
quad->SetColor(ARGB(255,255,255,255));
float scale = 30 / quad->mHeight;
@@ -330,11 +330,10 @@ int ActionStack::addPutInGraveyard(MTGCardInstance * card){
int ActionStack::addAbility(MTGAbility * ability){
StackAbility * stackAbility = NEW StackAbility(mCount,ability);
int result = addAction(stackAbility);
if (!game->players[0]->isAI() &&
ability->source->controller()==game->players[0] &&
GameOptions::GetInstance()->values[OPTIONS_INTERRUPTMYABILITIES].getIntValue() == 0){
interruptDecision[0] = DONT_INTERRUPT;
}
if (!game->players[0]->isAI() &&
ability->source->controller()==game->players[0] &&
0 == options[Options::INTERRUPTMYABILITIES].number)
interruptDecision[0] = DONT_INTERRUPT;
return result;
}
@@ -388,11 +387,10 @@ Spell * ActionStack::addSpell(MTGCardInstance * _source, TargetChooser * tc, Man
#endif
Spell * spell = NEW Spell(mCount,_source,tc, mana);
addAction(spell);
if (!game->players[0]->isAI() &&
_source->controller()==game->players[0] &&
GameOptions::GetInstance()->values[OPTIONS_INTERRUPTMYSPELLS].getIntValue() == 0){
interruptDecision[0] = DONT_INTERRUPT;
}
if (!game->players[0]->isAI() &&
_source->controller()==game->players[0] &&
0 == options[Options::INTERRUPTMYSPELLS].number)
interruptDecision[0] = DONT_INTERRUPT;
return spell;
}
@@ -403,10 +401,9 @@ Interruptible * ActionStack::getAt(int id){
return (Interruptible *)mObjects[id];
}
ActionStack::ActionStack(int id, GameObserver* _game):GuiLayer(id, _game){
for (int i=0; i<2; i++){
ActionStack::ActionStack(GameObserver* game) : game(game){
for (int i=0; i<2; i++)
interruptDecision[i] = 0;
}
askIfWishesToInterrupt = NULL;
timer = -1;
currentState = -1;
@@ -644,9 +641,9 @@ void ActionStack::Update(float dt){
// 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
// 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;
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
}
if (PSP_CTRL_TRIANGLE == key){
if (modal) {modal = 0;} else {modal = 1;}
if (modal) modal = 0; else modal = 1;
return true;
}
}
@@ -753,13 +750,12 @@ int ActionStack::CombatDamages(){
}
int ActionStack::CombatDamages(int strike){
DamageStack * damages = NEW DamageStack(mCount,game);
DamageStack * damages = NEW DamageStack(game);
int damageitems = damages->CombatDamages(strike);
if (damageitems){
if (damageitems)
addAction(damages);
}else{
else
SAFE_DELETE(damages);
}
return damageitems;
}
@@ -773,9 +769,8 @@ while( iter != mObjects.end() ){
iter = mObjects.erase( iter ) ;
mCount--;
SAFE_DELETE(current);
}else {
++iter ;
}
} else
++iter;
}
return 1;
}
@@ -842,7 +837,7 @@ void ActionStack::Render(){
// WALDORF - changed "interrupt ?" to "Interrupt?". Don't display count down
// seconds if the user disables auto progressing interrupts by setting the seconds
// 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());
else
sprintf(buffer, "%s %i", _("Interrupt?").c_str(),static_cast<int>(timer));
@@ -935,7 +930,7 @@ void Interruptible::Dump(){
sstate = "unknown";
break;
}
char buf[4096];
sprintf(buf, " type %s(%i) - state %s(%i) - display %i\n", stype.c_str(), type, sstate.c_str(),state, display);
OutputDebugString(buf);

View File

@@ -24,11 +24,11 @@ void UntapBlocker::init(ManaCost * _cost){
manaCost = _cost;
}
UntapBlocker * UntapBlocker::clone() const{
UntapBlocker * a = NEW UntapBlocker(*this);
a->isClone = 1;
return a;
}
UntapBlocker * UntapBlocker::clone() const{
UntapBlocker * a = NEW UntapBlocker(*this);
a->isClone = 1;
return a;
}
//Default behaviour for blockers : they block the card they're attached to
@@ -45,7 +45,7 @@ void UntapBlocker::Update(float dt){
_target->getUntapBlockers()->Add(this);
#if defined (WIN32) || defined (LINUX)
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);
#endif
}

View File

@@ -4,8 +4,8 @@
#include "../include/TargetChooser.h"
#include "../include/MTGGameZones.h"
CardDisplay::CardDisplay():PlayGuiObjectController(0, GameObserver::GetInstance()){
tc= NULL;
CardDisplay::CardDisplay() : mId(0), game(GameObserver::GetInstance()) {
tc = NULL;
listener = NULL;
nb_displayed_items = 7;
start_item = 0;
@@ -13,8 +13,8 @@ CardDisplay::CardDisplay():PlayGuiObjectController(0, GameObserver::GetInstance(
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){
tc= _tc;
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;
listener = _listener;
nb_displayed_items = _nb_displayed_items;
start_item = 0;
@@ -22,7 +22,7 @@ CardDisplay::CardDisplay(int id, GameObserver* _game, int _x, int _y, JGuiListen
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);
}
@@ -60,7 +60,7 @@ bool CardDisplay::CheckUserInput(u32 key){
if (listener){
listener->ButtonPressed(mId, 0);
return true;
}
}
}
if (!mCount)
@@ -75,7 +75,7 @@ bool CardDisplay::CheckUserInput(u32 key){
tc->toggleTarget(cardg->card);
return true;
}else{
if (game) game->ButtonPressed(mId, cardg);
if (game) game->ButtonPressed(cardg);
return true;
}
}
@@ -140,7 +140,7 @@ void CardDisplay::Render(){
if (mCount && mObjects[mCurr] != NULL){
mObjects[mCurr]->Render();
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);
}
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();
}

View File

@@ -1,3 +1,4 @@
#include "JGE.h"
#include "../include/config.h"
#include "../include/CardGui.h"
#include "../include/ManaCostHybrid.h"
@@ -6,6 +7,231 @@
#include "../include/MTGDefinitions.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){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAGIC_FONT);
float backup = mFont->GetScale();
@@ -36,31 +262,6 @@ void CardGui::alternateRender(MTGCard * card, JQuad ** manaIcons, float x, float
mFont->SetScale(scale);
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();
int nbicons = 0;
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);
}
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--){
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(_card->getName());
actX = x;
actY = y;
card = _card;
type = GUI_CARD;
@@ -227,12 +360,12 @@ void CardGui::Update(float dt){
if (card->changedZoneRecently > 0) alpha = 255.f - 255.f * card->changedZoneRecently;
if (mParticleSys && card->changedZoneRecently == 1.f){
mParticleSys->MoveTo(x+15, y+2*mHeight/3);
mParticleSys->MoveTo(actX + 15, actY + 2 * mHeight / 3);
mParticleSys->Fire();
}
if (card->changedZoneRecently){
if (mParticleSys) mParticleSys->Update(dt);
card->changedZoneRecently-= (5 *dt);
card->changedZoneRecently-= (5 *dt);
if (card->changedZoneRecently == 0) card->changedZoneRecently-= dt;//must not become zero atm
if (card->changedZoneRecently < 0){
if (mParticleSys) mParticleSys->Stop();
@@ -242,31 +375,13 @@ void CardGui::Update(float dt){
mParticleSys = NULL;
}
}
actX += 10 * dt * (x - actX);
actY += 10 * dt * (y - actY);
PlayGuiObject::Update(dt);
}
void CardGui::RenderBig(float xpos, float ypos, int alternate){
JQuad * quad = NULL;
JRenderer * renderer = JRenderer::GetInstance();
if (xpos == -1){
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;
}
}
if (alternate){
MTGCard * mtgcard = card->model;
@@ -299,44 +414,36 @@ void CardGui::Render(){
float rotation = M_PI_2 * tap;
float mScale = mHeight / 64;
float myW = 45 * mScale;
float myH = 60*mScale;
float myH = 60 * mScale;
GameObserver * game = GameObserver::GetInstance();
TargetChooser * tc = NULL;
if (game) tc = game->getCurrentTargetChooser();
float myX = x + (32 * tap * mScale);
float myY = y+(20 * tap * mScale);
float myX = actX + (32 * tap * mScale);
float myY = actY + (20 * tap * mScale);
if (quad){
mScale = mHeight / quad->mHeight;
myH = mHeight;
myW = quad->mWidth * mScale;
myX = x + (quad->mHeight/2 * tap * mScale);
myY = y+(quad->mWidth/2 * tap * mScale);
myX = actX + (quad->mHeight/2 * tap * mScale);
myY = actY + (quad->mWidth/2 * tap * mScale);
}
if (mHeight-defaultHeight){
if (card->isTapped()){
renderer->FillRect(myX + 1*(mHeight-defaultHeight) - myH , myY + 1*(mHeight-defaultHeight) , myH, myW, ARGB(128,0,0,0));
}else{
renderer->FillRect(myX + 1*(mHeight-defaultHeight) , myY + 1*(mHeight-defaultHeight) , myW, myH, ARGB(128,0,0,0));
}
if (card->isTapped())
renderer->FillRect(myX + 1 * (mHeight - defaultHeight) - myH, myY + 1 * (mHeight - defaultHeight), myH, myW, ARGB(128,0,0,0));
else
renderer->FillRect(myX + 1 * (mHeight - defaultHeight), myY + 1 * (mHeight-defaultHeight), myW, myH, ARGB(128,0,0,0));
}
if(quad){
quad->SetColor(ARGB( alpha,255,255,255));
quad->SetColor(ARGB(alpha, 255, 255, 255));
if (tc){
if (!tc->canTarget(card)){
quad->SetColor(ARGB( alpha,50,50,50));
}
}
renderer->RenderQuad(quad, myX , myY , rotation,mScale,mScale);
quad->SetColor(ARGB( alpha,255,255,255));
if (tc && !tc->canTarget(card)) quad->SetColor(ARGB(alpha, 50, 50, 50));
renderer->RenderQuad(quad, myX, myY ,rotation, mScale, mScale);
quad->SetColor(ARGB(alpha, 255, 255, 255));
}else{
int color = card->getColor();
char buffer[200];
sprintf(buffer, "%s",card->getName());
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 (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->DrawRect(myX - myH , myY , myH, myW, ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color]));
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]));
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE * 0.8 * mScale);
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 (tc){
if (!tc->canTarget(card)){
renderer->FillRect(myX - myH , myY , myH, myW, ARGB(200,0,0,0));
}
}
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 (tc && !tc->canTarget(card))
renderer->FillRect(myX - myH, myY, myH, myW, ARGB(200,0,0,0));
}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->DrawRect(myX , myY , myW, myH, ARGB(255,Constants::_r[color],Constants::_g[color],Constants::_b[color]));
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]));
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE * 0.5 * mScale);
mFont->DrawString(buffer,myX+4,myY + 1);
if (mIcon) renderer->RenderQuad(mIcon,myX + myW/2, myY + myH/2,0,mScale, mScale);
if (tc){
if (!tc->canTarget(card)){
renderer->FillRect(myX , myY , myW, myH, ARGB(200,0,0,0));
}
}
mFont->DrawString(buffer, myX + 4, myY + 1);
if (mIcon) renderer->RenderQuad(mIcon,myX + myW/2, myY + myH / 2, 0, mScale, mScale);
if (tc && !tc->canTarget(card))
renderer->FillRect(myX, myY, myW, myH, ARGB(200,0,0,0));
}
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
}
}
if (tc && tc->alreadyHasTarget(card)){
if (card->isTapped()){
renderer->FillRect(myX- myH , myY , myH, myW, ARGB(128,255,0,0));
}else{
renderer->FillRect(myX , myY , myW, myH, ARGB(128,255,0,0));
}
if (card->isTapped())
renderer->FillRect(myX - myH, myY, myH, myW, ARGB(128,255,0,0));
else
renderer->FillRect(myX, myY, myW, myH, ARGB(128,255,0,0));
}
if (card->isACreature()){
if (card->isCreature()){
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
char buffer[200];
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->DrawString(buffer,x+4,y + mHeight - 10);
mFont->DrawString(buffer, actX + 4, actY + mHeight - 10);
}
if (mParticleSys && card->changedZoneRecently > 0){
@@ -403,17 +503,33 @@ void CardGui::Render(){
// set normal blending
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(){
LOG("==Destroying CardGui object");
LOG(this->card->getName());
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
{
return (out << "CardGui ::: mParticleSys : " << mParticleSys << " ; alpha : " << alpha << " ; card : " << card);
return (out << "CardGui ::: x,y " << x << "," << y);
}

View File

@@ -41,12 +41,11 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
app = _app;
showMsg = (rand() % 5);
GameObserver * g = GameObserver::GetInstance();
if (!p1->isAI() && p2->isAI() && p1!= g->gameOver){
GameOptions * go = GameOptions::GetInstance();
if (!p1->isAI() && p2->isAI() && p1!= g->gameOver){
value = 400;
if (app->gameType != GAME_TYPE_CLASSIC) value = 200;
int difficulty = go->values[OPTIONS_DIFFICULTY].getIntValue();
if (go->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue() && difficulty) {
int difficulty = options[Options::DIFFICULTY].number;
if (options[Options::DIFFICULTY_MODE_UNLOCKED].number && difficulty) {
CreditBonus * b = NEW CreditBonus(100*difficulty, _("Difficulty Bonus"));
bonus.push_back(b);
}
@@ -77,31 +76,31 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
if (unlocked){
unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/unlocked.png", TEX_TYPE_USE_VRAM);
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED] = GameOption(1);
GameOptions::GetInstance()->save();
}else if((unlocked = isMomirUnlocked())) {
options[Options::DIFFICULTY_MODE_UNLOCKED] = GameOption(1);
options.save();
} else if ((unlocked = isMomirUnlocked())) {
unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/momir_unlocked.png", TEX_TYPE_USE_VRAM);
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
GameOptions::GetInstance()->values[OPTIONS_MOMIR_MODE_UNLOCKED] = GameOption(1);
GameOptions::GetInstance()->save();
}else if((unlocked = isEvilTwinUnlocked())) {
options[Options::MOMIR_MODE_UNLOCKED] = GameOption(1);
options.save();
} else if ((unlocked = isEvilTwinUnlocked())) {
unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/eviltwin_unlocked.png", TEX_TYPE_USE_VRAM);
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
GameOptions::GetInstance()->values[OPTIONS_EVILTWIN_MODE_UNLOCKED] = GameOption(1);
GameOptions::GetInstance()->save();
options[Options::EVILTWIN_MODE_UNLOCKED] = GameOption(1);
options.save();
}else if((unlocked = isRandomDeckUnlocked())) {
unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/randomdeck_unlocked.png", TEX_TYPE_USE_VRAM);
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
GameOptions::GetInstance()->values[OPTIONS_RANDOMDECK_MODE_UNLOCKED] = GameOption(1);
GameOptions::GetInstance()->save();
options[Options::RANDOMDECK_MODE_UNLOCKED] = GameOption(1);
options.save();
}else if((unlocked = unlockRandomSet())) {
unlockedTex = JRenderer::GetInstance()->LoadTexture("graphics/set_unlocked.png", TEX_TYPE_USE_VRAM);
unlockedQuad = NEW JQuad(unlockedTex, 2, 2, 396, 96);
char buffer[4096];
unlockedString = MtgSets::SetsList->values[unlocked -1];
sprintf(buffer,"unlocked_%s", unlockedString.c_str());
GameOptions::GetInstance()->values[buffer] = GameOption(1);
GameOptions::GetInstance()->save();
options[buffer] = GameOption(1);
options.save();
}
if (unlocked){
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/bonus.wav");
@@ -113,9 +112,8 @@ void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
if (bonus.size()){
CreditBonus * b = NEW CreditBonus(value, _("Victory"));
bonus.insert(bonus.begin(),b);
for ( it=bonus.begin()+1 ; it < bonus.end(); ++it){
value+= (*it)->value;
}
for (it = bonus.begin() + 1; it < bonus.end(); ++it)
value += (*it)->value;
}
@@ -186,7 +184,7 @@ void Credits::Render(){
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 found = 1;
int wins = 0;
@@ -210,20 +208,20 @@ int Credits::isDifficultyUnlocked(){
}
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;
return 0;
}
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;
return 0;
}
int Credits::isRandomDeckUnlocked(){
if (GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY].getIntValue() == 0 ) return 0;
if (GameOptions::GetInstance()->values[OPTIONS_RANDOMDECK_MODE_UNLOCKED].getIntValue()) return 0;
if (0 == options[Options::DIFFICULTY].number) return 0;
if (options[Options::RANDOMDECK_MODE_UNLOCKED].number) return 0;
if (p1->life >= 20 ) return 1;
return 0;
}
@@ -234,6 +232,6 @@ int Credits::unlockRandomSet(){
char buffer[4096];
string s = MtgSets::SetsList->values[setId];
sprintf(buffer,"unlocked_%s", s.c_str());
if (GameOptions::GetInstance()->values[buffer].getIntValue() == 1 ) return 0;
return setId+1;
if (1 == options[buffer].number) return 0;
return setId + 1;
}

View File

@@ -4,13 +4,14 @@
#include "../include/Counters.h"
#include "../include/WEvent.h"
#include "../include/Translate.h"
#include "../include/TexturesCache.h"
Damage::Damage(int id, MTGCardInstance * _source, Damageable * _target): Interruptible(id){
init(_source, _target, _source->getPower());
Damage::Damage(int id, MTGCardInstance * source, Damageable * target) {
init(source, target, source->getPower());
}
Damage::Damage(int id, MTGCardInstance * _source, Damageable * _target, int _damage): Interruptible(id){
init(_source, _target, _damage);
Damage::Damage(int id, MTGCardInstance * source, Damageable * target, int damage) {
init(source, target, 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);
mFont->DrawString(buffer, x + 20 , y, JGETEXT_LEFT);
JRenderer * renderer = JRenderer::GetInstance();
JQuad * quad = source->getThumb();
JQuad * quad = cache.getThumb(source);
if (quad){
float scale = 30 / quad->mHeight;
renderer->RenderQuad(quad, x , y , 0,scale,scale);
@@ -92,7 +93,7 @@ ostream& Damage::toString(ostream& out) const
return out;
}
DamageStack::DamageStack(int id, GameObserver * _game):GuiLayer(id, _game), Interruptible(id){
DamageStack::DamageStack(GameObserver* game) : game(game){
currentState = -1;
type = ACTION_DAMAGES;
}

View File

@@ -6,7 +6,7 @@
#include "../include/Damage.h"
#include "../include/Translate.h"
DamageResolverLayer::DamageResolverLayer(int id, GameObserver * _game):PlayGuiObjectController(id, _game){
DamageResolverLayer::DamageResolverLayer(GameObserver * game) : game(game){
currentPhase = -1;
remainingDamageSteps = 0;
damageStack = NULL;
@@ -106,9 +106,9 @@ DamagerDamaged * DamageResolverLayer::addIfNotExists(MTGCardInstance * card, Pla
DamagerDamaged * item = (DamagerDamaged *)mObjects[i];
if (item->card == card) return item;
}
CardGui * cardg = game->mLayers->playLayer()->getByCard(card);
DamagerDamaged * item = NEW DamagerDamaged(cardg, selecter, mCount == 0);
Add(item);
// CardGui * cardg = game->mLayers->playLayer()->getByCard(card);
DamagerDamaged * item = NEW DamagerDamaged(card, selecter, mCount == 0);
// Add(NEW TransientCardView(card->gui));
mCurr = 0;
return item;
}
@@ -116,9 +116,11 @@ DamagerDamaged * DamageResolverLayer::addIfNotExists(MTGCardInstance * card, Pla
void DamageResolverLayer::updateAllCoordinates(){
for (int i = 0; i < mCount; i++){
DamagerDamaged * item = (DamagerDamaged *)mObjects[i];
/*
CardGui * cardg = game->mLayers->playLayer()->getByCard(item->card);
item->x = cardg->x;
item->y = cardg->y;
*/
}
}
@@ -129,9 +131,11 @@ int DamageResolverLayer::updateCoordinates(MTGCardInstance * card){
if (item->card != card) item = NULL ;
}
if (!item) return 0;
/*
CardGui * cardg = game->mLayers->playLayer()->getByCard(card);
item->x = cardg->x;
item->y = cardg->y;
*/
return 1;
}
@@ -181,7 +185,7 @@ int DamageResolverLayer::initResolve(){
#endif
currentSource = NULL;
currentChoosingPlayer = game->currentPlayer;
damageStack = NEW DamageStack(mCount,game);
damageStack = NEW DamageStack(game);
int strike = 0;
if (remainingDamageSteps == 2) strike = 1;
@@ -436,7 +440,69 @@ bool DamageResolverLayer::CheckUserInput(u32 key){
}else if (PSP_CTRL_SQUARE == key){
return nextPlayer();
}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;
}
@@ -455,7 +521,7 @@ void DamageResolverLayer::Render(){
mFont->DrawString(_("Blocking Player").c_str(), 0,0);
}
if (currentSource){
currentSource->RenderBig(10, 20);
// currentSource->RenderBig(10, 20);
mFont->DrawString(_("Current Damager:").c_str(), 10, 5);
}
for (int i = 0; i < mCount; i++){

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;
damageSelecter = _damageSelecter;
damageToDeal = card->power;
@@ -37,7 +37,7 @@ int DamagerDamaged::dealOneDamage(DamagerDamaged * target){
damageToDeal--;
#if defined (WIN32) || defined (LINUX)
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);
#endif
return target->addDamage(1, this);
@@ -76,9 +76,10 @@ int DamagerDamaged::removeDamagesFrom(DamagerDamaged * source){
void DamagerDamaged::Render(Player * currentPlayer){
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
mFont->SetBase(0);
CardGui::Render();
// CardGui::Render();
char buf[4096];
/*
if (currentPlayer != damageSelecter){
if (hasLethalDamage()){
mFont->DrawString("X",x,y);
@@ -92,4 +93,5 @@ void DamagerDamaged::Render(Player * currentPlayer){
mFont->DrawString(buf,x+5, y+5);
}
mFont->SetColor(ARGB(255,255,255,255));
*/
}

View File

@@ -1,65 +1,146 @@
#include "../include/config.h"
#include "../include/DuelLayers.h"
#include "../include/MTGRules.h"
#include "../include/DamageResolverLayer.h"
#include "../include/GuiCombat.h"
#include "../include/GuiBackground.h"
#include "../include/GuiFrame.h"
#include "../include/GuiPhaseBar.h"
#include "../include/GuiAvatars.h"
#include "../include/GuiHand.h"
#include "../include/GuiPlay.h"
#include "../include/GuiMana.h"
void DuelLayers::init(){
GameObserver* go = GameObserver::GetInstance();
//0 Stack Layer
ActionStack * mActionStack = NEW ActionStack(0, GameObserver::GetInstance());
//Damage Resolver
DamageResolverLayer * mDamageResolver = NEW DamageResolverLayer(1, GameObserver::GetInstance());
cs = NEW CardSelector(this);
//1 Action Layer
GuiLayer * actionLayer = NEW ActionLayer(2, GameObserver::GetInstance());
MTGGamePhase * phaseManager = NEW MTGGamePhase(actionLayer->getMaxId());
actionLayer->Add(phaseManager);
action = NEW ActionLayer();
action->Add(NEW MTGGamePhase(action->getMaxId()));
//Add Magic Specific Rules
actionLayer->Add(NEW MTGPutInPlayRule(-1));
actionLayer->Add(NEW MTGAttackRule(-1));
actionLayer->Add(NEW MTGBlockRule(-1));
actionLayer->Add(NEW MTGLegendRule(-1));
actionLayer->Add(NEW MTGPersistRule(-1));
actionLayer->Add(NEW MTGLifelinkRule(-1));
action->Add(NEW MTGPutInPlayRule(-1));
action->Add(NEW MTGAttackRule(-1));
action->Add(NEW MTGBlockRule(-1));
action->Add(NEW MTGLegendRule(-1));
action->Add(NEW MTGPersistRule(-1));
action->Add(NEW MTGLifelinkRule(-1));
//Other display elements
actionLayer->Add(NEW HUDDisplay(-1));
action->Add(NEW HUDDisplay(-1));
//2 Hand Layer
MTGGuiHand * mGuiHand = NEW MTGGuiHand(3, GameObserver::GetInstance());
Add(NEW GuiMana());
Add(stack = NEW ActionStack(go));
Add(combat = NEW GuiCombat(cs));
Add(action);
Add(cs);
Add(hand = NEW GuiHandSelf(cs, go->players[0]->game->hand));
Add(NEW GuiHandOpponent(cs, go->players[1]->game->hand));
Add(NEW GuiPlay(go, cs));
//3 Game
MTGGuiPlay * play = NEW MTGGuiPlay(4, GameObserver::GetInstance());
//Add(NEW GuiPhaseBar(GameObserver::GetInstance()));
Add(mActionStack);
Add(mDamageResolver);
Add(actionLayer);
Add(mGuiHand);
Add(play);
Add(NEW GuiAvatars(cs));
Add(NEW GuiPhaseBar());
Add(NEW GuiFrame());
Add(NEW GuiBackground());
}
void DuelLayers::Update(float dt, Player * currentPlayer)
{
for (int i = 0; i < nbitems; ++i) objects[i]->Update(dt);
int isAI = currentPlayer->isAI();
u32 key;
GameObserver * game = GameObserver::GetInstance();
while ((key = JGE::GetInstance()->ReadButton())){
if ((!isAI) && (0 != key))
{
if (stack->CheckUserInput(key)) break;
// if (combat->CheckUserInput(key)) break;
if (action->CheckUserInput(key)) break;
if (hand->CheckUserInput(key)) break;
if (cs->CheckUserInput(key)) break;
}
}
if (isAI) currentPlayer->Act(dt);
}
ActionStack * DuelLayers::stackLayer(){
return ((ActionStack *) (objects[0]));
}
DamageResolverLayer * DuelLayers::combatLayer(){
return ((DamageResolverLayer *) (objects[1]));
return stack;
}
ActionLayer * DuelLayers::actionLayer(){
return ((ActionLayer *) (objects[2]));
return action;
}
MTGGuiHand * DuelLayers::handLayer(){
return ((MTGGuiHand *) (objects[3]));
}
MTGGuiPlay * DuelLayers::playLayer(){
return ((MTGGuiPlay *) (objects[4]));
DuelLayers::DuelLayers() : nbitems(0) {}
DuelLayers::~DuelLayers(){
for (int i = 0; i < nbitems; ++i) delete objects[i];
}
int DuelLayers::unstoppableRenderInProgress(){
for (int i = 0; i < nbitems; ++i)
if (objects[i]->unstoppableRenderInProgress())
return 1;
return 0;
}
void DuelLayers::Add(GuiLayer * layer){
objects.push_back(layer);
nbitems++;
}
void DuelLayers::Remove(){
--nbitems;
}
void DuelLayers::Render(){
bool focusMakesItThrough = true;
for (int i = 0; i < nbitems; ++i)
{
objects[i]->hasFocus = focusMakesItThrough;
if (objects[i]->modal) focusMakesItThrough = false;
}
for (int i = nbitems - 1; i >= 0; --i)
objects[i]->Render();
}
int DuelLayers::receiveEvent(WEvent * e){
#if 0
#define PRINT_IF(type) { type *foo = dynamic_cast<type*>(e); if (foo) cout << "Is a " << #type << endl; }
cout << "Received event " << e << endl;
PRINT_IF(WEventZoneChange);
PRINT_IF(WEventDamage);
PRINT_IF(WEventPhaseChange);
PRINT_IF(WEventCardUpdate);
PRINT_IF(WEventCardTap);
PRINT_IF(WEventCreatureAttacker);
PRINT_IF(WEventCreatureBlocker);
PRINT_IF(WEventCreatureBlockerRank);
PRINT_IF(WEventEngageMana);
PRINT_IF(WEventConsumeMana);
#endif
int used = 0;
for (int i = 0; i < nbitems; ++i)
used |= objects[i]->receiveEventPlus(e);
if (!used)
{
Pos* p;
if (WEventZoneChange *event = dynamic_cast<WEventZoneChange*>(e))
{
if (event->card->view)
waiters.push_back(p = new Pos(*(event->card->view)));
else
waiters.push_back(p = new Pos(0, 0, 0, 0, 255));
event->card->view = p;
}
}
for (int i = 0; i < nbitems; ++i)
objects[i]->receiveEventMinus(e);
return 1;
}
float DuelLayers::RightBoundary()
{
return hand->LeftBoundary();
}

View File

@@ -24,6 +24,8 @@ int GameApp::HasMusic = 1;
JMusic * GameApp::music = NULL;
string GameApp::systemError = "";
JQuad* manaIcons[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
GameState::GameState(GameApp* parent): mParent(parent)
{
mEngine = JGE::GetInstance();
@@ -64,19 +66,15 @@ void GameApp::Create()
//Test for Music files presence
std::ifstream file(RESPATH"/sound/Track0.mp3");
if(file){
if (file)
file.close();
}else{
else
HasMusic = 0;
}
std::ifstream file2(RESPATH"/sound/Track1.mp3");
if(file2){
if (file2)
file2.close();
}else{
else
HasMusic = 0;
}
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
@@ -87,6 +85,14 @@ void GameApp::Create()
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_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");
@@ -108,9 +114,54 @@ void GameApp::Create()
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/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->CreateQuad("interrupt", "graphics/interrupt.png", 0, 0, 256, 128);
@@ -188,8 +239,6 @@ void GameApp::Destroy()
SAFE_DELETE(CommonRes);
GameOptions::Destroy(); //No delete ???
SAFE_DELETE(Subtypes::subtypesList);
SAFE_DELETE(MtgSets::SetsList);

View File

@@ -88,10 +88,12 @@ void GameObserver::nextGamePhase(){
Phase * cPhaseOld = phaseRing->getCurrentPhase();
if (!blockersSorted && cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS){
blockersAssigned = 1;
/*
if (!mLayers->combatLayer()->autoOrderBlockers()){
OutputDebugString("Player has To choose ordering!");
return;
}
*/
}
phaseRing->forward();
@@ -149,18 +151,20 @@ int GameObserver::cancelCurrentAction(){
void GameObserver::userRequestNextGamePhase(){
if (mLayers->stackLayer()->getNext(NULL,0,NOT_RESOLVED)) return;
if (getCurrentTargetChooser()) return;
if (mLayers->combatLayer()->isDisplayed()) return;
// if (mLayers->combatLayer()->isDisplayed()) return;
Phase * cPhaseOld = phaseRing->getCurrentPhase();
if (!blockersSorted && cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS){
blockersAssigned = 1;
/*
if (!mLayers->combatLayer()->autoOrderBlockers()){
OutputDebugString("Player has To choose ordering!");
return;
}
*/
}
if (cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS ||
opponent()->isAI() ||
GameOptions::GetInstance()->values[GameOptions::phaseInterrupts[currentGamePhase]].getIntValue()){
if (cPhaseOld->id == Constants::MTG_PHASE_COMBATBLOCKERS ||
opponent()->isAI() ||
options[GameOptions::phaseInterrupts[currentGamePhase]].number){
mLayers->stackLayer()->AddNextGamePhase();
}else{
nextGamePhase();
@@ -170,30 +174,31 @@ void GameObserver::userRequestNextGamePhase(){
int GameObserver::forceShuffleLibraries(){
OutputDebugString("FORCING\n");
int result = 0;
for (int i=0; i<2; i++){
if (forceShuffleLibrary[i]) {
forceShuffleLibrary[i] = 0;
players[i]->game->library->shuffle();
result++;
OutputDebugString("YAY\n");
if (players[0]->game->library->needShuffle)
{
players[0]->game->library->shuffle();
players[0]->game->library->needShuffle = false;
++result;
}
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;
}
void GameObserver::startGame(int shuffle, int draw){
int i;
for (i=0; i<nbPlayers; i++){
for (i=0; i<nbPlayers; i++)
players[i]->game->initGame(shuffle, draw);
forceShuffleLibrary[i] = 0;
}
//Preload images from hand
if (!players[0]->isAI()){
for (i=0; i< players[0]->game->hand->nb_cards; i++){
players[0]->game->hand->cards[i]->getThumb();
players[0]->game->hand->cards[i]->getQuad();
cache.getThumb(players[0]->game->hand->cards[i]);
cache.getQuad(players[0]->game->hand->cards[i]);
}
}
turn = 0;
@@ -202,9 +207,8 @@ void GameObserver::startGame(int shuffle, int draw){
//Difficult mode special stuff
if (!players[0]->isAI() && players[1]->isAI()){
GameOptions * go = GameOptions::GetInstance();
int difficulty = go->values[OPTIONS_DIFFICULTY].getIntValue();
if (go->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue() && difficulty) {
int difficulty = options[Options::DIFFICULTY].number;
if (options[Options::DIFFICULTY_MODE_UNLOCKED].number && difficulty) {
Player * p = players[1];
for (int level=0; level < difficulty; level ++){
MTGCardInstance * card = NULL;
@@ -218,7 +222,7 @@ void GameObserver::startGame(int shuffle, int draw){
}
if (card){
MTGCardInstance * copy = p->game->putInZone(card, p->game->library, p->game->stack);
Spell * spell = NEW Spell(copy);
Spell * spell = NEW Spell(copy);
spell->resolve();
delete spell;
}
@@ -259,8 +263,8 @@ void GameObserver::Update(float dt){
if (currentGamePhase == Constants::MTG_PHASE_COMBATBLOCKERS && !blockersSorted){
player = opponent();
}else if (currentGamePhase == Constants::MTG_PHASE_COMBATDAMAGE){
DamageResolverLayer * drl = mLayers->combatLayer();
if (drl->currentChoosingPlayer && drl->mCount) player = drl->currentChoosingPlayer;
// DamageResolverLayer * drl = mLayers->combatLayer();
// if (drl->currentChoosingPlayer && drl->mCount) player = drl->currentChoosingPlayer;
}
currentActionPlayer = player;
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)
OutputDebugString("Click\n");
#endif
int id = _object->GetId();
if (id >=0){
MTGCardInstance * card = ((CardGui *)_object)->card;
if (CardView* cardview = dynamic_cast<CardView*>(target)){
MTGCardInstance * card = cardview->getCard();
cardClick(card, card);
}
if (id== -6 || id == -4){ //libraries
GuiGameZone * zone = (GuiGameZone *)_object;
if (zone->showCards){
zone->toggleDisplay();
else if (GuiLibrary* library = dynamic_cast<GuiLibrary*>(target)){
if (library->showCards){
library->toggleDisplay();
forceShuffleLibraries();
} else {
int pId = (-id - 4)/2;
TargetChooser * _tc = this->getCurrentTargetChooser();
if (_tc && _tc->targetsZone(players[pId]->game->library)){
zone->toggleDisplay();
forceShuffleLibrary[pId] = 1;
if (_tc && _tc->targetsZone(library->zone)){
library->toggleDisplay();
library->zone->needShuffle = true;
}
}
}
if (id== -5 || id == -3){
GuiGameZone * zone = (GuiGameZone *)_object;
zone->toggleDisplay();
}
if (id == -1 || id == -2){
else if (GuiGraveyard* graveyard = dynamic_cast<GuiGraveyard*>(target))
graveyard->toggleDisplay();
else if (GuiAvatar* avatar = dynamic_cast<GuiAvatar*>(target)){
#if defined (WIN32) || defined (LINUX)
OutputDebugString("Click Player !\n");
#endif
cardClick(NULL, ((GuiAvatar *)_object)->player);
cardClick(NULL, avatar->player);
}
}
@@ -468,8 +466,8 @@ int GameObserver::receiveEvent(WEvent * e){
}
int GameObserver::isACreature(MTGCardInstance * card){
return card->isACreature();
bool GameObserver::isCreature(MTGCardInstance * card){
return card->isCreature();
}

View File

@@ -22,22 +22,24 @@ const char* GameOptions::phaseInterrupts[] = {
"interrupt Cleanup",
"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;
GameOptions * GameOptions::GetInstance(){
if (mInstance == NULL)
mInstance = NEW GameOptions();
return mInstance;
}
GameOption::GameOption(int value) : number(value){}
GameOption::GameOption(string value) : str(value){}
GameOptions::GameOptions(){
load();
@@ -63,7 +65,7 @@ int GameOptions::save(){
if (file){
map<string, GameOption>::iterator 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.close();
@@ -71,13 +73,11 @@ int GameOptions::save(){
return 1;
}
GameOption& GameOptions::operator[](string option_name) {
return values[option_name];
}
GameOptions::~GameOptions(){
}
void GameOptions::Destroy(){
if (mInstance){
delete mInstance;
mInstance = NULL;
}
}
GameOptions options;

View File

@@ -77,7 +77,7 @@ void GameStateDuel::Start()
playerDecksDir = RESPATH"/player";
mFont = GameApp::CommonRes->GetJLBFont(Constants::MENU_FONT);
mFont->SetBase(0);
mFont->SetBase(0);
opponentMenuFont = mFont;
@@ -116,7 +116,7 @@ void GameStateDuel::loadPlayerRandom(int playerId, int isAI, int mode){
int nbcolors = 3;
string lands[] = {"forest", "forest", "island", "mountain", "swamp", "plains", "forest"};
MTGDeck * tempDeck = NEW MTGDeck(NULL, mParent->collection);
tempDeck->addRandomCards(9,0,0,-1,lands[color1].c_str());
@@ -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,"artifact",colors,nbcolors);
char * deckFile = "random";
string deckFile = "random";
string deckFileSmall = "random";
deck[playerId] = NEW MTGPlayerCards(mParent->collection,tempDeck);
if (!isAI){ //Human Player
mPlayers[playerId] = NEW HumanPlayer(deck[playerId],deckFile, deckFileSmall);
}else{
mPlayers[playerId] = NEW AIPlayerBaka(deck[playerId],deckFile, deckFileSmall.c_str() , "");
}
deck[playerId] = NEW MTGPlayerCards(mParent->collection, tempDeck);
if (!isAI) // Human Player
mPlayers[playerId] = NEW HumanPlayer(deck[playerId], deckFile, deckFileSmall);
else
mPlayers[playerId] = NEW AIPlayerBaka(deck[playerId],deckFile, deckFileSmall, "");
delete tempDeck;
}
@@ -147,12 +146,11 @@ void GameStateDuel::loadPlayerMomir(int playerId, int isAI){
string deckFileSmall = "momir";
char empty[] = "";
MTGDeck * tempDeck = NEW MTGDeck(deckFile, NULL, mParent->collection);
deck[playerId] = NEW MTGPlayerCards(mParent->collection,tempDeck);
if (!isAI){ //Human Player
mPlayers[playerId] = NEW HumanPlayer(deck[playerId],deckFile, deckFileSmall);
}else{
mPlayers[playerId] = NEW AIMomirPlayer(deck[playerId],deckFile,deckFileSmall.c_str(), empty);
}
deck[playerId] = NEW MTGPlayerCards(mParent->collection, tempDeck);
if (!isAI) // Human Player
mPlayers[playerId] = NEW HumanPlayer(deck[playerId], deckFile, deckFileSmall);
else
mPlayers[playerId] = NEW AIMomirPlayer(deck[playerId], deckFile, deckFileSmall, empty);
delete tempDeck;
}
@@ -295,17 +293,15 @@ void GameStateDuel::Update(float dt)
else deckmenu->Update(dt);
break;
case DUEL_STATE_CHOOSE_DECK2:
if (mParent->players[1] == PLAYER_TYPE_HUMAN){
if (mParent->players[1] == PLAYER_TYPE_HUMAN)
deckmenu->Update(dt);
}
else{
if (mParent->players[0] == PLAYER_TYPE_HUMAN){
if (!opponentMenu){
opponentMenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_OPPONENT, this, opponentMenuFont, 35, 25, "Choose Opponent");
opponentMenu->Add(0,"Random");
if (GameOptions::GetInstance()->values[OPTIONS_EVILTWIN_MODE_UNLOCKED].getIntValue()){
opponentMenu->Add(-1,"Evil Twin", "Can you play against yourself?");
}
if (options[Options::EVILTWIN_MODE_UNLOCKED].number)
opponentMenu->Add(-1,"Evil Twin", "Can you play against yourself?");
fillDeckMenu(opponentMenu,RESPATH"/ai/baka", "ai_baka", mPlayers[0]);
}
opponentMenu->Update(dt);
@@ -457,7 +453,7 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
break;
}
case DUEL_MENU_CHOOSE_DECK:
{
{
if (controlId < 0){
mParent->SetNextState(GAME_STATE_DECK_VIEWER);
return;

View File

@@ -5,7 +5,7 @@
#include "../include/GameOptions.h"
#include "../include/GameApp.h"
#include "../include/MTGCard.h"
#include "../include/Translate.h"
#include "../include/Translate.h"
#include "../include/DeckStats.h"
#include "../include/PlayerData.h"
#include "../include/utils.h"
@@ -148,23 +148,19 @@ void GameStateMenu::Start(){
JRenderer::GetInstance()->EnableVSync(true);
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");
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);
SAFE_DELETE(GameApp::music);
}
hasChosenGameType = 1;
if (GameOptions::GetInstance()->values[OPTIONS_MOMIR_MODE_UNLOCKED].getIntValue()) hasChosenGameType =0;
if (GameOptions::GetInstance()->values[OPTIONS_RANDOMDECK_MODE_UNLOCKED].getIntValue()) hasChosenGameType =0;
if (options[Options::MOMIR_MODE_UNLOCKED].number) hasChosenGameType = 0;
if (options[Options::RANDOMDECK_MODE_UNLOCKED].number) hasChosenGameType = 0;
}
@@ -175,7 +171,7 @@ void GameStateMenu::fillScroller(){
DeckStats * stats = DeckStats::GetInstance();
int totalGames = 0;
for (int j=1; j<6; j++){
sprintf(buffer, RESPATH"/player/stats/player_deck%i.txt",j);
if(fileExists(buffer)){
@@ -194,28 +190,26 @@ void GameStateMenu::fillScroller(){
sprintf(buff2, _("You have played a total of %i games").c_str(),totalGames);
scroller->Add(buff2);
}
GameOptions * go = GameOptions::GetInstance();
if (!go->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue()){
scroller->Add(_("Unlock the difficult mode for more challenging duels!"));
}
if (!go->values[OPTIONS_MOMIR_MODE_UNLOCKED].getIntValue()){
scroller->Add(_("Interested in playing Momir Basic? You'll have to unlock it first :)"));
}
if (!go->values[OPTIONS_RANDOMDECK_MODE_UNLOCKED].getIntValue()){
scroller->Add(_("You haven't unlocked the random deck mode yet"));
}
if (!go->values[OPTIONS_EVILTWIN_MODE_UNLOCKED].getIntValue()){
scroller->Add(_("You haven't unlocked the evil twin mode yet"));
}
if (!options[Options::DIFFICULTY_MODE_UNLOCKED].number)
scroller->Add(_("Unlock the difficult mode for more challenging duels!"));
if (!options[Options::MOMIR_MODE_UNLOCKED].number)
scroller->Add(_("Interested in playing Momir Basic? You'll have to unlock it first :)"));
if (!options[Options::RANDOMDECK_MODE_UNLOCKED].number)
scroller->Add(_("You haven't locked the random deck mode yet"));
if (!options[Options::EVILTWIN_MODE_UNLOCKED].number)
scroller->Add(_("You haven't unlocked the evil twin mode yet"));
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"));
//Unlocked sets
int nbunlocked = 0;
for (int i = 0; i < MtgSets::SetsList->nb_items; i++){
string s = MtgSets::SetsList->values[i];
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);
scroller->Add(buff2);
@@ -323,20 +317,16 @@ void GameStateMenu::Update(float dt)
string s = MtgSets::SetsList->values[setId];
char buffer[4096];
sprintf(buffer,"unlocked_%s", s.c_str());
GameOptions::GetInstance()->values[buffer] = GameOption(1);
GameOptions::GetInstance()->save();
createUsersFirstDeck(setId);
options[buffer] = GameOption(1);
options.save();
createUsersFirstDeck(setId);
}
currentState = MENU_STATE_MAJOR_MAINMENU | MENU_STATE_MINOR_NONE;
break;
case MENU_STATE_MAJOR_MAINMENU :
if (!scrollerSet) fillScroller();
if (mGuiController!=NULL){
if (NULL != mGuiController)
mGuiController->Update(dt);
}
break;
case MENU_STATE_MAJOR_SUBMENU :
subMenuController->Update(dt);
@@ -345,25 +335,24 @@ void GameStateMenu::Update(float dt)
case MENU_STATE_MAJOR_DUEL :
if (MENU_STATE_MINOR_NONE == (currentState & MENU_STATE_MINOR))
{
if (!hasChosenGameType){
currentState = MENU_STATE_MAJOR_SUBMENU;
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MENU_FONT);
subMenuController = NEW SimpleMenu(102, this, mFont, 150,60);
if (!hasChosenGameType){
currentState = MENU_STATE_MAJOR_SUBMENU;
JLBFont * mFont = GameApp::CommonRes->GetJLBFont(Constants::MENU_FONT);
subMenuController = NEW SimpleMenu(102, this, mFont, 150,60);
if (subMenuController){
subMenuController->Add(SUBMENUITEM_CLASSIC,"Classic");
if (GameOptions::GetInstance()->values[OPTIONS_MOMIR_MODE_UNLOCKED].getIntValue()){
subMenuController->Add(SUBMENUITEM_MOMIR, "Momir Basic");
}
if (GameOptions::GetInstance()->values[OPTIONS_RANDOMDECK_MODE_UNLOCKED].getIntValue()){
subMenuController->Add(SUBMENUITEM_RANDOM1, "Random 1 Color");
subMenuController->Add(SUBMENUITEM_RANDOM2, "Random 2 Colors");
}
if (options[Options::MOMIR_MODE_UNLOCKED].number)
subMenuController->Add(SUBMENUITEM_MOMIR, "Momir Basic");
if (options[Options::RANDOMDECK_MODE_UNLOCKED].number){
subMenuController->Add(SUBMENUITEM_RANDOM1, "Random 1 Color");
subMenuController->Add(SUBMENUITEM_RANDOM2, "Random 2 Colors");
}
subMenuController->Add(SUBMENUITEM_CANCEL, "Cancel");
}
}else{
}
}else{
mParent->SetNextState(GAME_STATE_DUEL);
currentState = MENU_STATE_MAJOR_MAINMENU;
}
}
}
}
switch (MENU_STATE_MINOR & currentState)
@@ -484,7 +473,7 @@ void GameStateMenu::Render()
if (yW < 2*SCREEN_HEIGHT) renderer->RenderQuad(mMovingW, SCREEN_WIDTH/2 - 10, yW, angleW);
if (mGuiController!=NULL)
mGuiController->Render();
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
mFont->SetColor(ARGB(128,255,255,255));
mFont->DrawString(GAME_VERSION, SCREEN_WIDTH-10,5,JGETEXT_RIGHT);

View File

@@ -25,23 +25,20 @@ void GameStateOptions::Start()
JRenderer::GetInstance()->EnableVSync(true);
optionsList = NEW OptionsList();
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_INTERRUPTMYSPELLS, "interrupt my spells"));
optionsList->Add(NEW OptionItem(OPTIONS_INTERRUPTMYABILITIES, "interrupt my abilities"));
optionsList->Add(NEW OptionItem(OPTIONS_OSD, "Display InGame extra information"));
// WALDORF - added next line
optionsList->Add(NEW OptionItem(OPTIONS_INTERRUPT_SECONDS, "Seconds to pause for an Interrupt", 20, 1));
if (GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue()) {
optionsList->Add(NEW OptionItem(OPTIONS_DIFFICULTY, "Difficulty", 3, 1));
}
optionsList->Add(NEW OptionItem(OPTIONS_CACHESIZE, "Image Cache Size", 60, 5));
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::INTERRUPTMYSPELLS, "interrupt my spells"));
optionsList->Add(NEW OptionItem(Options::INTERRUPTMYABILITIES, "interrupt my abilities"));
optionsList->Add(NEW OptionItem(Options::INTERRUPT_SECONDS, "Seconds to pause for an Interrupt", 20, 1));
optionsList->Add(NEW OptionItem(Options::OSD, "Display InGame extra information"));
if (options[Options::DIFFICULTY_MODE_UNLOCKED].number)
optionsList->Add(NEW OptionItem(Options::DIFFICULTY, "Difficulty", 3, 1));
optionsList->Add(NEW OptionItem(Options::CACHESIZE, "Image Cache Size", 60, 5));
JLBFont * mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
optionsMenu = NEW SimpleMenu(102, this,mFont, 50,170);
optionsMenu->Add(1, "Save & Back to Main Menu");
optionsMenu->Add(2, "Back to Main Menu");
optionsMenu->Add(3, "Cancel");
}

View File

@@ -67,22 +67,21 @@ void GameStateShop::load(){
if (s.compare("10E") == 0) defaultSet = i;
char buffer[4096];
sprintf(buffer,"unlocked_%s", s.c_str());
unlocked[i] = GameOptions::GetInstance()->values[buffer].getIntValue();
if ( unlocked[i] ){
unlocked[i] = options[buffer].number;
if (unlocked[i])
ok = 1;
}
}
if (!ok){
unlocked[defaultSet] = 1;
string s = MtgSets::SetsList->values[defaultSet];
char buffer[4096];
sprintf(buffer,"unlocked_%s", s.c_str());
GameOptions::GetInstance()->values[buffer] = GameOption(1);
GameOptions::GetInstance()->save();
options[buffer] = GameOption(1);
options.save();
}
for (int i = 0; i < MtgSets::SetsList->nb_items; i++){
if (unlocked[i] ){
if (unlocked[i]){
sets[nbsets] = i;
nbsets++;
if (mParent->collection->countBySet(i) > 80){ //Only sets with more than 80 cards can get boosters and starters

View File

@@ -2,9 +2,7 @@
#include "../include/GuiLayers.h"
#include "../include/Player.h"
GuiLayer::GuiLayer(int id, GameObserver* _game){
mId = id;
game = _game;
GuiLayer::GuiLayer(){
modal = 0;
hasFocus = false;
mCount = 0;
@@ -42,7 +40,7 @@ int GuiLayer::getMaxId(){
void GuiLayer::Render(){
for (int i=0;i<mCount;i++)
if (mObjects[i]!=NULL)
mObjects[i]->Render();
mObjects[i]->Render();
}
void GuiLayer::Update(float dt){
@@ -103,77 +101,3 @@ JGuiObject * GuiLayer::getByIndex(int 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;
}

View File

@@ -18,7 +18,7 @@ static int colors[] =
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");
if (texture)
@@ -45,24 +45,24 @@ void GuiPhaseBar::Render()
static const float ICONSCALE = 1.5;
static const unsigned CENTER = SCREEN_HEIGHT / 2 + 10;
JRenderer* renderer = JRenderer::GetInstance();
unsigned p = (phase->id + Phases - 4) * Width;
unsigned p = (phase->id + Phases - 4) * (Width+1);
float scale;
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));
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);
start += Width * scale;
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);
start += Width * scale;
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);
start += Width * scale;
@@ -70,25 +70,24 @@ void GuiPhaseBar::Render()
scale = ICONSCALE * sinf(angle + 2 * M_PI / 6) / 2;
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);
scale = ICONSCALE * sinf(angle + 1 * M_PI / 6) / 2;
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);
if (angle > 0)
{
scale = ICONSCALE * sinf(angle)/2;
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);
}
}
int GuiPhaseBar::receiveEvent(WEvent *e)
int GuiPhaseBar::receiveEventMinus(WEvent *e)
{
WEventPhaseChange *event = dynamic_cast<WEventPhaseChange*>(e);
if (event)

View File

@@ -1311,7 +1311,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
game->mLayers->stackLayer()->addDamage(card, game->players[i], x);
for (int j = 0; j < game->players[i]->game->inPlay->nb_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);
}
}
@@ -1348,7 +1348,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
game->mLayers->stackLayer()->addDamage(card, game->players[i], x);
for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
if (current->isACreature()){
if (current->isCreature()){
game->mLayers->stackLayer()->addDamage(card, current, x);
}
}
@@ -1372,13 +1372,13 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
{
int x = computeX(spell,card);
for (int i = 0; i < 2 ; i++){
game->mLayers->stackLayer()->addDamage(card, game->players[i], x);
for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
if (!current->basicAbilities[Constants::FLYING] && current->isACreature()){
game->mLayers->stackLayer()->addDamage(card, current, x);
}
}
game->mLayers->stackLayer()->addDamage(card, game->players[i], x);
for (int j = 0; j < game->players[i]->game->inPlay->nb_cards; j++){
MTGCardInstance * current = game->players[i]->game->inPlay->cards[j];
if (!current->basicAbilities[Constants::FLYING] && current->isCreature()){
game->mLayers->stackLayer()->addDamage(card, current, x);
}
}
}
break;
}
@@ -2286,69 +2286,79 @@ other solutions need to be provided for abilities that add mana (ex: mana flare)
*/
AManaProducer::AManaProducer(int id, MTGCardInstance * card, ManaCost * _output, ManaCost * _cost , int doTap):MTGAbility(id, card), tap(doTap){
AManaProducer::AManaProducer(int id, MTGCardInstance * card, ManaCost * _output, ManaCost * _cost , int doTap):MTGAbility(id, card), tap(doTap){
LOG("==Creating ManaProducer Object");
aType=MTGAbility::MANA_PRODUCER;
cost = _cost;
output=_output;
x1 = 10;
y1 = 220;
Player * player = card->controller();
if (player == game->players[1]) y1 = 100;
x = x1;
y = y1;
animation = 0.f;
mParticleSys = NULL;
menutext = "";
LOG("==Creating ManaProducer Object");
aType = MTGAbility::MANA_PRODUCER;
cost = _cost;
output = _output;
cout << "!" << card->view << endl;
if (card->view)
{
x1 = card->view->actX; y1 = card->view->actY;
}
else
{
x1 = 10; y1 = 220;
}
Player * player = card->controller();
if (player == game->players[1]) y1 = 100;
x = x1;
y = y1;
animation = 0.f;
mParticleSys = NULL;
menutext = "";
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"));
}else if (landColor == Constants::MTG_COLOR_BLUE){
break;
case Constants::MTG_COLOR_BLUE :
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"));
}else if (landColor == Constants::MTG_COLOR_BLACK){
break;
case Constants::MTG_COLOR_BLACK :
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"));
}else{
break;
default :
mParticleSys = NEW hgeParticleSystem("graphics/mana.psi", GameApp::CommonRes->GetQuad("particles"));
}
LOG("==ManaProducer Object Creation successful !");
}
LOG("==ManaProducer Object Creation successful !");
}
void AManaProducer::Update(float dt){
if (mParticleSys) mParticleSys->Update(dt);
if (animation){
x = (1.f - animation)*x1 + animation * x0;
y = (1.f - animation)*y1 + animation * y0;
if (mParticleSys) mParticleSys->MoveTo(x, y);
if (mParticleSys && animation == 1.f) mParticleSys->Fire();
animation -= 4 *dt;
if (!animation) animation = -1;
if (animation < 0){
resolve();
}
void AManaProducer::Update(float dt){
if (mParticleSys) mParticleSys->Update(dt);
if (animation){
x = (1.f - animation)*x1 + animation * x0;
y = (1.f - animation)*y1 + animation * y0;
if (mParticleSys) mParticleSys->MoveTo(x, y);
if (mParticleSys && animation == 1.f) mParticleSys->Fire();
animation -= 4 *dt;
if (!animation) animation = -1;
if (animation < 0){
resolve();
}
}
}
void AManaProducer::Render(){
JRenderer * renderer = JRenderer::GetInstance();
if (animation){
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
if (mParticleSys) mParticleSys->Render();
// set normal blending
renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
}
void AManaProducer::Render(){
JRenderer * renderer = JRenderer::GetInstance();
if (animation){
// renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE);
// if (mParticleSys) mParticleSys->Render();
// set normal blending
// renderer->SetTexBlend(BLEND_SRC_ALPHA, BLEND_ONE_MINUS_SRC_ALPHA);
}
}
int AManaProducer::isReactingToClick(MTGCardInstance * _card, ManaCost * mana){
int result = 0;
@@ -2387,17 +2397,21 @@ other solutions need to be provided for abilities that add mana (ex: mana flare)
currentlyTapping++;
animation = 1.f;
CardGui * cardg = game->mLayers->playLayer()->getByCard(source);
if (cardg){
x0 = cardg->x + 15;
y0 = cardg->y + 20;
}
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME].getIntValue() > 0 && currentlyTapping < 3){
if (options[Options::SFXVOLUME].number > 0 && currentlyTapping < 3){
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/mana.wav");
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;
}

View File

@@ -3,14 +3,15 @@
//-------------------------------------------------
//TODO Fill BasicAbilities
#include "../include/config.h"
#include "../include/MTGCard.h"
#include "../include/TexturesCache.h"
#include "../include/Subtypes.h"
#include <string>
#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;
@@ -18,12 +19,10 @@ const char * const MTGCard::Colors_To_Text[] = {"Artifact", "Green", "Blue", "Re
MTGCard::MTGCard(){
init();
mCache = NULL;
}
MTGCard::MTGCard(TexturesCache * cache, int set_id){
MTGCard::MTGCard(int set_id){
init();
mCache = cache;
setId = set_id;
}
@@ -32,7 +31,6 @@ const char * MTGCard::getSetName(){
}
MTGCard::MTGCard(MTGCard * source){
mCache = source->mCache;
for(map<int,int>::const_iterator it = source->basicAbilities.begin(); it != source->basicAbilities.end(); ++it){
basicAbilities[it->first] = source->basicAbilities[it->first];
}
@@ -55,7 +53,6 @@ MTGCard::MTGCard(MTGCard * source){
toughness = source->toughness;
mtgid = source->mtgid;
setId = source->setId;
formattedTextInit = 0;
magicText = source->magicText;
spellTargetType = source->spellTargetType;
alias = source->alias;
@@ -72,34 +69,63 @@ int MTGCard::init(){
colors[i] = 0;
}
setId = 0;
formattedTextInit = 0;
magicText = "";
spellTargetType = "";
alias = 0;
return 1;
}
JQuad * MTGCard::getQuad(int type){
if (mCache == NULL){
return NULL;
}
return mCache->getQuad(this, type);
const vector<string>& MTGCard::formattedText()
{
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);
}
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(){
return getQuad(CACHE_THUMB);
bool MTGCard::isCreature(){
return hasSubtype("creature");
}
JQuad * MTGCard::getQuad(TexturesCache * cache){
return cache->getQuad(this);
bool MTGCard::isLand(){
return hasSubtype("land");
}
int MTGCard::isACreature(){
return (hasSubtype("creature"));
bool MTGCard::isSpell(){
return (!isCreature() && !isLand());
}
void MTGCard::setColor(int _color, int removeAllOthers){
@@ -234,51 +260,45 @@ void MTGCard::setName( string value){
name = value;
//This is a bug fix for plague rats and the "foreach ability"
//Right now we add names as types, so that they get recognized
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(){
return name.c_str();
const string MTGCard::getName() const{
return name;
}
ManaCost * MTGCard::getManaCost(){
ManaCost* MTGCard::getManaCost(){
return &manaCost;
}
int MTGCard::hasType(int _type){
int i;
for (i = 0; i<nb_types; i++){
if(types[i] == _type){
return 1;
}
}
return 0;
bool MTGCard::hasType(int _type){
for (int i = 0; i<nb_types; i++)
if (types[i] == _type)
return true;
return false;
}
int MTGCard::hasSubtype(int _subtype){
return(hasType(_subtype));
bool MTGCard::hasSubtype(int _subtype){
return hasType(_subtype);
}
int MTGCard::hasType(const char * _type){
bool MTGCard::hasType(const char * _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);
return(hasType(id));
return hasType(id);
}
int MTGCard::hasSubtype(string _subtype){
bool MTGCard::hasSubtype(string _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(){
return toughness;
}

View File

@@ -12,24 +12,24 @@
#include <algorithm>
using namespace std;
MTGCardInstance::MTGCardInstance(): MTGCard(), Damageable(0){
MTGCardInstance::MTGCardInstance(): MTGCard(), Damageable(0), view(NULL){
LOG("==Creating MTGCardInstance==");
initMTGCI();
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==");
initMTGCI();
model = card;
attacker = 0;
lifeOrig = life;
belongs_to=_belongs_to;
belongs_to = arg_belongs_to;
owner = NULL;
if (_belongs_to) owner = _belongs_to->library->owner;
if (arg_belongs_to) owner = arg_belongs_to->library->owner;
lastController = owner;
defenser = NULL;
banding = NULL;
life=toughness;
life = toughness;
LOG("==Creating MTGCardInstance Successful==");
}
@@ -60,10 +60,9 @@ void MTGCardInstance::copy(MTGCardInstance * card){
lifeOrig = life;
//mtgid = source->mtgid;
//setId = source->setId;
formattedTextInit = 0;
magicText = source->magicText;
spellTargetType = source->spellTargetType;
alias = source->alias;
alias = source->alias;
//Now this is dirty...
int backupid = mtgid;
@@ -109,7 +108,7 @@ void MTGCardInstance::initMTGCI(){
}
const char * MTGCardInstance::getDisplayName(){
const string MTGCardInstance::getDisplayName(){
return getName();
}
@@ -135,7 +134,7 @@ int MTGCardInstance::isInPlay(){
int MTGCardInstance::afterDamage(){
if (!doDamageTest) return 0;
doDamageTest = 0;
if (!isACreature()) return 0;
if (!isCreature()) return 0;
if (life <=0 && isInPlay()){
return destroy();
}
@@ -168,10 +167,6 @@ MTGGameZone * MTGCardInstance::getCurrentZone(){
return NULL;
}
JQuad * MTGCardInstance::getIcon(){
return getThumb();
}
int MTGCardInstance::has(int basicAbility){
return basicAbilities[basicAbility];
}
@@ -271,16 +266,16 @@ return previous->stillInUse();
}
/* Summoning Sickness
* 212.3f A creature<EFBFBD>fs activated ability with the tap symbol or the untap symbol in its activation cost
* can<EFBFBD>ft be played unless the creature has been under its controller<EFBFBD>fs control since the start of his or
* her most recent turn. A creature can<EFBFBD>ft attack unless it has been under its controller<EFBFBD>fs control
* since the start of his or her most recent turn. This rule is informally called the <EFBFBD>gsummoning
* sickness<EFBFBD>h rule. Ignore this rule for creatures with haste (see rule 502.5).
* 212.3f A creature's activated ability with the tap symbol or the untap symbol in its activation cost
* 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 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 "summoning
* sickness" rule. Ignore this rule for creatures with haste (see rule 502.5).
*/
int MTGCardInstance::hasSummoningSickness(){
if (!summoningSickness) return 0;
if (basicAbilities[Constants::HASTE]) return 0;
if (!isACreature()) return 0;
if (!isCreature()) return 0;
return 1;
}
@@ -318,7 +313,7 @@ int MTGCardInstance::canAttack(){
if (tapped) return 0;
if (hasSummoningSickness()) return 0;
if (basicAbilities[Constants::DEFENSER] || basicAbilities[Constants::CANTATTACK]) return 0;
if (!isACreature()) return 0;
if (!isCreature()) return 0;
if (!isInPlay()) return 0;
return 1;
}
@@ -341,7 +336,7 @@ int MTGCardInstance::setToughness(int value){
int MTGCardInstance::canBlock(){
if (tapped) return 0;
if (basicAbilities[Constants::CANTBLOCK]) return 0;
if (!isACreature())return 0;
if (!isCreature()) return 0;
if (!isInPlay()) return 0;
return 1;
}
@@ -410,7 +405,7 @@ int MTGCardInstance::setAttacker(int value){
Targetable * target = NULL;
Player * p = controller()->opponent();
if (value) target = p;
if (attacker) previousTarget = p;
if (attacker) previousTarget = p;
attacker = value;
WEvent * e = NEW WEventCreatureAttacker(this,previousTarget, target);
GameObserver::GetInstance()->receiveEvent(e);
@@ -421,7 +416,7 @@ int MTGCardInstance::setAttacker(int value){
int MTGCardInstance::toggleAttacker(){
if (!attacker){
if (!basicAbilities[Constants::VIGILANCE]) tap();
setAttacker(1);
setAttacker(1);
return 1;
}else{
//Banding needs to be debugged...
@@ -472,15 +467,15 @@ MTGCardInstance * MTGCardInstance::getNextDefenser(MTGCardInstance * previous){
}
int MTGCardInstance::moveBlockerInRow(MTGCardInstance * blocker){
list<MTGCardInstance *>::iterator it1 = find(blockers.begin(), blockers.end(), blocker);
list<MTGCardInstance *>::iterator it2 = it1;
if (it2 == blockers.end()) it2 = blockers.begin(); else ++it2;
if (it2 == blockers.end()) it2 = blockers.begin();
std::iter_swap(it1,it2);
WEvent* e = NEW WEventCreatureBlockerRank(blocker,*it2,this);
GameObserver::GetInstance()->receiveEvent(e);
delete(e);
list<MTGCardInstance *>::iterator it1 = find(blockers.begin(), blockers.end(), blocker);
list<MTGCardInstance *>::iterator it2 = it1;
if (it2 == blockers.end()) it2 = blockers.begin(); else ++it2;
if (it2 == blockers.end()) it2 = blockers.begin();
std::iter_swap(it1,it2);
WEvent* e = NEW WEventCreatureBlockerRank(blocker,*it2,this);
GameObserver::GetInstance()->receiveEvent(e);
delete(e);
return 1;
}

View File

@@ -275,7 +275,7 @@ int MTGAllCards::readConfLine(std::ifstream &file, int set_id){
switch(conf_read_mode) {
case 0:
if (s[0] == '['){
tempCard = NEW MTGCard(mCache,set_id);
tempCard = NEW MTGCard(set_id);
conf_read_mode = 1;
}
break;

View File

@@ -14,7 +14,6 @@
//------------------------------
MTGPlayerCards::MTGPlayerCards(MTGAllCards * _collection, int * idList, int idListSize){
init();
int i;
collection = _collection;
@@ -25,14 +24,9 @@ MTGPlayerCards::MTGPlayerCards(MTGAllCards * _collection, int * idList, int idLi
library->addCard(newCard);
}
}
}
MTGPlayerCards::MTGPlayerCards(MTGAllCards * _collection,MTGDeck * deck){
MTGPlayerCards::MTGPlayerCards(MTGAllCards * _collection, MTGDeck * deck){
init();
collection = _collection;
map<int,int>::iterator it;
@@ -70,7 +64,7 @@ void MTGPlayerCards::setOwner(Player * player){
void MTGPlayerCards::initGame(int shuffle, int draw){
if (shuffle) library->shuffle();
if (draw){
for (int i=0;i<7;i++){
for (int i=0;i<7;i++){
OutputDebugString("draw\n");
drawFromLibrary();
}
@@ -153,10 +147,9 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
}
if ((copy = from->removeCard(card,doCopy))){
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME].getIntValue() > 0){
if (options[Options::SFXVOLUME].number > 0){
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");
if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
}
@@ -170,7 +163,7 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
ret = NULL;
}
}
to->addCard(copy);
copy->changedZoneRecently = 1.f;
GameObserver *g = GameObserver::GetInstance();
@@ -200,9 +193,7 @@ int MTGPlayerCards::isInPlay(MTGCardInstance * card){
// Zones specific code
//--------------------------------------
MTGGameZone::MTGGameZone(){
nb_cards= 0;
lastCardDrawn = NULL;
MTGGameZone::MTGGameZone() : nb_cards(0), lastCardDrawn(NULL), needShuffle(false) {
}
MTGGameZone::~MTGGameZone(){
@@ -227,13 +218,13 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy
nb_cards--;
cards.erase(cards.begin()+i);
MTGCardInstance * copy = card;
if (card->isToken){ //TODO better than this ?
if (card->isToken) //TODO better than this ?
return card;
}
//card->lastController = card->controller();
if (createCopy) {
copy = NEW MTGCardInstance(card->model,card->owner->game);
copy->previous = card;
copy->view = card->view;
card->next = copy;
}
copy->previousZone = this;
@@ -313,11 +304,8 @@ MTGCardInstance * MTGLibrary::draw(){
}
void MTGGameZone::debugPrint(){
int i;
for (i=0;i<nb_cards;i++){
MTGCard * card = cards[i];
fprintf(stderr, "%s", card->getName());
}
for (int i = 0; i < nb_cards; i++)
std::cerr << cards[i]->getName() << endl;
}

View File

@@ -2,7 +2,7 @@
#include "../include/MTGGuiHand.h"
#include "../include/CardGui.h"
MTGGuiHand::MTGGuiHand(int id, GameObserver * _game):GuiCardsController(id, _game){
MTGGuiHand::MTGGuiHand(GameObserver* game) : game(game) {
mShowHand = HAND_HIDE;
mAnimState = 0;
currentPlayer = NULL;
@@ -22,7 +22,7 @@ void MTGGuiHand::updateCards(){
resetObjects();
if (currentId[player->getId()] >= nb_cards) currentId[player->getId()] = nb_cards - 1;
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);
if ( i == currentId[player->getId()]) mCurr = i;
}
@@ -37,7 +37,7 @@ void MTGGuiHand::Update(float dt){
updateCards();
for (int i=0;i<mCount;i++){
if (mObjects[i]!=NULL){
((CardGui *)mObjects[i])->y= SCREEN_HEIGHT - mAnimState*60;
((CardGui *)mObjects[i])->y = SCREEN_HEIGHT - mAnimState*60;
}
}
@@ -79,7 +79,7 @@ bool MTGGuiHand::CheckUserInput(u32 key){
if (mShowHand == HAND_HIDE || currentPlayer->isAI()){
return false;
}else{
GuiCardsController::CheckUserInput(key);
// GuiCardsController::CheckUserInput(key);
return true;
}
}
@@ -98,7 +98,7 @@ void MTGGuiHand::Render(){
}
if (mCount && mObjects[mCurr] != NULL){
mObjects[mCurr]->Render();
if (showBigCards) ((CardGui *)mObjects[mCurr])->RenderBig(10,-1,showBigCards-1);
// if (showBigCards) ((CardGui *)mObjects[mCurr])->RenderBig(10,-1,showBigCards-1);
}
}
}

View File

@@ -23,7 +23,7 @@
MTGGuiPlay::MTGGuiPlay(int id, GameObserver * _game):PlayGuiObjectController(id, _game){
MTGGuiPlay::MTGGuiPlay(GameObserver* game) : game(game){
currentPlayer = NULL;
offset = 0;
@@ -123,18 +123,18 @@ void MTGGuiPlay::setCardPosition(CardGui * cardg, int player, int playerTurn, in
if (!(cardg->x ==0 && cardg->y ==0)) return ;
if (card->target)
return;
if (spellMode && (card->isACreature() || card->hasType("land"))) return;
if (!spellMode && !card->isACreature() && !card->hasType("land")) return;
if (card->isACreature()){
if (spellMode && (card->isCreature() || card->isLand())) return;
if (!spellMode && !card->isCreature() && !card->isLand()) return;
if (card->isCreature()){
int x_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->y=ZY_MAIN + ZH_CREATURES + (Z_CARDHEIGHT * y_offset) + 100 * (1-player);
cardg->x = ZX_MAIN + (Z_CARDWIDTH * x_offset);
cardg->y = ZY_MAIN + ZH_CREATURES + (Z_CARDHEIGHT * y_offset) + 100 * (1-player);
nb_creatures[player]++;
if (playerTurn){
if (card->isAttacker()){
cardg->y=122 + 30 * (1-player);
cardg->y = 122 + 30 * (1-player);
//Sets position of opponents as well
if (player == 1){
for (list<MTGCardInstance *>::iterator it= card->blockers.begin(); it !=card->blockers.end() ; ++it){
@@ -153,27 +153,26 @@ void MTGGuiPlay::setCardPosition(CardGui * cardg, int player, int playerTurn, in
}
}
}
}
}else{
if (card->isDefenser()){
CardGui * targetg = getByCard(card->isDefenser());
if (targetg) cardg->x = targetg->x;
cardg->y=122 + 30 * (1-player);
CardGui * targetg = getByCard(card->isDefenser());
if (targetg) cardg->x = targetg->x;
cardg->y = 122 + 30 * (1-player);
}
}
}else if(card->hasType("land")){
int x_offset = nb_lands[player] % cards_x_limit;
int y_offset = nb_lands[player] / cards_x_limit;
cardg->x=ZX_MAIN + (Z_CARDWIDTH * x_offset);
cardg->y=ZY_MAIN + (Z_CARDHEIGHT * y_offset) + 200 * (1-player);
cardg->x = ZX_MAIN + (Z_CARDWIDTH * x_offset);
cardg->y = ZY_MAIN + (Z_CARDHEIGHT * y_offset) + 200 * (1-player);
nb_lands[player]++;
}else{
int y_offset = nb_spells[player] % Z_SPELLS_NBCARDS;
int x_offset = nb_spells[player] / Z_SPELLS_NBCARDS;
cardg->x=ZX_SPELL - (Z_CARDWIDTH * x_offset);
cardg->y=ZY_SPELL + (Z_CARDHEIGHT * y_offset) + 125 * (1-player);
cardg->x = ZX_SPELL - (Z_CARDWIDTH * x_offset);
cardg->y = ZY_SPELL + (Z_CARDHEIGHT * y_offset) + 125 * (1-player);
nb_spells[player]++;
cards_x_limit = 12 - (nb_spells[player] + 2)/ Z_SPELLS_NBCARDS;
}
@@ -188,15 +187,14 @@ void MTGGuiPlay::setTargettingCardPosition(CardGui * cardg, int player, int play
return;
CardGui * targetg = getByCard(target);
if (targetg){
cardg->y=targetg->y + 5;
cardg->x=targetg->x + 5;
cardg->y = targetg->y + 5;
cardg->x = targetg->x + 5;
}
adjustCardPosition(cardg);
return;
}
void MTGGuiPlay::forceUpdateCards(){
GameObserver * game = GameObserver::GetInstance();
Player * player = game->players[0];
int player0Mode =(game->currentPlayer == player);
int nb_cards = player->game->inPlay->nb_cards;
@@ -211,14 +209,14 @@ void MTGGuiPlay::forceUpdateCards(){
for (int i = 0;i<nb_cards; i++){
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);
hasFocus = false;
}
hasFocus = !player0Mode;
for (int i = 0;i<opponent_cards; i++){
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);
hasFocus = false;
}
@@ -226,16 +224,17 @@ void MTGGuiPlay::forceUpdateCards(){
currentPlayer = game->currentPlayer;
}
int MTGGuiPlay::receiveEvent(WEvent *event){
int MTGGuiPlay::receiveEventPlus(WEvent *event){
WEventZoneChange * e = dynamic_cast<WEventZoneChange*>(event);
if (!e) return 0;
int ok = 0;
for (int i = 0; i < 2 ; i++){
Player * p = game->players[i];
if (e->from == p->game->inPlay || e->to == p->game->inPlay ) ok = 1;
}
if (!ok) return 0;
forceUpdateCards();
if (e->from == game->players[0]->game->inPlay || e->from == game->players[1]->game->inPlay)
{
for (vector<JGuiObject*>::iterator it = mObjects.begin(); it != mObjects.end(); ++it)
if (*it == (JGuiObject*)e->card) { mObjects.erase(it); delete(*it); return 1; }
}
else if (e->to == game->players[0]->game->inPlay || e->to == game->players[1]->game->inPlay)
Add(NEW CardView(e->card, 500, 300));
// forceUpdateCards();
updateCards();
return 1;
}
@@ -296,15 +295,15 @@ void MTGGuiPlay::updateCards(){
void MTGGuiPlay::AddPlayersGuiInfo(){
//init with the players objects
if (mCount == 0){
Add(NEW GuiAvatar(-1,50,2,155,false, GameObserver::GetInstance()->players[0]));
Add(NEW GuiAvatar(-2,50,2,30,false,GameObserver::GetInstance()->players[1]));
Add(NEW GuiAvatar(2,155,false, GameObserver::GetInstance()->players[0], GuiAvatar::BOTTOM_RIGHT, NULL));
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 GuiLibrary(-4,30,40,180,false, GameObserver::GetInstance()->players[0]));
Add(NEW GuiGraveyard(40,150,false, GameObserver::GetInstance()->players[0], NULL));
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 GuiLibrary(-6,30,40,60,false, GameObserver::GetInstance()->players[1]));
Add(NEW GuiGraveyard(40,30,false, GameObserver::GetInstance()->players[1], NULL));
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 PlayGuiObjectController::CheckUserInput(key);
return true; //PlayGuiObjectController::CheckUserInput(key);
}
@@ -439,7 +438,7 @@ void MTGGuiPlay::Render(){
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...
CardGui * cardg = ((CardGui *)mObjects[mCurr]);
cardg->RenderBig(-1,-1,showBigCards-1);
//cardg->RenderBig(-1,-1,showBigCards-1);
}
}
LOG("End MTGGuiPlay Render\n");

View File

@@ -53,7 +53,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card){
card->getManaCost()->doPayExtra();
ManaCost * spellCost = previousManaPool->Diff(player->getManaPool());
delete previousManaPool;
if (card->hasType("land")){
if (card->hasType("land")){
MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->stack);
Spell * spell = NEW Spell(copy);
spell->resolve();
@@ -65,9 +65,8 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card){
if (game->targetChooser){
spell = game->mLayers->stackLayer()->addSpell(card,game->targetChooser, spellCost);
game->targetChooser = NULL;
}else{
}else
spell = game->mLayers->stackLayer()->addSpell(card,NULL, spellCost);
}
MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->stack);
spell->source = copy;
}
@@ -85,10 +84,10 @@ ostream& MTGPutInPlayRule::toString(ostream& out) const
return MTGAbility::toString(out) << ")";
}
MTGPutInPlayRule * MTGPutInPlayRule::clone() const{
MTGPutInPlayRule * a = NEW MTGPutInPlayRule(*this);
a->isClone = 1;
return a;
MTGPutInPlayRule * MTGPutInPlayRule::clone() const{
MTGPutInPlayRule * a = NEW MTGPutInPlayRule(*this);
a->isClone = 1;
return a;
}
@@ -132,10 +131,10 @@ ostream& MTGAttackRule::toString(ostream& out) const
return MTGAbility::toString(out) << ")";
}
MTGAttackRule * MTGAttackRule::clone() const{
MTGAttackRule * a = NEW MTGAttackRule(*this);
a->isClone = 1;
return a;
MTGAttackRule * MTGAttackRule::clone() const{
MTGAttackRule * a = NEW MTGAttackRule(*this);
a->isClone = 1;
return a;
}
@@ -160,10 +159,10 @@ int MTGBlockRule::reactToClick(MTGCardInstance * card){
currentOpponent = game->currentPlayer->game->inPlay->getNextAttacker(currentOpponent);
#if defined (WIN32) || defined (LINUX)
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);
#endif
candefend = card->toggleDefenser(currentOpponent);
candefend = card->toggleDefenser(currentOpponent);
result = (candefend || currentOpponent == NULL);
}
return 1;
@@ -180,10 +179,10 @@ ostream& MTGBlockRule::toString(ostream& out) const
return MTGAbility::toString(out) << ")";
}
MTGBlockRule * MTGBlockRule::clone() const{
MTGBlockRule * a = NEW MTGBlockRule(*this);
a->isClone = 1;
return a;
MTGBlockRule * MTGBlockRule::clone() const{
MTGBlockRule * a = NEW MTGBlockRule(*this);
a->isClone = 1;
return a;
}
//
// Attacker chooses blockers order
@@ -201,7 +200,7 @@ MTGMomirRule::MTGMomirRule(int _id, MTGAllCards * _collection):MTGAbility(_id, N
if (!initialized){
for (size_t i = 0; i < collection->ids.size(); i++){
MTGCard * card = collection->collection[collection->ids[i]];
if (card->isACreature()){
if (card->isCreature()){
int convertedCost = card->getManaCost()->getConvertedCost();
if (convertedCost>20) continue;
pool[convertedCost].push_back(card->getMTGId());
@@ -239,7 +238,7 @@ int MTGMomirRule::reactToClick(MTGCardInstance * card_to_discard){
int MTGMomirRule::reactToClick(MTGCardInstance * card_to_discard, int cardId){
if (!isReactingToClick(card_to_discard)) return 0;
Player * player = game->currentlyActing();
ManaCost * cost = player->getManaPool();
ManaCost * cost = player->getManaPool();
player->getManaPool()->pay(cost);
MTGCardInstance * card = genCreature(cardId);
player->game->putInZone(card_to_discard, player->game->hand, player->game->graveyard);
@@ -312,10 +311,10 @@ ostream& MTGMomirRule::toString(ostream& out) const
}
MTGMomirRule * MTGMomirRule::clone() const{
MTGMomirRule * a = NEW MTGMomirRule(*this);
a->isClone = 1;
return a;
MTGMomirRule * MTGMomirRule::clone() const{
MTGMomirRule * a = NEW MTGMomirRule(*this);
a->isClone = 1;
return a;
}
//HUDDisplay
@@ -329,7 +328,7 @@ void HUDDisplay::Update(float dt){
if (events.size()){
list<HUDString *>::iterator it = events.begin();
HUDString * hs = *it;
if (popdelay > 1 && timestamp - hs->timestamp > 2){
if (popdelay > 1 && timestamp - hs->timestamp > 2){
events.pop_front();
delete hs;
if (events.size()) popdelay = 0;
@@ -372,7 +371,7 @@ int HUDDisplay::receiveEvent(WEvent * event){
return 0;
}
void HUDDisplay::Render(){
if (!GameOptions::GetInstance()->values[OPTIONS_OSD].getIntValue()) return;
if (!options[Options::OSD].number) return;
if (!events.size()) return;
f->SetColor(ARGB(255,255,255,255));
@@ -398,7 +397,7 @@ HUDDisplay::HUDDisplay(int _id):MTGAbility(_id, NULL){
f = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
maxWidth = 0;
}
HUDDisplay::~HUDDisplay(){
list<HUDString *>::iterator it;
for (it = events.begin(); it !=events.end(); ++it){
@@ -408,14 +407,14 @@ HUDDisplay::~HUDDisplay(){
events.clear();
}
HUDDisplay * HUDDisplay::clone() const{
HUDDisplay * a = NEW HUDDisplay(*this);
a->isClone = 1;
return a;
}
/* Persist */
HUDDisplay * HUDDisplay::clone() const{
HUDDisplay * a = NEW HUDDisplay(*this);
a->isClone = 1;
return a;
}
/* Persist */
MTGPersistRule::MTGPersistRule(int _id):MTGAbility(_id,NULL){};
int MTGPersistRule::receiveEvent(WEvent * event){
@@ -452,8 +451,8 @@ HUDDisplay::~HUDDisplay(){
}
int MTGPersistRule::testDestroy(){return 0;}
MTGPersistRule * MTGPersistRule::clone() const{
MTGPersistRule * a = NEW MTGPersistRule(*this);
a->isClone = 1;
MTGPersistRule * a = NEW MTGPersistRule(*this);
a->isClone = 1;
return a;
}
@@ -473,7 +472,7 @@ HUDDisplay::~HUDDisplay(){
int destroy = 0;
for ( it=cards.begin() ; it != cards.end(); it++ ){
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);
destroy = 1;
}
@@ -493,8 +492,8 @@ HUDDisplay::~HUDDisplay(){
return out << "MTGLegendRule :::";
}
MTGLegendRule * MTGLegendRule::clone() const{
MTGLegendRule * a = NEW MTGLegendRule(*this);
a->isClone = 1;
MTGLegendRule * a = NEW MTGLegendRule(*this);
a->isClone = 1;
return a;
}
@@ -522,7 +521,7 @@ HUDDisplay::~HUDDisplay(){
return MTGAbility::toString(out) << ")";
}
MTGLifelinkRule * MTGLifelinkRule::clone() const{
MTGLifelinkRule * a = NEW MTGLifelinkRule(*this);
a->isClone = 1;
MTGLifelinkRule * a = NEW MTGLifelinkRule(*this);
a->isClone = 1;
return a;
}
}

View File

@@ -9,14 +9,14 @@ OptionItem::OptionItem(string _id, string _displayValue, int _maxValue, int _inc
maxValue = _maxValue;
increment = _increment;
displayValue = _(_displayValue);
value = GameOptions::GetInstance()->values[id].getIntValue();
value = options[id].number;
hasFocus = 0;
x = 0;
y = 0;
}
void OptionItem::setData(){
GameOptions::GetInstance()->values[id] = GameOption(value);
options[id] = GameOption(value);
}
void OptionItem::Render(){
@@ -60,8 +60,6 @@ bool OptionItem::Leaving(){
}
OptionItem * options[20];
int nbitems;
OptionsList::OptionsList(){
nbitems = 0;
current = -1;
@@ -100,7 +98,7 @@ void OptionsList::save(){
for (int i = 0; i < nbitems; i++){
options[i]->setData();
}
GameOptions::GetInstance()->save();
::options.save();
}
void OptionsList::Update(float dt){

View File

@@ -1,15 +1,19 @@
#include <iostream>
#include "../include/config.h"
#include "../include/PlayGuiObject.h"
#include "../include/Player.h"
#include "../include/MTGGameZones.h"
#include "../include/CardDisplay.h"
using namespace std;
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;
mHeight = desiredHeight;
x = _x;
y = _y;
mHasFocus = hasFocus;
type = 0;
wave = 0;
@@ -32,143 +36,13 @@ void PlayGuiObject::Update(float dt){
mHeight = defaultHeight;
}
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){
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
void PlayGuiObject::Render()
{
return out << "GuiAvatar ::: avatarRed : " << avatarRed
<< " ; currentLife : " << currentLife
<< " ; 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 :::";
for (vector<Effect*>::iterator it = effects.begin(); it != effects.end(); ++it)
(*it)->Render();
}

View File

@@ -86,6 +86,7 @@ void PlayGuiObjectController::Update(float dt){
bool PlayGuiObjectController::CheckUserInput(u32 key){
/*
if (!mCount)
return false;
if (game != NULL){
@@ -148,5 +149,6 @@ bool PlayGuiObjectController::CheckUserInput(u32 key){
showBigCards = (showBigCards + 1) % 3;
return true;
}
*/
return false;
}

View File

@@ -4,10 +4,10 @@
#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;
deckFileSmall = fileSmall;
game = _deck;
game = deck;
game->setOwner(this);
manaPool = NEW ManaCost();
canPutLandsIntoPlay = 1;
@@ -26,7 +26,7 @@ Player::~Player(){
if (mAvatar) delete mAvatar;
}
const char * Player::getDisplayName(){
const string Player::getDisplayName(){
GameObserver * g = GameObserver::GetInstance();
if (this == g->players[0]) return "Player 1";
return "Player 2";
@@ -57,7 +57,7 @@ Player * Player::opponent(){
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);
if (mAvatarTex)
mAvatar = NEW JQuad(mAvatarTex, 0, 0, 35, 50);

View File

@@ -1,76 +1,76 @@
#include "../include/config.h"
#include "../include/ReplacementEffects.h"
#include "../include/MTGCardInstance.h"
#include "../include/TargetChooser.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){
}
WEvent * REDamagePrevention::replace (WEvent *event){
if (!event) return event;
if (!damage) return event;
WEventDamage * e = dynamic_cast<WEventDamage*>(event);
if (!e) return event;
Damage *d = e->damage;
if ((!tcSource || tcSource->canTarget(d->source)) &&
(!tcTarget || tcTarget->canTarget(d->target))
){
if (damage == -1){
d->damage = 0;
delete event;
if (oneShot) damage = 0;
return NULL;
}
if (damage >= d->damage){
damage-= d->damage;
d->damage = 0;
delete event;
return NULL;
}
d->damage -= damage;
damage = 0;
delete event;
WEventDamage* newEvent = NEW WEventDamage(d);
return newEvent;
}
return event;
}
REDamagePrevention::~REDamagePrevention(){
SAFE_DELETE(tcSource);
SAFE_DELETE(tcTarget);
}
ReplacementEffects::ReplacementEffects(){}
WEvent * ReplacementEffects::replace(WEvent *e){
list<ReplacementEffect *>::iterator it;
for ( it=modifiers.begin() ; it != modifiers.end(); it++ ){
ReplacementEffect *re = *it;
WEvent * newEvent = re->replace(e);
if (!newEvent) return NULL;
if (newEvent != e) return replace(newEvent);
}
return e;
}
int ReplacementEffects::add(ReplacementEffect * re){
modifiers.push_back(re);
return 1;
}
int ReplacementEffects::remove (ReplacementEffect *re){
modifiers.remove(re);
return 1;
}
ReplacementEffects::~ReplacementEffects(){
list<ReplacementEffect *>::iterator it;
for ( it=modifiers.begin() ; it != modifiers.end(); it++ ){
ReplacementEffect *re = *it;
delete(re);
}
modifiers.clear();
}
#include "../include/config.h"
#include "../include/ReplacementEffects.h"
#include "../include/MTGCardInstance.h"
#include "../include/TargetChooser.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){
}
WEvent * REDamagePrevention::replace (WEvent *event){
if (!event) return event;
if (!damage) return event;
WEventDamage * e = dynamic_cast<WEventDamage*>(event);
if (!e) return event;
Damage *d = e->damage;
if ((!tcSource || tcSource->canTarget(d->source)) &&
(!tcTarget || tcTarget->canTarget(d->target))
){
if (damage == -1){
d->damage = 0;
delete event;
if (oneShot) damage = 0;
return NULL;
}
if (damage >= d->damage){
damage-= d->damage;
d->damage = 0;
delete event;
return NULL;
}
d->damage -= damage;
damage = 0;
delete event;
WEventDamage* newEvent = NEW WEventDamage(d);
return newEvent;
}
return event;
}
REDamagePrevention::~REDamagePrevention(){
SAFE_DELETE(tcSource);
SAFE_DELETE(tcTarget);
}
ReplacementEffects::ReplacementEffects(){}
WEvent * ReplacementEffects::replace(WEvent *e){
list<ReplacementEffect *>::iterator it;
for ( it=modifiers.begin() ; it != modifiers.end(); it++ ){
ReplacementEffect *re = *it;
WEvent * newEvent = re->replace(e);
if (!newEvent) return NULL;
if (newEvent != e) return replace(newEvent);
}
return e;
}
int ReplacementEffects::add(ReplacementEffect * re){
modifiers.push_back(re);
return 1;
}
int ReplacementEffects::remove (ReplacementEffect *re){
modifiers.remove(re);
return 1;
}
ReplacementEffects::~ReplacementEffects(){
list<ReplacementEffect *>::iterator it;
for ( it=modifiers.begin() ; it != modifiers.end(); it++ ){
ReplacementEffect *re = *it;
delete(re);
}
modifiers.clear();
}

View File

@@ -2,21 +2,21 @@
#include "../include/ShopItem.h"
#include "../include/GameStateShop.h"
#include "../include/CardGui.h"
#include "../include/TexturesCache.h"
#include "../include/Translate.h"
#include <hge/hgedistort.h>
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::_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::_x2[] = { 44, 25, 64,128,171,211,121,165,209,143,200};
float ShopItems::_y2[] = {147,163,190,166,166,162,184,185,180,211,208};
float ShopItems::_x3[] = { 86, 47, 12, 85,133,177, 73,120,170, 88,153};
float ShopItems::_y3[] = {152,177,216,181,180,176,203,204,198,237,232};
float ShopItems::_x4[] = { 86, 66, 58,118,164,207,108,156,205,130,199};
float ShopItems::_x2[] = { 44, 25, 64,128,171,211,121,165,209,143,200};
float ShopItems::_y2[] = {147,163,190,166,166,162,184,185,180,211,208};
float ShopItems::_x3[] = { 86, 47, 12, 85,133,177, 73,120,170, 88,153};
float ShopItems::_y3[] = {152,177,216,181,180,176,203,204,198,237,232};
float ShopItems::_x4[] = { 86, 66, 58,118,164,207,108,156,205,130,199};
float ShopItems::_y4[] = {145,167,211,181,180,176,203,204,198,237,232};
ShopItem::ShopItem(int id, JLBFont *font, char* text, JQuad * _quad,JQuad * _thumb, float _xy[], bool hasFocus, int _price): JGuiObject(id), mFont(font), mText(text), quad(_quad), thumb(_thumb), price(_price)
@@ -31,16 +31,16 @@ ShopItem::ShopItem(int id, JLBFont *font, char* text, JQuad * _quad,JQuad * _thu
mScale = 1.0f;
mTargetScale = 1.0f;
mesh=NEW hgeDistortionMesh(2,2);
mesh->SetTexture(thumb->mTex);
float x0,y0,w0,h0;
thumb->GetTextureRect(&x0,&y0,&w0,&h0);
mesh->SetTextureRect(x0,y0,w0,h0);
mesh->Clear(ARGB(0xFF,0xFF,0xFF,0xFF));
mesh->SetDisplacement(0, 0, xy[0],xy[1], HGEDISP_NODE);
mesh->SetDisplacement(1, 0, xy[2] - w0,xy[3], HGEDISP_NODE);
mesh->SetDisplacement(0, 1,xy[4],xy[5]-h0, HGEDISP_NODE);
mesh->SetDisplacement(1, 1, xy[6]-w0,xy[7]-h0, HGEDISP_NODE);
mesh=NEW hgeDistortionMesh(2,2);
mesh->SetTexture(thumb->mTex);
float x0,y0,w0,h0;
thumb->GetTextureRect(&x0,&y0,&w0,&h0);
mesh->SetTextureRect(x0,y0,w0,h0);
mesh->Clear(ARGB(0xFF,0xFF,0xFF,0xFF));
mesh->SetDisplacement(0, 0, xy[0],xy[1], HGEDISP_NODE);
mesh->SetDisplacement(1, 0, xy[2] - w0,xy[3], HGEDISP_NODE);
mesh->SetDisplacement(0, 1,xy[4],xy[5]-h0, HGEDISP_NODE);
mesh->SetDisplacement(1, 1, xy[6]-w0,xy[7]-h0, HGEDISP_NODE);
mesh->SetColor(1,1,ARGB(255,100,100,100));
mesh->SetColor(0,1,ARGB(255,100,100,100));
mesh->SetColor(1,0,ARGB(255,100,100,100));
@@ -66,19 +66,20 @@ ShopItem::ShopItem(int id, JLBFont *font, int _cardid, float _xy[], bool hasFocu
quantity = 1 + (rand() % 4);
if (card->getRarity() == Constants::RARITY_L) quantity = 50;
quad = NULL;
thumb = card->getThumb();
if (!thumb) thumb = GameApp::CommonRes->GetQuad("back_thumb");
// thumb = card->getThumb();
// if (!thumb)
thumb = GameApp::CommonRes->GetQuad("back_thumb");
if (thumb){
mesh=NEW hgeDistortionMesh(2,2);
mesh->SetTexture(thumb->mTex);
float x0,y0,w0,h0;
thumb->GetTextureRect(&x0,&y0,&w0,&h0);
mesh->SetTextureRect(x0,y0,w0,h0);
mesh->Clear(ARGB(0xFF,0xFF,0xFF,0xFF));
mesh->SetDisplacement(0, 0, xy[0],xy[1], HGEDISP_NODE);
mesh->SetDisplacement(1, 0, xy[2] - w0,xy[3], HGEDISP_NODE);
mesh->SetDisplacement(0, 1,xy[4],xy[5]-h0, HGEDISP_NODE);
mesh->SetDisplacement(1, 1, xy[6]-w0,xy[7]-h0, HGEDISP_NODE);
mesh=NEW hgeDistortionMesh(2,2);
mesh->SetTexture(thumb->mTex);
float x0,y0,w0,h0;
thumb->GetTextureRect(&x0,&y0,&w0,&h0);
mesh->SetTextureRect(x0,y0,w0,h0);
mesh->Clear(ARGB(0xFF,0xFF,0xFF,0xFF));
mesh->SetDisplacement(0, 0, xy[0],xy[1], HGEDISP_NODE);
mesh->SetDisplacement(1, 0, xy[2] - w0,xy[3], HGEDISP_NODE);
mesh->SetDisplacement(0, 1,xy[4],xy[5]-h0, HGEDISP_NODE);
mesh->SetDisplacement(1, 1, xy[6]-w0,xy[7]-h0, HGEDISP_NODE);
mesh->SetColor(1,1,ARGB(255,100,100,100));
mesh->SetColor(0,1,ARGB(255,100,100,100));
mesh->SetColor(1,0,ARGB(255,100,100,100));
@@ -114,9 +115,8 @@ void ShopItem::Render(){
if (!quantity){
mFont->SetColor(ARGB(255,128,128,128));
}
if (card){
if (card){
if (nameCount){
char buffer[512];
sprintf(buffer, "%s (%i)", _(card->name).c_str(), nameCount );
@@ -136,7 +136,7 @@ void ShopItem::Render(){
renderer->FillPolygon(xs,ys,4,ARGB(200,0,0,0));
x0 = mX + 230 -30;
mFont->DrawString(mText.c_str(), x0, mY + 8,JGETEXT_RIGHT);
}else{
float xs[] = {mX-5, mX-5, mX-5+230,mX-5+230,};
float ys[] = {mY-5,mY-5+35,mY-5+17,mY-5+19} ;
@@ -153,14 +153,12 @@ void ShopItem::Render(){
//NOTHING
}
if (mHasFocus){
if (card){
quad = card->getQuad();
}
if (card) quad = cache.getQuad(card);
if (quad){
quad->SetColor(ARGB(255,255,255,255));
renderer->RenderQuad(quad,SCREEN_WIDTH/2 + 50,5,0, 0.9f,0.9f);
}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);
}
@@ -336,7 +334,7 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){
tempDeck->addRandomCards(1, sets,1,rare_or_mythic);
tempDeck->addRandomCards(3, sets,1,Constants::RARITY_U);
tempDeck->addRandomCards(11, sets,1,Constants::RARITY_C);
playerdata->collection->add(tempDeck);
myCollection->Add(tempDeck);
@@ -344,7 +342,7 @@ void ShopItems::ButtonPressed(int controllerId, int controlId){
ShopItem * si = ((ShopItem *)mObjects[j]);
si->updateCount(myCollection);
}
int i = 0;
for (map<int,int>::iterator it = tempDeck->cards.begin(); it!=tempDeck->cards.end(); it++){
MTGCard * c = tempDeck->getCardById(it->first);

View File

@@ -41,7 +41,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
s2 = "";
}
zones[nbzones] = MTGGameZone::MY_BATTLEFIELD;
//Graveyards
if(zoneName.compare("graveyard") == 0){
zones[nbzones] = MTGGameZone::MY_GRAVEYARD;
@@ -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
// 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){
MTGCardInstance * card = (MTGCardInstance *) target;
if (targetter && card->isInPlay() && (card->has(Constants::SHROUD)|| card->protectedAgainst(targetter) )) return 0;
if (source && targetter && card->isInPlay() && (source->controller() != card->controller()) && (card->has(Constants::OPPONENTSHROUD)|| card->protectedAgainst(targetter) )) return 0;
return 1;
}else if (target->typeAsTarget() == TARGET_STACKACTION){
return 1;
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 false;
return true;
}
return 0;
else if (target->typeAsTarget() == TARGET_STACKACTION)
return true;
return false;
}
@@ -340,17 +340,17 @@ CardTargetChooser::CardTargetChooser(MTGCardInstance * _card, MTGCardInstance *
validTarget = _card;
}
int CardTargetChooser::canTarget(Targetable * target ){
if (!target) return 0;
if (target->typeAsTarget() != TARGET_CARD) return 0;
if (!nbzones && !TargetChooser::canTarget(target)) return 0;
if (nbzones && !TargetZoneChooser::canTarget(target)) return 0;
bool CardTargetChooser::canTarget(Targetable * target ){
if (!target) return false;
if (target->typeAsTarget() != TARGET_CARD) return false;
if (!nbzones && !TargetChooser::canTarget(target)) return false;
if (nbzones && !TargetZoneChooser::canTarget(target)) return false;
MTGCardInstance * card = (MTGCardInstance *) target;
while(card){
if(card == validTarget) return 1;
while (card) {
if (card == validTarget) return true;
card = card->previous;
}
return 0;
return false;
}
/**
@@ -386,28 +386,28 @@ void TypeTargetChooser::addType(int type){
nbtypes++;
}
int TypeTargetChooser::canTarget(Targetable * target ){
if (!TargetZoneChooser::canTarget(target)) return 0;
bool TypeTargetChooser::canTarget(Targetable * target){
if (!TargetZoneChooser::canTarget(target)) return false;
if (target->typeAsTarget() == TARGET_CARD){
MTGCardInstance * card = (MTGCardInstance *) target;
for (int i= 0; i < nbtypes; i++){
if (card->hasSubtype(types[i])) return 1;
if (Subtypes::subtypesList->find(card->name) == types[i]) return 1;
if (card->hasSubtype(types[i])) return true;
if (Subtypes::subtypesList->find(card->name) == types[i]) return true;
}
return 0;
return false;
}else if (target->typeAsTarget() == TARGET_STACKACTION){
Interruptible * action = (Interruptible *) target;
if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){
Spell * spell = (Spell *) action;
MTGCardInstance * card = spell->source;
for (int i= 0; i < nbtypes; i++){
if (card->hasSubtype(types[i])) return 1;
if (Subtypes::subtypesList->find(card->name) == types[i]) return 1;
if (card->hasSubtype(types[i])) return true;
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;
}
int DescriptorTargetChooser::canTarget(Targetable * target){
if (!TargetZoneChooser::canTarget(target)) return 0;
bool DescriptorTargetChooser::canTarget(Targetable * target){
if (!TargetZoneChooser::canTarget(target)) return false;
if (target->typeAsTarget() == TARGET_CARD){
MTGCardInstance * _target = (MTGCardInstance *) target;
if (cd->match(_target)) return 1;
if (cd->match(_target)) return true;
}else if (target->typeAsTarget() == TARGET_STACKACTION){
Interruptible * action = (Interruptible *) target;
if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){
Spell * spell = (Spell *) action;
MTGCardInstance * card = spell->source;
if (cd->match(card)) return 1;
if (cd->match(card)) return true;
}
}
return 0;
return false;
}
DescriptorTargetChooser::~DescriptorTargetChooser(){
@@ -473,15 +473,15 @@ CreatureTargetChooser::CreatureTargetChooser(int * _zones, int nbzones, MTGCardI
}
int CreatureTargetChooser::canTarget(Targetable * target){
if (!TargetZoneChooser::canTarget(target)) return 0;
bool CreatureTargetChooser::canTarget(Targetable * target){
if (!TargetZoneChooser::canTarget(target)) return false;
if (target->typeAsTarget() == TARGET_CARD){
MTGCardInstance * card = (MTGCardInstance *) target;
if (maxpower != -1 && card->power > maxpower) return 0;
if (maxtoughness != -1 && card->toughness > maxtoughness) return 0;
return card->isACreature();
if (maxpower != -1 && card->power > maxpower) return false;
if (maxtoughness != -1 && card->toughness > maxtoughness) return false;
return card->isCreature();
}
return 0;
return false;
}
@@ -502,57 +502,47 @@ int TargetZoneChooser::init(int * _zones, int _nbzones){
return nbzones;
}
int TargetZoneChooser::canTarget(Targetable * target){
if (!TargetChooser::canTarget(target)) return 0;
bool TargetZoneChooser::canTarget(Targetable * target){
if (!TargetChooser::canTarget(target)) return false;
if (target->typeAsTarget() == TARGET_CARD){
MTGCardInstance * card = (MTGCardInstance *) target;
for (int i = 0; i<nbzones; i++){
if (MTGGameZone::intToZone(zones[i],source,card)->hasCard(card)) return 1;
}
for (int i = 0; i<nbzones; i++)
if (MTGGameZone::intToZone(zones[i],source,card)->hasCard(card)) return true;
}else if (target->typeAsTarget() == TARGET_STACKACTION){
OutputDebugString ("CHECKING INTERRUPTIBLE\n");
Interruptible * action = (Interruptible *) target;
if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){
Spell * spell = (Spell *) action;
MTGCardInstance * card = spell->source;
for (int i = 0; i<nbzones; i++){
if (MTGGameZone::intToZone(zones[i],source,card)->hasCard(card)) return 1;
}
for (int i = 0; i<nbzones; i++)
if (MTGGameZone::intToZone(zones[i],source,card)->hasCard(card)) return true;
}
}
return 0;
return false;
}
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;
}
return 0;
}
/* 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){
if (target->typeAsTarget() == TARGET_PLAYER){
Player * _target = (Player *) target;
if (!p || p == _target) return 1;
}
return 0;
bool PlayerTargetChooser::canTarget(Targetable * target){
return (target->typeAsTarget() == TARGET_PLAYER) && (!p || p == (Player*)target);
}
/*Damageable Target */
int DamageableTargetChooser::canTarget(Targetable * target){
bool DamageableTargetChooser::canTarget(Targetable * target){
if (target->typeAsTarget() == TARGET_PLAYER){
#if defined (WIN32) || defined (LINUX)
OutputDebugString("Targetting Player !!!\n");
#endif
return 1;
return true;
}
return CreatureTargetChooser::canTarget(target);
}
@@ -566,19 +556,18 @@ SpellTargetChooser::SpellTargetChooser(MTGCardInstance * card,int _color, int _m
color = _color;
}
int SpellTargetChooser::canTarget(Targetable * target){
bool SpellTargetChooser::canTarget(Targetable * target){
MTGCardInstance * card = NULL;
if (target->typeAsTarget() == TARGET_STACKACTION){
Interruptible * action = (Interruptible *) target;
if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){
Spell * spell = (Spell *) action;
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;
}
int SpellOrPermanentTargetChooser::canTarget(Targetable * target){
bool SpellOrPermanentTargetChooser::canTarget(Targetable * target){
MTGCardInstance * card = NULL;
if (target->typeAsTarget() == TARGET_CARD){
card = (MTGCardInstance *) target;
@@ -599,12 +588,10 @@ int SpellOrPermanentTargetChooser::canTarget(Targetable * target){
if (action->type == ACTION_SPELL && action->state==NOT_RESOLVED){
Spell * spell = (Spell *) action;
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;
}
@@ -615,19 +602,17 @@ DamageTargetChooser::DamageTargetChooser(MTGCardInstance * card,int _color, int
state = _state;
}
int DamageTargetChooser::canTarget(Targetable * target){
bool DamageTargetChooser::canTarget(Targetable * target){
MTGCardInstance * card = NULL;
if (target->typeAsTarget() == TARGET_STACKACTION){
Interruptible * action = (Interruptible *) target;
if (action->type == ACTION_DAMAGE && (action->state == state || state == -1)){
Damage * damage = (Damage *) action;
card = damage->source;
if (card && (color == -1 || card->hasColor(color))) return 1;
if (card && (color == -1 || card->hasColor(color))) return true;
}
}
return 0;
return false;
}
@@ -638,7 +623,7 @@ DamageOrPermanentTargetChooser::DamageOrPermanentTargetChooser(MTGCardInstance *
color = _color;
}
int DamageOrPermanentTargetChooser::canTarget(Targetable * target){
bool DamageOrPermanentTargetChooser::canTarget(Targetable * target){
MTGCardInstance * card = NULL;
if (target->typeAsTarget() == TARGET_CARD){
card = (MTGCardInstance *) target;
@@ -648,10 +633,8 @@ int DamageOrPermanentTargetChooser::canTarget(Targetable * target){
if (action->type == ACTION_DAMAGE){
Damage * damage = (Damage *) action;
card = damage->source;
if (card && (color == -1 || card->hasColor(color))) return 1;
if (card && (color == -1 || card->hasColor(color))) return true;
}
}
return 0;
return false;
}

View File

@@ -64,7 +64,7 @@ int TestSuiteAI::Act(float dt){
string action = suite->getNextAction();
g->mLayers->stackLayer()->Dump();
DamageResolverLayer * drl = g->mLayers->combatLayer();
// DamageResolverLayer * drl = g->mLayers->combatLayer();
OutputDebugString(action.c_str());
OutputDebugString("\n");
@@ -90,6 +90,7 @@ int TestSuiteAI::Act(float dt){
g->userRequestNextGamePhase();
}
else if (action.compare("next")==0){
/*
if (drl->orderingIsNeeded){
drl->blockersOrderingDone();
g->userRequestNextGamePhase();
@@ -100,6 +101,7 @@ int TestSuiteAI::Act(float dt){
}else{
g->userRequestNextGamePhase();
}
*/
}else if (action.compare("yes")==0){
g->mLayers->stackLayer()->setIsInterrupting(this);
}else if (action.compare("endinterruption")==0){
@@ -121,7 +123,7 @@ int TestSuiteAI::Act(float dt){
g->mLayers->actionLayer()->stuffHappened = 1;
}else if(action.find("p1")!=string::npos || action.find("p2")!=string::npos){
Player * p = g->players[1];
int start = action.find("p1");
unsigned int start = action.find("p1");
if (start != string::npos) p = g->players[0];
g->cardClick(NULL, p);
}else{
@@ -138,6 +140,7 @@ int TestSuiteAI::Act(float dt){
if (card) {
OutputDebugString("Clicking ON: ");
OutputDebugString(card->name.c_str());
/*
if (drl->mCount){
if (drl->orderingIsNeeded){
OutputDebugString(" Ordering Card\n");
@@ -149,6 +152,7 @@ int TestSuiteAI::Act(float dt){
}else{
g->cardClick(card,card);
}
*/
}
}
}else{
@@ -281,12 +285,12 @@ void TestSuite::initGame(){
for (int k = 0; k < initState.playerData[i].zones[j].nbitems; k++){
MTGCardInstance * card = getCardByMTGId(initState.playerData[i].zones[j].cards[k]);
char buf[4096];
sprintf(buf, "QUAD : %p\n", card->getQuad());
sprintf(buf, "QUAD : %p\n", cache.getQuad(card));
OutputDebugString(buf);
if (card && zone != p->game->library){
if (zone == p->game->inPlay){
MTGCardInstance * copy = p->game->putInZone(card, p->game->library, p->game->stack);
Spell * spell = NEW Spell(copy);
Spell * spell = NEW Spell(copy);
spell->resolve();
if (!summoningSickness && p->game->inPlay->nb_cards>k) p->game->inPlay->cards[k]->summoningSickness = 0;
delete spell;
@@ -418,7 +422,7 @@ int TestSuite::loadNext(){
if (currentfile >= nbfiles) return 0;
currentfile++;
if (!load(files[currentfile-1].c_str())) return loadNext();
//load(files[currentfile].c_str());
//currentfile++;
return currentfile;
@@ -482,7 +486,7 @@ int TestSuite::load(const char * _filename){
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){
cleanup();
while(std::getline(file,s)){

View File

@@ -3,16 +3,15 @@
#include "../include/GameOptions.h"
#include <JFileSystem.h>
TexturesCache cache;
TexturesCache::TexturesCache(){
nb_textures = 0;
totalsize = 0;
delete_previous = 0;
lastTime = 0;
for (int i=0; i<MAX_CACHE_OBJECTS;i++){
for (int i=0; i<MAX_CACHE_OBJECTS;i++)
cache[i] = NULL;
}
maxSize = GameOptions::GetInstance()->values[OPTIONS_CACHESIZE].getIntValue() * 100000;
if (!maxSize) maxSize = CACHE_SIZE_PIXELS;
#ifdef WIN32
char buf [4096];
sprintf(buf, " Init TextureCache : %p\n", this);
@@ -65,6 +64,8 @@ void TexturesCache::removeQuad(int id){
}
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){
int i = getOldestQuad();
if (i == -1) return 0;
@@ -76,7 +77,7 @@ int TexturesCache::cleanup(){
JQuad * TexturesCache::getQuad(MTGCard * card, int type){
int cache_id = getCacheById(card->getId(), type);
if (cache_id == -1){
//Not found in the cache, we have to load the file and put it in the cache
if (cleanup()){
cache_id = nb_textures;
@@ -126,6 +127,7 @@ CardTexture::CardTexture(MTGCard * card, int _type): type(_type){
}
if (tex){
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;
}
mtgid = card->getId();
@@ -200,4 +202,4 @@ SampleCache::~SampleCache(){
void SampleCache::DestroyInstance(){
SAFE_DELETE(mInstance);
}
}

View File

@@ -1,21 +1,19 @@
#include "../include/Token.h"
Token::Token(string _name, MTGCardInstance * source, int _power, int _toughness):MTGCardInstance(){
isToken = true;
tokenSource = source;
power = _power;
toughness = _toughness;
life=toughness;
lifeOrig = life;
name = _name;
setMTGId(- source->getMTGId());
setId = source->setId;
#include "../include/Token.h"
Token::Token(string _name, MTGCardInstance * source, int _power, int _toughness):MTGCardInstance(){
isToken = true;
tokenSource = source;
power = _power;
toughness = _toughness;
life=toughness;
lifeOrig = life;
name = _name;
setMTGId(- source->getMTGId());
setId = source->setId;
model = this;
owner = source->owner;
belongs_to=source->controller()->game;
attacker = 0;
defenser = NULL;
banding = NULL;
mCache = source->mCache;
}
}

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