animesprite unable to switch anime

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By D.Q.Li

I am trying to create an effect for my game NPC that allows it to have different idle animation randomly. I planned to achieve it with state machine and array but the code fails to work dispite having no error messages, here are the codes:

extends AnimatedSprite
var state = five
var next_anime = 4
onready var anime = $Knight_NPC_anime
var choose = [one,two,three,four,five]
enum{
	one
	two
	three
	four
	five
}
func _play_anime():
	match state:
		one:
			anime.play.anime_1
			print("play1")
		two:
			anime.play.anime_2
			print("play2")
		three:
			anime.play.anime_3
			print("play3")
		four:
			anime.play.anime_4
			print("play4")
		five:
			anime.play.anime_5
			print("play5")
func _on_Knight_NPC_anime_animation_finished():
	print("swap")
	next_anime = rand_range(0,4)
	state = choose[next_anime]

all the print code is for debug
I think the problem is because I referenced the exact same node. Please tell me if there is anyway to solve it.