Erwan
- no more 5 decks limitation for Player - Player decks can be given a name/description the same way we do for the AI. No PSP Gui for that yet though, has to be done outside of Wagic (PSPWrite ?)
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/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/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/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
|
||||||
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)
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
class JGE;
|
class JGE;
|
||||||
|
|
||||||
#include <JSoundSystem.h>
|
#include <JSoundSystem.h>
|
||||||
|
#include <string>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
enum ENUM_GAME_STATE
|
enum ENUM_GAME_STATE
|
||||||
{
|
{
|
||||||
@@ -16,7 +18,10 @@ enum ENUM_GAME_STATE
|
|||||||
GAME_STATE_OPTIONS = 0x05,
|
GAME_STATE_OPTIONS = 0x05,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class GameApp;
|
class GameApp;
|
||||||
|
class SimpleMenu;
|
||||||
|
class Player;
|
||||||
|
|
||||||
class GameState
|
class GameState
|
||||||
{
|
{
|
||||||
@@ -38,6 +43,7 @@ class GameState
|
|||||||
|
|
||||||
virtual void Update(float dt) = 0;
|
virtual void Update(float dt) = 0;
|
||||||
virtual void Render() = 0;
|
virtual void Render() = 0;
|
||||||
|
static int fillDeckMenu(SimpleMenu * _menu, string path, string smallDeckPrefix = "", Player * statsPlayer = NULL);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -184,18 +184,9 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
|||||||
menuFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
menuFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||||
welcome_menu = NEW SimpleMenu(10,this,menuFont,20,20);
|
welcome_menu = NEW SimpleMenu(10,this,menuFont,20,20);
|
||||||
char buffer[100];
|
char buffer[100];
|
||||||
for (int i=1; i < 6; i++){
|
int nbDecks = fillDeckMenu(welcome_menu,RESPATH"/player");
|
||||||
sprintf(buffer, RESPATH"/player/deck%i.txt",i);
|
welcome_menu->Add(nbDecks+1, "--NEW--");
|
||||||
std::ifstream file(buffer);
|
welcome_menu->Add(-1, "Cancel");
|
||||||
if(file){
|
|
||||||
welcome_menu->Add(i, GameState::menuTexts[i]);
|
|
||||||
file.close();
|
|
||||||
}else{
|
|
||||||
welcome_menu->Add(i, GameState::menuTexts[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
welcome_menu->Add(10, "Cancel");
|
|
||||||
|
|
||||||
if (GameApp::HasMusic && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME].getIntValue() > 0){
|
if (GameApp::HasMusic && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME].getIntValue() > 0){
|
||||||
if (GameApp::music){
|
if (GameApp::music){
|
||||||
@@ -680,8 +671,8 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
|||||||
virtual void Render()
|
virtual void Render()
|
||||||
{
|
{
|
||||||
// void RenderQuad(JQuad* quad, float xo, float yo, float angle=0.0f, float xScale=1.0f, float yScale=1.0f);
|
// void RenderQuad(JQuad* quad, float xo, float yo, float angle=0.0f, float xScale=1.0f, float yScale=1.0f);
|
||||||
|
JRenderer * r = JRenderer::GetInstance();
|
||||||
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));
|
r->ClearScreen(ARGB(0,0,0,0));
|
||||||
|
|
||||||
|
|
||||||
if(displayed_deck == myDeck){
|
if(displayed_deck == myDeck){
|
||||||
@@ -718,6 +709,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
|||||||
if (mStage == STAGE_ONSCREEN_MENU){
|
if (mStage == STAGE_ONSCREEN_MENU){
|
||||||
renderOnScreenMenu();
|
renderOnScreenMenu();
|
||||||
}else if (mStage == STAGE_WELCOME){
|
}else if (mStage == STAGE_WELCOME){
|
||||||
|
r->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB(200,0,0,0));
|
||||||
welcome_menu->Render();
|
welcome_menu->Render();
|
||||||
}else{
|
}else{
|
||||||
renderOnScreenBasicInfo();
|
renderOnScreenBasicInfo();
|
||||||
@@ -755,19 +747,20 @@ class GameStateDeckViewer: public GameState, public JGuiListener
|
|||||||
|
|
||||||
virtual void ButtonPressed(int controllerId, int controlId)
|
virtual void ButtonPressed(int controllerId, int controlId)
|
||||||
{
|
{
|
||||||
|
switch(controllerId){
|
||||||
|
case 10:
|
||||||
|
if (controlId == -1){
|
||||||
|
mParent->SetNextState(GAME_STATE_MENU);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loadDeck(controlId);
|
||||||
|
mStage = STAGE_WAITING;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (controlId)
|
switch (controlId)
|
||||||
{
|
{
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
loadDeck(controlId);
|
|
||||||
mStage = STAGE_WAITING;
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
mParent->SetNextState(GAME_STATE_MENU);
|
|
||||||
break;
|
|
||||||
case 11:
|
case 11:
|
||||||
myDeck->save();
|
myDeck->save();
|
||||||
playerdata->save();
|
playerdata->save();
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ class GameStateDuel: public GameState, public JGuiListener
|
|||||||
SimpleMenu * opponentMenu;
|
SimpleMenu * opponentMenu;
|
||||||
SimpleMenu * menu;
|
SimpleMenu * menu;
|
||||||
JLBFont* mFont, *opponentMenuFont;
|
JLBFont* mFont, *opponentMenuFont;
|
||||||
int nbAIDecks;
|
|
||||||
|
|
||||||
|
|
||||||
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:
|
||||||
GameStateDuel(GameApp* parent);
|
GameStateDuel(GameApp* parent);
|
||||||
virtual ~GameStateDuel();
|
virtual ~GameStateDuel();
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "../include/GameApp.h"
|
#include "../include/GameApp.h"
|
||||||
#include "../include/TexturesCache.h"
|
#include "../include/TexturesCache.h"
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
@@ -102,6 +103,7 @@ class MTGDeck{
|
|||||||
int remove(MTGCard * card);
|
int remove(MTGCard * card);
|
||||||
int save();
|
int save();
|
||||||
MTGCard * getCardById(int id);
|
MTGCard * getCardById(int id);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
46
projects/mtg/src/GameState.cpp
Normal file
46
projects/mtg/src/GameState.cpp
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#include "../include/config.h"
|
||||||
|
#include "../include/Translate.h"
|
||||||
|
#include "../include/GameState.h"
|
||||||
|
#include "../include/Player.h"
|
||||||
|
#include "../include/SimpleMenu.h"
|
||||||
|
#include "../include/DeckStats.h"
|
||||||
|
|
||||||
|
|
||||||
|
int GameState::fillDeckMenu(SimpleMenu * _menu, string path, string smallDeckPrefix, Player * statsPlayer){
|
||||||
|
int found = 1;
|
||||||
|
int nbDecks = 0;
|
||||||
|
while (found){
|
||||||
|
found = 0;
|
||||||
|
char buffer[512];
|
||||||
|
char smallDeckName[512];
|
||||||
|
char deckDesc[512];
|
||||||
|
sprintf(buffer, "%s/deck%i.txt",path.c_str(),nbDecks+1);
|
||||||
|
if(fileExists(buffer)){
|
||||||
|
MTGDeck * mtgd = NEW MTGDeck(buffer,NULL,NULL,1);
|
||||||
|
found = 1;
|
||||||
|
nbDecks++;
|
||||||
|
sprintf(smallDeckName, "%s_deck%i",smallDeckPrefix.c_str(),nbDecks);
|
||||||
|
|
||||||
|
if (statsPlayer){
|
||||||
|
DeckStats * stats = DeckStats::GetInstance();
|
||||||
|
stats->load(statsPlayer);
|
||||||
|
int percentVictories = stats->percentVictories(string(smallDeckName));
|
||||||
|
string difficulty;
|
||||||
|
if (percentVictories < 34){
|
||||||
|
difficulty = "(hard)";
|
||||||
|
}else if (percentVictories < 67){
|
||||||
|
difficulty = "";
|
||||||
|
}else{
|
||||||
|
difficulty = "(easy)";
|
||||||
|
}
|
||||||
|
sprintf(deckDesc, "%s %s",mtgd->meta_name.c_str(), _(difficulty).c_str());
|
||||||
|
}else{
|
||||||
|
sprintf(deckDesc, "%s",mtgd->meta_name.c_str());
|
||||||
|
}
|
||||||
|
deckDesc[16] = 0;
|
||||||
|
_menu->Add(nbDecks,deckDesc,mtgd->meta_desc);
|
||||||
|
delete mtgd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nbDecks;
|
||||||
|
}
|
||||||
@@ -90,20 +90,11 @@ void GameStateDuel::Start()
|
|||||||
|
|
||||||
for (int i = 0; i<2; i ++){
|
for (int i = 0; i<2; i ++){
|
||||||
if (mParent->players[i] == PLAYER_TYPE_HUMAN){
|
if (mParent->players[i] == PLAYER_TYPE_HUMAN){
|
||||||
if (!deckmenu){
|
decksneeded = 1;
|
||||||
decksneeded = 1;
|
deckmenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_DECK, this, mFont, 35, 25, "Choose a Deck");
|
||||||
deckmenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_DECK, this, mFont, 35, 25, "Choose a Deck");
|
int nbDecks = fillDeckMenu(deckmenu,RESPATH"/player");
|
||||||
char buffer[100];
|
if (nbDecks) decksneeded = 0;
|
||||||
for (int j=1; j<6; j++){
|
break;
|
||||||
sprintf(buffer, RESPATH"/player/deck%i.txt",j);
|
|
||||||
std::ifstream file(buffer);
|
|
||||||
if(file){
|
|
||||||
deckmenu->Add(j, GameState::menuTexts[j]);
|
|
||||||
file.close();
|
|
||||||
decksneeded = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,8 +124,6 @@ void GameStateDuel::loadPlayer(int playerId, int decknb, int isAI){
|
|||||||
sprintf(deckFile, RESPATH"/player/deck%i.txt",decknb);
|
sprintf(deckFile, RESPATH"/player/deck%i.txt",decknb);
|
||||||
char deckFileSmall[255];
|
char deckFileSmall[255];
|
||||||
sprintf(deckFileSmall, "player_deck%i",decknb);
|
sprintf(deckFileSmall, "player_deck%i",decknb);
|
||||||
//int deck_cards_ids[100];
|
|
||||||
//int nb_elements = readfile_to_ints(deckFile, deck_cards_ids);
|
|
||||||
MTGDeck * tempDeck = NEW MTGDeck(deckFile, NULL, mParent->collection);
|
MTGDeck * tempDeck = NEW MTGDeck(deckFile, NULL, mParent->collection);
|
||||||
deck[playerId] = NEW MTGPlayerCards(mParent->collection,tempDeck);
|
deck[playerId] = NEW MTGPlayerCards(mParent->collection,tempDeck);
|
||||||
delete tempDeck;
|
delete tempDeck;
|
||||||
@@ -214,6 +203,8 @@ void GameStateDuel::End()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GameStateDuel::Update(float dt)
|
void GameStateDuel::Update(float dt)
|
||||||
{
|
{
|
||||||
switch (mGamePhase)
|
switch (mGamePhase)
|
||||||
@@ -269,36 +260,7 @@ void GameStateDuel::Update(float dt)
|
|||||||
if (GameOptions::GetInstance()->values[OPTIONS_EVILTWIN_MODE_UNLOCKED].getIntValue()){
|
if (GameOptions::GetInstance()->values[OPTIONS_EVILTWIN_MODE_UNLOCKED].getIntValue()){
|
||||||
opponentMenu->Add(-1,"Evil Twin", "Can you play against yourself?");
|
opponentMenu->Add(-1,"Evil Twin", "Can you play against yourself?");
|
||||||
}
|
}
|
||||||
nbAIDecks = 0;
|
fillDeckMenu(opponentMenu,RESPATH"/ai/baka", "ai_baka", mPlayers[0]);
|
||||||
int found = 1;
|
|
||||||
while (found){
|
|
||||||
found = 0;
|
|
||||||
char buffer[512];
|
|
||||||
char aiSmallDeckName[512];
|
|
||||||
char deckDesc[512];
|
|
||||||
sprintf(buffer, RESPATH"/ai/baka/deck%i.txt",nbAIDecks+1);
|
|
||||||
if(fileExists(buffer)){
|
|
||||||
MTGDeck * mtgd = NEW MTGDeck(buffer,NULL,NULL,1);
|
|
||||||
found = 1;
|
|
||||||
nbAIDecks++;
|
|
||||||
sprintf(aiSmallDeckName, "ai_baka_deck%i",nbAIDecks);
|
|
||||||
DeckStats * stats = DeckStats::GetInstance();
|
|
||||||
stats->load(mPlayers[0]);
|
|
||||||
int percentVictories = stats->percentVictories(string(aiSmallDeckName));
|
|
||||||
string difficulty;
|
|
||||||
if (percentVictories < 34){
|
|
||||||
difficulty = "(hard)";
|
|
||||||
}else if (percentVictories < 67){
|
|
||||||
difficulty = "";
|
|
||||||
}else{
|
|
||||||
difficulty = "(easy)";
|
|
||||||
}
|
|
||||||
sprintf(deckDesc, "%s %s",mtgd->meta_name.c_str(), _(difficulty).c_str());
|
|
||||||
deckDesc[16] = 0;
|
|
||||||
opponentMenu->Add(nbAIDecks,deckDesc,mtgd->meta_desc);
|
|
||||||
delete mtgd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
opponentMenu->Update(dt);
|
opponentMenu->Update(dt);
|
||||||
}else{
|
}else{
|
||||||
@@ -444,27 +406,24 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case DUEL_MENU_CHOOSE_DECK:
|
||||||
|
{
|
||||||
|
if (mGamePhase == DUEL_STATE_CHOOSE_DECK1){
|
||||||
|
loadPlayer(0,controlId);
|
||||||
|
deckmenu->Close();
|
||||||
|
mGamePhase = DUEL_STATE_CHOOSE_DECK1_TO_2;
|
||||||
|
}else{
|
||||||
|
loadPlayer(1,controlId);
|
||||||
|
deckmenu->Close();
|
||||||
|
mGamePhase = DUEL_STATE_CHOOSE_DECK2_TO_PLAY;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
switch (controlId)
|
switch (controlId)
|
||||||
{
|
{
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
{
|
|
||||||
if (mGamePhase == DUEL_STATE_CHOOSE_DECK1){
|
|
||||||
loadPlayer(0,controlId);
|
|
||||||
deckmenu->Close();
|
|
||||||
mGamePhase = DUEL_STATE_CHOOSE_DECK1_TO_2;
|
|
||||||
}else{
|
|
||||||
loadPlayer(1,controlId);
|
|
||||||
deckmenu->Close();
|
|
||||||
mGamePhase = DUEL_STATE_CHOOSE_DECK2_TO_PLAY;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 12:
|
case 12:
|
||||||
menu->Close();
|
menu->Close();
|
||||||
mGamePhase = DUEL_STATE_BACK_TO_MAIN_MENU;
|
mGamePhase = DUEL_STATE_BACK_TO_MAIN_MENU;
|
||||||
|
|||||||
@@ -519,3 +519,5 @@ int MTGDeck::save(){
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -348,6 +348,10 @@
|
|||||||
RelativePath=".\src\GameOptions.cpp"
|
RelativePath=".\src\GameOptions.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\GameState.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\GameStateDuel.cpp"
|
RelativePath=".\src\GameStateDuel.cpp"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user