diff --git a/main.odin b/main.odin index e02b9f5..d1944c1 100644 --- a/main.odin +++ b/main.odin @@ -15,24 +15,6 @@ package phase10 import "core:fmt" -import "core:os" -import "core:strings" - -// Return a slice of space delimited strings from stdin -getSpaceDelimetedItems :: proc(backingBuffer: []byte) -> []string { - count, _ := os.read(os.stdin, backingBuffer) - response := string(backingBuffer[:count - 1]) // leave off the newline - strings.trim_space(response) - items, _ := strings.fields(response) - return items -} - -// Prompt user for names of all players -getNames :: proc(backingBuffer: []byte) -> []string { - fmt.print("Enter Names: ") - return getSpaceDelimetedItems(backingBuffer) -} - main :: proc() { // Prompt for names diff --git a/phase10.odin b/phase10.odin index 16f22d4..a2cdbc8 100644 --- a/phase10.odin +++ b/phase10.odin @@ -1,5 +1,7 @@ package phase10 +import "core:os" +import "core:strings" import "core:strconv" import "core:fmt" import "core:slice" @@ -32,7 +34,7 @@ addScores :: proc(game: ^Game) { fmt.print("Scores: ") newScores := getSpaceDelimetedItems(buf[:]) if len(newScores) != len(game.names) { - fmt.println("[ERROR] == Invalid number of scores") + fmt.println("[ERROR] Invalid number of scores") return } defer delete(newScores) @@ -114,3 +116,18 @@ printGame :: proc(game: ^Game) { game.phases[index]) } } + +// Return a slice of space delimited strings from stdin +getSpaceDelimetedItems :: proc(backingBuffer: []byte) -> []string { + count, _ := os.read(os.stdin, backingBuffer) + response := string(backingBuffer[:count - 1]) // leave off the newline + strings.trim_space(response) + items, _ := strings.fields(response) + return items +} + +// Prompt user for names of all players +getNames :: proc(backingBuffer: []byte) -> []string { + fmt.print("Enter Names: ") + return getSpaceDelimetedItems(backingBuffer) +}