|
| 1 | +import { PseudoRandom } from "../../PseudoRandom"; |
| 2 | + |
| 3 | +const PLURAL_NOUN = Symbol("plural!"); |
| 4 | +const NOUN = Symbol("noun!"); |
| 5 | + |
| 6 | +type NameTemplate = (string | typeof PLURAL_NOUN | typeof NOUN)[]; |
| 7 | + |
| 8 | +const NAME_TEMPLATES: NameTemplate[] = [ |
| 9 | + ["World Famous", NOUN], |
| 10 | + ["Famous", PLURAL_NOUN], |
| 11 | + ["Comically Large", NOUN], |
| 12 | + ["Comically Small", NOUN], |
| 13 | + ["Massive", PLURAL_NOUN], |
| 14 | + ["Friendly", NOUN], |
| 15 | + ["Evil", NOUN], |
| 16 | + ["Malicious", NOUN], |
| 17 | + ["Spiteful", NOUN], |
| 18 | + ["Suspicious", NOUN], |
| 19 | + ["Canonically Evil", NOUN], |
| 20 | + ["Limited Edition", NOUN], |
| 21 | + ["Patent Pending", NOUN], |
| 22 | + ["Patented", NOUN], |
| 23 | + ["Space", NOUN], |
| 24 | + ["Defend The", PLURAL_NOUN], |
| 25 | + ["Anarchist", NOUN], |
| 26 | + ["Republic of", PLURAL_NOUN], |
| 27 | + ["Slippery", NOUN], |
| 28 | + ["Wealthy", PLURAL_NOUN], |
| 29 | + ["Certified", NOUN], |
| 30 | + ["Dr", NOUN], |
| 31 | + ["Runaway", NOUN], |
| 32 | + ["Chrome", NOUN], |
| 33 | + ["All New", NOUN], |
| 34 | + ["Top Shelf", PLURAL_NOUN], |
| 35 | + ["Invading", PLURAL_NOUN], |
| 36 | + ["Loyal To", PLURAL_NOUN], |
| 37 | + ["United States of", NOUN], |
| 38 | + ["United States of", PLURAL_NOUN], |
| 39 | + ["Flowing Rivers of", NOUN], |
| 40 | + ["House of", PLURAL_NOUN], |
| 41 | + ["Certified Organic", NOUN], |
| 42 | + ["Unregulated", NOUN], |
| 43 | + |
| 44 | + [NOUN, "For Hire"], |
| 45 | + [PLURAL_NOUN, "That Bite"], |
| 46 | + [PLURAL_NOUN, "Are Opps"], |
| 47 | + [NOUN, "Hotel"], |
| 48 | + [PLURAL_NOUN, "The Movie"], |
| 49 | + [NOUN, "Corporation"], |
| 50 | + [PLURAL_NOUN, "Inc"], |
| 51 | + [NOUN, "Democracy"], |
| 52 | + [NOUN, "Network"], |
| 53 | + [NOUN, "Railway"], |
| 54 | + [NOUN, "Congress"], |
| 55 | + [NOUN, "Alliance"], |
| 56 | + [NOUN, "Island"], |
| 57 | + [NOUN, "Kingdom"], |
| 58 | + [NOUN, "Empire"], |
| 59 | + [NOUN, "Dynasty"], |
| 60 | + [NOUN, "Cartel"], |
| 61 | + [NOUN, "Cabal"], |
| 62 | + [NOUN, "Land"], |
| 63 | + [NOUN, "Oligarchy"], |
| 64 | + [NOUN, "Nationalist"], |
| 65 | + [NOUN, "State"], |
| 66 | + [NOUN, "Duchy"], |
| 67 | + [NOUN, "Ocean"], |
| 68 | + |
| 69 | + ["Alternate", NOUN, "Universe"], |
| 70 | + ["Famous", NOUN, "Collection"], |
| 71 | + ["Supersonic", NOUN, "Spaceship"], |
| 72 | + ["Secret", NOUN, "Agenda"], |
| 73 | + ["Ballistic", NOUN, "Missile"], |
| 74 | + ["The", PLURAL_NOUN, "are SPIES"], |
| 75 | + ["Traveling", NOUN, "Circus"], |
| 76 | + ["The", PLURAL_NOUN, "Lied"], |
| 77 | + ["Sacred", NOUN, "Knowledge"], |
| 78 | + ["Quantum", NOUN, "Computer"], |
| 79 | + ["Hadron", NOUN, "Collider"], |
| 80 | + ["Large", NOUN, "Obliterator"], |
| 81 | + ["Interstellar", NOUN, "Cabal"], |
| 82 | + ["Interstellar", NOUN, "Army"], |
| 83 | + ["Interstellar", NOUN, "Pirates"], |
| 84 | + ["Interstellar", NOUN, "Dynasty"], |
| 85 | + ["Interstellar", NOUN, "Clan"], |
| 86 | + ["Galactic", NOUN, "Smugglers"], |
| 87 | + ["Galactic", NOUN, "Cabal"], |
| 88 | + ["Galactic", NOUN, "Alliance"], |
| 89 | + ["Galactic", NOUN, "Empire"], |
| 90 | + ["Galactic", NOUN, "Army"], |
| 91 | + ["Galactic", NOUN, "Crown"], |
| 92 | + ["Galactic", NOUN, "Pirates"], |
| 93 | + ["Galactic", NOUN, "Dynasty"], |
| 94 | + ["Galactic", NOUN, "Clan"], |
| 95 | + ["Alien", NOUN, "Army"], |
| 96 | + ["Alien", NOUN, "Cabal"], |
| 97 | + ["Alien", NOUN, "Alliance"], |
| 98 | + ["Alien", NOUN, "Empire"], |
| 99 | + ["Alien", NOUN, "Pirates"], |
| 100 | + ["Alien", NOUN, "Clan"], |
| 101 | + ["Grand", NOUN, "Empire"], |
| 102 | + ["Grand", NOUN, "Dynasty"], |
| 103 | + ["Grand", NOUN, "Army"], |
| 104 | + ["Grand", NOUN, "Cabal"], |
| 105 | + ["Grand", NOUN, "Alliance"], |
| 106 | + ["Royal", NOUN, "Army"], |
| 107 | + ["Royal", NOUN, "Cabal"], |
| 108 | + ["Royal", NOUN, "Empire"], |
| 109 | + ["Royal", NOUN, "Dynasty"], |
| 110 | + ["Holy", NOUN, "Dynasty"], |
| 111 | + ["Holy", NOUN, "Empire"], |
| 112 | + ["Holy", NOUN, "Alliance"], |
| 113 | + ["Eternal", NOUN, "Empire"], |
| 114 | + ["Eternal", NOUN, "Cabal"], |
| 115 | + ["Eternal", NOUN, "Alliance"], |
| 116 | + ["Eternal", NOUN, "Dynasty"], |
| 117 | + ["Invading", NOUN, "Cabal"], |
| 118 | + ["Invading", NOUN, "Empire"], |
| 119 | + ["Invading", NOUN, "Alliance"], |
| 120 | + ["Immortal", NOUN, "Pirates"], |
| 121 | + ["Shadow", NOUN, "Cabal"], |
| 122 | + ["Secret", NOUN, "Dynasty"], |
| 123 | + ["The Great", NOUN, "Army"], |
| 124 | + ["The", NOUN, "Matrix"], |
| 125 | +]; |
| 126 | + |
| 127 | +const NOUNS = [ |
| 128 | + "Snail", |
| 129 | + "Cow", |
| 130 | + "Giraffe", |
| 131 | + "Donkey", |
| 132 | + "Horse", |
| 133 | + "Mushroom", |
| 134 | + "Salad", |
| 135 | + "Kitten", |
| 136 | + "Fork", |
| 137 | + "Apple", |
| 138 | + "Pancake", |
| 139 | + "Tree", |
| 140 | + "Fern", |
| 141 | + "Seashell", |
| 142 | + "Turtle", |
| 143 | + "Casserole", |
| 144 | + "Gnome", |
| 145 | + "Frog", |
| 146 | + "Cheese", |
| 147 | + "Mold", |
| 148 | + "Clown", |
| 149 | + "Boat", |
| 150 | + "Robot", |
| 151 | + "Millionaire", |
| 152 | + "Billionaire", |
| 153 | + "Pigeon", |
| 154 | + "Fish", |
| 155 | + "Bumblebee", |
| 156 | + "Jelly", |
| 157 | + "Wizard", |
| 158 | + "Worm", |
| 159 | + "Rat", |
| 160 | + "Pumpkin", |
| 161 | + "Zombie", |
| 162 | + "Grass", |
| 163 | + "Bear", |
| 164 | + "Skunk", |
| 165 | + "Sandwich", |
| 166 | + "Butter", |
| 167 | + "Soda", |
| 168 | + "Pickle", |
| 169 | + "Potato", |
| 170 | + "Book", |
| 171 | + "Friend", |
| 172 | + "Feather", |
| 173 | + "Flower", |
| 174 | + "Oil", |
| 175 | + "Train", |
| 176 | + "Fan", |
| 177 | + "Salmon", |
| 178 | + "Cod", |
| 179 | + "Sink", |
| 180 | + "Villain", |
| 181 | + "Bug", |
| 182 | + "Car", |
| 183 | + "Soup", |
| 184 | + "Puppy", |
| 185 | + "Rock", |
| 186 | + "Stick", |
| 187 | + "Succulent", |
| 188 | + "Nerd", |
| 189 | + "Mercenary", |
| 190 | + "Ninja", |
| 191 | + "Burger", |
| 192 | + "Tomato", |
| 193 | + "Penguin", |
| 194 | +]; |
| 195 | + |
| 196 | +function pluralize(noun: string): string { |
| 197 | + if (noun.endsWith("s")) { |
| 198 | + return `${noun}es`; |
| 199 | + } |
| 200 | + return `${noun}s`; |
| 201 | +} |
| 202 | + |
| 203 | +export function generateNationName(random: PseudoRandom): string { |
| 204 | + const template = NAME_TEMPLATES[random.nextInt(0, NAME_TEMPLATES.length)]; |
| 205 | + const noun = NOUNS[random.nextInt(0, NOUNS.length)]; |
| 206 | + |
| 207 | + const result: string[] = []; |
| 208 | + |
| 209 | + for (const part of template) { |
| 210 | + if (part === PLURAL_NOUN) { |
| 211 | + result.push(pluralize(noun)); |
| 212 | + } else if (part === NOUN) { |
| 213 | + result.push(noun); |
| 214 | + } else { |
| 215 | + result.push(part); |
| 216 | + } |
| 217 | + } |
| 218 | + |
| 219 | + return result.join(" "); |
| 220 | +} |
0 commit comments