summaryrefslogtreecommitdiffstats
path: root/ksirtet/ksirtet/check_score.cpp
blob: f6c97210b945cb18af057d4251e7e65118ede2a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream.h>

#include <kcmdlineargs.h>


int main(int argc, char **argv)
{
    // read argument
	TDECmdLineArgs::init(argc, argv, "check_score", 0, 0, true);
	static TDECmdLineOptions options[] =
		{ {"+file", "Count of removed lines", 0} };
	TDECmdLineArgs::addCmdLineOptions(options);
	TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
    if ( args->count()==0 ) TDECmdLineArgs::usage();
	TQString s = args->arg(0);
	bool ok;
	uint nb = s.toUInt(&ok);
	if ( !ok ) tqFatal("The argument is not an unsigned integer.");

    cout << "--------------" << endl;

    // constants
    const uint width = 10;
    const uint height = 22;
    const uint nbLinesPerLevel = 10;
    const uint blocksPerPiece = 4;

	// compute level
	uint level = (nb / nbLinesPerLevel) + 1;
	cout << "Level : " << level << endl << endl;

    // compute max score due to drop down
    uint ddScore =
        ((width*height) / blocksPerPiece) * height; // board full of pieces
    ddScore +=
        ((nb * width) / blocksPerPiece) * height; // piece for removed lines
    cout << "Max Score from drop down pieces : " << ddScore << endl;

    // compute max score due to removed lines
    uint score = 0;
    uint nb_tetris = 0;
    while ( nb>=4 ) {
        nb -= 4;
        level = (nb / nbLinesPerLevel) + 1;
        score += 1200 * level;
        nb_tetris++;
    }
    if ( nb==3 ) score += 300;
    else if ( nb==2 ) score += 100;
    else if ( nb==1 ) score += 40;
    cout << "Max score from removed lines : " << score << endl;
    cout << "Max count of tetris : " << nb_tetris << endl;

    cout << endl;
    cout << "Max score : " << ddScore + score << endl;

    cout << "--------------" << endl;
	return 0;
}