forked from Noxeangel/DEMOG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.js
134 lines (118 loc) · 4.06 KB
/
player.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
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
function ISODateString(d){
function pad(n){return n<10 ? '0'+n : n}
return d.getUTCFullYear()+'-'
+ pad(d.getUTCMonth()+1)+'-'
+ pad(d.getUTCDate())+'T'
+ pad(d.getUTCHours())+':'
+ pad(d.getUTCMinutes())+':'
+ pad(d.getUTCSeconds())+'Z'
}
var player = function()
{
this.score = 0;
this.currentRepetition = 1;
this.result = new PlayerResult();
};
player.prototype.InitResult = function(userid, amazonid)
{
this.result.init(userid, amazonid);
};
player.prototype.GetResult = function()
{
this.result.updateTotalScore(this.score);
return this.result;
};
player.prototype.SetGameResultRabbits = function(gameid, isSharer,total, given, kept, timesMissed, distanceSeesaw, balloonsPopped, gameLength, isP1)
{
this.result.addGameResultRabbits(gameid,this.currentRepetition, isSharer,total, given, kept, this.score, timesMissed, distanceSeesaw, balloonsPopped, gameLength, isP1);
};
player.prototype.SetGameResultSpace = function(gameid, isSharer,total, given, kept, shotsFired, enemyKilled, distanceToMothership, gameLength, isP1, gotMothership)
{
this.result.addGameResultSpace(gameid,this.currentRepetition, isSharer,total, given, kept, this.score, shotsFired, enemyKilled, distanceToMothership, gameLength, isP1, gotMothership);
};
var PlayerResult = function()
{
this.amazonId;
this.userid;
this.firstConnection;
this.status;
this.lostPartner;
this.IPaddress;
this.WaitingTimeLobby1;
this.WaitingTimeLobby2;
this.currentGame;
this.timedOut;
this.tabActive;
this.switchTabNum;
this.gameLog;
};
PlayerResult.prototype.init = function(userid, amazonId)
{
this.amazonId = amazonId;
this.totalScore = -1;
this.userid = userid;
this.firstConnection = ISODateString(new Date());
this.lostPartner = -1;
this.IPaddress = -1;
this.WaitingTimeLobby1 = new Date().getTime();
this.WaitingTimeLobby2 = new Date().getTime();
this.currentGame = 1;
this.timedOut = false;
this.tabActive = true;
this.switchTabNum = 0;
this.gameLog = [];
};
PlayerResult.prototype.updateStatus = function(status)
{
this.status = status;
};
PlayerResult.prototype.updateTotalScore = function(score)
{
this.totalScore = score;
};
PlayerResult.prototype.updateIP = function(ip)
{
this.IPaddress = ip;
};
PlayerResult.prototype.addGameResultRabbits = function(gameid,currentRepetition, isSharer,total, given, kept, presentScore,timesMissed,distanceSeesaw,balloonsPopped, gameLength, isP1)
{
this.gameLog.push(new GameResultRabbits(gameid, currentRepetition,isSharer, total, given, kept, presentScore,timesMissed,distanceSeesaw,balloonsPopped, gameLength, isP1));
};
PlayerResult.prototype.addGameResultSpace = function(gameid,currentRepetition, isSharer,total, given, kept, presentScore,shotsFired, enemyKilled, distanceToMothership, gameLength, isP1, gotMothership)
{
this.gameLog.push(new GameResultSpace(gameid, currentRepetition,isSharer, total, given, kept, presentScore,shotsFired, enemyKilled, distanceToMothership, gameLength, isP1, gotMothership));
};
var GameResultRabbits = function(gameid,repetition, isSharer,total, given, kept, presentScore, timesMissed,distanceSeesaw,balloonsPopped, gameLength, isP1)
{
this.gameid = gameid;
this.repetition = repetition;
this.gameScore = total;
this.isSharer = isSharer;
this.given = given;
this.kept = kept;
this.presentScore = presentScore;
this.timesMissed = timesMissed;
this.distanceSeesaw = distanceSeesaw;
this.balloonsPopped = balloonsPopped;
this.gameLength = gameLength;
this.isP1 = isP1;
};
var GameResultSpace = function(gameid, repetition, isSharer,total, given, kept, presentScore, shotsFired, enemyKilled, distanceToMothership, gameLength, isP1, gotMothership)
{
this.gameid = gameid;
this.repetition = repetition;
this.gameScore = total;
this.isSharer = isSharer;
this.given = given;
this.kept = kept;
this.presentScore = presentScore;
this.shotsFired = shotsFired;
this.enemyKilled = enemyKilled;
this.distanceToMothership = distanceToMothership;
this.gameLength = gameLength;
this.isP1 = isP1;
this.gotMothership = gotMothership;
};
if( 'undefined' != typeof global ) {
module.exports = global.player = player;
}