phase-10-tracker/main.odin

53 lines
1.3 KiB
Odin

/*
----------------
Phase 10 Tracker
----------------
This program helps the user keep track of a game of Phase 10 as it is being
played. It will keep track of players and their scores over the course of the
game, inferring which phase they are on based on their score.
To use the program, first you will input the first names of all of the
players, seperated by spaces. Then, after each round is finished, you will
enter the score of each player's hand, again seperated by spaces and in the
same order that the names were supplied.
*/
package phase10
import "core:fmt"
main :: proc() {
// Prompt for names
buf: [2048]byte
names := getNames(buf[:])
defer delete(names)
// Create game
game: Game
for name in names {
addPlayer(&game, name)
}
defer deleteGameData(&game) // Clean up game data
// Main game loop
printGame(&game)
winner: int = -1
for winner == -1 {
addScores(&game)
updatePhasesByScores(&game)
// fmt.println(game)
printGame(&game)
winner = checkWinner(&game)
}
// Print winner
fmt.printfln(
"%v wins! They had %v points!",
game.names[winner],
getScore(&game, winner)
)
exportGame(&game, "game.csv")
}