43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
import os
|
|
import random
|
|
|
|
from core.piece import Piece
|
|
import pygame
|
|
|
|
|
|
class Mushroom(Piece):
|
|
def __init__(self, x_y, img=0, grow=100):
|
|
self.name = "Mushroom"
|
|
self.col = x_y[0]
|
|
self.row = x_y[1]
|
|
self.grow = grow
|
|
|
|
self.isRed = bool(random.getrandbits(1))
|
|
self.hasRing = bool(random.getrandbits(1))
|
|
self.hasEmptyCore = bool(random.getrandbits(1))
|
|
self.hasDots = bool(random.getrandbits(1))
|
|
self.hasLamella = bool(random.getrandbits(1))
|
|
self.isShiftingColor = bool(random.getrandbits(1))
|
|
self.hasUnpleasantSmell = bool(random.getrandbits(1))
|
|
self.hasSlime = bool(random.getrandbits(1))
|
|
|
|
self.img = pygame.image.load(r'core' + os.path.sep + 'resources' + os.path.sep + 'mushrooms' +
|
|
os.path.sep + 'm' + str(img) + '.png')
|
|
|
|
poison = (int(self.isRed) + int(self.hasRing) + int(self.hasEmptyCore) + int(self.hasDots) + int(
|
|
self.hasLamella) + int(self.isShiftingColor) + int(self.hasUnpleasantSmell) + int(self.hasSlime)) > 4
|
|
if poison:
|
|
self.img = pygame.image.load(r'core' + os.path.sep + 'resources' + os.path.sep + 'mushrooms' +
|
|
os.path.sep + 'pm' + str(img) + '.png')
|
|
|
|
self.points = img + 1
|
|
if poison:
|
|
self.points *= -1
|
|
|
|
def draw(self, win, square_size):
|
|
x = (self.col + 0.5 * (100 - self.grow) / 100) * square_size[0]
|
|
y = (self.row + 0.5 * (100 - self.grow) / 100) * square_size[1]
|
|
win.blit(pygame.transform.scale(self.img,
|
|
(int(square_size[0] / 100 * self.grow), int(square_size[1] / 100 * self.grow))),
|
|
(x, y))
|