"""
Adolescent Life Events
General adolescent experiences including school, personal growth, and social situations (ages 10-18)

Events:
- groupProjectDrama: Dealing with lazy group project partners
- voiceCracking: Voice changing during puberty (males)
- bodySelfConsciousness: Growing awareness of physical appearance
- curfewArgument: Negotiating curfew with parents
- growthSpurt: Sudden rapid growth
- embarrassingSituation: Random embarrassing teen moment
- sleepover: First overnight party with friends
- socialMediaPressure: Deciding whether to get social media
- fashionExperimentation: Trying a bold new style
- learningToDrive: First time behind the wheel
"""

import random
from events.base import messageFunction, questionFunction, answerOption


def groupProjectDrama(player, type='message', message=False, response=False):
    """Dealing with lazy group project partners"""
    fname = 'groupProjectDrama'
    check = fname not in player.askedQuestions and player.c.ageYears >= 12 and player.c.ageYears <= 18 and player.c.occupation == 'student' and 1 >= random.random() * 500
    message = "Your group project is due tomorrow and your partners haven't done their part. What do you do?"
    answerOptions = [
        answerOption('Do all the work yourself', energyCost=20),
        answerOption('Tell the teacher'),
        answerOption('Stay up all night helping everyone finish', energyCost=15, diamondCost=5),
        answerOption('Turn in what you have')
    ]
    if (type != 'answer'):
        return questionFunction(fname, message, player, check, answerOptions)
    elif (type == 'answer'):
        if (response['option'] == answerOptions[0].option):
            player.messageQueue.append("You stayed up until 3am finishing everyone's work. You're exhausted but at least it's done.")
            player.c.happiness -= 10
        elif (response['option'] == answerOptions[1].option):
            player.messageQueue.append("You told the teacher about the situation. Your grade was protected, but your group members aren't happy with you.")
            player.c.social -= 10
        elif (response['option'] == answerOptions[2].option):
            player.messageQueue.append("You rallied the team and worked together all night. It was exhausting but everyone pulled through, and your group appreciates your leadership!")
            player.c.social += 15
        elif (response['option'] == answerOptions[3].option):
            player.messageQueue.append("You turned in the incomplete project. The teacher wasn't impressed, and you all got a lower grade.")
            player.c.happiness -= 5


def voiceCracking(player, type='message'):
    """Voice changing during puberty (males)"""
    fname = 'voiceCracking'
    check = fname not in player.events and player.c.sex == 'Male' and player.c.ageYears >= 12 and player.c.ageYears <= 14 and 1 >= random.random() * 800
    message = "Your voice cracks right in the middle of answering a question in class. Everyone giggles. Your face turns red."
    if check:
        player.events.add(fname)
    return messageFunction(fname, message, player, check)


def bodySelfConsciousness(player, type='message'):
    """Growing awareness of physical appearance"""
    fname = 'bodySelfConsciousness'
    check = fname not in player.events and player.c.ageYears >= 11 and player.c.ageYears <= 14 and 1 >= random.random() * 600
    message = "You spend extra time looking in the mirror today. You're starting to notice things you never paid attention to before."
    if check:
        player.events.add(fname)
    return messageFunction(fname, message, player, check)


def curfewArgument(player, type='message', message=False, response=False):
    """Negotiating curfew with parents"""
    fname = 'curfewArgument'
    check = fname not in player.askedQuestions and player.c.ageYears >= 14 and player.c.ageYears <= 17 and 1 >= random.random() * 700
    message = "Your parents set a 10pm curfew, but your friends are staying out until midnight. What do you do?"
    answerOptions = [
        answerOption('Follow the rules'),
        answerOption('Sneak out after they\'re asleep', energyCost=10),
        answerOption('Negotiate for 11pm', diamondCost=5),
        answerOption('Don\'t go out at all')
    ]
    if (type != 'answer'):
        return questionFunction(fname, message, player, check, answerOptions)
    elif (type == 'answer'):
        if (response['option'] == answerOptions[0].option):
            player.messageQueue.append("You followed the rules and came home at 10pm. Your friends teased you a bit, but your parents appreciated it.")
            player.c.happiness -= 5
            player.c.social -= 5
        elif (response['option'] == answerOptions[1].option):
            player.messageQueue.append("You snuck out after your parents went to sleep. You had fun but barely got any sleep and you're worried about getting caught.")
        elif (response['option'] == answerOptions[2].option):
            player.messageQueue.append("You calmly made your case and your parents agreed to 11pm. Compromise feels good!")
            player.c.happiness += 5
        elif (response['option'] == answerOptions[3].option):
            player.messageQueue.append("You decided not to go out at all. Your friends were disappointed and you felt left out.")
            player.c.social -= 10
            player.c.happiness -= 10


def growthSpurt(player, type='message'):
    """Sudden rapid growth"""
    fname = 'growthSpurt'
    check = fname not in player.events and player.c.ageYears >= 12 and player.c.ageYears <= 15 and 1 >= random.random() * 1000
    message = "You grew 3 inches this year! None of your pants fit anymore and you keep bumping into things."
    if check:
        player.events.add(fname)
    return messageFunction(fname, message, player, check)


def embarrassingSituation(player, type='message'):
    """Random embarrassing teen moment"""
    fname = 'embarrassingSituation'
    check = fname not in player.events and player.c.ageYears >= 13 and player.c.ageYears <= 17 and 1 >= random.random() * 500

    # Multiple message options for variety
    messages = [
        "You walked around all day with food stuck in your teeth. Why didn't anyone tell you?!",
        "You called your teacher 'Mom' by accident. The whole class erupted in laughter.",
        "You tripped going up the stairs and everyone saw. You wanted to disappear.",
        "Your stomach growled loudly during a quiet test. It echoed through the whole room."
    ]
    message = random.choice(messages)

    if check:
        player.events.add(fname)
    return messageFunction(fname, message, player, check)


def sleepover(player, type='message', message=False, response=False):
    """First overnight party with friends"""
    fname = 'sleepover'
    check = fname not in player.askedQuestions and player.c.ageYears >= 12 and player.c.ageYears <= 15 and 1 >= random.random() * 1000
    message = "You're at a sleepover and everyone wants to play truth or dare. Do you play?"
    answerOptions = [
        answerOption('Yes, and pick truth'),
        answerOption('Yes, and pick dare', energyCost=10),
        answerOption('Pretend to fall asleep'),
        answerOption('Suggest a different game', diamondCost=3)
    ]
    if (type != 'answer'):
        return questionFunction(fname, message, player, check, answerOptions)
    elif (type == 'answer'):
        if (response['option'] == answerOptions[0].option):
            player.messageQueue.append("You picked truth and had to share your biggest secret. It was scary but brought you closer to your friends!")
            player.c.social += 5
        elif (response['option'] == answerOptions[1].option):
            player.messageQueue.append("You picked dare and had to prank call someone. Your heart was racing but everyone thought you were so brave!")
            player.c.social += 10
        elif (response['option'] == answerOptions[2].option):
            player.messageQueue.append("You pretended to fall asleep. Your friends knew you were faking and thought you were lame.")
            player.c.social -= 10
            player.c.happiness -= 5
        elif (response['option'] == answerOptions[3].option):
            player.messageQueue.append("You suggested watching a movie instead. Everyone agreed and you all had a great time!")
            player.c.social += 5


def socialMediaPressure(player, type='message', message=False, response=False):
    """Deciding whether to get social media"""
    fname = 'socialMediaPressure'
    check = fname not in player.askedQuestions and player.c.ageYears >= 11 and player.c.ageYears <= 14 and 1 >= random.random() * 800
    message = "All your friends are on social media now. Do you want to join?"
    answerOptions = [
        answerOption('Yes, make an account'),
        answerOption('No, you\'re not interested'),
        answerOption('Make a private account')
    ]
    if (type != 'answer'):
        return questionFunction(fname, message, player, check, answerOptions)
    elif (type == 'answer'):
        if (response['option'] == answerOptions[0].option):
            player.messageQueue.append("You made a social media account! You're excited to connect with friends and share your life online.")
            player.c.social += 10
            player.c.happiness += 5
            player.c.hasSocialMedia = True
        elif (response['option'] == answerOptions[1].option):
            player.messageQueue.append("You decided social media isn't for you. Your friends don't get it, but you feel good about your choice.")
            player.c.social -= 5
            player.c.happiness += 5
        elif (response['option'] == answerOptions[2].option):
            player.messageQueue.append("You made a private account so you can stay connected but keep your privacy. Smart move!")
            player.c.social += 5
            player.c.hasSocialMedia = True


def fashionExperimentation(player, type='message', message=False, response=False):
    """Trying a bold new style"""
    fname = 'fashionExperimentation'
    check = fname not in player.askedQuestions and player.c.ageYears >= 13 and player.c.ageYears <= 17 and 1 >= random.random() * 900
    message = "You want to try a completely different fashion style. What do you go for?"
    answerOptions = [
        answerOption('Edgy and dark'),
        answerOption('Preppy and classic'),
        answerOption('Athletic and casual'),
        answerOption('Stay the same')
    ]
    if (type != 'answer'):
        return questionFunction(fname, message, player, check, answerOptions)
    elif (type == 'answer'):
        if (response['option'] == answerOptions[0].option):
            player.messageQueue.append("You went for an edgy, dark look. Some people stared but you feel confident and unique!")
            player.c.social += 5
        elif (response['option'] == answerOptions[1].option):
            player.messageQueue.append("You chose a preppy, classic style. You look put-together and people complimented your new look!")
            player.c.social += 5
        elif (response['option'] == answerOptions[2].option):
            player.messageQueue.append("You embraced an athletic, casual style. It's comfortable and sporty - perfect for you!")
            player.c.social += 5
        elif (response['option'] == answerOptions[3].option):
            player.messageQueue.append("You decided to stick with your current style. Better safe than sorry... but you wonder what could have been.")
            player.c.happiness -= 5


def learningToDrive(player, type='message'):
    """First time behind the wheel"""
    fname = 'learningToDrive'
    check = fname not in player.events and player.c.ageYears >= 15 and player.c.ageYears <= 16 and 1 >= random.random() * 1200
    message = "Your parent takes you to an empty parking lot to practice driving for the first time. You're nervous and excited!"
    if check:
        player.events.add(fname)
    return messageFunction(fname, message, player, check)


__all__ = [
    'groupProjectDrama',
    'voiceCracking',
    'bodySelfConsciousness',
    'curfewArgument',
    'growthSpurt',
    'embarrassingSituation',
    'sleepover',
    'socialMediaPressure',
    'fashionExperimentation',
    'learningToDrive',
]
