:benjamin_chicken_festival
  Benjamin "Hello! Welcome to Orange Town's Chicken 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."
    Benjamin "Alright! Do you want to enter one of your chickens in the race?"
    play child pick_chicken_to_race
    return
  end

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

:benjamin_chicken_festival_no_chicken
  Benjamin ("Do you need more time, or are you only going to watch?", "I need more time", "Just watch")
  if response == "I need more time"
    Benjamin "I'll wait, but hurry please."
    return
  end

  Benjamin "Okay, we are going to start the race then!"
  play child start_chicken_event

:benjamin_chicken_festival_ending
  if-switch playerWonChickenFestival
    Benjamin "Congratulations on winning the race, <name>. Your prize will be delivered by mail. Look forward to it."
    return
  end

  if-switch playerLostChickenFestival
    Benjamin "Better luck next time!"
    return
  end

  Benjamin "Do you think you can participate next time, <name>? The race is much more fun with more people."

:pick_chicken_to_race
  wait 10
  chickenFestival pickChicken

:start_chicken_event
  fade out
  teleport to race tracks from festival without saving (1, 8, right)
  wait 1

  js ChickenFestivalContent.startEvent();
  fade in

:brittany_chicken_festival
  Brittany "To raise a strong chicken, you need to let her roam free outside the coop."
  Brittany "Make sure to make a well fenced area to protect them from wild animals."

:brittany_chicken_festival_ending
  if-switch playerWonChickenFestival
    Brittany "I knew you had it in you to become a great farmer! Your chicken is amazing."
    return
  end

  if-switch playerLostChickenFestival
    Brittany "You lost? Are you sure you're taking good care of your chicken?"
    return
  end

  Brittany "Next time I want to see a chicken from your farm running in the race."
  

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

:julia_chicken_festival_ending
  
  if-switch playerWonChickenFestival
    Julia "Well done, <name>! You seem to be taking good care of your chicken."
    Julia "Your prize will be delivered by mail tomorrow morning."
    return
  end

  if-switch playerLostChickenFestival
    Julia "The festival was a sucess. Too bad you didn't win this time, but look forward for next year."
  else
    Julia "The festival was a sucess. I hope you will also participate next year."
  end

:viktor_chicken_festival
  Viktor "I once read a whole book of chicken facts. Did you know they have more bones in their necks than giraffes?"

:viktor_chicken_festival_ending
  if-switch playerWonChickenFestival
    Viktor "Hah, that was easy, wasn't it? Congratulations <name>."
  else
    if-switch playerLostChickenFestival
      Viktor "Your chicken was looking at me earlier. It felt like she was staring into my soul."
    else
      Viktor "I thought you were going to participate. Don't you have a chicken?"
    end
  end
  
:serge_chicken_festival
  Serge "If you win the chicken festival, your farm's brand will get some recognition and I'll be able to sell your eggs for more."

:serge_chicken_festival_ending
  if-switch playerWonChickenFestival
    Serge "Congratulations on your victory, <name>! Can you show Devin how you raise your chickens?"
  else
    if-switch devinWonChickenFestival
      Serge "Color me surprised! Devin's Horse actually won the chicken race. I never thought I would live to see this day."
      return
    end

    if-switch playerLostChickenFestival
      Serge "I knew Devin had no chance, but I had hoped you would win this."
      return
    end

    Serge "Why didn't you participate too? Devin's chicken is a lost cause, so I would be rooting for you."
  end

:chloe_chicken_festival
  Chloe "Most people around here like to eat eggs on their breakfast. It's cheap and a great source of protein."

:chloe_chicken_festival_ending
  if-switch playerWonChickenFestival
    Chloe "Your chicken runs very fast. What does she eat everyday to get so strong?"
  else
    if-switch playerLostChickenFestival
      Chloe "Don't worry about losing, <name>. You can try again next year."
    else
      Chloe "Why didn't you enter the race too, <name>?"
    end
  end
  
:gabriel_chicken_festival
  Gabriel "Is it true that chickens have an incredible sense of balance?"

:gabriel_chicken_festival_ending
  if-switch playerWonChickenFestival
    Gabriel "This is way more fun than it looks like. Also, Congratulations on your victory."
  else
    Gabriel "This is way more fun than it looks like."
  end
  
:lucas_chicken_festival
  Lucas "When I imagine a farm, the first animal I think of is always a chicken. Why do you think is that?"

:lucas_chicken_festival_ending
  if-switch playerWonChickenFestival
    Lucas "I have no idea what you have to do to train your chicken, but congratulations for doing it well."
  else
    Lucas "How can you even make the chickens run in a race? I thought they were going to just stay there, looking at each other."
  end

:stella_chicken_festival_rooster
  if-switch boughtFestivalAnimal
    Stella "I'll deliver your rooster when the festival ends."
  else
    Stella "Good morning, <name>. Today we are selling this magnificent rooster. Are you interested? The price is $ 5,000"
    play child stella_buy_rooster
  end

:stella_chicken_festival_ending_rooster
  if-switch boughtFestivalAnimal
    Stella "Hey <name>, I'm just about to go deliver the rooster you bought."
  else
    Stella "Good evening, <name>. This is your last chance to buy this magnificent rooster today. Are you interested? The price is $ 5,000"
    play child stella_buy_rooster
  end

:stella_chicken_festival
  Stella "I'll be keeping an eye on all participants. If anyone isn't taking good care of their animals, I'll know."

:stella_chicken_festival_ending
  if-switch nathaliaWonChickenFestival
    Stella "Nathalia always takes good care of Agatha. She probably read a lot of books to learn how to care for chickens."
    return
  end

  if-switch playerWonChickenFestival
    Stella "You did a great job <name>, but don't let it get over your head."
    return
  end

  if-switch devinWonChickenFestival
    Stella "The worst chicken won today. How can it be possible?"
    return
  end

  if-switch raphaelWonChickenFestival
    Stella "I didn't pay attention to Raphael's chicken, because I never expected her to win, but I guess he did a good job raising her."
    return
  end

  if-switch miaWonChickenFestival
    Stella "And Mia won once again. Nobody is surprised by that."
    return
  end

  Stella "The festival is over, I'll be going home soon."


:nathalia_chicken_festival
  Nathalia "Today I had to leave Pat-Pat at home. He's friends with Agatha, but I don't want to risk having him near so many chickens."

:nathalia_chicken_festival_ending

  if-switch nathaliaWonChickenFestival
    Nathalia "Look at that! I really won! It's all thanks to this book I've been reading."
    Nathalia "It's called 'How to make your Chicken win the Orange Town Chicken Race'."
    return
  end
  
  if-switch playerWonChickenFestival
    Nathalia "Well done, <name>. Congratulations for winning the race!"
    return
  end

  if-switch playerLostChickenFestival
    Nathalia "Hah. We both lost. I guess we need to study some more about how to properly raise a chicken."
  else
    Nathalia "My little Agatha lost the race, but it's not a big deal. I'll study more and raise her stronger for the next year."
  end

:devin_chicken_festival
  Player "Why is your chicken so... green?"
  Devin "I don't know. Maybe she hasn't matured yet."
  Player "I don't think that logic applies to animals."

:devin_chicken_festival_ending

  if-switch devinWonChickenFestival
    Devin "I can't believe my Horse won! After so many years I finally won this race!"
    Player "You mean your chicken?"
    Devin "Yeah, my chicken Horse."
  else
    Player "Is your chicken really called Horse?"
    Devin "Yeah! It's cool, right? It messes with people's heads."
    Player "What would you call your horse if you had one?"
    Devin "I have one. It's called Turtle."
  end

:annie_chicken_festival
  Annie "Hello there. Perfect day for a festival, isn't it?"

:annie_chicken_festival_ending
  if-switch playerWonChickenFestival
    Annie "Your chicken is very happy that she won. I can tell she likes you."
  else
    Annie "I had a lot of fun today. And I can tell that the chickens are happy too."
  end

:raphael_chicken_festival
  Raphael "Will you participate this time, <name>? I think my chicken Pipin has a chance this year."

:raphael_chicken_festival_ending
  if-switch raphaelWonChickenFestival
    Raphael "I knew it! My Pipin is the best chicken ever!"
  else
    Raphael "I lost again. I really thought this time things would be different..."
  end

:mia_chicken_festival
  Mia "It looks like everyone is taking good care of their animals. It fills my heart with joy."

:mia_chicken_festival_ending
  
  if-switch playerLostChickenFestival
    if-switch miaWonChickenFestival
      Mia "Hey <name>. I won this time, but you weren't bad either."
      Mia "I know you're taking good care of your animals, so keep competing and you'll eventually win."
    else
      Mia "I never expected both of us to lose this competition."
    end
  else
    if-switch miaWonChickenFestival
      Mia "I'm really happy! Cocoa won the race again."
    else
      if-switch playerWonChickenFestival
        Mia "Congratulations, <name>. I knew that if I were to lose this race, it was going to be to you."
      else
        Mia "Oh, I didn't think I would ever see the day that my Cocoa would lose a chicken race."
        Mia "At the same time, I'm happy that people here are raising their animals well."
      end
    end
  end

:ilda_chicken_festival
  Ilda "I can't even tell the chickens apart anymore, so I won't watch the race, but I like to come here when the whole town is together."

:ilda_chicken_festival_ending
  if-switch playerLostChickenFestival
    Ilda "Did you have fun? That is all that matters."
    return
  end

  if-switch playerWonChickenFestival
    Ilda "Congratulations, darling."
    return
  end

  Ilda "Those festivals are always fun. Did you have fun too?"

:amanda_chicken_festival
  Amanda "I think I know who's going to win the race today. I'll tell you later if I got it right."

:amanda_chicken_festival_ending
  if-switch playerWonChickenFestival
    Amanda "No, I didn't think you were going to win. Congratulations anyway."
  else
    Amanda "Yes! Exactly who I thought was going to win."
  end

:cindy_chicken_festival
  Cindy "The chickens are safe while running, right? I don't want to be part of a festival where the animals could get hurt."

:cindy_chicken_festival_ending
  if-switch playerWonChickenFestival
    Cindy "This was actually a lot of fun. Congratulations on your victory!"
    return
  end

  if-switch playerLostChickenFestival
    Cindy "This was actually a lot of fun. Too bad you didn't win."
    return
  end

  Cindy "This was actually a lot of fun. You should participate too next time."

:billy_chicken_festival
  Billy "Benjamin didn't let my Francisca enter the race. You wouldn't have a chance if she were to run."

:billy_chicken_festival_ending
  if-switch playerWonChickenFestival
    Billy "Wanna bet that trophy on a race against my duck?"
    return
  end
  
  if-switch playerLostChickenFestival
    Billy "Don't worry, I never really expected you to win."
    return
  end

  Billy "You didn't even try to race?"

:rory_chicken_festival
  Rory "What's so good about chickens anyway?"



:bonnie_chicken_festival
  Bonnie "When I was a kid, me and my friends used to throw eggs at each other as a prank."
  Bonnie "I remember one of them once slipped on a broken egg and ended up with a broken leg."
  Bonnie "That day was fun."

:bonnie_chicken_festival_ending
  if-switch playerWonChickenFestival
    Bonnie "Your chicken ran so fast in there. Near the end I thought she was going to jump to your face and peck your eye out."
    Bonnie "Well, there's always next year."
    return
  end

  if-switch playerLostChickenFestival
    Bonnie "Why did you lose? You should train your chicken better."
    return
  end

  Bonnie "Why aren't you participating? Do you think some chicken would peck your eye out?"

:richard_chicken_festival
  Richard "Will you participate in the race, <name>?"
  Richard "Benjamin said that only adults can participate, so this year I can only watch it."

:phi_chicken_festival
  Phi "Benjamin won't let me enter my chicken in the race. Ugh, he's such a green apple."

:martin_chicken_festival
  Martin "I don't have a chicken to enter the race, but Pom likes to see them running."

:pom_chicken_festival

:chicken_race_announcement
  wait 30
  js window.y = 9;
  js $gameMap.centerCameraOn(29, window.y, 4);
  wait for Camera
  wait 60
  js $gameMap.centerCameraOn(1, window.y, 4);
  wait for Camera
  wait 30
  play child chicken_race_announcement_part2

:chicken_race_announcement_part2
  if (ChickenFestivalContent.chicken0)
    Notice "<mid>Welcome everybody, to this year's chicken race.<BR>Today's competitors are: <var:chicken0Name>, <var:chicken1Name>, <var:chicken2Name>, <var:chicken3Name> and <var:chicken4Name>."
  else
    Notice "<mid>Welcome everybody, to this year's chicken race.<BR>Today's competitors are: <var:chicken1Name>, <var:chicken2Name>, <var:chicken3Name> and <var:chicken4Name>."
  end
  Notice "<mid>The race will start in <wait><BR>3...<wait><wait> <BR>2...<wait><wait> <BR>1...<wait><wait> \^"

  js ChickenFestivalContent.makeThemRun();

  wait 60
  js $gameMap.centerCameraOn(29, window.y, 2.5);

:chicken_festival_announce_winners
  Notice "<mid>What a fantastic race! The results are as follows:"
  Notice "<mid>Winner: <color:name><var:winnerChicken></color><BR>Runner Up: <color:name><var:runnerUpChicken></color><BR>Third Place: <color:name><var:thirdChicken></color>"
  Notice "<mid>Last Place: <color:name><var:fourthChicken></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 ChickenFestivalContent.goBackToSquare();

:chicken_festival_not_ready
  include festival_not_ready

:chicken_festival_announce_winners_with_player
  Notice "<mid>What a fantastic race! The results are as follows:"
  Notice "<mid>Winner: <color:name><var:winnerChicken></color><BR>Runner Up: <color:name><var:runnerUpChicken></color><BR>Third Place: <color:name><var:thirdChicken></color>"
  Notice "<mid>Fourth Place: <color:name><var:fourthChicken></color><BR>Last Place: <color:name><var:fifthChicken></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 ChickenFestivalContent.goBackToSquare();

:chicken_festival_first_prize_letter
  Letter "Hello, <name>. Congratulations for winning the Chicken Race yesterday.<BR><BR>I'm sending your prize 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('chicken-feed', 28);

  wait 10
  include mailbox_view_items

:chicken_festival_second_prize_letter
  Letter "Hello, <name>. Congratulations for getting second place in the Chicken Race yesterday.<BR><BR>I'm sending your prize 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('chicken-feed', 14);
  wait 10
  include mailbox_view_items

:chicken_festival_third_prize_letter
  Letter "Hello, <name>. Congratulations for getting third place in the Chicken Race yesterday.<BR><BR>I'm sending your prize 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('chicken-feed', 7);
  wait 10
  include mailbox_view_items

:chicken_festival_no_prize_letter
  Letter "Hello, <name>. Unfortunately you didn't win the Chicken Race yesterday, but don't give up. We'll have a new race next year and you can try again then.<BR><BR><BR>Benjamin."

:chicken_festival_notice_letter
  Letter "Hello, <name>.<BR><BR> Tomorrow (Spring 18th) we will be celebrating the Chicken Festival in the town center. If you want to participate, bring a chicken with you.<BR><BR><BR>Benjamin."
