From 9d55b2954a6f38909d15007c232933513e0d4fb0 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sun, 27 Apr 2025 13:48:35 -0400 Subject: [PATCH] The rituals can now craft from items taken from dead enemies and they go into the blanket right away. --- combat_ui.cpp | 2 +- ritual_ui.cpp | 3 ++- rituals.cpp | 6 ++++++ rituals.hpp | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/combat_ui.cpp b/combat_ui.cpp index c1d836f..e46d50a 100644 --- a/combat_ui.cpp +++ b/combat_ui.cpp @@ -39,7 +39,7 @@ namespace gui { $gui.world().set_the({$gui.$parser, ColorValue::DARK_MID}); auto& the_belt = $level.world->get_the(); - for(int slot = 0; slot < 4; slot++) { + for(int slot = 0; slot < the_belt.max_slots; slot++) { if(the_belt.has(slot)) { std::string name = fmt::format("button_{}", slot); auto& ritual = the_belt.get(slot); diff --git a/ritual_ui.cpp b/ritual_ui.cpp index 0d050df..2f2b7b9 100644 --- a/ritual_ui.cpp +++ b/ritual_ui.cpp @@ -105,7 +105,8 @@ namespace gui { // remove the items from the blanket now auto& the_belt = $level.world->get_the(); - the_belt.equip(0, ritual); + + the_belt.equip(the_belt.next(), ritual); $level.world->send(Events::GUI::NEW_RITUAL, $level.player, {}); reset_inv_positions(); diff --git a/rituals.cpp b/rituals.cpp index 4839c03..87c4902 100644 --- a/rituals.cpp +++ b/rituals.cpp @@ -130,6 +130,12 @@ namespace ritual { equipped.erase(index); } + int Belt::next() { + int slot = next_slot % max_slots; + next_slot++; + return slot; + } + DinkyECS::Entity Blanket::add(JunkItem name) { auto ent = contents.entity(); contents.set(ent, name); diff --git a/rituals.hpp b/rituals.hpp index 370b426..b84f4e1 100644 --- a/rituals.hpp +++ b/rituals.hpp @@ -62,12 +62,15 @@ namespace ritual { }; struct Belt { + int next_slot = 0; + int max_slots = 6; std::unordered_map equipped; Action& get(int index); void equip(int index, Action& action); bool has(int index); void unequip(int index); + int next(); }; using JunkItem = std::string;