7510ee165f
* Decks now support naming and renaming. Also added a "Switch decks without saving" option. * Removed unused static const char * menuTexts, from old 6-deck limited system * Keypad didn't display correctly when not given a title, and was never destructed. Fixed. * profileFile() default behavior was to fall back to RESPATH/player. Fixed. * New iconspsp.png, updated look to seem like PSP buttons, added some extra (unused) button icons.
43 lines
867 B
C++
43 lines
867 B
C++
#include "../include/config.h"
|
|
#include "../include/GameOptions.h"
|
|
#include "../include/PlayerData.h"
|
|
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
PlayerData::PlayerData(MTGAllCards * allcards){
|
|
//CREDITS
|
|
credits = 3000; //Default value
|
|
|
|
std::ifstream file(options.profileFile(PLAYER_SAVEFILE).c_str());
|
|
std::string s;
|
|
if(file){
|
|
if(std::getline(file,s)){
|
|
credits = atoi(s.c_str());
|
|
}else{
|
|
//TODO error management
|
|
}
|
|
file.close();
|
|
}
|
|
|
|
//COLLECTION
|
|
collection = NEW MTGDeck(options.profileFile(PLAYER_COLLECTION).c_str(), allcards);
|
|
}
|
|
|
|
|
|
int PlayerData::save(){
|
|
std::ofstream file(options.profileFile(PLAYER_SAVEFILE).c_str());
|
|
char writer[64];
|
|
if (file){
|
|
sprintf(writer,"%i\n", credits);
|
|
file<<writer;
|
|
file.close();
|
|
}
|
|
collection->save();
|
|
return 1;
|
|
}
|
|
|
|
PlayerData::~PlayerData(){
|
|
SAFE_DELETE(collection);
|
|
}
|