# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
#   cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
#   Mayor.create(:name => 'Daley', :city => cities.first)

require 'securerandom'

Game.create(
  singleton_guard: 0,
  live_round_id: nil,
  ready_round_id: nil,
  automated: false
)

User.create(
  username: 'admin',
  password: User.passhash(Rails.application.credentials.dig(Rails.env.to_sym, :default_admin_password)),
  role: :admin
)

# Add Team templates
(1..8).each do |i|
  Team.create(name: ('Team ' + i.to_s))
end

# Create blank puzzlesets for the 7 rounds
set1 = Puzzleset.create(name: 'Set 1')
set2 = Puzzleset.create(name: 'Set 2')
set3 = Puzzleset.create(name: 'Set 3')

# Create the rounds
round1 = Round.create(name: 'QuarterFinal1', puzzleset: set1)
round2 = Round.create(name: 'QuarterFinal2', puzzleset: set1)
round3 = Round.create(name: 'QuarterFinal3', puzzleset: set1)
round4 = Round.create(name: 'QuarterFinal4', puzzleset: set1)
round5 = Round.create(name: 'SemiFinal1', puzzleset: set2)
round6 = Round.create(name: 'SemiFinal2', puzzleset: set2)
round7 = Round.create(name: 'Final', puzzleset: set3)

Automation.instance.reset

# Seed Store Items
ItemGroup.create!([
                    { name: 'Slap',
                      description: 'Damage for the entire opposing team',
                      picture_location: 'slap.jpg',
                      discountable: true,
                      hack_item: false },

                    { name: 'Blindness',
                      description: 'Blind opposing team members',
                      picture_location: 'blindness.jpg',
                      discountable: true,
                      hack_item: false },

                    { name: 'Time Bomb',
                      description: 'Turn opposing team members into time bombs',
                      picture_location: 'timebomb.jpg',
                      discountable: false,
                      hack_item: false },

                    { name: 'Fire Bomb',
                      description: 'Turn opposing team members into fire bombs',
                      picture_location: 'firebomb.png',
                      discountable: false,
                      hack_item: false },

                    { name: 'Freeze Bomb',
                      description: 'Turn opposing team members into freeze bombs',
                      picture_location: 'freezebomb.jpg',
                      discountable: false,
                      hack_item: false },

                    { name: 'Freeze!',
                      description: 'Freeze opposing team members in their tracks',
                      picture_location: 'Freeze.png',
                      discountable: false,
                      hack_item: false },

                    { name: 'Critical',
                      description: 'Team members attacks are crits',
                      picture_location: 'crits.jpg',
                      discountable: true,
                      hack_item: false },

                    { name: 'Burn',
                      description: 'Burn opposing players',
                      picture_location: 'burn.jpg',
                      discountable: false,
                      hack_item: false },

                    { name: 'Mute',
                      description: 'Mute opposing team members',
                      picture_location: 'mute.jpg',
                      discountable: false,
                      hack_item: false },

                    { name: 'Hack Hint',
                      description: 'Need a Hint on a Puzzle?',
                      picture_location: 'hint.jpg',
                      discountable: false,
                      hack_item: true },

                    { name: 'Hack Capture Block',
                      description: 'Block the other team from submitting puzzles',
                      picture_location: 'statuses/status4.png',
                      discountable: false,
                      hack_item: true },

                    { name: 'Hack Effect Delay',
                      description: 'Delays any effects from occuring on the TF2 side',
                      picture_location: 'statuses/status1.jpg',
                      discountable: false,
                      hack_item: true },

                    { name: 'Hack Denial of Service',
                      description: 'Disables access to the store for the opposing team',
                      picture_location: 'denied2.jpg',
                      discountable: false,
                      hack_item: true },

                    { name: 'GameFck',
                      description: 'Swap a Hack Player of your choosing with a TF2 Player for 1 minute',
                      picture_location: 'swap.png',
                      discountable: false,
                      hack_item: true },

                    { name: 'Machine',
                      description: 'Embrace the Machine',
                      picture_location: 'makebot.png',
                      discountable: false,
                      hack_item: false },

                    { name: 'Disarm',
                      description: 'Remove unloaded ammo from enemy team members',
                      picture_location: 'disarm.png',
                      discountable: true,
                      hack_item: false },

                    { name: 'Drunk',
                      description: 'Buy your enemies a few drinks',
                      picture_location: 'drunk.png',
                      discountable: true,
                      hack_item: false }

                  ])

Item.create!([
               { name: 'Light Slap',
                 cost: 10,
                 description: 'Light Slap Damage (10-30 HP)',
                 discountable: true,
                 item_group_id: 1,
                 modifier: 20,
                 players: 6,
                 argument: 10,
                 starting_quantity: 9999,
                 friendly_text: 'Slap',
                 effect_iden: 'Slap',
                 is_buff: false },

               { name: 'Medium Slap',
                 cost: 20,
                 description: 'Medium Slap Damage (30-40 HP)',
                 discountable: true,
                 item_group_id: 1,
                 modifier: 10,
                 players: 6,
                 argument: 30,
                 starting_quantity: 9999,
                 friendly_text: 'Slap',
                 effect_iden: 'Slap',
                 is_buff: false },

               { name: 'Heavy Slap',
                 cost: 30,
                 description: 'Heavy Slap Damage (50-60 HP)',
                 discountable: true,
                 item_group_id: 1,
                 modifier: 10,
                 players: 6,
                 argument: 50,
                 starting_quantity: 9999,
                 friendly_text: 'Slap',
                 effect_iden: 'Slap',
                 is_buff: false },

               { name: 'Blindness - 1/10',
                 cost: 10,
                 description: 'Blind one opposing team member for 10 seconds',
                 discountable: true,
                 item_group_id: 2,
                 modifier: 0,
                 players: 1,
                 argument: 10,
                 starting_quantity: 9999,
                 friendly_text: 'Blindness',
                 effect_iden: 'Blind',
                 is_buff: false },

               { name: 'Blindness - 1/20',
                 cost: 20,
                 description: 'Blind one opposing team member for 20 seconds',
                 discountable: true,
                 item_group_id: 2,
                 modifier: 0,
                 players: 1,
                 argument: 20,
                 starting_quantity: 9999,
                 friendly_text: 'Blindness',
                 effect_iden: 'Blind',
                 is_buff: false },

               { name: 'Blindness - 6/10',
                 cost: 50,
                 description: 'Blind all opposing team members for 10 seconds',
                 discountable: true,
                 item_group_id: 2,
                 modifier: 0,
                 players: 6,
                 argument: 10,
                 starting_quantity: 9999,
                 friendly_text: 'Blindness',
                 effect_iden: 'Blind',
                 is_buff: false },

               { name: 'Blindness - 6/20',
                 cost: 100,
                 description: 'Blind all opposing team members for 20 seconds',
                 discountable: true,
                 item_group_id: 2,
                 modifier: 0,
                 players: 6,
                 argument: 20,
                 starting_quantity: 9999,
                 friendly_text: 'Blindness',
                 effect_iden: 'Blind',
                 is_buff: false },

               { name: 'Time Bomb - 1',
                 cost: 50,
                 description: 'Turn one opposing team member into a ticking time bomb',
                 discountable: true,
                 item_group_id: 3,
                 modifier: 0,
                 players: 1,
                 argument: 30,
                 starting_quantity: 9999,
                 friendly_text: 'Time Bomb',
                 effect_iden: 'Timebomb',
                 is_buff: false },

               { name: 'Time Bomb - 3',
                 cost: 100,
                 description: 'Turn half the opposing team into ticking time bombs',
                 discountable: true,
                 item_group_id: 3,
                 modifier: 0,
                 players: 3,
                 argument: 30,
                 starting_quantity: 9999,
                 friendly_text: 'Time Bomb',
                 effect_iden: 'Timebomb',
                 is_buff: false },

               { name: 'Fire Bomb - 1',
                 cost: 50,
                 description: 'Turn one opposing team member into a fire bomb',
                 discountable: true,
                 item_group_id: 4,
                 modifier: 0,
                 players: 1,
                 argument: 30,
                 starting_quantity: 9999,
                 friendly_text: 'Fire Bomb',
                 effect_iden: 'Firebomb',
                 is_buff: false },

               { name: 'Fire Bomb - 3',
                 cost: 100,
                 description: 'Turn half the opposing team into fire bombs',
                 discountable: true,
                 item_group_id: 4,
                 modifier: 0,
                 players: 3,
                 argument: 30,
                 starting_quantity: 9999,
                 friendly_text: 'Fire Bomb',
                 effect_iden: 'Firebomb',
                 is_buff: false },

               { name: 'Freeze Bomb - 1',
                 cost: 50,
                 description: 'Turn one opposing team member into a freeze bomb',
                 discountable: true,
                 item_group_id: 5,
                 modifier: 0,
                 players: 1,
                 argument: 30,
                 starting_quantity: 9999,
                 friendly_text: 'FreezeBomb',
                 effect_iden: 'FreezeBomb',
                 is_buff: true },

               { name: 'Freeze Bomb - 3',
                 cost: 100,
                 description: 'Turn half the opposing team into freeze bombs',
                 discountable: true,
                 item_group_id: 5,
                 modifier: 0,
                 players: 3,
                 argument: 30,
                 starting_quantity: 9999,
                 friendly_text: 'FreezeBomb',
                 effect_iden: 'FreezeBomb',
                 is_buff: true },

               { name: 'Freeze - 3',
                 cost: 50,
                 description: 'Freeze half the opposing team',
                 discountable: false,
                 item_group_id: 6,
                 modifier: 0,
                 players: 3,
                 argument: 15,
                 starting_quantity: 5,
                 friendly_text: 'Freeze',
                 effect_iden: 'Freeze',
                 is_buff: false },

               { name: 'Freeze - 6',
                 cost: 120,
                 description: 'Freeze all opposing players',
                 discountable: false,
                 item_group_id: 6,
                 modifier: 0,
                 players: 6,
                 argument: 15,
                 starting_quantity: 5,
                 friendly_text: 'Freeze',
                 effect_iden: 'Freeze',
                 is_buff: false },

               { name: 'Critical - 6/15',
                 cost: 75,
                 description: 'All team members attack are crits for 10 seconds',
                 discountable: true,
                 item_group_id: 7,
                 modifier: 0,
                 players: 6,
                 argument: 15,
                 starting_quantity: 9999,
                 friendly_text: 'Critical',
                 effect_iden: 'Criticals',
                 is_buff: true },

               { name: 'Critical - 6/30',
                 cost: 150,
                 description: 'All team members attack are crits for 20 seconds',
                 discountable: true,
                 item_group_id: 7,
                 modifier: 0,
                 players: 6,
                 argument: 30,
                 starting_quantity: 9999,
                 friendly_text: 'Critical',
                 effect_iden: 'Criticals',
                 is_buff: true },

               { name: 'Burn - 3',
                 cost: 60,
                 description: 'Burn half the opposing team for 20 seconds',
                 discountable: true,
                 item_group_id: 8,
                 modifier: 0,
                 players: 3,
                 argument: 20,
                 starting_quantity: 9999,
                 friendly_text: 'Burn',
                 effect_iden: 'Burn',
                 is_buff: false },
               { name: 'Burn - 6',
                 cost: 120,
                 description: 'Burn all opposing players for 20 seconds',
                 discountable: true,
                 item_group_id: 8,
                 modifier: 0,
                 players: 6,
                 argument: 20,
                 starting_quantity: 9999,
                 friendly_text: 'Burn',
                 effect_iden: 'Burn',
                 is_buff: false },
               { name: 'Single Hint',
                 cost: 15,
                 description: 'A single hint',
                 discountable: true,
                 item_group_id: 10,
                 modifier: 0,
                 players: 0,
                 argument: 1,
                 starting_quantity: 9999,
                 friendly_text: 'Small Hint',
                 effect_iden: 'hint_add',
                 is_buff: true },
               { name: 'Hint Value Pack',
                 cost: 65,
                 description: 'A 5-pack of hints',
                 discountable: true,
                 item_group_id: 10,
                 modifier: 0,
                 players: 0,
                 argument: 5,
                 starting_quantity: 9999,
                 friendly_text: 'Big Hint',
                 effect_iden: 'hint_add',
                 is_buff: true },

               { name: 'CapBlock',
                 cost: 100,
                 description: 'Block the other team from submitting puzzles for 60 seconds',
                 discountable: true,
                 item_group_id: 11,
                 modifier: 0,
                 players: 0,
                 argument: 0,
                 starting_quantity: 3,
                 friendly_text: 'Capture Block',
                 effect_iden: 'cap_block_add',
                 is_buff: false },

               { name: 'CapUnBlock',
                 cost: 75,
                 description: "Hey,
    if you've got the cash and little patience,
    why not?",
                 discountable: true,
                 item_group_id: 11,
                 modifier: 0,
                 players: 0,
                 argument: 0,
                 starting_quantity: 9999,
                 friendly_text: 'Capture Block Removal',
                 effect_iden: 'cap_block_del',
                 is_buff: true },

               { name: 'CapDelay',
                 cost: 100,
                 description: "Next effect to be sent to Fortress by the other team will be delayed by 30 seconds -- Note if team already has two delays in place,
    this will be a noop",
                 discountable: true,
                 item_group_id: 12,
                 modifier: 0,
                 players: 0,
                 argument: 0,
                 starting_quantity: 9999,
                 friendly_text: 'Effect Delay',
                 effect_iden: 'effect_delay_add',
                 is_buff: false },

               { name: 'CapUnDelay',
                 cost: 75,
                 description: "Hey,
    if you've got the cash and little patience,
    why not?",
                 discountable: true,
                 item_group_id: 12,
                 modifier: 0,
                 players: 0,
                 argument: 0,
                 starting_quantity: 9999,
                 friendly_text: 'Effect Delay Removal',
                 effect_iden: 'effect_delay_del',
                 is_buff: true },

               { name: 'Store DoS',
                 cost: 75,
                 description: 'The store will be down for the opposing team for 60 seconds',
                 discountable: false,
                 item_group_id: 13,
                 modifier: 0,
                 players: 0,
                 argument: 0,
                 starting_quantity: 3,
                 friendly_text: 'Denial of Service',
                 effect_iden: 'store_dos',
                 is_buff: false },

               { name: 'GameFck1',
                 cost: 200,
                 description: 'Swap 1 Hack Player of your choosing for 1 minute with a TF2 Player. Only one per customer',
                 discountable: false,
                 item_group_id: 14,
                 modifier: 0,
                 players: 0,
                 argument: 0,
                 starting_quantity: 1,
                 friendly_text: 'GameFck',
                 effect_iden: 'hack_event',
                 is_buff: false },

               { name: 'BotUp',
                 cost: 150,
                 description: "All of your team turns into bots with all of your health restored. No stacking,
    effect must wear out before purchasing again. NO REFUNDS!!!",
                 discountable: true,
                 item_group_id: 15,
                 modifier: 0,
                 players: 6,
                 argument: 60,
                 starting_quantity: 5,
                 friendly_text: 'Bot Up',
                 effect_iden: 'maketeamrobots',
                 is_buff: true },

               { name: 'Extra Player',
                 cost: 150,
                 description: "Add a Bot to your team to help out - Limit 1 at a time,
    NO REFUNDS!!!",
                 discountable: true,
                 item_group_id: 15,
                 modifier: 0,
                 players: 1,
                 argument: 120,
                 starting_quantity: 5,
                 friendly_text: 'Better Player',
                 effect_iden: 'spawnbot',
                 is_buff: true },

               { name: 'Disarm 1',
                 cost: 50,
                 description: 'Remove unloaded ammo from one enemy tf2 player',
                 discountable: true,
                 item_group_id: 16,
                 modifier: 0,
                 players: 1,
                 argument: 0,
                 starting_quantity: 10,
                 friendly_text: 'Remove Ammo',
                 effect_iden: 'empty_ammo',
                 is_buff: false },

               { name: 'Disarm 3',
                 cost: 100,
                 description: 'Remove unloaded ammo from three enemy tf2 players',
                 discountable: true,
                 item_group_id: 16,
                 modifier: 0,
                 players: 3,
                 argument: 0,
                 starting_quantity: 10,
                 friendly_text: 'Remove Ammo',
                 effect_iden: 'empty_ammo',
                 is_buff: false },

               { name: 'Disarm 6',
                 cost: 150,
                 description: 'Remove unloaded ammo from all enemy tf2 players',
                 discountable: true,
                 item_group_id: 16,
                 modifier: 0,
                 players: 6,
                 argument: 0,
                 starting_quantity: 10,
                 friendly_text: 'Remove Ammo',
                 effect_iden: 'empty_ammo',
                 is_buff: false },

               { name: 'Drunk 1/10',
                 cost: 10,
                 description: 'Make 1 opposing team member drunk for 10 seconds',
                 discountable: true,
                 item_group_id: 17,
                 modifier: 0,
                 players: 1,
                 argument: 10,
                 starting_quantity: 9999,
                 friendly_text: 'Drunkenness',
                 effect_iden: 'Drug',
                 is_buff: false },

               { name: 'Drunk 1/20',
                 cost: 20,
                 description: 'Make 1 opposing team member drunk for 20 seconds',
                 discountable: true,
                 item_group_id: 17,
                 modifier: 0,
                 players: 1,
                 argument: 20,
                 starting_quantity: 9999,
                 friendly_text: 'Drunkenness',
                 effect_iden: 'Drug',
                 is_buff: false },

               { name: 'Drunk 6/10',
                 cost: 50,
                 description: 'Make 6 opposing team members drunk for 10 seconds',
                 discountable: true,
                 item_group_id: 17,
                 modifier: 0,
                 players: 6,
                 argument: 10,
                 starting_quantity: 9999,
                 friendly_text: 'Drunkenness',
                 effect_iden: 'Drug',
                 is_buff: false },

               { name: 'Drunk 6/20',
                 cost: 100,
                 description: 'Make 6 opposing team members drunk for 20 seconds',
                 discountable: true,
                 item_group_id: 17,
                 modifier: 0,
                 players: 6,
                 argument: 20,
                 starting_quantity: 9999,
                 friendly_text: 'Drunkenness',
                 effect_iden: 'Drug',
                 is_buff: false }

             ])
