- It is now possible to have avatars associated to each Deck
- Added SFX
- Added Music files
- Possibility to choose your opponent
- Opponents' difficulty is measured according to their number of victories against a given deck
This commit is contained in:
wagic.the.homebrew
2008-11-24 09:24:47 +00:00
parent a9e70c0bdc
commit 3721247bee
69 changed files with 734 additions and 259 deletions
+4 -3
View File
@@ -29,7 +29,8 @@ class AIPlayer: public Player{
int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0);
AIStats * getStats();
public:
virtual int displayStack(){return 0;}
void End(){};
virtual int displayStack(){return 0;};
AIStats * stats;
ManaCost * getPotentialMana();
AIPlayer(MTGPlayerCards * _deck, string deckFile);
@@ -48,14 +49,14 @@ class AIPlayerBaka: public AIPlayer{
int timer;
MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type);
public:
AIPlayerBaka(MTGPlayerCards * _deck, char * deckFile);
AIPlayerBaka(MTGPlayerCards * _deck, char * deckFile, char * avatarFile);
virtual int Act(float dt);
void initTimer();
};
class AIPlayerFactory{
public:
AIPlayer * createAIPlayer(MTGAllCards * collection, MTGPlayerCards * oponents_deck);
AIPlayer * createAIPlayer(MTGAllCards * collection, MTGPlayerCards * oponents_deck, int deckid = 0);
};
+6
View File
@@ -8,6 +8,7 @@
#include "CardDisplay.h"
#include "Subtypes.h"
#include "CardGui.h"
#include "GameOptions.h"
#include <JGui.h>
#include <hge/hgeparticle.h>
@@ -570,6 +571,11 @@ class AManaProducer: public MTGAbility{
y0 = cardg->y + 20;
}
controller = source->controller();
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME] > 0){
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/mana.wav");
if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
}
return 1;
}
+1 -1
View File
@@ -21,7 +21,7 @@ class CardGui: public PlayGuiObject{
virtual void Render();
virtual void Update(float dt);
void RenderBig(float x=-1, float y = -1);
void RenderBig(float x=-1, float y = -1, int alternate = 0);
static void alternateRender(MTGCard * card, JLBFont * mFont, JQuad ** manaIcons, float x, float y, float rotation= 0, float scale=1);
~CardGui();
};
+36
View File
@@ -0,0 +1,36 @@
#ifndef _DECKSTATS_H_
#define _DECKSTATS_H_
#include <map>
#include <string>
using namespace std;
class Player;
class GameObserver;
class DeckStat{
public:
int nbgames;
int victories;
DeckStat(int _nbgames = 0 , int _victories = 0):nbgames(_nbgames),victories(_victories){};
int percentVictories();
};
class DeckStats{
protected:
static DeckStats * mInstance;
public:
map<string, DeckStat *>stats;
static DeckStats * GetInstance();
void saveStats(Player * player, Player * opponent, GameObserver * game);
void save(const char * filename);
void save(Player * player);
void load(const char * filename);
void load(Player * player);
void cleanStats();
~DeckStats();
int percentVictories(string opponentsDeckFile);
};
#endif
+2 -1
View File
@@ -4,7 +4,8 @@
#define MAX_OPTIONS 50
#define OPTIONS_MUSICVOLUME 0
#define OPTIONS_INTERRUPTATENDOFPHASE_OFFSET 1
#define OPTIONS_SFXVOLUME 1
#define OPTIONS_INTERRUPTATENDOFPHASE_OFFSET 2
#define OPTIONS_SAVEFILE "Res/settings/options.txt"
class GameOptions {
public:
+1 -1
View File
@@ -202,7 +202,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
}
GameApp::music = JSoundSystem::GetInstance()->LoadMusic("sound/track1.mp3");
if (GameApp::music){
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
JSoundSystem::GetInstance()->PlayMusic(GameApp::music, true);
}
}
colorFilter = ALL_COLORS;
+5 -2
View File
@@ -14,6 +14,7 @@
#define ERROR_NO_DECK 4
#define DUEL_PLAY 5
#define DUEL_MENU 6
#define CHOOSE_OPPONENT 7
#ifdef TESTSUITE
@@ -32,10 +33,12 @@ class GameStateDuel: public GameState, public JGuiListener
MTGPlayerCards * deck[2];
GameObserver * game;
SimpleMenu * deckmenu;
SimpleMenu * opponentMenu;
SimpleMenu * menu;
JLBFont* mFont;
JLBFont* mFont, *opponentMenuFont;
int nbAIDecks;
void loadPlayer(int playerId, int decknb = 0);
void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
public:
GameStateDuel(GameApp* parent);
virtual ~GameStateDuel();
+10 -3
View File
@@ -134,9 +134,11 @@ class GameStateMenu: public GameState, public JGuiListener
virtual void Destroy()
{
if (mGuiController)
delete mGuiController;
if (subMenuController)
delete subMenuController;
@@ -147,8 +149,10 @@ class GameStateMenu: public GameState, public JGuiListener
delete mIcons[i];
}
if (mBg) delete mBg;
if (mMovingW) delete mMovingW;
SAFE_DELETE(mBg);
SAFE_DELETE(mMovingW);
SAFE_DELETE(movingWTexture);
SAFE_DELETE(bgTexture);
//SAFE_DELETE (bgMusic);
}
@@ -265,15 +269,18 @@ class GameStateMenu: public GameState, public JGuiListener
if( subMenuController != NULL){
subMenuController->Update(dt);
}else{
subMenuController = NEW SimpleMenu(102, this,mFont, 50,170,SCREEN_WIDTH-120);
if (subMenuController){
subMenuController->Add(11,"1 Player");
subMenuController->Add(11,"1 Player");
subMenuController->Add(12, "2 Players");
subMenuController->Add(13,"Demo");
subMenuController->Add(14, "Cancel");
#ifdef TESTSUITE
subMenuController->Add(666, "Test Suite");
#endif
}
}
}
+2
View File
@@ -13,6 +13,8 @@ class SimpleMenu;
class GameStateOptions: public GameState, public JGuiListener
{
private:
float timer;
public:
SimpleMenu * optionsMenu;
+1 -2
View File
@@ -3,7 +3,6 @@
#ifdef DOLOG
#define LOG(x) Logger::Log(x);
#else
@@ -14,7 +13,7 @@
class Logger{
public:
static void Log(char * text);
static void Log(const char * text);
};
#endif
+2 -1
View File
@@ -27,7 +27,7 @@ class MTGCardInstance: public MTGCard, public Damageable, public Targetable {
protected:
int untapping;
int nb_damages;
string sample;
int lifeOrig;
Blockers * blockers;
@@ -94,6 +94,7 @@ class MTGCardInstance: public MTGCard, public Damageable, public Targetable {
void tap();
int isInPlay();
void resetAllDamage();
JSample * getSample();
};
@@ -1,18 +1,20 @@
#ifndef _PLAYGUIOBJECTCONTROLLER_H_
#define _PLAYGUIOBJECTCONTROLLER_H_
#define BIG_CARD_RENDER_TIME 0.4
#include "GuiLayers.h"
class PlayGuiObjectController : public GuiLayer{
protected:
float last_user_move;
int getClosestItem(int direction);
int getClosestItem(int direction, float tolerance);
static bool showBigCards;
static int showBigCards;// 0 hide, 1 show, 2 show text
public:
virtual void Update(float dt);
virtual void CheckUserInput(float dt);
PlayGuiObjectController(int id, GameObserver* _game):GuiLayer(id, _game){};
PlayGuiObjectController(int id, GameObserver* _game):GuiLayer(id, _game){last_user_move=0;};
virtual void Render(){GuiLayer::Render();};
};
+1
View File
@@ -15,6 +15,7 @@ class Player: public Damageable, public Targetable{
ManaCost * manaPool;
public:
virtual void End();
int typeAsTarget(){return TARGET_PLAYER;}
virtual int displayStack(){return 1;}
JTexture * mAvatarTex;
+3 -1
View File
@@ -14,9 +14,11 @@ class SimpleMenu:public JGuiController{
JLBFont* mFont;
std::string title;
int displaytitle;
int maxItems,startId;
public:
SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, int width, const char * _title = NULL);
SimpleMenu(int id, JGuiListener* listener, JLBFont* font, int x, int y, int width, const char * _title = NULL, int _maxItems = 10);
void Render();
void Update(float dt);
void Add(int id, const char * Text);
};
+2 -1
View File
@@ -13,7 +13,7 @@ class SimpleMenuItem: public JGuiObject
private:
bool mHasFocus;
JLBFont *mFont;
const char* mText;
string mText;
int mX;
int mY;
@@ -25,6 +25,7 @@ class SimpleMenuItem: public JGuiObject
public:
SimpleMenuItem(int id, JLBFont *font, const char* text, int x, int y, bool hasFocus = false);
void RenderWithOffset(float yOffset);
virtual void Render();
virtual void Update(float dt);
+1
View File
@@ -19,6 +19,7 @@ class Subtypes{
int find(const char * subtype);
int Add(string subtype);
int find(string subtype);
string find(int id);
};
+15
View File
@@ -10,6 +10,9 @@
#include <JGE.h>
#include <JTypes.h>
#include <map>
using std::map;
#include "MTGDeck.h"
@@ -55,4 +58,16 @@ class TexturesCache{
};
class SampleCache{
protected:
map<string, JSample *> cache;
static SampleCache * mInstance;
void cleanCache();
~SampleCache();
public:
static SampleCache * GetInstance();
JSample * getSample(string filename);
};
#endif
+1 -1
View File
@@ -46,5 +46,5 @@ int filesize(const char * filename);
int read_file (const char * filename, char * buffer, int filesize);
int readline (char * in_buffer, char * out_buffer, int cursor);
int readfile_to_ints(const char * filename, int * out_buffer);
int fileExists(const char * filename);
#endif