From a0d6ff1cff28736f2046e70666a1dec5889f90d2 Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Wed, 13 Dec 2023 08:03:57 +0100 Subject: [PATCH 1/8] frontend: backend: add logging, comments and cleanup code --- handlers/skill_calculation_handler.go | 114 ++++++++++++++++++-------- templates/skills.html | 2 +- 2 files changed, 79 insertions(+), 37 deletions(-) diff --git a/handlers/skill_calculation_handler.go b/handlers/skill_calculation_handler.go index 48935cf..a26866f 100644 --- a/handlers/skill_calculation_handler.go +++ b/handlers/skill_calculation_handler.go @@ -8,35 +8,38 @@ import ( "strconv" ) -// SkillCalculationHandler ist ein http.HandlerFunc, der von htmx getriggert wird, -// wenn der Benutzer Einträge in bestimmten Feldern macht, und dann die Skill-Felder befüllt. +// SkillCalculationHandler is an http.HandlerFunc triggered by htmx when the user makes entries in certain fields and then populates the skill fields. func SkillCalculationHandler(content embed.FS) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - log.Print("SkillCalculationHandler called") - - // Überprüfen Sie, ob die Anfrage eine POST-Anfrage ist. + // Check if the request is a POST request. if r.Method != http.MethodPost { - log.Print("Method not allowed") http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) return } - // Parse Formulardaten. + // Parse form data. err := r.ParseForm() if err != nil { - log.Printf("Error parsing form data: %v", err) http.Error(w, err.Error(), http.StatusInternalServerError) return } - tmplFiles := []string{"templates/base.html", "templates/header.html", "templates/skills.html", "templates/main.html", "templates/footer.html", "templates/about.html"} + // Parse template files. + tmplFiles := []string{ + "templates/base.html", + "templates/header.html", + "templates/skills.html", + "templates/main.html", + "templates/footer.html", + "templates/about.html", + } tmpl, err := template.ParseFS(content, tmplFiles...) if err != nil { - log.Printf("Template parsing error: %v\n", err) http.Error(w, err.Error(), http.StatusBadRequest) return } + // Parse form field values and calculate skill values. str := parseFieldValue(r.FormValue("str")) dex := parseFieldValue(r.FormValue("dex")) int := parseFieldValue(r.FormValue("int")) @@ -66,77 +69,116 @@ func SkillCalculationHandler(content embed.FS) http.HandlerFunc { "survival": strconv.Itoa(calcAbilityScore(wis) + crBonus), } + // Execute template with skill values. err = tmpl.ExecuteTemplate(w, "skills", skillValues) if err != nil { - log.Printf("Template execution error: %v\n", err) http.Error(w, err.Error(), http.StatusBadRequest) } } } +// calcBonus calculates the bonus based on the given credit rating. +// It returns the bonus value as an integer. func calcBonus(cr int) int { - if cr >= 0 && cr < 5 { + switch { + case cr >= 0 && cr < 5: + log.Println("Bonus calculated for credit rating:", cr) return 2 - } else if cr >= 5 && cr < 9 { + case cr >= 5 && cr < 9: + log.Println("Bonus calculated for credit rating:", cr) return 3 - } else if cr >= 9 && cr < 14 { + case cr >= 9 && cr < 14: + log.Println("Bonus calculated for credit rating:", cr) return 4 - } else if cr >= 14 && cr < 18 { + case cr >= 14 && cr < 18: + log.Println("Bonus calculated for credit rating:", cr) return 5 - } else if cr >= 18 && cr < 21 { + case cr >= 18 && cr < 21: + log.Println("Bonus calculated for credit rating:", cr) return 6 - } else if cr >= 21 && cr < 25 { + case cr >= 21 && cr < 25: + log.Println("Bonus calculated for credit rating:", cr) return 7 - } else if cr >= 25 && cr < 28 { + case cr >= 25 && cr < 28: + log.Println("Bonus calculated for credit rating:", cr) return 8 - } else if cr >= 28 && cr < 31 { + case cr >= 28 && cr < 31: + log.Println("Bonus calculated for credit rating:", cr) return 9 - } else { + default: + log.Println("Invalid credit rating:", cr) return 0 } } +// calcAbilityScore calculates the ability score based on the given value. func calcAbilityScore(val int) int { - if val < 2 { + switch { + case val < 2: + log.Println("Ability Score: -5") return -5 - } else if val >= 2 && val < 4 { + case val < 4: + log.Println("Ability Score: -4") return -4 - } else if val >= 4 && val < 6 { + case val < 6: + log.Println("Ability Score: -3") return -3 - } else if val >= 6 && val < 8 { + case val < 8: + log.Println("Ability Score: -2") return -2 - } else if val >= 8 && val < 10 { + case val < 10: + log.Println("Ability Score: -1") return -1 - } else if val >= 10 && val < 12 { + case val < 12: + log.Println("Ability Score: 0") return 0 - } else if val >= 12 && val < 14 { + case val < 14: + log.Println("Ability Score: 1") return 1 - } else if val >= 14 && val < 16 { + case val < 16: + log.Println("Ability Score: 2") return 2 - } else if val >= 16 && val < 18 { + case val < 18: + log.Println("Ability Score: 3") return 3 - } else if val >= 18 && val < 20 { + case val < 20: + log.Println("Ability Score: 4") return 4 - } else if val >= 20 && val < 22 { + case val < 22: + log.Println("Ability Score: 5") return 5 - } else if val >= 22 && val < 24 { + case val < 24: + log.Println("Ability Score: 6") return 6 - } else if val >= 24 && val < 26 { + case val < 26: + log.Println("Ability Score: 7") return 7 - } else if val >= 26 && val < 28 { + case val < 28: + log.Println("Ability Score: 8") return 8 - } else if val >= 28 && val < 30 { + case val < 30: + log.Println("Ability Score: 9") return 9 - } else { + default: + log.Println("Ability Score: 10") return 10 } } +// parseFieldValue takes a string value and returns an integer. +// If the string value cannot be converted to an integer, it logs an error and returns 0. +// The function follows these rules: +// - No line is over 66 characters. func parseFieldValue(value string) int { + // Convert the string value to an integer using strconv.Atoi. + // If an error occurs during the conversion, log the error and return 0. val, err := strconv.Atoi(value) if err != nil { log.Printf("Error converting field value to integer: %v", err) return 0 } + // Log the converted integer value for debugging purposes. + log.Printf("Converted field value to integer: %d", val) + // Return the converted integer value. return val } diff --git a/templates/skills.html b/templates/skills.html index 9322260..35cb72b 100644 --- a/templates/skills.html +++ b/templates/skills.html @@ -182,4 +182,4 @@ -{{ end }} +{{ end }} \ No newline at end of file From aba6e13663fc6e64b0b0253fdc1ad3a8fc1469ed Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Thu, 14 Dec 2023 20:00:10 +0100 Subject: [PATCH 2/8] backend: frontend: added calculation for save values --- handlers/skill_calculation_handler.go | 7 ++ templates/monsterForm.html | 65 +--------------- templates/skills.html | 107 +++++++++++++++++++++----- 3 files changed, 96 insertions(+), 83 deletions(-) diff --git a/handlers/skill_calculation_handler.go b/handlers/skill_calculation_handler.go index a26866f..b7bc109 100644 --- a/handlers/skill_calculation_handler.go +++ b/handlers/skill_calculation_handler.go @@ -45,6 +45,7 @@ func SkillCalculationHandler(content embed.FS) http.HandlerFunc { int := parseFieldValue(r.FormValue("int")) cha := parseFieldValue(r.FormValue("cha")) wis := parseFieldValue(r.FormValue("wis")) + con := parseFieldValue(r.FormValue("con")) cr := parseFieldValue(r.FormValue("cr")) crBonus := calcBonus(cr) @@ -67,6 +68,12 @@ func SkillCalculationHandler(content embed.FS) http.HandlerFunc { "sleightOfHand": strconv.Itoa(calcAbilityScore(dex) + crBonus), "stealth": strconv.Itoa(calcAbilityScore(dex) + crBonus), "survival": strconv.Itoa(calcAbilityScore(wis) + crBonus), + "saveStr": strconv.Itoa(calcAbilityScore(str)), + "saveWis": strconv.Itoa(calcAbilityScore(wis)), + "saveCon": strconv.Itoa(calcAbilityScore(con)), + "saveInt": strconv.Itoa(calcAbilityScore(int)), + "saveCha": strconv.Itoa(calcAbilityScore(cha)), + "saveDex": strconv.Itoa(calcAbilityScore(dex)), } // Execute template with skill values. diff --git a/templates/monsterForm.html b/templates/monsterForm.html index ca69873..ba8212b 100644 --- a/templates/monsterForm.html +++ b/templates/monsterForm.html @@ -219,70 +219,7 @@ -
-
-

- Save -

-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
+
{{ template "skills" }}
diff --git a/templates/skills.html b/templates/skills.html index 35cb72b..9946793 100644 --- a/templates/skills.html +++ b/templates/skills.html @@ -1,4 +1,71 @@ {{ define "skills" }} +
+
+
+

+ Save +

+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+

Skill @@ -9,7 +76,7 @@

- +
@@ -18,7 +85,7 @@
- +
@@ -27,7 +94,7 @@
- +
@@ -38,7 +105,7 @@
- +
@@ -47,7 +114,7 @@
- +
@@ -56,7 +123,7 @@
- +
@@ -67,7 +134,7 @@
- +
@@ -76,7 +143,7 @@
- +
@@ -85,7 +152,7 @@
- +
@@ -96,7 +163,7 @@
- +
@@ -105,7 +172,7 @@
- +
@@ -114,7 +181,7 @@
- +
@@ -125,7 +192,7 @@
- +
@@ -134,7 +201,7 @@
- +
@@ -143,7 +210,7 @@
- +
@@ -154,7 +221,7 @@
- +
@@ -163,7 +230,7 @@
- +
@@ -172,7 +239,7 @@
- +
@@ -182,4 +249,6 @@
-{{ end }} \ No newline at end of file +
+
+{{ end }} From f84ee2a46635f35c6faae527226e0327fee07454 Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Fri, 15 Dec 2023 08:22:34 +0100 Subject: [PATCH 3/8] added check if skills are included --- handlers/add_monster_handler.go | 110 ++++++++++++++++++++++++++------ templates/skills.html | 36 +++++------ 2 files changed, 110 insertions(+), 36 deletions(-) diff --git a/handlers/add_monster_handler.go b/handlers/add_monster_handler.go index 38cb1a1..c1342a6 100644 --- a/handlers/add_monster_handler.go +++ b/handlers/add_monster_handler.go @@ -64,6 +64,80 @@ func parseInt(s string) int { // parseMonster parses the Monster from monsterForm.html and return it. func parseMonster(r *http.Request) model.Monster { + var ( + acrobatics = "" + animalHandling = "" + arcana = "" + athletics = "" + deception = "" + history = "" + insight = "" + intimidation = "" + investigation = "" + medicine = "" + nature = "" + performance = "" + perception = "" + persuasion = "" + sleightOfHand = "" + religion = "" + stealth = "" + survival = "" + ) + if r.FormValue("checkAcrobatics") == "on" { + acrobatics = r.FormValue("acrobatics") + } + if r.FormValue("checkAnimalHandling") == "on" { + animalHandling = r.FormValue("animalHandling") + } + if r.FormValue("checkArcana") == "on" { + arcana = r.FormValue("arcana") + } + if r.FormValue("checkAthletics") == "on" { + athletics = r.FormValue("athletics") + } + if r.FormValue("checkDeception") == "on" { + deception = r.FormValue("deception") + } + if r.FormValue("checkHistory") == "on" { + history = r.FormValue("history") + } + if r.FormValue("checkInsight") == "on" { + insight = r.FormValue("insight") + } + if r.FormValue("checkIntimidation") == "on" { + intimidation = r.FormValue("intimidation") + } + if r.FormValue("checkInvestigation") == "on" { + investigation = r.FormValue("investigation") + } + if r.FormValue("checkMedicine") == "on" { + medicine = r.FormValue("medicine") + } + if r.FormValue("checkNature") == "on" { + nature = r.FormValue("nature") + } + if r.FormValue("checkPerformance") == "on" { + performance = r.FormValue("performance") + } + if r.FormValue("checkPerception") == "on" { + perception = r.FormValue("perception") + } + if r.FormValue("checkPersuasion") == "on" { + persuasion = r.FormValue("persuasion") + } + if r.FormValue("checkSleightOfHand") == "on" { + sleightOfHand = r.FormValue("sleightOfHand") + } + if r.FormValue("checkStealth") == "on" { + stealth = r.FormValue("stealth") + } + if r.FormValue("checkSurvival") == "on" { + survival = r.FormValue("survival") + } + if r.FormValue("checkReligion") == "on" { + religion = r.FormValue("religion") + } return model.Monster{ Name: r.FormValue("name"), Source: r.FormValue("source"), @@ -102,24 +176,24 @@ func parseMonster(r *http.Request) model.Monster { Int: r.FormValue("saveInt"), }, Skill: model.Skill{ - Perception: r.FormValue("perception"), - Stealth: r.FormValue("stealth"), - Acrobatics: r.FormValue("acrobatics"), - AnimalHandling: r.FormValue("animalHandling"), - Arcana: r.FormValue("arcana"), - Athletics: r.FormValue("athletics"), - Deception: r.FormValue("deception"), - History: r.FormValue("history"), - Insight: r.FormValue("insight"), - Intimidation: r.FormValue("intimidation"), - Investigation: r.FormValue("investigation"), - Medicine: r.FormValue("medicine"), - Nature: r.FormValue("nature"), - Performance: r.FormValue("performance"), - Persuasion: r.FormValue("persuasion"), - SleightOfHand: r.FormValue("sleightOfHand"), - Survival: r.FormValue("survival"), - Religion: r.FormValue("religion"), + Perception: perception, + Stealth: stealth, + Acrobatics: acrobatics, + AnimalHandling: animalHandling, + Arcana: arcana, + Athletics: athletics, + Deception: deception, + History: history, + Insight: insight, + Intimidation: intimidation, + Investigation: investigation, + Medicine: medicine, + Nature: nature, + Performance: performance, + Persuasion: persuasion, + SleightOfHand: sleightOfHand, + Survival: survival, + Religion: religion, }, Resist: []string{r.FormValue("resist")}, ConditionImmune: []string{r.FormValue("conditionImmune")}, diff --git a/templates/skills.html b/templates/skills.html index 9946793..83a8416 100644 --- a/templates/skills.html +++ b/templates/skills.html @@ -76,7 +76,7 @@
- +
@@ -85,7 +85,7 @@
- +
@@ -94,7 +94,7 @@
- +
@@ -105,7 +105,7 @@
- +
@@ -114,7 +114,7 @@
- +
@@ -123,7 +123,7 @@
- +
@@ -134,7 +134,7 @@
- +
@@ -143,7 +143,7 @@
- +
@@ -152,7 +152,7 @@
- +
@@ -163,7 +163,7 @@
- +
@@ -172,7 +172,7 @@
- +
@@ -181,7 +181,7 @@
- +
@@ -192,7 +192,7 @@
- +
@@ -201,7 +201,7 @@
- +
@@ -210,7 +210,7 @@
- +
@@ -221,7 +221,7 @@
- +
@@ -230,7 +230,7 @@
- +
@@ -239,7 +239,7 @@
- +
From 32a37eea3212110756f23ebce9dcb354b9d18370 Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Fri, 15 Dec 2023 09:27:55 +0100 Subject: [PATCH 4/8] frontend: backend: clean up code for better readability --- go.mod | 5 +- go.sum | 2 + handlers/add_monster_handler.go | 121 ++++++++------------------------ templates/skills.html | 8 +-- 4 files changed, 39 insertions(+), 97 deletions(-) diff --git a/go.mod b/go.mod index dfe5d47..7db1ebd 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,10 @@ module ddServer go 1.21.4 -require github.com/stretchr/testify v1.8.4 +require ( + github.com/stretchr/testify v1.8.4 + golang.org/x/text v0.14.0 +) require ( github.com/davecgh/go-spew v1.1.1 // indirect diff --git a/go.sum b/go.sum index fa4b6e6..e228b7b 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/handlers/add_monster_handler.go b/handlers/add_monster_handler.go index c1342a6..f2a7e92 100644 --- a/handlers/add_monster_handler.go +++ b/handlers/add_monster_handler.go @@ -2,10 +2,14 @@ package handlers import ( "ddServer/model" + "fmt" "log" "net/http" "strconv" "strings" + + "golang.org/x/text/cases" + "golang.org/x/text/language" ) // AddMonster is a http.HandlerFunc that adds a new monster to the Monsters slice. @@ -64,80 +68,6 @@ func parseInt(s string) int { // parseMonster parses the Monster from monsterForm.html and return it. func parseMonster(r *http.Request) model.Monster { - var ( - acrobatics = "" - animalHandling = "" - arcana = "" - athletics = "" - deception = "" - history = "" - insight = "" - intimidation = "" - investigation = "" - medicine = "" - nature = "" - performance = "" - perception = "" - persuasion = "" - sleightOfHand = "" - religion = "" - stealth = "" - survival = "" - ) - if r.FormValue("checkAcrobatics") == "on" { - acrobatics = r.FormValue("acrobatics") - } - if r.FormValue("checkAnimalHandling") == "on" { - animalHandling = r.FormValue("animalHandling") - } - if r.FormValue("checkArcana") == "on" { - arcana = r.FormValue("arcana") - } - if r.FormValue("checkAthletics") == "on" { - athletics = r.FormValue("athletics") - } - if r.FormValue("checkDeception") == "on" { - deception = r.FormValue("deception") - } - if r.FormValue("checkHistory") == "on" { - history = r.FormValue("history") - } - if r.FormValue("checkInsight") == "on" { - insight = r.FormValue("insight") - } - if r.FormValue("checkIntimidation") == "on" { - intimidation = r.FormValue("intimidation") - } - if r.FormValue("checkInvestigation") == "on" { - investigation = r.FormValue("investigation") - } - if r.FormValue("checkMedicine") == "on" { - medicine = r.FormValue("medicine") - } - if r.FormValue("checkNature") == "on" { - nature = r.FormValue("nature") - } - if r.FormValue("checkPerformance") == "on" { - performance = r.FormValue("performance") - } - if r.FormValue("checkPerception") == "on" { - perception = r.FormValue("perception") - } - if r.FormValue("checkPersuasion") == "on" { - persuasion = r.FormValue("persuasion") - } - if r.FormValue("checkSleightOfHand") == "on" { - sleightOfHand = r.FormValue("sleightOfHand") - } - if r.FormValue("checkStealth") == "on" { - stealth = r.FormValue("stealth") - } - if r.FormValue("checkSurvival") == "on" { - survival = r.FormValue("survival") - } - if r.FormValue("checkReligion") == "on" { - religion = r.FormValue("religion") - } return model.Monster{ Name: r.FormValue("name"), Source: r.FormValue("source"), @@ -176,24 +106,24 @@ func parseMonster(r *http.Request) model.Monster { Int: r.FormValue("saveInt"), }, Skill: model.Skill{ - Perception: perception, - Stealth: stealth, - Acrobatics: acrobatics, - AnimalHandling: animalHandling, - Arcana: arcana, - Athletics: athletics, - Deception: deception, - History: history, - Insight: insight, - Intimidation: intimidation, - Investigation: investigation, - Medicine: medicine, - Nature: nature, - Performance: performance, - Persuasion: persuasion, - SleightOfHand: sleightOfHand, - Survival: survival, - Religion: religion, + Perception: checkCheckbox("perception", r), + Stealth: checkCheckbox("stealth", r), + Acrobatics: checkCheckbox("acrobatics", r), + AnimalHandling: checkCheckbox("animalhandling", r), + Arcana: checkCheckbox("arcana", r), + Athletics: checkCheckbox("athletics", r), + Deception: checkCheckbox("deception", r), + History: checkCheckbox("history", r), + Insight: checkCheckbox("insight", r), + Intimidation: checkCheckbox("intimidation", r), + Investigation: checkCheckbox("investigation", r), + Medicine: checkCheckbox("medicine", r), + Nature: checkCheckbox("nature", r), + Performance: checkCheckbox("performance", r), + Persuasion: checkCheckbox("persuasion", r), + SleightOfHand: checkCheckbox("sleightofhand", r), + Survival: checkCheckbox("survival", r), + Religion: checkCheckbox("religion", r), }, Resist: []string{r.FormValue("resist")}, ConditionImmune: []string{r.FormValue("conditionImmune")}, @@ -216,3 +146,10 @@ func parseMonster(r *http.Request) model.Monster { }, } } + +func checkCheckbox(field string, r *http.Request) string { + if r.FormValue(fmt.Sprintf("check%v", cases.Caser(cases.Title(language.Und)).String(field))) == "on" { + return r.FormValue(field) + } + return "" +} diff --git a/templates/skills.html b/templates/skills.html index 83a8416..9512855 100644 --- a/templates/skills.html +++ b/templates/skills.html @@ -85,9 +85,9 @@
- +
-
@@ -221,9 +221,9 @@
- +
-
From 88cfe035e032e824c44e3b7bf41312d14a93f9ca Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Fri, 15 Dec 2023 15:38:43 +0100 Subject: [PATCH 5/8] backend: frontend: add file load feature added a feature to load existing json files and load the containing monsters --- handlers/load_file_handler.go | 46 +++++++++++++++++++++++++++++++++++ main.go | 1 + templates/main.html | 24 +++++++++++++++++- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 handlers/load_file_handler.go diff --git a/handlers/load_file_handler.go b/handlers/load_file_handler.go new file mode 100644 index 0000000..cfaaac4 --- /dev/null +++ b/handlers/load_file_handler.go @@ -0,0 +1,46 @@ +package handlers + +import ( + "ddServer/model" + "encoding/json" + "fmt" + "log" + "net/http" +) + +func LoadFileHandler(monsters *[]model.Monster) http.HandlerFunc { + log.Print("LoadFileHandler called") + return func(w http.ResponseWriter, r *http.Request) { + r.ParseMultipartForm(10 << 20) // 10 MB limit + + // Get the file from the request + file, _, err := r.FormFile("uploadFile") + if err != nil { + http.Error(w, "Error retrieving file", http.StatusBadRequest) + return + } + defer file.Close() + + // Parse the file content + decoder := json.NewDecoder(file) + var loadedChars model.Character + err = decoder.Decode(&loadedChars) + if err != nil { + http.Error(w, "Error decoding file content", http.StatusInternalServerError) + return + } + + // Lock the Monsters slice and append the loaded monsters, then unlock the slice + mu.Lock() + defer mu.Unlock() + + // Assuming 'loadedChars' contains an array of Monster objects + for _, monster := range loadedChars.Monster { + *monsters = append(*monsters, monster) + } + + fmt.Printf("%v\n", monsters) + // Send a success response + http.Redirect(w, r, "/monsterTable", http.StatusTemporaryRedirect) + } +} diff --git a/main.go b/main.go index d163e79..5bbd46f 100644 --- a/main.go +++ b/main.go @@ -37,6 +37,7 @@ func main() { routes.HandleFunc("/contact", handlers.ContactHandler(content)) routes.HandleFunc("/monsterTable", handlers.MonsterTableHandler(content, &Monsters)) routes.HandleFunc("/calculate-skills", handlers.SkillCalculationHandler(content)) + routes.HandleFunc("/loadFile", handlers.LoadFileHandler(&Monsters)) // Print the message indicating that 'static' has been included. log.Printf("Eingebunden is %v\n", static) diff --git a/templates/main.html b/templates/main.html index ed4581f..53884fd 100644 --- a/templates/main.html +++ b/templates/main.html @@ -6,6 +6,28 @@

Monster Form

+
+
+ +
+
+
+ +
+
+
@@ -13,6 +35,7 @@ class="input input-bordered w-full max-w-xs">
+ {{ template "monsterform" . }}
- {{ template "monsterform" . }} From 6db6d78ad95f24cf59e4c84da3fab7b9bdb235e3 Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Fri, 15 Dec 2023 18:34:16 +0100 Subject: [PATCH 6/8] added checkboxes and check for save attributes --- handlers/add_monster_handler.go | 12 +- handlers/skill_calculation_handler.go | 12 +- templates/main.html | 2 +- templates/monster.html | 2 +- templates/monsterForm.html | 526 +++++++++++++------------- templates/skills.html | 510 +++++++++++++------------ 6 files changed, 545 insertions(+), 519 deletions(-) diff --git a/handlers/add_monster_handler.go b/handlers/add_monster_handler.go index f2a7e92..5174c3a 100644 --- a/handlers/add_monster_handler.go +++ b/handlers/add_monster_handler.go @@ -98,12 +98,12 @@ func parseMonster(r *http.Request) model.Monster { Wis: parseInt(r.FormValue("wis")), Cha: parseInt(r.FormValue("cha")), Save: model.Save{ - Dex: r.FormValue("saveDex"), - Con: r.FormValue("saveCon"), - Wis: r.FormValue("saveWis"), - Str: r.FormValue("saveStr"), - Cha: r.FormValue("saveCha"), - Int: r.FormValue("saveInt"), + Dex: checkCheckbox("savedex", r), + Con: checkCheckbox("savecon", r), + Wis: checkCheckbox("savewis", r), + Str: checkCheckbox("savestr", r), + Cha: checkCheckbox("savecha", r), + Int: checkCheckbox("saveint", r), }, Skill: model.Skill{ Perception: checkCheckbox("perception", r), diff --git a/handlers/skill_calculation_handler.go b/handlers/skill_calculation_handler.go index b7bc109..55ce57b 100644 --- a/handlers/skill_calculation_handler.go +++ b/handlers/skill_calculation_handler.go @@ -68,12 +68,12 @@ func SkillCalculationHandler(content embed.FS) http.HandlerFunc { "sleightOfHand": strconv.Itoa(calcAbilityScore(dex) + crBonus), "stealth": strconv.Itoa(calcAbilityScore(dex) + crBonus), "survival": strconv.Itoa(calcAbilityScore(wis) + crBonus), - "saveStr": strconv.Itoa(calcAbilityScore(str)), - "saveWis": strconv.Itoa(calcAbilityScore(wis)), - "saveCon": strconv.Itoa(calcAbilityScore(con)), - "saveInt": strconv.Itoa(calcAbilityScore(int)), - "saveCha": strconv.Itoa(calcAbilityScore(cha)), - "saveDex": strconv.Itoa(calcAbilityScore(dex)), + "saveStr": strconv.Itoa(calcAbilityScore(str) + crBonus), + "saveWis": strconv.Itoa(calcAbilityScore(wis) + crBonus), + "saveCon": strconv.Itoa(calcAbilityScore(con) + crBonus), + "saveInt": strconv.Itoa(calcAbilityScore(int) + crBonus), + "saveCha": strconv.Itoa(calcAbilityScore(cha) + crBonus), + "saveDex": strconv.Itoa(calcAbilityScore(dex) + crBonus), } // Execute template with skill values. diff --git a/templates/main.html b/templates/main.html index 53884fd..1687e93 100644 --- a/templates/main.html +++ b/templates/main.html @@ -88,7 +88,7 @@ Save Con Save Wis Save Str - Save Con + Save Int Save Cha Perception Stealth diff --git a/templates/monster.html b/templates/monster.html index d3a59d6..ecd2f58 100644 --- a/templates/monster.html +++ b/templates/monster.html @@ -24,7 +24,7 @@ {{.Save.Con}} {{.Save.Wis}} {{.Save.Str}} - {{.Save.Con}} + {{.Save.Int}} {{.Save.Cha}} {{.Skill.Perception}} {{.Skill.Stealth}} diff --git a/templates/monsterForm.html b/templates/monsterForm.html index ba8212b..96e245d 100644 --- a/templates/monsterForm.html +++ b/templates/monsterForm.html @@ -1,315 +1,313 @@ {{ define "monsterform" }}
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
-
- +
+
+ +
+ +
-
-
-
-
- -
- -
+
+
+ +
+ +
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
-
-

- Speed -

-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
-
-
- {{ template "skills" }} + {{ template "skills" }} +
+
+
+

+ Speed +

+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
-
-
- -
- -
+
+
+ +
+ +
+
-
{{end}} diff --git a/templates/skills.html b/templates/skills.html index 9512855..3994276 100644 --- a/templates/skills.html +++ b/templates/skills.html @@ -1,254 +1,282 @@ {{ define "skills" }}
-
-
-

- Save -

-
-
-
-
-
-
- -
- +
+
+

+ Save +

+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
-
-
-
-
- -
- +
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
-
-
-
- -
- -
-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
-
-

- Skill -

-
-
-
-
-
-
- -
- +
+

+ Skill +

+
+
+
+
+
+
+ +
+ -
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
{{ end }} From ff0f06c0b9ef2a908d1b9531919bd95f83e698b0 Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Fri, 15 Dec 2023 18:43:38 +0100 Subject: [PATCH 7/8] frontend: backend: fix formatting errors and errors from tests --- handlers/main_handler.go | 2 +- templates/base.html | 64 ++++++++--------- templates/contact.html | 99 ++++++++++++------------- templates/footer.html | 10 +-- templates/header.html | 139 ++++++++++++++++++------------------ templates/monster.html | 110 ++++++++++++++-------------- templates/monsterTable.html | 4 +- 7 files changed, 215 insertions(+), 213 deletions(-) diff --git a/handlers/main_handler.go b/handlers/main_handler.go index f060e3b..19d2cdf 100644 --- a/handlers/main_handler.go +++ b/handlers/main_handler.go @@ -16,7 +16,7 @@ func MainHandler(content embed.FS, monsters *[]model.Monster) http.HandlerFunc { log.Print("MainHandler called") // Parse the templates from the embedded file system - tmpl, err := template.ParseFS(content, "templates/main.html", "templates/monsterForm.html", "templates/monster.html", "templates/monsterTable.html", "templates/base.html") + tmpl, err := template.ParseFS(content, "templates/main.html", "templates/monsterForm.html", "templates/monster.html", "templates/monsterTable.html", "templates/base.html", "templates/skills.html") if err != nil { log.Printf("Template parsing error: %v\n", err) http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/templates/base.html b/templates/base.html index 7d8e18c..ba46719 100644 --- a/templates/base.html +++ b/templates/base.html @@ -3,51 +3,51 @@ - - - {{.Title}} - - - + + + {{.Title}} + + + -
- {{ template "header" . }} -
-
- {{ template "main" . }} -
+
+ {{ template "header" . }} +
+
+ {{ template "main" . }} +
-
- {{ template "footer" . }} -
+
+ {{ template "footer" . }} +
diff --git a/templates/contact.html b/templates/contact.html index ce0085d..c8481f1 100644 --- a/templates/contact.html +++ b/templates/contact.html @@ -1,57 +1,58 @@ {{ define "contact" }}
-
-
-
-

Contact Us

-
-
+
+
+
+

Contact Us

+
+
-
-

Our Contact Information

-

You can reach us through the following channels:

-
    -
  • Email: example@example.com
  • -
  • Phone: +123456789
  • -
+
+

Our Contact Information

+

You can reach us through the following channels:

+
    +
  • Email: example@example.com
  • +
  • Phone: +123456789
  • +
+
+ +
+

Contact Form

+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+
+
+
- -
-

Contact Form

-
-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- -
-
- -
-
-
-
-
-
{{ end }} diff --git a/templates/footer.html b/templates/footer.html index cf8d261..260d84c 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -1,9 +1,9 @@ {{ define "footer" }}
-
-

- © {{.Year}} Dungeons and Dragons Monster Generator. Alle Rechte vorbehalten. -

-
+
+

+ © {{.Year}} Dungeons and Dragons Monster Generator. Alle Rechte vorbehalten. +

+
{{ end }} diff --git a/templates/header.html b/templates/header.html index 0efea19..441c7a4 100644 --- a/templates/header.html +++ b/templates/header.html @@ -1,81 +1,82 @@ {{ define "header" }}
- -
-
-
-
-
-
- Dungeons-and-Dragons-Banner + + -
+ +
+
+
+
+
+
+ Dungeons-and-Dragons-Banner +
+
+

+ Dungeons and Dragons Monster Generator +

+
+
+
+
+
-
- + // Ändere das Icon basierend auf dem aktuellen Stylesheet + if (link.getAttribute("href") === "/static/darkly_bulmawatch.css") { + link.setAttribute("href", "https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css"); + stylesheetIcon.innerHTML = ''; // Zum Mond-Icon wechseln + } else { + link.setAttribute("href", "/static/darkly_bulmawatch.css"); + stylesheetIcon.innerHTML = ''; // Zum Sonnen-Icon wechseln + } + } + }); +
{{ end }} diff --git a/templates/monster.html b/templates/monster.html index ecd2f58..5c5ad39 100644 --- a/templates/monster.html +++ b/templates/monster.html @@ -1,59 +1,59 @@ {{ define "monster" }} - {{.Name}} - {{.Source}} - {{range .Size}}{{.}}{{end}} - {{.Type}} - {{range .Alignment}}{{.}}{{end}} - {{range .AC}}{{.AC}}{{end}} - {{range .AC}}{{.From}}{{end}} - {{.HP.Average}} - {{.HP.Formula}} - {{.Speed.Walk}} - {{.Speed.Swim}} - {{.Speed.Burrow}} - {{.Speed.Climb}} - {{.Speed.Fly}} - {{.Str}} - {{.Dex}} - {{.Con}} - {{.Int}} - {{.Wis}} - {{.Cha}} - {{.Save.Dex}} - {{.Save.Con}} - {{.Save.Wis}} - {{.Save.Str}} - {{.Save.Int}} - {{.Save.Cha}} - {{.Skill.Perception}} - {{.Skill.Stealth}} - {{.Skill.Acrobatics}} - {{.Skill.AnimalHandling}} - {{.Skill.Arcana}} - {{.Skill.Athletics}} - {{.Skill.Deception}} - {{.Skill.History}} - {{.Skill.Insight}} - {{.Skill.Intimidation}} - {{.Skill.Investigation}} - {{.Skill.Medicine}} - {{.Skill.Nature}} - {{.Skill.Performance}} - {{.Skill.Persuasion}} - {{.Skill.SleightOfHand}} - {{.Skill.Survival}} - {{.Skill.Religion}} - {{range .Resist}}{{.}}{{end}} - {{range .Immune}}{{.}}{{end}} - {{range .Vulnerable}}{{.}}{{end}} - {{range .ConditionImmune}}{{.}}{{end}} - {{range .Senses}}{{.}}{{end}} - {{range .Languages}}{{.}}{{end}} - {{.CR}} - {{range .Traits}}{{.Name}}{{end}} - {{range .Traits}}{{range .Entries}}{{.}}{{end}}{{end}} - {{range .Actions}}{{.Name}}{{end}} - {{range .Actions}}{{range .Entries}}{{.}}{{end}}{{end}} + {{.Name}} + {{.Source}} + {{range .Size}}{{.}}{{end}} + {{.Type}} + {{range .Alignment}}{{.}}{{end}} + {{range .AC}}{{.AC}}{{end}} + {{range .AC}}{{.From}}{{end}} + {{.HP.Average}} + {{.HP.Formula}} + {{.Speed.Walk}} + {{.Speed.Swim}} + {{.Speed.Burrow}} + {{.Speed.Climb}} + {{.Speed.Fly}} + {{.Str}} + {{.Dex}} + {{.Con}} + {{.Int}} + {{.Wis}} + {{.Cha}} + {{.Save.Dex}} + {{.Save.Con}} + {{.Save.Wis}} + {{.Save.Str}} + {{.Save.Int}} + {{.Save.Cha}} + {{.Skill.Perception}} + {{.Skill.Stealth}} + {{.Skill.Acrobatics}} + {{.Skill.AnimalHandling}} + {{.Skill.Arcana}} + {{.Skill.Athletics}} + {{.Skill.Deception}} + {{.Skill.History}} + {{.Skill.Insight}} + {{.Skill.Intimidation}} + {{.Skill.Investigation}} + {{.Skill.Medicine}} + {{.Skill.Nature}} + {{.Skill.Performance}} + {{.Skill.Persuasion}} + {{.Skill.SleightOfHand}} + {{.Skill.Survival}} + {{.Skill.Religion}} + {{range .Resist}}{{.}}{{end}} + {{range .Immune}}{{.}}{{end}} + {{range .Vulnerable}}{{.}}{{end}} + {{range .ConditionImmune}}{{.}}{{end}} + {{range .Senses}}{{.}}{{end}} + {{range .Languages}}{{.}}{{end}} + {{.CR}} + {{range .Traits}}{{.Name}}{{end}} + {{range .Traits}}{{range .Entries}}{{.}}{{end}}{{end}} + {{range .Actions}}{{.Name}}{{end}} + {{range .Actions}}{{range .Entries}}{{.}}{{end}}{{end}} {{ end }} diff --git a/templates/monsterTable.html b/templates/monsterTable.html index d5aef50..0275be1 100644 --- a/templates/monsterTable.html +++ b/templates/monsterTable.html @@ -1,7 +1,7 @@ {{ define "monsterTable" }} - {{ range .Monsters }} - {{ template "monster" . }} + {{ range .Monsters }} + {{ template "monster" . }} {{ end }} {{ end }} From 2a47aa90a3e698f60b6cac66edfd6579426e011f Mon Sep 17 00:00:00 2001 From: Patryk Hegenberg Date: Thu, 15 Feb 2024 16:17:58 +0100 Subject: [PATCH 8/8] edited formating of templates --- templates/base.html | 64 ++--- templates/footer.html | 12 +- templates/header.html | 149 +++++------ templates/main.html | 242 ++++++++--------- templates/monster.html | 112 ++++---- templates/monsterForm.html | 505 +++++++++++++++++----------------- templates/monsterTable.html | 6 +- templates/skills.html | 521 +++++++++++++++++------------------- 8 files changed, 793 insertions(+), 818 deletions(-) diff --git a/templates/base.html b/templates/base.html index ba46719..7d8e18c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -3,51 +3,51 @@ - - - {{.Title}} - - - + + + {{.Title}} + + + -
- {{ template "header" . }} -
-
- {{ template "main" . }} -
+
+ {{ template "header" . }} +
+
+ {{ template "main" . }} +
-
- {{ template "footer" . }} -
+
+ {{ template "footer" . }} +
diff --git a/templates/footer.html b/templates/footer.html index 260d84c..9b0881a 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -1,9 +1,9 @@ {{ define "footer" }}
-
-

- © {{.Year}} Dungeons and Dragons Monster Generator. Alle Rechte vorbehalten. -

-
+
+

+ © {{.Year}} Dungeons and Dragons Monster Generator. Alle Rechte vorbehalten. +

+
-{{ end }} +{{ end }} \ No newline at end of file diff --git a/templates/header.html b/templates/header.html index 441c7a4..46c13ec 100644 --- a/templates/header.html +++ b/templates/header.html @@ -1,82 +1,81 @@ {{ define "header" }}
- -
-
-
-
-
-
- Dungeons-and-Dragons-Banner -
-
-

- Dungeons and Dragons Monster Generator -

-
-
-
-
-
+
+ + +
+ +
+
+
+
+
+
+ Dungeons-and-Dragons-Banner +
+
+

+ Dungeons and Dragons Monster Generator +

+
+
+
+
+
+
+
-{{ end }} +{{ end }} \ No newline at end of file diff --git a/templates/main.html b/templates/main.html index 1687e93..359f1a9 100644 --- a/templates/main.html +++ b/templates/main.html @@ -1,131 +1,131 @@ {{ define "main" }}
-
-
-
-

Monster Form

+
+
+
+

Monster Form

+
+
+
+
+ +
+
+
+
-
- -
- -
-
-
- -
-
- -
-
- -
-
-
- {{ template "monsterform" . }} -
-
- -
-
- - -
+
+ +
+
+ +
-
+
+ {{ template "monsterform" . }} +
+
+ +
+
+ + + +
+
-
-
-
-

Existing Monsters

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{ template "monsterTable" }} -
NameSourceSizeTypeAlignmentACAC FormHP AverageHP FormulaWalkSwimBurrowClimbFlyStrDexConIntWisChaSave DexSave ConSave WisSave StrSave IntSave ChaPerceptionStealthAcrobaticsAnimalHandlingArcanaAthleticsDeceptionHistoryInsightIntimidationInvestigationMedicineNaturePerformancePersuasionSleightOfHandSurvivalReligionDamage ResistanceDamage ImmuneVulnerableCondition ImmuneSensesLanguagesCRTrait NameTrait EntryAction NameAction Entry
-
-
+
+
+
+

Existing Monsters

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{ template "monsterTable" }} +
NameSourceSizeTypeAlignmentACAC FormHP AverageHP FormulaWalkSwimBurrowClimbFlyStrDexConIntWisChaSave DexSave ConSave WisSave StrSave IntSave ChaPerceptionStealthAcrobaticsAnimalHandlingArcanaAthleticsDeceptionHistoryInsightIntimidationInvestigationMedicineNaturePerformancePersuasionSleightOfHandSurvivalReligionDamage ResistanceDamage ImmuneVulnerableCondition ImmuneSensesLanguagesCRTrait NameTrait EntryAction NameAction Entry
+
+
-{{ end }} +{{ end }} \ No newline at end of file diff --git a/templates/monster.html b/templates/monster.html index 5c5ad39..0053cea 100644 --- a/templates/monster.html +++ b/templates/monster.html @@ -1,59 +1,59 @@ {{ define "monster" }} - {{.Name}} - {{.Source}} - {{range .Size}}{{.}}{{end}} - {{.Type}} - {{range .Alignment}}{{.}}{{end}} - {{range .AC}}{{.AC}}{{end}} - {{range .AC}}{{.From}}{{end}} - {{.HP.Average}} - {{.HP.Formula}} - {{.Speed.Walk}} - {{.Speed.Swim}} - {{.Speed.Burrow}} - {{.Speed.Climb}} - {{.Speed.Fly}} - {{.Str}} - {{.Dex}} - {{.Con}} - {{.Int}} - {{.Wis}} - {{.Cha}} - {{.Save.Dex}} - {{.Save.Con}} - {{.Save.Wis}} - {{.Save.Str}} - {{.Save.Int}} - {{.Save.Cha}} - {{.Skill.Perception}} - {{.Skill.Stealth}} - {{.Skill.Acrobatics}} - {{.Skill.AnimalHandling}} - {{.Skill.Arcana}} - {{.Skill.Athletics}} - {{.Skill.Deception}} - {{.Skill.History}} - {{.Skill.Insight}} - {{.Skill.Intimidation}} - {{.Skill.Investigation}} - {{.Skill.Medicine}} - {{.Skill.Nature}} - {{.Skill.Performance}} - {{.Skill.Persuasion}} - {{.Skill.SleightOfHand}} - {{.Skill.Survival}} - {{.Skill.Religion}} - {{range .Resist}}{{.}}{{end}} - {{range .Immune}}{{.}}{{end}} - {{range .Vulnerable}}{{.}}{{end}} - {{range .ConditionImmune}}{{.}}{{end}} - {{range .Senses}}{{.}}{{end}} - {{range .Languages}}{{.}}{{end}} - {{.CR}} - {{range .Traits}}{{.Name}}{{end}} - {{range .Traits}}{{range .Entries}}{{.}}{{end}}{{end}} - {{range .Actions}}{{.Name}}{{end}} - {{range .Actions}}{{range .Entries}}{{.}}{{end}}{{end}} + {{.Name}} + {{.Source}} + {{range .Size}}{{.}}{{end}} + {{.Type}} + {{range .Alignment}}{{.}}{{end}} + {{range .AC}}{{.AC}}{{end}} + {{range .AC}}{{.From}}{{end}} + {{.HP.Average}} + {{.HP.Formula}} + {{.Speed.Walk}} + {{.Speed.Swim}} + {{.Speed.Burrow}} + {{.Speed.Climb}} + {{.Speed.Fly}} + {{.Str}} + {{.Dex}} + {{.Con}} + {{.Int}} + {{.Wis}} + {{.Cha}} + {{.Save.Dex}} + {{.Save.Con}} + {{.Save.Wis}} + {{.Save.Str}} + {{.Save.Int}} + {{.Save.Cha}} + {{.Skill.Perception}} + {{.Skill.Stealth}} + {{.Skill.Acrobatics}} + {{.Skill.AnimalHandling}} + {{.Skill.Arcana}} + {{.Skill.Athletics}} + {{.Skill.Deception}} + {{.Skill.History}} + {{.Skill.Insight}} + {{.Skill.Intimidation}} + {{.Skill.Investigation}} + {{.Skill.Medicine}} + {{.Skill.Nature}} + {{.Skill.Performance}} + {{.Skill.Persuasion}} + {{.Skill.SleightOfHand}} + {{.Skill.Survival}} + {{.Skill.Religion}} + {{range .Resist}}{{.}}{{end}} + {{range .Immune}}{{.}}{{end}} + {{range .Vulnerable}}{{.}}{{end}} + {{range .ConditionImmune}}{{.}}{{end}} + {{range .Senses}}{{.}}{{end}} + {{range .Languages}}{{.}}{{end}} + {{.CR}} + {{range .Traits}}{{.Name}}{{end}} + {{range .Traits}}{{range .Entries}}{{.}}{{end}}{{end}} + {{range .Actions}}{{.Name}}{{end}} + {{range .Actions}}{{range .Entries}}{{.}}{{end}}{{end}} -{{ end }} +{{ end }} \ No newline at end of file diff --git a/templates/monsterForm.html b/templates/monsterForm.html index 96e245d..5903e0d 100644 --- a/templates/monsterForm.html +++ b/templates/monsterForm.html @@ -1,313 +1,306 @@ {{ define "monsterform" }}
-
-
- -
- -
-
+
+
+ +
+ +
-
-
- -
- -
-
+
+
+
+ +
+ +
-
-
- -
-
- -
-
+
+
+
+ +
+
+
+
-
-
- -
- -
-
+
+
+
+ +
+ +
+
-
-
- -
- -
-
+
+
+ +
+ +
+
-
-
- -
- -
-
+
+
+ +
+ +
-
-
- -
- -
-
+
+
+
+ +
+ +
+
-
-
- -
- -
-
+
+
+ +
+ +
-
-
- -
- -
-
+
+
+
+ +
+ +
+
-
-
- -
- -
-
+
+
+ +
+ +
-
-
- -
- -
-
+
+
+
+ +
+ +
-
-
- -
- -
-
+
+
+
+ +
+ +
-
-
- -
- -
-
+
+
+
+ +
+ +
+
-
-
- -
- -
-
+
+
+ +
+ +
-
-
- -
- -
-
+
+
+
+ +
+ +
-
-
- -
- -
-
+
+
+
+ +
+ +
+
- {{ template "skills" }} + {{ template "skills" }}
-
-

- Speed -

-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
+
+

+ Speed +

+
+
+
+
+
+
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
-
-
- -
- -
-
+
+
+ +
+ +
-
-
- -
- -
-
+
+
+
+ +
+ +
-
-
- -
- -
-
+
+
+
+ +
+ +
-
-
- -
- -
-
+
+
+
+ +
+ +
+
-
-
- -
- -
-
+
+
+ +
+ +
+
-
-
- -
- -
-
+
+
+ +
+ +
+
-
-
- -
- -
-
+
+
+ +
+ +
-
-
- -
- -
-
+
+
+
+ +
+ +
+
-
-
- -
- -
-
+
+
+ +
+ +
-
-
- -
- -
-
+
+
+
+ +
+ +
+
-{{end}} +{{end}} \ No newline at end of file diff --git a/templates/monsterTable.html b/templates/monsterTable.html index 0275be1..9eb1b75 100644 --- a/templates/monsterTable.html +++ b/templates/monsterTable.html @@ -1,7 +1,7 @@ {{ define "monsterTable" }} - {{ range .Monsters }} - {{ template "monster" . }} + {{ range .Monsters }} + {{ template "monster" . }} {{ end }} -{{ end }} +{{ end }} \ No newline at end of file diff --git a/templates/skills.html b/templates/skills.html index 3994276..acd9da9 100644 --- a/templates/skills.html +++ b/templates/skills.html @@ -1,282 +1,265 @@ {{ define "skills" }}
-
-
-

- Save -

-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
+
+
+

+ Save +

+
+
+
+
+
+
+ +
+ +
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
-
-
-

- Skill -

-
-
-
-
-
-
- -
- +
+

+ Skill +

+
+
+
+
+
+
+ +
+ -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
-
- -
- -
-
-
-
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
-{{ end }} +{{ end }} \ No newline at end of file