From 81f3e3bae7d82f0e0ad72d89ea5a5fdae8804712 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Sun, 5 Jul 2026 00:41:11 -0400 Subject: fix: remove redundant 'quality' on items, fix ranged str on ammo, item admin ui updates --- data/.admin_history.json | 2 +- data/items/ammo/adamant_arrow.yaml | 3 +-- data/items/ammo/adamant_bolts.yaml | 2 +- data/items/ammo/bronze_arrow.yaml | 2 +- data/items/ammo/bronze_bolts.yaml | 2 +- data/items/ammo/diamond_bolts.yaml | 4 +-- data/items/ammo/diamond_bolts_e.yaml | 4 +-- data/items/ammo/emerald_bolts.yaml | 4 +-- data/items/ammo/emerald_bolts_e.yaml | 4 +-- data/items/ammo/iron_arrow.yaml | 2 +- data/items/ammo/iron_bolts.yaml | 2 +- data/items/ammo/mithril_arrow.yaml | 2 +- data/items/ammo/mithril_bolts.yaml | 2 +- data/items/ammo/ruby_bolts.yaml | 4 +-- data/items/ammo/ruby_bolts_e.yaml | 4 +-- data/items/ammo/rune_arrow.yaml | 2 +- data/items/ammo/rune_bolts.yaml | 2 +- data/items/ammo/sapphire_bolts.yaml | 4 +-- data/items/ammo/sapphire_bolts_e.yaml | 4 +-- data/items/ammo/steel_arrow.yaml | 2 +- data/items/ammo/steel_bolts.yaml | 2 +- data/items/consumables/bread_dough.yaml | 1 - data/items/tools/lighter.yaml | 1 - internal/admin/api_tools.go | 31 +++++++++++++++++++++++ internal/admin/server.go | 1 + internal/admin/static/itemeditor.js | 29 +++++++++++++--------- internal/admin/static/objecteditor.js | 44 ++++++++++++++++++++++++++++++++- internal/game/core_utils.go | 2 +- internal/item/item.go | 5 ++-- 29 files changed, 124 insertions(+), 49 deletions(-) create mode 100644 internal/admin/api_tools.go diff --git a/data/.admin_history.json b/data/.admin_history.json index 4639022..8212f5e 100644 --- a/data/.admin_history.json +++ b/data/.admin_history.json @@ -1 +1 @@ -{"history":[{"time":"2026-07-04T23:03:14-04:00","description":"move objects teak_tree to test/","file_path":"data/objects/teak_tree.yaml","new_file_path":"data/objects/test/teak_tree.yaml","old_content":"color: \"B3\"\ngather:\n deplete_timer: 50\n drops:\n - depletes: false\n item_id: teak_logs\n level: 35\n success_message: You get some {B3}teak logs{/}.\n weight: 100\n xp: 85\n fail_message: You swing but get no logs.\n gather_message: You swing your axe at the teak tree...\n nest_chance: 256\n respawn_broadcast: A {name} grows back.\n respawn_timer: 15\n skill: woodcutting\n success:\n base: 0.32\n cap: 0.82\n per_level: 0.01\n tools:\n - axe\nname: teak tree\n","new_content":"color: \"B3\"\ngather:\n deplete_timer: 50\n drops:\n - depletes: false\n item_id: teak_logs\n level: 35\n success_message: You get some {B3}teak logs{/}.\n weight: 100\n xp: 85\n fail_message: You swing but get no logs.\n gather_message: You swing your axe at the teak tree...\n nest_chance: 256\n respawn_broadcast: A {name} grows back.\n respawn_timer: 15\n skill: woodcutting\n success:\n base: 0.32\n cap: 0.82\n per_level: 0.01\n tools:\n - axe\nname: teak tree\n","is_delete":false,"is_create":false},{"time":"2026-07-04T23:03:19-04:00","description":"move objects teak_tree to root","file_path":"data/objects/test/teak_tree.yaml","new_file_path":"data/objects/teak_tree.yaml","old_content":"color: \"B3\"\ngather:\n deplete_timer: 50\n drops:\n - depletes: false\n item_id: teak_logs\n level: 35\n success_message: You get some {B3}teak logs{/}.\n weight: 100\n xp: 85\n fail_message: You swing but get no logs.\n gather_message: You swing your axe at the teak tree...\n nest_chance: 256\n respawn_broadcast: A {name} grows back.\n respawn_timer: 15\n skill: woodcutting\n success:\n base: 0.32\n cap: 0.82\n per_level: 0.01\n tools:\n - axe\nname: teak tree\n","new_content":"color: \"B3\"\ngather:\n deplete_timer: 50\n drops:\n - depletes: false\n item_id: teak_logs\n level: 35\n success_message: You get some {B3}teak logs{/}.\n weight: 100\n xp: 85\n fail_message: You swing but get no logs.\n gather_message: You swing your axe at the teak tree...\n nest_chance: 256\n respawn_broadcast: A {name} grows back.\n respawn_timer: 15\n skill: woodcutting\n success:\n base: 0.32\n cap: 0.82\n per_level: 0.01\n tools:\n - axe\nname: teak tree\n","is_delete":false,"is_create":false},{"time":"2026-07-04T23:03:22-04:00","description":"delete directory objects/test","file_path":"data/objects/test","old_content":"","new_content":"","is_delete":true,"is_create":false}],"redo":null} \ No newline at end of file +{"history":[{"time":"2026-07-05T00:28:41-04:00","description":"Update item adamant_arrow","file_path":"data/items/ammo/adamant_arrow.yaml","old_content":"color: \"78\"\ncraft:\n - end_message: \"\"\n fail: \"\"\n ingredients:\n - items:\n - headless_arrow\n quantity: 15\n - items:\n - adamant_arrowtips\n quantity: 15\n level: 60\n output_qty: 15\n start_message: \"\"\n station: []\n subtype: \"\"\n success_message: \"\"\n ticks_per_cycle: 2\n tool: \"\"\n type: fletching\n xp: 10\ndescription: An adamant-tipped arrow.\nequipment:\n other:\n ranged_strength: 31\n slot: ammo\n type: ammo\nid: adamant_arrow\nmax_quality: 0\nname: adamant arrow\nquality: 0\nrecoverable: true\nstackable: true\nvalue: 20\n","new_content":"color: \"78\"\ncraft:\n - end_message: \"\"\n fail: \"\"\n ingredients:\n - items:\n - headless_arrow\n quantity: 15\n - items:\n - adamant_arrowtips\n quantity: 15\n level: 60\n output_qty: 15\n start_message: \"\"\n station: []\n subtype: \"\"\n success_message: \"\"\n ticks_per_cycle: 2\n tool: \"\"\n type: fletching\n xp: 10\ndescription: An adamant-tipped arrow.\nequipment:\n other:\n ranged_strength: 31\n slot: ammo\n type: ammo\nid: adamant_arrow\nmax_quality: 0\nname: adamant arrow\nquality: 0\nrecoverable: true\nstackable: true\nvalue: 20\n","is_delete":false,"is_create":false}],"redo":null} \ No newline at end of file diff --git a/data/items/ammo/adamant_arrow.yaml b/data/items/ammo/adamant_arrow.yaml index 9cacf2f..4c732ce 100644 --- a/data/items/ammo/adamant_arrow.yaml +++ b/data/items/ammo/adamant_arrow.yaml @@ -22,13 +22,12 @@ craft: description: An adamant-tipped arrow. equipment: other: - ranged: 31 + ranged_strength: 31 slot: ammo type: ammo id: adamant_arrow max_quality: 0 name: adamant arrow -quality: 0 recoverable: true stackable: true value: 20 diff --git a/data/items/ammo/adamant_bolts.yaml b/data/items/ammo/adamant_bolts.yaml index 90476ad..587825d 100644 --- a/data/items/ammo/adamant_bolts.yaml +++ b/data/items/ammo/adamant_bolts.yaml @@ -15,7 +15,7 @@ craft: description: Adamant crossbow bolts. equipment: other: - ranged: 43 + ranged_strength: 43 slot: ammo type: ammo name: adamant bolts diff --git a/data/items/ammo/bronze_arrow.yaml b/data/items/ammo/bronze_arrow.yaml index 855b141..16b109a 100644 --- a/data/items/ammo/bronze_arrow.yaml +++ b/data/items/ammo/bronze_arrow.yaml @@ -15,7 +15,7 @@ craft: description: A bronze-tipped arrow. equipment: other: - ranged: 7 + ranged_strength: 7 slot: ammo type: ammo name: bronze arrow diff --git a/data/items/ammo/bronze_bolts.yaml b/data/items/ammo/bronze_bolts.yaml index ab04b3e..6d293b5 100644 --- a/data/items/ammo/bronze_bolts.yaml +++ b/data/items/ammo/bronze_bolts.yaml @@ -15,7 +15,7 @@ craft: description: Bronze crossbow bolts. equipment: other: - ranged: 10 + ranged_strength: 10 slot: ammo type: ammo name: bronze bolts diff --git a/data/items/ammo/diamond_bolts.yaml b/data/items/ammo/diamond_bolts.yaml index bff23ac..5c8e2a3 100644 --- a/data/items/ammo/diamond_bolts.yaml +++ b/data/items/ammo/diamond_bolts.yaml @@ -14,8 +14,8 @@ craft: xp: 7 description: Bolts tipped with diamond. Can be enchanted via science. equipment: - attack: - ranged: 9 + other: + ranged_strength: 9 slot: ammo type: ammo name: diamond bolts diff --git a/data/items/ammo/diamond_bolts_e.yaml b/data/items/ammo/diamond_bolts_e.yaml index 86209f2..42e4493 100644 --- a/data/items/ammo/diamond_bolts_e.yaml +++ b/data/items/ammo/diamond_bolts_e.yaml @@ -1,8 +1,8 @@ color: FF bold description: Enchanted diamond-tipped bolts. Have a chance to ignore the target's defense. equipment: - attack: - ranged: 10 + other: + ranged_strength: 10 slot: ammo type: ammo name: diamond bolts e diff --git a/data/items/ammo/emerald_bolts.yaml b/data/items/ammo/emerald_bolts.yaml index 4f1a123..a07a5be 100644 --- a/data/items/ammo/emerald_bolts.yaml +++ b/data/items/ammo/emerald_bolts.yaml @@ -14,8 +14,8 @@ craft: xp: 5 description: Bolts tipped with emerald. Can be enchanted via science. equipment: - attack: - ranged: 5 + other: + ranged_strength: 5 slot: ammo type: ammo name: emerald bolts diff --git a/data/items/ammo/emerald_bolts_e.yaml b/data/items/ammo/emerald_bolts_e.yaml index 59f3883..5440c25 100644 --- a/data/items/ammo/emerald_bolts_e.yaml +++ b/data/items/ammo/emerald_bolts_e.yaml @@ -1,8 +1,8 @@ color: 22 bold description: Enchanted emerald-tipped bolts. Have a chance to poison the target. equipment: - attack: - ranged: 6 + other: + ranged_strength: 6 slot: ammo type: ammo name: emerald bolts e diff --git a/data/items/ammo/iron_arrow.yaml b/data/items/ammo/iron_arrow.yaml index baaa64e..f739521 100644 --- a/data/items/ammo/iron_arrow.yaml +++ b/data/items/ammo/iron_arrow.yaml @@ -15,7 +15,7 @@ craft: description: An iron-tipped arrow. equipment: other: - ranged: 10 + ranged_strength: 10 slot: ammo type: ammo name: iron arrow diff --git a/data/items/ammo/iron_bolts.yaml b/data/items/ammo/iron_bolts.yaml index 2b93900..f939c80 100644 --- a/data/items/ammo/iron_bolts.yaml +++ b/data/items/ammo/iron_bolts.yaml @@ -15,7 +15,7 @@ craft: description: Iron crossbow bolts. equipment: other: - ranged: 17 + ranged_strength: 17 slot: ammo type: ammo name: iron bolts diff --git a/data/items/ammo/mithril_arrow.yaml b/data/items/ammo/mithril_arrow.yaml index 8e37103..9dd438a 100644 --- a/data/items/ammo/mithril_arrow.yaml +++ b/data/items/ammo/mithril_arrow.yaml @@ -15,7 +15,7 @@ craft: description: A mithril-tipped arrow. equipment: other: - ranged: 22 + ranged_strength: 22 slot: ammo type: ammo name: mithril arrow diff --git a/data/items/ammo/mithril_bolts.yaml b/data/items/ammo/mithril_bolts.yaml index d21d769..b443ba5 100644 --- a/data/items/ammo/mithril_bolts.yaml +++ b/data/items/ammo/mithril_bolts.yaml @@ -15,7 +15,7 @@ craft: description: Mithril crossbow bolts. equipment: other: - ranged: 32 + ranged_strength: 32 slot: ammo type: ammo name: mithril bolts diff --git a/data/items/ammo/ruby_bolts.yaml b/data/items/ammo/ruby_bolts.yaml index f539b4f..8862503 100644 --- a/data/items/ammo/ruby_bolts.yaml +++ b/data/items/ammo/ruby_bolts.yaml @@ -14,8 +14,8 @@ craft: xp: 6 description: Bolts tipped with ruby. Can be enchanted via science. equipment: - attack: - ranged: 7 + other: + ranged_strength: 7 slot: ammo type: ammo name: ruby bolts diff --git a/data/items/ammo/ruby_bolts_e.yaml b/data/items/ammo/ruby_bolts_e.yaml index 618cf62..b66b0b2 100644 --- a/data/items/ammo/ruby_bolts_e.yaml +++ b/data/items/ammo/ruby_bolts_e.yaml @@ -1,8 +1,8 @@ color: C4 bold description: Enchanted ruby-tipped bolts. Have a chance to deal extra damage based on the target's remaining HP. equipment: - attack: - ranged: 8 + other: + ranged_strength: 8 slot: ammo type: ammo name: ruby bolts e diff --git a/data/items/ammo/rune_arrow.yaml b/data/items/ammo/rune_arrow.yaml index 3db9665..bd663f6 100644 --- a/data/items/ammo/rune_arrow.yaml +++ b/data/items/ammo/rune_arrow.yaml @@ -15,7 +15,7 @@ craft: description: A rune-tipped arrow. equipment: other: - ranged: 49 + ranged_strength: 49 slot: ammo type: ammo name: rune arrow diff --git a/data/items/ammo/rune_bolts.yaml b/data/items/ammo/rune_bolts.yaml index 5875f05..5022d80 100644 --- a/data/items/ammo/rune_bolts.yaml +++ b/data/items/ammo/rune_bolts.yaml @@ -15,7 +15,7 @@ craft: description: Rune crossbow bolts. equipment: other: - ranged: 55 + ranged_strength: 55 slot: ammo type: ammo name: rune bolts diff --git a/data/items/ammo/sapphire_bolts.yaml b/data/items/ammo/sapphire_bolts.yaml index 893ddc3..5b6b698 100644 --- a/data/items/ammo/sapphire_bolts.yaml +++ b/data/items/ammo/sapphire_bolts.yaml @@ -14,8 +14,8 @@ craft: xp: 4 description: Bolts tipped with sapphire. Can be enchanted via science. equipment: - attack: - ranged: 3 + other: + ranged_strength: 3 slot: ammo type: ammo name: sapphire bolts diff --git a/data/items/ammo/sapphire_bolts_e.yaml b/data/items/ammo/sapphire_bolts_e.yaml index 07694ea..aa28211 100644 --- a/data/items/ammo/sapphire_bolts_e.yaml +++ b/data/items/ammo/sapphire_bolts_e.yaml @@ -1,8 +1,8 @@ color: 27 bold description: Enchanted sapphire-tipped bolts. Have a chance to drain the target's Science level. equipment: - attack: - ranged: 4 + other: + ranged_strength: 4 slot: ammo type: ammo name: sapphire bolts e diff --git a/data/items/ammo/steel_arrow.yaml b/data/items/ammo/steel_arrow.yaml index d1094ad..8a6063d 100644 --- a/data/items/ammo/steel_arrow.yaml +++ b/data/items/ammo/steel_arrow.yaml @@ -15,7 +15,7 @@ craft: description: A steel-tipped arrow. equipment: other: - ranged: 16 + ranged_strength: 16 slot: ammo type: ammo name: steel arrow diff --git a/data/items/ammo/steel_bolts.yaml b/data/items/ammo/steel_bolts.yaml index ab42ad7..2d0bc5c 100644 --- a/data/items/ammo/steel_bolts.yaml +++ b/data/items/ammo/steel_bolts.yaml @@ -15,7 +15,7 @@ craft: description: Steel crossbow bolts. equipment: other: - ranged: 25 + ranged_strength: 25 slot: ammo type: ammo name: steel bolts diff --git a/data/items/consumables/bread_dough.yaml b/data/items/consumables/bread_dough.yaml index 9909c58..8b9405e 100644 --- a/data/items/consumables/bread_dough.yaml +++ b/data/items/consumables/bread_dough.yaml @@ -29,6 +29,5 @@ description: A ball of uncooked bread dough. It needs to be baked. id: bread_dough max_quality: 0 name: bread dough -quality: 0 stackable: false value: 3 diff --git a/data/items/tools/lighter.yaml b/data/items/tools/lighter.yaml index 9f47a45..ee73da3 100644 --- a/data/items/tools/lighter.yaml +++ b/data/items/tools/lighter.yaml @@ -5,7 +5,6 @@ equipment: type: tool max_quality: 100 name: lighter -quality: 100 stackable: false tool: speed: 4 diff --git a/internal/admin/api_tools.go b/internal/admin/api_tools.go new file mode 100644 index 0000000..9ed7ec3 --- /dev/null +++ b/internal/admin/api_tools.go @@ -0,0 +1,31 @@ +package admin + +import ( + "net/http" +) + +func (s *AdminServer) handleTools(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodGet { + http.Error(w, "method not allowed", http.StatusMethodNotAllowed) + return + } + + items, err := s.itemStore.LoadAll() + if err != nil { + http.Error(w, "failed to load items", http.StatusInternalServerError) + return + } + + seen := map[string]bool{} + var tools []string + for _, def := range items { + if def.Tool != nil && def.Tool.Type != "" { + if !seen[def.Tool.Type] { + seen[def.Tool.Type] = true + tools = append(tools, def.Tool.Type) + } + } + } + + writeJSON(w, tools) +} diff --git a/internal/admin/server.go b/internal/admin/server.go index 04e68a6..53dd5c8 100644 --- a/internal/admin/server.go +++ b/internal/admin/server.go @@ -148,6 +148,7 @@ func NewServer(cfg *config.Config, useTLS bool, accountStore *player.AccountStor apiMux.HandleFunc("/api/players", s.handlePlayers) apiMux.HandleFunc("/api/dashboard", s.handleDashboard) apiMux.HandleFunc("/api/flags", s.handleFlags) + apiMux.HandleFunc("/api/tools", s.handleTools) apiMux.HandleFunc("/api/search", s.handleSearch) apiMux.HandleFunc("/api/undo/state", s.handleUndoState) apiMux.HandleFunc("/api/undo/undo", s.doUndo) diff --git a/internal/admin/static/itemeditor.js b/internal/admin/static/itemeditor.js index 84090a1..f1450ab 100644 --- a/internal/admin/static/itemeditor.js +++ b/internal/admin/static/itemeditor.js @@ -12,8 +12,7 @@ var SECTIONS = [ ['color', 'Color', 'color', 'B2'], ['value', 'Value', 'number', '0'], ['stackable', 'Stackable', 'checkbox'], - ['quality', 'Quality', 'number', ''], - ['max_quality', 'Max Quality', 'number', ''], + ['max_quality', 'Quality', 'number', ''], ['aliases', 'Aliases', 'text', 'comma separated'], ['description', 'Description', 'textarea', 'A chunk of copper ore.'], ] @@ -57,9 +56,9 @@ var SECTIONS = [ ['station', 'Station', 'select', '|anvil|cooking_range|fire|furnace|pottery_oven|pottery_wheel|spinning_wheel|workbench'], ['tool', 'Tool', 'select', '|pickaxe|axe|fire|chisel|hammer|knife|needle|rake|saw|shears|spade|watering_can|fishing_rod|fly_rod|harpoon|small_net|big_net|lobster_pot'], ['fail', 'Fail Item', 'search', '', '', null, 'items'], - ['success_base', 'Base', 'number', '', 'narrow'], - ['success_per_level', 'Per Lvl', 'number', '', 'narrow'], - ['success_cap', 'Cap', 'number', '', 'narrow'], + ['success_base', 'Base', 'number', '0.5', 'narrow'], + ['success_per_level', 'Per Lvl', 'number', '0.01', 'narrow'], + ['success_cap', 'Cap', 'number', '0.95', 'narrow'], ['start_message', 'Start Message', 'text', 'e.g. You begin smithing %i1.', 'wide'], ['success_message', 'Success Message', 'text', 'e.g. You smith a %n.', 'wide'], ['fail_message', 'Fail Message', 'text', 'e.g. You accidentally burn the %i1.', 'wide', function(item) { return item.type === 'cooking' || item.subtype === 'smelt'; }], @@ -297,7 +296,7 @@ function renderCoreCard(data) { var h = '