Holy god the windows build better fucking work
[crack-attack.git] / src / Score.h
bloba162e2fa7828233be322cd894ab248abbcf5fc1e
1 /*
2 * Score.h
3 * Daniel Nelson - 8/24/0
5 * Copyright (C) 2000 Daniel Nelson
6 *
7 * This program 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.
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. See the
15 * GNU General Public License for more details.
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.
21 * Daniel Nelson - aluminumangel.org
22 * 174 W. 18th Ave.
23 * Columbus, OH 43210
26 #ifndef SCORE_H
27 #define SCORE_H
29 using namespace std;
31 #include "Game.h"
32 #include "ComboTabulator.h"
33 #include "MetaState.h"
35 class Rank {
36 public:
37 char name[GC_PLAYER_NAME_LENGTH];
38 int score;
41 /* static */ class Score {
42 public:
43 static void initialize ( );
44 static void cleanUp ( );
45 static int gameFinish ( );
47 static bool readScoreRecord ( );
48 static void writeScoreRecord ( );
49 static void setupDefaultScoreRecord ( );
51 static inline void timeStepMeta ( )
53 if (!(MetaState::mode & CM_SOLO)) return;
55 if (fade_timer == 0) return;
56 fade_timer--;
59 static inline void timeStepPlay ( )
61 if (!(MetaState::mode & CM_SOLO)) return;
63 if (fade_timer == 0) {
64 if (backlog > 0) {
65 backlog--;
66 score++;
67 incrementDigits();
68 fade_timer = GC_MAX_SCORE_INCREMENT_DELAY
69 - (GC_SCORE_DELAY_SLOPE * backlog);
70 if (fade_timer < GC_MIN_SCORE_INCREMENT_DELAY) {
71 fade_timer = GC_MIN_SCORE_INCREMENT_DELAY;
72 inverse_timer_start = 1.0f / (GLfloat) GC_MIN_SCORE_INCREMENT_DELAY;
73 } else
74 inverse_timer_start = 1.0f / (GLfloat) fade_timer;
76 } else
77 fade_timer--;
80 static inline void incrementDigits ( )
82 for (int i = GC_NUMBER_DIGITS; i--; )
83 previous_digits[i] = digits[i];
85 int i;
86 for (i = 0; i < GC_NUMBER_DIGITS; i++) {
87 digits[i]++;
88 if (digits[i] != 10) break;
89 digits[i] = 0;
91 if (++i > n_digits_displayed && i <= GC_NUMBER_DIGITS)
92 n_digits_displayed = i;
95 static inline void reportMultiplier ( ComboTabulator &combo )
97 if (!(MetaState::mode & CM_SOLO)) return;
99 // multiply this step's score
100 backlog += combo.base_score_this_step
101 * (combo.multiplier - combo.n_multipliers_this_step - 1);
103 // give another helping of the accumulated score
104 backlog += combo.base_accumulated_score
105 * combo.n_multipliers_this_step;
107 combo.n_multipliers_this_step = 0;
110 static inline int reportElimination ( ComboTabulator &combo )
112 if (!(MetaState::mode & CM_SOLO)) return 0;
114 int points = 0;
116 // gray elimination score
117 if (combo.special_magnitude > 0)
118 points
119 += GC_GRAY_SCORE * (combo.special_magnitude == GC_MIN_PATTERN_LENGTH
120 ? GC_MIN_PATTERN_SCORE
121 : combo.special_magnitude);
123 // colored elimination score
124 else
125 points += (combo.magnitude == GC_MIN_PATTERN_LENGTH
126 ? GC_MIN_PATTERN_SCORE
127 : combo.magnitude);
129 // special block bonuses
130 for (int n = BF_NUMBER_SPECIAL; n--; )
131 points += combo.special[n] * special_block_scores[n];
133 backlog += points;
135 return points;
138 static inline bool Score::topRank ( )
140 return player_rank == GC_SCORE_REC_LENGTH - 1;
143 static int score;
144 static int backlog;
145 static short digits[GC_NUMBER_DIGITS];
146 static short previous_digits[GC_NUMBER_DIGITS];
147 static int fade_timer;
148 static GLfloat inverse_timer_start;
149 static int n_digits_displayed;
151 static int player_rank;
152 static Rank record[GC_SCORE_REC_LENGTH];
154 static int special_block_scores[BF_NUMBER_SPECIAL];
157 #endif