public void AddAndUnlockMimisbrunnrWorld( WorldSheet.Row worldRow, long unlockedAt, WorldSheet worldSheet, WorldUnlockSheet worldUnlockSheet) { var succeed = false; var worldId = worldRow.Id; if (worldId == GameConfig.MimisbrunnrWorldId) { var unlockRow = worldUnlockSheet.OrderedList.FirstOrDefault(row => row.WorldIdToUnlock == worldId); if (!(unlockRow is null) && IsStageCleared(unlockRow.StageId)) { succeed = true; } } else if (IsStageCleared(worldRow.StageBegin - 1)) { succeed = true; } if (succeed) { var world = new World(worldRow); worlds.Add(worldId, world); UnlockWorld(worldId, unlockedAt, worldSheet); } else { throw new FailedAddWorldException($"Failed to add {worldId} world to WorldInformation."); } }
/// <summary> /// Clear a specific stage. And consider world unlock. /// </summary> /// <param name="worldId"></param> /// <param name="stageId"></param> /// <param name="clearedAt"></param> /// <param name="worldSheet"></param> /// <param name="worldUnlockSheet"></param> /// <exception cref="FailedToUnlockWorldException"></exception> public void ClearStage( int worldId, int stageId, long clearedAt, WorldSheet worldSheet, WorldUnlockSheet worldUnlockSheet) { if (!worlds.ContainsKey(worldId)) { return; } var world = worlds[worldId]; if (stageId < world.StageBegin || stageId > world.StageEnd) { return; } // NOTE: Always consider world unlock. // Because even a stage that has already been cleared can be a trigger for world unlock due to the table patch. if (worldUnlockSheet.TryGetUnlockedInformation(worldId, stageId, out var worldIdsToUnlock)) { foreach (var worldIdToUnlock in worldIdsToUnlock) { UnlockWorld(worldIdToUnlock, clearedAt, worldSheet); } } if (stageId <= world.StageClearedId) { return; } worlds[worldId] = new World(world, clearedAt, stageId); }