]> git.jsancho.org Git - lugaru.git/blob - Source/Account.h
7572e607b4ac953e49f227c05ba2b2bc95998243
[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 {
47 public:
48     static void destroy(int i);
49     static Account* destroy(Account* a);
50     static Account* add(std::string name);
51     static Account* get(int i);
52     static Account* loadFile(std::string filename);
53     static void saveFile(std::string filename, Account* accountactive);
54     static int indice(Account* a);
55
56     void endGame();
57     void winCampaignLevel(int choice, float score, float time);
58     void winLevel(int level, float score, float time);
59
60     // getter and setters
61     int getDifficulty();
62     void setDifficulty(int i) {
63         difficulty = i;
64     };
65     const char* getName() {
66         return name.c_str();
67     };
68     float getCampaignScore() {
69         return campaignProgress[currentCampaign].score;
70     };
71     int getCampaignChoicesMade() {
72         return campaignProgress[currentCampaign].choices.size();
73     };
74     int getCampaignChoice(int i) {
75         return campaignProgress[currentCampaign].choices[i];
76     };
77     void setCampaignScore(int s) {
78         campaignProgress[currentCampaign].score = s;
79         if (s > campaignProgress[currentCampaign].highscore)
80             campaignProgress[currentCampaign].highscore = s;
81     };
82     void setCampaignFinalTime(float t) {
83         campaignProgress[currentCampaign].time = t;
84         if ((t < campaignProgress[currentCampaign].fasttime) || ((campaignProgress[currentCampaign].fasttime == 0) && (t != 0)))
85             campaignProgress[currentCampaign].fasttime = t;
86     };
87     float getCampaignFasttime() {
88         return campaignProgress[currentCampaign].fasttime;
89     };
90     void resetFasttime() {
91         campaignProgress[currentCampaign].fasttime = 0;
92     };
93     float getCampaignHighScore() {
94         return campaignProgress[currentCampaign].highscore;
95     };
96     float getHighScore(int i) {
97         return highscore[i];
98     };
99     float getFastTime(int i) {
100         return fasttime[i];
101     };
102     int getProgress() {
103         return progress;
104     };
105     std::string getCurrentCampaign() {
106         return currentCampaign;
107     };
108     void setCurrentCampaign(std::string name);
109
110     static int getNbAccounts() {
111         return accounts.size();
112     };
113 private:
114     Account(std::string n = "");
115     int difficulty;
116     int progress; // progress in challenge levels
117     float points;
118     float highscore[50];
119     float fasttime[50];
120     bool unlocked[60];
121     std::string name;
122
123     std::string currentCampaign;
124     std::map<std::string, CampaignProgress> campaignProgress;
125
126     //statics
127     static std::vector<Account*> accounts;
128 };
129
130 #endif