Are you sure you want to buy this item?
+ +diff --git a/assets/dk.css b/assets/dk.css index a08761a..a6c0206 100644 --- a/assets/dk.css +++ b/assets/dk.css @@ -32,7 +32,7 @@ h3 { font-size: 1.4rem; font-weight: bold; } h4 { font-size: 1.1rem; font-weight: bold; } div#container { - width: 90vw; + max-width: 1024px; display: flex; flex-direction: column; margin: 0px auto; @@ -357,13 +357,9 @@ table { } } -table.item-shop { +table.shop { width: 80%; margin: 0px auto; - - td:first-child { - width: fit-content; - } } div.modal { diff --git a/internal/routes/town.go b/internal/routes/town.go index 799bd10..296ecd4 100644 --- a/internal/routes/town.go +++ b/internal/routes/town.go @@ -14,6 +14,17 @@ import ( "strconv" ) +// Map acts as a representation of owned/unowned maps in the town stores. +type Map struct { + ID int + Name string + Cost int + Owned bool + X int + Y int + TP int +} + func RegisterTownRoutes(r *router.Router) { group := r.Group("/town") group.Use(middleware.RequireAuth()) @@ -21,9 +32,11 @@ func RegisterTownRoutes(r *router.Router) { group.Get("/", showTown) group.Get("/inn", showInn) - group.Get("/shop", showShop) group.WithMiddleware(middleware.CSRF(auth.Manager)).Post("/inn", rest) + group.Get("/shop", showShop) group.Get("/shop/buy/:id", buyItem) + group.Get("/maps", showMaps) + group.Get("/maps/buy/:id", buyMap) } func showTown(ctx router.Ctx, _ []string) { @@ -133,3 +146,77 @@ func buyItem(ctx router.Ctx, params []string) { ctx.Redirect("/town/shop", 302) } + +func showMaps(ctx router.Ctx, _ []string) { + var errorHTML string + if flash := auth.GetFlashMessage(ctx); flash != nil { + errorHTML = `
Buying maps will put the town in your Travel To box, and it won't cost you as many TP to get there.
+Click a town name to purchase its map.
++ {if map.Owned == false} + {if user.Gold >= map.Cost} + {map.Name} + {else} + {map.Name} + {/if} + {else} + {map.Name} + {/if} + | +
+ {if map.Owned == false}
+ {if user.Gold >= map.Cost}
+ {map.Cost}G
+ {else}
+ {map.Cost}G (can't afford)
+ {/if}
+ {else}
+ {map.X}, {map.Y} + TP Cost: {map.TP} + {/if} + |
+
If you've changed your mind, you may also return back to town.
+Are you sure you want to buy this item?
+ +