+ more error handling and bug fixes
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v3"
|
"github.com/gofiber/fiber/v3"
|
||||||
"github.com/gofiber/fiber/v3/log"
|
|
||||||
"github.com/itsig0/tallytome/view/hptracker"
|
"github.com/itsig0/tallytome/view/hptracker"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,24 +19,25 @@ func Tracker(c fiber.Ctx) error {
|
|||||||
hx := len(c.GetReqHeaders()["Hx-Request"]) > 0
|
hx := len(c.GetReqHeaders()["Hx-Request"]) > 0
|
||||||
|
|
||||||
data := hptracker.TrackerData{
|
data := hptracker.TrackerData{
|
||||||
HP: "0",
|
Round: "0",
|
||||||
HPBase: "0",
|
|
||||||
HPStartPercentage: "0",
|
|
||||||
HPPercentage: "0",
|
|
||||||
Mana: "0",
|
|
||||||
ManaBase: "0",
|
|
||||||
ManaRegen: "0",
|
|
||||||
ManaStartPercentage: "0",
|
|
||||||
ManaPercentage: "0",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fields := []string{"HP", "HPBase", "HPStartPercentage", "HPPercentage", "Mana", "ManaBase", "ManaRegen", "ManaStartPercentage", "ManaPercentage"}
|
fields := []string{"HP", "HPBase", "HPStartPercentage", "HPPercentage", "Mana", "ManaBase", "ManaRegen", "ManaStartPercentage", "ManaPercentage", "Round"}
|
||||||
for _, field := range fields {
|
for _, field := range fields {
|
||||||
if val := sess.Get("tracker_" + field); val != nil {
|
if val := sess.Get("tracker_" + field); val != nil {
|
||||||
reflect.ValueOf(&data).Elem().FieldByName(field).SetString(fmt.Sprint(val))
|
reflect.ValueOf(&data).Elem().FieldByName(field).SetString(fmt.Sprint(val))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sess.Get("tracker_Round") == nil {
|
||||||
|
sess.Set("tracker_Round", "0")
|
||||||
|
sess.Save()
|
||||||
|
}
|
||||||
|
|
||||||
|
// prevent animation reset
|
||||||
|
data.HPStartPercentage = data.HPPercentage
|
||||||
|
data.ManaStartPercentage = data.ManaPercentage
|
||||||
|
|
||||||
return render(c, hptracker.Show(hx, data))
|
return render(c, hptracker.Show(hx, data))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,20 +59,47 @@ func TrackerUpdate(c fiber.Ctx) error {
|
|||||||
ManaPercentage: "100",
|
ManaPercentage: "100",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bd := hptracker.BaseData{}
|
||||||
|
|
||||||
|
mistake := false
|
||||||
|
|
||||||
|
if len(data.HP) > 5 || len(data.Mana) > 5 {
|
||||||
|
bd.Errors = "Einfach nur zu viel."
|
||||||
|
mistake = true
|
||||||
|
}
|
||||||
|
|
||||||
|
intManaRegen, _ := strconv.Atoi(data.ManaRegen)
|
||||||
|
if intManaRegen > 100 && !mistake {
|
||||||
|
bd.Errors = "Mehr als 100% geht nicht"
|
||||||
|
mistake = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if mistake {
|
||||||
|
c.Status(422)
|
||||||
|
c.Append("HX-Retarget", "#baseStats")
|
||||||
|
c.Append("HX-Reswap", "outerHTML")
|
||||||
|
|
||||||
|
return render(c, hptracker.BaseStats(data, bd))
|
||||||
|
}
|
||||||
|
|
||||||
pre := "tracker_"
|
pre := "tracker_"
|
||||||
sess.Set(pre+"HP", data.HP)
|
sess.Set(pre+"HP", data.HP)
|
||||||
sess.Set(pre+"HPBase", data.HPBase)
|
sess.Set(pre+"HPBase", data.HPBase)
|
||||||
sess.Set(pre+"HPPercentage", data.HPPercentage)
|
sess.Set(pre+"HPPercentage", data.HPPercentage)
|
||||||
sess.Set(pre+"HPStartPercentage", data.HPStartPercentage)
|
sess.Set(pre+"HPStartPercentage", data.HPPercentage)
|
||||||
|
|
||||||
sess.Set(pre+"Mana", data.Mana)
|
sess.Set(pre+"Mana", data.Mana)
|
||||||
sess.Set(pre+"ManaBase", data.ManaBase)
|
sess.Set(pre+"ManaBase", data.ManaBase)
|
||||||
sess.Set(pre+"ManaRegen", data.ManaRegen)
|
sess.Set(pre+"ManaRegen", data.ManaRegen)
|
||||||
sess.Set(pre+"ManaStartPercentage", data.ManaStartPercentage)
|
sess.Set(pre+"ManaStartPercentage", data.ManaPercentage)
|
||||||
sess.Set(pre+"ManaPercentage", data.ManaPercentage)
|
sess.Set(pre+"ManaPercentage", data.ManaPercentage)
|
||||||
|
|
||||||
|
sess.Set(pre+"Round", "0")
|
||||||
|
|
||||||
sess.Save()
|
sess.Save()
|
||||||
|
|
||||||
|
c.Append("HX-Trigger", "BaseUpdated")
|
||||||
|
|
||||||
return render(c, hptracker.TrackerColumn(data))
|
return render(c, hptracker.TrackerColumn(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,10 +112,17 @@ func TrackerDamage(c fiber.Ctx) error {
|
|||||||
damage, err := strconv.Atoi(c.FormValue("damageInput"))
|
damage, err := strconv.Atoi(c.FormValue("damageInput"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Status(422)
|
c.Status(422)
|
||||||
return c.SendString(err.Error())
|
c.Append("HX-Retarget", "#damageInputs")
|
||||||
} else if damage <= 0 {
|
c.Append("HX-Reswap", "outerHTML")
|
||||||
|
return render(c, hptracker.Hp(hptracker.DamageData{
|
||||||
|
Errors: "Einfach nur zu viel.",
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
if damage <= 0 {
|
||||||
c.Status(422)
|
c.Status(422)
|
||||||
c.Append("HX-Retarget", "#damageInputs")
|
c.Append("HX-Retarget", "#damageInputs")
|
||||||
|
c.Append("HX-Reswap", "outerHTML")
|
||||||
return render(c, hptracker.Hp(hptracker.DamageData{
|
return render(c, hptracker.Hp(hptracker.DamageData{
|
||||||
Errors: "Darf nicht 0 oder kleiner sein.",
|
Errors: "Darf nicht 0 oder kleiner sein.",
|
||||||
}))
|
}))
|
||||||
@@ -98,6 +132,7 @@ func TrackerDamage(c fiber.Ctx) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
c.Status(422)
|
c.Status(422)
|
||||||
c.Append("HX-Retarget", "#damageInputs")
|
c.Append("HX-Retarget", "#damageInputs")
|
||||||
|
c.Append("HX-Reswap", "outerHTML")
|
||||||
return render(c, hptracker.Hp(hptracker.DamageData{
|
return render(c, hptracker.Hp(hptracker.DamageData{
|
||||||
Errors: "Standard Werte nicht gesetzt.",
|
Errors: "Standard Werte nicht gesetzt.",
|
||||||
Values: c.FormValue("damageInput"),
|
Values: c.FormValue("damageInput"),
|
||||||
@@ -108,8 +143,8 @@ func TrackerDamage(c fiber.Ctx) error {
|
|||||||
// no error handling here because it's already done for currentHP
|
// no error handling here because it's already done for currentHP
|
||||||
baseHP, _ := strconv.Atoi(fmt.Sprint(sess.Get("tracker_HPBase")))
|
baseHP, _ := strconv.Atoi(fmt.Sprint(sess.Get("tracker_HPBase")))
|
||||||
|
|
||||||
heal := string(c.FormValue("heal"))
|
heal := c.FormValue("heal")
|
||||||
savingThrow := string(c.FormValue("savingthrow"))
|
savingThrow := c.FormValue("savingthrow")
|
||||||
|
|
||||||
if savingThrow == "on" || heal == "false" {
|
if savingThrow == "on" || heal == "false" {
|
||||||
damageFloat := float64(damage) * 0.33333
|
damageFloat := float64(damage) * 0.33333
|
||||||
@@ -155,33 +190,50 @@ func TrackerMana(c fiber.Ctx) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
manaData := hptracker.ManaData{}
|
||||||
|
|
||||||
mana, err := strconv.Atoi(c.FormValue("manaInput"))
|
mana, err := strconv.Atoi(c.FormValue("manaInput"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Status(422)
|
c.Status(422)
|
||||||
return c.SendString(err.Error())
|
c.Append("HX-Retarget", "#manaInputs")
|
||||||
} else if mana <= 0 {
|
manaData.Errors = "Einfach nur zu viel."
|
||||||
|
return render(c, hptracker.Mana(manaData))
|
||||||
|
}
|
||||||
|
|
||||||
|
if mana <= 0 {
|
||||||
c.Status(422)
|
c.Status(422)
|
||||||
// c.Append("HX-Retarget", "#damageInputs")
|
c.Append("HX-Retarget", "#manaInputs")
|
||||||
// return render(c, hptracker.Hp(hptracker.DamageData{
|
manaData.Errors = "Darf nicht 0 oder kleiner sein."
|
||||||
// Errors: "Darf nicht 0 oder kleiner sein.",
|
return render(c, hptracker.Mana(manaData))
|
||||||
// }))
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
currentMana, err := strconv.Atoi(fmt.Sprint(sess.Get("tracker_Mana")))
|
currentMana, err := strconv.Atoi(fmt.Sprint(sess.Get("tracker_Mana")))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Status(422)
|
c.Status(422)
|
||||||
// c.Append("HX-Retarget", "#manaInputs")
|
c.Append("HX-Retarget", "#manaInputs")
|
||||||
// return render(c, hptracker.Mana(hptracker.DamageData{
|
manaData.Errors = "Standard Werte nicht gesetzt."
|
||||||
// Errors: "Standard Werte nicht gesetzt.",
|
manaData.Values = c.FormValue("manaInput")
|
||||||
// }))
|
return render(c, hptracker.Mana(manaData))
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
baseMana, _ := strconv.Atoi(fmt.Sprint(sess.Get("tracker_ManaBase")))
|
baseMana, _ := strconv.Atoi(fmt.Sprint(sess.Get("tracker_ManaBase")))
|
||||||
|
|
||||||
|
add := c.FormValue("add")
|
||||||
|
|
||||||
|
if add == "true" {
|
||||||
|
mana *= -1
|
||||||
|
}
|
||||||
|
|
||||||
newMana := currentMana - mana
|
newMana := currentMana - mana
|
||||||
|
|
||||||
|
if newMana < 0 {
|
||||||
|
newMana = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if newMana > baseMana {
|
||||||
|
newMana = baseMana
|
||||||
|
}
|
||||||
|
|
||||||
newPercentage := (newMana * 100) / baseMana
|
newPercentage := (newMana * 100) / baseMana
|
||||||
|
|
||||||
data := hptracker.TrackerData{
|
data := hptracker.TrackerData{
|
||||||
@@ -196,14 +248,65 @@ func TrackerMana(c fiber.Ctx) error {
|
|||||||
|
|
||||||
sess.Save()
|
sess.Save()
|
||||||
|
|
||||||
|
c.Append("HX-Trigger", "ManaUpdated")
|
||||||
|
|
||||||
return render(c, hptracker.ManaTracker(data))
|
return render(c, hptracker.ManaTracker(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckStore(c fiber.Ctx) error {
|
func TrackerRound(c fiber.Ctx) error {
|
||||||
sess, err := store.Get(c)
|
sess, err := store.Get(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Info(sess.Keys())
|
|
||||||
return nil
|
data := hptracker.TrackerData{}
|
||||||
|
|
||||||
|
fields := []string{"HP", "HPBase", "HPStartPercentage", "HPPercentage", "Mana", "ManaBase", "ManaRegen", "ManaStartPercentage", "ManaPercentage", "Round"}
|
||||||
|
for _, field := range fields {
|
||||||
|
if val := sess.Get("tracker_" + field); val != nil {
|
||||||
|
reflect.ValueOf(&data).Elem().FieldByName(field).SetString(fmt.Sprint(val))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mana, _ := strconv.Atoi(data.Mana)
|
||||||
|
manaBase, _ := strconv.Atoi(data.ManaBase)
|
||||||
|
manaRegen, _ := strconv.Atoi(data.ManaRegen)
|
||||||
|
round, _ := strconv.Atoi(data.Round)
|
||||||
|
|
||||||
|
if manaBase == 0 || manaRegen == 0 {
|
||||||
|
c.Status(418)
|
||||||
|
return render(c, hptracker.TrackerHeader(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
mana += (manaRegen * manaBase) / 100
|
||||||
|
|
||||||
|
if mana > manaBase {
|
||||||
|
mana = manaBase
|
||||||
|
}
|
||||||
|
|
||||||
|
// hp stays the same for now
|
||||||
|
data.HPStartPercentage = data.HPPercentage
|
||||||
|
|
||||||
|
data.Mana = fmt.Sprint(mana)
|
||||||
|
data.Round = fmt.Sprint(round + 1)
|
||||||
|
data.ManaStartPercentage = data.ManaPercentage
|
||||||
|
data.ManaPercentage = fmt.Sprint((mana * 100) / manaBase)
|
||||||
|
|
||||||
|
sess.Set("tracker_Mana", data.Mana)
|
||||||
|
sess.Set("tracker_ManaPercentage", data.ManaPercentage)
|
||||||
|
sess.Set("tracker_ManaStartPercentage", data.ManaStartPercentage)
|
||||||
|
sess.Set("tracker_Round", data.Round)
|
||||||
|
|
||||||
|
sess.Save()
|
||||||
|
|
||||||
|
return render(c, hptracker.TrackerHeader(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TrackerReset(c fiber.Ctx) error {
|
||||||
|
sess, err := store.Get(c)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sess.Reset()
|
||||||
|
return render(c, hptracker.Show(true, hptracker.TrackerData{Round: "0"}))
|
||||||
}
|
}
|
||||||
|
|||||||
3
main.go
3
main.go
@@ -24,7 +24,8 @@ func main() {
|
|||||||
tracker.Post("/update", handler.TrackerUpdate)
|
tracker.Post("/update", handler.TrackerUpdate)
|
||||||
tracker.Post("/damage", handler.TrackerDamage)
|
tracker.Post("/damage", handler.TrackerDamage)
|
||||||
tracker.Post("/mana", handler.TrackerMana)
|
tracker.Post("/mana", handler.TrackerMana)
|
||||||
tracker.Get("/check", handler.CheckStore)
|
tracker.Get("/newround", handler.TrackerRound)
|
||||||
|
tracker.Get("/reset", handler.TrackerReset)
|
||||||
// app.Get("/*", func(c *fiber.Ctx) error {
|
// app.Get("/*", func(c *fiber.Ctx) error {
|
||||||
// return c.SendString("Hello, World!")
|
// return c.SendString("Hello, World!")
|
||||||
// })
|
// })
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ type TrackerData struct {
|
|||||||
ManaStartPercentage string
|
ManaStartPercentage string
|
||||||
ManaPercentage string
|
ManaPercentage string
|
||||||
ManaRegen string
|
ManaRegen string
|
||||||
|
Round string
|
||||||
}
|
}
|
||||||
|
|
||||||
type DamageData struct {
|
type DamageData struct {
|
||||||
@@ -21,34 +22,46 @@ type DamageData struct {
|
|||||||
Errors string
|
Errors string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ManaData struct {
|
||||||
|
Values string
|
||||||
|
Errors string
|
||||||
|
}
|
||||||
|
|
||||||
|
type BaseData struct {
|
||||||
|
HP string
|
||||||
|
Mana string
|
||||||
|
ManaRegen string
|
||||||
|
Errors string
|
||||||
|
}
|
||||||
|
|
||||||
var dd = DamageData {
|
var dd = DamageData {
|
||||||
Values: "",
|
Values: "",
|
||||||
SavingThrow: "",
|
SavingThrow: "",
|
||||||
Errors: "",
|
Errors: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var md = ManaData {
|
||||||
|
Values: "",
|
||||||
|
Errors: "",
|
||||||
|
}
|
||||||
|
|
||||||
|
var bd = BaseData {
|
||||||
|
HP: "",
|
||||||
|
Mana: "",
|
||||||
|
ManaRegen: "",
|
||||||
|
Errors: "",
|
||||||
|
}
|
||||||
|
|
||||||
templ Show(hx bool, td TrackerData){
|
templ Show(hx bool, td TrackerData){
|
||||||
@layout.Base(hx){
|
@layout.Base(hx){
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
<div class="grid mb-2">
|
<div id="trackerHeader" class="grid mb-2">
|
||||||
<div class="start">
|
@TrackerHeader(td)
|
||||||
<h2>Kampfrunde: </h2>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="trackerBars" class="middle">
|
|
||||||
|
|
||||||
@TrackerColumn(td)
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="text-right">
|
|
||||||
<button>Nächste Runde</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
// base stats go here
|
// base stats go here
|
||||||
@baseStats()
|
@BaseStats(td, bd)
|
||||||
|
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<div>
|
<div>
|
||||||
@@ -58,9 +71,10 @@ templ Show(hx bool, td TrackerData){
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h3>Mana</h3>
|
<h3>Mana</h3>
|
||||||
@Mana()
|
@Mana(md)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<button type="button" hx-get="/hp-mana-tracker/reset" hx-target="main" hx-swap="innerHTML">Reset</button>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", (event) => {
|
document.addEventListener("DOMContentLoaded", (event) => {
|
||||||
@@ -84,15 +98,44 @@ templ Show(hx bool, td TrackerData){
|
|||||||
var savingthrow = document.getElementById('savingthrow');
|
var savingthrow = document.getElementById('savingthrow');
|
||||||
savingthrow.checked = false;
|
savingthrow.checked = false;
|
||||||
});
|
});
|
||||||
})
|
|
||||||
|
|
||||||
|
document.body.addEventListener("ManaUpdated", function() {
|
||||||
|
var input = document.getElementById('manaInput');
|
||||||
|
input.value = "";
|
||||||
|
input.removeAttribute('aria-invalid');
|
||||||
|
|
||||||
|
var errorMessage = document.getElementById('manaError');
|
||||||
|
if (errorMessage) {
|
||||||
|
errorMessage.parentNode.removeChild(errorMessage);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
document.body.addEventListener("BaseUpdated", function() {
|
||||||
|
var errorMessage = document.getElementById('baseError');
|
||||||
|
if (errorMessage) {
|
||||||
|
errorMessage.parentNode.removeChild(errorMessage);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// css loading(percent string) {
|
templ TrackerHeader(td TrackerData){
|
||||||
// width: { fmt.Sprintf("%s%%", percent) };
|
<div class="start">
|
||||||
// }
|
<h2>Kampfrunde: {td.Round}</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="trackerBars" class="middle">
|
||||||
|
|
||||||
|
@TrackerColumn(td)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="text-right">
|
||||||
|
<button hx-get="/hp-mana-tracker/newround" hx-target="#trackerHeader" hx-swap="innerHTML">Nächste Runde</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
templ TrackerColumn(td TrackerData){
|
templ TrackerColumn(td TrackerData){
|
||||||
|
|
||||||
@@ -126,8 +169,8 @@ css manaAnimation(from, to string) {
|
|||||||
--mana-to-width:{ fmt.Sprintf("%s%%", to) };
|
--mana-to-width:{ fmt.Sprintf("%s%%", to) };
|
||||||
}
|
}
|
||||||
|
|
||||||
templ baseStats(){
|
templ BaseStats(td TrackerData, bd BaseData){
|
||||||
<details open>
|
<details id="baseStats" open>
|
||||||
<summary>Standard Werte</summary>
|
<summary>Standard Werte</summary>
|
||||||
<form class="grid" hx-post="/hp-mana-tracker/update" hx-target="#trackerBars">
|
<form class="grid" hx-post="/hp-mana-tracker/update" hx-target="#trackerBars">
|
||||||
|
|
||||||
@@ -137,12 +180,13 @@ templ baseStats(){
|
|||||||
type="number"
|
type="number"
|
||||||
placeholder="Trefferpunkte"
|
placeholder="Trefferpunkte"
|
||||||
name="hp"
|
name="hp"
|
||||||
|
value={td.HP}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
Mana <input type="number" name="mana" placeholder="Mana" required/>
|
Mana <input type="number" name="mana" placeholder="Mana" value={td.Mana} required/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
@@ -151,16 +195,20 @@ templ baseStats(){
|
|||||||
type="number"
|
type="number"
|
||||||
name="manaregen"
|
name="manaregen"
|
||||||
placeholder="Regenerations %"
|
placeholder="Regenerations %"
|
||||||
|
value={td.ManaRegen}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div class="lbl-offset">
|
<div class="lbl-offset">
|
||||||
<button type="submit">
|
<button type="submit" >
|
||||||
Go
|
Go
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
if bd.Errors != "" {
|
||||||
|
<small id="baseError" class="error-helper">{bd.Errors}</small>
|
||||||
|
}
|
||||||
</details>
|
</details>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,21 +258,35 @@ templ Hp(dd DamageData){
|
|||||||
</form>
|
</form>
|
||||||
}
|
}
|
||||||
|
|
||||||
templ Mana(){
|
templ Mana(md ManaData){
|
||||||
<form hx-post="/hp-mana-tracker/mana" hx-target="#manaBar">
|
<form id="manaInputs" hx-post="/hp-mana-tracker/mana" hx-target="#manaBar">
|
||||||
<fieldset role="group">
|
<fieldset role="group">
|
||||||
|
|
||||||
<button class="secondary" name="use">
|
<button class="secondary" name="use" value="true">
|
||||||
-
|
-
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<input name="manaInput" type="number" placeholder="" min="0" value="0"/>
|
<input
|
||||||
|
id="manaInput"
|
||||||
|
name="manaInput"
|
||||||
|
type="number"
|
||||||
|
placeholder="Mana"
|
||||||
|
required
|
||||||
|
if md.Errors != "" {
|
||||||
|
aria-invalid="true"
|
||||||
|
}
|
||||||
|
value={md.Values}
|
||||||
|
/>
|
||||||
|
|
||||||
<button class="secondary" name="add">
|
<button class="secondary" name="add" value="true">
|
||||||
+
|
+
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
if md.Errors != "" {
|
||||||
|
<small id="manaError" class="error-helper">{md.Errors}</small>
|
||||||
|
}
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ type TrackerData struct {
|
|||||||
ManaStartPercentage string
|
ManaStartPercentage string
|
||||||
ManaPercentage string
|
ManaPercentage string
|
||||||
ManaRegen string
|
ManaRegen string
|
||||||
|
Round string
|
||||||
}
|
}
|
||||||
|
|
||||||
type DamageData struct {
|
type DamageData struct {
|
||||||
@@ -32,12 +33,36 @@ type DamageData struct {
|
|||||||
Errors string
|
Errors string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ManaData struct {
|
||||||
|
Values string
|
||||||
|
Errors string
|
||||||
|
}
|
||||||
|
|
||||||
|
type BaseData struct {
|
||||||
|
HP string
|
||||||
|
Mana string
|
||||||
|
ManaRegen string
|
||||||
|
Errors string
|
||||||
|
}
|
||||||
|
|
||||||
var dd = DamageData{
|
var dd = DamageData{
|
||||||
Values: "",
|
Values: "",
|
||||||
SavingThrow: "",
|
SavingThrow: "",
|
||||||
Errors: "",
|
Errors: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var md = ManaData{
|
||||||
|
Values: "",
|
||||||
|
Errors: "",
|
||||||
|
}
|
||||||
|
|
||||||
|
var bd = BaseData{
|
||||||
|
HP: "",
|
||||||
|
Mana: "",
|
||||||
|
ManaRegen: "",
|
||||||
|
Errors: "",
|
||||||
|
}
|
||||||
|
|
||||||
func Show(hx bool, td TrackerData) templ.Component {
|
func Show(hx bool, td TrackerData) templ.Component {
|
||||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||||
@@ -61,7 +86,7 @@ func Show(hx bool, td TrackerData) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = TrackerColumn(td).Render(ctx, templ_7745c5c3_Buffer)
|
templ_7745c5c3_Err = TrackerHeader(td).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -69,7 +94,7 @@ func Show(hx bool, td TrackerData) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = baseStats().Render(ctx, templ_7745c5c3_Buffer)
|
templ_7745c5c3_Err = BaseStats(td, bd).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -85,7 +110,7 @@ func Show(hx bool, td TrackerData) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = Mana().Render(ctx, templ_7745c5c3_Buffer)
|
templ_7745c5c3_Err = Mana(md).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -109,10 +134,7 @@ func Show(hx bool, td TrackerData) templ.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// css loading(percent string) {
|
func TrackerHeader(td TrackerData) templ.Component {
|
||||||
// width: { fmt.Sprintf("%s%%", percent) };
|
|
||||||
// }
|
|
||||||
func TrackerColumn(td TrackerData) templ.Component {
|
|
||||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||||
if !templ_7745c5c3_IsBuffer {
|
if !templ_7745c5c3_IsBuffer {
|
||||||
@@ -129,7 +151,12 @@ func TrackerColumn(td TrackerData) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = HPTracker(td).Render(ctx, templ_7745c5c3_Buffer)
|
var templ_7745c5c3_Var4 string
|
||||||
|
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(td.Round)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/hptracker/tracker.templ`, Line: 125, Col: 33}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -137,7 +164,7 @@ func TrackerColumn(td TrackerData) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = ManaTracker(td).Render(ctx, templ_7745c5c3_Buffer)
|
templ_7745c5c3_Err = TrackerColumn(td).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -152,6 +179,46 @@ func TrackerColumn(td TrackerData) templ.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TrackerColumn(td TrackerData) templ.Component {
|
||||||
|
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||||
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||||
|
if !templ_7745c5c3_IsBuffer {
|
||||||
|
templ_7745c5c3_Buffer = templ.GetBuffer()
|
||||||
|
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||||
|
}
|
||||||
|
ctx = templ.InitializeContext(ctx)
|
||||||
|
templ_7745c5c3_Var5 := templ.GetChildren(ctx)
|
||||||
|
if templ_7745c5c3_Var5 == nil {
|
||||||
|
templ_7745c5c3_Var5 = templ.NopComponent
|
||||||
|
}
|
||||||
|
ctx = templ.ClearChildren(ctx)
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 9)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = HPTracker(td).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 10)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = ManaTracker(td).Render(ctx, templ_7745c5c3_Buffer)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 11)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
if !templ_7745c5c3_IsBuffer {
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||||
|
}
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func HPTracker(td TrackerData) templ.Component {
|
func HPTracker(td TrackerData) templ.Component {
|
||||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||||
@@ -160,51 +227,21 @@ func HPTracker(td TrackerData) templ.Component {
|
|||||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
templ_7745c5c3_Var4 := templ.GetChildren(ctx)
|
templ_7745c5c3_Var6 := templ.GetChildren(ctx)
|
||||||
if templ_7745c5c3_Var4 == nil {
|
if templ_7745c5c3_Var6 == nil {
|
||||||
templ_7745c5c3_Var4 = templ.NopComponent
|
templ_7745c5c3_Var6 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 9)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var5 string
|
|
||||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(td.HP)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/hptracker/tracker.templ`, Line: 109, Col: 43}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 10)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var6 string
|
|
||||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(td.HPBase)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/hptracker/tracker.templ`, Line: 109, Col: 55}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 11)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var7 = []any{"hp", hpAnimation(td.HPStartPercentage, td.HPPercentage)}
|
|
||||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var7...)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 12)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 12)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ.CSSClasses(templ_7745c5c3_Var7).String()))
|
var templ_7745c5c3_Var7 string
|
||||||
|
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(td.HP)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/hptracker/tracker.templ`, Line: 152, Col: 43}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -212,6 +249,36 @@ func HPTracker(td TrackerData) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
var templ_7745c5c3_Var8 string
|
||||||
|
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(td.HPBase)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/hptracker/tracker.templ`, Line: 152, Col: 55}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 14)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var9 = []any{"hp", hpAnimation(td.HPStartPercentage, td.HPPercentage)}
|
||||||
|
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var9...)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 15)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ.CSSClasses(templ_7745c5c3_Var9).String()))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 16)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
if !templ_7745c5c3_IsBuffer {
|
if !templ_7745c5c3_IsBuffer {
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||||
}
|
}
|
||||||
@@ -227,51 +294,21 @@ func ManaTracker(td TrackerData) templ.Component {
|
|||||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
templ_7745c5c3_Var8 := templ.GetChildren(ctx)
|
templ_7745c5c3_Var10 := templ.GetChildren(ctx)
|
||||||
if templ_7745c5c3_Var8 == nil {
|
if templ_7745c5c3_Var10 == nil {
|
||||||
templ_7745c5c3_Var8 = templ.NopComponent
|
templ_7745c5c3_Var10 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 14)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var9 string
|
|
||||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(td.Mana)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/hptracker/tracker.templ`, Line: 114, Col: 47}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 15)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var10 string
|
|
||||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(td.ManaBase)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/hptracker/tracker.templ`, Line: 114, Col: 61}
|
|
||||||
}
|
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 16)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
var templ_7745c5c3_Var11 = []any{"mana", manaAnimation(td.ManaStartPercentage, td.ManaPercentage)}
|
|
||||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var11...)
|
|
||||||
if templ_7745c5c3_Err != nil {
|
|
||||||
return templ_7745c5c3_Err
|
|
||||||
}
|
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 17)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 17)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ.CSSClasses(templ_7745c5c3_Var11).String()))
|
var templ_7745c5c3_Var11 string
|
||||||
|
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(td.Mana)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/hptracker/tracker.templ`, Line: 157, Col: 47}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -279,6 +316,36 @@ func ManaTracker(td TrackerData) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
var templ_7745c5c3_Var12 string
|
||||||
|
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(td.ManaBase)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/hptracker/tracker.templ`, Line: 157, Col: 61}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 19)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var13 = []any{"mana", manaAnimation(td.ManaStartPercentage, td.ManaPercentage)}
|
||||||
|
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var13...)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 20)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ.CSSClasses(templ_7745c5c3_Var13).String()))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 21)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
if !templ_7745c5c3_IsBuffer {
|
if !templ_7745c5c3_IsBuffer {
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W)
|
||||||
}
|
}
|
||||||
@@ -308,7 +375,7 @@ func manaAnimation(from, to string) templ.CSSClass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func baseStats() templ.Component {
|
func BaseStats(td TrackerData, bd BaseData) templ.Component {
|
||||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||||
if !templ_7745c5c3_IsBuffer {
|
if !templ_7745c5c3_IsBuffer {
|
||||||
@@ -316,12 +383,59 @@ func baseStats() templ.Component {
|
|||||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
templ_7745c5c3_Var12 := templ.GetChildren(ctx)
|
templ_7745c5c3_Var14 := templ.GetChildren(ctx)
|
||||||
if templ_7745c5c3_Var12 == nil {
|
if templ_7745c5c3_Var14 == nil {
|
||||||
templ_7745c5c3_Var12 = templ.NopComponent
|
templ_7745c5c3_Var14 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 19)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 22)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(td.HP))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 23)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(td.Mana))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 24)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(td.ManaRegen))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 25)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
if bd.Errors != "" {
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 26)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var15 string
|
||||||
|
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(bd.Errors)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/hptracker/tracker.templ`, Line: 209, Col: 65}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 27)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 28)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -340,22 +454,22 @@ func Hp(dd DamageData) templ.Component {
|
|||||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
templ_7745c5c3_Var13 := templ.GetChildren(ctx)
|
templ_7745c5c3_Var16 := templ.GetChildren(ctx)
|
||||||
if templ_7745c5c3_Var13 == nil {
|
if templ_7745c5c3_Var16 == nil {
|
||||||
templ_7745c5c3_Var13 = templ.NopComponent
|
templ_7745c5c3_Var16 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 20)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 29)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
if dd.Errors != "" {
|
if dd.Errors != "" {
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 21)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 30)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 22)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 31)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -363,40 +477,40 @@ func Hp(dd DamageData) templ.Component {
|
|||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 23)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 32)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
if dd.Errors != "" {
|
if dd.Errors != "" {
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 24)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 33)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
var templ_7745c5c3_Var14 string
|
var templ_7745c5c3_Var17 string
|
||||||
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(dd.Errors)
|
templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(dd.Errors)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/hptracker/tracker.templ`, Line: 195, Col: 67}
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/hptracker/tracker.templ`, Line: 243, Col: 67}
|
||||||
}
|
}
|
||||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 25)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 34)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 26)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 35)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
if dd.SavingThrow != "" {
|
if dd.SavingThrow != "" {
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 27)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 36)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 28)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 37)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
@@ -407,7 +521,7 @@ func Hp(dd DamageData) templ.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func Mana() templ.Component {
|
func Mana(md ManaData) templ.Component {
|
||||||
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) {
|
||||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer)
|
||||||
if !templ_7745c5c3_IsBuffer {
|
if !templ_7745c5c3_IsBuffer {
|
||||||
@@ -415,12 +529,53 @@ func Mana() templ.Component {
|
|||||||
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
defer templ.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||||
}
|
}
|
||||||
ctx = templ.InitializeContext(ctx)
|
ctx = templ.InitializeContext(ctx)
|
||||||
templ_7745c5c3_Var15 := templ.GetChildren(ctx)
|
templ_7745c5c3_Var18 := templ.GetChildren(ctx)
|
||||||
if templ_7745c5c3_Var15 == nil {
|
if templ_7745c5c3_Var18 == nil {
|
||||||
templ_7745c5c3_Var15 = templ.NopComponent
|
templ_7745c5c3_Var18 = templ.NopComponent
|
||||||
}
|
}
|
||||||
ctx = templ.ClearChildren(ctx)
|
ctx = templ.ClearChildren(ctx)
|
||||||
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 29)
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 38)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
if md.Errors != "" {
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 39)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 40)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(md.Values))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 41)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
if md.Errors != "" {
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 42)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
var templ_7745c5c3_Var19 string
|
||||||
|
templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(md.Errors)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ.Error{Err: templ_7745c5c3_Err, FileName: `view/hptracker/tracker.templ`, Line: 286, Col: 65}
|
||||||
|
}
|
||||||
|
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19))
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 43)
|
||||||
|
if templ_7745c5c3_Err != nil {
|
||||||
|
return templ_7745c5c3_Err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 44)
|
||||||
if templ_7745c5c3_Err != nil {
|
if templ_7745c5c3_Err != nil {
|
||||||
return templ_7745c5c3_Err
|
return templ_7745c5c3_Err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ if hx == false {
|
|||||||
<link rel="stylesheet" href="/stylesheets/tallytome.css" />
|
<link rel="stylesheet" href="/stylesheets/tallytome.css" />
|
||||||
|
|
||||||
<script src="/scripts/htmx.js"></script>
|
<script src="/scripts/htmx.js"></script>
|
||||||
<script src="/scripts/alpine.js" defer></script>
|
// <script src="/scripts/alpine.js" defer></script>
|
||||||
|
|
||||||
<title>Tallytome</title>
|
<title>Tallytome</title>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
Reference in New Issue
Block a user