#!/usr/bin/python3

import random

import pygame 
from pygame.sprite import Sprite


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

        self.screen = game.screen
        self.screen_rect = self.screen.get_rect()
        

        self.sailor_pluto_idle1 = []
        self.sailor_pluto_idle1.append(pygame.image.load('sailor_pluto/sailor_pluto_idle3-1.png'))
        self.sailor_pluto_idle1.append(pygame.image.load('sailor_pluto/sailor_pluto_idle3-2.png'))
        self.sailor_pluto_idle1.append(pygame.image.load('sailor_pluto/sailor_pluto_idle3-3.png'))
        self.sailor_pluto_idle1.append(pygame.image.load('sailor_pluto/sailor_pluto_idle3-4.png'))
        self.sailor_pluto_idle1.append(pygame.image.load('sailor_pluto/sailor_pluto_idle3-5.png'))
        self.current_idle1 = 0


        self.image = pygame.image.load('sailor_pluto/sailor_pluto_idle3-1.png')
        self.rect = self.image.get_rect()

        self.rect.midright = self.screen_rect.midright
        self.rect.bottom = game.sailor_saturn.rect.bottom

        self.blink = 0
        self.shake = False

    def update(self, game):
        if self.shake == False:
            self.not_shake_animation()
        elif self.shake == True:
            self.shake_animation()

    def not_shake_animation(self):
        random_number = random.randrange(25)
        self.blink += 1
        if random_number == 5:
            self.shake = True
        if self.blink >= 15:
            self.image = self.sailor_pluto_idle1[1]
            self.blink = 0
        elif self.blink < 15:
            self.image = self.sailor_pluto_idle1[0]

    def shake_animation(self):
        if self.current_idle1 < 2:
            self.current_idle2 = 2
        if self.current_idle1 >= len(self.sailor_pluto_idle1):
            self.current_idle1 = 0
            self.shake = False

        self.image = self.sailor_pluto_idle1[self.current_idle1]
        self.current_idle1 += 1
 
