package main import ( "encoding/json" "flag" "fmt" "io/ioutil" "math/rand" "os" "time" "gitlab.com/EternalWanderer/dice-roller/Dice" ) var ( path string modifier, diceThrows, surfaces int char Character ) func isError(err error) bool { if err != nil { fmt.Println(err.Error()) } return (err != nil) } func parseFlags() { flag.StringVar(&path, "file", "stats.json", "fock me") flag.Parse() } func readJson() { fmt.Println("Opening file...", path) var file, err = os.Open(path) if isError(err) { return } defer file.Close() byteValue, _ := ioutil.ReadAll(file) json.Unmarshal(byteValue, &char) } func main() { rand.Seed(time.Now().Unix()) parseFlags() readJson() Dice.SimpleCast() charismaChecks() } func charismaChecks() { die := Dice.SimpleCast() proficiencyScore := char.Misc.Proficiency expertiseScore := char.Misc.Proficiency * 2 fmt.Println("proficiencyScore:", proficiencyScore) fmt.Println("expertiseScore:", expertiseScore) fmt.Println("die:", die) if char.Skills.Charisma.Intimidation.Expertise { fmt.Printf("%s's Intimidation check results in %d\n", char.Misc.Name, die+char.Skills.Charisma.Intimidation.Modifier+expertiseScore) fmt.Printf("After all, %s has expertise in intimidation\n", char.Misc.Name) } else if char.Skills.Charisma.Intimidation.Proficient { fmt.Printf("%s's Intimidation check results in %d\n", char.Misc.Name, die+char.Skills.Charisma.Intimidation.Modifier+proficiencyScore) fmt.Printf("After all, %s is proficient with intimidation\n", char.Misc.Name) } }