- 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:
wagic.the.homebrew@gmail.com
2009-07-16 11:48:59 +00:00
parent 03530b7e17
commit 951065a59c
9 changed files with 102 additions and 90 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/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))
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)

View File

@@ -6,6 +6,8 @@
class JGE;
#include <JSoundSystem.h>
#include <string>
using namespace std;
enum ENUM_GAME_STATE
{
@@ -16,7 +18,10 @@ enum ENUM_GAME_STATE
GAME_STATE_OPTIONS = 0x05,
};
class GameApp;
class SimpleMenu;
class Player;
class GameState
{
@@ -38,6 +43,7 @@ class GameState
virtual void Update(float dt) = 0;
virtual void Render() = 0;
static int fillDeckMenu(SimpleMenu * _menu, string path, string smallDeckPrefix = "", Player * statsPlayer = NULL);
};

View File

@@ -184,18 +184,9 @@ class GameStateDeckViewer: public GameState, public JGuiListener
menuFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
welcome_menu = NEW SimpleMenu(10,this,menuFont,20,20);
char buffer[100];
for (int i=1; i < 6; i++){
sprintf(buffer, RESPATH"/player/deck%i.txt",i);
std::ifstream file(buffer);
if(file){
welcome_menu->Add(i, GameState::menuTexts[i]);
file.close();
}else{
welcome_menu->Add(i, GameState::menuTexts[0]);
}
}
welcome_menu->Add(10, "Cancel");
int nbDecks = fillDeckMenu(welcome_menu,RESPATH"/player");
welcome_menu->Add(nbDecks+1, "--NEW--");
welcome_menu->Add(-1, "Cancel");
if (GameApp::HasMusic && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME].getIntValue() > 0){
if (GameApp::music){
@@ -680,8 +671,8 @@ class GameStateDeckViewer: public GameState, public JGuiListener
virtual void Render()
{
// void RenderQuad(JQuad* quad, float xo, float yo, float angle=0.0f, float xScale=1.0f, float yScale=1.0f);
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));
JRenderer * r = JRenderer::GetInstance();
r->ClearScreen(ARGB(0,0,0,0));
if(displayed_deck == myDeck){
@@ -718,6 +709,7 @@ class GameStateDeckViewer: public GameState, public JGuiListener
if (mStage == STAGE_ONSCREEN_MENU){
renderOnScreenMenu();
}else if (mStage == STAGE_WELCOME){
r->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB(200,0,0,0));
welcome_menu->Render();
}else{
renderOnScreenBasicInfo();
@@ -755,19 +747,20 @@ class GameStateDeckViewer: public GameState, public JGuiListener
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)
{
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:
myDeck->save();
playerdata->save();

View File

@@ -29,11 +29,11 @@ class GameStateDuel: public GameState, public JGuiListener
SimpleMenu * opponentMenu;
SimpleMenu * menu;
JLBFont* mFont, *opponentMenuFont;
int nbAIDecks;
void loadPlayer(int playerId, int decknb = 0, int isAI = 0);
void loadPlayerMomir(int playerId, int isAI);
public:
GameStateDuel(GameApp* parent);
virtual ~GameStateDuel();

View File

@@ -13,6 +13,7 @@
#include "../include/GameApp.h"
#include "../include/TexturesCache.h"
#include <string>
using std::string;
@@ -102,6 +103,7 @@ class MTGDeck{
int remove(MTGCard * card);
int save();
MTGCard * getCardById(int id);
};

View 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;
}

View File

@@ -90,20 +90,11 @@ void GameStateDuel::Start()
for (int i = 0; i<2; i ++){
if (mParent->players[i] == PLAYER_TYPE_HUMAN){
if (!deckmenu){
decksneeded = 1;
deckmenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_DECK, this, mFont, 35, 25, "Choose a Deck");
char buffer[100];
for (int j=1; j<6; j++){
sprintf(buffer, RESPATH"/player/deck%i.txt",j);
std::ifstream file(buffer);
if(file){
deckmenu->Add(j, GameState::menuTexts[j]);
file.close();
decksneeded = 0;
}
}
}
decksneeded = 1;
deckmenu = NEW SimpleMenu(DUEL_MENU_CHOOSE_DECK, this, mFont, 35, 25, "Choose a Deck");
int nbDecks = fillDeckMenu(deckmenu,RESPATH"/player");
if (nbDecks) decksneeded = 0;
break;
}
}
@@ -133,8 +124,6 @@ void GameStateDuel::loadPlayer(int playerId, int decknb, int isAI){
sprintf(deckFile, RESPATH"/player/deck%i.txt",decknb);
char deckFileSmall[255];
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);
deck[playerId] = NEW MTGPlayerCards(mParent->collection,tempDeck);
delete tempDeck;
@@ -214,6 +203,8 @@ void GameStateDuel::End()
}
void GameStateDuel::Update(float dt)
{
switch (mGamePhase)
@@ -269,36 +260,7 @@ void GameStateDuel::Update(float dt)
if (GameOptions::GetInstance()->values[OPTIONS_EVILTWIN_MODE_UNLOCKED].getIntValue()){
opponentMenu->Add(-1,"Evil Twin", "Can you play against yourself?");
}
nbAIDecks = 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;
}
}
fillDeckMenu(opponentMenu,RESPATH"/ai/baka", "ai_baka", mPlayers[0]);
}
opponentMenu->Update(dt);
}else{
@@ -444,27 +406,24 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
}
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:
{
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:
menu->Close();
mGamePhase = DUEL_STATE_BACK_TO_MAIN_MENU;

View File

@@ -519,3 +519,5 @@ int MTGDeck::save(){
return 1;
}

View File

@@ -348,6 +348,10 @@
RelativePath=".\src\GameOptions.cpp"
>
</File>
<File
RelativePath=".\src\GameState.cpp"
>
</File>
<File
RelativePath=".\src\GameStateDuel.cpp"
>