]> git.jsancho.org Git - lugaru.git/blob - Source/Account.h
Some cleans, fullscreen is back if "--windowed" isn't passed as option.
[lugaru.git] / Source / Account.h
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010 - Côme <MCMic> BERNIGAUD
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 <map>
29 #include <fstream>
30
31 struct CampaignProgress {
32         float highscore;
33         float fasttime;
34         float score;
35         float time;
36         std::vector<int> choices;
37         CampaignProgress() {
38                 highscore = 0;
39                 fasttime = 0;
40                 score = 0;
41                 time = 0;
42         }
43 };
44
45 class Account {
46         public:
47                 static void destroy(int i);
48                 static Account* destroy(Account* a);
49                 static Account* add(std::string name);
50                 static Account* get(int i);
51                 static Account* loadFile(std::string filename);
52                 static void saveFile(std::string filename, Account* accountactive);
53                 static int indice(Account* a);
54                 
55                 void endGame();
56                 void winCampaignLevel(int choice, float score, float time);
57                 void winLevel(int level, float score, float time);
58                 
59                 // getter and setters
60                 int getDifficulty();
61                 void setDifficulty(int i) { difficulty = i; };
62                 const char* getName() { return name.c_str(); };
63                 float getCampaignScore() { return campaignProgress[currentCampaign].score; };
64                 int getCampaignChoicesMade() { return campaignProgress[currentCampaign].choices.size(); };
65                 int getCampaignChoice(int i) { return campaignProgress[currentCampaign].choices[i]; };
66                 void setCampaignScore(int s) {
67                         campaignProgress[currentCampaign].score=s;
68                         if(s>campaignProgress[currentCampaign].highscore)
69                                 campaignProgress[currentCampaign].highscore=s;
70                 };
71                 void setCampaignFinalTime(float t) {
72                                 campaignProgress[currentCampaign].time = t;
73                                 if((t<campaignProgress[currentCampaign].fasttime) || (campaignProgress[currentCampaign].fasttime==0) && (t!=0))
74                                         campaignProgress[currentCampaign].fasttime = t;
75                 };
76                 float getCampaignFasttime() { return campaignProgress[currentCampaign].fasttime; };
77                 void resetFasttime() { campaignProgress[currentCampaign].fasttime = 0; };
78                 float getCampaignHighScore() { return campaignProgress[currentCampaign].highscore; };
79                 float getHighScore(int i) { return highscore[i]; };
80                 float getFastTime(int i) { return fasttime[i]; };
81                 int getProgress() { return progress; };
82                 std::string getCurrentCampaign() { return currentCampaign; };
83                 void setCurrentCampaign(std::string name);
84                 
85                 static int getNbAccounts() { return accounts.size(); };
86         private:
87                 Account(std::string n="");
88                 int difficulty;
89                 int progress; // progress in challenge levels
90                 float points;
91                 float highscore[50];
92                 float fasttime[50];
93                 bool unlocked[60];
94                 std::string name;
95                 
96                 std::string currentCampaign;
97                 std::map<std::string,CampaignProgress> campaignProgress;
98         
99         //statics
100                 static std::vector<Account*> accounts;
101 };
102
103 #endif