33 lines
908 B
GDScript
33 lines
908 B
GDScript
extends Node
|
|
|
|
const APPLE = 0
|
|
const GRAPE = 1
|
|
|
|
const NONE = "NONE"
|
|
const SHURIKEN = "SHURIKEN"
|
|
const FIREBALL = "FIREBALL"
|
|
const FIRE_SWIRL = "FIRE_SWIRL"
|
|
const TORNADO = "TORNADO"
|
|
|
|
# Each spell's display recipe: sorted apples-first, grapes-last
|
|
var recipes: Dictionary = {
|
|
SHURIKEN: [APPLE, GRAPE, GRAPE],
|
|
FIREBALL: [APPLE, APPLE, APPLE],
|
|
FIRE_SWIRL: [APPLE, APPLE, GRAPE],
|
|
TORNADO: [GRAPE, GRAPE, GRAPE],
|
|
}
|
|
|
|
# Takes cauldron slot_states (uses texture indices: 2 = apple, 4 = grape)
|
|
# and returns which spell that combination brews.
|
|
func identify(cauldron_slots: Array) -> String:
|
|
var apples = cauldron_slots.count(2)
|
|
var grapes = cauldron_slots.count(4)
|
|
for spell_id in recipes:
|
|
var r: Array = recipes[spell_id]
|
|
if r.count(APPLE) == apples and r.count(GRAPE) == grapes:
|
|
return spell_id
|
|
return NONE
|
|
|
|
func get_recipe(spell: String) -> Array:
|
|
return recipes.get(spell, [])
|