public Battle(Fleet fleet, Fleet fleet2, CombinedFleetType fleetType, BattleKind kind) : base(new Side(fleet, fleet2)) { Kind = kind; FleetType = fleetType; Incomplete = true; }
internal void Update(RawPort rpPort) { CombinedFleetType = rpPort.CombinedFleetType; Update(rpPort.Fleets); }
public Battle(sortie_battle api, CombinedFleetType fleettype, MapNodeType battletype, ShipInBattle[] fleet1, ShipInBattle[] fleet2) { FleetType = fleettype; BattleType = battletype; Fleet1 = fleet1; Fleet2 = fleet2; bool isEnemyCombined = battletype == MapNodeType.Combined || battletype == MapNodeType.CombinedBOSS; if (api.api_formation != null) { FriendFormation = (Formation)api.api_formation[0]; EnemyFormation = (Formation)api.api_formation[1]; Direction = (Direction)api.api_formation[2]; } if (api.api_search != null) { FriendSearching = api.api_search[0]; EnemySearching = api.api_search[1]; } EnemyFleet = api.api_ship_ke .Select((x, i) => new ShipInBattle { Index = i + 1, IsEnemy = true, ShipInfo = Staff.Current.MasterData.ShipInfo[x], Level = api.api_ship_lv[i], Equipments = api.api_eSlot[i].Select(y => Staff.Current.MasterData.EquipInfo[y]).Where(y => y != null).Select(y => new EquipInBattle(y)).ToArray(), Firepower = api.api_eParam[i][0], Torpedo = api.api_eParam[i][1], AA = api.api_eParam[i][2], Armor = api.api_eParam[i][3] }) .ToArray(); EnemyFleet2 = api.api_ship_ke_combined? .Select((x, i) => new ShipInBattle { Index = i + 7, IsEnemy = true, ShipInfo = Staff.Current.MasterData.ShipInfo[x], Level = api.api_ship_lv_combined[i], Equipments = api.api_eSlot_combined[i].Select(y => Staff.Current.MasterData.EquipInfo[y]).Where(y => y != null).Select(y => new EquipInBattle(y)).ToArray(), Firepower = api.api_eParam_combined[i][0], Torpedo = api.api_eParam_combined[i][1], AA = api.api_eParam_combined[i][2], Armor = api.api_eParam_combined[i][3] }) .ToArray(); EnemyShipIds = api.api_ship_ke.ConcatNotNull(api.api_ship_ke_combined).ToArray(); SetHPs(Fleet1, api.api_f_nowhps, api.api_f_maxhps); SetHPs(EnemyFleet, api.api_e_nowhps, api.api_e_maxhps); SetHPs(Fleet2, api.api_f_nowhps_combined, api.api_f_maxhps_combined); SetHPs(EnemyFleet2, api.api_e_nowhps_combined, api.api_e_maxhps_combined); api.api_escape_idx?.ForEach(x => Fleet1[x - 1].IsEscaped = true); api.api_escape_idx_combined?.ForEach(x => Fleet2[x - 1].IsEscaped = true); if (api.api_n_support_info != null) { Support = new SupportAttack(this, api.api_n_support_info, api.api_n_support_flag); } if (api.api_n_hougeki1 != null) { NightToDay1 = new FireCombat(this, api.api_n_hougeki1); } if (api.api_n_hougeki2 != null) { NightToDay2 = new FireCombat(this, api.api_n_hougeki2); } if (api.api_air_base_injection != null) { AirBaseJet = new JetPlaneAttack(this, api.api_air_base_injection, true); } if (api.api_injection_kouku != null) { Jet = new JetPlaneAttack(this, api.api_injection_kouku, false); } if (api.api_air_base_attack != null) { AirBaseAttacks = api.api_air_base_attack.Select(x => new AirBaseAttack(this, x)).ToArray(); } if (api.api_kouku != null) { AirCombat1 = new AerialCombat(this, api.api_kouku); } if (api.api_kouku2 != null) { AirCombat2 = new AerialCombat(this, api.api_kouku2); } if (api.api_support_flag != 0) { Support = new SupportAttack(this, api.api_support_info, api.api_support_flag); } if (api.api_opening_taisen != null) { OpeningASW = new FireCombat(this, api.api_opening_taisen); } if (api.api_opening_atack != null) { OpeningTorpedo = new TorpedoCombat(this, api.api_opening_atack); } if (isEnemyCombined) { switch (fleettype) { case CombinedFleetType.None: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(this, api.api_hougeki1); } if (api.api_raigeki != null) { TorpedoStage = new TorpedoCombat(this, api.api_raigeki); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(this, api.api_hougeki2); } if (api.api_hougeki3 != null) { FireStage3 = new FireCombat(this, api.api_hougeki3); } break; case CombinedFleetType.Carrier: case CombinedFleetType.Transport: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(this, api.api_hougeki1); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(this, api.api_hougeki2); } if (api.api_raigeki != null) { TorpedoStage = new TorpedoCombat(this, api.api_raigeki); } if (api.api_hougeki3 != null) { FireStage3 = new FireCombat(this, api.api_hougeki3); } break; case CombinedFleetType.Surface: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(this, api.api_hougeki1); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(this, api.api_hougeki2); } if (api.api_hougeki3 != null) { FireStage3 = new FireCombat(this, api.api_hougeki3); } if (api.api_raigeki != null) { TorpedoStage = new TorpedoCombat(this, api.api_raigeki); } break; } } else { switch (fleettype) { case CombinedFleetType.None: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(this, api.api_hougeki1); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(this, api.api_hougeki2); } if (api.api_raigeki != null) { TorpedoStage = new TorpedoCombat(this, api.api_raigeki); } break; case CombinedFleetType.Carrier: case CombinedFleetType.Transport: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(this, api.api_hougeki1); } if (api.api_raigeki != null) { TorpedoStage = new TorpedoCombat(this, api.api_raigeki); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(this, api.api_hougeki2); } if (api.api_hougeki3 != null) { FireStage3 = new FireCombat(this, api.api_hougeki3); } break; case CombinedFleetType.Surface: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(this, api.api_hougeki1); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(this, api.api_hougeki2); } if (api.api_hougeki3 != null) { FireStage3 = new FireCombat(this, api.api_hougeki3); } if (api.api_raigeki != null) { TorpedoStage = new TorpedoCombat(this, api.api_raigeki); } break; } } if (api.api_hougeki != null || api.api_friendly_info != null) { NightBattle(api); } else { EndApplyBattle(); } }
public Battle(sortie_battle api, CombinedFleetType fleettype, MapNodeType battletype, BattleManager source) { FleetType = fleettype; BattleType = battletype; Fleet1 = (source.SortieFleet1?.Ships ?? Staff.Current.Homeport.Fleets[api.api_deck_id + api.api_dock_id].Ships) .Select(x => new ShipInBattle(x)).ToArray(); Fleet2 = source.SortieFleet2?.Ships .Select(x => new ShipInBattle(x)).ToArray(); if (source.SortieFleet1 == null)//演习 { Staff.Current.Homeport.Fleets[api.api_deck_id + api.api_dock_id].Ships.ForEach(x => x.IgnoreNextCondition()); } if (api.api_formation != null) { FriendFormation = (Formation)api.api_formation[0]; EnemyFormation = (Formation)api.api_formation[1]; Direction = (Direction)api.api_formation[2]; } bool iscombined = fleettype != CombinedFleetType.None; bool isenemycombined = battletype == MapNodeType.Combined || battletype == MapNodeType.CombinedBOSS; EnemyFleet = api.api_ship_ke.Where(x => x != -1) .Select((x, i) => new ShipInBattle { ShipInfo = Staff.Current.MasterData.ShipInfo[x], Level = api.api_ship_lv[i + 1], Equipments = api.api_eSlot[i].Select(y => Staff.Current.MasterData.EquipInfo[y]).Where(y => y != null).ToArray(), Firepower = api.api_eParam[i][0], Torpedo = api.api_eParam[i][1], AA = api.api_eParam[i][2], Armor = api.api_eParam[i][3] }) .ToArray(); EnemyFleet2 = api.api_ship_ke_combined?.Where(x => x != -1) .Select((x, i) => new ShipInBattle { ShipInfo = Staff.Current.MasterData.ShipInfo[x], Level = api.api_ship_lv_combined[i + 1], Equipments = api.api_eSlot_combined[i].Select(y => Staff.Current.MasterData.EquipInfo[y]).Where(y => y != null).ToArray(), Firepower = api.api_eParam_combined[i][0], Torpedo = api.api_eParam_combined[i][1], AA = api.api_eParam_combined[i][2], Armor = api.api_eParam_combined[i][3] }) .ToArray(); EnemyShipIds = api.api_ship_ke.Skip(1).ConcatNotNull(api.api_ship_ke_combined?.Skip(1)).ToArray(); Fleet1.ArrayZip(api.api_maxhps, 1, Delegates.SetMaxHP); Fleet2?.ArrayZip(api.api_maxhps_combined, 1, Delegates.SetMaxHP); EnemyFleet.ArrayZip(api.api_maxhps, 7, Delegates.SetMaxHP); EnemyFleet2?.ArrayZip(api.api_maxhps_combined, 7, Delegates.SetMaxHP); Fleet1.ArrayZip(api.api_nowhps, 1, Delegates.SetStartHP); Fleet2?.ArrayZip(api.api_nowhps_combined, 1, Delegates.SetStartHP); EnemyFleet.ArrayZip(api.api_nowhps, 7, Delegates.SetStartHP); EnemyFleet2?.ArrayZip(api.api_nowhps_combined, 7, Delegates.SetStartHP); api.api_escape_idx?.ForEach(x => Fleet1[x - 1].IsEscaped = true); api.api_escape_idx_combined?.ForEach(x => Fleet2[x - 1].IsEscaped = true); JetAttack(api.api_air_base_injection); JetAttack(api.api_injection_kouku); AirBaseAttack(api.api_air_base_attack); AirCombat1 = AirBattle(api.api_kouku, false); AirCombat2 = AirBattle(api.api_kouku2, false); SupportAttack(api.api_support_info); FireAttack(api.api_opening_taisen, NightOrTorpedo); if (isenemycombined) { ECTorpedoAttack(api.api_opening_atack); } else { TorpedoAttack(api.api_opening_atack); } if (isenemycombined) { ECFireAttack(api.api_hougeki1); ECFireAttack(api.api_hougeki2); ECFireAttack(api.api_hougeki3); } else { switch (fleettype) { case CombinedFleetType.None: FireAttack(api.api_hougeki1, Fleet1); FireAttack(api.api_hougeki2, Fleet1); break; case CombinedFleetType.Carrier: case CombinedFleetType.Transport: FireAttack(api.api_hougeki1, Fleet2); FireAttack(api.api_hougeki2, Fleet1); FireAttack(api.api_hougeki3, Fleet1); break; case CombinedFleetType.Surface: FireAttack(api.api_hougeki1, Fleet1); FireAttack(api.api_hougeki2, Fleet1); FireAttack(api.api_hougeki3, Fleet2); break; } } if (isenemycombined) { ECTorpedoAttack(api.api_raigeki); } else { TorpedoAttack(api.api_raigeki); } NightBattle(api); }
public Battle(sortie_battle api, CombinedFleetType fleettype, MapNodeType battletype, BattleManager source) { FleetType = fleettype; BattleType = battletype; Fleet1 = (source.SortieFleet1?.Ships ?? Staff.Current.Homeport.Fleets[api.api_deck_id + api.api_dock_id].Ships) .Select(x => new ShipInBattle(x)).ToArray(); Fleet2 = source.SortieFleet2?.Ships .Select(x => new ShipInBattle(x)).ToArray(); if (source.SortieFleet1 == null)//演习 Staff.Current.Homeport.Fleets[api.api_deck_id + api.api_dock_id].Ships.ForEach(x => x.IgnoreNextCondition()); if (api.api_formation != null) { FriendFormation = (Formation)api.api_formation[0]; EnemyFormation = (Formation)api.api_formation[1]; Direction = (Direction)api.api_formation[2]; } bool iscombined = fleettype != CombinedFleetType.None; bool isenemycombined = battletype == MapNodeType.Combined || battletype == MapNodeType.CombinedBOSS; EnemyFleet = api.api_ship_ke.Where(x => x != -1) .Select((x, i) => new ShipInBattle { ShipInfo = Staff.Current.MasterData.ShipInfo[x], Level = api.api_ship_lv[i + 1], Equipments = api.api_eSlot[i].Select(y => Staff.Current.MasterData.EquipInfo[y]).Where(y => y != null).ToArray(), Firepower = api.api_eParam[i][0], Torpedo = api.api_eParam[i][1], AA = api.api_eParam[i][2], Armor = api.api_eParam[i][3] }) .ToArray(); EnemyFleet2 = api.api_ship_ke_combined?.Where(x => x != -1) .Select((x, i) => new ShipInBattle { ShipInfo = Staff.Current.MasterData.ShipInfo[x], Level = api.api_ship_lv_combined[i + 1], Equipments = api.api_eSlot_combined[i].Select(y => Staff.Current.MasterData.EquipInfo[y]).Where(y => y != null).ToArray(), Firepower = api.api_eParam_combined[i][0], Torpedo = api.api_eParam_combined[i][1], AA = api.api_eParam_combined[i][2], Armor = api.api_eParam_combined[i][3] }) .ToArray(); EnemyShipIds = api.api_ship_ke.Skip(1).ConcatNotNull(api.api_ship_ke_combined?.Skip(1)).ToArray(); Fleet1.ArrayZip(api.api_maxhps, 1, Delegates.SetMaxHP); Fleet2?.ArrayZip(api.api_maxhps_combined, 1, Delegates.SetMaxHP); EnemyFleet.ArrayZip(api.api_maxhps, 7, Delegates.SetMaxHP); EnemyFleet2?.ArrayZip(api.api_maxhps_combined, 7, Delegates.SetMaxHP); Fleet1.ArrayZip(api.api_nowhps, 1, Delegates.SetStartHP); Fleet2?.ArrayZip(api.api_nowhps_combined, 1, Delegates.SetStartHP); EnemyFleet.ArrayZip(api.api_nowhps, 7, Delegates.SetStartHP); EnemyFleet2?.ArrayZip(api.api_nowhps_combined, 7, Delegates.SetStartHP); api.api_escape_idx?.ForEach(x => Fleet1[x - 1].IsEscaped = true); api.api_escape_idx_combined?.ForEach(x => Fleet2[x - 1].IsEscaped = true); AirCombat1 = AirBattle(api.api_kouku, false); AirCombat2 = AirBattle(api.api_kouku2, false); AirBaseAttack(api.api_air_base_attack); SupportAttack(api.api_support_info); FireAttack(api.api_opening_taisen, NightOrTorpedo); if (isenemycombined) ECTorpedoAttack(api.api_opening_atack); else TorpedoAttack(api.api_opening_atack); if (isenemycombined) { ECFireAttack(api.api_hougeki1); ECFireAttack(api.api_hougeki2); ECFireAttack(api.api_hougeki3); } else switch (fleettype) { case CombinedFleetType.None: FireAttack(api.api_hougeki1, Fleet1); FireAttack(api.api_hougeki2, Fleet1); break; case CombinedFleetType.Carrier: case CombinedFleetType.Transport: FireAttack(api.api_hougeki1, Fleet2); FireAttack(api.api_hougeki2, Fleet1); FireAttack(api.api_hougeki3, Fleet1); break; case CombinedFleetType.Surface: FireAttack(api.api_hougeki1, Fleet1); FireAttack(api.api_hougeki2, Fleet1); FireAttack(api.api_hougeki3, Fleet2); break; } if (isenemycombined) ECTorpedoAttack(api.api_raigeki); else TorpedoAttack(api.api_raigeki); NightBattle(api); }
public Logger(IDataService dataService, GameProvider provider, NavalBase navalBase, IStatePersist statePersist) { this.dataService = dataService; this.navalBase = navalBase; this.statePersist = statePersist; provider.EquipmentCreated += (t, m) => { using var context = CreateContext(); context.EquipmentCreationTable.AddRange(m.Equipment.Select((e, i) => new EquipmentCreationEntity { TimeStamp = t.AddMilliseconds(i), Consumption = m.Consumption, EquipmentCreated = e?.EquipmentInfoId, IsSuccess = e is object, AdmiralLevel = this.navalBase.Admiral.Leveling.Level, Secretary = this.navalBase.Secretary.Info.Id, SecretaryLevel = this.navalBase.Secretary.Leveling.Level })); context.SaveChanges(); }; provider.ShipCreated += (t, m) => { shipCreation = new ShipCreationEntity { TimeStamp = t, Consumption = m.Consumption, IsLSC = m.IsLSC, AdmiralLevel = this.navalBase.Admiral.Leveling.Level, Secretary = this.navalBase.Secretary.Info.Id, SecretaryLevel = this.navalBase.Secretary.Leveling.Level }; lastBuildingDock = m.BuildingDockId; }; provider.BuildingDockUpdated += (t, m) => { if (shipCreation != null) { using var context = CreateContext(); shipCreation.ShipBuilt = m.Single(x => x.Id == lastBuildingDock).BuiltShipId.Value; shipCreation.EmptyDockCount = this.navalBase.BuildingDocks.Count(x => x.State == BuildingDockState.Empty); context.ShipCreationTable.Add(shipCreation); shipCreation = null; lastBuildingDock = default; context.SaveChanges(); } }; provider.ExpeditionCompleted += (t, m) => { using var context = CreateContext(); var fleet = this.navalBase.Fleets[m.FleetId]; context.ExpeditionCompletionTable.Add(new ExpeditionCompletionEntity { TimeStamp = t, ExpeditionId = fleet.Expedition.Id, ExpeditionName = m.ExpeditionName, Result = m.Result, MaterialsAcquired = m.MaterialsAcquired, RewardItem1 = m.RewardItem1, RewardItem2 = m.RewardItem2 }); context.SaveChanges(); foreach (var ship in fleet.HomeportShips) { this.statePersist.ClearLastSortie(ship.Id); } this.statePersist.SaveChanges(); }; #if DEBUG InitializeAdmiral(null); #endif navalBase.AdmiralChanging += (t, _, a) => { if (a != null) { lock (admiralLock) InitializeAdmiral(a); } }; navalBase.MaterialsUpdating += (t, old, @new, reason) => { using var context = CreateContext(); context.MaterialsChangeTable.Add(new MaterialsChangeEntity { TimeStamp = t, Materials = @new, Reason = reason }); context.SaveChanges(); }; navalBase.HomeportUpdated += (t, n) => { if (this.statePersist.LastSortieTime is DateTimeOffset last) { currentBattleContext ??= CreateContext(); var consumption = this.navalBase.Fleets[this.statePersist.LastSortieFleets].Sum(f => f.RepairingCost + f.SupplyingCost); var diff = consumption - this.statePersist.ConsumptionBeforeSortie; var entity = currentBattleContext.BattleConsumptionTable.Find(last); if (diff != default && entity != null) { entity.Consumption = diff; currentBattleContext.BattleConsumptionTable.Update(entity); currentBattleContext.SaveChanges(); } } currentBattle = null; currentExercise = null; currentBattleContext?.Dispose(); currentFleetInBattle = null; currentFleet2InBattle = null; this.statePersist.LastSortieFleets = null; this.statePersist.LastSortieTime = null; this.statePersist.SaveChanges(); }; navalBase.ShipSupplying += (t, s, raw) => { if (this.statePersist.GetLastSortie(s.Id) is DateTimeOffset last) { using var context = CreateContext(); var entity = context.BattleConsumptionTable.Find(last); if (entity is null) { return; } int fuel = raw.CurrentFuel - s.Fuel.Current; int bullet = raw.CurrentBullet - s.Bullet.Current; bool isMarriaged = s.Leveling.Level >= 100; entity.ActualConsumption += new Materials { Fuel = isMarriaged ? (int)(fuel * 0.85) : fuel, Bullet = isMarriaged ? (int)(bullet * 0.85) : bullet, Bauxite = (raw.SlotAircraft.Sum() - s.Slots.Sum(x => x.Aircraft.Current)) * 5 }; context.BattleConsumptionTable.Update(entity); context.SaveChanges(); } }; navalBase.ShipRepairing += (t, s, i) => { if (this.statePersist.GetLastSortie(s.Id) is DateTimeOffset last) { using var context = CreateContext(); var entity = context.BattleConsumptionTable.Find(last); if (entity is null) { return; } entity.ActualConsumption += s.RepairingCost; if (i) { entity.ActualConsumption += new Materials { InstantRepair = 1 } } ; context.BattleConsumptionTable.Update(entity); context.SaveChanges(); } }; navalBase.RepairingDockInstant += (t, d, s) => { if (this.statePersist.GetLastSortie(s.Id) is DateTimeOffset last) { using var context = CreateContext(); var entity = context.BattleConsumptionTable.Find(last); if (entity is null) { return; } entity.ActualConsumption += new Materials { InstantRepair = 1 }; context.BattleConsumptionTable.Update(entity); context.SaveChanges(); } }; provider.SortieStarting += (t, m) => { FleetId[] fleets; currentFleetInBattle = this.navalBase.Fleets[m.FleetId]; currentCombinedFleet = this.navalBase.CombinedFleet; if (currentCombinedFleet != CombinedFleetType.None) { currentFleet2InBattle = this.navalBase.Fleets[(FleetId)2]; fleets = new[] { (FleetId)1, (FleetId)2 }; } else { fleets = new[] { m.FleetId }; } currentBattleContext = CreateContext(); currentBattleContext.BattleConsumptionTable.Add(new BattleConsumptionEntity { TimeStamp = t, MapId = m.MapId }); currentBattleContext.SaveChanges(); this.statePersist.ConsumptionBeforeSortie = currentFleetInBattle.RepairingCost + currentFleetInBattle.SupplyingCost + (currentFleet2InBattle?.RepairingCost ?? default) + (currentFleet2InBattle?.SupplyingCost ?? default); this.statePersist.LastSortieTime = t; this.statePersist.LastSortieFleets = fleets; foreach (var ship in currentFleetInBattle.HomeportShips) { this.statePersist.SetLastSortie(ship.Id, t); } if (currentFleet2InBattle != null) { foreach (var ship in currentFleet2InBattle.HomeportShips) { this.statePersist.SetLastSortie(ship.Id, t); } } this.statePersist.SaveChanges(); }; provider.MapRouting += (t, m) => { var map = this.navalBase.Maps[m.MapId]; currentBattle = new BattleEntity { TimeStamp = t, CompletionTime = t, MapId = m.MapId, MapName = map.Info.Name.Origin, RouteId = m.RouteId, EventKind = m.EventKind, BattleKind = m.BattleKind, CombinedFleetType = this.navalBase.CombinedFleet, MapRank = map.Rank, MapGaugeType = map.GaugeType, MapGaugeNumber = map.GaugeIndex, MapGaugeHP = map.Gauge?.Current, MapGaugeMaxHP = map.Gauge?.Max }; if (m.UnparsedLandBaseDefence != null) { currentBattle.LandBaseDefence = m.UnparsedLandBaseDefence.ToString(Formatting.None); } Materials acquired = default; foreach (var r in m.ItemAcquired) { switch ((KnownUseItem)r.ItemId) { case KnownUseItem.Fuel: acquired.Fuel += r.Count; break; case KnownUseItem.Bullet: acquired.Bullet += r.Count; break; case KnownUseItem.Steel: acquired.Steel += r.Count; break; case KnownUseItem.Bauxite: acquired.Bauxite += r.Count; break; case KnownUseItem.InstantBuild: acquired.InstantBuild += r.Count; break; case KnownUseItem.InstantRepair: acquired.InstantRepair += r.Count; break; case KnownUseItem.Development: acquired.Development += r.Count; break; case KnownUseItem.Improvement: acquired.Improvement += r.Count; break; } } if (acquired != default) { var entity = currentBattleContext.BattleConsumptionTable.Find(this.statePersist.LastSortieTime); if (entity != null) { entity.Acquired += acquired; currentBattleContext.BattleConsumptionTable.Update(entity); } } currentBattleContext.BattleTable.Add(currentBattle); currentBattleContext.SaveChanges(); }; provider.ExerciseCandidateSelected += (t, m) => { currentExercise = new ExerciseEntity { TimeStamp = t, EnemyId = m.AdmiralId, EnemyName = m.Name, EnemyLevel = m.Leveling.Level }; }; provider.ExerciseStarted += (t, m) => { currentFleetInBattle = this.navalBase.Fleets[m]; currentBattleContext = CreateContext(); }; provider.BattleStarted += (t, m) => { if (currentBattle != null) { currentBattle.CompletionTime = t; currentBattle.SortieFleetState = currentFleetInBattle.Ships.Select(x => new ShipInBattleEntity(x)).ToArray(); currentBattle.SortieFleet2State = currentFleet2InBattle?.Ships.Select(x => new ShipInBattleEntity(x)).ToArray(); currentBattle.FirstBattleDetail = m.Unparsed.ToString(Formatting.None); currentBattle.LbasState = m.Parsed.LandBasePhases .Select(x => new AirForceInBattle(this.navalBase.AirForce[(currentBattle.MapId.AreaId, x.GroupId)])) .ToArray(); }
public bool CanUseCombinedFleet(CombinedFleetType type) => (api_sally_flag.At(1) & (1 << ((int)type - 1))) != 0;
public Battle(sortie_battle api, CombinedFleetType fleettype, MapNodeType battletype, ShipInBattle[] fleet1, ShipInBattle[] fleet2) { FleetType = fleettype; BattleType = battletype; Fleet1 = fleet1; Fleet2 = fleet2; if (api.api_formation != null) { FriendFormation = (Formation)api.api_formation[0]; EnemyFormation = (Formation)api.api_formation[1]; Direction = (Direction)api.api_formation[2]; } if (api.api_search != null) { FriendSearching = api.api_search[0]; EnemySearching = api.api_search[1]; } bool iscombined = fleettype != CombinedFleetType.None; bool isenemycombined = battletype == MapNodeType.Combined || battletype == MapNodeType.CombinedBOSS; EnemyFleet = api.api_ship_ke.Where(x => x != -1) .Select((x, i) => new ShipInBattle { Index = i + 1, IsEnemy = true, ShipInfo = Staff.Current.MasterData.ShipInfo[x], Level = api.api_ship_lv[i + 1], Equipments = api.api_eSlot[i].Select(y => Staff.Current.MasterData.EquipInfo[y]).Where(y => y != null).Select(y => new EquipInBattle(y)).ToArray(), Firepower = api.api_eParam[i][0], Torpedo = api.api_eParam[i][1], AA = api.api_eParam[i][2], Armor = api.api_eParam[i][3] }) .ToArray(); EnemyFleet2 = api.api_ship_ke_combined?.Where(x => x != -1) .Select((x, i) => new ShipInBattle { Index = i + 7, IsEnemy = true, ShipInfo = Staff.Current.MasterData.ShipInfo[x], Level = api.api_ship_lv_combined[i + 1], Equipments = api.api_eSlot_combined[i].Select(y => Staff.Current.MasterData.EquipInfo[y]).Where(y => y != null).Select(y => new EquipInBattle(y)).ToArray(), Firepower = api.api_eParam_combined[i][0], Torpedo = api.api_eParam_combined[i][1], AA = api.api_eParam_combined[i][2], Armor = api.api_eParam_combined[i][3] }) .ToArray(); EnemyShipIds = api.api_ship_ke.Skip(1).ConcatNotNull(api.api_ship_ke_combined?.Skip(1)).ToArray(); void SetHPs(ShipInBattle[] fleet, int index, int[] hps, int[] maxhps) { if (fleet == null) { return; } for (int i = 0; i < fleet.Length; i++) { var ship = fleet[i]; ship.MaxHP = maxhps[i + index]; ship.FromHP = ship.ToHP = hps[i + index]; } } SetHPs(Fleet1, 1, api.api_nowhps, api.api_maxhps); SetHPs(EnemyFleet, 7, api.api_nowhps, api.api_maxhps); SetHPs(Fleet2, 1, api.api_nowhps_combined, api.api_maxhps_combined); SetHPs(EnemyFleet2, 7, api.api_nowhps_combined, api.api_maxhps_combined); api.api_escape_idx?.ForEach(x => Fleet1[x - 1].IsEscaped = true); api.api_escape_idx_combined?.ForEach(x => Fleet2[x - 1].IsEscaped = true); if (api.api_air_base_injection != null) { AirBaseJet = new JetPlaneAttack(this, api.api_air_base_injection, true); } if (api.api_injection_kouku != null) { Jet = new JetPlaneAttack(this, api.api_injection_kouku, false); } if (api.api_air_base_attack != null) { AirBaseAttacks = api.api_air_base_attack.Select(x => new AirBaseAttack(this, x)).ToArray(); } if (api.api_kouku != null) { AirCombat1 = new AerialCombat(this, api.api_kouku); } if (api.api_kouku2 != null) { AirCombat2 = new AerialCombat(this, api.api_kouku2); } if (api.api_support_flag != 0) { Support = new SupportAttack(this, api.api_support_info, api.api_support_flag); } if (isenemycombined) { if (api.api_opening_taisen != null) { OpeningASW = new ECFireCombat(this, api.api_opening_taisen); } if (api.api_opening_atack != null) { OpeningTorpedo = new ECTorpedoCombat(this, api.api_opening_atack); } if (api.api_hougeki1 != null) { FireStage1 = new ECFireCombat(this, api.api_hougeki1); } if (api.api_hougeki2 != null) { FireStage2 = new ECFireCombat(this, api.api_hougeki2); } if (api.api_hougeki3 != null) { FireStage3 = new ECFireCombat(this, api.api_hougeki3); } if (api.api_raigeki != null) { TorpedoStage = new ECTorpedoCombat(this, api.api_raigeki); } } else { if (api.api_opening_taisen != null) { OpeningASW = new FireCombat(api.api_opening_taisen, NightOrTorpedo, EnemyFleet); } if (api.api_opening_atack != null) { OpeningTorpedo = new TorpedoCombat(api.api_opening_atack, NightOrTorpedo, EnemyFleet); } switch (fleettype) { case CombinedFleetType.None: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(api.api_hougeki1, Fleet1, EnemyFleet); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(api.api_hougeki2, Fleet1, EnemyFleet); } break; case CombinedFleetType.Carrier: case CombinedFleetType.Transport: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(api.api_hougeki1, Fleet2, EnemyFleet); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(api.api_hougeki2, Fleet1, EnemyFleet); } if (api.api_hougeki3 != null) { FireStage3 = new FireCombat(api.api_hougeki3, Fleet1, EnemyFleet); } break; case CombinedFleetType.Surface: if (api.api_hougeki1 != null) { FireStage1 = new FireCombat(api.api_hougeki1, Fleet1, EnemyFleet); } if (api.api_hougeki2 != null) { FireStage2 = new FireCombat(api.api_hougeki2, Fleet1, EnemyFleet); } if (api.api_hougeki3 != null) { FireStage3 = new FireCombat(api.api_hougeki3, Fleet2, EnemyFleet); } break; } if (api.api_raigeki != null) { TorpedoStage = new TorpedoCombat(api.api_raigeki, NightOrTorpedo, EnemyFleet); } } if (api.api_hougeki != null) { NightBattle(api); } else { EndApplyBattle(); } }
public HomeportUpdate(IReadOnlyCollection <RawShip> ships, CombinedFleetType combinedFleetType) { Ships = ships; CombinedFleetType = combinedFleetType; }
internal static int CalcCombinedFleetFactor(CombinedFleetType type, int fleetId, bool abyssalCombined) { if (type == CombinedFleetType.None || fleetId >= 3) { return(0); } if (abyssalCombined) { if (fleetId == 2) { if (type == CombinedFleetType.None) { return(5); } else { return(-5); } } switch (type) { case CombinedFleetType.SurfaceTaskForce: return(2); case CombinedFleetType.CarrierTaskForce: return(2); case CombinedFleetType.TransportEscort: return(-5); default: return(5); } } else { switch (type) { case CombinedFleetType.SurfaceTaskForce: if (fleetId == 1) { return(10); } else { return(-5); } case CombinedFleetType.CarrierTaskForce: if (fleetId == 1) { return(2); } else { return(10); } case CombinedFleetType.TransportEscort: if (fleetId == 1) { return(-5); } else { return(10); } } } return(0); }