You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

roomname_generator.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. var RoomNameGenerator = function(my) {
  2. /**
  3. * Constructs new RoomNameGenerator object.
  4. * @constructor constructs new RoomNameGenerator object.
  5. */
  6. function RoomNameGeneratorProto()
  7. {
  8. }
  9. /**
  10. * Default separator the words in the room name
  11. * @type {string}
  12. */
  13. var DEFAULT_SEPARATOR = "-";
  14. /**
  15. * Default number of words in the room name.
  16. * @type {number}
  17. */
  18. var NUMBER_OF_WORDS = 3;
  19. /**
  20. * The list with words.
  21. * @type {string[]}
  22. */
  23. var words = [
  24. "definite ", "indefinite ", "articles", "name", "preposition ", "help", "very", "to", "through", "and", "just",
  25. "a", "form", "in", "sentence", "is", "great", "it", "think", "you", "say", "that", "help", "he", "low", "was",
  26. "line", "for", "differ", "on", "turn", "are", "cause", "with", "much", "as", "mean", "before", "his", "move",
  27. "they", "right", "be", "boy", "at", "old", "one", "too", "have", "same", "this", "tell", "from", "does", "or",
  28. "set", "had", "three", "by", "want", "hot", "air", "word", "well", "but", "also", "what", "play", "some", "small",
  29. "we", "end", "can", "put", "out", "home", "other", "read", "were", "hand", "all", "port", "there", "large",
  30. "when", "spell", "up", "add", "use", "even", "your", "land", "how", "here", "said", "must", "an", "big", "each",
  31. "high", "she", "such", "which", "follow", "do", "act", "their", "why", "time", "ask", "if", "men", "will", "change",
  32. "way", "went", "about", "light", "many", "kind", "then", "off", "them", "need", "write", "house", "would",
  33. "picture", "like", "try", "so", "us", "these", "again", "her", "animal", "long", "point", "make", "mother",
  34. "thing", "world", "see", "near", "him", "build", "two", "self", "has", "earth", "look", "father", "more", "head",
  35. "day", "stand", "could", "own", "go", "page", "come", "should", "did", "country", "number", "found", "sound",
  36. "answer", "no", "school", "most", "grow", "people", "study", "my", "still", "over", "learn", "know", "plant",
  37. "water", "cover", "than", "food", "call", "sun", "first", "four", "who", "between", "may", "state", "down",
  38. "keep", "side", "eye", "been", "never", "now", "last", "find", "let", "any", "thought", "new", "city", "work",
  39. "tree", "part", "cross", "take", "farm", "get", "hard", "place", "start", "made", "might", "live", "story",
  40. "where", "saw", "after", "far", "back", "sea", "little", "draw", "only", "left", "round", "late", "man", "run",
  41. "year", "don't", "came", "while", "show", "press", "every", "close", "good", "night", "me", "real", "give",
  42. "life", "our", "few", "under", "north", "open", "ten", "seem", "simple", "together", "several", "next", "vowel",
  43. "white", "toward", "children", "war", "begin", "lay", "got", "against", "walk", "pattern", "example", "slow",
  44. "ease", "center", "paper", "love", "group", "person", "always", "money", "music", "serve", "those", "appear",
  45. "both", "road", "mark", "map", "often", "rain", "letter", "rule", "until", "govern", "mile", "pull", "river",
  46. "cold", "car", "notice", "feet", "voice", "care", "unit", "second", "power", "book", "town", "carry", "fine",
  47. "took", "certain", "science", "fly", "eat", "fall", "room", "lead", "friend", "cry", "began", "dark", "idea",
  48. "machine", "fish", "note", "mountain", "wait", "stop", "plan", "once", "figure", "base", "star", "hear", "box",
  49. "horse", "noun", "cut", "field", "sure", "rest", "watch", "correct", "color", "able", "face", "pound", "wood",
  50. "done", "main", "beauty", "enough", "drive", "plain", "stood", "girl", "contain", "usual", "front", "young",
  51. "teach", "ready", "week", "above", "final", "ever", "gave", "red", "green", "list", "oh", "though", "quick",
  52. "feel", "develop", "talk", "ocean", "bird", "warm", "soon", "free", "body", "minute", "dog", "strong", "family",
  53. "special", "direct", "mind", "pose", "behind", "leave", "clear", "song", "tail", "measure", "produce", "door",
  54. "fact", "product", "street", "black", "inch", "short", "multiply", "numeral", "nothing", "class", "course", "wind",
  55. "stay", "question", "wheel", "happen", "full", "complete", "force", "ship", "blue", "area", "object", "half",
  56. "decide", "rock", "surface", "order", "deep", "fire", "moon", "south", "island", "problem", "foot", "piece",
  57. "system", "told", "busy", "knew", "test", "pass", "record", "since", "boat", "top", "common", "whole", "gold",
  58. "king", "possible", "space", "plane", "heard", "stead", "best", "dry", "hour", "wonder", "better", "laugh",
  59. "true", "thousand", "during", "ago", "hundred", "ran", "five", "check", "remember", "game", "step", "shape",
  60. "early", "equate", "hold", "hot", "west", "miss", "ground", "brought", "interest", "heat", "reach", "snow",
  61. "fast", "tire", "verb", "bring", "sing", "yes", "listen", "distant", "six", "fill", "table", "east", "travel",
  62. "paint", "less", "language", "morning", "among", "grand", "cat", "ball", "century", "yet", "consider", "wave",
  63. "type", "drop", "law", "heart", "bit", "am", "coast", "present", "copy", "heavy", "phrase", "dance", "silent",
  64. "engine", "tall", "position", "sand", "arm", "soil", "wide", "roll", "sail", "temperature", "material", "finger",
  65. "size", "industry", "vary", "value", "settle", "fight", "speak", "lie", "weight", "beat", "general", "excite",
  66. "ice", "natural", "matter", "view", "circle", "sense", "pair", "ear", "include", "else", "divide", "quite",
  67. "syllable", "broke", "felt", "case", "perhaps", "middle", "pick", "kill", "sudden", "son", "count", "lake",
  68. "square", "moment", "reason", "scale", "length", "loud", "represent", "spring", "art", "observe", "subject",
  69. "child", "region", "straight", "energy", "consonant", "hunt", "nation", "probable", "dictionary", "bed", "milk",
  70. "brother", "speed", "egg", "method", "ride", "organ", "cell", "pay", "believe", "age", "fraction", "section",
  71. "forest", "dress", "sit", "cloud", "race", "surprise", "window", "quiet", "store", "stone", "summer", "tiny",
  72. "train", "climb", "sleep", "cool", "prove", "design", "lone", "poor", "leg", "lot", "exercise", "experiment",
  73. "wall", "bottom", "catch", "key", "mount", "iron", "wish", "single", "sky", "stick", "board", "flat", "joy",
  74. "twenty", "winter", "skin", "sat", "smile", "written", "crease", "wild", "hole", "instrument", "trade", "kept",
  75. "melody", "glass", "trip", "grass", "office", "cow", "receive", "job", "row", "edge", "mouth", "sign", "exact",
  76. "visit", "symbol", "past", "die", "soft", "least", "fun", "trouble", "bright", "shout", "gas", "except",
  77. "weather", "wrote", "month", "seed", "million", "tone", "bear", "join", "finish", "suggest", "happy", "clean",
  78. "hope", "break", "flower", "lady", "clothe", "yard", "strange", "rise", "gone", "bad", "jump", "blow", "baby",
  79. "oil", "eight", "blood", "village", "touch", "meet", "grew", "root", "cent", "buy", "mix", "raise", "team",
  80. "solve", "wire", "metal", "cost", "whether", "lost", "push", "brown", "seven", "wear", "paragraph", "garden",
  81. "third", "equal", "shall", "sent", "held", "choose", "hair", "fell", "describe", "fit", "cook", "flow", "floor",
  82. "fair", "either", "bank", "result", "collect", "burn", "save", "hill", "control", "safe", "decimal", "rank",
  83. "word", "reference", "gentle", "truck", "woman", "noise", "captain", "level",
  84. "practice", "chance", "separate", "gather", "difficult", "shop", "doctor", "stretch", "please", "throw",
  85. "protect", "shine", "noon", "property", "whose", "column", "locate", "molecule", "ring", "select", "character",
  86. "wrong", "insect", "gray", "caught", "repeat", "period", "require", "indicate", "broad", "radio", "prepare",
  87. "spoke", "salt", "atom", "nose", "human", "plural", "history", "anger", "effect", "claim", "electric",
  88. "continent", "expect", "oxygen", "crop", "sugar", "modern", "death", "element", "pretty", "hit", "skill",
  89. "student", "women", "corner", "season", "party", "solution", "supply", "magnet", "bone", "silver", "rail",
  90. "thank", "imagine", "branch", "provide", "match", "agree", "suffix", "thus", "especially", "capital", "fig",
  91. "won't", "afraid", "chair", "huge", "danger", "sister", "fruit", "steel", "rich", "discuss", "thick", "forward",
  92. "soldier", "similar", "process", "guide", "operate", "experience", "guess", "score", "necessary", "apple",
  93. "sharp", "bought", "wing", "led", "create", "pitch", "neighbor", "coat", "wash", "mass", "bat", "card", "rather",
  94. "band", "crowd", "rope", "corn", "slip", "compare", "win", "poem", "dream", "string", "evening", "bell",
  95. "condition", "depend", "feed", "meat", "tool", "rub", "total", "tube", "basic", "famous", "smell", "dollar",
  96. "valley", "stream", "nor", "fear", "double", "sight", "seat", "thin", "arrive", "triangle", "master", "planet",
  97. "track", "hurry", "parent", "chief", "shore", "colony", "division", "clock", "sheet", "mine", "substance", "tie",
  98. "favor", "enter", "connect", "major", "post", "fresh", "spend", "search", "chord", "send", "fat", "yellow",
  99. "glad", "gun", "original", "allow", "share", "print", "station", "dead", "dad", "spot", "bread", "desert",
  100. "charge", "suit", "proper", "current", "bar", "lift", "offer", "rose", "segment", "continue", "slave", "block",
  101. "duck", "chart", "instant", "hat", "market", "sell", "degree", "success", "populate", "company", "chick",
  102. "subtract", "dear", "event", "enemy", "particular", "reply", "deal", "drink", "swim", "occur", "term", "support",
  103. "opposite", "speech", "wife", "nature", "shoe", "range", "shoulder", "steam", "spread", "motion", "arrange",
  104. "path", "camp", "liquid", "invent", "log", "cotton", "meant", "born", "quotient", "determine", "teeth", "quart",
  105. "shell", "nine", "neck", "fancy", "fan", "football"
  106. ];
  107. /**
  108. * Returns random word from the array of words.
  109. * @returns {string} random word from the array of words.
  110. */
  111. function generateWord()
  112. {
  113. return words[Math.floor(Math.random() * words.length)];
  114. }
  115. /**
  116. * Generates new room name.
  117. * @param separator the separator for the words.
  118. * @param number_of_words number of words in the room name
  119. * @returns {string} the room name
  120. */
  121. RoomNameGeneratorProto.generateRoom = function(separator, number_of_words)
  122. {
  123. if(!separator)
  124. separator = DEFAULT_SEPARATOR;
  125. if(!number_of_words)
  126. number_of_words = NUMBER_OF_WORDS;
  127. var name = "";
  128. for(var i = 0; i<number_of_words; i++)
  129. name += ((i != 0)? separator : "") + generateWord();
  130. return name;
  131. }
  132. /**
  133. * Generates new room name.
  134. * @param number_of_words number of words in the room name
  135. * @returns {string} the room name
  136. */
  137. RoomNameGeneratorProto.generateRoomWithoutSeparator = function(number_of_words)
  138. {
  139. if(!number_of_words)
  140. number_of_words = NUMBER_OF_WORDS;
  141. var name = "";
  142. for(var i = 0; i<number_of_words; i++) {
  143. var word = generateWord();
  144. word = word.substring(0, 1).toUpperCase() + word.substring(1, word.length);
  145. name += word ;
  146. }
  147. return name;
  148. }
  149. return RoomNameGeneratorProto;
  150. }();