phase-10-tracker/main.odin

53 lines
1.3 KiB
Odin
Raw Normal View History

2026-02-15 20:58:06 +00:00
/*
----------------
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.
*/
2026-02-15 23:17:10 +00:00
package phase10
2026-02-15 20:58:06 +00:00
import "core:fmt"
main :: proc() {
// Prompt for names
buf: [2048]byte
names := getNames(buf[:])
defer delete(names)
2026-02-15 23:17:10 +00:00
// Create game
game: Game
2026-02-15 20:58:06 +00:00
for name in names {
2026-02-16 01:30:11 +00:00
addPlayer(&game, name)
2026-02-15 20:58:06 +00:00
}
2026-02-15 23:17:10 +00:00
defer deleteGameData(&game) // Clean up game data
2026-02-15 20:58:06 +00:00
2026-02-16 01:30:11 +00:00
// Main game loop
printGame(&game)
winner: int = -1
for winner == -1 {
2026-02-15 23:17:10 +00:00
addScores(&game)
2026-02-16 01:30:11 +00:00
updatePhasesByScores(&game)
// fmt.println(game)
printGame(&game)
2026-02-15 23:17:10 +00:00
winner = checkWinner(&game)
}
2026-02-19 01:51:19 +00:00
// Print winner
2026-02-18 21:50:34 +00:00
fmt.printfln(
"%v wins! They had %v points!",
game.names[winner],
getScore(&game, winner)
)
2026-02-19 01:51:19 +00:00
exportGame(&game, "game.csv")
2026-02-15 20:58:06 +00:00
}