-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayer.js
111 lines (96 loc) · 3.64 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
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)
{
this.result.addGameResultRabbits(gameid,this.currentRepetition, isSharer,total, given, kept, this.score, timesMissed, distanceSeesaw, balloonsPopped, gameLength);
};
player.prototype.SetGameResultSpace = function(gameid, isSharer,total, given, kept, p1ShotsFired,p2ShotsFired, p1EnemyKilled, p2EnemyKilled, p1DistanceToMothership, p2DistanceToMothership, gameLength)
{
this.result.addGameResultSpace(gameid,this.currentRepetition, isSharer,total, given, kept, this.score, p1ShotsFired, p2ShotsFired, p1EnemyKilled, p2EnemyKilled, p1DistanceToMothership, p2DistanceToMothership, gameLength);
};
var PlayerResult = function()
{
this.userid;
this.amazonId;
this.status;
this.totalScore;
this.gameLog;
this.lostPartner;
this.IPaddress;
};
PlayerResult.prototype.init = function(userid, amazonId)
{
this.userid = userid;
this.amazonId = amazonId;
this.totalScore = 0;
this.gameLog = [];
this.lostPartner = 0;
this.IPaddress = -1;
};
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)
{
this.gameLog.push(new GameResultRabbits(gameid, currentRepetition,isSharer, total, given, kept, presentScore,timesMissed,distanceSeesaw,balloonsPopped, gameLength));
};
PlayerResult.prototype.addGameResultSpace = function(gameid,currentRepetition, isSharer,total, given, kept, presentScore,p1ShotsFired,p2ShotsFired, p1EnemyKilled, p2EnemyKilled, p1DistanceToMothership, p2DistanceToMothership, gameLength)
{
this.gameLog.push(new GameResultSpace(gameid, currentRepetition,isSharer, total, given, kept, presentScore,p1ShotsFired,p2ShotsFired, p1EnemyKilled, p2EnemyKilled, p1DistanceToMothership, p2DistanceToMothership, gameLength));
};
var GameResultRabbits = function(gameid,repetition, isSharer,total, given, kept, presentScore, timesMissed,distanceSeesaw,balloonsPopped, gameLength)
{
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;
};
var GameResultSpace = function(gameid,repetition, isSharer,total, given, kept, presentScore, p1ShotsFired,p2ShotsFired, p1EnemyKilled, p2EnemyKilled, p1DistanceToMothership, p2DistanceToMothership, gameLength)
{
this.gameid = gameid;
this.repetition = repetition;
this.gameScore = total;
this.isSharer = isSharer;
this.given = given;
this.kept = kept;
this.presentScore = presentScore;
this.p1ShotsFired = p1ShotsFired;
this.p2ShotsFired = p2ShotsFired;
this.p1EnemyKilled = p1EnemyKilled;
this.p2EnemyKilled = p2EnemyKilled;
this.p1DistanceToMothership = p1DistanceToMothership;
this.p2DistanceToMothership = p2DistanceToMothership;
this.gameLength = gameLength;
};
if( 'undefined' != typeof global ) {
module.exports = global.player = player;
}