summaryrefslogtreewikicommitdiff
path: root/core/src/inv/BlockHunt.kt
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2026-03-26 23:15:33 -0400
committerFreya Murphy <freya@freyacat.org>2026-03-27 23:09:23 -0400
commitf8322cd21cde68a72b05efbad3a05b8e67c0bdd0 (patch)
treed7e60bc8fedadc8fa7ae725571cad1f398eaf6dc /core/src/inv/BlockHunt.kt
downloadkenshinshideandseek2-f8322cd21cde68a72b05efbad3a05b8e67c0bdd0.tar.gz
kenshinshideandseek2-f8322cd21cde68a72b05efbad3a05b8e67c0bdd0.tar.bz2
kenshinshideandseek2-f8322cd21cde68a72b05efbad3a05b8e67c0bdd0.zip
initial
Diffstat (limited to 'core/src/inv/BlockHunt.kt')
-rw-r--r--core/src/inv/BlockHunt.kt26
1 files changed, 26 insertions, 0 deletions
diff --git a/core/src/inv/BlockHunt.kt b/core/src/inv/BlockHunt.kt
new file mode 100644
index 0000000..615c746
--- /dev/null
+++ b/core/src/inv/BlockHunt.kt
@@ -0,0 +1,26 @@
+package cat.freya.khs.inv
+
+import cat.freya.khs.Khs
+import cat.freya.khs.config.ItemConfig
+import cat.freya.khs.game.KhsMap
+import cat.freya.khs.player.Inventory
+
+const val BLOCKHUNT_TITLE_PREFIX = "Select a Block: "
+
+fun createBlockHuntPicker(plugin: Khs, map: KhsMap): Inventory? {
+ val blocks = map.config.blockHunt.blocks
+
+ // make inv
+ val rows = (blocks.size.toUInt() + 8u) / 9u
+ val size = minOf(rows * 9u, 9u)
+ val inv = plugin.shim.createInventory("$BLOCKHUNT_TITLE_PREFIX${map.name}", size) ?: return null
+
+ // add items
+ blocks
+ .map { plugin.shim.parseItem(ItemConfig(material = it)) }
+ .filterNotNull()
+ .withIndex()
+ .forEach { (i, item) -> inv.set(i.toUInt(), item) }
+
+ return inv
+}