From bc6b2e0f3edbf424e2c1732d56e5f429f1e3b57b Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Mon, 4 Jan 2021 15:57:37 -0800 Subject: [PATCH] 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. --- qt_ui/main.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/qt_ui/main.py b/qt_ui/main.py index 09620098..0371dee8 100644 --- a/qt_ui/main.py +++ b/qt_ui/main.py @@ -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,