1 /* Tower Toppler - Nebulus
2  * Copyright (C) 2000-2012  Andreas R�ver
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18 
19 #include "points.h"
20 #include "decl.h"
21 #include "configuration.h"
22 
23 static unsigned int points;
24 static unsigned long nextlife;
25 static int lifes;
26 
27 #define LIFE_INCREMENT 5000
28 
pts_reset(void)29 void pts_reset(void) {
30   points = 0;
31   lifes = config.start_lives();
32   nextlife = LIFE_INCREMENT;
33 }
34 
pts_add(int add)35 void pts_add(int add) {
36   points += add;
37 
38   while (points >= nextlife) {
39     nextlife += LIFE_INCREMENT;
40     lives_add();
41   }
42 }
43 
lives_add(void)44 void lives_add(void) {
45     lifes++;
46     if (lifes > 8)
47       lifes = 8;
48 }
49 
pts_points(void)50 unsigned int pts_points(void) {
51   return points;
52 }
53 
pts_lifes(void)54 unsigned char pts_lifes(void) {
55   return lifes;
56 }
57 
pts_died(void)58 void pts_died(void) {
59   lifes--;
60 }
61 
pts_lifesleft(void)62 bool pts_lifesleft(void) {
63   return lifes != 0;
64 }
65 
66