mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-29 00:15:42 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4fbcb1987 |
+40
-9
@@ -125,11 +125,24 @@ namespace eagle {
|
||||
|
||||
public GameObject shardokContainer;
|
||||
|
||||
private KeyValuePair<ProvinceId, OneProvinceAvailableCommands>? NextActiveProvinceKeyPair =>
|
||||
Model == null || Model.AvailableCommandsByProvince.Count == 0
|
||||
? null
|
||||
: Model.AvailableCommandsByProvince.First(
|
||||
kvp => kvp.Key == Model.SuggestedProvinceId);
|
||||
private KeyValuePair<ProvinceId, OneProvinceAvailableCommands>? NextActiveProvinceKeyPair {
|
||||
get {
|
||||
if (Model == null || Model.AvailableCommandsByProvince.Count == 0) { return null; }
|
||||
|
||||
// If the server's suggested province is still actionable, prefer it.
|
||||
// Otherwise fall back to the first available province rather than throwing —
|
||||
// a stale SuggestedProvinceId can lag a turn behind AvailableCommandsByProvince
|
||||
// after a refresh, and an exception here aborts SwapModel partway through.
|
||||
if (Model.AvailableCommandsByProvince.TryGetValue(
|
||||
Model.SuggestedProvinceId,
|
||||
out var suggested)) {
|
||||
return new KeyValuePair<ProvinceId, OneProvinceAvailableCommands>(
|
||||
Model.SuggestedProvinceId,
|
||||
suggested);
|
||||
}
|
||||
return Model.AvailableCommandsByProvince.First();
|
||||
}
|
||||
}
|
||||
|
||||
void Start() {
|
||||
gameIdButton.GetComponentInChildren<Text>().text = "";
|
||||
@@ -576,11 +589,19 @@ namespace eagle {
|
||||
chronicleCanvasController.Entries = _newModel.ChronicleEntries;
|
||||
}
|
||||
|
||||
// If we already had commands, and we still have commands, don't actually swap the
|
||||
// model. But always update battle effects — battles can start or end between
|
||||
// command updates, and skipping cleanup leaves stale animations on the map.
|
||||
// If we already had commands, and we still have commands FOR THE SAME SET OF
|
||||
// PROVINCES, don't actually swap the model — keep the user's selection state
|
||||
// intact. If the available province set has changed, we MUST swap, otherwise
|
||||
// the controllers (mapController.SelectedProvinceId, _commandPanelController,
|
||||
// mapController.ProvincesWithCommands, etc.) keep pointing at provinces that
|
||||
// are no longer in the model, and a subsequent commit posts a stale province
|
||||
// with the freshly-advanced token.
|
||||
//
|
||||
// Always update battle effects — battles can start or end between command
|
||||
// updates, and skipping cleanup leaves stale animations on the map.
|
||||
if (Model != null && _newModel != null && _newModel.AvailableCommandsByProvince.Any() &&
|
||||
Model.AvailableCommandsByProvince.Any()) {
|
||||
Model.AvailableCommandsByProvince.Any() &&
|
||||
SameAvailableProvinces(Model, _newModel)) {
|
||||
mapController.UpdateBattleEffects(_newModel);
|
||||
UpdateBattleProgressDisplay(_newModel);
|
||||
return;
|
||||
@@ -757,6 +778,16 @@ namespace eagle {
|
||||
}
|
||||
}
|
||||
|
||||
private static bool SameAvailableProvinces(IGameModel a, IGameModel b) {
|
||||
if (a.AvailableCommandsByProvince.Count != b.AvailableCommandsByProvince.Count) {
|
||||
return false;
|
||||
}
|
||||
foreach (var key in a.AvailableCommandsByProvince.Keys) {
|
||||
if (!b.AvailableCommandsByProvince.ContainsKey(key)) { return false; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UpdateBattleProgressDisplay(IGameModel model) {
|
||||
if (model.ShardokBattles.Any()) {
|
||||
string fightableGameId =
|
||||
|
||||
Reference in New Issue
Block a user