-
Notifications
You must be signed in to change notification settings - Fork 1
/
BaronDestinatr.js
56 lines (43 loc) · 1.06 KB
/
BaronDestinatr.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
//Represents a player in the game
function PlayerVM(Name, Color)
{
var self = this;
//the name of the player
this.Name = ko.observable(Name);
//The color of the player
this.Color = ko.observable(Color);
//the home city of the player
this.Home = ko.observable(null);
//The origin of the player's current trip
this.Origin = ko.observable(null);
//the destination of player's current trip
this.Destination = ko.observable(null);
this.Payout = ko.computed(
function()
{
if(self.Origin() != null && self.Destination() != null)
{
return Payoffs[self.Origin()][self.Destination()];
}
else
{
return null;
}
}
);
}
//Represents a Game
function GameVM(PlayerCount)
{
var self = this;
if(PlayerCount == null) PlayerCount = 4; //default
this.PlayerCount = ko.observable(PlayerCount);
this.Players = ko.observableArray();
this.Start = function()
{
for(var i = 0, l = self.PlayerCount();i<l; i++)
{
self.Players.push( new PlayerVM("Player " + (i+1), "Color") );
}
};
}