#NeoPeewee Pygame Engine (January 4, 2020)

import pygame

#Import Global Memory
from Scripts import Global

from Scripts.Minigames import Lizardstail
from Scripts.Minigames import Gryphonegg
from Scripts.Minigames import Spineflowerberry
from Scripts.Minigames import Bonemeal
from Scripts.Minigames import Makishroom
from Scripts.Minigames import Mermaidscale

class Map:
    def __init__(this):
        #Main Variables
        this.state = 0
        this.doControls = 1
        this.doGraphics = 1
        this.alarm = [0]
        #Class Variables
        this.select = 3

    #Main Control Method
    def Control(this, leftpress, rightpress, uppress, downpress, zpress, xpress):
        #Manage Alarms
        for i in range(len(this.alarm)):
            if this.alarm[i] > 0:
                this.alarm[i] -= 1
                if this.alarm[i] == 0:
                    #Go to area and turn off the state
                    if i == 0:
                        if this.select == 0:
                            Global.game = Gryphonegg.Gryphonegg()
                        if this.select == 1:
                            Global.game = Mermaidscale.Mermaidscale()
                        if this.select == 2:
                            Global.game = Bonemeal.Bonemeal()
                        if this.select == 3:
                            Global.shop.state = 1
                            Global.audio.ReplaceMusic('Sounds/Music/Town_Theme_Minimal.mp3')
                        if this.select == 4:
                            Global.game = Makishroom.Makishroom()
                        if this.select == 5:
                            Global.game = Spineflowerberry.Spineflowerberry()
                        if this.select == 6:
                            Global.game = Lizardstail.Lizardstail()
                    this.state = 0
                    this.doControls = 1

        #Do Controls
        if this.doControls == 1:
            if leftpress == 1 and (this.select != 0 and this.select != 2 and this.select != 5):
                this.select -= 1
            if rightpress == 1 and (this.select != 1 and this.select != 4 and this.select != 6):
                this.select += 1
            if uppress == 1:
                if this.select == 2:
                    this.select = 0
                elif this.select == 3:
                    this.select = 0
                elif this.select == 4:
                    this.select = 1
                elif this.select == 5:
                    this.select = 3
                elif this.select == 6:
                    this.select = 4
            if downpress == 1:
                if this.select == 0:
                    this.select = 3
                elif this.select == 1:
                    this.select = 4
                elif this.select == 2:
                    this.select = 5
                elif this.select == 3:
                    this.select = 5
                elif this.select == 4:
                    this.select = 6
            if zpress == 1:
                Global.DoTransition(Global, 10)
                this.doControls = 0
                this.alarm[0] = 10

        #Do Graphics
        if this.doGraphics == 1:
            Global.screen.blit(Global.graphics.map, (0, 0))
            Global.screen.blit(Global.graphics.tag, (0, 16))
            Global.screen.blit(Global.graphics.area, (110, 50))
            if this.select == 0:
                Global.screen.blit(Global.graphics.select, (110, 50))
                Global.TextDisplay(Global, 1, (0, 0, 0), 8, 24, 'Gryphon Nestings')
                Global.TextDisplay(Global, 1, (0, 0, 0), 3, 206, 'The mountains where the Gryphons make their nest.')
                Global.TextDisplay(Global, 1, (0, 0, 0), 3, 222, 'Keep quiet and you might be able to snag some of their eggs!')
            Global.screen.blit(Global.graphics.area, (330, 50))
            if this.select == 1:
                Global.screen.blit(Global.graphics.select, (330, 50))
                Global.TextDisplay(Global, 1, (0, 0, 0), 8, 24, 'Mermaids Reef')
                Global.TextDisplay(Global, 1, (0, 0, 0), 3, 206, 'The beatiful coast where the Mermaids meet.')
                Global.TextDisplay(Global, 1, (0, 0, 0), 3, 222, 'They usually wait for passerbys to tell their riddles to.')
            Global.screen.blit(Global.graphics.area, (50, 102))
            if this.select == 2:
                Global.screen.blit(Global.graphics.select, (50, 102))
                Global.TextDisplay(Global, 1, (0, 0, 0), 8, 24, 'Forever Woods')
                Global.TextDisplay(Global, 1, (0, 0, 0), 3, 206, 'Some say these woods have been standing for millions of years...')
                Global.TextDisplay(Global, 1, (0, 0, 0), 3, 222, 'Many people have stubmled upon fossils exploring the area.')
            Global.screen.blit(Global.graphics.area, (190, 102))
            if this.select == 3:
                Global.screen.blit(Global.graphics.select, (190, 102))
                Global.TextDisplay(Global, 1, (0, 0, 0), 8, 24, 'Capital')
                Global.TextDisplay(Global, 1, (0, 0, 0), 3, 206, 'The main village you call home!')
                Global.TextDisplay(Global, 1, (0, 0, 0), 3, 222, 'Come back here whenever you need to check on your shop.')
            Global.screen.blit(Global.graphics.area, (350, 102))
            if this.select == 4:
                Global.screen.blit(Global.graphics.select, (350, 102))
                Global.TextDisplay(Global, 1, (0, 0, 0), 8, 24, 'Bog Ridden Swamp')
                Global.TextDisplay(Global, 1, (0, 0, 0), 3, 206, 'There is little reason anyone would ever want to come through here...')
                Global.TextDisplay(Global, 1, (0, 0, 0), 3, 222, 'That is unless you have an interest in mushrooms...')
            Global.screen.blit(Global.graphics.area, (130, 160))
            if this.select == 5:
                Global.screen.blit(Global.graphics.select, (130, 160))
                Global.TextDisplay(Global, 1, (0, 0, 0), 8, 24, 'Vineyards')
                Global.TextDisplay(Global, 1, (0, 0, 0), 3, 206, 'Many berries of all sorts grow in this garden!')
                Global.TextDisplay(Global, 1, (0, 0, 0), 3, 222, 'However plenty of thorns grow along side them...')
            Global.screen.blit(Global.graphics.area, (290, 160))
            if this.select == 6:
                Global.screen.blit(Global.graphics.select, (290, 160))
                Global.TextDisplay(Global, 1, (0, 0, 0), 8, 24, 'Wildern Fields')
                Global.TextDisplay(Global, 1, (0, 0, 0), 3, 206, 'There is nothing quite like an open field!')
                Global.TextDisplay(Global, 1, (0, 0, 0), 3, 222, 'Many types of animals make their home here.')
