public Dungeon(int level, DungeonLength length, DungeonDifficulty difficulty) { this.chanceToDivert = this.startChance; bool isFinished = false; this.Rooms = new List <Room>(); int cLayer = 0; while (!isFinished) { var layerToAdd = GenerateLayer(cLayer, length, difficulty); this.Rooms.AddRange(layerToAdd); cLayer++; if (layerToAdd.Count == 1 && cLayer > 2) { isFinished = true; } } if (level == 0) { //Do something later } }
internal string ChooseDungeonDifficulty(string dungeonName, DungeonDifficulty difficulty) { var dungeonUrl = new CommonUrls().GetDungeonUrl(dungeonName); dungeonUrl = difficulty.Equals(DungeonDifficulty.Normal) ? dungeonUrl + "/normal" : difficulty.Equals(DungeonDifficulty.Hard) ? dungeonUrl + "/hard" : difficulty.Equals(DungeonDifficulty.Impossible) ? dungeonUrl + "/impossible" : throw new ArgumentException($"Specified complexity ({difficulty}) " + "does not match any of the existing ones: 'normal', 'hard', 'impossible'"); return(dungeonUrl); }
private Room GenerateNormalRoom(DungeonDifficulty difficulty, DungeonLength length) { int maxLootRoomChance = (int)DungeonDifficulty.Catastrophical * 10; int lootRoomChance = (int)difficulty; Room generatedRoom = null; if (Helpers.RandomGenerator.RandomInt(0, maxLootRoomChance) > lootRoomChance) { generatedRoom = GenerateRoom(DungeonTextExtension.RoomType.Loot); } else { generatedRoom = GenerateRoom(DungeonTextExtension.RoomType.LesserMob, DungeonTextExtension.RoomType.Boss); } if (generatedRoom == null) { throw new NullReferenceException("A suiting Room could not be generated"); } return(generatedRoom); }
public async Task OverviewAsync(CommandContext ctx) { using var context = new DiscordContext(); DiscordEmbedBuilder builder = new DiscordEmbedBuilder() { Title = "These are all of your settings" }; var settings = UserSetting.GetAllSettings(ctx.Message.Author.Id, context).ToDictionary(setting => (UserSetting.SettingID)setting.SettingId); var items = await WheelItemExtension.GetUserItemsAsync(ctx.Message.Author.Id, context); AnalLevel analLevel = AnalLevel.None; if (settings.ContainsKey(SettingID.AnalLevel)) { analLevel = settings[SettingID.AnalLevel].GetValue <AnalLevel>(); } UserSetting.WheelDifficultyPreference wheelDifficulty = UserSetting.WheelDifficultyPreference.Default; if (settings.ContainsKey(SettingID.WheelDifficulty)) { wheelDifficulty = settings[SettingID.WheelDifficulty].GetValue <UserSetting.WheelDifficultyPreference>(); } UserSetting.WheelTaskPreferenceSetting wheelTaskPreference = UserSetting.WheelTaskPreferenceSetting.Default; if (settings.ContainsKey(SettingID.WheelTaskPreference)) { wheelTaskPreference = settings[SettingID.WheelTaskPreference].GetValue <UserSetting.WheelTaskPreferenceSetting>(); } BondageLevel bondageLevel = BondageLevel.None; if (settings.ContainsKey(SettingID.BondageLevel)) { bondageLevel = settings[SettingID.BondageLevel].GetValue <BondageLevel>(); } CBTLevel cbtLevel = CBTLevel.None; if (settings.ContainsKey(SettingID.CBTLevel)) { cbtLevel = settings[SettingID.CBTLevel].GetValue <CBTLevel>(); } DungeonDifficulty dungeonDifficulty = DungeonDifficulty.Normal; if (settings.ContainsKey(SettingID.DungeonDifficulty)) { dungeonDifficulty = settings[SettingID.DungeonDifficulty].GetValue <DungeonDifficulty>(); } //PeeLevel peeLevel = PeeLevel.None; //if (settings.ContainsKey(SettingID.PeeLevel)) //{ // peeLevel = settings[SettingID.PeeLevel].GetValue<PeeLevel>(); //} SissyLevel sissyLevel = SissyLevel.None; if (settings.ContainsKey(SettingID.SissyLevel)) { sissyLevel = settings[SettingID.SissyLevel].GetValue <SissyLevel>(); } //DegrationLevel degrationLevel = DegrationLevel.None; //if (settings.ContainsKey(SettingID.DegrationLevel)) //{ // degrationLevel = settings[SettingID.DegrationLevel].GetValue<DegrationLevel>(); //} PublicLevel publicLevel = PublicLevel.None; if (settings.ContainsKey(SettingID.PublicLevel)) { publicLevel = settings[SettingID.PublicLevel].GetValue <PublicLevel>(); } Gender gender = Gender.None; if (settings.ContainsKey(SettingID.Gender)) { gender = settings[SettingID.Gender].GetValue <Gender>(); } foreach (SettingID possibleSetting in Enum.GetValues(typeof(SettingID))) { Enum setting = null; switch (possibleSetting) { case SettingID.AnalLevel: setting = analLevel; break; case SettingID.BanType: break; case SettingID.WheelDifficulty: setting = wheelDifficulty; break; case SettingID.WheelTaskPreference: setting = wheelTaskPreference; break; case SettingID.BondageLevel: setting = bondageLevel; break; case SettingID.Toys: break; case SettingID.CBTLevel: setting = cbtLevel; break; case SettingID.DungeonDifficulty: break; case SettingID.PeeLevel: break; case SettingID.SissyLevel: setting = sissyLevel; break; case SettingID.DegrationLevel: break; case SettingID.PublicLevel: setting = publicLevel; break; case SettingID.BanEnd: break; case SettingID.Gender: setting = gender; break; } if (setting == null) { continue; } var name = possibleSetting.ToFormattedText(); var value = $"{setting.ToFormattedText()} ({Convert.ToInt32(setting)})"; builder.AddField(name, value, true); } await ctx.RespondAsync(embed : builder.Build()); if (items.Any()) { builder = new DiscordEmbedBuilder() { Title = "Your Items" }; foreach (var item in items.OrderBy(it => it.ItemId)) { var cItem = (WheelItemExtension.Item)item.ItemId; builder.AddField(cItem.ToFormattedText(), item.ItemId.ToString()); } await ctx.RespondAsync(embed : builder.Build()); } }
/// <summary>Событие загрузки формы</summary> private void LoadForm_Load(object sender, EventArgs e) { dataGridView_saves.ColumnCount = 7; // количество столбцов таблицы dataGridView_saves.RowCount = 0; // количество строк таблицы // задаём названия столбцов dataGridView_saves.Columns[0].Name = "Название сохранения"; dataGridView_saves.Columns[1].Name = "Сложность"; dataGridView_saves.Columns[2].Name = "Персонаж"; dataGridView_saves.Columns[3].Name = "Уровень персонажа"; dataGridView_saves.Columns[4].Name = "Ключ генерации мира"; dataGridView_saves.Columns[5].Name = "Текущий уровень подземелья"; dataGridView_saves.Columns[6].Name = "Дата и время сохранения"; string folder_path = Path.GetDirectoryName(Application.ExecutablePath) + "\\data"; if (!Directory.Exists(folder_path)) { Directory.CreateDirectory(folder_path); } folder_path = Path.GetDirectoryName(Application.ExecutablePath) + "\\data\\saves"; if (!Directory.Exists(folder_path)) { Directory.CreateDirectory(folder_path); } folder_path = Path.GetDirectoryName(Application.ExecutablePath) + "\\data\\saves\\" + (Owner as MainForm).Nick; if (!Directory.Exists(folder_path)) { Directory.CreateDirectory(folder_path); } string[] files = Directory.GetFiles("data\\saves\\" + (Owner as MainForm).Nick + "\\", "*.bin"); dataGridView_saves.RowCount = files.Length; for (int i = 0; i < files.Length; i++) { try { BinaryFormatter formatter = new BinaryFormatter(); // создаем объект BinaryFormatter using (FileStream fs = new FileStream(files[i], FileMode.Open)) // получаем поток, откуда будем считывать сериализованные объекты { string filename = (string)formatter.Deserialize(fs); DungeonDifficulty total_difficulty_id = (DungeonDifficulty)formatter.Deserialize(fs); string hero_name = (string)formatter.Deserialize(fs); int hero_level = (int)formatter.Deserialize(fs); string total_level_generation_number = (string)formatter.Deserialize(fs); int hero_dungeon_level_id = (int)formatter.Deserialize(fs); string datetime = (string)formatter.Deserialize(fs); formatter.Deserialize(fs); // герой DungeonInventoryStatus m_total_inventory_mode = (DungeonInventoryStatus)formatter.Deserialize(fs); int m_id_clicked_cell = (int)formatter.Deserialize(fs); string difficulty; if (total_difficulty_id == DungeonDifficulty.Easy) { difficulty = "Легко"; } else if (total_difficulty_id == DungeonDifficulty.Normal) { difficulty = "Нормально"; } else if (total_difficulty_id == DungeonDifficulty.Hard) { difficulty = "Сложно"; } else { difficulty = "Хардкор"; } dataGridView_saves.Rows[i].Cells[0].Value = filename; dataGridView_saves.Rows[i].Cells[1].Value = difficulty; dataGridView_saves.Rows[i].Cells[2].Value = hero_name; dataGridView_saves.Rows[i].Cells[3].Value = hero_level; dataGridView_saves.Rows[i].Cells[4].Value = total_level_generation_number; dataGridView_saves.Rows[i].Cells[5].Value = (hero_dungeon_level_id + 1).ToString(); dataGridView_saves.Rows[i].Cells[6].Value = datetime; } } catch { MessageBox.Show("Ошибка при чтении файла!", "Рекорды", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (dataGridView_saves.RowCount == 0) { button_load.Enabled = false; } else { button_load.Enabled = true; } }
public void SetDifficulty(DungeonDifficulty difficulty) { _difficulty = difficulty; }
/// <summary>Обновляет таблицу рекордов</summary> private void UpdateData() { dataGridView_records.ColumnCount = 11; // количество столбцов таблицы dataGridView_records.RowCount = 0; // количество строк таблицы // задаём названия столбцов dataGridView_records.Columns[0].Name = "Номер рекорда"; dataGridView_records.Columns[1].Name = "Состояние"; dataGridView_records.Columns[2].Name = "Время прохождения"; dataGridView_records.Columns[3].Name = "Ник игрока"; dataGridView_records.Columns[4].Name = "Сложность"; dataGridView_records.Columns[5].Name = "Персонаж"; dataGridView_records.Columns[6].Name = "Достигнутый уровень персонажа"; dataGridView_records.Columns[7].Name = "Ключ генерации мира"; dataGridView_records.Columns[8].Name = "Пройденное расстояние"; dataGridView_records.Columns[9].Name = "Монстров убито"; dataGridView_records.Columns[10].Name = "Боссов убито"; try { string folder_path = Path.GetDirectoryName(Application.ExecutablePath) + "\\data"; if (!Directory.Exists(folder_path)) { Directory.CreateDirectory(folder_path); } BinaryFormatter formatter = new BinaryFormatter(); // создаем объект BinaryFormatter using (FileStream fs = new FileStream("data\\records.bin", FileMode.OpenOrCreate)) // получаем поток, куда будем записывать сериализованные объекты { if (fs.Length != 0) // если длина файла не равна нулю - рекорды есть { fs.Position = 0; // перемещаем указатель в начало файла int records_number = (int)formatter.Deserialize(fs); // количество рекордов for (int i = 0; i < records_number; i++) // проходим циклом по всем рекордам { int record_number = (int)formatter.Deserialize(fs); // номер рекорда bool is_win = (bool)formatter.Deserialize(fs); // пройдена ли игра int time = (int)formatter.Deserialize(fs); // время string nick = (string)formatter.Deserialize(fs); // ник игрока DungeonDifficulty difficulty_id = (DungeonDifficulty)formatter.Deserialize(fs); // сложность string character_name = (string)formatter.Deserialize(fs); // имя персонажа int character_level = (int)formatter.Deserialize(fs); // достигнутый уровень персонажа string world_key = (string)formatter.Deserialize(fs); // ключ генерации мира double distance_walked = (double)formatter.Deserialize(fs); // пройденное расстояние int monsters_killed = (int)formatter.Deserialize(fs); // монстров убито int bosses_killed = (int)formatter.Deserialize(fs); // боссов убито if (radioButton_records_all.Checked || (radioButton_records_player.Checked && nick == (Owner as MainForm).Nick)) { dataGridView_records.Rows.Add(); int id = dataGridView_records.RowCount - 1; // занесение прочитанных из файла данных в таблицу dataGridView_records.Rows[id].Cells[0].Value = record_number; string is_win_text; if (is_win) { is_win_text = "Победа"; } else { is_win_text = "Поражение"; } dataGridView_records.Rows[id].Cells[1].Value = is_win_text; string time_text = ""; if (time / 60 / 60 < 10) { time_text += "0"; } time_text += (time / 60 / 60).ToString(); time_text += ":"; if ((time - time / 60 / 60 * 60) / 60 < 10) { time_text += "0"; } time_text += ((time - time / 60 / 60 * 60) / 60).ToString(); time_text += ":"; if (time - time / 60 / 60 * 60 - (time - time / 60 / 60 * 60) / 60 * 60 < 10) { time_text += "0"; } time_text += (time - time / 60 / 60 * 60 - (time - time / 60 / 60 * 60) / 60 * 60).ToString(); dataGridView_records.Rows[id].Cells[2].Value = time_text; dataGridView_records.Rows[id].Cells[3].Value = nick; string difficulty; if (difficulty_id == DungeonDifficulty.Easy) { difficulty = "Легко"; } else if (difficulty_id == DungeonDifficulty.Normal) { difficulty = "Нормально"; } else if (difficulty_id == DungeonDifficulty.Hard) { difficulty = "Сложно"; } else { difficulty = "Хардкор"; } dataGridView_records.Rows[id].Cells[4].Value = difficulty; dataGridView_records.Rows[id].Cells[5].Value = character_name; dataGridView_records.Rows[id].Cells[6].Value = character_level; dataGridView_records.Rows[id].Cells[7].Value = world_key; dataGridView_records.Rows[id].Cells[8].Value = distance_walked; dataGridView_records.Rows[id].Cells[9].Value = monsters_killed; dataGridView_records.Rows[id].Cells[10].Value = bosses_killed; } } } else // если нет рекордов { dataGridView_records.RowCount = 0; // количество строк = 0 } } } catch { MessageBox.Show("Ошибка при чтении файла!", "Рекорды", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private List <Room> GenerateLayer(int layerID, DungeonLength length, DungeonDifficulty difficulty) { List <Room> generatedLayer = new List <Room>(); int prevRoomIndex = 0; int skipRooms = 0; if (layerID - 1 == -1) { var room = this.GenerateNormalRoom(difficulty, length); room.LayerID = 0; generatedLayer.Add(room); return(generatedLayer); } int chanceDifference = this.startChance - this.chanceToDivert; int minNumberForDouble = startChance / 3 * 2; int minNumberForSingle = startChance / 2; int chance = Helpers.RandomGenerator.RandomInt(0, this.startChance); this.chanceToDivert -= Convert.ToInt32((int)DungeonLength.Endless - (int)length); foreach (var prevRoom in this.Rooms.Where(r => r.LayerID == layerID - 1)) { if (skipRooms > 0) { prevRoomIndex++; skipRooms--; continue; } var chanceToRandom = Helpers.RandomGenerator.RandomInt(0, 5); var tempChance = 0; if (chanceToRandom == 0) { tempChance = Helpers.RandomGenerator.RandomInt(-(((int)DungeonLength.Endless - (int)length) * 2), ((int)DungeonLength.Endless - (int)length) * 2); } if (this.chanceToDivert + tempChance > minNumberForDouble) { //Generate Two Rooms var room1 = this.GenerateNormalRoom(difficulty, length); room1.AdjacentRooms = new Guid[] { prevRoom.RoomID }; room1.LayerID = layerID; generatedLayer.Add(room1); var room2 = this.GenerateNormalRoom(difficulty, length); room2.AdjacentRooms = new Guid[] { prevRoom.RoomID }; room2.LayerID = layerID; generatedLayer.Add(room2); } else if (this.chanceToDivert + tempChance > minNumberForSingle) { //Generate a Single Room var room = this.GenerateNormalRoom(difficulty, length); room.LayerID = layerID; room.AdjacentRooms = new Guid[] { prevRoom.RoomID }; generatedLayer.Add(room); } else { //Converge with another Room Random rnd = new Random(); int convergeNum = rnd.Next(1, 3); var adjacentRooms = new List <Room> { prevRoom }; //If enough Rooms are left, converge with either 2 or 3 rooms if (this.Rooms.Count(r => r.LayerID == layerID - 1) > prevRoomIndex + 1) { adjacentRooms.Add(this.Rooms.Where(r => r.LayerID == layerID - 1).ElementAt(prevRoomIndex + 1)); skipRooms++; if (convergeNum == 2 && this.Rooms.Count(r => r.LayerID == layerID - 1) > prevRoomIndex + 2) { adjacentRooms.Add(this.Rooms.Where(r => r.LayerID == layerID - 1).ElementAt(prevRoomIndex + 2)); skipRooms++; } } var room = this.GenerateNormalRoom(difficulty, length); room.LayerID = layerID; room.AdjacentRooms = adjacentRooms.Select(r => r.RoomID).ToArray(); generatedLayer.Add(room); } prevRoomIndex++; } if (!generatedLayer.Any()) { throw new NullReferenceException("Could not add a Room to the Current Layer."); } return(generatedLayer); }