extends Node2D

var slimes = [
	"garden",
	"marsh",
	"bark",
	"moss",
	"canopy",
	"loam",
	"lagoon",
	"foam",
	"coral",
	"mud",
	"quartz",
	"amanita",
	"cactus",
	"brick",
	"wisp",
	"cave",
	"sunflower",
	"honey",
	"seaweed",
	"kudzu",
	"ivy",
	"chili",
	"cloud",
	"zen",
	"sand",
	"snail",
	"charcoal",
	"snowflake",
	"hermit",
	"magnetic",
	#"sulphur",
	"mint",
	#"basalt",
	"algae",
	"lilypad",
	"silver",
	"leaf",
	"chalk",
	"lava",
	"watermelon",
	"tuna",
	"lightning",
	"clamshell",
	"water",
	"cubic",
	"tundra",
	"rice",
	#"cereal",
	"salmon",
	"banana",
	#"love",
	"acorn",
	"shark",
	"vapour",
	"upward",
	"clover",
	"peach",
	"ababa",
	"pixie",
	"bouncy",
	"breeze",
	"six",
	"bean",
	"holy",
	"citrus",
	"crab",
	"tomato",
	"dandelion",
	"hairy",
	"coffee",
	"copper",
	"onion",
	"bear",
	"pumpkin",
	"fly",
	"firefly",
	"cow",
	"dog",
	"husky",
	"tabby",
	"bunny",
	"panda",
	"seal",
	"pineapple",
	#"sheepsalt",
	"sunbeam",
	#"bramble",
	#"arboreal",
	#"groveheart",
	"verdant",
	#"fern",
	"marine",
	"fortress",
	"pop",
	"blade",
	"trapper",
	"godot",
	"cat",
	"trout",
	"tea",
	"makona",
	#"dedia",
	"sushi",
	"milk",
	"navi",
	"ghost",
	"gargoyle",
	"box",
	#"feral",
	"draco",
	#"fossil",
	"ramen",
	"fuzzy",
	"wig",
	"sunbear",
	"polar",
	"artillery",
	"frosthorn",
	"arcane",
	"miremaw",
	"abyssal",
	"spooky",
	"balm",
	"bomb",
	"meat",
	#"titanic",
	"mime",
	"hollow",
	"googly",
	"gon",
	"celestial",
	"spectral",
	"crystal",
	"dapper",
	"rattle",
	"tinker",
	"memory",
	"train",
	"godotstein",
	"booty",
	"squirrel",
	"goyao",
	"babu",
	#"orion",
	"raine",
	"pandora",
	"francis",
	"slimon",
	"mimic",
	#"echo",
	#"basilisk",
	"oats",
]

var slime_images = {}

var current_slime

@onready var sprite_2d: Sprite2D = $Sprite2D


func _ready() -> void:
	get_viewport().transparent_bg = true
	
	for slime in slimes:
		slime_images[slime] = {}
		slime_images[slime].variants = []
		for i in range(1, 4):
			slime_images[slime].variants.push_back(load("res://slimes/%s-%d.png" % [slime, i]))
	
	current_slime = slimes.pick_random()
	sprite_2d.texture = slime_images[current_slime].variants.pick_random()


func _on_set_slime_buddy_redemption_listener_received(data: Dictionary) -> void:
	if slimes.has(data.user_input.to_lower()):
		current_slime = data.user_input.to_lower()
		sprite_2d.texture = slime_images[current_slime].variants.pick_random()


func _on_change_slime_buddy_redemption_listener_received(data: Dictionary) -> void:
	var new_slime = current_slime
	while new_slime == current_slime:
		new_slime = slimes.pick_random()
	current_slime = new_slime
	sprite_2d.texture = slime_images[current_slime].variants.pick_random()