import tkinter as tk
from tkinter import messagebox

mystery_book1_summary= """Alicia Berenson’s life is seemingly perfect.
     A famous painter married to an in-demand fashion photographer, 
     she lives in a grand house with big windows overlooking a park in one of London’s most desirable areas. 
     One evening her husband Gabriel returns home late from a fashion shoot, and Alicia shoots him five times in the face,
     and then never speaks another word. Alicia’s refusal to talk, or give any kind of explanation,
     turns a domestic tragedy into something far grander, a mystery that captures the public imagination and casts Alicia into notoriety.
     The price of her art skyrockets, and she, the silent patient, is hidden away from the tabloids and spotlight at the Grove, a secure 
     forensic unit in North London. Theo Faber is a criminal psychotherapist who has waited a long time for the opportunity to work with Alicia.
      His determination to get her to talk and unravel the mystery of why she shot her husband takes him down a twisting path into his own motivations—a search for the truth that threatens to consume him....
      The Silent Patient is a shocking psychological thriller of a woman’s act of violence against her husband—and of the therapist obsessed with uncovering her motive."""
mystery_book1_link = "https://www.goodreads.com/book/show/40097951-the-silent-patient?ref=nav_sb_ss_1_11"

mystery_book2_summary= """ Nobody knows Delilah like Logan does. Nobody. 
     He makes sure of it by learning everything he can through her social media and watching her through a hidden camera
     he has trained on her house. Some might call him a stalker. Logan prefers to be called “romantic.” 
     But after Logan sees Delilah killing her abusive stepfather, he realizes there’s still more about her to discover. 
     His sweet, perfect Delilah isn’t so perfect after all. Delilah knows she should feel guilty, but all she feels is free.
     She’s so over the men in her life controlling her. Except Logan saw what she did, and he won’t let her forget it.
     Delilah is done being the victim.  """
mystery_book2_link = "https://www.goodreads.com/book/show/51260845-the-obsession?from_search=true&from_srp=true&qid=okIIIEULx9&rank=3"

fantasy_book1_summary= """In a land without magic, where the king rules with an iron hand, an assassin is summoned to the castle.
    She comes not to kill the king, but to win her freedom. If she defeats twenty-three killers, thieves, and warriors in a competition,
    she is released from prison to serve as the king's champion. Her name is Celaena Sardothien. The Crown Prince will provoke her. 
    The Captain of the Guard will protect her. But something evil dwells in the castle of glass—and it's there to kill. 
    When her competitors start dying one by one, Celaena's fight for freedom becomes a fight for survival, and a desperate quest to root out the evil before it destroys her world."""
fantasy_book1_link = "https://www.goodreads.com/book/show/76703559-throne-of-glass?from_search=true&from_srp=true&qid=R1CpWVMCns&rank=1"

fantasy_book2_summary= """Laia is a slave. Elias is a soldier. Neither is free. Under the Martial Empire, defiance is met with death. 
    Those who do not vow their blood and bodies to the Emperor risk the execution of their loved ones and the destruction of all they hold dear. 
    It is in this brutal world, inspired by ancient Rome, that Laia lives with her grandparents and older brother. The family ekes out an existence in the Empire’s impoverished backstreets. 
    They do not challenge the Empire. They’ve seen what happens to those who do. But when Laia’s brother is arrested for treason, Laia is forced to make a decision. 
    In exchange for help from rebels who promise to rescue her brother, she will risk her life to spy for them from within the Empire’s greatest military academy. 
    There, Laia meets Elias, the school’s finest soldier—and secretly, its most unwilling. Elias wants only to be free of the tyranny he’s being trained to enforce. 
    He and Laia will soon realize that their destinies are intertwined—and that their choices will change the fate of the Empire itself."""
fantasy_book2_link = "https://www.goodreads.com/book/show/27774758-an-ember-in-the-ashes?from_search=true&from_srp=true&qid=uYX5z67X9N&rank=1"

mg_book1_summary= """Twelve-year-old Sophie Foster has a secret. She’s a Telepath—someone who hears the thoughts of everyone around her. 
    It’s a talent she’s never known how to explain. Everything changes the day she meets Fitz, a mysterious boy who appears out of nowhere and also reads minds. 
    She discovers there’s a place she does belong, and that staying with her family will place her in grave danger. In the blink of an eye, Sophie is forced to leave behind everything and 
    start a new life in a place that is vastly different from anything she has ever known. Sophie has new rules to learn and new skills to master, and not everyone is thrilled that she has come “home.” 
    There are secrets buried deep in Sophie’s memory—secrets about who she really is and why she was hidden among humans—that other people desperately want. Would even kill for. 
    In this page-turning debut, Shannon Messenger creates a riveting story where one girl must figure out why she is the key to her brand-new world, before the wrong person finds the answer first."""
mg_book1_link = "https://www.goodreads.com/en/book/show/12842828-keeper-of-the-lost-cities"

mg_book2_summary= """Percy Jackson is a good kid, but he can't seem to focus on his schoolwork or control his temper. And lately, being away at boarding school is only getting worse - 
    Percy could have sworn his pre-algebra teacher turned into a monster and tried to kill him. When Percy's mom finds out, she knows it's time that he knew the truth about where he came from, 
    and that he go to the one place he'll be safe. She sends Percy to Camp Half Blood, a summer camp for demigods (on Long Island), where he learns that the father he never knew is Poseidon, 
    God of the Sea. Soon a mystery unfolds and together with his friends—one a satyr and the other the demigod daughter of Athena - Percy sets out on a quest across the United States to
    reach the gates of the Underworld (located in a recording studio in Hollywood) and prevent a catastrophic war between the gods."""
mg_book2_link = "https://www.goodreads.com/book/show/28187.The_Lightning_Thief?from_search=true&from_srp=true&qid=XEBZ7Azh7Z&rank=1"

class Book:
    def __init__(self, name, author, rating, summary, link):
        self.name = name
        self.author = author
        self.rating = rating
        self.summary = summary
        self.link = link


def show_message(message, input_list):
    for index, item in enumerate(input_list):
        message += f'{index+1}) {item}\n'
    user_input = input(message)
    return user_input


def show_popup(msg, title, justify):
    window = tk.Tk()
    window.geometry("800x900")
    window.title(title)
    font_size = tk.StringVar()
    font_size.set("16")
    tk.Label(window, text=msg, justify=justify).pack()
    tk.mainloop()

def ask_user_if_bored():
    bored = input("Are you currently bored? (enter yes or no)")
    
    if bored=="yes":
        book_summary_task()
    else:
        show_popup("Have A Great Day! Please come back later when you are bored.", "Hope to See you soon..", "center")
 

def book_summary_task():
    
    mystery_book1 = Book("The Silent Patient", "Alex Michaelides ","4.18/5", mystery_book1_summary, mystery_book1_link)
    mystery_book2 = Book("The Obsession", "Jesse Q. Sutanto","3.76/5", mystery_book2_summary, mystery_book2_link)

    fantasy_book1 = Book("Throne of Glass", "Sarah J. Maas ","4.19/5", fantasy_book1_summary, fantasy_book1_link)
    fantasy_book2 = Book("An Ember in the Ashes", "Sabaa Tahir","4.26/5", fantasy_book2_summary, fantasy_book2_link)

    mg_book1 = Book("Keeper of the Lost Cities", "Shannon Messenger","4.43/5", mystery_book1_summary, mystery_book1_link)
    mg_book2 = Book("Percy Jackson", "Rick Riordan","4.29/5", mystery_book2_summary, mystery_book2_link)

    books_names_dict = {
        "mystery": ["The Silent Patient","The Obsession"],
        "fantasy":["Throne of Glass","An Ember in the Ashes"],
        "middle grade":["Keeper of the Lost Cities","Percy Jackson"]
        }

    books_dict = {
        "the silent patient": mystery_book1,
        "the obsession":mystery_book2,
        "throne of glass":fantasy_book1,
        "an ember in the ashes":fantasy_book2,
        "keeper of the lost cities":mg_book1,
        "percy jackson":mg_book2        
    }

    # print genre options 
    genres = {"Mystery", "Fantasy", "Middle Grade"}

    genre_msg = "Since you are bored, which of these genres are you most interested in reading?\n (Enter the genre name - options) \n"
    genre_user_input = show_message(genre_msg, genres)
    print("user input: "+genre_user_input)

    select_book_msg= "For the "+genre_user_input+ " genre you have two book options. "+ "Which of these books would you like to learn more about, Enter book name\n" 
    book_input = show_message(select_book_msg, books_names_dict[genre_user_input])
    book_result= books_dict[book_input.lower()]
    
    book_summary_message = "This is the book suggestion you have!!\n"+"Book Name: "+book_result.name +"\n"+"Author: "+book_result.author+"\n"+ "Rating: "+book_result.rating +"\n"+"Summary: "+book_result.summary+"\n"+"Link to Goodreads:"+book_result.link
    show_popup(book_summary_message, "Your Book Choice", "left")

ask_user_if_bored()