| } | } | ||||
| func main() { | func main() { | ||||
| rand.Seed(time.Now().UnixNano()) // Keep this the first line in main() | |||||
| barb := Class{"Barbarian", 12, []string{"Int", "Wis", "Cha", "Dex", "Con", "Str"}} | barb := Class{"Barbarian", 12, []string{"Int", "Wis", "Cha", "Dex", "Con", "Str"}} | ||||
| rand.Seed(time.Now().UnixNano()) | |||||
| fmt.Println("=== Generated D&D character ===") | fmt.Println("=== Generated D&D character ===") | ||||
| rolls := stats() | rolls := stats() | ||||
| fmt.Println("Rolls: ", rolls) | fmt.Println("Rolls: ", rolls) | ||||
| for k, v := range barb.StatPriority { | for k, v := range barb.StatPriority { | ||||
| ply.Stats[v] = rolls[k] | ply.Stats[v] = rolls[k] | ||||
| } | } | ||||
| fmt.Println(ply) | |||||
| fmt.Printf("%s - %s\n", ply.Name, ply.Class.Name) | |||||
| fmt.Printf("Str: %d\tInt: %d\nDex: %d\tWis: %d\nCon: %d\tCha: %d\n", | |||||
| ply.Stats["Str"], | |||||
| ply.Stats["Int"], | |||||
| ply.Stats["Dex"], | |||||
| ply.Stats["Wis"], | |||||
| ply.Stats["Con"], | |||||
| ply.Stats["Cha"]) | |||||
| } | } |