Erwan
- Added new bonus system for victories. Unlock and bonuses need to be tested :/
This commit is contained in:
@@ -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/ConstraintResolver.o objs/Counters.o objs/Damage.o objs/DamagerDamaged.o objs/DamageResolverLayer.o objs/DeckDataWrapper.o objs/DeckStats.o objs/DuelLayers.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiCardsController.o objs/GuiLayers.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/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TexturesCache.o objs/Token.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/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/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiCardsController.o objs/GuiLayers.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/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TexturesCache.o objs/Token.o objs/utils.o objs/WEvent.o
|
||||||
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
|
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
|
||||||
|
|
||||||
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
|
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)
|
||||||
|
|||||||
42
projects/mtg/include/Credits.h
Normal file
42
projects/mtg/include/Credits.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#ifndef _CREDITS_H_
|
||||||
|
#define _CREDITS_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <JGE.h>
|
||||||
|
#include <JLBFont.h>
|
||||||
|
#include "../include/Player.h"
|
||||||
|
class GameApp;
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
|
class CreditBonus{
|
||||||
|
public:
|
||||||
|
int value;
|
||||||
|
string text;
|
||||||
|
CreditBonus(int _value, string _text);
|
||||||
|
void Render(float x, float y, JLBFont * font);
|
||||||
|
};
|
||||||
|
|
||||||
|
class Credits{
|
||||||
|
private:
|
||||||
|
int isDifficultyUnlocked();
|
||||||
|
int isMomirUnlocked();
|
||||||
|
public:
|
||||||
|
int value;
|
||||||
|
Player * p1, *p2;
|
||||||
|
GameApp * app;
|
||||||
|
int showMsg;
|
||||||
|
int unlocked;
|
||||||
|
JQuad * unlockedQuad;
|
||||||
|
JTexture * unlockedTex;
|
||||||
|
vector<CreditBonus *> bonus;
|
||||||
|
Credits();
|
||||||
|
~Credits();
|
||||||
|
void compute(Player * _p1, Player * _p2, GameApp * _app);
|
||||||
|
void Render();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -34,6 +34,7 @@ class GameObserver{
|
|||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
int turn;
|
||||||
int targetListIsSet(MTGCardInstance * card);
|
int targetListIsSet(MTGCardInstance * card);
|
||||||
PhaseRing * phaseRing;
|
PhaseRing * phaseRing;
|
||||||
int cancelCurrentAction();
|
int cancelCurrentAction();
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#ifdef TESTSUITE
|
#ifdef TESTSUITE
|
||||||
class TestSuite;
|
class TestSuite;
|
||||||
#endif
|
#endif
|
||||||
|
class Credits;
|
||||||
|
|
||||||
class GameStateDuel: public GameState, public JGuiListener
|
class GameStateDuel: public GameState, public JGuiListener
|
||||||
{
|
{
|
||||||
@@ -18,7 +19,7 @@ class GameStateDuel: public GameState, public JGuiListener
|
|||||||
#ifdef TESTSUITE
|
#ifdef TESTSUITE
|
||||||
TestSuite * testSuite;
|
TestSuite * testSuite;
|
||||||
#endif
|
#endif
|
||||||
int showMsg;
|
Credits * credits;
|
||||||
int mGamePhase;
|
int mGamePhase;
|
||||||
Player * mCurrentPlayer;
|
Player * mCurrentPlayer;
|
||||||
Player * mPlayers[2];
|
Player * mPlayers[2];
|
||||||
@@ -29,11 +30,8 @@ class GameStateDuel: public GameState, public JGuiListener
|
|||||||
SimpleMenu * menu;
|
SimpleMenu * menu;
|
||||||
JLBFont* mFont, *opponentMenuFont;
|
JLBFont* mFont, *opponentMenuFont;
|
||||||
int nbAIDecks;
|
int nbAIDecks;
|
||||||
int unlocked;
|
|
||||||
JQuad * unlockedQuad;
|
|
||||||
JTexture * unlockedTex;
|
|
||||||
int isDifficultyUnlocked();
|
|
||||||
int isMomirUnlocked();
|
|
||||||
void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
|
void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
|
||||||
void loadPlayerMomir(int playerId, int isAI);
|
void loadPlayerMomir(int playerId, int isAI);
|
||||||
public:
|
public:
|
||||||
|
|||||||
196
projects/mtg/src/Credits.cpp
Normal file
196
projects/mtg/src/Credits.cpp
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
#include "../include/Credits.h"
|
||||||
|
#include "../include/GameApp.h"
|
||||||
|
#include "../include/GameOptions.h"
|
||||||
|
#include "../include/config.h"
|
||||||
|
#include "../include/PlayerData.h"
|
||||||
|
#include "../include/DeckStats.h"
|
||||||
|
|
||||||
|
CreditBonus::CreditBonus(int _value, string _text){
|
||||||
|
value = _value;
|
||||||
|
text = _text;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CreditBonus::Render(float x, float y, JLBFont * font){
|
||||||
|
char buffer[512];
|
||||||
|
sprintf(buffer, "%s: %i", text.c_str(), value);
|
||||||
|
font->DrawString(buffer,x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
Credits::Credits(){
|
||||||
|
unlockedTex = NULL;
|
||||||
|
unlockedQuad = NULL;
|
||||||
|
unlocked = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Credits::~Credits(){
|
||||||
|
SAFE_DELETE(unlockedTex);
|
||||||
|
SAFE_DELETE(unlockedQuad);
|
||||||
|
for (int i=0;i<bonus.size();i++)
|
||||||
|
if (bonus[i])
|
||||||
|
delete bonus[i];
|
||||||
|
bonus.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Credits::compute(Player * _p1, Player * _p2, GameApp * _app){
|
||||||
|
p1 = _p1;
|
||||||
|
p2 = _p2;
|
||||||
|
app = _app;
|
||||||
|
showMsg = (rand() % 5);
|
||||||
|
GameObserver * g = GameObserver::GetInstance();
|
||||||
|
if (!p1->isAI() && p2->isAI() && p1!= g->gameOver){
|
||||||
|
GameOptions * go = GameOptions::GetInstance();
|
||||||
|
value = 400;
|
||||||
|
if (app->gameType == GAME_TYPE_MOMIR) value = 200;
|
||||||
|
int difficulty = go->values[OPTIONS_DIFFICULTY].getIntValue();
|
||||||
|
if (go->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue() && difficulty) {
|
||||||
|
CreditBonus * b = NEW CreditBonus(100*difficulty, "Difficulty Bonus");
|
||||||
|
bonus.push_back(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p1->life == 1) {
|
||||||
|
CreditBonus * b = NEW CreditBonus(111, "'Live dangerously and you live right' Bonus");
|
||||||
|
bonus.push_back(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
int diff = p1->life - p2->life;
|
||||||
|
if (diff){
|
||||||
|
CreditBonus * b = NEW CreditBonus(diff, "Life Delta Bonus");
|
||||||
|
bonus.push_back(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p1->game->library->nb_cards == 0) {
|
||||||
|
CreditBonus * b = NEW CreditBonus(391, "'Decree of Theophilus' Bonus");
|
||||||
|
bonus.push_back(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g->turn < 15) {
|
||||||
|
CreditBonus * b = NEW CreditBonus((20 - g->turn)*17, "'Fast and Furious' Bonus");
|
||||||
|
bonus.push_back(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (unlocked == -1){
|
||||||
|
unlocked = isDifficultyUnlocked();
|
||||||
|
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{
|
||||||
|
unlocked = isMomirUnlocked();
|
||||||
|
if (unlocked){
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (unlocked){
|
||||||
|
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/bonus.wav");
|
||||||
|
if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<CreditBonus *>::iterator it;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PlayerData * playerdata = NEW PlayerData(app->collection);
|
||||||
|
playerdata->credits+= value;
|
||||||
|
playerdata->save();
|
||||||
|
delete playerdata;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
unlocked = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Credits::Render(){
|
||||||
|
GameObserver * g = GameObserver::GetInstance();
|
||||||
|
JRenderer * r = JRenderer::GetInstance();
|
||||||
|
JLBFont * f = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
|
||||||
|
JLBFont * f2 = GameApp::CommonRes->GetJLBFont(Constants::MENU_FONT);
|
||||||
|
JLBFont * f3 = GameApp::CommonRes->GetJLBFont(Constants::MAGIC_FONT);
|
||||||
|
f->SetScale(1);
|
||||||
|
f2->SetScale(1);
|
||||||
|
f3->SetScale(1);
|
||||||
|
char buffer[512];
|
||||||
|
if (!p1->isAI() && p2->isAI() ){
|
||||||
|
if (g->gameOver != p1){
|
||||||
|
sprintf (buffer, "Congratulations! You earn %i credits", value);
|
||||||
|
if (unlockedQuad){
|
||||||
|
showMsg = 0;
|
||||||
|
r->RenderQuad(unlockedQuad, 20, 20);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
sprintf (buffer, "You have been defeated");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
int winner = 2;
|
||||||
|
if (g->gameOver !=p1){
|
||||||
|
winner = 1;
|
||||||
|
}
|
||||||
|
int p0life = p1->life;
|
||||||
|
sprintf(buffer, "Player %i wins (%i)", winner, p0life );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float y = 130;
|
||||||
|
if (showMsg == 1) y = 50;
|
||||||
|
vector<CreditBonus *>:: iterator it;
|
||||||
|
for ( it=bonus.begin() ; it < bonus.end(); ++it){
|
||||||
|
(*it)->Render(10,y,f3);
|
||||||
|
y+=12;
|
||||||
|
}
|
||||||
|
f2->DrawString(buffer, 10, y);
|
||||||
|
y+=15;
|
||||||
|
|
||||||
|
if (showMsg == 1){
|
||||||
|
f2->DrawString("Please support this project !" ,10,y+15);
|
||||||
|
f->DrawString("Wagic is free, open source, and developed on the little free time I have" ,10,y+30);
|
||||||
|
f->DrawString("If you enjoy this game, please consider donating a few bucks" ,10,y+42);
|
||||||
|
f->DrawString("(Seriously, donate or I'll kill this cute little bunny)" ,10,y+54);
|
||||||
|
f->DrawString("Thanks in advance for your support." ,10,y+66);
|
||||||
|
f2->DrawString("-> http://wololo.net/wagic" ,10,y+78);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Credits::isDifficultyUnlocked(){
|
||||||
|
if (GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue()) return 0;
|
||||||
|
int nbAIDecks = 0;
|
||||||
|
int found = 1;
|
||||||
|
int wins = 0;
|
||||||
|
DeckStats * stats = DeckStats::GetInstance();
|
||||||
|
stats->load(p1);
|
||||||
|
while (found){
|
||||||
|
found = 0;
|
||||||
|
char buffer[512];
|
||||||
|
char aiSmallDeckName[512];
|
||||||
|
sprintf(buffer, RESPATH"/ai/baka/deck%i.txt",nbAIDecks+1);
|
||||||
|
if(fileExists(buffer)){
|
||||||
|
found = 1;
|
||||||
|
nbAIDecks++;
|
||||||
|
sprintf(aiSmallDeckName, "ai_baka_deck%i",nbAIDecks);
|
||||||
|
int percentVictories = stats->percentVictories(string(aiSmallDeckName));
|
||||||
|
if (percentVictories >=67) wins++;
|
||||||
|
if (wins >= 10) return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Credits::isMomirUnlocked(){
|
||||||
|
if (GameOptions::GetInstance()->values[OPTIONS_MOMIR_MODE_UNLOCKED].getIntValue()) return 0;
|
||||||
|
if (p1->game->inPlay->countByType("land") == 8) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -73,6 +73,7 @@ int GameObserver::enteringPhase(int phase){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameObserver::nextPlayer(){
|
void GameObserver::nextPlayer(){
|
||||||
|
turn++;
|
||||||
currentPlayerId = (currentPlayerId+1)%nbPlayers;
|
currentPlayerId = (currentPlayerId+1)%nbPlayers;
|
||||||
currentPlayer = players[currentPlayerId];
|
currentPlayer = players[currentPlayerId];
|
||||||
currentActionPlayer = currentPlayer;
|
currentActionPlayer = currentPlayer;
|
||||||
@@ -84,6 +85,7 @@ void GameObserver::nextGamePhase(){
|
|||||||
currentGamePhase = cPhase->id;
|
currentGamePhase = cPhase->id;
|
||||||
if (currentPlayer != cPhase->player) nextPlayer();
|
if (currentPlayer != cPhase->player) nextPlayer();
|
||||||
|
|
||||||
|
|
||||||
//init begin of turn
|
//init begin of turn
|
||||||
if (currentGamePhase == Constants::MTG_PHASE_BEFORE_BEGIN){
|
if (currentGamePhase == Constants::MTG_PHASE_BEFORE_BEGIN){
|
||||||
cleanupPhase();
|
cleanupPhase();
|
||||||
@@ -153,6 +155,7 @@ void GameObserver::startGame(int shuffle, int draw){
|
|||||||
for (i=0; i<nbPlayers; i++){
|
for (i=0; i<nbPlayers; i++){
|
||||||
players[i]->game->initGame(shuffle, draw);
|
players[i]->game->initGame(shuffle, draw);
|
||||||
}
|
}
|
||||||
|
turn = 0;
|
||||||
phaseRing->goToPhase(Constants::MTG_PHASE_FIRSTMAIN, players[0]);
|
phaseRing->goToPhase(Constants::MTG_PHASE_FIRSTMAIN, players[0]);
|
||||||
currentGamePhase = Constants::MTG_PHASE_FIRSTMAIN;
|
currentGamePhase = Constants::MTG_PHASE_FIRSTMAIN;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "../include/PlayerData.h"
|
#include "../include/PlayerData.h"
|
||||||
#include "../include/DeckStats.h"
|
#include "../include/DeckStats.h"
|
||||||
#include "../include/MTGRules.h"
|
#include "../include/MTGRules.h"
|
||||||
|
#include "../include/Credits.h"
|
||||||
|
|
||||||
#ifdef TESTSUITE
|
#ifdef TESTSUITE
|
||||||
#include "../include/TestSuiteAI.h"
|
#include "../include/TestSuiteAI.h"
|
||||||
@@ -49,9 +50,8 @@ GameStateDuel::GameStateDuel(GameApp* parent): GameState(parent) {
|
|||||||
#ifdef TESTSUITE
|
#ifdef TESTSUITE
|
||||||
testSuite = NULL;
|
testSuite = NULL;
|
||||||
#endif
|
#endif
|
||||||
showMsg = 0;
|
|
||||||
unlockedTex = NULL;
|
credits = NULL;
|
||||||
unlockedQuad = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameStateDuel::~GameStateDuel() {
|
GameStateDuel::~GameStateDuel() {
|
||||||
@@ -72,12 +72,12 @@ void GameStateDuel::Start()
|
|||||||
|
|
||||||
|
|
||||||
mGamePhase = DUEL_STATE_CHOOSE_DECK1;
|
mGamePhase = DUEL_STATE_CHOOSE_DECK1;
|
||||||
|
credits = NEW Credits();
|
||||||
|
|
||||||
mFont = GameApp::CommonRes->GetJLBFont(Constants::MENU_FONT);
|
mFont = GameApp::CommonRes->GetJLBFont(Constants::MENU_FONT);
|
||||||
mFont->SetBase(0);
|
mFont->SetBase(0);
|
||||||
opponentMenuFont = mFont;
|
opponentMenuFont = mFont;
|
||||||
|
|
||||||
unlocked = -1;
|
|
||||||
|
|
||||||
|
|
||||||
menu = NEW SimpleMenu(DUEL_MENU_GAME_MENU, this, mFont, SCREEN_WIDTH/2-100, 25);
|
menu = NEW SimpleMenu(DUEL_MENU_GAME_MENU, this, mFont, SCREEN_WIDTH/2-100, 25);
|
||||||
@@ -199,8 +199,8 @@ void GameStateDuel::End()
|
|||||||
SAFE_DELETE(deck[i]);
|
SAFE_DELETE(deck[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
SAFE_DELETE(unlockedQuad);
|
SAFE_DELETE(credits);
|
||||||
SAFE_DELETE(unlockedTex);
|
|
||||||
SAFE_DELETE(menu);
|
SAFE_DELETE(menu);
|
||||||
SAFE_DELETE(opponentMenu);
|
SAFE_DELETE(opponentMenu);
|
||||||
#ifdef TESTSUITE
|
#ifdef TESTSUITE
|
||||||
@@ -326,37 +326,8 @@ void GameStateDuel::Update(float dt)
|
|||||||
}
|
}
|
||||||
game->Update(dt);
|
game->Update(dt);
|
||||||
if (game->gameOver){
|
if (game->gameOver){
|
||||||
showMsg = (rand() % 5);
|
credits->compute(mPlayers[0],mPlayers[1], mParent);
|
||||||
if (!mPlayers[0]->isAI() && mPlayers[1]->isAI() && mPlayers[0]!= game->gameOver){
|
mGamePhase = DUEL_STATE_END;
|
||||||
PlayerData * playerdata = NEW PlayerData(mParent->collection);
|
|
||||||
playerdata->credits+= 500;
|
|
||||||
playerdata->save();
|
|
||||||
delete playerdata;
|
|
||||||
if (unlocked == -1){
|
|
||||||
unlocked = isDifficultyUnlocked();
|
|
||||||
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{
|
|
||||||
unlocked = isMomirUnlocked();
|
|
||||||
if (unlocked){
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (unlocked){
|
|
||||||
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/bonus.wav");
|
|
||||||
if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
unlocked = 0;
|
|
||||||
}
|
|
||||||
mGamePhase = DUEL_STATE_END;
|
|
||||||
#ifdef TESTSUITE
|
#ifdef TESTSUITE
|
||||||
if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){
|
if (mParent->players[1] == PLAYER_TYPE_TESTSUITE){
|
||||||
if (testSuite->loadNext()){
|
if (testSuite->loadNext()){
|
||||||
@@ -413,36 +384,7 @@ void GameStateDuel::Render()
|
|||||||
{
|
{
|
||||||
JRenderer * r = JRenderer::GetInstance();
|
JRenderer * r = JRenderer::GetInstance();
|
||||||
r->ClearScreen(ARGB(200,0,0,0));
|
r->ClearScreen(ARGB(200,0,0,0));
|
||||||
char buffer[50];
|
credits->Render();
|
||||||
int p0life = mPlayers[0]->life;
|
|
||||||
if (!mPlayers[0]->isAI() && mPlayers[1]->isAI() ){
|
|
||||||
if (game->gameOver != mPlayers[0]){
|
|
||||||
sprintf (buffer, "Victory! Congratulations, You earn 500 credits");
|
|
||||||
|
|
||||||
}else{
|
|
||||||
sprintf (buffer, "You have been defeated");
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
int winner = 2;
|
|
||||||
if (game->gameOver !=mPlayers[0]){
|
|
||||||
winner = 1;
|
|
||||||
}
|
|
||||||
sprintf(buffer, "Player %i wins (%i)", winner, p0life );
|
|
||||||
}
|
|
||||||
mFont->SetScale(1);
|
|
||||||
mFont->DrawString(buffer, 10, 150);
|
|
||||||
if (unlockedQuad){
|
|
||||||
r->RenderQuad(unlockedQuad, 20, 20);
|
|
||||||
}
|
|
||||||
if (showMsg == 1){
|
|
||||||
JLBFont * f = GameApp::CommonRes->GetJLBFont(Constants::MAIN_FONT);
|
|
||||||
mFont->DrawString("Please support this project !" ,10,180);
|
|
||||||
f->DrawString("Wagic is free, open source, and developed on the little free time I have" ,10,196);
|
|
||||||
f->DrawString("If you enjoy this game, please consider donating a few bucks" ,10,208);
|
|
||||||
f->DrawString("I'll drink a beer in your name!" ,10,220);
|
|
||||||
f->DrawString("Thanks in advance for your support." ,10,232);
|
|
||||||
mFont->DrawString("-> http://wololo.net/wagic" ,10,244);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DUEL_STATE_CHOOSE_DECK1:
|
case DUEL_STATE_CHOOSE_DECK1:
|
||||||
@@ -520,34 +462,3 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int GameStateDuel::isDifficultyUnlocked(){
|
|
||||||
if (GameOptions::GetInstance()->values[OPTIONS_DIFFICULTY_MODE_UNLOCKED].getIntValue()) return 0;
|
|
||||||
nbAIDecks = 0;
|
|
||||||
int found = 1;
|
|
||||||
int wins = 0;
|
|
||||||
DeckStats * stats = DeckStats::GetInstance();
|
|
||||||
stats->load(mPlayers[0]);
|
|
||||||
while (found){
|
|
||||||
found = 0;
|
|
||||||
char buffer[512];
|
|
||||||
char aiSmallDeckName[512];
|
|
||||||
sprintf(buffer, RESPATH"/ai/baka/deck%i.txt",nbAIDecks+1);
|
|
||||||
if(fileExists(buffer)){
|
|
||||||
found = 1;
|
|
||||||
nbAIDecks++;
|
|
||||||
sprintf(aiSmallDeckName, "ai_baka_deck%i",nbAIDecks);
|
|
||||||
int percentVictories = stats->percentVictories(string(aiSmallDeckName));
|
|
||||||
if (percentVictories >=67) wins++;
|
|
||||||
if (wins >= 10) return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int GameStateDuel::isMomirUnlocked(){
|
|
||||||
if (GameOptions::GetInstance()->values[OPTIONS_MOMIR_MODE_UNLOCKED].getIntValue()) return 0;
|
|
||||||
Player *p = mPlayers[0];
|
|
||||||
if (p->game->inPlay->countByType("land") == 8) return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -25,7 +25,7 @@ PlayerData::PlayerData(MTGAllCards * allcards){
|
|||||||
|
|
||||||
int PlayerData::save(){
|
int PlayerData::save(){
|
||||||
std::ofstream file(PLAYER_SAVEFILE);
|
std::ofstream file(PLAYER_SAVEFILE);
|
||||||
char writer[10];
|
char writer[64];
|
||||||
if (file){
|
if (file){
|
||||||
sprintf(writer,"%i\n", credits);
|
sprintf(writer,"%i\n", credits);
|
||||||
file<<writer;
|
file<<writer;
|
||||||
|
|||||||
@@ -264,6 +264,10 @@
|
|||||||
RelativePath=".\src\Counters.cpp"
|
RelativePath=".\src\Counters.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Credits.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\Damage.cpp"
|
RelativePath=".\src\Damage.cpp"
|
||||||
>
|
>
|
||||||
@@ -577,6 +581,10 @@
|
|||||||
RelativePath=".\include\Counters.h"
|
RelativePath=".\include\Counters.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Credits.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\Damage.h"
|
RelativePath=".\include\Damage.h"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user