mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
typing and comment cleanup
This commit is contained in:
parent
253e8a209c
commit
ecd073e31d
@ -460,7 +460,7 @@ class GroundConflictGenerator:
|
||||
|
||||
def get_valid_position_for_group(self, conflict_position, isplayer, combat_width, distance_from_frontline):
|
||||
i = 0
|
||||
while i < 1000: # 25 attempt for valid position
|
||||
while i < 1000:
|
||||
heading_diff = -90 if isplayer else 90
|
||||
shifted = conflict_position[0].point_from_heading(self.conflict.heading,
|
||||
random.randint((int)(-combat_width / 2), (int)(combat_width / 2)))
|
||||
@ -468,9 +468,8 @@ class GroundConflictGenerator:
|
||||
|
||||
if self.conflict.theater.is_on_land(final_position):
|
||||
return final_position
|
||||
else:
|
||||
i = i + 1
|
||||
continue
|
||||
i += 1
|
||||
continue
|
||||
return None
|
||||
|
||||
def _generate_group(self, side: Country, unit: VehicleType, count: int, at: Point, move_formation: PointAction = PointAction.OffRoad, heading=0):
|
||||
|
||||
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
import datetime
|
||||
import logging
|
||||
import math
|
||||
from typing import List, Optional, Tuple
|
||||
from typing import Iterable, List, Optional, Tuple, Iterator
|
||||
|
||||
from PySide2.QtCore import QPointF, Qt
|
||||
from PySide2.QtGui import (
|
||||
@ -47,18 +47,18 @@ from theater.theatergroundobject import (
|
||||
TheaterGroundObject,
|
||||
)
|
||||
|
||||
def binomial(i, n):
|
||||
def binomial(i: int, n: int) -> float:
|
||||
"""Binomial coefficient"""
|
||||
return math.factorial(n) / float(
|
||||
math.factorial(i) * math.factorial(n - i))
|
||||
|
||||
|
||||
def bernstein(t, i, n):
|
||||
def bernstein(t: float, i: int, n: int) -> float:
|
||||
"""Bernstein polynom"""
|
||||
return binomial(i, n) * (t ** i) * ((1 - t) ** (n - i))
|
||||
|
||||
|
||||
def bezier(t, points):
|
||||
def bezier(t: float, points: Iterable[Tuple[float, float]]) -> Tuple[float, float]:
|
||||
"""Calculate coordinate of a point in the bezier curve"""
|
||||
n = len(points) - 1
|
||||
x = y = 0
|
||||
@ -69,7 +69,7 @@ def bezier(t, points):
|
||||
return x, y
|
||||
|
||||
|
||||
def bezier_curve_range(n, points):
|
||||
def bezier_curve_range(n: int, points: Iterable[Tuple[float, float]]) -> Iterator[Tuple[float, float]]:
|
||||
"""Range of points in a curve bezier"""
|
||||
for i in range(n):
|
||||
t = i / float(n - 1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user