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

public static class GameMaster{
	static public List<Player> players;
	static public string name1;
	static public string name2;
	static public int activePlayer;
	static public string configData;
	static public Battle battle;
	static public int winner;

	static public bool state = false;
	
	static public void SetPlayersInList(string _playerName1, string _playerName2){
		Player player1 = new Player(_playerName1);
        Player player2 = new Player(_playerName2);
		name1 = _playerName1;
		name2 = _playerName2;

        players = new List<Player>(2);
        players.Add(player1);
        players.Add(player2);
	}

    static public void changeActivePlayer() {
        if (activePlayer == 0) {
            activePlayer = 1;
        } else {
            activePlayer = 0;
        }
		state = !state;
    }

	static public void createPortrait() {
		Sprite symbolWater = (Sprite)Resources.Load<Sprite>("PortraitWater");
		Sprite symbolAir = (Sprite)Resources.Load<Sprite>("PortraitAir");
		Sprite symbolStone = (Sprite)Resources.Load<Sprite>("PortraitStone");
		Sprite symbolFire = (Sprite)Resources.Load<Sprite>("PortraitFire");

		int c = 2;

		Debug.Log ("Mach Bilder! " + activePlayer);
		for (int i = 1; i < 7; i++) {
			List<Monster> monsterArray;
			List<Elements> elementArray;
			if (i < 4) {
				monsterArray = players [0].GetMonsters();
				elementArray = monsterArray[i-1].GetElements ();
				Debug.Log ("PLAYER 0");
			} else {
				monsterArray = players [1].GetMonsters();
				elementArray = monsterArray[c].GetElements ();
				Debug.Log ("PLAYER 1");
				c--;
			}
			Debug.Log (elementArray [0].ToString ());
			switch(elementArray[0].ToString()) {
				case "FIRE":
					GameObject.Find ("pd" + i).GetComponent<Image> ().sprite = symbolFire;
					break;
				case "EARTH":
					GameObject.Find ("pd" + i).GetComponent<Image> ().sprite = symbolStone;
					break;
				case "AIR":
					GameObject.Find ("pd" + i).GetComponent<Image> ().sprite = symbolAir;
					break;
				case "WATER":
					GameObject.Find ("pd" + i).GetComponent<Image> ().sprite = symbolWater;
					break;
			}
			Debug.Log ("CASE " + elementArray [0].ToString ());
		}
	}
}
