:benjamin_tomato_festival
  Benjamin "Hello! Welcome to Orange Town's Tomato Festival."
  Benjamin ("We would like to start the event now, are you ready?", "Yes, let's start.", "Not yet. Please wait a minute.", "Not yet. Please wait a minute.")
  if response == "Yes, let's start."
    play child start_tomato_event
    return
  end

  if response == "Not yet. Please wait a minute."
    Benjamin "I'll wait, but hurry please."
    return
  end

:benjamin_tomato_festival_ending
  if-switch playerWonTomatoFestival
    Benjamin "Congratulations on winning the festival, <name>. Your trophy and prize will be delivered by mail. Look forward to it."
    return
  end

  Benjamin "Better luck next time!"

:brittany_tomato_festival
  Brittany "We always supply the tomatoes for this festival. We usually sell our best stock during the month and leave the bad ones for the games."

:brittany_tomato_festival_ending
  if-switch playerWonTomatoFestival
    Brittany "Congratulations on your victory!"
    return
  end

  if-switch brittanyWonTomatoFestival
    Brittany "Hah! I'm still good at this! You were good too, <name>!"
    return
  end

  Brittany "I need to go clean myself better, I even got tomato juice under my nails."

:julia_tomato_festival
  Julia "Hey <name>! Welcome to the tomato festival. Please, talk to Benji if you want to participate."

:julia_tomato_festival_ending
  
  if-switch playerWonTomatoFestival
    Julia "Well done, <name>! You played it really well."
    Julia "Your prize will be delivered by mail tomorrow morning."
    return
  end

  Julia "The festival was a sucess. Too bad you didn't win this time, but look forward for next year."

:billy_tomato_festival
  Billy "Are you playing too, <name>? Maybe I should play as well next time then."

:cindy_tomato_festival
  Cindy "Good luck on the games, <name>. Do your best!"

:viktor_tomato_festival
  Viktor "Hey <name>, will you play the tomato war too? Don't get your hopes up, because I am going to win it."

:viktor_tomato_festival_ending

  if-switch playerWonTomatoFestival
    Viktor "Color me surprised! You won fair and square. Congratulations."
    return
  end

  if-switch viktorWonTomatoFestival
    Viktor "We both knew this was the only possible outcome."
    return
  end

  Viktor "There's something wrong. How come I didn't win?"

:stella_tomato_festival
  Stella "Are you participating, <name>? Good luck."

:stella_tomato_festival_ending
  if-switch playerWonTomatoFestival
    Stella "Congratulations on your victory, <name>!"
    return
  end

  Stella "You should try harder next time."

:annie_tomato_festival
  Annie "I would rather be eating those tomatoes..."

:annie_tomato_festival_ending
  if-switch playerWonTomatoFestival
    Annie "Congrats! Do you get to keep some tomatoes now?"
    return
  end

  Annie "Oh, you didn't win?"

:bonnie_tomato_festival

  Bonnie "This is such a violent game. If you get hit in the eyes you can even go blind!"
  Bonnie "Did you know this is my favorite time of the year?"

:bonnie_tomato_festival_ending
  Bonnie "Looks like nobody got hurt this time."
  if-switch playerWonTomatoFestival
    Bonnie "Still, congratulations for winning the game."
    return
  end

:serge_tomato_festival
  Serge "I'm surprised to see Devin participating in this. Don't go easy on him, alright?"

:serge_tomato_festival_ending
  if-switch playerWonTomatoFestival
    Serge "Congratulations, <name>! You deserve this prize."
    return
  end

  if-switch devinWonTomatoFestival
    Serge "What? Devin won the game? Did you let him win on purpose, <name>?"
    return
  end

  Serge "This is a fun game, isn't it?"

:chloe_tomato_festival
  Chloe "Some people think that this festival is a waste of food. It kind of is, but the tomatoes used here are from Brittany's excess stock, so it couldn't be used anywhere else either."
  
:chloe_tomato_festival_ending

  if-switch playerWonTomatoFestival
    Chloe "Congratulations, <name>! You did a good job."
    return
  end

  Chloe "Better luck next time, <name>!"

:richard_tomato_festival
  Richard "Hey <name>, will you be playing too? What's the point? You know my brother will win."

:phi_tomato_festival
  Phi "I'll be rooting for Richard's brother this year. Don't throw any tomatoes on him, alright?"

:raphael_tomato_festival
  Raphael "Make sure to stretch before the game begins, so you don't hurt your muscles."

:raphael_tomato_festival_ending
  
  if-switch playerWonTomatoFestival
    Raphael "Good job in there, <name>!"
    return
  end

  Raphael "Don't worry, <name>! You can try again next year."

:nathalia_tomato_festival
  Nathalia "I'm not very good at this game, but I have a lot of fun, so I'm gonna play too."

:nathalia_tomato_festival_ending

  if-switch playerWonTomatoFestival
    Nathalia "Congratulations for winning the game, <name>! I loved playing with you."
    return
  end

  if-switch nathaliaWonTomatoFestival
    Nathalia "I really won? I'm as surprised as everybody else."
    return
  end

  Nathalia "I had so much fun today!"

:devin_tomato_festival
  Devin "Are you playing too, <name>? Do your best, because I'll give it my all too."

:devin_tomato_festival_ending

  if-switch devinWonTomatoFestival
    Devin "I can't believe I won! My father must be proud!"
    return
  end

  Devin "Hey, you showed some really good moves in there!"

:start_tomato_event
  fade out
  teleport to war from festival without saving (15, 8, down)
  wait 1

  js TomatoWarContent.startEvent();
  fade in

:tomato_war_pick_tomato
  if Managers.Items.isHoldingItem()
    return
  end

  js Managers.Items._specialItem = Managers.Items.getItemData('tomato')

:tomato_festival_start_game
  Notice "<mid>Welcome everybody, to this year's tomato war.<BR>Today's competitors are: <name>, Brittany, Nathalia, Viktor and Devin."
  Notice "<mid>In this game you have to pick tomatoes from the barrels and throw them at your opponents."
  Notice "<mid>The first person to reach 500 points wins the war."
  Notice "<mid>The game will start in <wait><BR>3...<wait><wait> <BR>2...<wait><wait> <BR>1...<wait><wait> \^"
  js TomatoWarContent.resumeGame();

:tomato_festival_announce_winners

  if TomatoWarContent._winner == 'player'
    include tomato_festival_announce_winner_player
  else
    if TomatoWarContent._winner == 'brittany'
      include tomato_festival_announce_winner_brittany
    else
      if TomatoWarContent._winner == 'nathalia'
        include tomato_festival_announce_winner_nathalia
      else
        if TomatoWarContent._winner == 'devin'
          include tomato_festival_announce_winner_devin
        else
          include tomato_festival_announce_winner_viktor
        end
      end
    end
  end

  if TomatoWarContent._runnerUp == 'player'
    include tomato_festival_announce_runnerUp_player
  else
    if TomatoWarContent._runnerUp == 'brittany'
      include tomato_festival_announce_runnerUp_brittany
    else
      if TomatoWarContent._runnerUp == 'nathalia'
        include tomato_festival_announce_runnerUp_nathalia
      else
        if TomatoWarContent._runnerUp == 'devin'
          include tomato_festival_announce_runnerUp_devin
        else
          include tomato_festival_announce_runnerUp_viktor
        end
      end
    end
  end

  Notice "<mid>Third place: <color:name><var:tomatoWarThirdPlace></color><BR>Fourth Place: <color:name><var:tomatoWarFourthPlace></color><BR>Last Place: <color:name><var:tomatoWarLastPlace></color>"
  Notice "<mid>The prizes will be sent by mail later today. Thank you all for participating in this year's festival!"
  wait 30
  js TomatoWarContent.goBackToSquare();

:tomato_festival_notice_letter
  Letter "Hello, <name>.<BR><BR>On the 28th of summer we will be celebrating another Harvest Festival. You're welcome to join us in the town center between 10AM and 5PM.<BR><BR><BR>From: Benjamin."

:tomato_festival_announce_winner_player
  Notice "<mid>And the game is over! <color:name><name></color> made <var:tomatoWarPlayerScore> points and won this year's festival!"
  
:tomato_festival_announce_winner_brittany
  Notice "<mid>And the game is over! <color:name>Brittany</color> made <var:tomatoWarBrittanyScore> points and won this year's festival!"

:tomato_festival_announce_winner_nathalia
  Notice "<mid>And the game is over! <color:name>Nathalia</color> made <var:tomatoWarNathaliaScore> points and won this year's festival!"

:tomato_festival_announce_winner_devin
  Notice "<mid>And the game is over! <color:name>Devin</color> made <var:tomatoWarDevinScore> points and won this year's festival!"

:tomato_festival_announce_winner_viktor
  Notice "<mid>And the game is over! <color:name>Viktor</color> made <var:tomatoWarViktorScore> points and won this year's festival!"

:tomato_festival_announce_runnerUp_player
  Notice "<mid>In second place we have <color:name><name></color> with <var:tomatoWarPlayerScore> points!"
  
:tomato_festival_announce_runnerUp_brittany
  Notice "<mid>In second place we have <color:name>Brittany</color> with <var:tomatoWarBrittanyScore> points!"

:tomato_festival_announce_runnerUp_nathalia
  Notice "<mid>In second place we have <color:name>Nathalia</color> with <var:tomatoWarNathaliaScore> points!"

:tomato_festival_announce_runnerUp_devin
  Notice "<mid>In second place we have <color:name>Devin</color> with <var:tomatoWarDevinScore> points!"

:tomato_festival_announce_runnerUp_viktor
  Notice "<mid>In second place we have <color:name>Viktor</color> with <var:tomatoWarViktorScore> points!"

:tomato_festival_first_prize_letter
  Letter "Hello, <name>. Congratulations for winning the tomato war yesterday.<BR><BR>I'm sending your trophy attached to this letter.<BR><BR><BR>Benjamin."
  wait 1
  Player "Oh, my trophy is already here!"

  js Managers.Items.mailboxContainer.gainItemId('golden-trophy');
  + Managers.Items.mailboxContainer.gainItemId('tomato-seeds', 20);

  wait 10
  include mailbox_view_items

:tomato_festival_second_prize_letter
  Letter "Hello, <name>. Congratulations for getting second place in the tomato war yesterday.<BR><BR>I'm sending your trophy attached to this letter.<BR><BR><BR>Benjamin."
  wait 1
  Player "Oh, my trophy is already here!"

  js Managers.Items.mailboxContainer.gainItemId('silver-trophy');
  + Managers.Items.mailboxContainer.gainItemId('tomato-seeds', 10);

  wait 10
  include mailbox_view_items

:tomato_festival_third_prize_letter
  Letter "Hello, <name>. Congratulations for getting third place in the tomato war yesterday.<BR><BR>I'm sending your trophy attached to this letter.<BR><BR><BR>Benjamin."
  wait 1
  Player "Oh, my trophy is already here!"

  js Managers.Items.mailboxContainer.gainItemId('bronze-trophy');
  + Managers.Items.mailboxContainer.gainItemId('tomato-seeds', 5);
  wait 10
  include mailbox_view_items

:tomato_festival_no_prize_letter
  Letter "Hello, <name>. Unfortunately you didn't win the tomato war yesterday, but don't give up. We'll repeat the festival next year and you can try again then.<BR><BR><BR>Benjamin."