Newer
Older
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package GUI.game;
/**
*
* @author Kovax
*/
public class ScoreCounter extends Thread
{
Controller controller;
int score;
Boolean enabled;
public ScoreCounter(Controller controller)
{
this.controller = controller;
this.enabled = false;
}
public void resetCounter()
{
this.score = 0;
}
public void startCounter()
{
this.enabled = true;
}
@Override
public void run()
{
synchronized(this)
{
while( true )
{
try
{
int time = controller.model.getTimeLeft();
int mines = controller.model.getMines();
int uncovered = controller.model.getUncoveredFields();
int covered = ( this.controller.settings.size * this.controller.settings.size ) - uncovered;
if( this.controller.settings.level == 0 )
{
//this.score += this.score*1.5;
}
else if( this.controller.settings.level == 1 )
{
this.score = ( covered * mines * 8 ) / (time+1) + covered;
}
else if( this.controller.settings.level == 2 )
{
this.score = ( mines * 10 ) / time+1 + covered;
}
else if( this.controller.settings.level == 3 )
{
this.score = ( mines * 15 ) / time+1 + covered;
}
this.controller.setScore(score);
sleep(1000);
} catch (InterruptedException ex)
{
System.out.println("int error");
}
}
}
}
}