From f9d6ab3702b9dae1cbe9c41fd78d5ed22ac466bf Mon Sep 17 00:00:00 2001 From: ccjmne Date: Wed, 19 Oct 2022 17:19:17 +0200 Subject: [PATCH] Enforce unique, sequential ID for pet names Resolves #161. Nota Bene: Both cat and dog names lists were missing ID 104, from 8ed7cb9. --- src/common/names.ts | 817 +++++++++++++++++++++----------------------- 1 file changed, 397 insertions(+), 420 deletions(-) diff --git a/src/common/names.ts b/src/common/names.ts index e1118e2b..6c67041f 100644 --- a/src/common/names.ts +++ b/src/common/names.ts @@ -1,437 +1,414 @@ import { PetType } from './types'; -export const CAT_NAMES: Map = new Map([ - [1, 'Bella'], - [2, 'Charlie'], - [3, 'Molly'], - [4, 'Coco'], - [5, 'Ruby'], - [6, 'Oscar'], - [7, 'Lucy'], - [8, 'Bailey'], - [9, 'Milo'], - [10, 'Daisy'], - [11, 'Archie'], - [12, 'Ollie'], - [13, 'Rosie'], - [14, 'Lola'], - [15, 'Frankie'], - [16, 'Roxy'], - [17, 'Poppy'], - [18, 'Luna'], - [19, 'Jack'], - [20, 'Millie'], - [21, 'Teddy'], - [22, 'Cooper'], - [23, 'Bear'], - [24, 'Rocky'], - [25, 'Alfie'], - [26, 'Hugo'], - [27, 'Bonnie'], - [28, 'Pepper'], - [29, 'Lily'], - [30, 'Tilly'], - [31, 'Leo'], - [32, 'Maggie'], - [33, 'George'], - [34, 'Mia'], - [35, 'Marley'], - [36, 'Harley'], - [37, 'Chloe'], - [38, 'Lulu'], - [39, 'Missy'], - [40, 'Jasper'], - [41, 'Billy'], - [42, 'Nala'], - [43, 'Monty'], - [44, 'Ziggy'], - [45, 'Winston'], - [46, 'Zeus'], - [47, 'Zoe'], - [48, 'Stella'], - [49, 'Sasha'], - [50, 'Rusty'], - [51, 'Gus'], - [52, 'Baxter'], - [53, 'Dexter'], - [54, 'Willow'], - [55, 'Barney'], - [56, 'Bruno'], - [57, 'Penny'], - [58, 'Honey'], - [59, 'Milly'], - [60, 'Murphy'], - [61, 'Simba'], - [62, 'Holly'], - [63, 'Benji'], - [64, 'Henry'], - [65, 'Lilly'], - [66, 'Pippa'], - [67, 'Shadow'], - [68, 'Sam'], - [69, 'Lucky'], - [70, 'Ellie'], - [71, 'Duke'], - [72, 'Jessie'], - [73, 'Cookie'], - [74, 'Harvey'], - [75, 'Bruce'], - [76, 'Jax'], - [77, 'Rex'], - [78, 'Louie'], - [79, 'Jet'], - [80, 'Banjo'], - [81, 'Beau'], - [82, 'Ella'], - [83, 'Ralph'], - [84, 'Loki'], - [85, 'Lexi'], - [86, 'Chester'], - [87, 'Sophie'], - [88, 'Chilli'], - [89, 'Billie'], - [90, 'Louis'], - [91, 'Scout'], - [92, 'Cleo'], - [93, 'Purfect'], - [94, 'Spot'], - [95, 'Bolt'], - [96, 'Julia'], - [97, 'Ginger'], - [98, 'Daisy'], - [99, 'Amelia'], - [100, 'Oliver'], - [101, 'Ghost'], - [102, 'Midnight'], - [103, 'Pumpkin'], - [105, 'Shadow'], - [106, 'Binx'], - [107, 'Riley'], - [108, 'Lenny'], - [109, 'Mango'], - [110, 'Alex'], - [111, 'Boo'], - [112, 'Botas'], - [113, 'Romeo'], - [114, 'Bob'], - [115, 'Clyde'], - [116, 'Simon'], - [117, 'Mimmo'], - [118, 'Carlotta'], - [119, 'Felix'], -]); +export const CAT_NAMES: ReadonlyArray = [ + 'Bella', + 'Charlie', + 'Molly', + 'Coco', + 'Ruby', + 'Oscar', + 'Lucy', + 'Bailey', + 'Milo', + 'Daisy', + 'Archie', + 'Ollie', + 'Rosie', + 'Lola', + 'Frankie', + 'Roxy', + 'Poppy', + 'Luna', + 'Jack', + 'Millie', + 'Teddy', + 'Cooper', + 'Bear', + 'Rocky', + 'Alfie', + 'Hugo', + 'Bonnie', + 'Pepper', + 'Lily', + 'Tilly', + 'Leo', + 'Maggie', + 'George', + 'Mia', + 'Marley', + 'Harley', + 'Chloe', + 'Lulu', + 'Missy', + 'Jasper', + 'Billy', + 'Nala', + 'Monty', + 'Ziggy', + 'Winston', + 'Zeus', + 'Zoe', + 'Stella', + 'Sasha', + 'Rusty', + 'Gus', + 'Baxter', + 'Dexter', + 'Willow', + 'Barney', + 'Bruno', + 'Penny', + 'Honey', + 'Milly', + 'Murphy', + 'Simba', + 'Holly', + 'Benji', + 'Henry', + 'Lilly', + 'Pippa', + 'Shadow', + 'Sam', + 'Lucky', + 'Ellie', + 'Duke', + 'Jessie', + 'Cookie', + 'Harvey', + 'Bruce', + 'Jax', + 'Rex', + 'Louie', + 'Jet', + 'Banjo', + 'Beau', + 'Ella', + 'Ralph', + 'Loki', + 'Lexi', + 'Chester', + 'Sophie', + 'Chilli', + 'Billie', + 'Louis', + 'Scout', + 'Cleo', + 'Purfect', + 'Spot', + 'Bolt', + 'Julia', + 'Ginger', + 'Daisy', + 'Amelia', + 'Oliver', + 'Ghost', + 'Midnight', + 'Pumpkin', + 'Shadow', + 'Binx', + 'Riley', + 'Lenny', + 'Mango', + 'Alex', + 'Boo', + 'Botas', + 'Romeo', + 'Bob', + 'Clyde', + 'Simon', + 'Mimmo', + 'Carlotta', + 'Felix', +]; -export const DOG_NAMES: Map = new Map([ - [1, 'Bella'], - [2, 'Charlie'], - [3, 'Max'], - [4, 'Molly'], - [5, 'Coco'], - [6, 'Buddy'], - [7, 'Ruby'], - [8, 'Oscar'], - [9, 'Lucy'], - [10, 'Bailey'], - [11, 'Milo'], - [12, 'Daisy'], - [13, 'Archie'], - [14, 'Ollie'], - [15, 'Rosie'], - [16, 'Lola'], - [17, 'Frankie'], - [18, 'Toby'], - [19, 'Roxy'], - [20, 'Poppy'], - [21, 'Luna'], - [22, 'Jack'], - [23, 'Millie'], - [24, 'Teddy'], - [25, 'Harry'], - [26, 'Cooper'], - [27, 'Bear'], - [28, 'Rocky'], - [29, 'Alfie'], - [30, 'Hugo'], - [31, 'Bonnie'], - [32, 'Pepper'], - [33, 'Lily'], - [34, 'Leo'], - [35, 'Maggie'], - [36, 'George'], - [37, 'Mia'], - [38, 'Marley'], - [39, 'Harley'], - [40, 'Chloe'], - [41, 'Lulu'], - [42, 'Jasper'], - [43, 'Billy'], - [44, 'Nala'], - [45, 'Monty'], - [46, 'Ziggy'], - [47, 'Winston'], - [48, 'Zeus'], - [49, 'Zoe'], - [50, 'Stella'], - [51, 'Sasha'], - [52, 'Rusty'], - [53, 'Gus'], - [54, 'Baxter'], - [55, 'Dexter'], - [56, 'Diesel'], - [57, 'Willow'], - [58, 'Barney'], - [59, 'Bruno'], - [60, 'Penny'], - [61, 'Honey'], - [62, 'Milly'], - [63, 'Murphy'], - [64, 'Holly'], - [65, 'Benji'], - [66, 'Henry'], - [67, 'Lilly'], - [68, 'Pippa'], - [69, 'Shadow'], - [70, 'Sam'], - [71, 'Buster'], - [72, 'Lucky'], - [73, 'Ellie'], - [74, 'Duke'], - [75, 'Jessie'], - [76, 'Cookie'], - [77, 'Harvey'], - [78, 'Bruce'], - [79, 'Jax'], - [80, 'Rex'], - [81, 'Louie'], - [82, 'Bentley'], - [83, 'Jet'], - [84, 'Banjo'], - [85, 'Beau'], - [86, 'Ella'], - [87, 'Ralph'], - [88, 'Loki'], - [89, 'Lexi'], - [90, 'Chester'], - [91, 'Sophie'], - [92, 'Billie'], - [93, 'Louis'], - [94, 'Charlie'], - [95, 'Cleo'], - [96, 'Spot'], - [97, 'Harry'], - [98, 'Bolt'], - [99, 'Ein'], - [100, 'Maddy'], - [101, 'Ghost'], - [102, 'Midnight'], - [103, 'Pumpkin'], - [105, 'Shadow'], - [106, 'Sparky'], - [107, 'Linus'], - [108, 'Cody'], - [109, 'Slinky'], - [110, 'Toto'], - [111, 'Balto'], - [112, 'Golfo'], - [113, 'Pongo'], - [114, 'Beethoven'], - [115, 'Hachiko'], - [116, 'Scooby'], - [117, 'Clifford'], - [118, 'Astro'], - [119, 'Goofy'], - [120, 'Chip'], - [121, 'Einstein'], - [122, 'Fang'], - [123, 'Truman'], - [124, 'Uggie'], - [125, 'Bingo'], - [126, 'Blue'], - [127, 'Cometa'], - [128, 'Krypto'], - [129, 'Huesos'], - [130, 'Odie'], - [131, 'Snoopy'], - [132, 'Aisha'], - [133, 'Moly'], - [134, 'Chiquita'], - [135, 'Chavela'], -]); +export const DOG_NAMES: ReadonlyArray = [ + 'Bella', + 'Charlie', + 'Max', + 'Molly', + 'Coco', + 'Buddy', + 'Ruby', + 'Oscar', + 'Lucy', + 'Bailey', + 'Milo', + 'Daisy', + 'Archie', + 'Ollie', + 'Rosie', + 'Lola', + 'Frankie', + 'Toby', + 'Roxy', + 'Poppy', + 'Luna', + 'Jack', + 'Millie', + 'Teddy', + 'Harry', + 'Cooper', + 'Bear', + 'Rocky', + 'Alfie', + 'Hugo', + 'Bonnie', + 'Pepper', + 'Lily', + 'Leo', + 'Maggie', + 'George', + 'Mia', + 'Marley', + 'Harley', + 'Chloe', + 'Lulu', + 'Jasper', + 'Billy', + 'Nala', + 'Monty', + 'Ziggy', + 'Winston', + 'Zeus', + 'Zoe', + 'Stella', + 'Sasha', + 'Rusty', + 'Gus', + 'Baxter', + 'Dexter', + 'Diesel', + 'Willow', + 'Barney', + 'Bruno', + 'Penny', + 'Honey', + 'Milly', + 'Murphy', + 'Holly', + 'Benji', + 'Henry', + 'Lilly', + 'Pippa', + 'Shadow', + 'Sam', + 'Buster', + 'Lucky', + 'Ellie', + 'Duke', + 'Jessie', + 'Cookie', + 'Harvey', + 'Bruce', + 'Jax', + 'Rex', + 'Louie', + 'Bentley', + 'Jet', + 'Banjo', + 'Beau', + 'Ella', + 'Ralph', + 'Loki', + 'Lexi', + 'Chester', + 'Sophie', + 'Billie', + 'Louis', + 'Charlie', + 'Cleo', + 'Spot', + 'Harry', + 'Bolt', + 'Ein', + 'Maddy', + 'Ghost', + 'Midnight', + 'Pumpkin', + 'Shadow', + 'Sparky', + 'Linus', + 'Cody', + 'Slinky', + 'Toto', + 'Balto', + 'Golfo', + 'Pongo', + 'Beethoven', + 'Hachiko', + 'Scooby', + 'Clifford', + 'Astro', + 'Goofy', + 'Chip', + 'Einstein', + 'Fang', + 'Truman', + 'Uggie', + 'Bingo', + 'Blue', + 'Cometa', + 'Krypto', + 'Huesos', + 'Odie', + 'Snoopy', + 'Aisha', + 'Moly', + 'Chiquita', + 'Chavela', +]; -export const CRAB_NAMES: Map = new Map([ - [1, 'Ferris'], - [2, 'Pinchy'], - [3, 'Grabby'], - [4, 'Big Red'], - [5, 'Crabby'], - [6, 'Buddy'], - [7, 'Ruby Red'], - [8, 'Oscar'], - [9, 'Lucy'], - [10, 'Bailey'], - [11, 'Crabito'], - [12, 'Percy'], - [13, 'Rocky'], - [14, 'Mr. Krabs'], - [15, 'Shelly'], - [16, 'Santa Claws'], - [17, 'Clawdia'], - [18, 'Scuttle'], - [19, 'Snappy'], - [20, 'Hermit'], - [21, 'Horseshoe'], - [22, 'Snapper'], - [23, 'Coconut'], -]); +export const CRAB_NAMES: ReadonlyArray = [ + 'Ferris', + 'Pinchy', + 'Grabby', + 'Big Red', + 'Crabby', + 'Buddy', + 'Ruby Red', + 'Oscar', + 'Lucy', + 'Bailey', + 'Crabito', + 'Percy', + 'Rocky', + 'Mr. Krabs', + 'Shelly', + 'Santa Claws', + 'Clawdia', + 'Scuttle', + 'Snappy', + 'Hermit', + 'Horseshoe', + 'Snapper', + 'Coconut', +]; -export const CLIPPY_NAMES: Map = new Map([ - [1, 'Clippy'], - [2, 'Karl Klammer'], - [3, 'Clippy Jr.'], - [4, 'Molly'], - [5, 'Coco'], - [6, 'Buddy'], - [7, 'Ruby'], - [8, 'Oscar'], - [9, 'Lucy'], - [10, 'Bailey'], -]); +export const CLIPPY_NAMES: ReadonlyArray = [ + 'Clippy', + 'Karl Klammer', + 'Clippy Jr.', + 'Molly', + 'Coco', + 'Buddy', + 'Ruby', + 'Oscar', + 'Lucy', + 'Bailey', +]; -export const TOTORO_NAMES: Map = new Map([ - [1, 'Totoro'], - [2, 'トトロ'], - [3, 'Max'], - [4, 'Molly'], - [5, 'Coco'], - [6, 'Buddy'], - [7, 'Ruby'], - [8, 'Oscar'], - [9, 'Lucy'], - [10, 'Bailey'], - [11, 'Big fella'], -]); +export const TOTORO_NAMES: ReadonlyArray = [ + 'Totoro', + 'トトロ', + 'Max', + 'Molly', + 'Coco', + 'Buddy', + 'Ruby', + 'Oscar', + 'Lucy', + 'Bailey', + 'Big fella', +]; -export const SNAKE_NAMES: Map = new Map([ - [1, 'Sneaky'], - [2, 'Mr Slippery'], - [3, 'Hissy Elliott'], - [4, 'Molly'], - [5, 'Coco'], - [6, 'Buddy'], - [7, 'Ruby'], - [8, 'Bailey'], - [9, 'Max'], - [10, 'Seb'], -]); +export const SNAKE_NAMES: ReadonlyArray = [ + 'Sneaky', + 'Mr Slippery', + 'Hissy Elliott', + 'Molly', + 'Coco', + 'Buddy', + 'Ruby', + 'Bailey', + 'Max', + 'Seb', +]; -export const DUCK_NAMES: Map = new Map([ - [1, 'Quacky'], - [2, 'Floaty'], - [3, 'Duck'], - [4, 'Molly'], - [5, 'Sunshine'], - [6, 'Buddy'], - [7, 'Chirpy'], - [8, 'Oscar'], - [9, 'Lucy'], - [10, 'Bailey'], - [11, 'Beaky'], - [12, 'Jemima'], - [13, 'Peaches'], - [14, 'Quackers'], - [15, 'Jelly Beans'], - [16, 'Donald'], - [17, 'Chady'], -]); +export const DUCK_NAMES: ReadonlyArray = [ + 'Quacky', + 'Floaty', + 'Duck', + 'Molly', + 'Sunshine', + 'Buddy', + 'Chirpy', + 'Oscar', + 'Lucy', + 'Bailey', + 'Beaky', + 'Jemima', + 'Peaches', + 'Quackers', + 'Jelly Beans', + 'Donald', + 'Chady', +]; -export const ZAPPY_NAMES: Map = new Map([ - [1, 'Zappy'], - [2, 'Zippy'], - [3, 'Zappy Jr.'], - [4, 'Zoppy'], - [5, 'Zuppy'], - [6, 'Zeppy'], - [7, 'Big Z'], - [8, 'Little z'], - [9, 'The Flash'], - [10, 'Thor'], - [11, 'Electric Bolt'], -]); +export const ZAPPY_NAMES: ReadonlyArray = [ + 'Zappy', + 'Zippy', + 'Zappy Jr.', + 'Zoppy', + 'Zuppy', + 'Zeppy', + 'Big Z', + 'Little z', + 'The Flash', + 'Thor', + 'Electric Bolt', +]; -export const ROCKY_NAMES: Map = new Map([ - [1, 'Rocky'], - [2, 'The Rock'], - [3, 'Quartzy'], - [4, 'Rocky I'], - [5, 'Rocky II'], - [6, 'Rocky III'], - [7, 'Pebbles Sr.'], - [8, 'Big Granite'], - [9, 'Boulder'], - [10, 'Rockefeller'], - [11, 'Pebble'], - [12, 'Rocksanne'], - [13, 'Rockstar'], -]); +export const ROCKY_NAMES: ReadonlyArray = [ + 'Rocky', + 'The Rock', + 'Quartzy', + 'Rocky I', + 'Rocky II', + 'Rocky III', + 'Pebbles Sr.', + 'Big Granite', + 'Boulder', + 'Rockefeller', + 'Pebble', + 'Rocksanne', + 'Rockstar', +]; -export const COCKATIEL_NAMES: Map = new Map([ - [1, 'Cocktail'], - [2, 'Pipsqueak'], - [3, 'Sir Chirps a Lot'], - [4, 'Nibbles'], - [5, 'Lord of the Wings'], - [6, 'Girl Nest Door'], - [7, 'Wingman'], - [8, 'Meryl Cheep'], - [9, 'Jack Sparrow'], - [10, 'Godfeather'], - [11, 'Mickey'], - [12, 'Baquack Obama'], - [13, 'Dame Judi Finch'], - [14, 'Kanye Nest'], -]); +export const COCKATIEL_NAMES: ReadonlyArray = [ + 'Cocktail', + 'Pipsqueak', + 'Sir Chirps a Lot', + 'Nibbles', + 'Lord of the Wings', + 'Girl Nest Door', + 'Wingman', + 'Meryl Cheep', + 'Jack Sparrow', + 'Godfeather', + 'Mickey', + 'Baquack Obama', + 'Dame Judi Finch', + 'Kanye Nest', +]; export function randomName(type: PetType): string { - var collection: Map; - - switch (type) { - case PetType.cat: - collection = CAT_NAMES; - break; - case PetType.dog: - collection = DOG_NAMES; - break; - case PetType.crab: - collection = CRAB_NAMES; - break; - case PetType.clippy: - collection = CLIPPY_NAMES; - break; - case PetType.totoro: - collection = TOTORO_NAMES; - break; - case PetType.snake: - collection = SNAKE_NAMES; - break; - case PetType.rubberduck: - collection = DUCK_NAMES; - break; - case PetType.zappy: - collection = ZAPPY_NAMES; - break; - case PetType.rocky: - collection = ROCKY_NAMES; - break; - case PetType.cockatiel: - collection = COCKATIEL_NAMES; - break; - default: - collection = CAT_NAMES; - break; - } + const collection: ReadonlyArray = + ( + { + [PetType.cat]: CAT_NAMES, + [PetType.dog]: DOG_NAMES, + [PetType.crab]: CRAB_NAMES, + [PetType.clippy]: CLIPPY_NAMES, + [PetType.totoro]: TOTORO_NAMES, + [PetType.snake]: SNAKE_NAMES, + [PetType.rubberduck]: DUCK_NAMES, + [PetType.zappy]: ZAPPY_NAMES, + [PetType.rocky]: ROCKY_NAMES, + [PetType.cockatiel]: COCKATIEL_NAMES, + } as Record> + )[type] ?? CAT_NAMES; return ( - collection.get(Math.floor(Math.random() * collection.size) + 1) ?? - 'Unknown' + collection[Math.floor(Math.random() * collection.length)] ?? 'Unknown' ); }