package action

import (
	"autobrew/utils"
	"fmt"
)

type StepAction int

const (
	Prepare StepAction = iota
	Base
	AddToCauldron
	GrindIngredients
	Boil
	BoilBellows
	PourPhial
	Distill
	GrindPotion
)

func (e *StepAction) UnmarshalText(text []byte) (err error) {
	name := string(text)
	// *e, err = ParseEngine(name)
	fmt.Println(name)
	return
}

func (a *StepAction) UnmarshalYAML(unmarshal func(any) error) error {
	var s string
	err := unmarshal(&s)
	if err != nil {
		return err
	}
	s = utils.Strip(s)
	switch s {
	case "Prepare":
		*a = Prepare
	case "Base":
		*a = Base
	case "AddToCauldron":
		*a = AddToCauldron
	case "GrindIngredients":
		*a = GrindIngredients
	case "Boil":
		*a = Boil
	case "BoilBellows":
		*a = BoilBellows
	case "PourPhial":
		*a = PourPhial
	case "Distill":
		*a = Distill
	case "GrindPotion":
		*a = GrindPotion
	default:
		return fmt.Errorf("Invalid Action: %s", s)
	}
	return nil
}
