just some refactor, a line is misplaced
All checks were successful
CI/CD / wol (push) Successful in 0s
CI/CD / build (push) Successful in 9m23s

This commit is contained in:
2025-08-27 21:45:59 +02:00
parent 50b783c1df
commit 7adb7ed34a
2 changed files with 24 additions and 15 deletions

View File

@@ -1,4 +1,5 @@
import logging
import random
from PySide6.QtCore import QRectF, Qt
from PySide6.QtGui import QBrush, QPainter, QPen
@@ -59,6 +60,23 @@ class AgilitySphereGraphicsItem(SphereGraphicsItem):
def __init__(self, x_pos: int, y_pos: int) -> None:
super().__init__(x_pos, y_pos, Qt.GlobalColor.darkYellow)
class EmptySphereGraphicsItem(SphereGraphicsItem):
def __init__(self, x_pos: int, y_pos: int) -> None:
self.SPHERE_WIDTH = 20
super().__init__(x_pos, y_pos, Qt.GlobalColor.black)
@staticmethod
def random_sphere_factory(x_pos: int, y_pos: int) -> SphereGraphicsItem:
rand = random.random()
if rand > 3 / 4:
obj = SphereGraphicsItem(x_pos, y_pos)
elif rand > 2 / 4:
obj = AgilitySphereGraphicsItem(x_pos, y_pos)
elif rand > 1 / 4:
obj = StrenghSphereGraphicsItem(x_pos, y_pos)
else:
obj = EmptySphereGraphicsItem(x_pos, y_pos)
return obj
class ArcGraphicsItem(QGraphicsItem):
"""Circle arc."""

View File

@@ -1,5 +1,4 @@
import math
import random
from typing import List, Tuple
@@ -14,12 +13,10 @@ from PySide6.QtWidgets import (
)
from grid.ui.items import (
AgilitySphereGraphicsItem,
HPSphereGraphicsItem,
SphereGraphicsItem,
ArcGraphicsItem,
LineGraphicsItem,
StrenghSphereGraphicsItem,
random_sphere_factory,
)
@@ -47,10 +44,10 @@ class Pattern(QGraphicsItemGroup):
LineGraphicsItem(line_start_x, line_start_y, line_end_x, line_end_y, self)
)
line_start_x = top_left_corner_x + center_x
line_start_x = center_x
line_start_y = top_left_corner_y + self.SPACE_BETWEEN_SPHERE * 1.5
line_end_x = top_left_corner_x + center_x
line_end_y = top_left_corner_y + self.SPACE_BETWEEN_SPHERE * 2.5
line_end_x = center_x
line_end_y = top_left_corner_y + self.SPACE_BETWEEN_SPHERE # * 2.5
self.addToGroup(
LineGraphicsItem(line_start_x, line_start_y, line_end_x, line_end_y, self)
)
@@ -74,13 +71,7 @@ class Pattern(QGraphicsItemGroup):
center_x, center_y, self.SPACE_BETWEEN_SPHERE, sphere_on_circle
)
for x, y in points:
rand = random.random()
if rand > 2 / 3:
self.addToGroup(SphereGraphicsItem(x, y))
elif rand > 1 / 3:
self.addToGroup(AgilitySphereGraphicsItem(x, y))
else:
self.addToGroup(StrenghSphereGraphicsItem(x, y))
self.addToGroup(random_sphere_factory(x, y))
# second cercle
sphere_on_circle = 8
@@ -99,7 +90,7 @@ class Pattern(QGraphicsItemGroup):
)
)
for x, y in points:
self.addToGroup(SphereGraphicsItem(x, y))
self.addToGroup(random_sphere_factory(x, y))
# self.addToGroup(
# ArcGraphicsItem(
# center_x, center_y, self.SPACE_BETWEEN_SPHERE * 2, 0, 90, self