# Ian Binstock
# Version of Token Class
# 6/11/2026

import random, pygame, sys
from pygame.locals import *

# Modifying our ball sprite from spritegroup.py to be image sprites
class RPSsprite(pygame.sprite.Sprite):
    
    def __init__(self, x, y, dx, dy, radius, rps_type, global_images):
        super().__init__()
        self.radius = radius
        self.rps_type = rps_type # 'rock', 'paper', or 'scissors'
        self.global_images = global_images
        self.dx = dx
        self.dy = dy
        
        # Assign the initial image asset based on type
        self.image = self.global_images[self.rps_type]
        self.rect = self.image.get_rect(center=(x, y))

    def change_identity(self, new_type):
        self.rps_type = new_type
        self.image = self.global_images[new_type]

    def update(self, SCREEN_W, SCREEN_H):
        self.rect.x += self.dx
        self.rect.y += self.dy

        # Bounce off left border
        if self.rect.left <= 0:
            self.rect.left = 0
            self.dx *= -1
        # Bounce off right border
        elif self.rect.right >= SCREEN_W:
            self.rect.right = SCREEN_W
            self.dx *= -1

        # Bounce off top border
        if self.rect.top <= 0:
            self.rect.top = 0
            self.dy *= -1
        # Bounce off bottom border
        elif self.rect.bottom >= SCREEN_H:
            self.rect.bottom = SCREEN_H
            self.dy *= -1