forked from dcs-retribution/dcs-retribution
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of https://github.com/Chilli935/dcs-retribution in…
…to dev
- Loading branch information
Showing
269 changed files
with
8,059 additions
and
1,821 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { RootState } from "../app/store"; | ||
import { gameLoaded, gameUnloaded } from "./actions"; | ||
import { createSlice } from "@reduxjs/toolkit"; | ||
import { MapZones } from "./_liberationApi"; | ||
|
||
interface MapZonesState { | ||
mapZones: MapZones; | ||
} | ||
|
||
const initialState: MapZonesState = { | ||
mapZones: { inclusion: [], exclusion: [], sea: [] }, | ||
}; | ||
|
||
const mapZonesSlice = createSlice({ | ||
name: "map", | ||
initialState: initialState, | ||
reducers: {}, | ||
extraReducers: (builder) => { | ||
builder.addCase(gameLoaded, (state, action) => { | ||
if (action.payload != null) { | ||
state.mapZones.exclusion = action.payload.map_zones.exclusion; | ||
state.mapZones.inclusion = action.payload.map_zones.inclusion; | ||
state.mapZones.sea = action.payload.map_zones.sea; | ||
} | ||
}); | ||
builder.addCase(gameUnloaded, (state) => { | ||
state.mapZones = initialState.mapZones; | ||
}); | ||
}, | ||
}); | ||
|
||
export const selectMapZones = (state: RootState) => state.mapZones; | ||
|
||
export default mapZonesSlice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
from collections import defaultdict | ||
from dataclasses import dataclass | ||
from typing import Any, TYPE_CHECKING | ||
|
||
from game.dcs.shipunittype import ShipUnitType | ||
|
||
if TYPE_CHECKING: | ||
pass | ||
|
||
|
||
@dataclass(frozen=True) | ||
class CarrierConfig: | ||
preferred_name: str | ||
preferred_type: ShipUnitType | ||
|
||
@classmethod | ||
def from_data(cls, data: dict[str, Any]) -> CarrierConfig: | ||
return CarrierConfig( | ||
str(data["preferred_name"]), ShipUnitType.named(data["preferred_type"]) | ||
) | ||
|
||
|
||
@dataclass(frozen=True) | ||
class CampaignCarrierConfig: | ||
by_original_name: dict[str, CarrierConfig] | ||
|
||
@classmethod | ||
def from_campaign_data(cls, data: dict[str, Any]) -> CampaignCarrierConfig: | ||
by_original_name: dict[str, CarrierConfig] = defaultdict() | ||
for original_name, carrier_config_data in data.items(): | ||
try: | ||
carrier_config = CarrierConfig.from_data(carrier_config_data) | ||
by_original_name[original_name] = carrier_config | ||
except KeyError: | ||
logging.warning( | ||
f"Skipping invalid carrier config for '{original_name}'" | ||
) | ||
|
||
return CampaignCarrierConfig(by_original_name) |
Oops, something went wrong.