type hinting and comment cleanup

This commit is contained in:
walterroach
2020-11-03 16:21:15 -06:00
committed by Dan Albert
parent 9087f3487d
commit 1f165835c6
9 changed files with 74 additions and 52 deletions

View File

@@ -1,14 +1,23 @@
from __future__ import annotations
import math
import random
from typing import TYPE_CHECKING, Optional
from dcs import unitgroup
from dcs.point import PointAction
from dcs.unit import Vehicle, Ship
from dcs.unittype import VehicleType
from game.factions.faction import Faction
from theater.theatergroundobject import TheaterGroundObject
if TYPE_CHECKING:
from game.game import Game
class GroupGenerator():
def __init__(self, game, ground_object, faction = None): # faction is not mandatory because some subclasses do not use it
def __init__(self, game: Game, ground_object: TheaterGroundObject, faction: Optional[Faction] = None): # faction is not mandatory because some subclasses do not use it
self.game = game
self.go = ground_object
self.position = ground_object.position
@@ -28,8 +37,7 @@ class GroupGenerator():
def get_generated_group(self):
return self.vg
def add_unit(self, unit_type, name, pos_x, pos_y, heading):
def add_unit(self, unit_type: VehicleType, name: str, pos_x: float, pos_y: float, heading: int):
nn = "cgroup|" + str(self.go.cp_id) + '|' + str(self.go.group_id) + '|' + str(self.go.group_identifier) + "|" + name
unit = Vehicle(self.game.next_unit_id(),
@@ -77,7 +85,7 @@ class GroupGenerator():
class ShipGroupGenerator(GroupGenerator):
"""Abstract class for other ship generator classes"""
def __init__(self, game, ground_object, faction):
def __init__(self, game: Game, ground_object: TheaterGroundObject, faction: Faction):
self.game = game
self.go = ground_object
self.position = ground_object.position