~muirrum/hkgi

657efa332360d7e614876b02022b26845635a703 — Cara Salter 7 months ago 67296ef
craft: WIP craft
1 files changed, 14 insertions(+), 1 deletions(-)

M internal/handlers/hkgi.go
M internal/handlers/hkgi.go => internal/handlers/hkgi.go +14 -1
@@ 348,7 348,20 @@ func Craft(c *fiber.Ctx) error {
				recipe["make_item"].(string): 1,
			})
		default:
			one_of := recipe["make_item"].([]
			one_of := recipe["make_item"].(map[string]interface{})["one_of"].([][]any)
			r := rand.Float64()
			i := 0
			var item string
			for next := true; next; next = r > 0 && i < len(one_of) {
				pair := one_of[i]
				chance := pair[0].(float64)
				item = pair[1].(string)
				r -= chance
			}

			game.GiveItem(u, map[string]interface{}{
				item: 1,
			})
		}
	}