// TODO: rely on turn instead of slot! public Error GetPieceInfo(string gameId, int slot, int piece, out PieceInfo pieceInfo) { pieceInfo = null; var err = ludoService.GetIngame(gameId, out var ingame); if (err) { return(err); } var ts = ingame.GetPieceInfo(piece, out pieceInfo); if (ts.slot == slot) // TODO: rely on turn instead of slot! { return(Error.Codes.E00NoError); // <- good path } if (!ingame.IsValidSlot(slot)) { return(Error.Codes.E10InvalidSlotIndex); } if (ingame.Slots[slot] == null) { return(Error.Codes.E16SlotIsEmpty); } if (ts.turn == 0) { return(Error.Codes.E17GameNotStarted); } if (ts.slot == -1) { return(Error.Codes.E18InvalidPieceIndex); } // slot is valid but not what we expected: return(Error.Codes.E15NotYourTurn); }
public Error MovePiece(string gameId, int slot, int piece) { var err = ludoService.GetIngame(gameId, out var ingame); if (err) { return(err); } return(ingame.MovePiece(slot, piece)); }
public Error TryGetBoardState(string gameId, out BoardState bstate) { bstate = default; var err = ludoService.GetIngame(gameId, out var ingame); if (err) { return(err); } bstate = ingame.GetBoardState(); return(Error.Codes.E00NoError); }
public Error GetCurrent(string gameId, out TurnSlotDie turnSlotDie) { turnSlotDie = null; var err = ludoService.GetIngame(gameId, out var ingame); if (err) { return(err); } turnSlotDie = ingame.GetCurrent(); return(Error.Codes.E00NoError); }
public Error PassTurn(string gameId, int slot) { var err = ludoService.GetIngame(gameId, out var ingame); if (err) { return(err); } if (!ingame.IsValidSlot(slot)) { return(Error.Codes.E10InvalidSlotIndex); } if (ingame.Slots[slot] == null) { return(Error.Codes.E16SlotIsEmpty); } return(ingame.TryPassTrun(slot) ? Error.Codes.E00NoError : Error.Codes.E15NotYourTurn); }
public Error GetTurnInfo(string gameId, int slot, out TurnInfo turnInfo) { turnInfo = null; var err = ludoService.GetIngame(gameId, out var ingame); if (err) { return(err); } if (!ingame.IsValidSlot(slot)) { return(Error.Codes.E10InvalidSlotIndex); } if (ingame.Slots[slot] == null) { return(Error.Codes.E16SlotIsEmpty); } turnInfo = ingame.TryGetTurnInfo(slot); return(turnInfo == null ? Error.Codes.E15NotYourTurn : Error.Codes.E00NoError); }