public void OnPost() { // Overwrite current rules foreach (var key in Request.Form.Keys) { // Get value for current key Request.Form.TryGetValue(key, out var strVal); // Skip empty fields if (string.IsNullOrWhiteSpace(strVal) || string.IsNullOrEmpty(strVal)) { continue; } // Skip non-integer parameters if (!int.TryParse(key, out var intKey)) { continue; } if (!int.TryParse(strVal, out var intVal)) { StatusMsg = "Non-integer rules!"; IsError = true; return; } // Update static rule context ActiveGame.TryChangeRule((RuleType)intKey, intVal); } IsStatus = true; StatusMsg = "Rules saved!"; IsDisplayContinue = true; }
public void HealGlobalVillainTargetsModTest() { Setup.SetupTestInfrastructure(); ActiveGame activeGame = GameContainer.ActiveGame; try { AmountModifier healthModifier = new AmountModifier("Obsidion Field", "Increase all damage by 1", ModifierTargets.VillainTargets, AmountModifierType.DamageGiven, 1, false); CharacterAccount fromAccount = activeGame.AllTargets[43]; CharacterAccount toAccount = activeGame.AllTargets[87]; GameContainer.AddHealthModifier(healthModifier, fromAccount); Assert.IsTrue(!activeGame.GlobalEnvironmentModifiers.ContainsValue(healthModifier), "Global Environment Mods List incorrectly contains expected modifier"); Assert.IsTrue(!activeGame.GlobalHeroModifers.ContainsValue(healthModifier), "Global Environment Mods List incorrectly contains expected modifier"); Assert.IsTrue(activeGame.GlobalVillainModifiers.ContainsValue(healthModifier), "Global Environment Mods List does not contain expected modifier"); foreach (CharacterAccount characterAccount in activeGame.VillainTargets) { Assert.IsTrue(characterAccount.HealingModList.ContainsValue(healthModifier), $"{characterAccount} does not contain the expected modifier"); } } catch (Exception e) { Assert.Fail("Test failed: " + e); } }
private void SpawnNewBlock() { // Everytime one block is dead the ground ten new block will be created if (block.isBlockDead == true) { end_pos_y = newBlock.transform.position.y; // If Block's start_pos_y is equal to its end pos_y then we know that player has lost the game if (start_pos_y == end_pos_y) { ActiveGame.GameOver(); game_over_menu.SetActive(true); } newBlock = listOfPrefabs.GetOnePrefab(); newBlock = Instantiate(newBlock, transform.position, newBlock.transform.rotation); block = newBlock.GetComponent <Block>(); block.fallingRate = block_falling_rate; block.deathRate = block_death_rate; blockInput.buttonsBlocked = false; blockInput.buttonLeftBlocked = false; blockInput.buttonRightBlocked = false; blockInput.buttonRotateBlocked = false; blockInput.buttonFastDropBlocked = false; setBlockMaterial(); // Setting color of the new block rowManager.RefreshRows(); // Refreshing every hot spot on the map } }
public void AddDamage(ActiveGame game, int damage, Card originCard) { if (game.Modifiers.Contains(GameModifier.CreaturesTakeNoDamage)) { return; } foreach (IAbility ability in Abilities.FindAll(o => o.Trigger == EffectTrigger.RecievesDamage)) { ability.Process(new AbilityArgs() { Damage = damage, OriginCard = originCard, TargetCard = this }); if (PreventDamage >= damage) { PreventDamage -= damage; damage = 0; } else { damage -= PreventDamage; PreventDamage = 0; } } foreach (IAbility ability in originCard.Abilities.FindAll(o => o.Trigger == EffectTrigger.DamageToCreature)) { ability.Process(new AbilityArgs() { Damage = damage, OriginCard = originCard, TargetCard = this }); } DamageTaken += damage; }
public void DamageImmunityGlobalEnvironmentTargetsModTest() { Setup.SetupTestInfrastructure(); ActiveGame activeGame = GameContainer.ActiveGame; try { ImmunityModifier DamageImmunityMod = new ImmunityModifier("Obsidion Field", "Increase all damage by 1", ModifierTargets.EnvironmentTargets, DamageType.All); CharacterAccount fromAccount = activeGame.AllTargets[43]; CharacterAccount toAccount = activeGame.AllTargets[87]; GameContainer.AddDamageImmunityModifier(DamageImmunityMod, fromAccount); Assert.IsTrue(activeGame.GlobalEnvironmentModifiers.ContainsValue(DamageImmunityMod), "Global Environment Mods List does not contain expected modifier"); Assert.IsTrue(!activeGame.GlobalHeroModifers.ContainsValue(DamageImmunityMod), "Global Environment Mods List incorrectly contains expected modifier"); Assert.IsTrue(!activeGame.GlobalVillainModifiers.ContainsValue(DamageImmunityMod), "Global Environment Mods List incorrectly contains expected modifier"); foreach (CharacterAccount characterAccount in activeGame.EnvCharacters) { Assert.IsTrue(characterAccount.ImmunityModList.ContainsValue(DamageImmunityMod), $"{characterAccount} does not contain the expected modifier"); } } catch (Exception e) { Assert.Fail("Test failed: " + e); } }
public static bool AutoPlaceShips(Player player) { const int tryAmount = 64; var boardSize = ActiveGame.GetRuleVal(RuleType.BoardSize); foreach (var ship in player.Ships) { var attemptCount = 0; // Attempt to place ship at X different locations while (attemptCount < tryAmount) { var pos = new Pos(Random.Next(0, boardSize), Random.Next(0, boardSize)); var dir = Random.Next(0, 2) == 1 ? ShipDirection.Right : ShipDirection.Down; if (!PlayerLogic.CheckValidShipPlacementPos(player, pos, ship.Size, dir)) { attemptCount++; continue; } ship.SetLocation(pos, dir); break; } if (attemptCount >= tryAmount) { return(false); } } return(true); }
public void DamageGivenGlobalAllTargetsModTest() { Setup.SetupTestInfrastructure(); ActiveGame activeGame = GameContainer.ActiveGame; try { AmountModifier damageGivenMod = new AmountModifier("Obsidion Field", "Increase all damage by 1", ModifierTargets.AllTargets, AmountModifierType.DamageGiven, 1, false); CharacterAccount fromAccount = activeGame.AllTargets[43]; CharacterAccount toAccount = activeGame.AllTargets[87]; GameContainer.AddDamageGivenModifier(damageGivenMod, fromAccount); GameContainer.DealDamage(fromAccount, toAccount, 4, DamageType.Melee); int expectedHealth = 10; int actualhealth = toAccount.CurrentHealth; Assert.IsTrue(expectedHealth == actualhealth, $"{toAccount.Name} health doesn't match expected health. Expected {expectedHealth}, actually {actualhealth}"); int expectedMod = 1; int actualMod = fromAccount.DamageGivenMod; Assert.IsTrue(expectedMod == actualMod, $"{fromAccount.Name} damage given mod doesn't match expected mod. Expected {expectedMod}, actually {actualMod}"); Assert.IsTrue(activeGame.GlobalEnvironmentModifiers.ContainsValue(damageGivenMod), "Global Environment Mods List does not contain expected modifier"); Assert.IsTrue(activeGame.GlobalHeroModifers.ContainsValue(damageGivenMod), "Global Environment Mods List does not contain expected modifier"); Assert.IsTrue(activeGame.GlobalVillainModifiers.ContainsValue(damageGivenMod), "Global Environment Mods List does not contain expected modifier"); foreach (CharacterAccount characterAccount in activeGame.AllTargets.Values) { Assert.IsTrue(characterAccount.DamageGivenModList.ContainsValue(damageGivenMod), $"{characterAccount} does not contain the expected modifier"); } } catch (Exception e) { Assert.Fail("Test failed: " + e); } }
public void DamageGivenOneTimeModTest() { Setup.SetupTestInfrastructure(); ActiveGame activeGame = GameContainer.ActiveGame; try { AmountModifier damageGivenMod = new AmountModifier("Critical Multiplier", "Increase next damage by 1", ModifierTargets.Local, AmountModifierType.DamageGiven, 1, true); CharacterAccount fromAccount = activeGame.AllTargets[43]; CharacterAccount toAccount = activeGame.AllTargets[87]; GameContainer.AddDamageGivenModifier(damageGivenMod, fromAccount); GameContainer.DealDamage(fromAccount, toAccount, 4, DamageType.Melee); int expectedHealth = 10; int actualhealth = toAccount.CurrentHealth; Assert.IsTrue(expectedHealth == actualhealth, $"{toAccount.Name} health doesn't match expected health. Expected {expectedHealth}, actually {actualhealth}"); int expectedMod = 0; int actualMod = fromAccount.DamageGivenMod; Assert.IsTrue(expectedMod == actualMod, $"{fromAccount.Name} damage given mod doesn't match expected mod. Expected {expectedMod}, actually {actualMod}"); } catch (Exception e) { Assert.Fail("Test failed: " + e); } }
public void HealOneTimeModTest() { Setup.SetupTestInfrastructure(); ActiveGame activeGame = GameContainer.ActiveGame; try { AmountModifier healthMod = new AmountModifier("Healing Field", "Increase next healing by 1", ModifierTargets.Local, AmountModifierType.Health, 1, true); CharacterAccount fromAccount = activeGame.AllTargets[43]; CharacterAccount toAccount = activeGame.AllTargets[87]; GameContainer.AddHealthModifier(healthMod, toAccount); GameContainer.DealDamage(fromAccount, toAccount, 4, DamageType.Melee); GameContainer.HealCharacter(toAccount, toAccount, 1); int expectedHealth = 13; int actualhealth = toAccount.CurrentHealth; Assert.IsTrue(expectedHealth == actualhealth, $"{toAccount.Name} health doesn't match expected health. Expected {expectedHealth}, actually {actualhealth}"); int expectedMod = 0; int actualMod = toAccount.HealthMod; Assert.IsTrue(expectedMod == actualMod, $"{toAccount.Name} health mod doesn't match expected mod. Expected {expectedMod}, actually {actualMod}"); } catch (Exception e) { Assert.Fail("Test failed: " + e); } }
public void ImmunityTypeSpecificModTest() { Setup.SetupTestInfrastructure(); ActiveGame activeGame = GameContainer.ActiveGame; try { ImmunityModifier immunityMod = new ImmunityModifier("Flesh of the Sun God", "Ra is Immune to Fire Damage", ModifierTargets.Local, DamageType.Fire); CharacterAccount fromAccount = activeGame.AllTargets[43]; CharacterAccount toAccount = activeGame.AllTargets[87]; GameContainer.AddDamageImmunityModifier(immunityMod, toAccount); GameContainer.DealDamage(fromAccount, toAccount, 4, DamageType.Melee); int expectedHealth = 11; int actualhealth = toAccount.CurrentHealth; Assert.IsTrue(expectedHealth == actualhealth, $"{toAccount.Name} health doesn't match expected health for Melee test. Expected {expectedHealth}, actually {actualhealth}"); GameContainer.DealDamage(fromAccount, toAccount, 4, DamageType.Fire); expectedHealth = 11; actualhealth = toAccount.CurrentHealth; Assert.IsTrue(expectedHealth == actualhealth, $"{toAccount.Name} health doesn't match expected health for Fire test. Expected {expectedHealth}, actually {actualhealth}"); } catch (Exception e) { Assert.Fail("Test failed: " + e); } }
public static bool CheckIfIntersect(Ship ship, Pos newPos, int newSize, ShipDirection newDirection) { // Ship hasn't been placed yet if (ship.ShipPos == null) { return(false); } var padding = ActiveGame.GetRuleVal(RuleType.ShipPadding); // This is one retarded way of doing it, but hey, it works... for (int offset = 0; offset < newSize; offset++) { var newPosOffsetX = newPos.X + (newDirection == ShipDirection.Right ? offset : 0); var newPosOffsetY = newPos.Y + (newDirection == ShipDirection.Right ? 0 : offset); for (int i = 0; i < ship.Size; i++) { var shipPosX = ship.ShipPos.X + (ship.Direction == ShipDirection.Right ? i : 0); var shipPosY = ship.ShipPos.Y + (ship.Direction == ShipDirection.Right ? 0 : i); if (shipPosX >= newPosOffsetX - padding && shipPosX <= newPosOffsetX + padding && shipPosY >= newPosOffsetY - padding && shipPosY <= newPosOffsetY + padding) { return(true); } } } return(false); }
void InitializeModules() { // We would prefer to drop Home all together but then it's difficult to show it up top :) Items.Add(Home); PreInit(Games); PreInit(Mods); PreInit(Missions); PreInit(Servers); //ActivateLastModule(); if (Common.Flags.LockDown) { var activeGame = ActiveGame; if (activeGame.Servers != null) { ActivateModule(ControllerModules.ServerBrowser); } } else { // TODO: Also use RX Router instead ActivateModule(ControllerModules.Home); } /* * TODO: Store per game? * this.WhenAnyValue(x => x.CurrentModule) * .Skip(1) * .Subscribe( * x => { _userSettings.AppOptions.LastModule = x == null ? null : x.ModuleName.ToString(); }); */ ActiveGame.InitModules(); }
public void DamageTakenModTest() { Setup.SetupTestInfrastructure(); ActiveGame activeGame = GameContainer.ActiveGame; try { AmountModifier damageTakenMod = new AmountModifier("HeavyPlating", "Decrease damage taken by 1", ModifierTargets.Local, AmountModifierType.DamageTaken, -1, false); CharacterAccount fromAccount = activeGame.AllTargets[43]; CharacterAccount toAccount = activeGame.AllTargets[87]; GameContainer.AddDamageTakenModifier(damageTakenMod, toAccount); GameContainer.DealDamage(fromAccount, toAccount, 4, DamageType.Melee); int expectedHealth = 12; int actualhealth = toAccount.CurrentHealth; Assert.IsTrue(expectedHealth == actualhealth, $"{toAccount.Name} health doesn't match expected health. Expected {expectedHealth}, actually {actualhealth}"); int expectedMod = -1; int actualMod = toAccount.DamageTakenMod; Assert.IsTrue(expectedMod == actualMod, $"{toAccount.Name} damage taken mod doesn't match expected mod. Expected {expectedMod}, actually {actualMod}"); } catch (Exception e) { Assert.Fail("Test failed: " + e); } }
/// <summary> /// Gets the Active Game In a File System Appropriate Format /// </summary> public static string ToFileSystemAppropriate(this string x) { #if WINDOWS return(x.Replace(" ", "").Replace(".", "")); #else return(ActiveGame.Replace(" ", "").Replace(".", "")); #endif }
void BackTask() { StartMenu.SetActive(true); ExitButton.gameObject.SetActive(true); BackButton.gameObject.SetActive(false); ActiveGame.SetActive(false); Animate = true; }
// PUT api/ActiveGame/5 public HttpResponseMessage Put(int id, ActiveGame value) { if (ModelState.IsValid) { _activeGameRepository.InsertOrUpdate(value); _activeGameRepository.Save(); return(new HttpResponseMessage(HttpStatusCode.NoContent)); } throw new HttpResponseException(HttpStatusCode.BadRequest); }
private void KelimeOyunu_FormClosed(object sender, FormClosedEventArgs e) { //Uygulamadan çıkış yapıldığında geçerli profil dosyasına kayıt yapar. if (ActiveGame.IsGameStarted) { ActiveGame.Abort(); } UserProfileUtils.SaveUserProfile(GlobalVariants.ActiveProfile); GlobalSettings.SaveSettings(); }
private void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); } else { instance = this; DontDestroyOnLoad(this.gameObject); } }
public void InsertOrUpdate(ActiveGame activegame) { if (activegame.Id == default(int)) { // New entity context.ActiveGames.Add(activegame); } else { // Existing entity context.Entry(activegame).State = EntityState.Modified; } }
public static void ChangeRuleValue(RuleType ruleType) { var rule = ActiveGame.GetRule(ruleType); var menu = new Menu { Title = $"Change rule {rule.RuleType}", MenuTypes = new List <MenuType> { MenuType.Input, MenuType.RuleIntInput }, MenuItems = new List <MenuItem> { new MenuItem { Description = $"Current value: {rule.Value}" }, new MenuItem { Description = $"Enter a value between {rule.MinVal} and {rule.MaxVal}" } } }; while (true) { // Run menu, ask user for integer input var input = menu.RunMenu(); // User entered exit shortcut if (input.ToUpper() == MenuInitializers.GoBackItem.Shortcut) { return; } // Attempt to parse input as int if (string.IsNullOrEmpty(input) || !int.TryParse(input, out var value)) { Console.WriteLine("Value not an integer!"); Console.ReadKey(true); continue; } if (!ActiveGame.TryChangeRule(ruleType, value)) { Console.WriteLine("Value not in range!"); Console.ReadKey(true); continue; } Console.WriteLine("Rule value changed!"); Console.ReadKey(true); break; } }
public void OnGet() { if (!Request.Query.ContainsKey("persist")) { ActiveGame.ResetAllRules(); } if (Request.Query.ContainsKey("reset")) { IsStatus = true; StatusMsg = "Rules reverted to default values!"; IsDisplayContinue = true; } }
} //X #endregion #region Methods public static Effect CreateEffect(ActiveGame game, EffectTypes effectType, int cardId = 0, int playerId = 0, int value = 0, bool boolean = false) { Player player = game.Players.FirstOrDefault(o => o.Id == playerId); Card card = game.FindCard(cardId); return(new Effect() { Boolean = boolean, EffectType = effectType, TargetCard = card, TargetPlayer = player, Value = value, }); }
public void processDamageToDefender(ActiveGame game, int damageDealt) { Player defendingPlayer = game.Players.First(o => o.Id == Defender.PlayerId); Card planeswalker = defendingPlayer.Battlefield.Cards.FirstOrDefault(o => o.Id == Defender.PlaneswalkerId); if (Defender.AttackableType == AttackableType.Planeswalker && planeswalker != null)// card not destroyed { planeswalker.AddDamage(game, damageDealt, Card); } else if (Defender.AttackableType == AttackableType.Player) { defendingPlayer.AddDamage(game, damageDealt, Card); } }
private void btBack_Click(object sender, EventArgs e) { if (ActiveGame.IsGameStarted) { MesajSonuç msonuc = Mesaj.mbox.Göster(String.GetLangText("STI_GAME_RETURN"), String.GetLangText("STI_GAME_RETURN_HDR"), MessageBoxButtons.YesNo); if (msonuc.MesajCevap != DialogResult.Yes) { return; } ActiveGame.Resign(); } grpGame.Visible = false; grpStartNew.Visible = true; lblInfo.Text = ""; }
private void closeProfileToolStripMenuItem_Click(object sender, EventArgs e) { MesajSonuç mesajSonuç = Mesaj.mbox.Göster(String.GetLangText("MENU_PROF_CLOSE_PRMPT"), "", MessageBoxButtons.YesNo); if (mesajSonuç.MesajCevap == DialogResult.Yes) { UserProfileUtils.SaveUserProfile(GlobalVariants.ActiveProfile); if (ActiveGame.IsGameStarted) { ActiveGame.Abort(); } GlobalVariants.ActiveProfile = null; CheckProfile(true); } }
private void btnTahminYap_Click(object sender, EventArgs e) { if (!ActiveGame.IsGameStarted) { return; } string inputtext = txtInput.Text.TrimStart('0'); if (inputtext.Length != ActiveGame.ActiveNumber.Length) { Mesaj.mbox.Göster(String.GetLangText("GAME_ERR_THM_LEN", ActiveGame.ActiveNumber.Length)); return; } ActiveGame.EnterGuess(inputtext); }
private void StartGame() { MusicEngine.ButtonSoundEffect(); // kod som startar och lagrar spel i databas try { if (AreAllPlayersBots() == false) { Game game = new Game(); DbOperations.CreateNewGameId(Selected_game_type.Gametype_id); game = DbOperations.GetGameId(); foreach (var player in Selected_players) { DbOperations.StartNewGame(game.Game_Id, player.Player_id); } ActiveGame.SetActiveGame(Selected_players, game.Game_Id, game.Start, game.End, Selected_game_type); if (HelperActive == true) { ActiveGame.Helper = true; } else if (HelperActive == false) { ActiveGame.Helper = false; } MusicEngine.StartStop(); ChangeWindow(); MusicEngine.ButtonSoundEffectGameStart(); } else { MessageBox.Show("Det är inte tillåtet att starta ett spel med enbart botar"); } } catch (PostgresException ex) { MessageBox.Show(ex.Message.ToString()); } }
public void TryToDestroyRow() { // Destroys Row as soon as it is ready if (RowReadyToDestroy()) { // then it destroys everything in this row DestroyRow(); // We pass the time because if the difference between one row and the next row being destroyed is low then we know that they were // destroyed in the same move ActiveGame.AddPoints(time); ActiveGame.UpdateTime(time); // Updating time when the last row was destroyed // then it makes other blocks upstairs fall down TetrisDecrease(index + 1); // + 1 because we want to fall only that blocks which are higher than our destroyed one } }
public static bool CheckIfPosInBoard(Pos pos) { var boardSize = ActiveGame.GetRuleVal(RuleType.BoardSize); // Out of bounds if (pos.X < 0 || pos.X >= boardSize) { return(false); } if (pos.Y < 0 || pos.Y >= boardSize) { return(false); } return(true); }
public void OnGet() { // Players have not been defined yet if (ActiveGame.Players == null || ActiveGame.Players.Count == 0) { IsInvalidAccess = true; return; } // There's no current player so set it if (ActiveGame.CurrentPlayer == null || ActiveGame.NextPlayer == null) { ActiveGame.InitPlayerPointers(); // Just to get rid of IDE warnings if (ActiveGame.CurrentPlayer == null || ActiveGame.NextPlayer == null) { throw new NullReferenceException(); } } // Players haven't placed ships yet if (ActiveGame.CurrentPlayer.Ships.FirstOrDefault(ship => ship.IsPlaced) == null) { IsInvalidAccess = true; return; } if (Request.Query.ContainsKey("save")) { GameSaver.Save(); IsStatus = true; StatusMsg = "Game saved!"; return; } // There's a winner if (ActiveGame.TrySetWinner()) { IsWinner = true; StatusMsg = $"The winner of the game is {ActiveGame.Winner.Name}!"; return; } MainTitle = $"{ActiveGame.CurrentPlayer.Name} is attacking {ActiveGame.NextPlayer.Name}"; IsDisplayBoards = true; }