using System.Collections.Generic;
using UnityEngine;

[System.Serializable]
public class Tile 
{
    public string code = "C01-0";
    public string style = "city";
    public int styleModel = 1;
    public int format = 1;
    public int rotation = 0;
    public TileFormat tileFormat;
    
    private Dictionary<char, string> styles = new Dictionary<char, string>
    {
        {'C', "city"},
        {'F', "farm"},
        {'B', "beach"},
        {'L', "lake"}
    };

    public Tile (string code)
    {
        //TODO Refactor
        this.code = code;
        style = styles[code[0]];
        styleModel = int.Parse(code.Substring(1, 2));
        format = int.Parse(code.Substring(4, 2));
        rotation = int.Parse(code.Substring(7));
        tileFormat = new TileFormat(format);
    }

    override public string ToString()
    {
        return string.Format("Style: {0}{1}, Format: {2}, Rotation: {3}\nTileFormat: {4}\n", style, styleModel, format, rotation, tileFormat);
    } 
}