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

roomname_generator.js 10KB

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