Madra_smieciarka/classes/Garbagetruck.py
Neerka e02adf16b6 grid works + little adjustments
Signed-off-by: Neerka <jakub.markil1@gmail.com>
2024-03-25 14:26:41 +01:00

125 lines
3.1 KiB
Python

import pygame
from classes.Household import *
from classes.Trashcan import *
class Garbagetruck:
def __init__(self, file="sprites/garbage_truck.png"):
self.capacity: int = 20
self.trash: list = []
self.trashweight: int = 0
self.image = pygame.image.load(file).convert_alpha()
self.image = pygame.transform.scale(self.image, (32, 32))
self.position = [3, 3]
self.predicts: set = set()
self.others: set = set()
self.state = 0
self.route = None
self.scanner = None
self.planner = None
self.driver = None
def getOthers(self):
return self.others
def setOthers(self, others):
self.others = others
return self
def setPredicts(self, predicts):
self.predicts = predicts
return self
def getPredicts(self):
return self.predicts
def getCapacity(self) -> int:
return self.capacity
def getTrash(self) -> list:
return self.trash
def setTrash(self, trash: list) -> None:
self.trash = trash
for item in trash:
self.addTrashweight(item.getWaga)
def addTrash(self, trash: Trash) -> None:
self.trash.append(trash)
self.addTrashweight(trash.getWaga())
def removeTrash(self, trashid: int) -> object:
trash = self.trash.pop(trashid)
self.addTrashweight(trash.getWeight * (-1))
return trash
def getTrashweight(self) -> int:
return self.trashweight
def setTrashweight(self, weight: int) -> None:
self.trashweight = weight
def addTrashweight(self, weight: int) -> None:
self.trashweight += weight
def getImage(self) -> object:
return self.image
def setImage(self, image: object) -> None:
self.image = image
def getPosition(self) -> list:
return self.position
def setPosition(self, position: list) -> object:
self.position = position
return self
def modPosiotion(self, modX, modY):
x = self.getPosition()[0] + modX
y = self.getPosition()[1] + modY
self.setPosition([x, y])
def getRoute(self):
return self.route
def setRoute(self, route) -> None:
self.route = route
def getScanner(self):
return self.scanner
def setScanner(self, scanner) -> None:
self.route = scanner
def getPlanner(self):
return self.planner
def setPlanner(self, planner) -> None:
self.route = planner
def getDriver(self):
return self.driver
def setDriver(self, driver) -> None:
self.route = driver
def distance(self, object1, object2) -> int:
lok1 = object1.getPosition()
lok2 = object2.getPosition()
dist = abs(lok1[0] - lok2[0]) + abs(lok1[1] - lok2[1])
return dist
def scanTile(self):
self.state = 0
for loc in self.others:
if tuple(self.position) == loc.getPosition():
self.state = loc
return
def printme(self):
x, y = self.getPosition()
return 32*x, 32*y