Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

RoomnameGenerator.js 9.5KB

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