diff --git a/main.odin b/main.odin index 375b521..e02b9f5 100644 --- a/main.odin +++ b/main.odin @@ -48,7 +48,6 @@ main :: proc() { defer deleteGameData(&game) // Clean up game data // Main game loop - // fmt.println(game) printGame(&game) winner: int = -1 for winner == -1 { @@ -59,5 +58,9 @@ main :: proc() { winner = checkWinner(&game) } - fmt.printfln("%v wins! They had %v points!", game.names[winner], getScore(&game, winner)) + fmt.printfln( + "%v wins! They had %v points!", + game.names[winner], + getScore(&game, winner) + ) } diff --git a/phase10.odin b/phase10.odin index f06f80f..16f22d4 100644 --- a/phase10.odin +++ b/phase10.odin @@ -31,6 +31,10 @@ addScores :: proc(game: ^Game) { fmt.println() fmt.print("Scores: ") newScores := getSpaceDelimetedItems(buf[:]) + if len(newScores) != len(game.names) { + fmt.println("[ERROR] == Invalid number of scores") + return + } defer delete(newScores) for score, index in newScores { intScore, _ := strconv.parse_int(score) @@ -101,6 +105,7 @@ checkWinner :: proc(game: ^Game) -> int { return -1 } +// Print state of the game as a nice table printGame :: proc(game: ^Game) { fmt.printf("Name\tScore\tPhase\n") fmt.printf("----\t-----\t-----\n")