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

namespace Peoples
{
    public static class NamesGenerator
    {
        const string maleNamesFile = "Peoples/male_names";
        const string femaleNamesFile = "Peoples/female_names";
        const string surnamesFile = "Peoples/surnames";

        public static PeopleData GenerateBasePeopleStats()
        {
            var result = new PeopleData();

            result.sex = (Sex)Random.Range(1, 3);
            result.surname = GetRandomFileRow(surnamesFile);
            result.name = GetRandomFileRow(result.sex == Sex.Male ? maleNamesFile : femaleNamesFile);

            return result;
        }

        static string GetRandomFileRow(string filePath)
        {
            var dataFile = Resources.Load<TextAsset>(filePath);
            var words = dataFile.text.Split("\n");

            return words[Random.Range(0, words.Length)].Replace("\r", "");
        }
    }
}