public void StateDeepCopyTest() { var game = new GameInstance(3); var ability = new AbilityInfo(3, 1, 1, 0); var abilityId = game.AddAbilityWithInfo(ability); var abilities1 = new List <int>(); var abilities2 = new List <int> { abilityId }; var info1 = new MobInfo(TeamColor.Red, 5, 1, 0, abilities1); var info2 = new MobInfo(TeamColor.Blue, 5, 1, 1, abilities2); var m1 = game.AddMobWithInfo(info1); var m2 = game.AddMobWithInfo(info2); game.PrepareEverything(); var copy = game.CopyStateOnly(); TestHelpers.GameInstancesEqual(game, copy); var copy2 = copy.CopyStateOnly(); ActionEvaluator.F(copy2, UctAction.AbilityUseAction(abilityId, m1, m2)); TestHelpers.GameInstancesEqual(game, copy); TestHelpers.MobManagersEqual(game.MobManager, copy2.MobManager); TestHelpers.MapsEqual(game.Map, copy2.Map); }
public void IsFinishedFastAutoUpdateTest() { var game = new GameInstance(3); var a1 = game.AddAbilityWithInfo(new AbilityInfo(5, 1, 5, 0)); var m1 = game.AddMobWithInfo(new MobInfo(TeamColor.Red, 1, 10, 0, new[] { a1 })); var m2 = game.AddMobWithInfo(new MobInfo(TeamColor.Blue, 1, 10, 0, new[] { a1 })); game.PrepareEverything(); Assert.IsFalse(game.IsFinished); ActionEvaluator.FNoCopy(game, UctAction.AbilityUseAction(a1, m1, m2)); Assert.IsTrue(game.IsFinished); }
private void AttackMob(int targetId) { Debug.Assert(SelectedAbilityIndex != null, "_gameInstance.TurnManager.SelectedAbilityIndex != null"); var abilityIndex = SelectedAbilityIndex.Value; var mobId = _game.CurrentMob; Debug.Assert(mobId != null); var abilityId = _game.MobManager.MobInfos[mobId.Value].Abilities[abilityIndex]; var visibilityPath = _game.Map.AxialLinedraw(_game.State.MobInstances[mobId.Value].Coord, _game.State.MobInstances[targetId].Coord); bool isVisible = true; foreach (var coord in visibilityPath) { if (_game.Map[coord] == HexType.Wall) { isVisible = false; } } if (isVisible) { bool withinRange = (visibilityPath.Count - 1) <= _game.MobManager.Abilities[abilityId].Range; if (withinRange) { InputManager.Instance.UserInputEnabled = false; _eventHub.SlowPlayAction(_game, UctAction.AbilityUseAction(abilityId, mobId.Value, targetId)) .ContinueWith(t => { InputManager.Instance.UserInputEnabled = true; }) .LogContinuation(); } else { ShowMessage("Target is outside the range of the currently selected ability."); } } else { ShowMessage("The target is not visible."); } }