-
Notifications
You must be signed in to change notification settings - Fork 0
/
tix.js
85 lines (76 loc) · 1.96 KB
/
tix.js
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
var tixRemain = [];
var tixMove = []; // TODO use to show tix movement
var tixText = ["VIP", "investor", "collector"];
var tixColors = ["pink", "brown", "white"];
var TCOLpink = 0;
var TCOLbrown = 1;
var TCOLwhite = 2;
var TLOCremain = 0;
var TLOCplayer = 1;
function TixPile(numTix, tixColor, loc) {
this.numTix = numTix;
this.color = tixColor;
if (loc == TLOCremain) {
this.currX = 858 + 112*tixColor;
this.currY = 590;
} else {
// assume TLOCplayer
this.currX = 430;
this.currY = 840 + 32*tixColor;
}
this.anime = 0;
}
TixPile.prototype.draw = function() {
ctx.fillStyle = 'black';
ctx.fillText(this.numTix, this.currX - 10+2, this.currY + 10+2);
ctx.fillStyle = 'yellow';
ctx.fillText(this.numTix, this.currX - 10, this.currY + 10);
}
TixPile.prototype.pile2player = function(pl) {
peeps[pl].tix[this.color].numTix++;
if (this.numTix != 0) {
this.numTix--;
if (!this.numTix && !intermediateScoring) {
intermediateScoring = 1;
}
if (!this.numTix) {
checkTixEOG();
}
} else {
// ticket color already at 0
// decrement another ticket color
for (var c=0; c<3; c++) {
if (tixRemain[c].numTix) {
tixRemain[c].numTix--;
checkTixEOG();
break;
}
}
}
// TODO add animation stuff
//~ this.destX = 430;
//~ this.destY = 840 + 32*this.color;
}
TixPile.prototype.playerUse = function() {
if (this.numTix) {
this.numTix--;
}
// TODO add stuff for animation
}
TixPile.prototype.lacerda = function() {
if (this.numTix) {
this.numTix--;
if (!this.numTix && !intermediateScoring) {
intermediateScoring = 1;
}
if (!this.numTix) {
checkTixEOG();
}
}
// TODO add stuff for animation
};
function checkTixEOG() {
if ((tixRemain[TCOLpink].numTix + tixRemain[TCOLbrown].numTix + tixRemain[TCOLwhite].numTix) == 0) {
addEOG(0);
}
}