public RequestSchema(FoodMainPart?foodMainPart = null, FoodType?foodType = null, Difficulty?difficulty = null) { ConditionCount = 0; MainPart = foodMainPart; FoodType = foodType; Difficulty = difficulty; }
public void ChangeDifficulty() { Difficulty?diff = null; while (diff is null) { string response = uiHelper.GetString("Enter desired difficulty (Easy/Medium/Hard)"); switch (response.ToLower()) { case "easy": diff = Difficulty.Easy; break; case "medium": diff = Difficulty.Medium; break; case "hard": diff = Difficulty.Hard; break; default: uiHelper.WriteLine("That wasn't an option!"); break; } } this.diff = (Difficulty)diff; }
public Enemy SpawnEnemy(int level, Difficulty?difficulty = null) { var enemy = Enemy.Spawn(EnemySymbols.SkeletonSymbol, level, Container, difficulty); enemy.Container = Container; return(enemy); }
private void EasyR_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { VisibleRects(); HardR.AnimateOpacity(1); NormalR.AnimateOpacity(1); EasyR.AnimateOpacity(0, Completed: (element) => element.Visibility = Visibility.Hidden); difficulty = Difficulty.Easy; }
private void EasyB_Clicked(object sender, EventArgs e) { VisibleRects(); HardR.AnimateOpacity(1); NormalR.AnimateOpacity(1); EasyR.Visibility = Visibility.Hidden; ShowInputAnimate(); difficulty = Difficulty.Easy; }
public static Monster GetMonster(Difficulty?difficulty = null, bool isHarcodedList = false) { // Choose a list type // > Generate a list List <Monster> Monsters; // > Use hard-coded list //List<Monster> Monsters = MonsterList; if (isHarcodedList) { Monsters = MonsterList.ToList(); } else { Monsters = MonsterGenerator.GenerateMonsters(); // Note, this generates an entire list of monsters everytime a monster is needed. } List <Monster> SortedMonsters; DateTime currentDate = DateTime.Today; if (difficulty == Difficulty.Easy) { SortedMonsters = (from monster in Monsters where monster.Difficulty == Difficulty.Easy && monster.Day == currentDate.DayOfWeek select monster).ToList(); } else if (difficulty == Difficulty.Medium) { SortedMonsters = (from monster in Monsters where monster.Difficulty == Difficulty.Medium && monster.Day == currentDate.DayOfWeek select monster).ToList(); } else if (difficulty == Difficulty.Hard) { SortedMonsters = (from monster in Monsters where monster.Difficulty == Difficulty.Hard && monster.Day == currentDate.DayOfWeek select monster).ToList(); } else { // Else, difficulty not selected, pick based on day. SortedMonsters = (from monster in Monsters where monster.Day == currentDate.DayOfWeek select monster).ToList(); } return(SortedMonsters[new Random().Next(0, SortedMonsters.Count - 1)]); }
// PRIVATE private async Task <List <Recipe> > GetRecipes( string searchString, string time, Difficulty?difficulty, string likes, int?category) { var query = from recipe in _context.Recipes join recipeIngredients in _context.RecipeIngredients on recipe.Id equals recipeIngredients.RecipeId join ingredient in _context.Ingredients on recipeIngredients.IngredientId equals ingredient.Id where (NameContains(recipe.Name, searchString) || NameContains(ingredient.Name, searchString)) && RecipeTimeBetween(recipe.DefaultDuration, time) && RecipeDifficultyIs(recipe.Difficulty, difficulty) && CategoryIsCategory(recipe.Category, category) && RecipeLikesBetween( (from ucr in _context.UserReactedToRecipes where ucr.Recipe.Id == recipe.Id && ucr.Reaction == Reaction.Like select ucr).Count(), likes) select recipeIngredients; var listRecipeIds = new List <int>(); foreach (var item in await query.ToListAsync()) { listRecipeIds.Add(item.RecipeId); } var user = _context.AppUsers.Where(r => r.Email == User.Identity.Name) .Include(u => u.UserFavouriteRecipes) .Include(u => u.UserCompletedRecipes) .Include(u => u.UserFavouriteIngredients) .ThenInclude(u => u.Ingredient) .Include(u => u.UserUnwantedIngredients) .ThenInclude(u => u.Ingredient) .FirstAsync(); var recipes = await _context.Recipes .Where(r => listRecipeIds.Contains(r.Id)) .Include(r => r.UserCompletedRecipes) .Include(r => r.UserReactedToRecipes) .Include(r => r.RecipeIngredients) .ThenInclude(r => r.Ingredient) .ToListAsync(); recipes.Sort(new RecipeScorer(await user)); return(recipes); }
/// <summary> Returns the name of the difficulty in a gramatically correct way, for example "an Easy" and "a Normal". /// Mostly useful for adding in the middle of sentences.</summary> public string GetDifficultyName(Difficulty?aDifficulty = null) { switch (aDifficulty ?? GetDifficulty()) { case Difficulty.Easy: return("an Easy"); case Difficulty.Normal: return("a Normal"); case Difficulty.Hard: return("a Hard"); case Difficulty.Insane: return("an Insane"); case Difficulty.Expert: return("an Expert"); default: return("an Ultra"); } }
private void Start() { gazeListener = new GazeListener(new [] { typeof(MenuNode), typeof(ReferenceNode), typeof(CurvedUIButton) }, OnItemGazedAt, OnItemGazedOff); GazeWatcher.AddListener(gazeListener); GazeWatcher.RaycastEnabled = true; lastNode = selectedNode = Galaxy.GetComponent <MenuNode>(); SceneManager.sceneLoaded += OnSceneLoadedDoPillarSetup; SceneManager.LoadScene("Pillars", LoadSceneMode.Additive); if (DeepLinkOnLoad) { deepLinkDifficulty = DifficultyToLoad; } }
// GET: Recipes public async Task <IActionResult> Index( string searchString, int?category, string time, Difficulty?difficulty, string likes) { var recipes = GetRecipes( searchString, time, difficulty, likes, category); var categories = _context.Categories.ToListAsync(); ViewData["CurrentFilter"] = searchString; ViewData["CurrentCategory"] = category.GetValueOrDefault(-1); ViewData["CurrentTime"] = time ?? "none"; ViewData["CurrentDifficulty"] = difficulty.HasValue ? difficulty.ToString() : ""; ViewData["CurrentLikes"] = likes ?? "none"; return(View(new RecipeViewModel(await recipes, await categories))); }
public async Task <List <TriviaQuestion> > GetQuestionsAsync(int amount = 50, int?categoryId = null, Difficulty?difficulty = null, QuestionType?type = null, string token = null) { amount = amount < 0 ? 0 : amount; if (amount == 0) { return(new List <TriviaQuestion>()); } var args = new List <string> { $"amount={amount}" }; if (categoryId.HasValue) { args.Add($"category={categoryId.Value}"); } if (difficulty.HasValue) // Check if the specified difficulty is an actual flag { args.Add($"difficulty={difficulty.Value.ToString().ToLower()}"); } if (type.HasValue) { args.Add($"type={type.Value.ToString().ToLower()}"); } args.Add($"encode={ResponseEncoding.Base64.ToString().ToLower()}"); if (!string.IsNullOrWhiteSpace(token)) { args.Add($"token={token}"); } string endpoint = API.CreateQuery(API.BaseEndpoint, args); var result = await GetAsync <QuestionResult>(endpoint); return(result?.Questions.Select(API.DecodeQuestion).ToList()); }
public override bool SetLevel(int level, Difficulty?diff = null) { var set = base.SetLevel(level, diff); LevelSet = set; if (set) { foreach (var fi in this.fightItems) { if (fi.Value is ProjectileFightItem pfi) { int inc = 80; if (pfi.FightItemKind == FightItemKind.ExplosiveCocktail || pfi.FightItemKind == FightItemKind.PoisonCocktail) { inc = 60; } pfi.baseDamage = Roguelike.Calculated.FactorCalculator.AddFactor(pfi.baseDamage, inc); } } } return(set); }
public int CountDefeatedMonsters(Difficulty?difficulty = null) { if (DefeatedMonsters.Any()) { switch (difficulty) { case Difficulty.Easy: //Return count of easy monsters. var easyCount = (from EasyMonster in DefeatedMonsters where EasyMonster.Difficulty == Difficulty.Easy select EasyMonster).Count(); return(easyCount); case Difficulty.Medium: //Return count of medium monsters. var mediumCount = (from mediumMonster in DefeatedMonsters where mediumMonster.Difficulty == Difficulty.Medium select mediumMonster).Count(); return(mediumCount); case Difficulty.Hard: //Return count of hard monsters. var hardCount = (from hardMonster in DefeatedMonsters where hardMonster.Difficulty == Difficulty.Hard select hardMonster).Count(); return(hardCount); default: // Else, no difficulty chosen, so return whole count. return(DefeatedMonsters.Count); } } else { return(0); } }
public void Setup(PillarMenuNode menuNode, Difficulty?difficulty = null) { currentMenuNode = menuNode; if (difficulty != null) { CurrentDifficulty = (Difficulty)difficulty; EasyButton.Selected = MediumButton.Selected = HardButton.Selected = false; switch (CurrentDifficulty) { case Difficulty.Medium: MediumButton.Selected = true; break; case Difficulty.Hard: HardButton.Selected = true; break; default: EasyButton.Selected = true; break; } UpdatePillars(); } if (menuNode.Config.Game == Game.Duel || menuNode.Config.Game == Game.Assault) { ChangeBackground(CurrentDifficulty); } else { ChangeBackground(CurrentDifficulty, true); } SetupMode(false); SetupGame(menuNode.Config.Game); if (menuNode.Locked) { switch (menuNode.Config.Game) { case Game.Assault: case Game.Duel: AudioEvent.Play(AudioEventName.Archivist.GalaxyMap.PillarLockedDuel, gameObject); break; case Game.HoloChess: AudioEvent.Play(AudioEventName.Archivist.GalaxyMap.PillarLockedHoloChess, gameObject); break; case Game.TowerDefense: AudioEvent.Play(AudioEventName.Archivist.GalaxyMap.PillarLockedTowerDefense, gameObject); break; } AudioEvent.Play(AudioEventName.GalaxyMap.NodeLocked, gameObject); } LeftLocked.SetActive(menuNode.Locked); LeftUnlocked.SetActive(!menuNode.Locked); RightPillarMode.SetActive(!menuNode.Locked); string configString = menuNode.Config.GetTokenString(); // Pillar Selected Mode LevelName.text = Localizer.Get("PedestalView.Title.LevelName." + configString); Description.text = Localizer.Get("PedestalView.Description.LevelObjective." + configString); LockedDescription.text = Localizer.Get("PedestalView.Prompt.LevelLocked." + configString); // DarkSide does not have achievements if (menuNode.Config.Planet != PlanetType.DarkSide) { // Achivements int achievements = ContainerAPI.GetLevelAchievements(menuNode.Config, (int)CurrentDifficulty); AchievementOneComplete.SetActive(achievements > 0); AchievementTwoComplete.SetActive(achievements > 1); AchievementThreeComplete.SetActive(achievements > 2); SetAchievementText(menuNode, configString); } }
public bool SetLevel(int level, Difficulty?diff = null) { Level = level; return(true); }
private void OnEnable() { PickCharacterMenu.gameObject.SetActive(true); _voteDifficulty = null; _voteGameMode = null; }
private static bool RecipeDifficultyIs( Difficulty recipeDifficulty, Difficulty?requestedDifficulty) { return(!requestedDifficulty.HasValue || recipeDifficulty == requestedDifficulty); }
public void VoteDifficultyNormal() { _voteDifficulty = Difficulty.Normal; }
/// <summary> /// Creates an asynchronous enumerator for question pagination. /// </summary> /// <param name="token"> /// a token (that was returned from <see cref="RequestTokenAsync(CancellationToken)"/>), /// which can be used to distinct the returned questions, so that no duplicate questions /// are returned. /// </param> /// <param name="pageSize"> /// the amount of questions to return per page (maximum: 50 questions) /// </param> /// <param name="difficulty">the difficulty the questions should have</param> /// <param name="type"> /// the type of the question (either <see cref="QuestionType.YesNo"/> or <see cref="QuestionType.Multiple"/>). /// </param> /// <param name="categoryId"> /// the identifier of the category ( <see cref="TriviaCategory.Id"/>) to return questions /// from, if <see langword="null"/> a random category will be chosen for the questions. /// </param> /// <returns>an asynchronous enumerator for question pagination</returns> public PaginatedEnumerator <Question> PaginateQuestions(string token = null, int pageSize = 20, Difficulty?difficulty = null, QuestionType?type = null, int?categoryId = null) => new PaginatedEnumerator <Question>(async() => (await GetQuestionsAsync(token, pageSize, difficulty, type, categoryId)).Questions.ToArray());
/// <summary> /// Gets questions from the Trivia API asynchronously. /// </summary> /// <param name="token"> /// a token (that was returned from <see cref="RequestTokenAsync(CancellationToken)"/>), /// which can be used to distinct the returned questions, so that no duplicate questions /// are returned. /// </param> /// <param name="amount">the amount of questions to return (maximum: 50 questions)</param> /// <param name="difficulty">the difficulty the questions should have</param> /// <param name="type"> /// the type of the question (either <see cref="QuestionType.YesNo"/> or <see cref="QuestionType.Multiple"/>). /// </param> /// <param name="categoryId"> /// the identifier of the category ( <see cref="TriviaCategory.Id"/>) to return questions /// from, if <see langword="null"/> a random category will be chosen for the questions. /// </param> /// <param name="cancellationToken"> /// a cancellation token used to propagate notification that the asynchronous operation /// should be canceled. /// </param> /// <returns> /// a task that represents the asynchronous operation. The task result is the response /// received from the Trivia API endpoint. /// </returns> /// <exception cref="ArgumentOutOfRangeException"> /// thrown if the specified <paramref name="amount"/> is greater than 50. /// </exception> /// <exception cref="ArgumentOutOfRangeException"> /// thrown if the specified <paramref name="amount"/> is less than 1. /// </exception> public async Task <QuestionsResponse> GetQuestionsAsync(string token = null, int amount = 20, Difficulty?difficulty = null, QuestionType?type = null, int?categoryId = null, CancellationToken cancellationToken = default) { if (amount > 50) { throw new ArgumentOutOfRangeException(nameof(amount), amount, "It can be only 50 questions requested at a time."); } if (amount < 1) { throw new ArgumentOutOfRangeException(nameof(amount), amount, "It must be requested at least 1 question."); } // parse an empty query string and add the amount parameter to it var parameters = HttpUtility.ParseQueryString(string.Empty); parameters.Add("amount", amount.ToString()); // add the token if specified if (!string.IsNullOrWhiteSpace(token)) { parameters.Add("token", token); } // add the difficulty query to the parameters if specified if (difficulty.HasValue) { parameters.Add("difficulty", difficulty.Value.GetSerializedValue()); } // add the type query to the parameters if specified if (type.HasValue) { parameters.Add("type", type.Value.GetSerializedValue()); } // add the category id query to the parameters if specified if (categoryId.HasValue) { parameters.Add("category", categoryId.Value.ToString()); } // make request var response = await RequestAsync <QuestionsResponse>("api.php?" + parameters, cancellationToken); // check if the token should be reseted if needed if (_autoResetToken && !string.IsNullOrWhiteSpace(token) && response.ResponseCode == ResponseCode.TokenEmpty) { // reset the token, because this request has consumed all possible left questions. await ResetTokenAsync(token, cancellationToken); } return(response); }
private EncounterDetail GetMonster(Difficulty?difficulty = null) { var monsterCount = Monsters.Count; var monster = 0; var indexes = new List <int>(Enumerable.Range(0, _multipliers.GetLength(0))); while (monster < monsterCount) { var currentMonster = Monsters[GetRandomInt(0, Monsters.Count)]; Monsters.Remove(currentMonster); var monsterXP = GetMonsterXP(currentMonster); indexes.Shuffle(); if (difficulty.HasValue) { var difficultyXp = XpList.First(l => l.Key == difficulty).Value; foreach (var i in indexes) { var count = (int)_multipliers[i, 0]; var allXP = monsterXP * count * _multipliers[i, 1]; if (allXP >= difficultyXp && XpList.OrderByDescending(l => l.Value).First(l => allXP >= l.Value).Key == difficulty) { var encounterDetail = _mapper.Map <EncounterDetail>(currentMonster); encounterDetail.XP = (int)allXP; encounterDetail.Count = count; encounterDetail.Difficulty = difficulty.Value.GetName(Resources.Enum.ResourceManager); if (Enum.TryParse(encounterDetail.Type, out MonsterType type)) { encounterDetail.Type = type.GetName(Resources.Enum.ResourceManager); } return(encounterDetail); } } } else { foreach (var i in indexes) { var count = (int)_multipliers[i, 0]; var allXP = monsterXP * count * _multipliers[i, 1]; foreach (var xp in XpList) { if (allXP <= xp.Value) { var encounterDetail = _mapper.Map <EncounterDetail>(currentMonster); encounterDetail.XP = (int)allXP; encounterDetail.Count = count; encounterDetail.Difficulty = xp.Key.GetName(Resources.Enum.ResourceManager); if (Enum.TryParse(encounterDetail.Type, out MonsterType type)) { encounterDetail.Type = type.GetName(Resources.Enum.ResourceManager); } return(encounterDetail); } } } } monster++; } return(null); }
private bool EditAI(int slot, AIHero?setToHero, Difficulty?setToDifficulty) { using (cg.LockHandler.Interactive) { if (!CustomGame.IsSlotValid(slot)) { throw new InvalidSlotException(slot); } // Make sure there is a player or AI in selected slot, or if they are a valid slot to select in queue. if (cg.PlayerSlots.Contains(slot)) { if (cg.OpenChatIsDefault) { cg.Chat.CloseChat(); } // Click the slot of the selected slot. var slotlocation = cg.Interact.FindSlotLocation(slot); cg.LeftClick(slotlocation.X, slotlocation.Y); // Check if Edit AI window has opened by checking if the confirm button exists. cg.UpdateScreen(); if (Capture.CompareColor(Points.EDIT_AI_CONFIRM, Colors.CONFIRM, 20)) { var sim = new List <Keys>(); // Set hero if setToHero does not equal null. if (setToHero != null) { // Open hero menu sim.Add(Keys.Space); // <image url="$(ProjectDir)\ImageComments\AI.cs\EditAIHero.png" scale="0.5" /> // Select the topmost hero option for (int i = 0; i < Enum.GetNames(typeof(AIHero)).Length; i++) { sim.Add(Keys.Up); } // Select the hero in selectHero. for (int i = 0; i < (int)setToHero; i++) { sim.Add(Keys.Down); } sim.Add(Keys.Space); } sim.Add(Keys.Down); // Select difficulty option // Set difficulty if setToDifficulty does not equal null. if (setToDifficulty != null) { // Open difficulty menu sim.Add(Keys.Space); // <image url="$(ProjectDir)\ImageComments\AI.cs\EditAIDifficulty.png" scale="0.6" /> // Select the topmost difficulty for (int i = 0; i < Enum.GetNames(typeof(Difficulty)).Length; i++) { sim.Add(Keys.Up); } // Select the difficulty in selectDifficulty. for (int i = 0; i < (int)setToDifficulty; i++) { sim.Add(Keys.Down); } sim.Add(Keys.Space); } // Confirm the changes sim.Add(Keys.Return); // Send the keypresses. cg.KeyPress(sim.ToArray()); //cg.//ResetMouse(); if (cg.OpenChatIsDefault) { cg.Chat.OpenChat(); } return(true); } else { //cg.//ResetMouse(); if (cg.OpenChatIsDefault) { cg.Chat.OpenChat(); } return(false); } } else { return(false); } } }
public override void Update(float dt) { if (_difficultyPrompt.IsVisible) { Difficulty?result = _difficultyPrompt.Update(dt); if (result == null) { return; } SMH.SaveManager.CurrentSave.Difficulty = result.Value; } if (State == MenuState.EnteringScreen) { SetWindowPosition(_windowX, _windowY + 1800f * dt); if (_windowY > 138f) { EnterState(MenuState.InScreen); SetWindowPosition(_windowX, 138f); } } else if (State == MenuState.ExitingScreen) { SetWindowPosition(_windowX, _windowY - 1800f * dt); if (_windowY <= -512f) { //Done exiting screen - perform action based on what button was clicked. switch (_clickedButton) { case SelectFileButton.Back: MainMenu.ShowScreen <TitleScreen>(); break; case SelectFileButton.Start: if (SMH.SaveManager.CurrentSave.IsEmpty) { SMH.Environment.LoadLevelAsynch(Level.FOUNTAIN_AREA); MainMenu.ShowScreen <CinematicScreen>(); } else { SMH.StartGame(false); } break; } } } //Set "start" button text based on whether or not an empty file is selected. _buttons[SelectFileButton.Start].Text = SMH.SaveManager.Saves[_selectedSlot].IsEmpty ? "Start" : "Continue"; //Update buttons foreach (KeyValuePair <SelectFileButton, Button> kvp in _buttons) { kvp.Value.Update(dt); if (kvp.Value.IsClicked() && kvp.Key != SelectFileButton.Delete) { _clickedButton = kvp.Key; SMH.SaveManager.CurrentSave = SMH.SaveManager.Saves[_selectedSlot]; EnterState(MenuState.ExitingScreen); if (kvp.Key == SelectFileButton.Start && SMH.SaveManager.Saves[_selectedSlot].IsEmpty) { _difficultyPrompt.IsVisible = true; } } } //Click delete button if (_buttons[SelectFileButton.Delete].IsClicked()) { if (!SMH.SaveManager.Saves[_selectedSlot].IsEmpty) { _deletePromptActive = true; } } //Update save box selections if (!_deletePromptActive) { foreach (KeyValuePair <SaveSlot, SaveBox> kvp in _saveBoxes) { if (SMH.Input.IsDown(Input.Attack) && kvp.Value.CollisionBox.Contains(SMH.Input.Cursor)) { _selectedSlot = kvp.Key; } } } //Listen for response to delete prompt if (_deletePromptActive) { SaveBox box = _saveBoxes[_selectedSlot]; _yesDeleteBox = new Rect(box.X + 100f, box.Y + 60f, 50f, 35f); _noDeleteBox = new Rect(box.X + 180f, box.Y + 60f, 50f, 35f); _mouseOverYes = _yesDeleteBox.Contains(SMH.Input.Cursor); _mouseOverNo = _noDeleteBox.Contains(SMH.Input.Cursor); if (SMH.Input.IsDown(Input.Attack)) { if (_mouseOverYes) { SMH.SaveManager.Delete(_selectedSlot); _deletePromptActive = false; } else if (_mouseOverNo) { _deletePromptActive = false; } } } //Move the Smiley selector towards the selected file. if (_smileyY > _saveBoxes[_selectedSlot].Y + 45f) { _smileyY -= 750f * dt; if (_smileyY < _saveBoxes[_selectedSlot].Y + 45f) { _smileyY = _saveBoxes[_selectedSlot].Y + 45f; } } else if (_smileyY < _saveBoxes[_selectedSlot].Y + 45f) { _smileyY += 750f * dt; if (_smileyY > _saveBoxes[_selectedSlot].Y + 45f) { _smileyY = _saveBoxes[_selectedSlot].Y + 45f; } } }
public void VoteDifficultyHard() { _voteDifficulty = Difficulty.Hard; }
public IAchievementFormatter WithDifficulty(Difficulty?difficulty) { Difficulty = difficulty; return(this); }