private bool validInput(string msg, ref int[] start, ref int[] target) { if (msg.Length < 4) { return(false); } msg = msg.ToUpper(); string startMsg = msg.Substring(0, 2); string targetMsg = msg.Substring(2, 2); if (ClientUtil.stringToCoord(startMsg, ref start) == false || ClientUtil.stringToCoord(targetMsg, ref target) == false) { return(false); } return(true); }
protected override void playMove(string input) { string move = MainClass.playBotMove(input); int[] start = new int[2], target = new int[2]; if (ClientUtil.stringToCoord(move.Substring(0, 2), ref start) == false || ClientUtil.stringToCoord(move.Substring(2, 2), ref target) == false) { return; } if (botColor == Game.PlayerColor.Black) { ClientUtil.rotateCoords(boardHeight, ref start, ref target); } move = ClientUtil.moveToString(start, target); MainThread.fireEventAtMainThread(() => { theClientController.onOutgoingLocalMsg(move, botColor); }); }
protected override void readTCPMsg(ReceivedLocalMessage msg) { if (waitingForInput == false) { return; } int[] start = new int[2], target = new int[2]; if (validInput(msg.message, ref start, ref target) == false) { requestMove(lastBoardMsg); return; } if (lastBoardMsg.updateNumber % 2 != 0) { ClientUtil.rotateCoords(lastBoardMsg.board.GetLength(1), ref start, ref target); } string outString = ClientUtil.moveToString(start, target); onOutgoingLocalMsg(outString, lastBoardMsg.updateNumber % 2 == 0 ? PlayerColor.White : PlayerColor.Black); waitingForInput = false; }