diff --git a/frontend-react/src/components/freeagents/FAPostModal.tsx b/frontend-react/src/components/freeagents/FAPostModal.tsx index 6f979930c..39b698dd6 100644 --- a/frontend-react/src/components/freeagents/FAPostModal.tsx +++ b/frontend-react/src/components/freeagents/FAPostModal.tsx @@ -38,7 +38,6 @@ const FAPostModal: React.FC = ({ closeModal, post }) => { ) const [showErrors, setShowErrors] = useState(false) const [deleting, setDeleting] = useState(false) - const [disableSubmit, setDisableSubmit] = useState(false) const toast = useToast() const { themeColor, grayWithShade } = useContext(MyThemeContext) @@ -130,7 +129,6 @@ const FAPostModal: React.FC = ({ closeModal, post }) => { const actionType = post ? "EDIT" : "NEW" const handleSubmit = () => { - if (disableSubmit) return if ( form.playstyles?.length === 0 || !form.can_vc || @@ -143,10 +141,8 @@ const FAPostModal: React.FC = ({ closeModal, post }) => { return } - setDisableSubmit(true) if (actionType === "NEW") addFreeAgentPost() - if (actionType === "EDIT") editFreeAgentPost() - setDisableSubmit(false) + else if (actionType === "EDIT") editFreeAgentPost() } return ( diff --git a/graphql-schemas/build.js b/graphql-schemas/build.js index 39de06a2e..d918f9138 100644 --- a/graphql-schemas/build.js +++ b/graphql-schemas/build.js @@ -163,14 +163,8 @@ const resolvers = { invalidArgs: args, }) - const items = gear.flatMap(brand => { - const headItems = brand.head ? brand.head : [] - const clothesItems = brand.clothes ? brand.clothes : [] - const shoesItems = brand.shoes ? brand.shoes : [] - return headItems.concat(clothesItems).concat(shoesItems) - }) if (args.headgearItem) { - if (!items.includes(args.headgearItem)) + if (!gear.includes(args.headgearItem)) throw new UserInputError("Invalid headgear item.", { invalidArgs: args, }) @@ -178,7 +172,7 @@ const resolvers = { args.headgearItem = undefined } if (args.clothingItem) { - if (!items.includes(args.clothingItem)) + if (!gear.includes(args.clothingItem)) throw new UserInputError("Invalid clothing item.", { invalidArgs: args, }) @@ -186,7 +180,7 @@ const resolvers = { args.clothingItem = undefined } if (args.shoesItem) { - if (!items.includes(args.shoesItem)) + if (!gear.includes(args.shoesItem)) throw new UserInputError("Invalid shoes item.", { invalidArgs: args, }) @@ -254,26 +248,20 @@ const resolvers = { invalidArgs: args, }) - const items = gear.flatMap(brand => { - const headItems = brand.head ? brand.head : [] - const clothesItems = brand.clothes ? brand.clothes : [] - const shoesItems = brand.shoes ? brand.shoes : [] - return headItems.concat(clothesItems).concat(shoesItems) - }) if (args.headgearItem) { - if (!items.includes(args.headgearItem)) + if (!gear.includes(args.headgearItem)) throw new UserInputError("Invalid headgear item.", { invalidArgs: args, }) } if (args.clothingItem) { - if (!items.includes(args.clothingItem)) + if (!gear.includes(args.clothingItem)) throw new UserInputError("Invalid clothing item.", { invalidArgs: args, }) } if (args.shoesItem) { - if (!items.includes(args.shoesItem)) + if (!gear.includes(args.shoesItem)) throw new UserInputError("Invalid shoes item.", { invalidArgs: args, }) diff --git a/graphql-schemas/detailedtournament.js b/graphql-schemas/detailedtournament.js index dd391fe08..0e496e164 100644 --- a/graphql-schemas/detailedtournament.js +++ b/graphql-schemas/detailedtournament.js @@ -1,12 +1,12 @@ const { UserInputError, gql } = require("apollo-server-express") const DetailedTournament = require("../mongoose-models/detailedtournament") -const DetailedSet = require("../mongoose-models/detailedset") +const DetailedMatch = require("../mongoose-models/detailedmatch") const typeDef = gql` extend type Mutation { addDetailedTournament( tournament: DetailedTournamentInput! - maps: [DetailedMapInput!]! + matches: [DetailedMatchInput!]! lanistaToken: String! ): Boolean! } @@ -28,9 +28,20 @@ const typeDef = gql` type: EventType! } - input DetailedMapInput { + input DetailedMatchInput { + round_name: String! round_number: Int! - game_number: Int! + match_details: [DetailedMapInput!]! + } + + type DetailedMatch { + round_name: String! + round_number: Int! + match_details: [DetailedMap!]! + type: EventType! + } + + input DetailedMapInput { stage: String! mode: Mode! duration: Int! @@ -40,15 +51,12 @@ const typeDef = gql` type DetailedMap { tournament_id: DetailedTournament! - round_number: Int! - game_number: Int! stage: String! mode: Mode! "Duration of the round in seconds" duration: Int! winners: TeamInfo! losers: TeamInfo! - type: EventType! } input TeamInfoInput { diff --git a/mongoose-models/detailedset.js b/mongoose-models/detailedmatch.js similarity index 75% rename from mongoose-models/detailedset.js rename to mongoose-models/detailedmatch.js index b86c67afe..c5bab4468 100644 --- a/mongoose-models/detailedset.js +++ b/mongoose-models/detailedmatch.js @@ -19,18 +19,22 @@ const TeamInfo = { score: Number, } -const detailedSetSchema = new mongoose.Schema({ +const Map = { tournament_id: { type: mongoose.Schema.Types.ObjectId, ref: "DetailedTournament", }, - round_number: Number, - game_number: Number, stage: String, mode: String, duration: Number, winners: TeamInfo, losers: TeamInfo, +} + +const detailedMatchSchema = new mongoose.Schema({ + round_number: Number, + round_name: String, + match_details: [Map], }) -module.exports = mongoose.model("DetailedSet", detailedSetSchema) +module.exports = mongoose.model("DetailedMatch", detailedMatchSchema) diff --git a/utils/gear.js b/utils/gear.js index f38a29bff..4081c91f7 100644 --- a/utils/gear.js +++ b/utils/gear.js @@ -1,721 +1,585 @@ const gear = [ - { - brand: "amiibo", - clothes: [ - "Enchanted Robe", - "Fresh Fish Gloves", - "Marinated Top", - "Pearlescent Hoodie", - "Power Armor", - "Power Armor Mk I", - "Samurai Jacket", - "School Cardigan", - "School Uniform", - "Squinja Suit", - "Steel Platemail", - ], - head: [ - "Enchanted Hat", - "Fresh Fish Head", - "Marinated Headphones", - "Pearlescent Crown", - "Power Mask", - "Power Mask Mk I", - "Samurai Helmet", - "Squid Clip-Ons", - "Squid Hairclip", - "Squinja Mask", - "Steel Helm", - ], - shoes: [ - "Enchanted Boots", - "Fresh Fish Feet", - "Fringed Loafers", - "Marinated Slip-Ons", - "Pearlescent Kicks", - "Power Boots", - "Power Boots Mk I", - "Samurai Shoes", - "School Shoes", - "Squinja Boots", - "Steel Greaves", - ], - }, - { - brand: "Annaki", - clothes: [ - "Annaki Blue Cuff", - "Annaki Drive Tee ", - "Annaki Evolution Tee", - "Annaki Flannel Hoodie", - "Annaki Polpo-Pic Tee", - "Annaki Red Cuff", - "Annaki Yellow Cuff", - "Crimson Parashooter", - "Hula Punk Shirt", - "Prune Parashooter", - "Red Hula Punk with Tie", - "Rockin' Leather Jacket", - ], - head: ["Annaki Beret", "Annaki Beret & Glasses", "Annaki Mask"], - shoes: ["Annaki Arachno Boots", "Annaki Habaneros", "Annaki Tigers"], - }, - { - brand: "Cuttlegear", - clothes: [ - "Armor Jacket Replica", - "Black Cuttlegear LS", - "Fresh Octo Tee", - "Hero Hoodie Replica", - "Hero Jacket Replica", - "Neo Octoling Armor", - "Null Armor Replica", - "Octarian Retro", - "Octo Layered LS", - "Octo Tee", - "Old-Timey Clothes", - "Red Cuttlegear LS", - "Sennyu Suit", - ], - head: [ - "Armor Helmet Replica", - "Conductor Cap", - "Golden Toothpick", - "Hero Headphones Replica", - "Hero Headset Replica", - "Null Visor Replica", - "Octoling Shades", - "Old-Timey Hat", - "Studio Octophones", - ], - shoes: [ - "Armor Boot Replicas", - "Hero Runner Replicas", - "Hero Snowboots Replicas", - "Neo Octoling Boots", - "Null Boots Replica", - "Old-Timey Shoes", - ], - }, - { - brand: "Enperry", - clothes: [ - "Black Velour Octoking Tee ", - "Grape Hoodie", - "Green Velour Octoking Tee", - "King Jersey", - "Milky Eminence Jacket", - "N-Pacer Sweat", - "Navy Eminence Jacket", - "Navy King Tank", - "Octoking HK Jersey", - "Slash King Tank", - "White King Tank", - ], - head: [ - "Eminence Cuff", - "King Facemask", - "King Flip Mesh", - "Octoking Facemask", - ], - shoes: [ - "Black & Blue Squidkid V", - "Blue & Black Squidkid IV", - "Honey & Orange Squidkid V", - "Milky Enperrials", - "N-Pacer Ag", - "N-Pacer Au", - "N-Pacer CaO", - "Navy Enperrials", - "Online Squidkid V", - "Pearlescent Squidkid IV", - "Red & Black Squidkid IV", - "Red & White Squidkid V", - "Rina Squidkid IV", - "Sun & Shade Squidkid IV", - ], - }, - { - brand: "Firefin", - clothes: [ - "Baseball Jersey", - "Black 8-Bit FishFry", - "Blue 16-Bit FishFry", - "Camo Zip Hoodie", - "Carnivore Tee", - "Dark Urban Vest", - "Firefin Navy Sweat", - "Fugu Tee", - "Gray 8-Bit FishFry", - "Green Zip Hoodie", - "Herbivore Tee", - "Khaki 16-Bit FishFry", - "White 8-Bit FishFry", - "Yellow Urban Vest", - "ω-3 Tee", - ], - head: [ - "Black FishFry Bandana", - "Blowfish Bell Hat", - "Blowfish Newsie", - "Camo Mesh", - "Firefin Facemask", - "FishFry Biscuit Bandana", - "FishFry Visor", - "Fugu Bell Hat", - "Jet Cap", - "Jungle Hat", - "Knitted Hat", - "Octoglasses", - ], - shoes: ["Red FishFry Sandals", "Yellow FishFry Sandals"], - }, - { - brand: "Forge", - clothes: [ - "Aloha Shirt", - "Blue Sailor Suit", - "Brown FA-11 Bomber", - "Custom Painted F-3 ", - "FA-01 Jacket", - "FA-01 Reversed", - "Forge Inkling Parka", - "Forge Octarian Jacket", - "Gray FA-11 Bomber", - "Green Tee", - "Moist Ghillie Suit", - "White Leather F-3", - "White Sailor Suit", - ], - head: [ - "Deca Tackle Visor Helmet", - "Designer Headphones", - "Digi-Camo Forge Mask", - "Forge Mask", - "Gas Mask", - "Hockey Helmet", - "Moist Ghillie Helmet", - "Motocross Nose Guard", - "Noise Cancelers", - "Octo Tackle Helmet Deco", - "Paintball Mask", - "Pilot Goggles", - "Safari Hat", - "Sennyu Goggles", - "Sennyu Headphones", - "Skull Bandana", - "Snorkel Mask", - "Special Forces Beret", - "Splash Goggles", - "Squidfin Hook Cans", - "Squidlife Headphones", - "Stealth Goggles", - "Studio Headphones", - "Treasure Hunter", - ], - shoes: ["Moist Ghillie Boots"], - }, - { - brand: "Grizzco", - clothes: [ - "Anchor Life Vest", - "Crustwear XXL", - "Dev Uniform", - "Garden Gear", - "Juice Parka", - "North-Country Parka", - "Octoleet Armor", - "Office Attire", - "Online Jersey", - "Record Shop Look EP", - "Squiddor Polo", - "SRL Coat", - ], - head: [ - "Beekeeper Hat", - "Cap of Legend", - "Dust Blocker 2000", - "Headlamp Helmet", - "Oceanic Hard Hat", - "Octoleet Goggles", - "Sailor Cap", - "Welding Mask", - "Worker's Cap", - "Worker's Head Towel", - ], - shoes: [ - "Angry Rain Boots", - "Flipper Floppers", - "Friendship Bracelet", - "Non-slip Senseis", - "Octoleet Boots", - "Wooden Sandals", - ], - }, - { - brand: "Inkline", - clothes: [ - "Berry Ski Jacket", - "Blue Peaks Tee", - "Chili-Pepper Ski Jacket", - "Chilly Mountain Coat", - "Eggplant Mountain Coat", - "Fishing Vest", - "Forest Vest", - "Green Striped LS", - "Ivory Peaks Tee", - "Matcha Down Jacket", - "Mountain Vest", - "Olive Ski Jacket", - "Striped Peaks LS", - ], - head: [ - "Bamboo Hat", - "Camping Hat", - "Lightweight Cap", - "Mountie Hat", - "Seashell Bamboo Hat", - "Short Beanie", - "Tulip Parasol", - "Yamagiri Beanie", - ], - shoes: [ - "Acerola Rain Boots", - "Birch Climbing Shoes", - "Bubble Rain Boots", - "Custom Trail Boots", - "Green Rain Boots", - "Luminous Delta Straps", - "Musselforge Flip-Flops", - "Neon Delta Straps", - "Pro Trail Boots", - "Snow Delta Straps", - "Sunny Climbing Shoes", - "Trail Boots", - ], - }, - { - brand: "Krak-On", - clothes: [ - "Chili Octo Aloha", - "Krak-On 528", - "Missus Shrug Tee", - "Mister Shrug Tee", - "Octobowler Shirt", - "Rainy-Day Tee", - "Rodeo Shirt", - "Squid-Pattern Waistcoat", - "Squidstar Waistcoat", - "Sunny-Day Tee", - ], - head: [ - "Full Moon Glasses", - "Hickory Work Cap", - "Long-Billed Cap", - "Paisley Bandana", - "Two-Stripe Mesh", - "Woolly Urchins Classic", - ], - shoes: [ - "Banana Basics", - "Blue Slip-Ons", - "Blueberry Casuals", - "Choco Clogs", - "Clownfish Basics", - "Cream Basics", - "Cream Hi-Tops", - "Hunter Hi-Tops", - "Midnight Slip-Ons", - "Oyster Clogs", - "Plum Casuals", - "Polka-dot Slip-Ons", - "Red Hi-Tops", - "Red Slip-Ons", - "Squid-Stitch Slip-Ons", - "Truffle Canvas Hi-Tops", - ], - }, - { - brand: "Rockenberg", - clothes: [ - "Black Baseball LS", - "Black Inky Rider", - "Black Urchin Rock Tee", - "Chirpy Chips Band Tee", - "Hightide Era Band Tee", - "Lumberjack Shirt", - "Rockenberg Black", - "Rockenberg White", - "Round-Collar Shirt", - "Squid Squad Band Tee", - "Vintage Check Shirt", - "Wet Floor Band Tee", - "White Baseball LS", - "White Inky Rider", - "White Urchin Rock Tee", - ], - head: ["18K Aviators", "SV925 Circle Shades"], - shoes: [ - "Blue Moto Boots", - "Cherry Kicks", - "Deepsea Leather Boots", - "Gray Yellow-Soled Wingtips", - "Inky Kid Clams", - "Kid Clams", - "Moto Boots", - "Navy Red-Soled Wingtips", - "New-Leaf Leather Boots", - "Pearl Punk Crowns", - "Punk Blacks", - "Punk Cherries", - "Punk Whites", - "Punk Yellows", - "Red Work Boots", - "Roasted Brogues", - "Sennyu Inksoles", - "Smoky Wingtips", - "Squink Wingtips", - "Tan Work Boots", - "Turquoise Kicks", - "White Kicks", - ], - }, - { - brand: "Skalop", - clothes: [ - "Black Hoodie", - "Dots-On-Dots Shirt", - "Firewave Tee", - "Grape Tee", - "Gray Hoodie", - "Hothouse Hoodie", - "Icewave Tee", - "Mint Tee", - "Pearl Tee", - "Reggae Tee", - "Squid-Stitch Tee", - ], - head: [ - "Bike Helmet", - "Classic Straw Boater", - "Do-Rag, Cap, & Glasses", - "Hothouse Hat", - "Jellyvader Cap", - "Patched Hat", - "Skate Helmet", - "Sneaky Beanie", - "Sporty Bobble Hat", - "Squid Nordic", - "Squid-Stitch Cap", - "Squidvader Cap", - "Straw Boater", - "Streetstyle Cap", - "Urchins Cap", - "Visor Skate Helmet", - ], - shoes: [], - }, - { - brand: "Splash Mob", - clothes: [ - "Baby-Jelly Shirt", - "Baby-Jelly Shirt & Tie", - "Gray College Sweat", - "Green Cardigan", - "Lime Easy-Stripe Shirt", - "Linen Shirt", - "Navy College Sweat", - "Navy Striped LS", - "Orange Cardigan", - "Pink Easy-Stripe Shirt", - "Pink Hoodie", - "Pirate-Stripe Tee", - "Sage Polo", - "Sailor-Stripe Tee", - "Shirt & Tie", - "Shirt with Blue Hoodie", - "Shrimp-Pink Polo", - "Striped Shirt", - "Varsity Baseball LS", - "Whale-Knit Sweater", - "White Shirt", - "White Striped LS", - ], - head: [ - "Bobble Hat", - "Half-Rim Glasses", - "House-Tag Denim Cap", - "Pilot Hat", - "Retro Specs", - "Sennyu Bon Bon Beanie", - "Sennyu Specs", - "Striped Beanie", - ], - shoes: [ - "Green Laceups", - "Hunting Boots", - "Mawcasins", - "Piranha Moccasins", - "Shark Moccasins", - "Strapping Reds", - "Strapping Whites", - "Tea-Green Hunting Boots", - ], - }, - { - brand: "SquidForce", - clothes: [ - "Anchor Sweat", - "Basic Tee", - "Black Anchor Tee", - "Black Layered LS", - "Black Tee", - "Black V-Neck Tee", - "Camo Layered LS", - "Friend Tee", - "Green V-Neck Limited Tee", - "Layered Anchor LS", - "League Tee", - "Mecha Body - AKM", - "Octo Support Hoodie", - "Red V-Neck Limited Tee", - "Retro Sweat", - "Splatfest Tee", - "Squid Yellow Layered LS", - "Squidmark LS", - "Squidmark Sweat", - "SWC Logo Tee", - "White Anchor Tee", - "White Layered LS", - "White LS", - "White Tee", - "White V-Neck Tee", - "Yellow Layered LS", - ], - head: [ - "Anglerfish Mask", - "Bucket Hat", - "Eel-Cake Hat", - "Festive Party Cone", - "Hockey Mask", - "Koshien Bandana", - "Kyonshi Hat", - "Li'l Devil Horns", - "Mecha Head - HTR", - "New Year's Glasses DX", - "Painter's Mask", - "Squid Facemask", - "Twisty Headband", - "White Headband", - "Jetflame Crest", - "Fierce Fishskull", - "Hivemind Antenna", - "Eye of Justice", - ], - shoes: ["Mecha Legs - LBS"], - }, - { - brand: "Takoroka", - clothes: [ - "Choco Layered LS", - "FC Albacore", - "Gray Vector Tee", - "Layered Vector LS", - "Purple Camo LS", - "Red Vector Tee", - "Slipstream United", - "Striped Rugby", - "Takoroka Crazy Baseball LS", - "Takoroka Galactic Tie Dye", - "Takoroka Jersey", - "Takoroka Nylon Vintage", - "Takoroka Rainbow Tie Dye", - "Takoroka Windcrusher", - "Tricolor Rugby", - ], - head: ["Takoroka Mesh", "Takoroka Visor"], - shoes: [ - "Athletic Arrows", - "Blue Power Stripes", - "Crazy Arrows", - "LE Soccer Shoes", - "New-Day Arrows", - "Orange Arrows", - "Orca Hi-Tops", - "Orca Passion Hi-Tops", - "Orca Woven Hi-Tops", - "Red Power Stripes", - "Soccer Shoes", - "Sunset Orca Hi-Tops", - "Trooper Power Stripes", - "White Arrows", - ], - }, - { - brand: "Tentatek", - clothes: [ - "Black Squideye", - "Blue Tentatek Tee", - "Cycle King Jersey", - "Lob-Stars Jersey", - "Part-Time Pirate", - "Red Tentatek Tee", - "Silver Tentatek Vest", - "Sky-Blue Squideye", - "Tentatek Slogan Tee", - ], - head: [ - "Cycle King Cap", - "Fake Contacts", - "Green Novelty Visor", - "Orange Novelty Visor", - "Pink Novelty Visor", - "Purple Novelty Visor", - "Soccer Headband", - "Sun Visor", - "Tennis Headband", - ], - shoes: [ - "Amber Sea Slug Hi-Tops", - "Black Norimaki 750s", - "Black Trainers", - "Blue Iromaki 750s", - "Blue Sea Slugs", - "Canary Trainers", - "Cyan Trainers", - "Gray Sea-Slug Hi-Tops", - "Green Iromaki 750s", - "Icy Down Boots", - "Neon Sea Slugs", - "Orange Iromaki 750s", - "Pink Trainers", - "Purple Iromaki 750s", - "Purple Sea Slugs", - "Red Iromaki 750s", - "Red Sea Slugs", - "Red-Mesh Sneakers", - "Sea Slug Volt 95s", - "Sesame Salt 270s", - "Snowy Down Boots", - "Violet Trainers", - "White Norimaki 750s", - "Yellow Iromaki 750s", - "Yellow-Mesh Sneakers", - ], - }, - { - brand: "Toni Kensa", - clothes: [ - "Dark Bomber Jacket", - "Front Zip Vest", - "Half-Sleeve Sweater", - "Ink-Wash Shirt", - "Inkfall Shirt", - "Kensa Coat", - "Kung-Fu Zip-Up", - "Light Bomber Jacket", - "Negative Longcuff Sweater", - "Panda Kung-Fu Zip-Up", - "Positive Longcuff Sweater", - "Pullover Coat", - "Short Knit Layers", - "Toni K. Baseball Jersey", - ], - head: ["Face Visor", "Ink-Guard Goggles", "Toni Kensa Goggles"], - shoes: [ - "Arrow Pull-Ons", - "Toni Kensa Black Hi-Tops", - "Toni Kensa Soccer Shoes", - ], - }, - { - brand: "Zekko", - clothes: [ - "Birded Corduroy Jacket", - "Black LS", - "Black Polo", - "Deep-Octo Satin Jacket", - "Gray Mixed Shirt", - "Green-Check Shirt", - "Logo Aloha Shirt", - "Olive Zekko Parka", - "Red-Check Shirt", - "Reel Sweat", - "Squid Satin Jacket", - "Tumeric Zekko Coat", - "Varsity Jacket", - "Zapfish Satin Jacket", - "Zekko Baseball LS", - "Zekko Hoodie", - "Zekko Jade Coat", - "Zekko Long Carrot Tee", - "Zekko Long Radish Tee", - "Zekko Redleaf Coat", - ], - head: [ - "Backwards Cap", - "Black Arrowbands", - "Double Egg Shades", - "Five-Panel Cap", - "Jogging Headband", - "Matte Bike Helmet", - "MTB Helmet", - "Tinted Shades", - "White Arrowbands", - "Zekko Cap", - "Zekko Mesh", - ], - shoes: [ - "Black Flip-Flops", - "Blue Lo-Tops", - "LE Lo-Tops", - "Marination Lace-Ups", - "Orange Lo-Tops", - "Pearl-Scout Lace-Ups", - "Suede Gray Lace-Ups", - "Suede Marine Lace-Ups", - "Suede Nation Lace-Ups", - ], - }, - { - brand: "Zink", - clothes: [ - "B-ball Jersey (Away)", - "B-ball Jersey (Home)", - "Cycling Shirt", - "Dakro Golden Tee", - "Dakro Nana Tee", - "Inkopolis Squaps Jersey", - "Navy Deca Logo Tee", - "Retro Gamer Jersey", - "School Jersey", - "Urchins Jersey", - "White Deca Logo Tee", - "Zink Layered LS", - "Zink LS", - ], - head: [ - "B-ball Headband", - "Cycling Cap", - "Golf Visor", - "Squash Headband", - "Swim Goggles", - ], - shoes: [ - "Black Dakroniks", - "Black Seahorses", - "Blue Laceless Dakroniks", - "Chocolate Dakroniks", - "Gold Hi-Horses", - "Mint Dakroniks", - "Purple Hi-Horses", - "Red Hi-Horses", - "White Laceless Dakroniks", - "White Seahorses", - "Yellow Seahorses", - "Zombie Hi-Horses", - ], - }, + "Enchanted Hat", + "Fresh Fish Head", + "Marinated Headphones", + "Pearlescent Crown", + "Power Mask", + "Power Mask Mk I", + "Samurai Helmet", + "Squid Clip-Ons", + "Squid Hairclip", + "Squinja Mask", + "Steel Helm", + "Enchanted Robe", + "Fresh Fish Gloves", + "Marinated Top", + "Pearlescent Hoodie", + "Power Armor", + "Power Armor Mk I", + "Samurai Jacket", + "School Cardigan", + "School Uniform", + "Squinja Suit", + "Steel Platemail", + "Enchanted Boots", + "Fresh Fish Feet", + "Fringed Loafers", + "Marinated Slip-Ons", + "Pearlescent Kicks", + "Power Boots", + "Power Boots Mk I", + "Samurai Shoes", + "School Shoes", + "Squinja Boots", + "Steel Greaves", + "Annaki Beret", + "Annaki Beret & Glasses", + "Annaki Mask", + "Annaki Blue Cuff", + "Annaki Drive Tee ", + "Annaki Evolution Tee", + "Annaki Flannel Hoodie", + "Annaki Polpo-Pic Tee", + "Annaki Red Cuff", + "Annaki Yellow Cuff", + "Crimson Parashooter", + "Hula Punk Shirt", + "Prune Parashooter", + "Red Hula Punk with Tie", + "Rockin' Leather Jacket", + "Annaki Arachno Boots", + "Annaki Habaneros", + "Annaki Tigers", + "Armor Helmet Replica", + "Conductor Cap", + "Golden Toothpick", + "Hero Headphones Replica", + "Hero Headset Replica", + "Null Visor Replica", + "Octoling Shades", + "Old-Timey Hat", + "Studio Octophones", + "Armor Jacket Replica", + "Black Cuttlegear LS", + "Fresh Octo Tee", + "Hero Hoodie Replica", + "Hero Jacket Replica", + "Neo Octoling Armor", + "Null Armor Replica", + "Octarian Retro", + "Octo Layered LS", + "Octo Tee", + "Old-Timey Clothes", + "Red Cuttlegear LS", + "Sennyu Suit", + "Armor Boot Replicas", + "Hero Runner Replicas", + "Hero Snowboots Replicas", + "Neo Octoling Boots", + "Null Boots Replica", + "Old-Timey Shoes", + "Eminence Cuff", + "King Facemask", + "King Flip Mesh", + "Octoking Facemask", + "Black Velour Octoking Tee ", + "Grape Hoodie", + "Green Velour Octoking Tee", + "King Jersey", + "Milky Eminence Jacket", + "N-Pacer Sweat", + "Navy Eminence Jacket", + "Navy King Tank", + "Octoking HK Jersey", + "Slash King Tank", + "White King Tank", + "Black & Blue Squidkid V", + "Blue & Black Squidkid IV", + "Honey & Orange Squidkid V", + "Milky Enperrials", + "N-Pacer Ag", + "N-Pacer Au", + "N-Pacer CaO", + "Navy Enperrials", + "Online Squidkid V", + "Pearlescent Squidkid IV", + "Red & Black Squidkid IV", + "Red & White Squidkid V", + "Rina Squidkid IV", + "Sun & Shade Squidkid IV", + "Black FishFry Bandana", + "Blowfish Bell Hat", + "Blowfish Newsie", + "Camo Mesh", + "Firefin Facemask", + "FishFry Biscuit Bandana", + "FishFry Visor", + "Fugu Bell Hat", + "Jet Cap", + "Jungle Hat", + "Knitted Hat", + "Octoglasses", + "Baseball Jersey", + "Black 8-Bit FishFry", + "Blue 16-Bit FishFry", + "Camo Zip Hoodie", + "Carnivore Tee", + "Dark Urban Vest", + "Firefin Navy Sweat", + "Fugu Tee", + "Gray 8-Bit FishFry", + "Green Zip Hoodie", + "Herbivore Tee", + "Khaki 16-Bit FishFry", + "White 8-Bit FishFry", + "Yellow Urban Vest", + "ω-3 Tee", + "Red FishFry Sandals", + "Yellow FishFry Sandals", + "Deca Tackle Visor Helmet", + "Designer Headphones", + "Digi-Camo Forge Mask", + "Forge Mask", + "Gas Mask", + "Hockey Helmet", + "Moist Ghillie Helmet", + "Motocross Nose Guard", + "Noise Cancelers", + "Octo Tackle Helmet Deco", + "Paintball Mask", + "Pilot Goggles", + "Safari Hat", + "Sennyu Goggles", + "Sennyu Headphones", + "Skull Bandana", + "Snorkel Mask", + "Special Forces Beret", + "Splash Goggles", + "Squidfin Hook Cans", + "Squidlife Headphones", + "Stealth Goggles", + "Studio Headphones", + "Treasure Hunter", + "Aloha Shirt", + "Blue Sailor Suit", + "Brown FA-11 Bomber", + "Custom Painted F-3 ", + "FA-01 Jacket", + "FA-01 Reversed", + "Forge Inkling Parka", + "Forge Octarian Jacket", + "Gray FA-11 Bomber", + "Green Tee", + "Moist Ghillie Suit", + "White Leather F-3", + "White Sailor Suit", + "Moist Ghillie Boots", + "Beekeeper Hat", + "Cap of Legend", + "Dust Blocker 2000", + "Headlamp Helmet", + "Oceanic Hard Hat", + "Octoleet Goggles", + "Sailor Cap", + "Welding Mask", + "Worker's Cap", + "Worker's Head Towel", + "Anchor Life Vest", + "Crustwear XXL", + "Dev Uniform", + "Garden Gear", + "Juice Parka", + "North-Country Parka", + "Octoleet Armor", + "Office Attire", + "Online Jersey", + "Record Shop Look EP", + "Squiddor Polo", + "SRL Coat", + "Angry Rain Boots", + "Flipper Floppers", + "Friendship Bracelet", + "Non-slip Senseis", + "Octoleet Boots", + "Wooden Sandals", + "Bamboo Hat", + "Camping Hat", + "Lightweight Cap", + "Mountie Hat", + "Seashell Bamboo Hat", + "Short Beanie", + "Tulip Parasol", + "Yamagiri Beanie", + "Berry Ski Jacket", + "Blue Peaks Tee", + "Chili-Pepper Ski Jacket", + "Chilly Mountain Coat", + "Eggplant Mountain Coat", + "Fishing Vest", + "Forest Vest", + "Green Striped LS", + "Ivory Peaks Tee", + "Matcha Down Jacket", + "Mountain Vest", + "Olive Ski Jacket", + "Striped Peaks LS", + "Acerola Rain Boots", + "Birch Climbing Shoes", + "Bubble Rain Boots", + "Custom Trail Boots", + "Green Rain Boots", + "Luminous Delta Straps", + "Musselforge Flip-Flops", + "Neon Delta Straps", + "Pro Trail Boots", + "Snow Delta Straps", + "Sunny Climbing Shoes", + "Trail Boots", + "Full Moon Glasses", + "Hickory Work Cap", + "Long-Billed Cap", + "Paisley Bandana", + "Two-Stripe Mesh", + "Woolly Urchins Classic", + "Chili Octo Aloha", + "Krak-On 528", + "Missus Shrug Tee", + "Mister Shrug Tee", + "Octobowler Shirt", + "Rainy-Day Tee", + "Rodeo Shirt", + "Squid-Pattern Waistcoat", + "Squidstar Waistcoat", + "Sunny-Day Tee", + "Banana Basics", + "Blue Slip-Ons", + "Blueberry Casuals", + "Choco Clogs", + "Clownfish Basics", + "Cream Basics", + "Cream Hi-Tops", + "Hunter Hi-Tops", + "Midnight Slip-Ons", + "Oyster Clogs", + "Plum Casuals", + "Polka-dot Slip-Ons", + "Red Hi-Tops", + "Red Slip-Ons", + "Squid-Stitch Slip-Ons", + "Truffle Canvas Hi-Tops", + "18K Aviators", + "SV925 Circle Shades", + "Black Baseball LS", + "Black Inky Rider", + "Black Urchin Rock Tee", + "Chirpy Chips Band Tee", + "Hightide Era Band Tee", + "Lumberjack Shirt", + "Rockenberg Black", + "Rockenberg White", + "Round-Collar Shirt", + "Squid Squad Band Tee", + "Vintage Check Shirt", + "Wet Floor Band Tee", + "White Baseball LS", + "White Inky Rider", + "White Urchin Rock Tee", + "Blue Moto Boots", + "Cherry Kicks", + "Deepsea Leather Boots", + "Gray Yellow-Soled Wingtips", + "Inky Kid Clams", + "Kid Clams", + "Moto Boots", + "Navy Red-Soled Wingtips", + "New-Leaf Leather Boots", + "Pearl Punk Crowns", + "Punk Blacks", + "Punk Cherries", + "Punk Whites", + "Punk Yellows", + "Red Work Boots", + "Roasted Brogues", + "Sennyu Inksoles", + "Smoky Wingtips", + "Squink Wingtips", + "Tan Work Boots", + "Turquoise Kicks", + "White Kicks", + "Bike Helmet", + "Classic Straw Boater", + "Do-Rag, Cap, & Glasses", + "Hothouse Hat", + "Jellyvader Cap", + "Patched Hat", + "Skate Helmet", + "Sneaky Beanie", + "Sporty Bobble Hat", + "Squid Nordic", + "Squid-Stitch Cap", + "Squidvader Cap", + "Straw Boater", + "Streetstyle Cap", + "Urchins Cap", + "Visor Skate Helmet", + "Black Hoodie", + "Dots-On-Dots Shirt", + "Firewave Tee", + "Grape Tee", + "Gray Hoodie", + "Hothouse Hoodie", + "Icewave Tee", + "Mint Tee", + "Pearl Tee", + "Reggae Tee", + "Squid-Stitch Tee", + "Bobble Hat", + "Half-Rim Glasses", + "House-Tag Denim Cap", + "Pilot Hat", + "Retro Specs", + "Sennyu Bon Bon Beanie", + "Sennyu Specs", + "Striped Beanie", + "Baby-Jelly Shirt", + "Baby-Jelly Shirt & Tie", + "Gray College Sweat", + "Green Cardigan", + "Lime Easy-Stripe Shirt", + "Linen Shirt", + "Navy College Sweat", + "Navy Striped LS", + "Orange Cardigan", + "Pink Easy-Stripe Shirt", + "Pink Hoodie", + "Pirate-Stripe Tee", + "Sage Polo", + "Sailor-Stripe Tee", + "Shirt & Tie", + "Shirt with Blue Hoodie", + "Shrimp-Pink Polo", + "Striped Shirt", + "Varsity Baseball LS", + "Whale-Knit Sweater", + "White Shirt", + "White Striped LS", + "Green Laceups", + "Hunting Boots", + "Mawcasins", + "Piranha Moccasins", + "Shark Moccasins", + "Strapping Reds", + "Strapping Whites", + "Tea-Green Hunting Boots", + "Anglerfish Mask", + "Bucket Hat", + "Eel-Cake Hat", + "Festive Party Cone", + "Hockey Mask", + "Koshien Bandana", + "Kyonshi Hat", + "Li'l Devil Horns", + "Mecha Head - HTR", + "New Year's Glasses DX", + "Painter's Mask", + "Squid Facemask", + "Twisty Headband", + "White Headband", + "Jetflame Crest", + "Fierce Fishskull", + "Hivemind Antenna", + "Eye of Justice", + "Anchor Sweat", + "Basic Tee", + "Black Anchor Tee", + "Black Layered LS", + "Black Tee", + "Black V-Neck Tee", + "Camo Layered LS", + "Friend Tee", + "Green V-Neck Limited Tee", + "Layered Anchor LS", + "League Tee", + "Mecha Body - AKM", + "Octo Support Hoodie", + "Red V-Neck Limited Tee", + "Retro Sweat", + "Splatfest Tee", + "Squid Yellow Layered LS", + "Squidmark LS", + "Squidmark Sweat", + "SWC Logo Tee", + "White Anchor Tee", + "White Layered LS", + "White LS", + "White Tee", + "White V-Neck Tee", + "Yellow Layered LS", + "Mecha Legs - LBS", + "Takoroka Mesh", + "Takoroka Visor", + "Choco Layered LS", + "FC Albacore", + "Gray Vector Tee", + "Layered Vector LS", + "Purple Camo LS", + "Red Vector Tee", + "Slipstream United", + "Striped Rugby", + "Takoroka Crazy Baseball LS", + "Takoroka Galactic Tie Dye", + "Takoroka Jersey", + "Takoroka Nylon Vintage", + "Takoroka Rainbow Tie Dye", + "Takoroka Windcrusher", + "Tricolor Rugby", + "Athletic Arrows", + "Blue Power Stripes", + "Crazy Arrows", + "LE Soccer Shoes", + "New-Day Arrows", + "Orange Arrows", + "Orca Hi-Tops", + "Orca Passion Hi-Tops", + "Orca Woven Hi-Tops", + "Red Power Stripes", + "Soccer Shoes", + "Sunset Orca Hi-Tops", + "Trooper Power Stripes", + "White Arrows", + "Cycle King Cap", + "Fake Contacts", + "Green Novelty Visor", + "Orange Novelty Visor", + "Pink Novelty Visor", + "Purple Novelty Visor", + "Soccer Headband", + "Sun Visor", + "Tennis Headband", + "Black Squideye", + "Blue Tentatek Tee", + "Cycle King Jersey", + "Lob-Stars Jersey", + "Part-Time Pirate", + "Red Tentatek Tee", + "Silver Tentatek Vest", + "Sky-Blue Squideye", + "Tentatek Slogan Tee", + "Amber Sea Slug Hi-Tops", + "Black Norimaki 750s", + "Black Trainers", + "Blue Iromaki 750s", + "Blue Sea Slugs", + "Canary Trainers", + "Cyan Trainers", + "Gray Sea-Slug Hi-Tops", + "Green Iromaki 750s", + "Icy Down Boots", + "Neon Sea Slugs", + "Orange Iromaki 750s", + "Pink Trainers", + "Purple Iromaki 750s", + "Purple Sea Slugs", + "Red Iromaki 750s", + "Red Sea Slugs", + "Red-Mesh Sneakers", + "Sea Slug Volt 95s", + "Sesame Salt 270s", + "Snowy Down Boots", + "Violet Trainers", + "White Norimaki 750s", + "Yellow Iromaki 750s", + "Yellow-Mesh Sneakers", + "Face Visor", + "Ink-Guard Goggles", + "Toni Kensa Goggles", + "Dark Bomber Jacket", + "Front Zip Vest", + "Half-Sleeve Sweater", + "Ink-Wash Shirt", + "Inkfall Shirt", + "Kensa Coat", + "Kung-Fu Zip-Up", + "Light Bomber Jacket", + "Negative Longcuff Sweater", + "Panda Kung-Fu Zip-Up", + "Positive Longcuff Sweater", + "Pullover Coat", + "Short Knit Layers", + "Toni K. Baseball Jersey", + "Arrow Pull-Ons", + "Toni Kensa Black Hi-Tops", + "Toni Kensa Soccer Shoes", + "Backwards Cap", + "Black Arrowbands", + "Double Egg Shades", + "Five-Panel Cap", + "Jogging Headband", + "Matte Bike Helmet", + "MTB Helmet", + "Tinted Shades", + "White Arrowbands", + "Zekko Cap", + "Zekko Mesh", + "Birded Corduroy Jacket", + "Black LS", + "Black Polo", + "Deep-Octo Satin Jacket", + "Gray Mixed Shirt", + "Green-Check Shirt", + "Logo Aloha Shirt", + "Olive Zekko Parka", + "Red-Check Shirt", + "Reel Sweat", + "Squid Satin Jacket", + "Tumeric Zekko Coat", + "Varsity Jacket", + "Zapfish Satin Jacket", + "Zekko Baseball LS", + "Zekko Hoodie", + "Zekko Jade Coat", + "Zekko Long Carrot Tee", + "Zekko Long Radish Tee", + "Zekko Redleaf Coat", + "Black Flip-Flops", + "Blue Lo-Tops", + "LE Lo-Tops", + "Marination Lace-Ups", + "Orange Lo-Tops", + "Pearl-Scout Lace-Ups", + "Suede Gray Lace-Ups", + "Suede Marine Lace-Ups", + "Suede Nation Lace-Ups", + "B-ball Headband", + "Cycling Cap", + "Golf Visor", + "Squash Headband", + "Swim Goggles", + "B-ball Jersey (Away)", + "B-ball Jersey (Home)", + "Cycling Shirt", + "Dakro Golden Tee", + "Dakro Nana Tee", + "Inkopolis Squaps Jersey", + "Navy Deca Logo Tee", + "Retro Gamer Jersey", + "School Jersey", + "Urchins Jersey", + "White Deca Logo Tee", + "Zink Layered LS", + "Zink LS", + "Black Dakroniks", + "Black Seahorses", + "Blue Laceless Dakroniks", + "Chocolate Dakroniks", + "Gold Hi-Horses", + "Mint Dakroniks", + "Purple Hi-Horses", + "Red Hi-Horses", + "White Laceless Dakroniks", + "White Seahorses", + "Yellow Seahorses", + "Zombie Hi-Horses", ] module.exports = gear diff --git a/utils/validators.js b/utils/validators.js index fffe9ec46..cbe1f709a 100644 --- a/utils/validators.js +++ b/utils/validators.js @@ -1,16 +1,13 @@ const { UserInputError } = require("apollo-server-express") const DetailedTournament = require("../mongoose-models/detailedtournament") +const weapons = require("../utils/weapons") +const gear = require("../utils/gear") +const stages = require("../utils/maps") function isNum(maybeNumber) { return /^\d+$/.test(maybeNumber) } -/*name: String! - bracket_url: String! - date: String! - top_3_team_names: [String!]! - top_3_discord_ids: [[String!]!]!*/ - async function validateDetailedTournamentInput(input) { const existingTournament = await DetailedTournament.find({ name: input.name }) @@ -18,6 +15,8 @@ async function validateDetailedTournamentInput(input) { throw new UserInputError("Tournament with that name already exists") } + //date not validated + if (input.top_3_team_names.length !== 3) { throw new UserInputError("Length of top_3_team_names was not 3") } @@ -39,3 +38,95 @@ async function validateDetailedTournamentInput(input) { }) }) } + +async function validateDetailedMapInput(input) { + if (!stages.includes(input.stage)) { + throw new UserInputError(`Invalid stage name: ${input.stage}`) + } + + if (!["SZ", "TC", "RM", "CB", "TW"].includes(input.mode)) { + throw new UserInputError(`Invalid mode name: ${input.mode}`) + } + + if (input.duration < 0 || input.duration > 500) { + throw new UserInputError(`Invalid duration: ${input.duration}`) + } + + if (input.winners.score <= input.losers.score) { + throw new UserInputError( + "Losing team has greater or equal score as the winner team" + ) + } + + input.winners.players.forEach(player => validateDetailedPlayerInput(player)) + input.losers.players.forEach(player => validateDetailedPlayerInput(player)) +} + +/*input DetailedPlayerInput { + discord_id: String! + weapon: String! + main_abilities: [Ability!]! + sub_abilities: [Ability]! + kills: Int! + assists: Int! + deaths: Int! + specials: Int! + paint: Int! + gear: [String]! +}*/ + +async function validateDetailedPlayerInput(input) { + if (!isNum(input.discord_id)) { + throw new UserInputError(`Invalid Discord ID: ${input.discord_id}`) + } + + if (!weapons.includes(input.weapon)) { + throw new UserInputError(`Invalid weapon: ${input.weapon}`) + } + + if (input.main_abilities.length !== 3) { + throw new UserInputError( + `Invalid main abilities length: ${input.main_abilities.length}` + ) + } + + if (input.sub_abilities.length !== 9) { + throw new UserInputError( + `Invalid main abilities length: ${input.sub_abilities.length}` + ) + } + + if (input.kills < 0 || input.kills > 50) { + throw new UserInputError(`Invalid kill count: ${input.kills}`) + } + + if (input.assists < 0 || input.assists > 50) { + throw new UserInputError(`Invalid assist count: ${input.assists}`) + } + + if (input.deaths < 0 || input.deaths > 50) { + throw new UserInputError(`Invalid death count: ${input.deaths}`) + } + + if (input.specials < 0 || input.specials > 50) { + throw new UserInputError(`Invalid special count: ${input.specials}`) + } + + if (input.paint < 0 || input.paint > 5000) { + throw new UserInputError(`Invalid paint count: ${input.paint}`) + } + + if (input.gear.length !== 3) { + throw new UserInputError(`Invalid gear length: ${input.gear.length}`) + } + + input.gear.forEach(gearPiece => { + if (!gear.includes(gearPiece)) { + throw new UserInputError(`Invalid gear: ${gearPiece}`) + } + }) +} + +module.exports = { + validateDetailedTournamentInput, +}