-
Notifications
You must be signed in to change notification settings - Fork 0
/
Daytime.java
154 lines (138 loc) · 2.86 KB
/
Daytime.java
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/**
*
*/
/** Daytime keeps track of the current time in the game and the light that is appropriate for that time. It also keeps
* track of the number of days that have passed.
* @author Team Red
*
*/
public class Daytime {
private static int light; //light value
private static int currentmin; //number of mins
private static int currenthour; //number of hours
private static int days; //number of days
public static void main (String[] args) {
}
/** Constructor for Daytime class
*
*
* */
public Daytime(){
light = 0;
currentmin = 0;
currenthour = 0;
}
/** Adds time (2 min) after each action to determine the light value
*
*
* */
public static void addTime(){
//24 hour clock: 0 to 23
currentmin = currentmin + 2;
//resets currentmin once it has hit 60
if(currentmin == 60){
currentmin = 0;
currenthour++;
}
//resets currenthour once it has hit 24
if(currenthour == 24){
currenthour = 0;
days++;
}
//sets light value based on current hour
if(currenthour == 0){
setLightValue(1);
}
else if(currenthour == 1){
setLightValue(0);
}
else if(currenthour == 2){
setLightValue(1);
}
else if(currenthour == 3){
setLightValue(2);
}
else if(currenthour == 4){
setLightValue(3);
}
else if(currenthour == 5){
setLightValue(4);
}
else if(currenthour == 6){
setLightValue(5);
}
else if(currenthour == 7){
setLightValue(6);
}
else if(currenthour == 8){
setLightValue(7);
}
else if(currenthour == 9){
setLightValue(8);
}
else if(currenthour == 10){
setLightValue(9);
}
else if(currenthour == 11){
setLightValue(10);
}
else if(currenthour == 12){
setLightValue(11);
}
else if(currenthour == 13){
setLightValue(12);
}
else if(currenthour == 14){
setLightValue(11);
}
else if(currenthour == 15){
setLightValue(10);
}
else if(currenthour == 16){
setLightValue(9);
}
else if(currenthour == 17){
setLightValue(8);
}
else if(currenthour == 18){
setLightValue(7);
}
else if(currenthour == 19){
setLightValue(6);
}
else if(currenthour == 20){
setLightValue(5);
}
else if(currenthour == 21){
setLightValue(4);
}
else if(currenthour == 22){
setLightValue(3);
}
else if(currenthour == 23){
setLightValue(2);
}
}
/** Returns the time for general use
*
* @return Current time in format "<hour>:<minute>"
* */
public static String getTime(){
String totalTime = currenthour + ":" + currentmin +"\n";
return totalTime;
}
/** Sets light value based on hour
*
* @param addLight int that is the new light value derived from the current hour
* */
public static void setLightValue(int addLight){
light = addLight;
}
/** Returns the light value for use by NPCs and Rooms
*
* @return light
* */
public static int getLightValue(){
return light;
}
}