init -1000 python:

#############################################

############### CHAR CLASS ##################

    class char:
                                      # Below are all the variables used in the game for characters :
        def __init__(self, **kwargs): # c_name, age, occupation, notes, notes2, notes3, notes4, notes5, notes6, notes7, notes8,
                                      # notes9, notes10, pic, weakness, nickname, say_name, first_name, say_color

            for i in kwargs:
                self.__dict__[i] = kwargs[i]

            self.current_lvl = 1
            self.punished_today = False
            self.call_for_punish = False
            self.card_version = 0.13 # To Change when adding new things in char class. It helps the updater to know if he has to update a character.

        def scorer(self,multiplier = 1, bonus = 0):
            return (pain + humiliation + pleasure) * (5 + 5 * self.current_lvl) * multiplier + bonus

        @property
        def quest_name(self):
            return self.c_name.split()[0]


        def say(self,the_text): # Useful if you have a character chosen randomly and want it to talk
            globals()[self.say_name](the_text,interact=True)
            return


#################################################

################## QUEST CLASS ##################


    # declares a class called 'm_quest'
    default_var = '???'

    class m_quest:
        def __init__(self, q_name=default_var, description=default_var, note1=default_var, note2=default_var, note3=default_var, note4=default_var, note5=default_var, note6=default_var, note7=default_var, idlepic='none', hoverpic='none'): #<-- this line sets all the defaults; the only one you'll probably use

            self.q_name = q_name
            self.description = description
            self.note1 = note1
            self.note2 = note2
            self.note3 = note3
            self.note4 = note4
            self.note5 = note5
            self.note6 = note6
            self.note7 = note7
            self.idlepic = idlepic
            self.hoverpic = hoverpic
            #You can add more areas if you want, just put self. and whatever it is you need


        def set_char(self, char):
            self.char = char
            return

        def get_char(self):
            if "char" in self.__dict__.keys():
                return self.char.quest_name.replace("Charles","Mr. Wilson")+"'s"
            return "this"

        def move_to_next(self,task=default_var):
            # complete the latest step and add a new one (if we're at the end, add_step will automatically dtrt)
            self.complete_step(self.last_entry)
            self.add_step(task)
            return

        def add_step(self,task=default_var):
            if not task:
                return ""
            # find the first blank step and overwrite it with the task
            self.overwrite_step(min(self.last_entry,7),task)
            return

        def is_complete(self,num=1):
            # check the font color to see if the task is complete
            # this isn't great, but it's at least language-agnostic
            return self.step_contains(num,'{color=#606060}')

        def is_erased(self,num=1):
            if self.__dict__["note"+str(num)] == "":
                return True
            return False

        def is_future(self,num=1):
            # check for a promise of future scenes
            return self.step_contains(num,__("COMING SOON"))

        def step_contains(self,num=1,check=default_var):
            # check wither the supplied string is part of the step text
            if check in self.__dict__["note"+str(num)]:
                return True
            return False

        def any_step_contains(self,check=default_var):
            # loop through all the steps checking for a match to supplied string
            for i in range(1,self.last_entry):
                if self.step_contains(i,check):
                    return True
            return False

        def erase_step(self,num=1):
            # used in cheat menu to roll back priti
            self.overwrite_step(num,"",False)
            return

        def complete_step(self,num=1):
            # don't change anything if already complete
            if self.is_complete(num):
                return
            # change the number to a checkbox - not working with this font :-(, add COMPLETE and change the color
            #leader = str(num) + ")"
            #otask = self.__dict__["note"+str(num)].replace( leader, "{font='DejaVuSans.ttf'}{b}\u2611{/b}{/font}" )

            self.overwrite_step(num,"{color=#606060}" + self.__dict__["note"+str(num)] + " COMPLETE{/color}",False)
            return

        def overwrite_step(self,num=1,task=default_var,seq=True):
            # if we're marking a task complete, or ending the quest we don't want the number
            if seq == False:
              self.__dict__["note"+str(num)] = task
              return
            # if the string already has the number, we don't want to add it again
            if (str(num) + ") ") in task:
              self.__dict__["note"+str(num)] = task
              return
            # otherwise, prepend the number like 2)
            task = str(num) + ") " + task
            self.__dict__["note"+str(num)] = task
            return

        def add_steps(self,*args):
            # to add multiple steps at once
            for s in args:
                self.add_step(s)
            return

        def overwrite_steps(self,num=1,*args):
            # to bulk overwrite steps starting with the supplied step
            for s in args:
                self.overwrite_step(num,s)
                num += 1
            return

        def complete_steps(self,last_step = 0):
            # complete a series of steps but not the whole quest
            for i in range(1,last_step+1):
                self.complete_step(i)
            return

        def erase_steps_after(self,num=1):
            # erase steps after (but not including) the supplied step
            if num < self.last_entry:
                for i in range(num+1,self.last_entry):
                    self.erase_step(i)
            return

        def complete_quest(self,forever=False):
            # mark all steps complete
            for i in range(1,self.last_entry):
                self.complete_step(i)
            # add final note
            whose = self.get_char() # will be "this" if no character is assigned
            if forever:
                self.overwrite_step(self.last_entry,"You have completed " + whose + " story line.",False)
            else:
                self.overwrite_step(self.last_entry,"You've reached the end of " + whose + " story line for this update.",False)
            return

        @property
        def last_entry(self):
            for i in range(1,8):
                if not self.__dict__["note"+str(i)] : return i
            return 8



# Obsolete classes but necessary for old save compatibility.
    class Computer_item:
        pass
    class Electronic_item(Computer_item):
        pass
    class Clothing_item(Computer_item):
        pass
    class Health_item(Computer_item):
        pass
    class Sex_toys_item(Computer_item):
        pass
