summaryrefslogtreecommitdiff
path: root/src/sliceitoff/field/field.py
diff options
context:
space:
mode:
authorViljami Ilola <+@hix.fi>2024-03-29 00:30:39 +0200
committerViljami Ilola <+@hix.fi>2024-03-29 00:30:39 +0200
commit5c5df6e068b2957987cb51b34d6930769424f8ca (patch)
tree1f6ce6ff479ee787a3da6f51a9c337bcd24b841a /src/sliceitoff/field/field.py
parent27c7e16e4bd808ce1176f18b7a78c02ff4fa88ee (diff)
stats as object
Diffstat (limited to 'src/sliceitoff/field/field.py')
-rw-r--r--src/sliceitoff/field/field.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/sliceitoff/field/field.py b/src/sliceitoff/field/field.py
index 82391d6..5769bfc 100644
--- a/src/sliceitoff/field/field.py
+++ b/src/sliceitoff/field/field.py
@@ -3,11 +3,9 @@ import pygame
from random import randrange
from display import Scaling, INTERNAL_WIDTH, INTERNAL_HEIGHT
-from stats import Stats
DEBUG = os.getenv("DEBUG")
-
class FieldSprite(pygame.sprite.Sprite):
def __init__(self, area: tuple):
super().__init__()
@@ -67,19 +65,20 @@ class ExplodedField(FieldSprite):
class Field(pygame.sprite.LayeredUpdates):
initial_area = (320_000, 220_000)
- def __init__(self):
+ def __init__(self, stats = None):
super().__init__()
self.add(FieldSprite( (0, 0, *__class__.initial_area) ))
self.area_full = __class__.initial_area[0] * __class__.initial_area[1]
+ self.stats = stats
def calculate_current_area(self):
return sum( s.area[2]*s.area[3] for s in self.active_sprites() )
def update_stats(self):
""" calculates remaining area and remaining percentage """
- Stats.percent = 100 * self.calculate_current_area() / self.area_full
+ self.stats.percent = 100 * self.calculate_current_area() / self.area_full
if DEBUG:
- print(f"FIELD: {Stats.percent}")
+ print(f"FIELD: {self.stats.percent}")
def slice(
self,
@@ -152,4 +151,4 @@ class Field(pygame.sprite.LayeredUpdates):
else:
self.explode(field.area)
field.remove(self)
- Stats.field_count=len(self.active_sprites())
+ self.stats.field_count=len(self.active_sprites())