您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

roomnameGenerator.js 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /* @flow */
  2. import { randomElement } from '../base/util';
  3. /*
  4. const _NOUN_ = [
  5. ];
  6. */
  7. /**
  8. * The list of plural nouns.
  9. * @const
  10. */
  11. const _PLURALNOUN_ = [
  12. 'Aliens', 'Animals', 'Antelopes', 'Ants', 'Apes', 'Apples', 'Baboons',
  13. 'Bacteria', 'Badgers', 'Bananas', 'Bats', 'Bears', 'Birds', 'Bonobos',
  14. 'Brides', 'Bugs', 'Bulls', 'Butterflies', 'Cheetahs', 'Cherries', 'Chicken',
  15. 'Children', 'Chimps', 'Clowns', 'Cows', 'Creatures', 'Dinosaurs', 'Dogs',
  16. 'Dolphins', 'Donkeys', 'Dragons', 'Ducks', 'Dwarfs', 'Eagles', 'Elephants',
  17. 'Elves', 'Fathers', 'Fish', 'Flowers', 'Frogs', 'Fruit', 'Fungi',
  18. 'Galaxies', 'Geese', 'Goats', 'Gorillas', 'Hedgehogs', 'Hippos', 'Horses',
  19. 'Hunters', 'Insects', 'Kids', 'Knights', 'Lemons', 'Lemurs', 'Leopards',
  20. 'LifeForms', 'Lions', 'Lizards', 'Mice', 'Monkeys', 'Monsters', 'Mushrooms',
  21. 'Octopodes', 'Oranges', 'Orangutans', 'Organisms', 'Pants', 'Parrots',
  22. 'Penguins', 'People', 'Pigeons', 'Pigs', 'Pineapples', 'Plants', 'Potatoes',
  23. 'Priests', 'Rats', 'Reptiles', 'Reptilians', 'Rhinos', 'Seagulls', 'Sheep',
  24. 'Siblings', 'Snakes', 'Spaghetti', 'Spiders', 'Squid', 'Squirrels',
  25. 'Stars', 'Students', 'Teachers', 'Tigers', 'Tomatoes', 'Trees', 'Vampires',
  26. 'Vegetables', 'Viruses', 'Vulcans', 'Weasels', 'Werewolves', 'Whales',
  27. 'Witches', 'Wizards', 'Wolves', 'Workers', 'Worms', 'Zebras'
  28. ];
  29. /*
  30. const _PLACE_ = [
  31. 'Pub', 'University', 'Airport', 'Library', 'Mall', 'Theater', 'Stadium',
  32. 'Office', 'Show', 'Gallows', 'Beach', 'Cemetery', 'Hospital', 'Reception',
  33. 'Restaurant', 'Bar', 'Church', 'House', 'School', 'Square', 'Village',
  34. 'Cinema', 'Movies', 'Party', 'Restroom', 'End', 'Jail', 'PostOffice',
  35. 'Station', 'Circus', 'Gates', 'Entrance', 'Bridge'
  36. ];
  37. */
  38. /**
  39. * The list of verbs.
  40. * @const
  41. */
  42. const _VERB_ = [
  43. 'Abandon', 'Adapt', 'Advertise', 'Answer', 'Anticipate', 'Appreciate',
  44. 'Approach', 'Argue', 'Ask', 'Bite', 'Blossom', 'Blush', 'Breathe', 'Breed',
  45. 'Bribe', 'Burn', 'Calculate', 'Clean', 'Code', 'Communicate', 'Compute',
  46. 'Confess', 'Confiscate', 'Conjugate', 'Conjure', 'Consume', 'Contemplate',
  47. 'Crawl', 'Dance', 'Delegate', 'Devour', 'Develop', 'Differ', 'Discuss',
  48. 'Dissolve', 'Drink', 'Eat', 'Elaborate', 'Emancipate', 'Estimate', 'Expire',
  49. 'Extinguish', 'Extract', 'Facilitate', 'Fall', 'Feed', 'Finish', 'Floss',
  50. 'Fly', 'Follow', 'Fragment', 'Freeze', 'Gather', 'Glow', 'Grow', 'Hex',
  51. 'Hide', 'Hug', 'Hurry', 'Improve', 'Intersect', 'Investigate', 'Jinx',
  52. 'Joke', 'Jubilate', 'Kiss', 'Laugh', 'Manage', 'Meet', 'Merge', 'Move',
  53. 'Object', 'Observe', 'Offer', 'Paint', 'Participate', 'Party', 'Perform',
  54. 'Plan', 'Pursue', 'Pierce', 'Play', 'Postpone', 'Pray', 'Proclaim',
  55. 'Question', 'Read', 'Reckon', 'Rejoice', 'Represent', 'Resize', 'Rhyme',
  56. 'Scream', 'Search', 'Select', 'Share', 'Shoot', 'Shout', 'Signal', 'Sing',
  57. 'Skate', 'Sleep', 'Smile', 'Smoke', 'Solve', 'Spell', 'Steer', 'Stink',
  58. 'Substitute', 'Swim', 'Taste', 'Teach', 'Terminate', 'Think', 'Type',
  59. 'Unite', 'Vanish', 'Worship'
  60. ];
  61. /**
  62. * The list of adverbs.
  63. * @const
  64. */
  65. const _ADVERB_ = [
  66. 'Absently', 'Accurately', 'Accusingly', 'Adorably', 'AllTheTime', 'Alone',
  67. 'Always', 'Amazingly', 'Angrily', 'Anxiously', 'Anywhere', 'Appallingly',
  68. 'Apparently', 'Articulately', 'Astonishingly', 'Badly', 'Barely',
  69. 'Beautifully', 'Blindly', 'Bravely', 'Brightly', 'Briskly', 'Brutally',
  70. 'Calmly', 'Carefully', 'Casually', 'Cautiously', 'Cleverly', 'Constantly',
  71. 'Correctly', 'Crazily', 'Curiously', 'Cynically', 'Daily', 'Dangerously',
  72. 'Deliberately', 'Delicately', 'Desperately', 'Discreetly', 'Eagerly',
  73. 'Easily', 'Euphoricly', 'Evenly', 'Everywhere', 'Exactly', 'Expectantly',
  74. 'Extensively', 'Ferociously', 'Fiercely', 'Finely', 'Flatly', 'Frequently',
  75. 'Frighteningly', 'Gently', 'Gloriously', 'Grimly', 'Guiltily', 'Happily',
  76. 'Hard', 'Hastily', 'Heroically', 'High', 'Highly', 'Hourly', 'Humbly',
  77. 'Hysterically', 'Immensely', 'Impartially', 'Impolitely', 'Indifferently',
  78. 'Intensely', 'Jealously', 'Jovially', 'Kindly', 'Lazily', 'Lightly',
  79. 'Loudly', 'Lovingly', 'Loyally', 'Magnificently', 'Malevolently', 'Merrily',
  80. 'Mightily', 'Miserably', 'Mysteriously', 'NOT', 'Nervously', 'Nicely',
  81. 'Nowhere', 'Objectively', 'Obnoxiously', 'Obsessively', 'Obviously',
  82. 'Often', 'Painfully', 'Patiently', 'Playfully', 'Politely', 'Poorly',
  83. 'Precisely', 'Promptly', 'Quickly', 'Quietly', 'Randomly', 'Rapidly',
  84. 'Rarely', 'Recklessly', 'Regularly', 'Remorsefully', 'Responsibly',
  85. 'Rudely', 'Ruthlessly', 'Sadly', 'Scornfully', 'Seamlessly', 'Seldom',
  86. 'Selfishly', 'Seriously', 'Shakily', 'Sharply', 'Sideways', 'Silently',
  87. 'Sleepily', 'Slightly', 'Slowly', 'Slyly', 'Smoothly', 'Softly', 'Solemnly',
  88. 'Steadily', 'Sternly', 'Strangely', 'Strongly', 'Stunningly', 'Surely',
  89. 'Tenderly', 'Thoughtfully', 'Tightly', 'Uneasily', 'Vanishingly',
  90. 'Violently', 'Warmly', 'Weakly', 'Wearily', 'Weekly', 'Weirdly', 'Well',
  91. 'Well', 'Wickedly', 'Wildly', 'Wisely', 'Wonderfully', 'Yearly'
  92. ];
  93. /**
  94. * The list of adjectives.
  95. * @const
  96. */
  97. const _ADJECTIVE_ = [
  98. 'Abominable', 'Accurate', 'Adorable', 'All', 'Alleged', 'Ancient', 'Angry',
  99. 'Anxious', 'Appalling', 'Apparent', 'Astonishing', 'Attractive', 'Awesome',
  100. 'Baby', 'Bad', 'Beautiful', 'Benign', 'Big', 'Bitter', 'Blind', 'Blue',
  101. 'Bold', 'Brave', 'Bright', 'Brisk', 'Calm', 'Camouflaged', 'Casual',
  102. 'Cautious', 'Choppy', 'Chosen', 'Clever', 'Cold', 'Cool', 'Crawly',
  103. 'Crazy', 'Creepy', 'Cruel', 'Curious', 'Cynical', 'Dangerous', 'Dark',
  104. 'Delicate', 'Desperate', 'Difficult', 'Discreet', 'Disguised', 'Dizzy',
  105. 'Dumb', 'Eager', 'Easy', 'Edgy', 'Electric', 'Elegant', 'Emancipated',
  106. 'Enormous', 'Euphoric', 'Evil', 'Fast', 'Ferocious', 'Fierce', 'Fine',
  107. 'Flawed', 'Flying', 'Foolish', 'Foxy', 'Freezing', 'Funny', 'Furious',
  108. 'Gentle', 'Glorious', 'Golden', 'Good', 'Green', 'Green', 'Guilty',
  109. 'Hairy', 'Happy', 'Hard', 'Hasty', 'Hazy', 'Heroic', 'Hostile', 'Hot',
  110. 'Humble', 'Humongous', 'Humorous', 'Hysterical', 'Idealistic', 'Ignorant',
  111. 'Immense', 'Impartial', 'Impolite', 'Indifferent', 'Infuriated',
  112. 'Insightful', 'Intense', 'Interesting', 'Intimidated', 'Intriguing',
  113. 'Jealous', 'Jolly', 'Jovial', 'Jumpy', 'Kind', 'Laughing', 'Lazy', 'Liquid',
  114. 'Lonely', 'Longing', 'Loud', 'Loving', 'Loyal', 'Macabre', 'Mad', 'Magical',
  115. 'Magnificent', 'Malevolent', 'Medieval', 'Memorable', 'Mere', 'Merry',
  116. 'Mighty', 'Mischievous', 'Miserable', 'Modified', 'Moody', 'Most',
  117. 'Mysterious', 'Mystical', 'Needy', 'Nervous', 'Nice', 'Objective',
  118. 'Obnoxious', 'Obsessive', 'Obvious', 'Opinionated', 'Orange', 'Painful',
  119. 'Passionate', 'Perfect', 'Pink', 'Playful', 'Poisonous', 'Polite', 'Poor',
  120. 'Popular', 'Powerful', 'Precise', 'Preserved', 'Pretty', 'Purple', 'Quick',
  121. 'Quiet', 'Random', 'Rapid', 'Rare', 'Real', 'Reassuring', 'Reckless', 'Red',
  122. 'Regular', 'Remorseful', 'Responsible', 'Rich', 'Rude', 'Ruthless', 'Sad',
  123. 'Scared', 'Scary', 'Scornful', 'Screaming', 'Selfish', 'Serious', 'Shady',
  124. 'Shaky', 'Sharp', 'Shiny', 'Shy', 'Simple', 'Sleepy', 'Slow', 'Sly',
  125. 'Small', 'Smart', 'Smelly', 'Smiling', 'Smooth', 'Smug', 'Sober', 'Soft',
  126. 'Solemn', 'Square', 'Square', 'Steady', 'Strange', 'Strong', 'Stunning',
  127. 'Subjective', 'Successful', 'Surly', 'Sweet', 'Tactful', 'Tense',
  128. 'Thoughtful', 'Tight', 'Tiny', 'Tolerant', 'Uneasy', 'Unique', 'Unseen',
  129. 'Warm', 'Weak', 'Weird', 'WellCooked', 'Wild', 'Wise', 'Witty', 'Wonderful',
  130. 'Worried', 'Yellow', 'Young', 'Zealous'
  131. ];
  132. /*
  133. const _PRONOUN_ = [
  134. ];
  135. */
  136. /*
  137. const _CONJUNCTION_ = [
  138. 'And', 'Or', 'For', 'Above', 'Before', 'Against', 'Between'
  139. ];
  140. */
  141. /**
  142. * Maps a string (category name) to the array of words from that category.
  143. * @const
  144. */
  145. const CATEGORIES: { [key: string]: Array<string> } = {
  146. _ADJECTIVE_,
  147. _ADVERB_,
  148. _PLURALNOUN_,
  149. _VERB_
  150. // _CONJUNCTION_,
  151. // _NOUN_,
  152. // _PLACE_,
  153. // _PRONOUN_,
  154. };
  155. /**
  156. * The list of room name patterns.
  157. * @const
  158. */
  159. const PATTERNS = [
  160. '_ADJECTIVE__PLURALNOUN__VERB__ADVERB_'
  161. // BeautifulFungiOrSpaghetti
  162. // '_ADJECTIVE__PLURALNOUN__CONJUNCTION__PLURALNOUN_',
  163. // AmazinglyScaryToy
  164. // '_ADVERB__ADJECTIVE__NOUN_',
  165. // NeitherTrashNorRifle
  166. // 'Neither_NOUN_Nor_NOUN_',
  167. // 'Either_NOUN_Or_NOUN_',
  168. // EitherCopulateOrInvestigate
  169. // 'Either_VERB_Or_VERB_',
  170. // 'Neither_VERB_Nor_VERB_',
  171. // 'The_ADJECTIVE__ADJECTIVE__NOUN_',
  172. // 'The_ADVERB__ADJECTIVE__NOUN_',
  173. // 'The_ADVERB__ADJECTIVE__NOUN_s',
  174. // 'The_ADVERB__ADJECTIVE__PLURALNOUN__VERB_',
  175. // WolvesComputeBadly
  176. // '_PLURALNOUN__VERB__ADVERB_',
  177. // UniteFacilitateAndMerge
  178. // '_VERB__VERB_And_VERB_',
  179. // NastyWitchesAtThePub
  180. // '_ADJECTIVE__PLURALNOUN_AtThe_PLACE_',
  181. ];
  182. /**
  183. * Generates a new room name.
  184. *
  185. * @returns {string} A newly-generated room name.
  186. */
  187. export function generateRoomWithoutSeparator() {
  188. // XXX Note that if more than one pattern is available, the choice of 'name'
  189. // won't have a uniform distribution amongst all patterns (names from
  190. // patterns with fewer options will have higher probability of being chosen
  191. // that names from patterns with more options).
  192. let name = randomElement(PATTERNS);
  193. while (_hasTemplate(name)) {
  194. for (const template in CATEGORIES) { // eslint-disable-line guard-for-in
  195. const word = randomElement(CATEGORIES[template]);
  196. name = name.replace(template, word);
  197. }
  198. }
  199. return name;
  200. }
  201. /**
  202. * Determines whether a specific string contains at least one of the
  203. * templates/categories.
  204. *
  205. * @param {string} s - String containing categories.
  206. * @private
  207. * @returns {boolean} True if the specified string contains at least one of the
  208. * templates/categories; otherwise, false.
  209. */
  210. function _hasTemplate(s) {
  211. for (const template in CATEGORIES) {
  212. if (s.indexOf(template) >= 0) {
  213. return true;
  214. }
  215. }
  216. return false;
  217. }