public void FIBS_Board() { // from http://www.fibs.com/fibs_interface.html#board_state var monster = CreateLoggedInCookieMonster(); var s = "board:You:someplayer:3:0:1:0:-2:0:0:0:0:5:0:3:0:0:0:-5:5:0:0:0:-3:0:-5:0:0:0:0:2:0:1:6:2:0:0:1:1:1:0:1:-1:0:25:0:0:0:0:2:0:0:0"; var cm = monster.EatCookie(s); Assert.Equal(FibsCookie.FIBS_Board, cm.Cookie); Assert.Equal("You", cm.Crumbs["player1"]); Assert.Equal("someplayer", cm.Crumbs["player2"]); Assert.Equal(3, int.Parse(cm.Crumbs["matchLength"])); Assert.Equal(0, int.Parse(cm.Crumbs["player1Score"])); Assert.Equal(1, int.Parse(cm.Crumbs["player2Score"])); Assert.Equal("0:-2:0:0:0:0:5:0:3:0:0:0:-5:5:0:0:0:-3:0:-5:0:0:0:0:2:0", cm.Crumbs["board"]); Assert.Equal("O", CookieMonster.ParseBoardTurn(cm.Crumbs["turnColor"])); Assert.Equal("6:2", cm.Crumbs["player1Dice"]); Assert.Equal("0:0", cm.Crumbs["player2Dice"]); Assert.Equal(1, int.Parse(cm.Crumbs["doublingCube"])); Assert.True(CookieMonster.ParseBool(cm.Crumbs["player1MayDouble"])); Assert.True(CookieMonster.ParseBool(cm.Crumbs["player2MayDouble"])); Assert.False(CookieMonster.ParseBool(cm.Crumbs["wasDoubled"])); Assert.Equal("O", CookieMonster.ParseBoardColor(cm.Crumbs["player1Color"])); Assert.Equal(-1, int.Parse(cm.Crumbs["direction"])); Assert.Equal(0, int.Parse(cm.Crumbs["player1Home"])); Assert.Equal(0, int.Parse(cm.Crumbs["player2Home"])); Assert.Equal(0, int.Parse(cm.Crumbs["player1Bar"])); Assert.Equal(0, int.Parse(cm.Crumbs["player2Bar"])); Assert.Equal(2, int.Parse(cm.Crumbs["canMove"])); Assert.Equal(0, int.Parse(cm.Crumbs["redoubles"])); }
public Player(string color, BoardCrumbs b) { Assert.True(color == "O" || color == "X"); this.Color = color; if (CookieMonster.ParseBoardColor(b.player1Color) == this.Color) { Name = b.player1; Score = b.player1Score; Bar = b.player1Bar; Home = b.player1Home; Dice = b.player1Dice == "0:0" ? null : b.player1Dice.Split(':').Select(s => int.Parse(s)).ToArray(); MayDouble = b.player1MayDouble == 1; } else { Name = b.player2; Score = b.player2Score; Bar = b.player2Bar; Home = b.player2Home; Dice = b.player2Dice == "0:0" ? null : b.player2Dice.Split(':').Select(s => int.Parse(s)).ToArray(); MayDouble = b.player2MayDouble == 1; } IsTurn = CookieMonster.ParseTurnColor(b.turnColor) == Color; }