Files
wagic/projects/mtg/src/PlayerData.cpp
wagic.the.homebrew@gmail.com e9cb57dbb1 Erwan
- Added new bonus system for victories. Unlock and bonuses need to be tested :/
2009-04-11 09:43:29 +00:00

41 lines
776 B
C++

#include "../include/config.h"
#include "../include/PlayerData.h"
#include <string.h>
#include <stdio.h>
PlayerData::PlayerData(MTGAllCards * allcards){
//CREDITS
credits = 3000; //Default value
std::ifstream file(PLAYER_SAVEFILE);
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(RESPATH"/player/collection.dat", allcards->mCache , allcards);
}
int PlayerData::save(){
std::ofstream file(PLAYER_SAVEFILE);
char writer[64];
if (file){
sprintf(writer,"%i\n", credits);
file<<writer;
file.close();
}
collection->save();
return 1;
}
PlayerData::~PlayerData(){
SAFE_DELETE(collection);
}