#!/usr/bin/python3

import random

import pygame
from pygame.sprite import Sprite
from load import Load

class Sailor_Mercury(Sprite):
    def __init__(self, game):
        """initializes the memory sailor mercury"""
        super().__init__()
        
        #screen set up:
        self.screen = game.screen
        self.screen_rect = self.screen.get_rect()

        #variable flags
        self.stage = 1

        #loads
        self.read = game.load.read_difference

        #loads sailor mercury images for animations
        self.mercury_idle1 = []
        self.mercury_idle1.append(pygame.image.load('sailor_mercury/sailor_mercury_idle1-1.png'))
        self.mercury_idle1.append(pygame.image.load('sailor_mercury/sailor_mercury_idle1-2.png'))
        self.mercury_idle1.append(pygame.image.load('sailor_mercury/sailor_mercury_idle1-3.png'))
        self.mercury_idle1.append(pygame.image.load('sailor_mercury/sailor_mercury_idle1-4.png'))
        self.current_idle1 = 0

        self.mercury_idle2 = []
        self.mercury_idle2.append(pygame.image.load('sailor_mercury/sailor_mercury_idle2-1.png'))
        self.mercury_idle2.append(pygame.image.load('sailor_mercury/sailor_mercury_idle2-2.png'))
        self.mercury_idle2.append(pygame.image.load('sailor_mercury/sailor_mercury_idle2-3.png'))
        self.mercury_idle2.append(pygame.image.load('sailor_mercury/sailor_mercury_idle2-4.png'))
        self.mercury_idle2.append(pygame.image.load('sailor_mercury/sailor_mercury_idle2-5.png'))       
        self.current_idle2 = 0

        self.mercury_idle3 = []
        self.mercury_idle3.append(pygame.image.load('sailor_mercury/sailor_mercury_idle3-1.png'))
        self.mercury_idle3.append(pygame.image.load('sailor_mercury/sailor_mercury_idle3-2.png'))
        self.mercury_idle3.append(pygame.image.load('sailor_mercury/sailor_mercury_idle3-3.png'))
        self.mercury_idle3.append(pygame.image.load('sailor_mercury/sailor_mercury_idle3-4.png'))
        self.mercury_idle3.append(pygame.image.load('sailor_mercury/sailor_mercury_idle3-5.png'))
        self.current_idle3 = 0


        self.mercury_transform1 = []
        self.mercury_transform1.append(pygame.image.load('sailor_mercury/transform1-1.png'))
        self.mercury_transform1.append(pygame.image.load('sailor_mercury/transform1-2.png'))
        self.mercury_transform1.append(pygame.image.load('sailor_mercury/transform1-3.png'))
        self.mercury_transform1.append(pygame.image.load('sailor_mercury/transform1-4.png'))
        self.mercury_transform1.append(pygame.image.load('sailor_mercury/transform1-5.png'))
        self.mercury_transform1.append(pygame.image.load('sailor_mercury/transform1-6.png'))
        self.mercury_transform1.append(pygame.image.load('sailor_mercury/transform1-7.png'))
        self.mercury_transform1.append(pygame.image.load('sailor_mercury/transform1-8.png'))
        self.current_transform1 = 0

        self.mercury_transform2 = []
        self.mercury_transform2.append(pygame.image.load('sailor_mercury/transform2-1.png'))
        self.mercury_transform2.append(pygame.image.load('sailor_mercury/transform2-2.png'))
        self.mercury_transform2.append(pygame.image.load('sailor_mercury/transform2-3.png'))
        self.mercury_transform2.append(pygame.image.load('sailor_mercury/transform2-4.png'))
        self.mercury_transform2.append(pygame.image.load('sailor_mercury/transform2-5.png'))
        self.current_transform2 = 0

        #sets image and rect
        self.image = self.mercury_idle1[self.current_idle1]
        self.rect = self.image.get_rect()

        #places image and rect in correct location
        self.rect.midright = self.screen_rect.midright
        #self.rect.x += 30
        self.rect.y = game.sailor_moon.rect.y
    
   
    def update(self, game):
        if self.read >= 0 and self.read < 1:
            
            if self.stage == 1:
                if self.current_idle1 >= len(self.mercury_idle1):
                    self.current_idle1 = 0
                    self.read = game.read_difference

                self.image = self.mercury_idle1[self.current_idle1]
                self.current_idle1 += 1
        
            elif self.stage == 2:
                self.stage = 1

            elif self.stage == 3:
                self.stage =2

        elif self.read >= 1 and self.read <= 10:
            if self.stage == 1:
                if self.current_transform1 >= len(self.mercury_transform1):
                    self.current_transform1 = 0
                    self.stage = 2

                if self.stage == 1:
                    self.image = self.mercury_transform1[self.current_transform1]
                    self.current_transform1 += 1

            elif self.stage == 2:
                if self.current_idle2 >= len(self.mercury_idle2):
                    self.current_idle2 = 0
                    self.read = game.read_difference

                self.image = self.mercury_idle2[self.current_idle2]
                self.current_idle2 += 1

            elif self.stage == 3:
                self.stage = 2

        else:
            if self.stage == 1:
                if self.current_transform1 >= len(self.mercury_transform1):
                    self.current_transform1 = 0
                    self.stage = 2

                if self.stage == 1:
                    self.image = self.mercury_transform1[self.current_transform1]
                    self.current_transform1 += 1

            elif self.stage == 2:
                if self.current_transform2 >= len(self.mercury_transform2):
                    self.current_transform2 = 0
                    self.stage = 3

                if self.stage == 2:
                    self.image = self.mercury_transform2[self.current_transform2]
                    self.current_transform2 += 1

            elif self.stage == 3:
                if self.current_idle3 >= len(self.mercury_idle3):
                    self.current_idle3 = 0
                    self.read = game.read_difference

                self.image = self.mercury_idle3[self.current_idle3]
                self.current_idle3 += 1

class Coming_Soon(Sprite):
    def __init__(self, game):
        super().__init__()

        self.screen_rect = game.screen_rect

        self.coming_soon_idle = []
        self.coming_soon_idle.append(pygame.image.load('sailor_mercury/coming_soon1-1.png'))
        self.coming_soon_idle.append(pygame.image.load('sailor_mercury/coming_soon1-2.png'))
        self.coming_soon_idle.append(pygame.image.load('sailor_mercury/coming_soon1-2.png'))
        self.current_coming_idle = 0

        self.image = self.coming_soon_idle[self.current_coming_idle]
        self.rect = self.image.get_rect()

        self.rect.center = game.sailor_mercury.rect.center

    def update(self, game):
        if self.current_coming_idle >= len(self.coming_soon_idle):
            self.current_coming_idle = 0
        
        self.image = self.coming_soon_idle[self.current_coming_idle]
        self.current_coming_idle += 1


class Venus_Office(Sprite):
    def __init__(self, game):
        """initializes the sailor mercury"""
        super().__init__()
        
        #screen set up:
        self.screen = game.screen
        self.screen_rect = self.screen.get_rect()

        #images

        #creates sailor moon and positions her

    def update(self):
        if self.current_major_cakes >= len(self.major_cakes):
            self.current_major_cakes = 0

        self.image = self.major_cakes[self.current_major_cakes]
        self.current_major_cakes += 1


