from .unit import Unit
import random
import uuid

# Costanti
AGE_THRESHOLD = 200


class Point(Unit):
    def __init__(self, game, position=(0,0), id=None, value=5):
        super().__init__(game, position, id)
        # Specific attributes for points
        self.speed = 4  # Points age faster
        self.fight = False
        self.value = value
        self.game.add_point(self.value)

    def move(self):
        self.age += self.speed
        if self.age == AGE_THRESHOLD:
            self.die()
        
    def collisions(self):
        pass
                    
    def die(self, unit=None, score=None):
        """Handle point cleanup. Points just disappear when they expire."""
        target_unit = unit if unit else self
        # Use base class cleanup
        super().die()
        
        
    def draw(self):
        image = self.game.assets[f"BMP_BONUS_{self.value}"]
        image_size = self.game.render_engine.get_image_size(image)
        self.rat_image = image
        partial_x, partial_y = 0, 0
        
        x_pos = self.position_before[0] * self.game.cell_size + (self.game.cell_size - image_size[0]) // 2 + partial_x
        y_pos = self.position_before[1] * self.game.cell_size + (self.game.cell_size - image_size[1]) // 2 + partial_y
        
        self.game.render_engine.draw_image(x_pos, y_pos, image, anchor="nw", tag="unit")
