public static Mods.Lua.TurnInfo GetTurnInfo(NextTurnInfo nextTurn) { return(new Mods.Lua.TurnInfo() { ActivePlayer = GetPlayerTag(nextTurn.player), TurnNumber = nextTurn.number, }); }
private EoTScriptState CheckGameOver() { EoTScriptState type = EoTScriptState.Undecided; NextTurnInfo nextTurn = nextTurnInfo.Send(); lastCalcState.TurnInfo = LuaTranslator.GetTurnInfo(nextTurn); lastCalcState.Board = LuaTranslator.GetBoard(board, db); luaHelper.Ready = true; scripts.AddGlobal("winCheckHelper", luaHelperValue); DynValue ret = scripts.CallFunction(db.WinLossCheck, lastCalcState.Board); scripts.RemoveGlobal("winCheckHelper"); luaHelper.Ready = false; foreach (var options in optionCache.Values) { options.Dispose(); } optionCache.Clear(); if (ret.Type != DataType.String) { type = EoTScriptState.Error; } else { switch (ret.String.ToUpperInvariant()) { case Mods.Lua.LuaConstants.GameOverFirstWins: type = EoTScriptState.FirstPlayerWins; break; case Mods.Lua.LuaConstants.GameOverSecondWins: type = EoTScriptState.SecondPlayerWins; break; case Mods.Lua.LuaConstants.GameOverTie: type = EoTScriptState.Tie; break; case Mods.Lua.LuaConstants.GameOverUndecided: type = EoTScriptState.Undecided; break; default: type = EoTScriptState.Error; break; } } return(type); }
private void NextTurnCommand(bool increment) { if (increment) { NextTurnInfo next = FigureNextTurn(); board.TurnNumber++; board.ActivePlayer = next.player; turnChange.Send(); } if (IsLocalPlayerTurn()) { startTurnChoosingCommand.Send(); } }