public MockUser StubMove(ITicTacToeBoxClass.ITicTacToeBox stubBox) { _mock.Setup(m => m.Move(It.IsAny <ITicTacToeBoxClass.ITicTacToeBox>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(stubBox); return(this); }
public ITicTacToeBoxClass.ITicTacToeBox Move( ITicTacToeBoxClass.ITicTacToeBox ticTacToeBox, int move, string playerSymbol, string aISymbol) { return(TicTacToeBoxEdit.insertUserOption(ticTacToeBox , move, playerSymbol, aISymbol)); }
public MockAi StubMove(ITicTacToeBoxClass.ITicTacToeBox stubBox) { _mock.Setup(m => m.Move( It.IsAny <ITicTacToeBoxClass.ITicTacToeBox>(), It.IsAny <GameSettings.gameSetting>())).Returns(stubBox); return(this); }
private string MakeForm(ITicTacToeBoxClass.ITicTacToeBox ticTacToeBox) { var formPage = new StringBuilder(); formPage.Append(@"<form action=""/"" method=""post"">"); formPage.Append(@"<table style=""width: 100 % "">"); for (var i = 0; i < ticTacToeBox.cellCount(); i += 3) { formPage.Append("<tr>"); for (var k = 0; k < ticTacToeBox.victoryCellCount(); k++) { formPage.Append( @"<td><button name=box type=""submit"" value=""" + WebUtility.HtmlEncode(ticTacToeBox.getGlyphAtLocation(i + k)) + @""">" + $"{WebUtility.HtmlEncode(ticTacToeBox.getGlyphAtLocation(i + k))}" + "</button></td>"); } formPage.Append("</tr>"); } formPage.Append(@"</table>"); for (var i = 0; i < ticTacToeBox.cellCount(); i++) { formPage.Append(@"<input type=""hidden"" name=""pos" + i + @""" value=""" + ticTacToeBox.getGlyphAtLocation(i) + @"""><br>"); } formPage.Append(@"</form>"); return(formPage.ToString()); }
private string Form(ITicTacToeBoxClass.ITicTacToeBox ticTacToeBox, TicTacToeGame game, int errorMesageCode, ServerProperties serverProperties) { var form = MakeForm(ticTacToeBox); form = RemoveButton(game.Setting.playerGlyph, form); form = RemoveButton(game.Setting.aIGlyph, form); var errorMessage = errorMesageCode != Translate.Blank ? "<p>" + Translator.translator(Translator.language.english, errorMesageCode) + "</p>" : ""; form = errorMessage += form; if (!game.CheckForWinner((TicTacToeBoxClass.TicTacToeBox)ticTacToeBox)) { return(form); } form = "<p>Game Over</p>" + @"<a href=""http://127.0.0.1:" + serverProperties.Port + @"""><button>Another Game?</button></a>" + form; for (var i = 0; i < ticTacToeBox.cellCount(); i++) { form = RemoveButton("-" + (i + 1) + "-", form); } return(form); }
private bool GameOver(ITicTacToeBoxClass.ITicTacToeBox ticTacToeBox, TicTacToeGame game) { return(CheckForWinnerOrTie .checkForWinnerOrTie(ticTacToeBox, game.Setting.playerGlyph, game.Setting.aIGlyph) != (int)GameStatusCodes.GenResult.NoWinner); }
private string GameFormPage(ITicTacToeBoxClass .ITicTacToeBox ticTacToeBox, TicTacToeGame game, int errorMesageCode, ServerProperties serverProperties) { return(HtmlHeader() + Form(ticTacToeBox, game, errorMesageCode, serverProperties) + HtmlTail()); }
public string SerializeTicTacToeBox (ITicTacToeBoxClass.ITicTacToeBox ticTacToeBox) { var jSonTicTacToeBox = @"{ ""board"" : ["; for (var i = 0; i < ticTacToeBox.cellCount(); i++) { jSonTicTacToeBox += "\"" + ticTacToeBox .getGlyphAtLocation(i) + "\", "; } jSonTicTacToeBox = jSonTicTacToeBox .Substring(0, jSonTicTacToeBox.Length - 2) + @"], ""gameOver"" : ""false""}"; return(jSonTicTacToeBox); }
public ITicTacToeBoxClass.ITicTacToeBox Play( ITicTacToeBoxClass.ITicTacToeBox ticTacToeBox, int move) { if (CheckForWinner((TicTacToeBoxClass.TicTacToeBox) ticTacToeBox)) { return(ticTacToeBox); } var newTicTacToeBox = (TicTacToeBoxClass.TicTacToeBox) _user.Move(ticTacToeBox, move, Setting.playerGlyph, Setting.aIGlyph); return(!CheckForWinner(newTicTacToeBox) ? _aI.Move(newTicTacToeBox, Setting) : newTicTacToeBox); }
public ITicTacToeBoxClass.ITicTacToeBox Move(ITicTacToeBoxClass.ITicTacToeBox ticTacToeBox, int move, string playerSymbol, string aISymbol) { return(_mock.Object.Move(ticTacToeBox, move, playerSymbol, aISymbol)); }
public ITicTacToeBoxClass.ITicTacToeBox Move( ITicTacToeBoxClass.ITicTacToeBox ticTacToeBox, GameSettings.gameSetting settings) { return(AI.aIMove(settings, ticTacToeBox)); }
public ITicTacToeBoxClass.ITicTacToeBox Move( ITicTacToeBoxClass.ITicTacToeBox ticTacToeBox, GameSettings.gameSetting settings) { return(_mock.Object.Move(ticTacToeBox, settings)); }
private string StartingFormPage(ITicTacToeBoxClass.ITicTacToeBox ticTacToeBox) { return(HtmlHeader() + MakeForm(ticTacToeBox) + HtmlTail()); }