]> git.jsancho.org Git - lugaru.git/blob - Source/Awards.cpp
9243cf4051cbe9ae87c9085e009bdbf58cd46ae4
[lugaru.git] / Source / Awards.cpp
1 /*
2 Copyright (C) 2010 - Lugaru authors
3
4 This file is part of Lugaru.
5
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15 See the GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 */
21
22 #include "Awards.h"
23 #include "Person.h"
24 #include "Game.h"
25
26 int bonus;
27 float bonusvalue;
28 float bonustotal;
29 float startbonustotal;
30 float bonustime;
31 float bonusnum[100];
32
33 const char *bonus_names[bonus_count] = {
34 #define DECLARE_BONUS(id, name, ...) name,
35 #include "Bonuses.def"
36 #undef DECLARE_BONUS
37 };
38
39 const char *award_names[award_count] = {
40 #define DECLARE_AWARD(id, name) name,
41 #include "Awards.def"
42 #undef DECLARE_AWARD
43 };
44
45 static const int bonus_values[bonus_count] = {
46 #define DECLARE_BONUS(id, name, value, ...) value,
47 #include "Bonuses.def"
48 #undef DECLARE_BONUS
49 };
50
51 void
52 award_bonus(int playerid, int bonusid, int alt_value)
53 {
54     if (playerid != 0)
55         return;
56     bonus = bonusid;
57     bonustime = 0;
58     bonusvalue = alt_value ? alt_value : bonus_values[bonusid];
59 }
60
61 // FIXME: make these per-player
62 float damagetaken;
63 int numfalls;
64 int numflipfail;
65 int numseen;
66 int numresponded;
67 int numstaffattack;
68 int numswordattack;
69 int numknifeattack;
70 int numunarmedattack;
71 int numescaped;
72 int numflipped;
73 int numwallflipped;
74 int numthrowkill;
75 int numafterkill;
76 int numreversals;
77 int numattacks;
78 int maxalarmed;
79
80 int award_awards(int *awards)
81 {
82     int numawards = 0;
83     if (damagetaken == 0 && Person::players[0]->bloodloss == 0) {
84         awards[numawards] = awardflawless;
85         numawards++;
86     }
87     bool alldead = true;
88     for (unsigned i = 1; i < Person::players.size(); i++) {
89         if (Person::players[i]->dead != 2)
90             alldead = 0;
91     }
92     if (alldead) {
93         awards[numawards] = awardalldead;
94         numawards++;
95     }
96     alldead = 1;
97     for (unsigned i = 1; i < Person::players.size(); i++) {
98         if (Person::players[i]->dead != 1)
99             alldead = 0;
100     }
101     if (alldead) {
102         awards[numawards] = awardnodead;
103         numawards++;
104     }
105     if (numresponded == 0 && !numthrowkill) {
106         awards[numawards] = awardstealth;
107         numawards++;
108     }
109     if (numattacks == numstaffattack && numattacks > 0) {
110         awards[numawards] = awardbojutsu;
111         numawards++;
112     }
113     if (numattacks == numswordattack && numattacks > 0) {
114         awards[numawards] = awardswordsman;
115         numawards++;
116     }
117     if (numattacks == numknifeattack && numattacks > 0) {
118         awards[numawards] = awardknifefighter;
119         numawards++;
120     }
121     if (numattacks == numunarmedattack && numthrowkill == 0 && weapons.size() > 0) {
122         awards[numawards] = awardkungfu;
123         numawards++;
124     }
125     if (numescaped > 0) {
126         awards[numawards] = awardevasion;
127         numawards++;
128     }
129     if (numflipfail == 0 && numflipped + numwallflipped * 2 > 20) {
130         awards[numawards] = awardacrobat;
131         numawards++;
132     }
133     if (numthrowkill == (int(Person::players.size()) - 1)) {
134         awards[numawards] = awardlongrange;
135         numawards++;
136     }
137     alldead = 1;
138     for (unsigned i = 1; i < Person::players.size(); i++) {
139         if (Person::players[i]->dead != 2)
140             alldead = 0;
141     }
142     if (numafterkill > 0 && alldead) {
143         awards[numawards] = awardbrutal;
144         numawards++;
145     }
146     if (numreversals > ((float)numattacks)*.8 && numreversals > 3) {
147         awards[numawards] = awardaikido;
148         numawards++;
149     }
150     if (maxalarmed == 1 && Person::players.size() > 2) {
151         awards[numawards] = awardstrategy;
152         numawards++;
153     }
154     if (numflipfail > 3) {
155         awards[numawards] = awardklutz;
156         numawards++;
157     }
158     return numawards;
159 }