]> git.jsancho.org Git - lugaru.git/blob - Source/Awards.cpp
c4eb7650330cf6bb0130170943de537812f6231b
[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 static const int bonus_values[bonus_count] = {
34 #define DECLARE_BONUS(id, name, value, ...) value,
35 #include "Bonuses.def"
36 #undef DECLARE_BONUS
37 };
38
39 void
40 award_bonus(int playerid, int bonusid, int alt_value)
41 {
42     if (playerid != 0)
43         return;
44     bonus = bonusid;
45     bonustime = 0;
46     bonusvalue = alt_value ? alt_value : bonus_values[bonusid];
47 }
48
49 // FIXME: make these per-player
50 float damagetaken;
51 int numfalls;
52 int numflipfail;
53 int numseen;
54 int numresponded;
55 int numstaffattack;
56 int numswordattack;
57 int numknifeattack;
58 int numunarmedattack;
59 int numescaped;
60 int numflipped;
61 int numwallflipped;
62 int numthrowkill;
63 int numafterkill;
64 int numreversals;
65 int numattacks;
66 int maxalarmed;
67
68 int award_awards(int *awards)
69 {
70     int numawards = 0, i;
71     if (damagetaken == 0 && player[0].bloodloss == 0) {
72         awards[numawards] = awardflawless;
73         numawards++;
74     }
75     bool alldead = true;
76     for (i = 1; i < numplayers; i++) {
77         if (player[i].dead != 2)
78             alldead = 0;
79     }
80     if (alldead) {
81         awards[numawards] = awardalldead;
82         numawards++;
83     }
84     alldead = 1;
85     for (i = 1; i < numplayers; i++) {
86         if (player[i].dead != 1)
87             alldead = 0;
88     }
89     if (alldead) {
90         awards[numawards] = awardnodead;
91         numawards++;
92     }
93     if (numresponded == 0 && !numthrowkill) {
94         awards[numawards] = awardstealth;
95         numawards++;
96     }
97     if (numattacks == numstaffattack && numattacks > 0) {
98         awards[numawards] = awardbojutsu;
99         numawards++;
100     }
101     if (numattacks == numswordattack && numattacks > 0) {
102         awards[numawards] = awardswordsman;
103         numawards++;
104     }
105     if (numattacks == numknifeattack && numattacks > 0) {
106         awards[numawards] = awardknifefighter;
107         numawards++;
108     }
109     if (numattacks == numunarmedattack && numthrowkill == 0 && weapons.size() > 0) {
110         awards[numawards] = awardkungfu;
111         numawards++;
112     }
113     if (numescaped > 0) {
114         awards[numawards] = awardevasion;
115         numawards++;
116     }
117     if (numflipfail == 0 && numflipped + numwallflipped * 2 > 20) {
118         awards[numawards] = awardacrobat;
119         numawards++;
120     }
121     if (numthrowkill == numplayers - 1) {
122         awards[numawards] = awardlongrange;
123         numawards++;
124     }
125     alldead = 1;
126     for (i = 1; i < numplayers; i++) {
127         if (player[i].dead != 2)
128             alldead = 0;
129     }
130     if (numafterkill > 0 && alldead) {
131         awards[numawards] = awardbrutal;
132         numawards++;
133     }
134     if (numreversals > ((float)numattacks)*.8 && numreversals > 3) {
135         awards[numawards] = awardaikido;
136         numawards++;
137     }
138     if (maxalarmed == 1 && numplayers > 2) {
139         awards[numawards] = awardstrategy;
140         numawards++;
141     }
142     if (numflipfail > 3) {
143         awards[numawards] = awardklutz;
144         numawards++;
145     }
146     return numawards;
147 }