using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ConverseStates : MonoBehaviour {

	static ConverseStates __self;

	Dictionary<string, int> planetConversation;

	// Use this for initialization
	void Start () {
		__self = this;
		planetConversation = new Dictionary<string, int>();
		planetConversation["Mercury"] = 0;
		planetConversation["Venus"] = 0;
		planetConversation["Earth"] = 0;
		planetConversation["Mars"] = 0;
		planetConversation["Phaeton"] = 0;
		planetConversation["Jupiter"] = 0;
		planetConversation["Saturn"] = 0;
		planetConversation["Uranus"] = 0;
		planetConversation["Neptune"] = 0;
	}
	
	// Update is called once per frame
	public static string[] GetConversation(string planet){
		switch(planet){
		case "Mercury":
			return __self.MercuryConversation();
		case "Venus":
			return __self.VenusConversation();
		case "Earth":
			return __self.EarthConversation();
		case "Mars":
			return __self.MarsConversation();
		case "Phaeton":
			return __self.PhaetonConversation();
		case "Jupiter":
			return __self.JupiterConversation();
		case "Saturn":
			return __self.SaturnConversation();
		case "Uranus":
			return __self.UranusConversation();
		case "Neptune":
			return __self.NeptuneConversation();
		default:
			return null;
		}
	}

	public string[] MercuryConversation(){
		List<string> conv = new List<string>();
		switch(planetConversation["Mercury"]){
		case 0:
			conv.Add("Mercury: Hey buddy, what are you doing way over here?");
			if(planetConversation["Phaeton"] == 0){
				conv.Add("I know people look down on you 'cause you're small, but you should try making conversation anyway.");
				conv.Add("You are a planet after all. Nothing's gonna change that!");
				planetConversation["Mercury"] = 1;
			}else{
				conv.Add("I know people look down on you 'cause you're small, but you should try making conversation anyway.");
				conv.Add("You are a planet after all. Nothing's gonna change that!");
				conv.Add("You heard Phaeton saying he's going to throw us into the Sun?");
				conv.Add("That's preposterous! What is he thinking? We'll need some help to talk him down.");
				conv.Add("I'll come with you, in case you need some help.");
				planetConversation["Mercury"] = 2;
				ConversationManager.atConvEnd = () => {
					GlobalScript.JoinPluto(0);
					GlobalScript.getPlayer().SendMessage("Detatch");
				};

			}
			break;
		case 1:
			if(planetConversation["Phaeton"] == 0){
				conv.Add("I know people look down on you 'cause you're small, but you should try making conversation anyway.");
				conv.Add("You are a planet after all. Nothing's gonna change that!");
				planetConversation["Mercury"] = 1;
			}else{
				conv.Add("You heard Phaeton saying he's going to throw us into the Sun?");
				conv.Add("That's preposterous! What is he thinking? We'll need some help to talk him down.");
				conv.Add("I'll come with you, in case you need some help.");
				planetConversation["Mercury"] = 2;
				ConversationManager.atConvEnd = () => {
					GlobalScript.JoinPluto(0);
					GlobalScript.getPlayer().SendMessage("Detatch");
				};

			}
			break;
		default:
			break;
		}
		return conv.ToArray();
	}

	public string[] VenusConversation(){
		List<string> conv = new List<string>();
		switch(planetConversation["Venus"]){
		case 0:
			conv.Add("Venus: Who's there? Why, it's little old Pluto, how are you getting along?");
			if(planetConversation["Phaeton"] == 0){
				conv.Add("It's dangerous this close to the sun, be careful.");
				conv.Add("Watch out for Mars. He's got a mean streak in him.");
				planetConversation["Venus"] = 1;
			}else{
				conv.Add("Phaeton? Why he's harmless!");
				if(GlobalScript.hasJoined(3)){
					conv.Add("Is that Mars with you? You must be serious then. I'm coming along.");
					conv.Add("No, don't try to stop me. You're going to hurt yourself, if I'm not there.");
					planetConversation["Venus"] = 2;
					ConversationManager.atConvEnd = () => {
						GlobalScript.JoinPluto(1);
						GlobalScript.getPlayer().SendMessage("Detatch");
					};
				}else{
					conv.Add("You're just being silly. Run along, now.");
					planetConversation["Venus"] = 1;
				}
			}
			break;
		case 1:
			if(planetConversation["Phaeton"] == 0){
				conv.Add("It's dangerous this close to the sun, be careful.");
				conv.Add("Watch out for Mars. He's got a mean streak in him.");
				planetConversation["Venus"] = 1;
			}else{
				conv.Add("Phaeton? Why he's harmless!");
				if(GlobalScript.hasJoined(3)){
					conv.Add("Is that Mars with you? You must be serious then. I'm coming along.");
					conv.Add("No, don't try to stop me. You're going to hurt yourself if I'm not there.");
					planetConversation["Venus"] = 2;
					ConversationManager.atConvEnd = () => {
						GlobalScript.JoinPluto(1);
						GlobalScript.getPlayer().SendMessage("Detatch");
					};
				}else{
					conv.Add("You're just being silly. Run along, now.");
					planetConversation["Venus"] = 1;
				}
			}
			break;
		default:
			break;
		}
		return conv.ToArray();
	}

	public string[] EarthConversation(){
		List<string> conv = new List<string>();
		switch(planetConversation["Earth"]){
		case 0:
			conv.Add("Earth: Hmm? Oh, look, it's Pluto!");
			if(planetConversation["Phaeton"] == 0){
				conv.Add("Hanging out with the small planets for a cycle?");
				conv.Add("Must be lonely all the way in the back.");
				planetConversation["Earth"] = 1;
			}else{
				conv.Add("Hanging out with the small planets for a cycle?");
				conv.Add("Must be lonely all the way in the back.");
				conv.Add("I wouldn't want to go against a planet like Phaeton.");
				if(GlobalScript.hasJoined(3)){
					conv.Add("Oh, Mars, I didn't see you there.");
					conv.Add("I don't want any trouble. If you think it's worth looking into, I'll come.");
					planetConversation["Earth"] = 2;
					ConversationManager.atConvEnd = () => {
						GlobalScript.JoinPluto(2);
						GlobalScript.getPlayer().SendMessage("Detatch");
					};
				}else{
					conv.Add("We'd need some real strength, and you aren't it.");
					planetConversation["Earth"] = 1;
				}
			}
			break;
		case 1:
			if(planetConversation["Phaeton"] == 0){
				conv.Add("Hanging out with the small planets for a cycle?");
				conv.Add("Must be lonely all the way in the back.");
				planetConversation["Earth"] = 1;
			}else{
				conv.Add("I wouldn't want to go against a planet like Phaeton.");
				if(GlobalScript.hasJoined(3)){
					conv.Add("Oh, Mars, I didn't see you there.");
					conv.Add("I don't want any trouble. If you think it's worth looking into, I'll come.");
					planetConversation["Earth"] = 2;
					ConversationManager.atConvEnd = () => {
						GlobalScript.JoinPluto(2);
						GlobalScript.getPlayer().SendMessage("Detatch");
					};
				}else{
					conv.Add("We'd need some real strength, and you aren't it.");
					planetConversation["Earth"] = 1;
				}
			}
			break;
		default:
			break;
		}
		return conv.ToArray();
	}

	public string[] MarsConversation(){
		List<string> conv = new List<string>();
		switch(planetConversation["Mars"]){
		case 0:
			conv.Add("Mars: Who is invading me? Pluto? Pah!");
			if(planetConversation["Phaeton"] == 0){
				conv.Add("Go back to your home in the far reaches of the system.");
				conv.Add("Leave before I retalliate!");
				planetConversation["Mars"] = 1;
			}else{
				conv.Add("Go back to your home in the far reaches of the system.");
				conv.Add("Leave before I retalliate!");
				conv.Add("Phaeton, you say? I've had my eye on his territory for a while.");
				if(GlobalScript.hasJoined(0)){
					conv.Add("I see you are forming an army for this endeavor.");
					conv.Add("Very well. I will lead it to victory in the ensuing battle.");
					planetConversation["Mars"] = 2;
					ConversationManager.atConvEnd = () => {
						GlobalScript.JoinPluto(3);
						GlobalScript.getPlayer().SendMessage("Detatch");
					};
				}else{
					conv.Add("But you are no warrior and I would be a fool to go it alone.");
					planetConversation["Mars"] = 1;
				}
			}
			break;
		case 1:
			if(planetConversation["Phaeton"] == 0){
				conv.Add("Go back to your home in the far reaches of the system.");
				conv.Add("Leave before I retalliate!");
				planetConversation["Mars"] = 1;
			}else{
				conv.Add("Phaeton, you say? I've had my eye on his territory for a while.");
				if(GlobalScript.hasJoined(0)){
					conv.Add("I see you are forming an army for this endeavor.");
					conv.Add("Very well. I will lead it to victory in the ensuing battle.");
					planetConversation["Mars"] = 2;
					ConversationManager.atConvEnd = () => {
						GlobalScript.JoinPluto(3);
						GlobalScript.getPlayer().SendMessage("Detatch");
					};
				}else{
					conv.Add("But you are no warrior and I would be a fool to go it alone.");
					planetConversation["Mars"] = 1;
				}
			}
			break;
		default:
			break;
		}
		return conv.ToArray();
	}

	public string[] PhaetonConversation(){
		List<string> conv = new List<string>();
		switch(planetConversation["Phaeton"]){
		case 0:
			conv.Add("Phaeton: They have mocked me long enough!");
			conv.Add("Slow though I am now, with the Sun's chariot, I shall surpass them all.");
			conv.Add("And every one of them I will hurtle into the Sun himself.");
			conv.Add("A fitting sacrifice to my father, and to my future reign over the whole system.");
			planetConversation["Phaeton"] = 1;
			break;
		case 1:
			conv.Add("*grumble* *grumble* How dare they?");
			conv.Add("*whisper* MY chariot now!");
			planetConversation["Phaeton"] = 1;
			break;
		default:
			break;
		}
		return conv.ToArray();
	}

	public string[] JupiterConversation(){
		List<string> conv = new List<string>();
		switch(planetConversation["Jupiter"]){
		case 0:
			conv.Add("Jupiter: Is someone there? No, I guess not.");
			if(planetConversation["Phaeton"] == 0){
				planetConversation["Jupiter"] = 0;
			}else{
				if(GlobalScript.hasJoined(6)){
					conv.Add("My goodness, all my subjects are here to praise me!");
					conv.Add("What? Phaeton said he would drive us into the Sun?");
					conv.Add("Not only would we be destroyed but he would destroy himself!");
					conv.Add("We cannot stand for this. I shall smite him down myself.");
					conv.Add("But I shall need a bolt to loose upon him.");
					conv.Add("You, dear Pluto, are the perfect size to strike deep within his heart.");
					conv.Add("Though you may not survive, I will make this sacrifice, as your ruler.");
					planetConversation["Jupiter"] = 3;
					ConversationManager.atConvEnd = () => {
						GlobalScript.JoinPluto(3);
						GlobalScript.getPlayer().SendMessage("Detatch");
						GlobalScript.Finale();

					};
				}else{
					conv.Add("Did someone say something? I must be getting old.");
					conv.Add("No one would dare approach me without consulting my subjects.");
					planetConversation["Jupiter"] = 0;
				}
			}
			break;
		default:
			break;
		}
		return conv.ToArray();
	}

	public string[] SaturnConversation(){
		List<string> conv = new List<string>();
		switch(planetConversation["Saturn"]){
		case 0:
			conv.Add("Saturn: I sense something beckoning me.");
			if(planetConversation["Phaeton"] == 0){
				conv.Add("Is anyone there?");
				conv.Add("Oh, Pluto! I barely noticed you!");
				planetConversation["Saturn"] = 1;
			}else{
				conv.Add("Is anyone there?");
				conv.Add("Oh, Pluto! I barely noticed you!");
				conv.Add("Phaeton is saying what?");
				conv.Add("I'm sorry, my child, but you are quite small and I am quite large.");
				if(GlobalScript.hasJoined(7) && GlobalScript.hasJoined(8)){
					conv.Add("Why you have quite a lot of planets with you!");
					conv.Add("One at a time, please!");
					conv.Add("I see. Phaeton said that? We must go to Jupiter at once!");
					planetConversation["Saturn"] = 2;
					ConversationManager.atConvEnd = () => {
						GlobalScript.JoinPluto(6);
						GlobalScript.getPlayer().SendMessage("Detatch");
					};
				}else{
					conv.Add("I simply can't hear you well enough.");
					planetConversation["Saturn"] = 1;
				}
			}
			break;
		case 1:
			if(planetConversation["Phaeton"] == 0){
				conv.Add("Is anyone there?");
				conv.Add("Oh, Pluto! I barely noticed you!");
				planetConversation["Saturn"] = 1;
			}else{
				conv.Add("Phaeton is saying what?");
				conv.Add("I'm sorry, my child, but you are quite small and I am quite large.");
				if(GlobalScript.hasJoined(7) && GlobalScript.hasJoined(8)){
					conv.Add("Why you have quite a lot of planets with you!");
					conv.Add("One at a time, please!");
					conv.Add("I see. Phaeton said that? We must go to Jupiter at once!");
					planetConversation["Saturn"] = 2;
					ConversationManager.atConvEnd = () => {
						GlobalScript.JoinPluto(6);
						GlobalScript.getPlayer().SendMessage("Detatch");
					};
				}else{
					conv.Add("I simply can't hear you well enough.");
					planetConversation["Saturn"] = 1;
				}
			}
			break;
		default:
			break;
		}
		return conv.ToArray();
	}

	public string[] UranusConversation(){
		List<string> conv = new List<string>();
		switch(planetConversation["Uranus"]){
		case 0:
			conv.Add("Uranus: ZzZ...");
			if(planetConversation["Phaeton"] == 0){
				conv.Add("*snore*");
				conv.Add("Huh? What? Leave an old thing like me alone!");
				planetConversation["Uranus"] = 1;
			}else{
				conv.Add("*snore*");
				conv.Add("Huh? What? Leave an old thing like me alone!");
				conv.Add("*yawn*");
				conv.Add("Must you prattle on so? About Phaeton, no less?");
				if(GlobalScript.hasJoined(1) && GlobalScript.hasJoined(2)){
					conv.Add("Oh, all the little ones are here. How novel!");
					conv.Add("Phaeton is planning to throw us into the sun?");
					conv.Add("I would like to see him try.");
					conv.Add("Still, it would be worth investigating.");
					conv.Add("I'll follow behind, at my own pace.");
					planetConversation["Uranus"] = 2;
					ConversationManager.atConvEnd = () => {
						GlobalScript.JoinPluto(7);
						GlobalScript.getPlayer().SendMessage("Detatch");
					};
				}else{
					conv.Add("Leave me to my slumber.");
					planetConversation["Uranus"] = 1;
				}
			}
			break;
		case 1:
			if(planetConversation["Phaeton"] == 0){
				conv.Add("*snore*");
				conv.Add("Huh? What? Leave an old thing like me alone!");
				planetConversation["Uranus"] = 1;
			}else{
				conv.Add("*yawn*");
				conv.Add("Must you prattle on so? About Phaeton, no less?");
				if(GlobalScript.hasJoined(1) && GlobalScript.hasJoined(2)){
					conv.Add("Oh, all the little ones are here. How novel!");
					conv.Add("Phaeton is planning to throw us into the sun?");
					conv.Add("I would like to see him try.");
					conv.Add("Still, it would be worth investigating.");
					conv.Add("I'll follow behind, at my own pace.");
					planetConversation["Uranus"] = 2;
					ConversationManager.atConvEnd = () => {
						GlobalScript.JoinPluto(7);
						GlobalScript.getPlayer().SendMessage("Detatch");
					};
				}else{
					conv.Add("Leave me to my slumber.");
					planetConversation["Uranus"] = 1;
				}
			}
			break;
		default:
			break;
		}
		return conv.ToArray();
	}

	public string[] NeptuneConversation(){
		List<string> conv = new List<string>();
		switch(planetConversation["Neptune"]){
		case 0:
			conv.Add("Neptune: Oh, what's this?");
			if(planetConversation["Phaeton"] == 0){
				conv.Add("My neighbor has blessed me with a visit!");
				conv.Add("I'm afraid I'm much to busy for anything you might bother me with.");
				planetConversation["Neptune"] = 1;
			}else{
				conv.Add("My neighbor has blessed me with a visit!");
				conv.Add("I'm afraid I'm much to busy for anything you might bother me with.");
				conv.Add("Oh, please don't bore me with tales of that silly Phaeton.");
				conv.Add("He gets in the way of my work, and just gawks at me.");
				if(GlobalScript.hasJoined(1) && GlobalScript.hasJoined(2)){
					conv.Add("Into the sun? Him? He'll hurt himself trying.");
					conv.Add("What a waste of time this is.");
					conv.Add("But I suppose it would waste my efforts being pushed into the Sun.");
					conv.Add("An effort will be made by all, I am sure.");
					conv.Add("Though some more significantly than others.");
					planetConversation["Neptune"] = 2;
					ConversationManager.atConvEnd = () => {
						GlobalScript.JoinPluto(8);
						GlobalScript.getPlayer().SendMessage("Detatch");
					};
				}else{
					conv.Add("So unsightly!");
					planetConversation["Neptune"] = 1;
				}
			}
			break;
		case 1:
			if(planetConversation["Phaeton"] == 0){
				conv.Add("My neighbor has blessed me with a visit!");
				conv.Add("I'm afraid I'm much to busy for anything you might bother me with.");
				planetConversation["Neptune"] = 1;
			}else{
				conv.Add("Oh, please don't bore me with tales of that silly Phaeton.");
				conv.Add("He gets in the way of my work, and just gawks at me.");
				if(GlobalScript.hasJoined(1) && GlobalScript.hasJoined(2)){
					conv.Add("Into the sun? Him? He'll hurt himself trying.");
					conv.Add("What a waste of time this is.");
					conv.Add("But I suppose it would waste my efforts being pushed into the Sun.");
					conv.Add("An effort will be made by all, I am sure.");
					conv.Add("Though some more significantly than others.");
					planetConversation["Neptune"] = 2;
					ConversationManager.atConvEnd = () => {
						GlobalScript.JoinPluto(8);
						GlobalScript.getPlayer().SendMessage("Detatch");
					};
				}else{
					conv.Add("So unsightly!");
					planetConversation["Neptune"] = 1;
				}
			}
			break;
		default:
			break;
		}
		return conv.ToArray();
	}
}
