]> git.jsancho.org Git - lugaru.git/blob - Source/Account.h
clean ups, and now campaignProgess is well initialized in accounts
[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 typedef struct {
32         float highscore;
33         float fasttime;
34         float score;
35         float time;
36         std::vector<int> choices;
37 } campaign_progress_t;
38
39 class Account {
40         public:
41                 static void destroy(int i);
42                 static Account* destroy(Account* a);
43                 static Account* add(std::string name);
44                 static Account* get(int i);
45                 static Account* loadFile(std::string filename);
46                 static void saveFile(std::string filename, Account* accountactive);
47                 static int indice(Account* a);
48                 
49                 void endGame();
50                 void winCampaignLevel(int choice, float score, float time);
51                 void winLevel(int level, float score, float time);
52                 
53                 // getter and setters
54                 int getDifficulty();
55                 void setDifficulty(int i) { difficulty = i; };
56                 const char* getName() { return name.c_str(); };
57                 float getCampaignScore() { return campaignProgress[currentCampaign].score; };
58                 int getCampaignChoicesMade() { return campaignProgress[currentCampaign].choices.size(); };
59                 int getCampaignChoice(int i) { return campaignProgress[currentCampaign].choices[i]; };
60                 void setCampaignScore(int s) {
61                         campaignProgress[currentCampaign].score=s;
62                         if(s>campaignProgress[currentCampaign].highscore)
63                                 campaignProgress[currentCampaign].highscore=s;
64                 };
65                 void setCampaignFinalTime(float t) {
66                                 campaignProgress[currentCampaign].time = t;
67                                 if((t<campaignProgress[currentCampaign].fasttime) || (campaignProgress[currentCampaign].fasttime==0) && (t!=0))
68                                         campaignProgress[currentCampaign].fasttime = t;
69                 };
70                 float getCampaignFasttime() { return campaignProgress[currentCampaign].fasttime; };
71                 void resetFasttime() { campaignProgress[currentCampaign].fasttime = 0; };
72                 float getCampaignHighScore() { return campaignProgress[currentCampaign].highscore; };
73                 float getHighScore(int i) { return highscore[i]; };
74                 float getFastTime(int i) { return fasttime[i]; };
75                 int getProgress() { return progress; };
76                 void setCurrentCampaign(std::string name);
77                 
78                 static int getNbAccounts() { return accounts.size(); };
79         private:
80                 Account(std::string n="");
81                 int difficulty;
82                 int progress; // progress in challenge levels
83                 float points;
84                 float highscore[50];
85                 float fasttime[50];
86                 bool unlocked[60];
87                 std::string name;
88                 
89                 std::string currentCampaign;
90                 std::map<std::string,campaign_progress_t> campaignProgress;
91         
92         //statics
93                 static std::vector<Account*> accounts;
94 };
95
96 #endif