ShopNameGenerator.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. /// <summary>
  4. /// Generates randomized shop names based on shop type and settlement seed
  5. /// </summary>
  6. public static class ShopNameGenerator
  7. {
  8. private static readonly Dictionary<ShopType, (string[] prefixes, string[] suffixes)> shopNameParts =
  9. new Dictionary<ShopType, (string[], string[])>
  10. {
  11. [ShopType.Weapons] = (
  12. new string[] { "Iron", "Steel", "Sharp", "Blade", "Sword", "Battle", "War", "Forge", "Smith's", "Master" },
  13. new string[] { "Forge", "Armory", "Smithy", "Workshop", "Arms", "Weapons", "Blades", "Steel", "Works", "Arsenal" }
  14. ),
  15. [ShopType.Armor] = (
  16. new string[] { "Iron", "Steel", "Shield", "Guard", "Protection", "Battle", "Sturdy", "Strong", "Heavy", "Knight's" },
  17. new string[] { "Armory", "Protection", "Guards", "Shields", "Armor", "Defense", "Gear", "Works", "Smithy", "Hall" }
  18. ),
  19. [ShopType.Potions] = (
  20. new string[] { "Mystic", "Magic", "Healing", "Wise", "Ancient", "Bubbling", "Crystal", "Elven", "Herbal", "Sacred" },
  21. new string[] { "Potions", "Elixirs", "Brews", "Cauldron", "Remedies", "Apothecary", "Alchemy", "Lab", "Herbs", "Tonics" }
  22. ),
  23. [ShopType.General] = (
  24. new string[] { "General", "Trading", "Merchant's", "Common", "Useful", "Daily", "Town", "Village", "Traveler's", "Wanderer's" },
  25. new string[] { "Goods", "Store", "Supplies", "Trading Post", "Emporium", "Market", "Shop", "Merchant", "General Store", "Bazaar" }
  26. ),
  27. [ShopType.Magic] = (
  28. new string[] { "Arcane", "Mystical", "Enchanted", "Magical", "Wizard's", "Sorcerer's", "Ancient", "Ethereal", "Divine", "Celestial" },
  29. new string[] { "Emporium", "Artifacts", "Relics", "Magic", "Enchantments", "Scrolls", "Tomes", "Mysteries", "Wonders", "Sanctum" }
  30. ),
  31. [ShopType.Tools] = (
  32. new string[] { "Useful", "Handy", "Crafting", "Builder's", "Worker's", "Master", "Quality", "Fine", "Reliable", "Sturdy" },
  33. new string[] { "Tools", "Implements", "Workshop", "Supplies", "Equipment", "Gear", "Utilities", "Hardware", "Crafts", "Works" }
  34. )
  35. };
  36. private static readonly string[] keepersNameParts = new string[]
  37. {
  38. // Male names
  39. "Marcus", "Gareth", "Thorin", "Finn", "Aldric", "Bram", "Cael", "Daven", "Erik", "Galen",
  40. "Hector", "Ivan", "Joren", "Kane", "Lars", "Magnus", "Nolan", "Owen", "Pike", "Quinn",
  41. // Female names
  42. "Elara", "Brenna", "Cira", "Delia", "Evelyn", "Fiona", "Greta", "Hilda", "Iris", "Jenna",
  43. "Kira", "Luna", "Mira", "Nina", "Olivia", "Piper", "Rose", "Sara", "Tara", "Vera",
  44. // Fantasy names
  45. "Zephyr", "Xara", "Vex", "Wick", "Yara", "Zane"
  46. };
  47. /// <summary>
  48. /// Generate a randomized shop name based on shop type and seed
  49. /// </summary>
  50. public static string GenerateShopName(ShopType shopType, int seed)
  51. {
  52. var random = new System.Random(seed);
  53. if (!shopNameParts.ContainsKey(shopType))
  54. {
  55. return $"Unknown {shopType} Shop";
  56. }
  57. var parts = shopNameParts[shopType];
  58. var prefix = parts.prefixes[random.Next(parts.prefixes.Length)];
  59. var suffix = parts.suffixes[random.Next(parts.suffixes.Length)];
  60. // Sometimes use "The" prefix
  61. var useThe = random.NextDouble() > 0.6;
  62. var shopName = useThe ? $"The {prefix} {suffix}" : $"{prefix} {suffix}";
  63. return shopName;
  64. }
  65. /// <summary>
  66. /// Generate a randomized shopkeeper name based on seed
  67. /// </summary>
  68. public static string GenerateShopkeeperName(int seed)
  69. {
  70. var random = new System.Random(seed);
  71. return keepersNameParts[random.Next(keepersNameParts.Length)];
  72. }
  73. /// <summary>
  74. /// Generate a shop name with embedded settlement and shop type info for uniqueness
  75. /// </summary>
  76. public static string GenerateUniqueShopName(ShopType shopType, string settlementName, Vector2Int position)
  77. {
  78. // Create a unique seed based on settlement name, position, and shop type
  79. var combinedSeed = settlementName.GetHashCode() ^ position.GetHashCode() ^ shopType.GetHashCode();
  80. return GenerateShopName(shopType, combinedSeed);
  81. }
  82. /// <summary>
  83. /// Generate a shopkeeper name with embedded settlement and shop type info for uniqueness
  84. /// </summary>
  85. public static string GenerateUniqueShopkeeperName(ShopType shopType, string settlementName, Vector2Int position)
  86. {
  87. // Create a unique seed based on settlement name, position, and shop type (offset for different result)
  88. var combinedSeed = (settlementName.GetHashCode() ^ position.GetHashCode() ^ shopType.GetHashCode()) + 12345;
  89. return GenerateShopkeeperName(combinedSeed);
  90. }
  91. }