-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.go
73 lines (64 loc) · 1.34 KB
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
/**
* This is the main module. It is responsiple for driving the program.
* @module app
*/
import (
"fmt"
"os"
)
/**
* The entry point for the application.
*/
func main() {
// Load the player data from the disk
var players map[string]Player = loadData()
// Main application loop
for {
_printMenu()
switch _getInput() {
case 0: // The user wants to quit
_quit()
case 1: // The user wants to see all the player data
_printPlayers(players)
case 2: // The user wants to get teams
// IDEA : This should be instanciating an object and running the sim
runSimulation(players)
}
}
}
/**
* Prompts the user for input and returns there input.
* @returns {Int} i The input from the user
*/
func _getInput() (i int) {
fmt.Print("> ")
fmt.Scan(&i)
return
}
/**
* Prints the menu.
* @private
*/
func _printMenu() {
fmt.Print("1) View all players.\n")
fmt.Print("2) Run team creator.\n")
fmt.Print("0) Exit\n")
}
/**
* Prints all the players and there information.
* @param {Array.<String, Player>} The players to print.
*/
func _printPlayers(players map[string]Player) {
fmt.Println(getPlayerTableHeader())
for _, p := range players {
fmt.Println(p.toString())
}
fmt.Print("\n")
}
/**
* Quits the application
*/
func _quit() {
os.Exit(0)
}