/// <summary>
/// Create a copy of this file, altering the datapath appropriately
/// </summary>
public Personality Copy(string name, string description)
{
// Tidy the name up to avoid bad characters
string regexSearch = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());
Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));
name = r.Replace(name, "");
// Save a copy of this personality
string iname = name.ToLowerInvariant();
string copyPath = Constants.DATA_DIR + @"\personalities\" + iname + ".json";
// Ensure it doesn't exist
if (!File.Exists(copyPath))
{
ToFile(copyPath);
}
// Load the personality back in
Personality newPersonality = FromFile(copyPath);
// Change its name and description and save it back out again
newPersonality.Name = name;
newPersonality.Description = description;
newPersonality.ToFile();
// And finally return it
return(newPersonality);
}