using UnityEngine;
using System.Collections;

public class Witch : Graph {

    public Controller controller;
	// Use this for initialization
	void Awake () {
        currentState = startState;
	}
	
	// Update is called once per frame
	void Update () {
        ChangeState();
	}

    void ChangeState() {
        
        switch (currentState)
        {
            case Constants.Colors.CYAN: {
                    ControlCyan();
                    break;
            }
            case Constants.Colors.ORANGE: {
                    ControlOrange();
                    break;
                }
            case Constants.Colors.RED: {
                    ControlRed();
                    break;
                }
            case Constants.Colors.GREEN: {
                    ControlGreen();
                    break;
                }
            case Constants.Colors.MAGENTA: {
                    ControlMagenta();
                    break;
                }
            case Constants.Colors.YELLOW: {
                    ControlYellow();
                    break;
                }

        }
    }

    void ControlYellow() {
        if (controller.ings.Count == 4 && controller.ings[3] == "SR" && controller.ings[2] == "Troll Snot" && controller.ings[1] == "SL" && controller.ings[0] == "Kraken Ink") {
            currentState = Constants.Colors.GREEN;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 1 && controller.ings[0] == "SL") {
            currentState = Constants.Colors.RED;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 1 && controller.ings[0] == "Grave Dirt") {
            currentState = Constants.Colors.ORANGE;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 2 && controller.ings[1] == "Mermaid Findust" && controller.ings[0] == "Mermaid Findust") {
            currentState = Constants.Colors.CYAN;
            controller.ings.Clear();
        }
    }

    void ControlCyan() {
        if (controller.ings.Count == 4 && controller.ings[3] == "Stardust" && controller.ings[2] == "Kraken Ink" && controller.ings[1] == "SR" && controller.ings[0] == "SR") {
            currentState = Constants.Colors.RED;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 3 && controller.ings[2] == "SR" && controller.ings[1] == "Flies" && controller.ings[0] == "SL") {
            currentState = Constants.Colors.MAGENTA;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 1 && controller.ings[0] == "Dragon's Blood") {
            currentState = Constants.Colors.GREEN;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 2 && controller.ings[1] == "Kraken Ink" && controller.ings[0] == "Kraken Ink") {
            currentState = Constants.Colors.YELLOW;
            controller.ings.Clear();
        }
    }


    void ControlRed() {
        if (controller.ings.Count == 4 && controller.ings[3] == "SL" && controller.ings[2] == "SL" && controller.ings[1] == "Mermaid Findust" && controller.ings[0] == "Lava") {
            currentState = Constants.Colors.CYAN;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 3 && controller.ings[2] == "Eye of The Tiger" && controller.ings[1] == "Stardust" && controller.ings[0] == "Wings of a Bat") {
            currentState = Constants.Colors.ORANGE;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 1 && controller.ings[0] == "SR") {
            currentState = Constants.Colors.YELLOW;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 2 && controller.ings[1] == "Wings of a Bat" && controller.ings[0] == "Mermaid Findust") {
            currentState = Constants.Colors.MAGENTA;
            controller.ings.Clear();
        }

    }

    void ControlOrange() {
        if (controller.ings.Count == 1 && controller.ings[0] == "Unicorn Blood") {
            currentState = Constants.Colors.YELLOW;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 3 && controller.ings[2] == "Flies" && controller.ings[1] == "Lava" && controller.ings[0] == "Dragon's Claw") {
            currentState = Constants.Colors.RED;
            controller.ings.Clear();
        }
    }

    void ControlMagenta() {
        if (controller.ings.Count == 2 && controller.ings[1] == "Kraken Ink" && controller.ings[0] == "Flies") {
            currentState = Constants.Colors.RED;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 3 && controller.ings[2] == "SR" && controller.ings[1] == "Wings of a Bat" && controller.ings[0] == "SL") {
            currentState = Constants.Colors.CYAN;
            controller.ings.Clear();
        }
    }

    void ControlGreen() {
        if (controller.ings.Count == 1 && controller.ings[0] == "Bone Dust") {
            currentState = Constants.Colors.CYAN;
            controller.ings.Clear();
        }
        else if (controller.ings.Count == 4 && controller.ings[3] == "Mermaid Findust" && controller.ings[2] == "SR" && controller.ings[1] == "Poppy Seeds" && controller.ings[0] == "SL") {
            currentState = Constants.Colors.YELLOW;
            controller.ings.Clear();
        }
    }
}
