# Initialization of resources and global variables (i.e. not tied to a specific
# character's dialogue tree) 
# Includes things like character sprites and backgrounds, for easy reference.

# Display a notification that one's stats have changed, then actually update it.
label changeStats(_stat, _delta) :
    python :          
        statDialogue = myPlayer.changeStats(_stat, _delta) 
        for dialogueLine in statDialogue : 
           renpy.say(None, dialogueLine)  
    return
    
# Display a notification that one's relationship has changed, then actually
# update it.
label changeRelationship(_person, _delta) :
    python :
        relaDialogue = getNPC(_person).changeRelationship(_delta) 
        for dialogueLine in relaDialogue :
           renpy.say(None, dialogueLine) 
    return            
    
# Global game setup, initializes some of the singleton classes, as well as error
# tracking, and importing all our Python modules.
init 2 python :                
    
    # Modify stderr to print to a log rather than to crash the game (except in
    # extreme cases) 
    from datetime import datetime
    sys.stderr = open('dinocracy.log', 'a')
    sys.stderr.write("\n========================================\nDINOCRACY\n")
    sys.stderr.write("%s\n" % datetime.now())
    
    # Import our custom classes and code.
    from NPC import *
    from NPCController import *
    from Planner import *
    from PlannerData import *
    from Player import *
    from Tooltip import *
    from random import *
  
    # Since some of our tests exercise Renpy code, we have to do the tests
    #in-game. Load the test suite, run the tests. Results are printed to stderr. 
    from TestSuite import *
    runTestSuite()
    
    # Initialize the singleton classes that control player data, planner data, and NPC data
    myPlanner = Planner()
    myPlayer = Player()
    npcControl = NPCController()
    
    def getNPC(name):
        return npcControl.getNPC(name)
    
init 3:

    # Here we define the backgrounds that are used.
    image bg title = "resource/BG/dinocracy.png"
    image bg wakeupBG = "resource/BG/room.png"
    image bg nightBG = "resource/BG/room_night.png"
    image bg plannerBG = "resource/BG/planningBG.png"
    image bg crowdBG = "resource/BG/fundraise.png"
    image bg coffeeBG = "resource/BG/coffee.png"
    image bg readingBG = "resource/BG/library.png"
    image bg golfBG = "resource/BG/golfcourse.png"
    image bg plannerBG_main = "resource/BG/plannerBG_main.png"
    image bg plannerBG_sub = "resource/BG/plannerBG_sub.png"

    # Override default narrator and player character
    $ you = DynamicCharacter("myPlayer.getName()", color="#ffffff", ctc = anim.Blink("resource/nextArrow.png"))
    $ planner = getNPC("planner").getCharacter()
    $ narrator = Character(ctc = anim.Blink("resource/nextArrow.png")) 

    # Extra positions
    $ offright = Position(xpos=1.0, xanchor='left')
    $ offleft = Position(xpos=0.0, xanchor='right')

        
        
    
