From 4b9a5c83e699a8b258e3de37426741bde39af721 Mon Sep 17 00:00:00 2001 From: Darren VanBuren Date: Tue, 30 Sep 2014 22:24:08 -0700 Subject: [PATCH] Add episode names, split the constants out into a separate data file. --- stargaterando-data.rb | 398 ++++++++++++++++++++++++++++++++++++++++++ stargaterando.rb | 17 +- 2 files changed, 406 insertions(+), 9 deletions(-) create mode 100644 stargaterando-data.rb diff --git a/stargaterando-data.rb b/stargaterando-data.rb new file mode 100644 index 0000000..1f3c4fe --- /dev/null +++ b/stargaterando-data.rb @@ -0,0 +1,398 @@ +# Holds all our data. We're in another file to make things cleaner. +module StargateRando::Data + SERIES_SHORT_NAMES = ['SG-1', 'SGA', 'SGU'] + SERIES_NAMES = { 'SG-1' => 'Stargate SG-1', 'SGA' => 'Stargate Atlantis', + 'SGU' => 'Stargate Universe'} + SEASONS_PER_SERIES = { 'SG-1' => 10, 'SGA' => 5, 'SGU' => 2} + + # Begin a horrible crime against humanity. Let's try to make it reasonable though. + EPISODES = { + # SG-1 Season 1 (21 episodes) + 'SG-1|1x1' => 'Children of the Gods', + 'SG-1|1x2' => 'The Enemy Within', + 'SG-1|1x3' => 'Emancipation', + 'SG-1|1x4' => 'The Broca Divide', + 'SG-1|1x5' => 'The First Commandment', + 'SG-1|1x6' => 'Cold Lazarus', + 'SG-1|1x7' => 'The Nox', + 'SG-1|1x8' => 'Brief Candle', + 'SG-1|1x9' => 'Thor\'s Hammer', + 'SG-1|1x10' => 'The Torment of Tantalus', + 'SG-1|1x11' => 'Bloodlines', + 'SG-1|1x12' => 'Fire and Water', + 'SG-1|1x13' => 'Hathor', + 'SG-1|1x14' => 'Singularity', + 'SG-1|1x15' => 'Cor-Ai', + 'SG-1|1x16' => 'Enigma', + 'SG-1|1x17' => 'Solitudes', + 'SG-1|1x18' => 'Tin Man', + 'SG-1|1x19' => 'There But for the Grace of God', + 'SG-1|1x20' => 'Politics', + 'SG-1|1x21' => 'Within the Serpent\'s Grasp', + + # SG-1 Season 2 (22 episodes) + 'SG-1|2x1' => 'The Serpent\'s Lair', + 'SG-1|2x2' => 'In the Line of Duty', + 'SG-1|2x3' => 'Prisoners', + 'SG-1|2x4' => 'The Gamekeeper', + 'SG-1|2x5' => 'Need', + 'SG-1|2x6' => 'Thor\'s Chariot', + 'SG-1|2x7' => 'Message in a Bottle', + 'SG-1|2x8' => 'Family', + 'SG-1|2x9' => 'Secrets', + 'SG-1|2x10' => 'Bane', + 'SG-1|2x11' => 'The Tok\'ra (Part 1)', + 'SG-1|2x12' => 'The Tok\'ra (Part 2)', + 'SG-1|2x13' => 'Spirits', + 'SG-1|2x14' => 'Touchstone', + 'SG-1|2x15' => 'The Fifth Race', + 'SG-1|2x16' => 'A Matter of Time', + 'SG-1|2x17' => 'Holiday', + 'SG-1|2x18' => 'Serpent\'s Song', + 'SG-1|2x19' => 'One False Step', + 'SG-1|2x20' => 'Show and Tell', + 'SG-1|2x21' => '1969', + 'SG-1|2x22' => 'Out of Mind', + + # SG-1 Season 3 (22 episodes) + 'SG-1|3x1' => 'Into the Fire', + 'SG-1|3x2' => 'Seth', + 'SG-1|3x3' => 'Fair Game', + 'SG-1|3x4' => 'Legacy', + 'SG-1|3x5' => 'Lurning Curve', + 'SG-1|3x6' => 'Point of View', + 'SG-1|3x7' => 'Deadman Switch', + 'SG-1|3x8' => 'Demons', + 'SG-1|3x9' => 'Rules of Engagement', + 'SG-1|3x10' => 'Forever in a Day', + 'SG-1|3x11' => 'Past and Present', + 'SG-1|3x12' => 'Jolinar\'s Memories', + 'SG-1|3x13' => 'The Devil You Know', + 'SG-1|3x14' => 'Foothold', + 'SG-1|3x15' => 'Pretense', + 'SG-1|3x16' => 'Urgo', + 'SG-1|3x17' => 'A Hundred Days', + 'SG-1|3x18' => 'Shades of Grey', + 'SG-1|3x19' => 'New Ground', + 'SG-1|3x20' => 'Maternal Instinct', + 'SG-1|3x21' => 'Crystal Skull', + 'SG-1|3x22' => 'Nemesis', + + # SG-1 Season 4 (22 episodes) + 'SG-1|4x1' => 'Small Victories', + 'SG-1|4x2' => 'The Other Side', + 'SG-1|4x3' => 'Upgrades', + 'SG-1|4x4' => 'Crossroads', + 'SG-1|4x5' => 'Divide and Conquer', + 'SG-1|4x6' => 'Window of Opportunity', + 'SG-1|4x7' => 'Watergate', + 'SG-1|4x8' => 'The First Ones', + 'SG-1|4x9' => 'Scorched Earth', + 'SG-1|4x10' => 'Beneath the Surface', + 'SG-1|4x11' => 'Point of No Return', + 'SG-1|4x12' => 'Tangent', + 'SG-1|4x13' => 'The Curse', + 'SG-1|4x14' => 'The Serpent\'s Venom', + 'SG-1|4x15' => 'Chain Reaction', + 'SG-1|4x16' => '2010', + 'SG-1|4x17' => 'Absolute Power', + 'SG-1|4x18' => 'The Light', + 'SG-1|4x19' => 'Prodigy', + 'SG-1|4x20' => 'Entity', + 'SG-1|4x21' => 'Double Jeopardy', + 'SG-1|4x22' => 'Exodus', + + # SG-1 Season 5 (22 episodes) + 'SG-1|5x1' => 'Enemies', + 'SG-1|5x2' => 'Threshold', + 'SG-1|5x3' => 'Ascension', + 'SG-1|5x4' => 'The Fifth Man', + 'SG-1|5x5' => 'Red Sky', + 'SG-1|5x6' => 'Rite of Passage', + 'SG-1|5x7' => 'Beast of Burden', + 'SG-1|5x8' => 'The Tomb', + 'SG-1|5x9' => 'Between Two Fires', + 'SG-1|5x10' => '2001', + 'SG-1|5x11' => 'Desperate Measures', + 'SG-1|5x12' => 'Wormhole X-treme!', + 'SG-1|5x13' => 'Proving Ground', + 'SG-1|5x14' => '48 Hours', + 'SG-1|5x15' => 'Summit', + 'SG-1|5x16' => 'Last Stand', + 'SG-1|5x17' => 'Fail Safe', + 'SG-1|5x18' => 'The Warrior', + 'SG-1|5x19' => 'Menace', + 'SG-1|5x20' => 'Sentinel', + 'SG-1|5x21' => 'Meridian', + 'SG-2|5x22' => 'Revelations', + + # SG-1 Season 6 (22 episodes) + 'SG-1|6x1' => 'Redemption (Part 1)', + 'SG-1|6x2' => 'Redemption (Part 2)', + 'SG-1|6x3' => 'Descent', + 'SG-1|6x4' => 'Frozen', + 'SG-1|6x5' => 'Nightwalkers', + 'SG-1|6x6' => 'Abyss', + 'SG-1|6x7' => 'Shadow Play', + 'SG-1|6x8' => 'The Other Guys', + 'SG-1|6x9' => 'Allegiance', + 'SG-1|6x10' => 'Cure', + 'SG-1|6x11' => 'Prometheus', + 'SG-1|6x12' => 'Unnatural Selection', + 'SG-1|6x13' => 'Sight Unseen', + 'SG-1|6x14' => 'Smoke and Mirrors', + 'SG-1|6x15' => 'Paradise Lost', + 'SG-1|6x16' => 'Metamorphosis', + 'SG-1|6x17' => 'Disclosure', + 'SG-1|6x18' => 'Forsaken', + 'SG-1|6x19' => 'The Changeling', + 'SG-1|6x20' => 'Memento', + 'SG-1|6x21' => 'Propehcy', + 'SG-1|6x22' => 'Full Circle', + + # SG-1 Season 7 (22 episodes) + 'SG-1|7x1' => 'Fallen', + 'SG-1|7x2' => 'Homecoming', + 'SG-1|7x3' => 'Fragile Balance', + 'SG-1|7x4' => 'Orpheus', + 'SG-1|7x5' => 'Revisions', + 'SG-1|7x6' => 'Lifeboat', + 'SG-1|7x7' => 'Enemy Mine', + 'SG-1|7x8' => 'Space Race', + 'SG-1|7x9' => 'Avenger 2.0', + 'SG-1|7x10' => 'Birthright', + 'SG-1|7x11' => 'Evolution (Part 1)', + 'SG-1|7x12' => 'Evolution (Part 2)', + 'SG-1|7x13' => 'Grace', + 'SG-1|7x14' => 'Fallout', + 'SG-1|7x15' => 'Chimera', + 'SG-1|7x16' => 'Death Knell', + 'SG-1|7x17' => 'Heroes (Part 1)', + 'SG-1|7x18' => 'Heroes (Part 2)', + 'SG-1|7x19' => 'Resurrection', + 'SG-1|7x20' => 'Inauguration', + 'SG-1|7x21' => 'Lost City (Part 1)', + 'SG-1|7x22' => 'Lost City (Part 2)', + + # SG-1 Season 8 (20 episodes) + 'SG-1|8x1' => 'New Order (Part 1)', + 'SG-1|8x2' => 'New Order (Part 2)', + 'SG-1|8x3' => 'Lockdown', + 'SG-1|8x4' => 'Zero Hour', + 'SG-1|8x5' => 'Icon', + 'SG-1|8x6' => 'Avatar', + 'SG-1|8x7' => 'Affinity', + 'SG-1|8x8' => 'Covenant', + 'SG-1|8x9' => 'Sacrifices', + 'SG-1|8x10' => 'Endgame', + 'SG-1|8x11' => 'Gemini', + 'SG-1|8x12' => 'Prometheus Unbound', + 'SG-1|8x13' => 'It\'s Good to be King', + 'SG-1|8x14' => 'Full Alert', + 'SG-1|8x15' => 'Citizen Joe', + 'SG-1|8x16' => 'Reckoning (Part 1)', + 'SG-1|8x17' => 'Reckoning (Part 2)', + 'SG-1|8x18' => 'Threads', + 'SG-1|8x19' => 'Moebius (Part 1)', + 'SG-1|8x20' => 'Moebius (Part 2)', + + # SG-1 Season 9 (20 episodes) + 'SG-1|9x1' => 'Avalon (Part 1)', + 'SG-1|9x2' => 'Avalon (Part 2)', + 'SG-1|9x3' => 'Origin', + 'SG-1|9x4' => 'The Ties That Bind', + 'SG-1|9x5' => 'The Powers That Be', + 'SG-1|9x6' => 'Beachhead', + 'SG-1|9x7' => 'Ex Deus Machina', + 'SG-1|9x8' => 'Babylon', + 'SG-1|9x9' => 'Prototype', + 'SG-1|9x10' => 'The Fourth Horseman (Part 1)', + 'SG-1|9x11' => 'The Fourth Horseman (Part 2)', + 'SG-1|9x12' => 'Collateral Damage', + 'SG-1|9x13' => 'Ripple Effect', + 'SG-1|9x14' => 'Stronghold', + 'SG-1|9x15' => 'Ethon', + 'SG-1|9x16' => 'Off the Grid', + 'SG-1|9x17' => 'The Scourge', + 'SG-1|9x18' => 'Arthur\'s Mantle', + 'SG-1|9x19' => 'Crusade', + 'SG-1|9x20' => 'Camelot', + + # SG-1 Season 10 (20 episodes) + 'SG-1|10x1' => 'Flesh and Blood', + 'SG-1|10x2' => 'Morpheus', + 'SG-1|10x3' => 'The Pegasus Project', + 'SG-1|10x4' => 'Insiders', + 'SG-1|10x5' => 'Uninvited', + 'SG-1|10x6' => '200', + 'SG-1|10x7' => 'Counterstrike', + 'SG-1|10x8' => 'Memento Mori', + 'SG-1|10x9' => 'Company of Thieves', + 'SG-1|10x10' => 'The Quest (Part 1)', + 'SG-1|10x11' => 'The Quest (Part 2)', + 'SG-1|10x12' => 'Line in the Sand', + 'SG-1|10x13' => 'The Road Not Taken', + 'SG-1|10x14' => 'The Shround', + 'SG-1|10x15' => 'Bounty', + 'SG-1|10x16' => 'Bad Guys', + 'SG-1|10x17' => 'Talion', + 'SG-1|10x18' => 'Family Ties', + 'SG-1|10x19' => 'Dominion', + 'SG-1|10x20' => 'Unending', + + # SGA Season 1 (20 episodes) + 'SGA|1x1' => 'Rising (Part 1)', + 'SGA|1x2' => 'Rising (Part 2)', + 'SGA|1x3' => 'Hide and Seek', + 'SGA|1x4' => 'Thirty Eight Minutes', + 'SGA|1x5' => 'Suspicion', + 'SGA|1x6' => 'Childhood\'s End', + 'SGA|1x7' => 'Poisoning the Well', + 'SGA|1x8' => 'Underground', + 'SGA|1x9' => 'Home', + 'SGA|1x10' => 'The Storm', + 'SGA|1x11' => 'The Eye', + 'SGA|1x12' => 'The Defiant One', + 'SGA|1x13' => 'Hot Zone', + 'SGA|1x14' => 'Sanctuary', + 'SGA|1x15' => 'Before I Sleep', + 'SGA|1x16' => 'The Brotherhood', + 'SGA|1x17' => 'Letters From Pegasus', + 'SGA|1x18' => 'The Gift', + 'SGA|1x19' => 'The Siege (Part 1)', + 'SGA|1x20' => 'The Siege (Part 2)', + + # SGA Season 2 (20 episodes) + 'SGA|2x1' => 'The Siege (Part 3)', + 'SGA|2x2' => 'The Intruder', + 'SGA|2x3' => 'Runner', + 'SGA|2x4' => 'Duet', + 'SGA|2x5' => 'Condemned', + 'SGA|2x6' => 'Trinity', + 'SGA|2x7' => 'Instinct', + 'SGA|2x8' => 'Conversion', + 'SGA|2x9' => 'Aurora', + 'SGA|2x10' => 'The Lost Boys', + 'SGA|2x11' => 'The Hive', + 'SGA|2x12' => 'Epiphany', + 'SGA|2x13' => 'Critical Mass', + 'SGA|2x14' => 'Grace Under Pressure', + 'SGA|2x15' => 'The Tower', + 'SGA|2x16' => 'The Long Goodbye', + 'SGA|2x17' => 'Coup D\'etat', + 'SGA|2x18' => 'Michael', + 'SGA|2x19' => 'Inferno', + 'SGA|2x20' => 'Allies', + + # SGA Season 3 (20 episodes) + 'SGA|3x1' => 'No Man\'s Land', + 'SGA|3x2' => 'Misbegotten', + 'SGA|3x3' => 'Irresistible', + 'SGA|3x4' => 'Sateda', + 'SGA|3x5' => 'Progeny', + 'SGA|3x6' => 'The Real World', + 'SGA|3x7' => 'Common Ground', + 'SGA|3x8' => 'McKay and Mrs. Miller', + 'SGA|3x9' => 'Phantoms', + 'SGA|3x10' => 'The Return (Part 1)', + 'SGA|3x11' => 'The Return (Part 2)', + 'SGA|3x12' => 'Echoes', + 'SGA|3x13' => 'Irresponsible', + 'SGA|3x14' => 'Tao of Rodney', + 'SGA|3x15' => 'The Game', + 'SGA|3x16' => 'The Ark', + 'SGA|3x17' => 'Sunday', + 'SGA|3x18' => 'Submersion', + 'SGA|3x19' => 'Vengeance', + 'SGA|3x20' => 'First Strike', + + # SGA Season 4 (20 episodes) + 'SGA|4x1' => 'Adrift', + 'SGA|4x2' => 'Lifeline', + 'SGA|4x3' => 'Reunion', + 'SGA|4x4' => 'Doppelganger', + 'SGA|4x5' => 'Travelers', + 'SGA|4x6' => 'Tabula Rasa', + 'SGA|4x7' => 'Missing', + 'SGA|4x8' => 'The Seer', + 'SGA|4x9' => 'Miller\'s Crossing', + 'SGA|4x10' => 'This Mortal Coil', + 'SGA|4x11' => 'Be All My Sins Remember\'d', + 'SGA|4x12' => 'Spoils of War', + 'SGA|4x13' => 'Quarantine', + 'SGA|4x14' => 'Harmony', + 'SGA|4x15' => 'Outcast', + 'SGA|4x16' => 'Trio', + 'SGA|4x17' => 'Midway', + 'SGA|4x18' => 'The Kindred (Part 1)', + 'SGA|4x19' => 'The Kindred (Part 2)', + 'SGA|4x20' => 'The Last Man', + + # SGA Season 5 (20 episodes) + 'SGA|5x1' => 'Search and Rescue', + 'SGA|5x2' => 'The Seed', + 'SGA|5x3' => 'Broken Ties', + 'SGA|5x4' => 'The Daedalus Variations', + 'SGA|5x5' => 'Ghost in the Machine', + 'SGA|5x6' => 'The Shrine', + 'SGA|5x7' => 'Whispers', + 'SGA|5x8' => 'The Queen', + 'SGA|5x9' => 'Tracker', + 'SGA|5x10' => 'First Contact', + 'SGA|5x11' => 'The Lost Tribe', + 'SGA|5x12' => 'Outsiders', + 'SGA|5x13' => 'Inquisition', + 'SGA|5x14' => 'The Prodigal', + 'SGA|5x15' => 'Remnants', + 'SGA|5x16' => 'Brain Storm', + 'SGA|5x17' => 'Infection', + 'SGA|5x18' => 'Identity', + 'SGA|5x19' => 'Vegas', + 'SGA|5x20' => 'Enemy at the Gate', + + # SGU Season 1 (20 episodes) + 'SGU|1x1' => 'Air (Part 1)', + 'SGU|1x2' => 'Air (Part 2)', + 'SGU|1x3' => 'Air (Part 3)', + 'SGU|1x4' => 'Darkness', + 'SGU|1x5' => 'Light', + 'SGU|1x6' => 'Water', + 'SGU|1x7' => 'Earth', + 'SGU|1x8' => 'Time', + 'SGU|1x9' => 'Life', + 'SGU|1x10' => 'Justice', + 'SGU|1x11' => 'Space', + 'SGU|1x12' => 'Divided', + 'SGU|1x13' => 'Faith', + 'SGU|1x14' => 'Human', + 'SGU|1x15' => 'Lost', + 'SGU|1x16' => 'Sabotage', + 'SGU|1x17' => 'Pain', + 'SGU|1x18' => 'Subversion', + 'SGU|1x19' => 'Incursion (Part 1)', + 'SGU|1x20' => 'Incursion (Part 2)', + + # SGU Season 2 (20 episodes) + 'SGU|2x1' => 'Intervention', + 'SGU|2x2' => 'Aftermath', + 'SGU|2x3' => 'Awakening', + 'SGU|2x4' => 'Pathogen', + 'SGU|2x5' => 'Cloverdale', + 'SGU|2x6' => 'Trial and Error', + 'SGU|2x7' => 'The Greater Good', + 'SGU|2x8' => 'Malice', + 'SGU|2x9' => 'Visitation', + 'SGU|2x10' => 'Resurgence', + 'SGU|2x11' => 'Deliverance', + 'SGU|2x12' => 'Twin Destinies', + 'SGU|2x13' => 'Alliances', + 'SGU|2x14' => 'Hope', + 'SGU|2x15' => 'Seizure', + 'SGU|2x16' => 'The Hunt', + 'SGU|2x17' => 'Common Descent', + 'SGU|2x18' => 'Epilogue', + 'SGU|2x19' => 'Blockade', + 'SGU|2x20' => 'Gauntlet' + } + # Our crimes against humanity have ended. Please forgive us. +end \ No newline at end of file diff --git a/stargaterando.rb b/stargaterando.rb index 6384da4..380d358 100644 --- a/stargaterando.rb +++ b/stargaterando.rb @@ -1,12 +1,10 @@ +require 'camping' + # Camping is a great small framework. Camping.goes :StargateRando -# This holds all our constant data. -module StargateRando::Data - SERIES_SHORT_NAMES = ['SG-1', 'SGA', 'SGU'] - SERIES_NAMES = { 'SG-1' => 'Stargate SG-1', 'SGA' => 'Stargate Atlantis', 'SGU' => 'Stargate Universe'} - SEASONS_PER_SERIES = { 'SG-1' => 10, 'SGA' => 5, 'SGU' => 2} -end +# Data was moved out to stargaterando-data.rb to keep this file clean +require './stargaterando-data' # This holds our (currently there's only one) controllers. module StargateRando::Controllers @@ -34,8 +32,8 @@ module StargateRando::Controllers chosen_episode = 1 + rand(num_episodes) - @episode_code = "#{chosen_season}x#{chosen_episode}" - @episode_and_season = "Season #{chosen_season}: Episode #{chosen_episode}" + @episode_and_season = "Season #{chosen_season} Episode #{chosen_episode}" + @episode_name = Data::EPISODES["#{chosen_series_id}|#{chosen_season}x#{chosen_episode}"] render :results end end @@ -57,7 +55,8 @@ module StargateRando::Views end def results - h1 "You should watch #{@series}: #{@episode_and_season}" + h1 "You should watch: " + h2 "#{@series}: #{@episode_and_season}: #{@episode_name}" button :onclick => "document.location.reload()", :id => "reload" do "Get a new episode" end