253 Commits

Author SHA1 Message Date
Dan Albert
9d43eb8f03 Handle game over.
The contents are completely uninteresting, but at least it's visible.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/978.
2023-06-12 23:43:26 -07:00
Dan Albert
799dbfa99c Move and split up weather.py.
This is getting out of hand, and I'm about to make it worse.
2023-05-16 00:52:51 -07:00
Dan Albert
ca96a232f0 Revert "Use the actual Country type instead of the name."
This reverts commit bd2ec12e0f039c9500ea0dd94e7b2e4f7d168fef.

Country is both the data (name, ID, etc) and the container for groups
added to the miz, so it can't be used across multiple mission
generations. See https://github.com/pydcs/dcs/issues/314 for potential
follow up work that would let us do this.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2864.
2023-05-15 18:23:48 -07:00
Dan Albert
bd2ec12e0f Use the actual Country type instead of the name.
We want other pieces of country information (in particular the short
names). This cleans up a lot of code anyway.

As an added bonus, this now catches squadrons that used invalid names
which would previously be passed through to pydcs and... then I don't
know what would happen.
2023-05-12 22:18:40 -07:00
Dan Albert
15fa73a514 Add option to limit squadron sizes and begin full.
Adding temporarily as an option to make sure it's not a terrible idea,
but the old mode will probably go away.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1583.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2808.
2023-05-05 18:16:42 -07:00
Dan Albert
77f1706cbb Extract plugins from settings.
There isn't really any need for these two types to interact. The lua
plugin manager effectively fully owned its properties, it just delegated
all reads and writes to the settings object.

Instead, break the plugin settings out into the plugin manager and
preserve the manager in the Game. This will make it possible to expose
plugin options in the NGW without breaking the game on cancel.
2023-04-25 23:28:01 -07:00
Dan Albert
4e067eaaa8 Remove GroundPlanners from the save state.
These are only used during mission generation. Remove them from the save
state to reduce compatibility requirements. We also have at least one
report of this data being corrupted... somehow. I don't know how that
could have happened, but if there's no data to corrupt in the first
place that's not a problem. If the corruption _does_ recur, it'll be
much easier to repro if it corrupts during mission generation rather
than during turn initialization.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2729.
2023-04-15 14:27:20 -07:00
Dan Albert
0f34946127 Restructure save games into a zipped bundle.
This is the first step toward bundling all assets related to a save game
into a single item. That makes it easier to avoid clobbering "temporary"
assets from other games like the state.json, but also makes it easier
for players to file bug reports, since there's only a single asset to
upload.

This is only the first step because so far it only includes the various
save files: start of turn, end of last turn before results processing,
and "latest" (the game saved explicitly by the player).
2023-01-16 13:59:16 -08:00
Dan Albert
4b542b70ae Fix post-results "last turn" save. 2023-01-04 15:15:56 -08:00
Dan Albert
22503d4e95 Save the last turn for bug reports.
We often get save games uploaded with bug reports that are already in a
broken state with nothing we can do about it. This saves that turn to
`last_turn.liberation` so users are less likely to have clobbered the
useful data before filing the report.
2022-12-20 13:46:21 -08:00
Dan Albert
db7cd17c10 Send the new turn event from turn initialization.
We'll have to get smarter about this some day (since turn initialization
won't always exist), but for now we can avoid stale UI data by doing
what we've always done and refreshing the world on turn init.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2397.
2022-10-15 14:47:55 -07:00
Dan Albert
f15c2ada1b Fix DaytimeMap error with disabled night missions.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2429
2022-09-09 13:01:10 -07:00
Dan Albert
c630226e2d Add campaign property for campaign start time.
This field is optional. Omitting the field (or using only a date instead
of a full timestamp) will use the old behavior of picking a random
daylight hour to start the campaign.

This doesn't include any UI in the new game wizard yet. This is only a
campaign yaml option.

https://github.com/dcs-liberation/dcs_liberation/issues/2400
2022-09-01 01:13:01 -07:00
Dan Albert
f49833646d Don't advance the clock between turn 0 and turn 1.
Turn 0 isn't a real thing, it's just a game play affordance that allows
players to set up their initial conditions.
2022-09-01 00:52:51 -07:00
Raffson
289545e777
Push full unculled zone information in the event stream.
https://github.com/dcs-liberation/dcs_liberation/issues/2263
2022-06-25 21:09:07 +00:00
Raffson
ad7032064d
Add culling exclusion zones display to the new map.
https://github.com/dcs-liberation/dcs_liberation/issues/2158
2022-06-14 18:57:04 -07:00
RndName
a10e55cfd7
Calculate orientation of specific TGOs automatically
This will allow to automatically calculate the orientation of TGOs which are required to head to the conflict if the campaign designer has not defined a specific heading in the campaign miz. This is for example required for silkworm, scuds or some SAM systems like the SA-11.
Added the should_head_to_conflict property to the TGO
2022-05-06 17:34:16 +02:00
RndName
5cdfe62e2d Implement advanced skynet functions
- factor out own class for the iadsnetwork within the conflicttheater
- This class will handle all Skynet related things - no specific group_name handling necessary in future
- make iadsbuilding own TGO class because SAM & EWRs are Vehicle Groups. IADS Elements dont have any groups attached.
- added command center, connection node and power source as Ground objects which can be added by the campaign designer
- adjust lua generator to support new iads units
- parse the campaign yaml to get the iads network information
- use the range as fallback if no yaml information was found
- complete rewrite of the skynet lua script
- allow destruction of iads network to be persistent over all rounds
- modified the presetlocation handling: the wrapper PresetLocation for PointWithHeading now stores the original name from the campaign miz to have the ability to process campaign yaml configurations based on the ground unit
- Implementation of the UI representation for the IADS Network
- Give user the option to enable or disable advanced iads
- Extended the layout system: Implement Sub task handling to support PD
2022-04-19 10:41:16 +02:00
Dan Albert
039ac9ec74 Replace CP integer ID with a UUID.
This allows unique identification across saves. The front-end needs to
be able to differentiate the first carrier in game A and the first
carrier in game B, but because carriers (and other non-airfield CPs) are
assigned IDs sequentially, collisions were to be expected. The front-end
can't tell the difference between a reloaded game and a new turn, so we
need to ensure different IDs across games.

This is a handy cleanup anyway, since callers constructing CPs no longer
need to manually track the CP ID counter.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/2078.
2022-03-20 16:00:29 -07:00
Dan Albert
738cf1f381 Reset game state on new turn.
This may not be the way to do this long term, but it is how the old map
works so it's at least not a regression. It might be better to generate
events for the between-turn changes in state instead.

https://github.com/dcs-liberation/dcs_liberation/issues/2039
2022-03-06 00:02:25 -08:00
Dan Albert
c5c596dc2f Move TGOs out of MapModel. 2022-03-03 17:11:01 -08:00
Dan Albert
ccb510fe47 Move front lines out of MapModel. 2022-03-03 02:17:13 -08:00
Dan Albert
e5f4974e9a Stop ad-hoc constructing FrontLines.
The UI needs to be able to identify these to the server and vice versa,
so they'll need IDs that don't change. Rather than constructing an ID
based on the control points names, make them an owned part of the
control point. The constructed ID would be fine, but a UUID will make
them more suitable for the database, and this was always fairly gross
anyway.

Some follow up work if anyone is interested: a bunch of the data that's
computed in the various properties can now probably be computed *once*
and persisted to the FrontLine type.
2022-03-03 00:38:52 -08:00
Dan Albert
b1356551c6 Move threat zones out of MapModel. 2022-02-22 19:59:29 -08:00
Dan Albert
0e6a303c17 Move NavMesh out of MapModel. 2022-02-22 18:49:12 -08:00
Dan Albert
9e2e4ffa74 Update pydcs, adapt to new Point APIs.
This is briefly moving us over to my fork of pydcs while we wait for
https://github.com/pydcs/dcs/pull/206 to be merged. The adaptation is
invasive enough that I don't want it lingering for long.
2022-02-23 01:02:48 +00:00
Dan Albert
ac80c4adc1 Finish moving gen into game. 2022-02-22 00:10:31 -08:00
Dan Albert
df7be8603b Clean up some uses of Point to prep for update. 2022-02-21 18:12:59 -08:00
RndName
2c17a9a52e Refactor Templates to Layouts, Review and Cleanup
- Fix tgogenerator
- Fix UI for ForceGroup and Layouts
- Fix ammo depot handling
- Split bigger files in smaller meaningful files (TGO, layouts, forces)
- Renamed Template to Layout
- Renamed GroundGroup to TheaterGroup and GroundUnit to TheaterUnit
- Reorganize Layouts and UnitGroups to a ArmedForces class and ForceGroup similar to the AirWing and Squadron
- Reworded the UnitClass, GroupRole, GroupTask (adopted to PEP8) and reworked the connection from Role and Task
- added comments
- added missing unit classes
- added temp workaround for missing classes
- add repariable property to TheaterUnit
- Review and Cleanup

Added serialization for loaded templates

Loading the templates from the .miz files takes a lot of computation time and in the future there will be more templates added to the system. Therefore a local pickle serialization for the loaded templates was re-added:
- The pickle will be created the first time the TemplateLoader will be accessed
- Pickle is stored in Liberation SaveDir
- Added UI option to (re-)import templates
2022-02-21 20:45:41 +01:00
RndName
d154069877 Refactor ground objects and prepare template system
- completly refactored the way TGO handles groups and replaced the usage of the pydcs ground groups (vehicle, ship, static) with an own Group and Unit class.
- this allows us to only take care of dcs group generation during miz generation, where it should have always been.
- We can now have any type of unit (even statics) in the same logic ground group we handle in liberation. this is independent from the dcs group handling. the dcs group will only be genarted when takeoff is pressed.
- Refactored the unitmap and the scenery object handling to adopt to changes that now TGOs can hold all Units we want.
- Cleaned up many many many lines of uneeded hacks to build stuff around dcs groups.
- Removed IDs for TGOs as the names we generate are unique and for liberation to work we need no ids. Unique IDs for dcs will be generated for the units and groups only.
2022-02-21 20:45:41 +01:00
Dan Albert
cba68549d8 Add a UUID -> Flight database to Game.
This will be expanded with other types as needed.
2022-02-19 12:57:41 -08:00
SnappyComebacks
3987f26689
Add performance option to not cull threatening IADS (#1953)
- Don't cull EWRs in detection range.
- Don't cull SAMs within threat range + small buffer.
2022-02-05 18:38:25 -07:00
leemarov
5d291846d5
Fix unculled zones not updating when needed.
Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1034.
2022-01-16 13:54:09 -08:00
Dan Albert
12f420f50e Pre-emptive Python 3.10 compat.
Iterator is no longer exposed directly in collections, but is in
collections.abc.
2021-11-20 18:49:14 -08:00
Dan Albert
b728fcc2d6 Clean up mission result handling. 2021-10-22 14:36:51 -07:00
Dan Albert
74291271e3 Move mission generation code into game.
Operation has been renamed MissionGenerator and is no longer a static
class.
2021-10-22 13:48:43 -07:00
Dan Albert
be69d17345 Move Flight and its related components out of gen. 2021-10-22 11:30:28 -07:00
Dan Albert
b174e668f4 Fix day being off-by-one on turn zero.
Doesn't have any real effect since no mission can be generated for that
turn, but shows up wrong in the top bar.
2021-10-17 17:33:29 -07:00
Khopa
e84e36fd22 Merge remote-tracking branch 'khopa/develop' into helipads
# Conflicts:
#	changelog.md
2021-09-08 21:56:45 +02:00
Dan Albert
45b52f4dea Remove auto-loss on front line for skipped turns. 2021-09-05 21:19:36 -07:00
Dan Albert
18336f58d3 Minor cleanup of notification system. 2021-09-05 21:15:32 -07:00
Dan Albert
4715773bba Store the owning coalition in ControlPoint.
This is needed fairly often, and we have a lot of Game being passed
around to ControlPoint methods specifically to support this. Just store
the owning Coalition directly in the ControlPoint to clean up. I haven't
cleaned up *every* API here, but did that aircraft allocations as an
example.
2021-08-28 16:40:55 -07:00
C. Perreau
707d13a65c
Merge branch 'develop' into helipads 2021-08-16 12:20:43 +02:00
Dan Albert
4423288a53 Assign aircraft to squadrons rather than bases.
This is needed to support the upcoming squadron transfers, since
squadrons need to bring their aircraft with them.

https://github.com/dcs-liberation/dcs_liberation/issues/1145
2021-08-15 17:42:56 -07:00
Dan Albert
90ad1f4a61 Change squadrons to operate out of a single base.
https://github.com/dcs-liberation/dcs_liberation/issues/1145

Currently this is fixed at the start of the campaign. The squadron
locations are defined by the campaign file.

Follow up work:

* Track aircraft ownership per-squadron rather than per-airbase.
* UI for relocating squadrons.
* Ferry missions for squadrons that are relocating.
* Auto-relocation (probably only for retreat handling).

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1138
2021-08-14 21:46:27 -07:00
Khopa
fbd0198771 Fixed mypy errors 2021-08-03 00:37:26 +02:00
Khopa
5b37698d36 Fixed mypy errors 2021-08-03 00:28:22 +02:00
Khopa
483640b0c6 Fixed errors after merge on helipad feature. 2021-08-03 00:15:14 +02:00
Khopa
71143536bf Merge branch 'develop' into helipads
# Conflicts:
#	game/game.py
#	game/operation/operation.py
#	game/theater/conflicttheater.py
#	game/theater/controlpoint.py
#	gen/groundobjectsgen.py
#	resources/campaigns/golan_heights_lite.miz
2021-08-02 19:34:05 +02:00
Dan Albert
edf95ea9fb Dedup purchase requests.
Since the theater commander runs once per campaign action, missions that
do not have aircraft available may be checked more than once a turn.
Without deduping requests this can lead to cases where the AI buys
dozens of tankers on turn 0.

Fixes https://github.com/dcs-liberation/dcs_liberation/issues/1470
2021-08-01 15:17:43 -07:00