git repos / blockattack-game

blame: source/code/highscore.h

normal view · raw

89c4a3a6 sago007 2008-08-29 14:32 1
/*
c53e6443 sago007 2012-04-17 11:04 2
===========================================================================
c53e6443 sago007 2012-04-17 11:04 3
blockattack - Block Attack - Rise of the Blocks
c53e6443 sago007 2012-04-17 11:04 4
Copyright (C) 2005-2012 Poul Sander
89c4a3a6 sago007 2008-08-29 14:32 5
c53e6443 sago007 2012-04-17 11:04 6
This program is free software: you can redistribute it and/or modify
c53e6443 sago007 2012-04-17 11:04 7
it under the terms of the GNU General Public License as published by
c53e6443 sago007 2012-04-17 11:04 8
the Free Software Foundation, either version 2 of the License, or
c53e6443 sago007 2012-04-17 11:04 9
(at your option) any later version.
89c4a3a6 sago007 2008-08-29 14:32 10
c53e6443 sago007 2012-04-17 11:04 11
This program is distributed in the hope that it will be useful,
c53e6443 sago007 2012-04-17 11:04 12
but WITHOUT ANY WARRANTY; without even the implied warranty of
c53e6443 sago007 2012-04-17 11:04 13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c53e6443 sago007 2012-04-17 11:04 14
GNU General Public License for more details.
89c4a3a6 sago007 2008-08-29 14:32 15
c53e6443 sago007 2012-04-17 11:04 16
You should have received a copy of the GNU General Public License
c53e6443 sago007 2012-04-17 11:04 17
along with this program.  If not, see http://www.gnu.org/licenses/
89c4a3a6 sago007 2008-08-29 14:32 18
c53e6443 sago007 2012-04-17 11:04 19
Source information and contacts persons can be found at
021de090 sago007 2015-12-30 18:56 20
http://blockattack.net
c53e6443 sago007 2012-04-17 11:04 21
===========================================================================
89c4a3a6 sago007 2008-08-29 14:32 22
*/
89c4a3a6 sago007 2008-08-29 14:32 23
89c4a3a6 sago007 2008-08-29 14:32 24
#include <iostream>
89c4a3a6 sago007 2008-08-29 14:32 25
#include <cstring>
89c4a3a6 sago007 2008-08-29 14:32 26
#include <string>
89c4a3a6 sago007 2008-08-29 14:32 27
#include <stdlib.h>
7a956470 sago007 2016-02-14 17:09 28
#include <vector>
89c4a3a6 sago007 2008-08-29 14:32 29
c3b697c6 sago007 2016-02-07 17:30 30
#ifndef HIGHSCORE_H
c3b697c6 sago007 2016-02-07 17:30 31
#define HIGHSCORE_H
c3b697c6 sago007 2016-02-07 17:30 32
89c4a3a6 sago007 2008-08-29 14:32 33
const int top = 10;
89c4a3a6 sago007 2008-08-29 14:32 34
89c4a3a6 sago007 2008-08-29 14:32 35
struct record
89c4a3a6 sago007 2008-08-29 14:32 36
{
7a956470 sago007 2016-02-14 17:09 37
	std::string name;
7a956470 sago007 2016-02-14 17:09 38
	int score = 0;
89c4a3a6 sago007 2008-08-29 14:32 39
};
89c4a3a6 sago007 2008-08-29 14:32 40
dfdb7d66 sago007 2015-11-29 19:21 41
89c4a3a6 sago007 2008-08-29 14:32 42
class Highscore
89c4a3a6 sago007 2008-08-29 14:32 43
{
89c4a3a6 sago007 2008-08-29 14:32 44
private:
7a956470 sago007 2016-02-14 17:09 45
	std::vector<record> table;
90e6c797 sago007 2015-11-22 21:46 46
	std::string filename;
7a956470 sago007 2016-02-14 17:09 47
	std::string type;
c53e6443 sago007 2012-04-17 11:04 48
	void writeFile();
4379ec19 Poul Sander 2019-01-30 18:27 49
	double speed = 0.5;
89c4a3a6 sago007 2008-08-29 14:32 50
public:
4379ec19 Poul Sander 2019-01-30 18:27 51
	Highscore(const std::string& type, double speed);
89c4a3a6 sago007 2008-08-29 14:32 52
c53e6443 sago007 2012-04-17 11:04 53
	bool isHighScore(int);
8f632c05 sago007 2015-08-22 16:21 54
	void addScore(const std::string& newName, int);
7a956470 sago007 2016-02-14 17:09 55
	record getScoreNumber(int);
89c4a3a6 sago007 2008-08-29 14:32 56
};
c3b697c6 sago007 2016-02-07 17:30 57
c3b697c6 sago007 2016-02-07 17:30 58
#endif