diff --git a/.Lib9c.Tests/Model/AdventureBoss/AdventureBossSimulatorTest.cs b/.Lib9c.Tests/Model/AdventureBoss/AdventureBossSimulatorTest.cs index ab29ce40d3..d9e6d4ea80 100644 --- a/.Lib9c.Tests/Model/AdventureBoss/AdventureBossSimulatorTest.cs +++ b/.Lib9c.Tests/Model/AdventureBoss/AdventureBossSimulatorTest.cs @@ -6,7 +6,6 @@ namespace Lib9c.Tests.Model.AdventureBoss using Lib9c.Tests.Action; using Libplanet.Action; using Nekoyume.Battle.AdventureBoss; - using Nekoyume.Data; using Nekoyume.Model.BattleStatus; using Nekoyume.Model.BattleStatus.AdventureBoss; using Nekoyume.Model.EnumType; @@ -92,22 +91,31 @@ public AdventureBossSimulator Simulate() } [Theory] - [InlineData(true, 1, 1)] - [InlineData(true, 1, 5)] - [InlineData(true, 1, 3)] - [InlineData(false, 1, 1)] - [InlineData(false, 1, 5)] - [InlineData(false, 1, 3)] - [InlineData(false, 21, 23)] // For Boss ID 2 - public void AddBreakthrough(bool simulate, int firstFloorId, int lastFloorId) + [InlineData(true, 1, 1, 1)] + [InlineData(true, 1, 1, 5)] + [InlineData(true, 1, 1, 3)] + [InlineData(false, 1, 1, 1)] + [InlineData(false, 1, 1, 5)] + [InlineData(false, 1, 1, 3)] + [InlineData(true, 2, 1, 1)] + [InlineData(true, 2, 1, 5)] + [InlineData(true, 2, 1, 3)] + [InlineData(false, 2, 1, 1)] + [InlineData(false, 2, 1, 5)] + [InlineData(false, 2, 1, 3)] + public void AddBreakthrough(bool simulate, int bossId, int fristFloor, int lastFloor) { AdventureBossSimulator simulator; + var floorRows = _tableSheets.AdventureBossFloorSheet.Values + .Where(row => row.AdventureBossId == bossId).ToList(); + if (simulate) { simulator = Simulate(); } else { + var floorId = floorRows.First(row => row.Floor == lastFloor).Id; var adventureBossData = _tableSheets.AdventureBossSheet.Values.First(); var row = _tableSheets.CostumeStatSheet.Values.First( r => r.StatType == StatType.ATK); @@ -118,20 +126,20 @@ public void AddBreakthrough(bool simulate, int firstFloorId, int lastFloorId) simulator = new AdventureBossSimulator( adventureBossData.BossId, - 1, + floorId, _random, _avatarState, new List(), new AllRuneState(), new RuneSlotState(BattleType.Adventure), - _tableSheets.AdventureBossFloorSheet[lastFloorId], - _tableSheets.AdventureBossFloorWaveSheet[lastFloorId], + _tableSheets.AdventureBossFloorSheet[floorId], + _tableSheets.AdventureBossFloorWaveSheet[floorId], _tableSheets.GetSimulatorSheets(), _tableSheets.EnemySkillSheet, _tableSheets.CostumeStatSheet, AdventureBossSimulator.GetWaveRewards( _random, - _tableSheets.AdventureBossFloorSheet[1], + _tableSheets.AdventureBossFloorSheet[floorId], _tableSheets.MaterialItemSheet ), new List @@ -142,17 +150,23 @@ public void AddBreakthrough(bool simulate, int firstFloorId, int lastFloorId) ); } - simulator.AddBreakthrough(firstFloorId, lastFloorId, _tableSheets.AdventureBossFloorWaveSheet); + var floorIdList = new List(); + for (var fl = fristFloor; fl <= lastFloor; fl++) + { + floorIdList.Add(floorRows.First(row => row.Floor == fl).Id); + } + + simulator.AddBreakthrough(floorIdList, _tableSheets.AdventureBossFloorWaveSheet); Assert.Equal(typeof(SpawnPlayer), simulator.Log.events.First().GetType()); if (!simulate) { // +2: 1 for last floor, 1 for SpawnPlayer - Assert.Equal(lastFloorId - firstFloorId + 2, simulator.Log.events.Count); + Assert.Equal(lastFloor - fristFloor + 2, simulator.Log.events.Count); } var filtered = simulator.Log.events.OfType(); - Assert.Equal(lastFloorId - firstFloorId + 1, filtered.Count()); + Assert.Equal(lastFloor - fristFloor + 1, filtered.Count()); if (simulate) { diff --git a/Lib9c/Action/AdventureBoss/ExploreAdventureBoss.cs b/Lib9c/Action/AdventureBoss/ExploreAdventureBoss.cs index 3ac414e816..c5ae007aae 100644 --- a/Lib9c/Action/AdventureBoss/ExploreAdventureBoss.cs +++ b/Lib9c/Action/AdventureBoss/ExploreAdventureBoss.cs @@ -9,8 +9,6 @@ using Nekoyume.Action.Exceptions.AdventureBoss; using Nekoyume.Battle; using Nekoyume.Battle.AdventureBoss; -using Nekoyume.Data; -using Nekoyume.Exceptions; using Nekoyume.Extensions; using Nekoyume.Helper; using Nekoyume.Model.AdventureBoss; @@ -243,7 +241,7 @@ public override IWorld Execute(IActionContext context) AdventureBossSimulator simulator = null; var firstFloorId = 0; - var lastFloorId = 0; + var floorIdList = new List(); // Claim floors from last failed var exploreAp = sheets.GetSheet().OrderedList @@ -260,7 +258,6 @@ public override IWorld Execute(IActionContext context) if (firstFloorId == 0) { firstFloorId = floorRow.Id; - lastFloorId = firstFloorId; } var rewards = @@ -278,10 +275,10 @@ public override IWorld Execute(IActionContext context) simulator = new AdventureBossSimulator( bossId: latestSeason.BossId, - floorId: fl, + floorId: floorRow.Id, random, avatarState, - fl == firstFloorId ? Foods : new List(), + floorRow.Id == firstFloorId ? Foods : new List(), runeStates, runeSlotState, floorRow, @@ -297,7 +294,6 @@ public override IWorld Execute(IActionContext context) ); simulator.Simulate(); - lastFloorId = floorRow.Id; // Get Reward if cleared if (simulator.Log.IsClear) @@ -331,6 +327,12 @@ public override IWorld Execute(IActionContext context) selected.ItemId, random.Next(selected.Min, selected.Max + 1)) ); + + // Add floorId for breakthrough + if (fl < explorer.MaxFloor + 1) + { + floorIdList.Add(floorRow.Id); + } } else { @@ -338,9 +340,9 @@ public override IWorld Execute(IActionContext context) } } - if (simulator is not null && simulator.LogEvent && lastFloorId > firstFloorId) + if (simulator is not null && simulator.LogEvent && floorIdList.Count > 0) { - simulator.AddBreakthrough(firstFloorId, lastFloorId, floorWaveSheet); + simulator.AddBreakthrough(floorIdList, floorWaveSheet); } states = AdventureBossHelper.AddExploreRewards( diff --git a/Lib9c/Action/AdventureBoss/SweepAdventureBoss.cs b/Lib9c/Action/AdventureBoss/SweepAdventureBoss.cs index 3889e93564..b433852f6d 100644 --- a/Lib9c/Action/AdventureBoss/SweepAdventureBoss.cs +++ b/Lib9c/Action/AdventureBoss/SweepAdventureBoss.cs @@ -186,7 +186,7 @@ public override IWorld Execute(IActionContext context) var adventureBossId = states.GetSheet().OrderedList .First(row => row.BossId == latestSeason.BossId).Id; var floorRows = states.GetSheet().OrderedList - .Where(row => row.AdventureBossId == adventureBossId); + .Where(row => row.AdventureBossId == adventureBossId).ToList(); var firstFloorId = floorRows.First(r => r.Floor == 1).Id; var floorId = floorRows.First(r => r.Floor == explorer.Floor).Id; @@ -194,8 +194,13 @@ public override IWorld Execute(IActionContext context) latestSeason.BossId, floorId, context.GetRandom(), avatarState, sheets.GetSimulatorSheets(), logEvent: false ); - simulator.AddBreakthrough(firstFloorId, floorId, - sheets.GetSheet()); + var floorIdList = new List(); + for (var fl = 1; fl <= explorer.MaxFloor; fl++) + { + floorIdList.Add(floorRows.First(row => row.Floor == fl).Id); + } + + simulator.AddBreakthrough(floorIdList, sheets.GetSheet()); // Add point, reward var point = 0; diff --git a/Lib9c/Battle/AdventureBoss/AdventureBossSimulator.cs b/Lib9c/Battle/AdventureBoss/AdventureBossSimulator.cs index 43d6670dd7..7dccfd388e 100644 --- a/Lib9c/Battle/AdventureBoss/AdventureBossSimulator.cs +++ b/Lib9c/Battle/AdventureBoss/AdventureBossSimulator.cs @@ -246,7 +246,7 @@ public Player Simulate() return Player; } - public void AddBreakthrough(int firstFloorId, int lastFloorId, + public void AddBreakthrough(IEnumerable floorIdList, AdventureBossFloorWaveSheet adventureBossFloorWaveSheet) { if (Log.events.Count == 0) @@ -255,7 +255,7 @@ public void AddBreakthrough(int firstFloorId, int lastFloorId, } // Add event in reversed order to keep insert position - for (var floorId = lastFloorId; floorId >= firstFloorId; floorId--) + foreach (var floorId in floorIdList) { var floorWave = adventureBossFloorWaveSheet[floorId].Waves[0]; Log.events.Insert(1, new Breakthrough(Player, floorId, floorWave.Monsters)); diff --git a/Lib9c/Model/BattleStatus/AdventureBoss/Breakthrough.cs b/Lib9c/Model/BattleStatus/AdventureBoss/Breakthrough.cs index bd7c0106cd..1778b8860e 100644 --- a/Lib9c/Model/BattleStatus/AdventureBoss/Breakthrough.cs +++ b/Lib9c/Model/BattleStatus/AdventureBoss/Breakthrough.cs @@ -8,20 +8,20 @@ namespace Nekoyume.Model.BattleStatus.AdventureBoss [Serializable] public class Breakthrough : EventBase { - public readonly int Floor; + public readonly int FloorId; public readonly List Monsters; - public Breakthrough(CharacterBase character, int floor, + public Breakthrough(CharacterBase character, int floorId, List monsters ) : base(character) { - Floor = floor; + FloorId = floorId; Monsters = monsters; } public override IEnumerator CoExecute(IStage stage) { - yield return stage.CoBreakthrough((Player)Character, Floor, Monsters); + yield return stage.CoBreakthrough((Player)Character, FloorId, Monsters); } } } diff --git a/Lib9c/Model/IStage.cs b/Lib9c/Model/IStage.cs index bc626825a9..9b72e07db9 100644 --- a/Lib9c/Model/IStage.cs +++ b/Lib9c/Model/IStage.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using Nekoyume.Model.BattleStatus; using Nekoyume.Model.Item; -using Nekoyume.TableData; using Nekoyume.TableData.AdventureBoss; namespace Nekoyume.Model @@ -37,7 +36,7 @@ public interface IStage IEnumerator CoCustomEvent(CharacterBase character, EventBase eventBase); #region AdvetureBoss - IEnumerator CoBreakthrough(CharacterBase character, int floor, List monsters); + IEnumerator CoBreakthrough(CharacterBase character, int floorId, List monsters); IEnumerator CoStageBuff(CharacterBase affected, int skillId, IEnumerable skillInfos, IEnumerable buffInfos); #endregion }