Campaign have a recommended defaults faction setup to ease campaign setup

This commit is contained in:
Khopa 2021-01-22 22:09:55 +01:00
parent 444605920f
commit f959dd0519
16 changed files with 66 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import json
import logging
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Dict, List
from typing import Any, Dict, List, Union
from PySide2 import QtGui
from PySide2.QtCore import QItemSelectionModel
@ -14,6 +14,10 @@ from PySide2.QtWidgets import QAbstractItemView, QListView
import qt_ui.uiconstants as CONST
from game.theater import ConflictTheater
PERF_FRIENDLY = 0
PERF_MEDIUM = 1
PERF_HARD = 2
PERF_NASA = 3
@dataclass(frozen=True)
class Campaign:
@ -21,6 +25,9 @@ class Campaign:
icon_name: str
authors: str
description: str
recommended_player_faction: str
recommended_enemy_faction: str
performance: Union[PERF_FRIENDLY, PERF_MEDIUM, PERF_HARD, PERF_NASA]
data: Dict[str, Any]
path: Path
@ -35,6 +42,9 @@ class Campaign:
f"Terrain_{sanitized_theater}",
data.get("authors", "???"),
data.get("description", ""),
data.get("recommended_player_faction", "USA 2005"),
data.get("recommended_enemy_faction", "Russia 1990"),
data.get("performance", 0),
data,
path
)

View File

@ -39,9 +39,10 @@ class NewGameWizard(QtWidgets.QWizard):
self.campaigns = load_campaigns()
self.faction_selection_page = FactionSelection()
self.addPage(IntroPage())
self.addPage(FactionSelection())
self.addPage(TheaterConfiguration(self.campaigns))
self.addPage(TheaterConfiguration(self.campaigns, self.faction_selection_page))
self.addPage(self.faction_selection_page)
self.addPage(GeneratorOptions())
self.addPage(DifficultyAndAutomationOptions())
self.addPage(ConclusionPage())
@ -195,6 +196,24 @@ class FactionSelection(QtWidgets.QWizardPage):
self.blueFactionSelect.activated.connect(self.updateUnitRecap)
self.redFactionSelect.activated.connect(self.updateUnitRecap)
def setDefaultFactions(self, campaign:Campaign):
""" Set default faction for selected campaign """
self.blueFactionSelect.clear()
self.redFactionSelect.clear()
for f in db.FACTIONS:
self.blueFactionSelect.addItem(f)
for i, r in enumerate(db.FACTIONS):
self.redFactionSelect.addItem(r)
if r == campaign.recommended_enemy_faction:
self.redFactionSelect.setCurrentIndex(i)
if r == campaign.recommended_player_faction:
self.blueFactionSelect.setCurrentIndex(i)
def updateUnitRecap(self):
red_faction = db.FACTIONS[self.redFactionSelect.currentText()]
@ -233,9 +252,11 @@ class FactionSelection(QtWidgets.QWizardPage):
class TheaterConfiguration(QtWidgets.QWizardPage):
def __init__(self, campaigns: List[Campaign], parent=None) -> None:
def __init__(self, campaigns: List[Campaign], faction_selection: FactionSelection, parent=None) -> None:
super().__init__(parent)
self.faction_selection = faction_selection
self.setTitle("Theater configuration")
self.setSubTitle("\nChoose a terrain and time period for this game.")
self.setPixmap(QtWidgets.QWizard.LogoPixmap,
@ -258,6 +279,7 @@ class TheaterConfiguration(QtWidgets.QWizardPage):
campaign = campaignList.campaigns[index]
self.setField("selectedCampaign", campaign)
self.campaignMapDescription.setText(template.render({"campaign": campaign}))
self.faction_selection.setDefaultFactions(campaign)
campaignList.selectionModel().setCurrentIndex(campaignList.indexAt(QPoint(1, 1)), QItemSelectionModel.Rows)
campaignList.selectionModel().selectionChanged.connect(on_campaign_selected)

View File

@ -2,6 +2,8 @@
"name": "The Channel - Battle of Britain",
"theater": "The Channel",
"authors": "Khopa",
"recommended_player_faction": "United Kingdom 1944",
"recommended_enemy_faction": "Germany 1942",
"description": "<p>Experience the Battle of Britain on the Channel map !<br/></p><p><strong>Note:</strong> It is not possible to cross the channel to capture enemy bases yet, but you can consider you won if you manage to destroy all the ennemy targets</p>",
"miz": "battle_of_britain.miz"
}

View File

@ -2,6 +2,8 @@
"name": "Persian Gulf - Desert War",
"theater": "Persian Gulf",
"authors": "Khopa",
"recommended_player_faction": "USA 2005",
"recommended_enemy_faction": "Iran 2015",
"description": "<p>This is a simple scenario in the Desert near Dubai and Abu-Dhabi. Progress from Liwa airbase to Al-Minhad.</p><p>This scenario shouldn't require too much performance.</p>",
"miz": "desert_war.miz"
}

View File

@ -2,6 +2,8 @@
"name": "The Channel - Dunkirk",
"theater": "The Channel",
"authors": "Khopa",
"recommended_player_faction": "Allies 1944",
"recommended_enemy_faction": "Germany 1942",
"description": "<p>In this scenario, your forces starts in Dunkirk and can be supported by the airfields on the other side of the Channel.</p><p>If you select the inverted configuration, you can play a German invasion of England.</p><p><strong>Note:</strong> B-17 should be operated from Manston airfield</p>",
"miz": "dunkirk.miz"
}

View File

@ -2,6 +2,8 @@
"name": "Persian Gulf - Emirates",
"theater": "Persian Gulf",
"authors": "Khopa",
"recommended_player_faction": "USA 2005",
"recommended_enemy_faction": "Iran 2015",
"description": "<p>In this scenario, you can play an invasion of the Emirates and Oman, where your forces starts in Fujairah.</p><p><strong>Note:</strong> Fujairah airfield has very few slots for aircrafts, so it recommended to operate from carriers at the start of the campaign. Thus, a carrier-capable faction is recommended.</p>",
"miz": "emirates.miz"
}

View File

@ -2,6 +2,8 @@
"name": "Syria - Battle for Golan Heights",
"theater": "Syria",
"authors": "Khopa",
"recommended_player_faction": "Israel 2000",
"recommended_enemy_faction": "Syria 2011",
"description": "<p>In this scenario, you start in Israel and the conflict is focused around the golan heights, an historically disputed territory.<br/><br/>You can use the inverted configuration to start on the Syrian side.<br/><br/>If this scenario is too heavy, try the lite version.</p>",
"miz": "golan_heights.miz"
}

View File

@ -2,6 +2,8 @@
"name": "Syria - Battle for Golan Heights - Lite",
"theater": "Syria",
"authors": "Khopa",
"recommended_player_faction": "Israel 2000",
"recommended_enemy_faction": "Syria 2011",
"description": "<p>In this scenario, you start in Israel and the conflict is focused around the golan heights, an historically disputed territory.<br/><br/>This scenario is designed to be performance friendly.</p>",
"miz": "golan_heights_lite.miz"
}

View File

@ -2,6 +2,8 @@
"name": "Syria - Inherent Resolve",
"theater": "Syria",
"authors": "Khopa",
"recommended_player_faction": "USA 2005",
"recommended_enemy_faction": "Insurgents (Hard)",
"description": "<p>In this scenario, you start from Jordan, and have to fight your way through eastern Syria.</p>",
"miz": "inherent_resolve.miz"
}

View File

@ -2,6 +2,8 @@
"name": "Syria - Invasion from Turkey",
"theater": "Syria",
"authors": "Khopa",
"recommended_player_faction": "Turkey 2005",
"recommended_enemy_faction": "Insurgents (Hard)",
"description": "<p>In this scenario, you start from Turkey and have to invade territories in northern Syria.</p>",
"miz": "invasion_from_turkey.miz"
}

View File

@ -2,6 +2,8 @@
"name": "Persian Gulf - Invasion of Iran",
"theater": "Persian Gulf",
"authors": "Khopa",
"recommended_player_faction": "USA 2005",
"recommended_enemy_faction": "Iran 2015",
"description": "<p>In this scenario, you start in Bandar Abbas, and must invade Iran.</p>",
"miz": "invasion_of_iran.miz"
}

View File

@ -2,6 +2,8 @@
"name": "Persian Gulf - Invasion of Iran [Lite]",
"theater": "Persian Gulf",
"authors": "Khopa",
"recommended_player_faction": "USA 2005",
"recommended_enemy_faction": "Iran 2015",
"description": "<p>This is lighter version of the invasion of Iran scenario.</p>",
"miz": "invasion_of_iran_lite.miz"
}

View File

@ -2,6 +2,9 @@
"name": "Normandy - Normandy",
"theater": "Normandy",
"authors": "Khopa",
"recommended_player_faction": "Allies 1944",
"recommended_enemy_faction": "Germany 1944",
"performance": 3,
"description": "<p>Normandy 1944 D-Day scenario.</p>",
"miz":"normandy.miz"
}

View File

@ -2,6 +2,8 @@
"name": "Normandy - Normandy Small",
"theater": "Normandy",
"authors": "Khopa",
"recommended_player_faction": "Allies 1944",
"recommended_enemy_faction": "Germany 1944",
"description": "<p>A lighter version of the Normandy 1944 D-Day scenario.</p>",
"miz": "normandy_small.miz"
}

View File

@ -2,6 +2,9 @@
"name": "Caucasus - Russia Small",
"theater": "Caucasus",
"authors": "Khopa",
"recommended_player_faction": "Russia 2010",
"recommended_enemy_faction": "USA 1990",
"performance": "heavy",
"description": "<p>A small theater in Russia, progress from Mozdok to Maykop.</p><p>This scenario is pretty simple, it is ideal if you want to run a short campaign. If your PC is not powerful, this is also the less performance heavy scenario.</p>",
"miz": "russia_small.miz"
}

View File

@ -2,6 +2,8 @@
"name": "Syria - Syrian Civil War",
"theater": "Syria",
"authors": "Khopa",
"recommended_player_faction": "Russia 2010",
"recommended_enemy_faction": "Insurgents (Hard)",
"description": "<p>This scenario can be used to simulate parts of the Syrian Civil War.<br/><br/>You start on the coast with an airbase in Latakia, and ground forces in Tartus.<br/><br/>This scenario can also be used to simulate a western invasion of Syria.<br/><br/>In inverted configuration you start in Aleppo.</p>",
"miz": "syrian_civil_war.miz"
}