59 lines
2.3 KiB
Python
59 lines
2.3 KiB
Python
import pygame
|
|
import sys
|
|
import random
|
|
from enum import Enum
|
|
from sprites.cell import Cell
|
|
from enums.house_image import House_image
|
|
|
|
PLASTIC = 0 # blue
|
|
GLASS = 1 # green
|
|
METAL = 2 # yellow
|
|
|
|
|
|
class House(Cell):
|
|
def __init__(self, x, y, max_plastic, max_glass, max_metal):
|
|
Cell.__init__(self, x, y)
|
|
self.image = pygame.image.load(House_image.house.value)
|
|
self.rubbish = [random.randint(0, max_plastic), random.randint(
|
|
0, max_glass), random.randint(0, max_metal)] # plastic, glass, metal
|
|
|
|
self.max_plastic = max_plastic
|
|
self.max_glass = max_glass
|
|
self.max_metal = max_metal
|
|
|
|
def generate_rubbish(self):
|
|
if(random.randint(0, 25) == 1): # 1/25 szansa na wyrzucenie śmiecia w klatce
|
|
thrash_type = random.randint(0, 2)
|
|
self.rubbish[thrash_type] = self.rubbish[thrash_type] + 1
|
|
|
|
#mozna ladniej?
|
|
if(self.rubbish[PLASTIC] > self.max_plastic):
|
|
if(self.rubbish[GLASS] > self.max_glass):
|
|
if(self.rubbish[METAL] > self.max_metal):
|
|
self.image = pygame.image.load(House_image.full.value) #plastik, szklo, metal
|
|
else:
|
|
self.image = pygame.image.load(House_image.plastic_glass.value) #plastik, szklo
|
|
elif(self.rubbish[METAL] > self.max_metal):
|
|
self.image = pygame.image.load(House_image.plastic_metal.value) #plastik, metal
|
|
else:
|
|
self.image = pygame.image.load(House_image.plastic.value) #plastik
|
|
elif(self.rubbish[GLASS] > self.max_glass):
|
|
if(self.rubbish[METAL] > self.max_metal):
|
|
self.image = pygame.image.load(House_image.glass_metal.value) #szklo, metal
|
|
else:
|
|
self.image = pygame.image.load(House_image.glass.value) #szklo
|
|
elif(self.rubbish[METAL] > self.max_metal):
|
|
self.image = pygame.image.load(House_image.metal.value) #metal
|
|
|
|
def give_away_rubbish(self, plastic, glass, metal):
|
|
self.rubbish[PLASTIC] -= plastic
|
|
self.rubbish[GLASS] -= glass
|
|
self.rubbish[METAL] -= metal
|
|
|
|
def check_rubbish_status(self):
|
|
print("plastic: " + str(self.rubbish[PLASTIC]) + " glass: " + str(
|
|
self.rubbish[GLASS]) + " metal: " + str(self.rubbish[METAL]))
|
|
|
|
def get_rubbish_data(self):
|
|
return self.rubbish
|