Skip to content

Commit

Permalink
basic game VM for #7
Browse files Browse the repository at this point in the history
  • Loading branch information
drdamour committed Jan 6, 2013
1 parent a668798 commit 34f1e5f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
21 changes: 20 additions & 1 deletion BaronDestinatr.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
//Represents a player in the game
function PlayerVM(Name, Color)
{
//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);


Expand All @@ -14,4 +23,14 @@ function PlayerVM(Name, Color)
return null;
}
);
}
}


//Represents a Game
function GameVM(PlayerCount)
{
if(PlayerCount == null) PlayerCount = 4; //default
this.PlayerCount = ko.observable(PlayerCount);
this.Players = ko.observableArray();
}

1 change: 1 addition & 0 deletions Test/BaronDestinatr.Test.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@

<!--Test Sets-->
<script src="PlayerVM.Tests.js"></script>
<script src="GameVM.Tests.js"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions Test/GameVM.Tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module( "GameVM" );
test( "constructor", function() {
ok(GameVM);

var g = new GameVM(4);
equal(g.PlayerCount(), 4);
deepEqual(g.Players(), []);

g = new GameVM();
equal(g.PlayerCount(), 4); //default
deepEqual(g.Players(), []);

g = new GameVM(3);
equal(g.PlayerCount(), 3);
deepEqual(g.Players(), []);
});


test( "constructor invalid parameters", function() {

});

0 comments on commit 34f1e5f

Please sign in to comment.