-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGame.pde
59 lines (48 loc) · 1.24 KB
/
Game.pde
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
import org.json.*;
class Game {
int gameID;
String playerName = "";
boolean active = false;
int totalHits;
int treasurySize;
int successfulHits;
boolean listingRequestSent = false;
boolean ready = false;
long timeInPlay;
Listing curListing;
Stack listings = new Stack();
int imageSize = 60; // Size of image rectangle
Game(int id) {
gameID = id;
active = true;
totalHits = 0;
successfulHits = 0;
treasurySize = 3;
ready = false;
timeInPlay = millis();
}
void loadListings(JSONArray listings) {
try {
for (int j = 0; j < listings.length(); j++) {
JSONObject listing = (JSONObject)listings.get(j);
String id = listing.get("listing_id").toString();
this.listings.push(new Listing(Integer.parseInt(id))); // change this to initialize images differently
}
this.ready = true; // game is ready!
} catch (Exception e) {
e.printStackTrace();
}
}
void setNextListing() {
curListing = (Listing)listings.pop();
}
boolean isReady() {
return this.ready;
}
void setRequestSent(boolean wasSent) {
this.listingRequestSent = wasSent;
}
void updateGameTime() {
this.timeInPlay = millis();
}
}