Add warning for missing weapon data.

These are disabled by default because it would otherwise warn about
nearly every piece of equipment in the game currently.
This commit is contained in:
Dan Albert 2021-01-04 15:57:37 -08:00
parent 746c99ebd6
commit bc6b2e0f3e

View File

@ -7,11 +7,18 @@ from pathlib import Path
from typing import Optional
import dcs
from dcs.weapons_data import weapon_ids
from PySide2 import QtWidgets
from PySide2.QtGui import QPixmap
from PySide2.QtWidgets import QApplication, QSplashScreen
from game import Game, db, persistency, VERSION
from game.data.weapons import (
WEAPON_FALLBACK_MAP,
WEAPON_INTRODUCTION_YEARS,
Weapon,
)
from game.settings import Settings
from game.theater.start_generator import GameGenerator, GeneratorSettings
from qt_ui import (
@ -103,6 +110,11 @@ def parse_args() -> argparse.Namespace:
raise argparse.ArgumentTypeError("path does not exist")
return path
parser.add_argument(
"--warn-missing-weapon-data", action="store_true",
help="Emits a warning for weapons without date or fallback information."
)
new_game = subparsers.add_parser("new-game")
new_game.add_argument(
@ -163,6 +175,15 @@ def create_game(campaign_path: Path, blue: str, red: str,
return generator.generate()
def lint_weapon_data() -> None:
for clsid in weapon_ids:
weapon = Weapon.from_clsid(clsid)
if weapon not in WEAPON_INTRODUCTION_YEARS:
logging.warning(f"{weapon} has no introduction date")
if weapon not in WEAPON_FALLBACK_MAP:
logging.warning(f"{weapon} has no fallback")
def main():
logging_config.init_logging(VERSION)
@ -172,6 +193,11 @@ def main():
game: Optional[Game] = None
args = parse_args()
# TODO: Flesh out data and then make unconditional.
if args.warn_missing_weapon_data:
lint_weapon_data()
if args.subcommand == "new-game":
game = create_game(args.campaign, args.blue, args.red,
args.supercarrier, args.auto_procurement,