]> git.jsancho.org Git - lugaru.git/blob - Source/Account.h
Move player account handling into separate class
[lugaru.git] / Source / Account.h
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010 - MCMic
4
5 This file is part of Lugaru.
6
7 Lugaru is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
15
16 See the GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 */
22
23 #ifndef _Account_H_
24 #define _Account_H_
25
26 #include <vector>
27 #include <string>
28 #include <fstream>
29
30
31 class Account {
32         public:
33                 static void destroy(int i);
34                 static Account* destroy(Account* a);
35                 static Account* add(std::string name);
36                 static Account* get(int i);
37                 static Account* loadFile(std::string filename);
38                 static void saveFile(std::string filename, Account* accountactive);
39                 static int indice(Account* a);
40                 
41                 void endGame();
42                 void winCampaignLevel(int choice, float score, float time);
43                 void winLevel(int level, float score, float time);
44                 
45                 // getter and setters
46                 int getDifficulty();
47                 void setDifficulty(int i) { difficulty = i; };
48                 const char* getName() { return name.c_str(); };
49                 float getCampaignScore() { return campaignscore; };
50                 int getCampaignChoicesMade() { return campaignchoicesmade; };
51                 int getCampaignChoice(int i) { return campaignchoices[i]; };
52                 void setCampaignScore(int s) {
53                         campaignscore=s;
54                         if(s>campaignhighscore)
55                                 campaignhighscore=s;
56                 };
57                 void setCampaignFinalTime(float t) {
58                                 campaigntime = t;
59                                 if((t<campaignfasttime) || (campaignfasttime==0) && (t!=0))
60                                         campaignfasttime = t;
61                 };
62                 float getCampaignFasttime() { return campaignfasttime; };
63                 void resetFasttime() { campaignfasttime = 0; };
64                 float getCampaignHighScore() { return campaignhighscore; };
65                 float getHighScore(int i) { return highscore[i]; };
66                 float getFastTime(int i) { return fasttime[i]; };
67                 int getProgress() { return progress; };
68                 
69                 static int getNbAccounts() { return accounts.size(); };
70         private:
71                 Account(std::string n="");
72                 int difficulty;
73                 int progress;
74                 float points;
75                 float highscore[50];
76                 float fasttime[50];
77                 bool unlocked[60];
78                 std::string name;
79                 float campaignhighscore;
80                 float campaignfasttime;
81                 float campaignscore;
82                 float campaigntime;
83                 int campaignchoicesmade;
84                 int campaignchoices[5000]; // should really disappear. I'd use a vector or something like that.
85         
86         //statics
87                 static std::vector<Account*> accounts;
88 };
89
90 #endif