# -*- coding: utf-8 -*-
import csv, re

def slugify(s):
    s = s.lower()
    s = re.sub(r'[^a-z0-9]+', '-', s)
    return s.strip('-')

# (name, category, browser_domain_or_None)
GAMES = [
("PUBG Mobile","Battle Royale",None),
("Battlegrounds Mobile India (BGMI)","Battle Royale",None),
("Garena Free Fire Max","Battle Royale",None),
("Fortnite","Battle Royale",None),
("Call of Duty Mobile","Shooter",None),
("Apex Legends Mobile","Battle Royale",None),
("Rules of Survival","Battle Royale",None),
("Zombs Royale","Battle Royale","zombsroyale.io"),
("Surviv.io","Battle Royale","surviv.io"),
("Valorant","Shooter",None),
("Counter-Strike 2","Shooter",None),
("Overwatch 2","Shooter",None),
("Krunker.io","Shooter","krunker.io"),
("1v1.lol","Shooter","1v1.lol"),
("Shell Shockers","Shooter","shellshock.io"),
("Venge.io","Shooter","venge.io"),
("Bloxd.io","Shooter","bloxd.io"),
("Minecraft","Sandbox",None),
("Roblox","Sandbox",None),
("Terraria","Sandbox",None),
("Stardew Valley","Simulation",None),
("Among Us","Casual",None),
("Fall Guys","Casual",None),
("Brawl Stars","Strategy",None),
("Clash of Clans","Strategy",None),
("Clash Royale","Strategy",None),
("Boom Beach","Strategy",None),
("Rise of Kingdoms","Strategy",None),
("Lords Mobile","Strategy",None),
("State of Survival","Strategy",None),
("Age of Empires Mobile","Strategy",None),
("Chess.com","Board","chess.com"),
("Chess Rush","Board",None),
("Ludo King","Board",None),
("UNO","Card",None),
("Teen Patti Gold","Card",None),
("Rummy Circle","Card",None),
("8 Ball Pool","Sports",None),
("Carrom Pool","Sports",None),
("Basketball Stars","Sports",None),
("Basket Random","Sports","basketrandom.com"),
("Soccer Random","Sports","soccerrandom.com"),
("Head Ball 2","Sports",None),
("Score Hero","Sports",None),
("Dream League Soccer","Sports",None),
("EA Sports FC Mobile","Sports",None),
("eFootball","Sports",None),
("NBA 2K Mobile","Sports",None),
("Retro Bowl","Sports",None),
("Real Cricket 24","Sports",None),
("WCC3 - World Cricket Championship","Sports",None),
("Cricket League","Sports",None),
("Asphalt 9 Legends","Racing",None),
("Real Racing 3","Racing",None),
("Need for Speed No Limits","Racing",None),
("Hill Climb Racing 2","Racing",None),
("Subway Princess Runner","Racing",None),
("Traffic Rider","Racing",None),
("Bike Race","Racing",None),
("Extreme Car Driving Simulator","Racing",None),
("Car Parking Multiplayer","Racing",None),
("Moto X3M","Racing","moto-x3m.io"),
("Slither.io","IO Game","slither.io"),
("Agar.io","IO Game","agar.io"),
("Paper.io 2","IO Game","paper-io.com"),
("Wormate.io","IO Game","wormate.io"),
("Diep.io","IO Game","diep.io"),
("Smash Karts","IO Game","smashkarts.io"),
("Hole.io","IO Game","hole-io.com"),
("Candy Crush Saga","Puzzle",None),
("Candy Crush Soda Saga","Puzzle",None),
("Gardenscapes","Puzzle",None),
("Homescapes","Puzzle",None),
("Toon Blast","Puzzle",None),
("Toy Blast","Puzzle",None),
("2048","Puzzle","play2048.co"),
("Wordle","Puzzle","nytimes.com/games/wordle"),
("Sudoku.com","Puzzle","sudoku.com"),
("Bubble Shooter","Puzzle","bubbleshooter.net"),
("Cut the Rope","Puzzle",None),
("Angry Birds 2","Puzzle",None),
("Plants vs Zombies 2","Strategy",None),
("Geometry Dash","Arcade",None),
("Piano Tiles 2","Arcade",None),
("Temple Run 2","Arcade",None),
("Subway Surfers","Arcade",None),
("Solitaire.com","Card","solitaire.com"),
("Spider Solitaire","Card",None),
("Words With Friends 2","Word",None),
("Scrabble GO","Word",None),
("Word Cookies","Word",None),
("Trivia Crack","Trivia",None),
("QuizUp","Trivia",None),
("Coin Master","Casual",None),
("Monopoly GO","Board",None),
("Board Kings","Board",None),
("Draw Something","Casual",None),
("Township","Simulation",None),
("Hay Day","Simulation",None),
("Farmville 3","Simulation",None),
("The Sims Mobile","Simulation",None),
("Bus Simulator Indonesia","Simulation",None),
("Truck Simulator Ultimate","Simulation",None),
("Flight Pilot Simulator 3D","Simulation",None),
("Genshin Impact","RPG",None),
("Honkai Star Rail","RPG",None),
("Wuthering Waves","RPG",None),
("Tower of Fantasy","RPG",None),
("Summoners War","RPG",None),
("Raid Shadow Legends","RPG",None),
("AFK Arena","RPG",None),
("Idle Heroes","RPG",None),
("Cookie Run Kingdom","RPG",None),
("Mobile Legends Bang Bang","MOBA",None),
("Arena of Valor","MOBA",None),
("League of Legends","MOBA",None),
("League of Legends Wild Rift","MOBA",None),
("Dota 2","MOBA",None),
("Pokemon Unite","MOBA",None),
("Marvel Snap","Card",None),
("Clash Mini","Strategy",None),
("Shadow Fight 3","Fighting",None),
("Mortal Kombat Mobile","Fighting",None),
("Injustice 2","Fighting",None),
("Marvel Contest of Champions","Fighting",None),
("DC Legends","Fighting",None),
("Brawlhalla","Fighting",None),
("Rocket League Sideswipe","Sports",None),
("Pokemon Go","Adventure",None),
("Sky Children of the Light","Adventure",None),
("Adopt Me (Roblox)","Adventure",None),
("Blox Fruits (Roblox)","Adventure",None),
("Brookhaven RP (Roblox)","Adventure",None),
("Poppy Playtime","Horror",None),
("Five Nights at Freddy's","Horror",None),
("Slope","Arcade","slope-game.io"),
("Basket Random 2","Sports",None),
("Stumble Guys","Casual",None),
("Garena Speed Drifters","Racing",None),
("Mini Militia","Shooter",None),
("Into the Dead 2","Shooter",None),
("Dead Trigger 2","Shooter",None),
("Battle Prime","Shooter",None),
("Standoff 2","Shooter",None),
("Critical Ops","Shooter",None),
("Modern Combat 5","Shooter",None),
("World War Heroes","Shooter",None),
("Guns of Boom","Shooter",None),
("Bullet Force","Shooter","bulletforce.io"),
("Forge of Empires","Strategy",None),
("Game of Thrones Conquest","Strategy",None),
("Total Battle","Strategy",None),
("Top War","Strategy",None),
("Puzzles and Survival","Strategy",None),
("Whiteout Survival","Strategy",None),
("Last War Survival","Strategy",None),
("Rise of Empires","Strategy",None),
("Empires and Puzzles","Strategy",None),
("Merge Dragons","Puzzle",None),
("Merge Mansion","Puzzle",None),
("Fishdom","Puzzle",None),
("June's Journey","Puzzle",None),
("Match Masters","Puzzle",None),
("Royal Match","Puzzle",None),
("Project Makeover","Puzzle",None),
("Wordscapes","Word",None),
("4 Pics 1 Word","Word",None),
("Crossword Jam","Word",None),
("Sudoku Classic","Puzzle",None),
("Solitaire Grand Harvest","Card",None),
("Big Fish Casino","Casino",None),
("Zynga Poker","Card",None),
("WSOP Poker","Card",None),
("Teen Patti Master","Card",None),
("Ludo Club","Board",None),
("Ludo Star","Board",None),
("Carrom Master","Sports",None),
("Snake.io","IO Game","snake.io"),
("Battledudes.io","IO Game","battledudes.io"),
("Krunker Strike","Shooter",None),
("Warbrokers.io","Shooter","warbrokers.io"),
("Def Guard.io","Shooter",None),
("Deadshot.io","Shooter","deadshot.io"),
("Tanksgame","IO Game","diep.io"),
("Wormax.io","IO Game","wormax.io"),
("Little Big Snake","IO Game","littlebigsnake.com"),
("Starblast.io","IO Game","starblast.io"),
("Krew.io","IO Game","krew.io"),
("Skribbl.io","Casual","skribbl.io"),
("Gartic Phone","Casual","garticphone.com"),
("Among Us Online","Casual",None),
("Basket Champs","Sports","basketballstars.io"),
("Football Legends","Sports","footballlegends.io"),
("Soccer Skills World Cup","Sports",None),
("Volleyball Challenge","Sports",None),
("Table Tennis World Tour","Sports",None),
("Real Boxing 2","Sports",None),
("WWE Mayhem","Sports",None),
("WWE SuperCard","Sports",None),
("MLB Tap Sports Baseball","Sports",None),
("NFL Clash","Sports",None),
("Golf Rival","Sports",None),
("Golf Battle","Sports",None),
("Mini Golf King","Sports",None),
("Bowling King","Sports",None),
("Archery King","Sports",None),
("8 Ball Live","Sports",None),
("Snooker Live Pro","Sports",None),
("Pool Payday","Sports",None),
("Extreme Car Driving 2","Racing",None),
("Drift Max Pro","Racing",None),
("CarX Drift Racing 2","Racing",None),
("Real Moto 2","Racing",None),
("Trial Xtreme 4","Racing",None),
("Beach Buggy Racing 2","Racing",None),
("Mario Kart Tour","Racing",None),
("F1 Mobile Racing","Racing",None),
("Rush Rally 3","Racing",None),
("City Racing 3D","Racing",None),
("Zombie Catchers","Casual",None),
("Toca Life World","Casual",None),
("Pou","Casual",None),
("My Talking Tom Friends","Casual",None),
("Talking Angela","Casual",None),
("Subway Surfers World Tour","Arcade",None),
("Temple Run Oz","Arcade",None),
("Jetpack Joyride 2","Arcade",None),
("Fruit Ninja 2","Arcade",None),
("Crossy Road","Arcade",None),
("Flappy Bird Remake","Arcade",None),
("Doodle Jump","Arcade",None),
("Helix Jump","Arcade",None),
("Color Switch","Arcade",None),
("Stack Ball","Arcade",None),
("Tiles Hop EDM Rush","Arcade",None),
("Sky Dancer Run","Arcade",None),
("Run Race 3D","Arcade",None),
("Kick the Buddy","Casual",None),
("Human Fall Flat","Casual",None),
("Garena Contra Returns","Shooter",None),
("Cover Fire","Shooter",None),
("Sniper 3D Assassin","Shooter",None),
("Sniper Strike","Shooter",None),
("Zombie Frontier 4","Shooter",None),
("Left to Survive","Shooter",None),
("Last Day on Earth Survival","Survival",None),
("DayZ Mobile","Survival",None),
("Grim Soul Dark Survival","Survival",None),
("Frostborn Survival","Survival",None),
("Rules of Survival PC","Battle Royale",None),
("Free Fire Advance Server","Battle Royale",None),
("Free Fire OB Update","Battle Royale",None),
("New State Mobile","Battle Royale",None),
("Metal Slug Awakening","Arcade",None),
("Contra Anniversary Collection","Arcade",None),
("Mortal Kombat 1 Mobile","Fighting",None),
("Tekken Mobile","Fighting",None),
("Street Fighter Duel","Fighting",None),
("King of Fighters ALLSTAR","Fighting",None),
("Naruto x Boruto Ninja Voltage","RPG",None),
("Dragon Ball Legends","RPG",None),
("One Piece Treasure Cruise","RPG",None),
("Bleach Brave Souls","RPG",None),
("Fate Grand Order","RPG",None),
("Genshin Impact TCG","Card",None),
("Marvel Future Fight","RPG",None),
("Star Wars Galaxy of Heroes","RPG",None),
("Watcher of Realms","RPG",None),
("Solo Leveling Arise","RPG",None),
("Ni no Kuni Cross Worlds","RPG",None),
("Blade Idle","RPG",None),
("Idle Slayer","RPG",None),
("Tap Titans 2","RPG",None),
("Cookie Clicker","Idle","orteil.dashnet.org/cookieclicker"),
("Adventure Capitalist","Idle",None),
("Egg Inc","Idle",None),
("Idle Miner Tycoon","Idle",None),
("Hustle Castle","Simulation",None),
("Design Home","Simulation",None),
("Sim City BuildIt","Simulation",None),
("RollerCoaster Tycoon Touch","Simulation",None),
("Two Point Hospital","Simulation",None),
("Football Manager Mobile","Sports",None),
("Top Eleven","Sports",None),
("PES Club Manager","Sports",None),
]

CATEGORY_TEXT = {
"Battle Royale": ("drop into a shrinking map and fight to be the last one standing", "battle royale"),
"Shooter": ("aim, shoot, and outplay opponents in fast paced combat", "shooter"),
"Sandbox": ("build, explore, and create in an open sandbox world", "sandbox"),
"Simulation": ("manage, build, and grow a virtual world at your own pace", "simulation"),
"Casual": ("jump in for quick, easy to learn fun anytime, anywhere", "casual"),
"Strategy": ("build a base, train troops, and outsmart rivals", "strategy"),
"Board": ("roll the dice and outwit friends in a classic board game", "board"),
"Card": ("bluff, bet, and out-strategize opponents card by card", "card"),
"Sports": ("compete in fast, arcade-style sports action", "sports"),
"Racing": ("floor the pedal and race for the finish line", "racing"),
"IO Game": ("jump into instant browser matches against players worldwide", "io"),
"Puzzle": ("match, solve, and clear levels in a relaxing puzzle challenge", "puzzle"),
"Arcade": ("run, jump, and dodge through addictive arcade action", "arcade"),
"Word": ("test your vocabulary in a fun word challenge", "word"),
"Trivia": ("answer fast and prove your knowledge against others", "trivia"),
"RPG": ("collect heroes, level up, and battle through an epic story", "RPG"),
"MOBA": ("team up and battle in strategic 5v5 lane combat", "MOBA"),
"Fighting": ("pick a fighter and battle head to head", "fighting"),
"Adventure": ("explore an open world full of quests and surprises", "adventure"),
"Horror": ("survive a spine chilling horror experience", "horror"),
"Survival": ("scavenge, craft, and survive as long as you can", "survival"),
"Idle": ("earn rewards automatically and level up even while away", "idle"),
"Casino": ("spin, bet, and try your luck in casino style games", "casino"),
}

rows = []
for name, cat, domain in GAMES:
    slug = slugify(name)
    action, genre = CATEGORY_TEXT.get(cat, ("play a fun online game", "online"))
    desc = f"{name} is a popular {genre} game where players {action}. Play {name} online for free in your browser or install the official app to jump into the action anytime, anywhere."
    play_url = f"https://{domain}" if domain else ""
    gplay_url = f"https://play.google.com/store/search?q={name.replace(' ','+')}&c=apps"
    appstore_url = f"https://apps.apple.com/search?term={name.replace(' ','+')}"
    rows.append([slug, name, cat, desc, play_url, gplay_url, appstore_url])

with open("games.csv","w",newline="",encoding="utf-8") as f:
    w = csv.writer(f)
    w.writerow(["slug","name","category","description","play_url","gplay_url","appstore_url"])
    w.writerows(rows)

print(f"Wrote {len(rows)} games")
