Example #1
0
        public void FirstBattle_BarbarianRunsAway_3TurnsAfterShieldDestroyed()
        {
            _barbarian.PreBattleSetup(_enemyTeam, _humanTeam, _output, BattleConfigurationSpecialFlag.FirstBarbarianBattle);

            BattleMoveWithTarget moveWithTarget = _barbarian.SetupMove(_enemyTeam, _humanTeam);
            BattleMove           battleMove     = moveWithTarget.Move;
            MultiTurnBattleMove  multiTurnMove  = battleMove as MultiTurnBattleMove;

            Assert.NotNull(multiTurnMove);
            Assert.AreEqual(3, multiTurnMove.Moves.Count);

            for (int i = 0; i < 3; ++i)
            {
                battleMove = multiTurnMove.Moves[i];

                if (i < 2)
                {
                    Assert.IsAssignableFrom <DoNothingMove>(battleMove);
                }
                else
                {
                    Assert.AreEqual(BattleMoveType.Runaway, battleMove.MoveType);
                }
            }
        }
Example #2
0
        public void CastSpell_CorrectlyReflectsSpells_WithCorrectMultiplier([Values(MagicType.Water, MagicType.Earth, MagicType.Wind)] MagicType spellType,
                                                                            [Values(true, false)] bool reflectAll)
        {
            const int spellCost  = 5;
            const int spellPower = 5;
            const int expectedRemainingHealth = 100 - (spellPower * 2);

            Spell      spell       = new Spell("foo", spellType, SpellType.Attack, TargetType.SingleEnemy, spellCost, spellPower);
            BattleMove runawayMove = MoveFactory.Get(BattleMoveType.Runaway);

            MagicType     reflectType = reflectAll ? MagicType.All : spellType;
            ReflectStatus status      = new ReflectStatus(1, reflectType, 2);

            _human.SetHealth(100);
            _human.SetMana(spellCost);
            _human.AddSpell(spell);
            _human.SetMove(spell, 1);
            _human.SetMove(runawayMove);
            _human.SetMoveTarget(_enemy);

            _enemy.AddStatus(status);
            _enemy.SetHealth(100);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.AreEqual(_enemy.MaxHealth, _enemy.CurrentHealth, "enemy should still have full health, the spell should have been reflected!");
            Assert.AreEqual(expectedRemainingHealth, _human.CurrentHealth, $"the human should have lost {spellPower * 2} health from being hit by their own spell reflected at double the power!");
        }
Example #3
0
        protected virtual IFighter _selectTarget(BattleMove move, Team ownTeam, Team enemyTeam)
        {
            IFighter   ret;
            TargetType targetType = move.TargetType;

            if (targetType == TargetType.Self || targetType == TargetType.Field)
            {
                ret = this;
            }
            else
            {
                List <IFighter> fighters = new List <IFighter>();

                switch (targetType)
                {
                case TargetType.SingleEnemy:
                    fighters = enemyTeam.Fighters.Where(f => f.IsAlive()).ToList();
                    break;

                case TargetType.SingleAlly:
                    fighters = Team.Fighters.Where(f => f.IsAlive() && f != this).ToList();
                    break;

                case TargetType.SingleAllyOrSelf:
                    fighters = Team.Fighters.Where(f => f.IsAlive()).ToList();
                    break;
                }

                fighters = move.GetAvailableTargets(fighters).ToList();
                ret      = _selectTarget(fighters);
            }

            return(ret);
        }
Example #4
0
        protected virtual IEnumerable <IFighter> _getViableTargets(BattleMove move, Team enemyTeam)
        {
            IEnumerable <IFighter> viableTargets;

            switch (move.TargetType)
            {
            case TargetType.EnemyTeam:
            case TargetType.SingleEnemy:
                viableTargets = enemyTeam.Fighters.Where(f => f.IsAlive()).ToList();
                break;

            case TargetType.SingleAlly:
                viableTargets = Team.Fighters.Where(f => f.IsAlive() && f != this).ToList();
                break;

            case TargetType.SingleAllyOrSelf:
            case TargetType.OwnTeam:
                viableTargets = Team.Fighters.Where(f => f.IsAlive()).ToList();
                break;

            case TargetType.Self:
                viableTargets = Team.Fighters.Where(f => f == this && f.IsAlive());
                break;

            case TargetType.Field:
                viableTargets =
                    Team.Fighters.Where(f => f.IsAlive()).Concat(enemyTeam.Fighters.Where(f => f.IsAlive()));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(viableTargets);
        }
Example #5
0
        public void Level1ShieldGuy_CorrectlyDeterminesViableMoves_NoShieldMove()
        {
            IronBattleShield shield = new IronBattleShield(3, 0, 0);

            _level1ShieldGuy.SetBattleShield(shield);
            _level1ShieldGuy.BattleShield.DecrementHealth(1);
            _ally1.SetBattleShield(shield);
            _ally2.SetBattleShield(shield);

            _chanceService.PushWhichEventsOccur(0);
            BattleMove returnedMove = _level1ShieldGuy.SelectMove(_shieldGuyTeam, _humanTeam);

            double[] lastEventOccursArgs = _chanceService.LastEventOccursArgs;

            Assert.AreEqual(3, lastEventOccursArgs.Length);
            Assert.AreEqual(0.2, lastEventOccursArgs[0]);
            Assert.AreEqual(0.4, lastEventOccursArgs[1]);
            Assert.AreEqual(0.4, lastEventOccursArgs[2]);

            Assert.AreEqual(BattleMoveType.Attack, returnedMove.MoveType);

            _chanceService.PushWhichEventsOccur(1);
            returnedMove = _level1ShieldGuy.SelectMove(_shieldGuyTeam, _humanTeam);
            ShieldFortifyingMove shieldFortifyingMove = returnedMove as ShieldFortifyingMove;

            Assert.NotNull(shieldFortifyingMove);
            Assert.AreEqual(ShieldFortifyingType.Defense, shieldFortifyingMove.FortifyingType);

            _chanceService.PushWhichEventsOccur(2);
            returnedMove         = _level1ShieldGuy.SelectMove(_shieldGuyTeam, _humanTeam);
            shieldFortifyingMove = returnedMove as ShieldFortifyingMove;
            Assert.NotNull(shieldFortifyingMove);
            Assert.AreEqual(ShieldFortifyingType.Health, shieldFortifyingMove.FortifyingType);
        }
Example #6
0
        public void MoveFactory_SmokeTest()
        {
            BattleMove ret = null;

            Assert.DoesNotThrow(() => ret = MoveFactory.Get(BattleMoveType.ShieldBuster));
            Assert.NotNull(ret);
        }
Example #7
0
        protected override IFighter _selectTarget(BattleMove move, Team ownTeam, Team enemyTeam)
        {
            IEnumerable <IFighter> viableTargets;
            IFighter ret;

            if (move == _ironShieldMove)
            {
                viableTargets = GetAlliesWithoutShield(ownTeam);
                ret           = _selectTarget(viableTargets.ToList());
            }
            else if (move == _fortifyShield)
            {
                viableTargets = GetAlliesWithShield(ownTeam);
                ret           = _selectTarget(viableTargets.ToList());
            }
            else if (move == _healShield)
            {
                viableTargets = GetAlliesWithDamagedShield(ownTeam);
                ret           = _selectTarget(viableTargets.ToList());
            }
            else
            {
                ret = base._selectTarget(move, ownTeam, enemyTeam);
            }

            return(ret);
        }
Example #8
0
        public void CastSpell_CorrectlyDoesNotReflectsSpells_ReflectStatus_DoesNotMatchAttackingType(
            [Values(MagicType.Fire, MagicType.Ice, MagicType.Lightning)] MagicType spellType,
            [Values(MagicType.Wind, MagicType.Earth, MagicType.Water)] MagicType reflectType)
        {
            const int spellCost  = 5;
            const int spellPower = 5;
            const int expectedRemainingHealth = 100 - spellPower;

            Spell         spell       = new Spell("foo", spellType, SpellType.Attack, TargetType.SingleEnemy, spellCost, spellPower);
            BattleMove    runawayMove = MoveFactory.Get(BattleMoveType.Runaway);
            ReflectStatus status      = new ReflectStatus(1, reflectType);

            _human.SetHealth(100);
            _human.SetMana(spellCost);
            _human.SetMagicStrength(0);
            _human.SetMagicBonus(spellType, 0);
            _human.SetMagicResistance(0);
            _human.SetResistanceBonus(spellType, 0);
            _human.AddSpell(spell);
            _human.SetMove(spell, 1);
            _human.SetMove(runawayMove);
            _human.SetMoveTarget(_enemy);

            _enemy.AddStatus(status);
            _enemy.SetHealth(100);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.AreEqual(_human.MaxHealth, _human.CurrentHealth, "human should still have full health, the spell should not have been reflected!");
            Assert.AreEqual(expectedRemainingHealth, _enemy.CurrentHealth, "the enemy should have lost 5 health from being hit by the spell!");
        }
Example #9
0
        protected void BuildMenuActions(BattleMove move = null)
        {
            if (move == null || move.TargetType == TargetType.SingleEnemy)
            {
                MenuActions = _enemyTeam.Fighters.Where(enemy => enemy.IsAlive()).Select(enemy => new MenuAction(enemy.DisplayName, fighter: enemy)).ToList();
            }
            else
            {
                switch (move.TargetType)
                {
                case TargetType.SingleAlly:
                case TargetType.SingleAllyOrSelf:
                    IEnumerable <IFighter> fighters = _ownTeam.Fighters.Where(fighter => fighter.IsAlive());

                    if (move.TargetType == TargetType.SingleAlly)
                    {
                        fighters = fighters.Where(f => f != Owner);
                    }

                    MenuActions = fighters.Select(fighter => new MenuAction(fighter.DisplayName, fighter: fighter)).ToList();

                    break;

                case TargetType.Self:
                    MenuActions = new List <MenuAction>
                    {
                        new MenuAction(Owner.DisplayName, fighter: Owner)
                    };
                    break;
                }
            }
        }
Example #10
0
        public void MalevolenceCharge_CorrectlyCapsAtMaximumChargeAmount()
        {
            //arrange
            int maximumMalevolenceCharge = Shade.MaxMalevolenceLevel;

            List <BattleMove> executableMoves = _shade1.GetExecutableMoves(_humanTeam);
            BattleMove        chargeMove      = executableMoves.First(m => m.MoveType == BattleMoveType.Special);
            BattleMove        attackMove      = executableMoves.First(m => m.MoveType == BattleMoveType.ConditionalPowerAttack);

            _humanFighter.SetHealth(maximumMalevolenceCharge + 1);
            _humanFighter.SetDefense(_shade1.Strength);
            int totalTurnsCharging = maximumMalevolenceCharge * 2;

            _humanFighter.SetMove(_runawayMove);

            for (var i = 0; i < totalTurnsCharging; ++i)
            {
                _battleManager.SetBattleMoveQueues(new BattleMoveQueue(new List <BattleMoveWithTarget>
                {
                    new BattleMoveWithTarget(chargeMove, _shade1, _shade1)
                }));
            }

            _battleManager.SetBattleMoveQueues(new BattleMoveQueue(new List <BattleMoveWithTarget>
            {
                new BattleMoveWithTarget(attackMove, _humanFighter, _shade1)
            }));
            _chanceService.PushAttackHitsNotCrit();

            //Act
            _battleManager.Battle(_humanTeam, new Team(TestMenuManager.GetTestMenuManager(), _shade1));

            //Assert
            Assert.AreEqual(1, _humanFighter.CurrentHealth);
        }
Example #11
0
 public MenuSelection(string description, BattleMove move, IFighter target, IMoveExecutor moveExecutor = null)
 {
     Description  = description;
     Move         = move;
     Target       = target;
     MoveExecutor = moveExecutor;
 }
Example #12
0
        public void CastSpell_SpellsVanishIfReflectedTwice([Values(MagicType.Fire, MagicType.Ice, MagicType.Lightning)] MagicType spellType,
                                                           [Values(true, false)] bool reflectAll)
        {
            const int spellCost  = 5;
            const int spellPower = 5;

            Spell      spell       = new Spell("foo", spellType, SpellType.Attack, TargetType.SingleEnemy, spellCost, spellPower);
            BattleMove runawayMove = MoveFactory.Get(BattleMoveType.Runaway);

            MagicType     reflectType = reflectAll ? MagicType.All : spellType;
            ReflectStatus status      = new ReflectStatus(1, reflectType);

            _human.SetHealth(100);
            _human.SetMana(spellCost);
            _human.AddStatus(status);
            _human.AddSpell(spell);
            _human.SetMove(spell, 1);
            _human.SetMove(runawayMove);
            _human.SetMoveTarget(_enemy);

            _enemy.AddStatus(status);
            _enemy.SetHealth(100);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.AreEqual(_enemy.MaxHealth, _enemy.CurrentHealth, "enemy should still have full health, the spell should have disappeared without hurting anyone!");
            Assert.AreEqual(_human.MaxHealth, _human.CurrentHealth, "the human should still have full health, the spell should have disappeared without hurting anyone");
        }
        string GetInstructionLogInfo(RpBattleInstructionList rpMessage)
        {
            System.Text.StringBuilder logSb = new System.Text.StringBuilder();
            logSb.Append("收到数据 " + rpMessage.FrameCount + "\t\t");
            for (int i = 0; i < rpMessage.BattleInstructionList.Count; ++i)
            {
                var item = rpMessage.BattleInstructionList [i];
                logSb.Append(item.SceneUnitId.ToString() + "\t");
                logSb.Append(item.InstructionType.ToString() + "\t");
                switch (item.InstructionType)
                {
                case BattleInstructionType.Move:
                    BattleMove moveInstruct = item as BattleMove;
                    logSb.Append(moveInstruct.MoveAngle);
                    break;

                case BattleInstructionType.StopMove:
                    break;

                default:
                    break;
                }
            }
            return(logSb.ToString());
        }
        public void SetupMove_PrintsCorrectPrompts()
        {
            Fairy fairy = (Fairy)FighterFactory.GetFighter(FighterType.Fairy, 1);

            _fighter.SetEnemy(fairy);

            _input.Push("1", "1");

            _fighter.SetupMove(_ownTeam, _enemyTeam);

            MockOutputMessage[] outputs = _output.GetOutputs();

            int expectedOutputLength = 5;

            //menu prompt for both menus, plus "back," "help," and "status" option from target menu
            expectedOutputLength += fairy.AvailableMoves.Count + _enemyTeam.Fighters.Count;
            Assert.AreEqual(expectedOutputLength, outputs.Length);

            int i = 0;

            MockOutputMessage output = outputs[i++];

            Assert.AreEqual($"You are currently selecting a move for {fairy.DisplayName}. What move will you use?\n", output.Message);
            Assert.AreEqual(ConsoleColor.Cyan, output.Color);

            for (int j = 0; j < fairy.AvailableMoves.Count; ++j)
            {
                BattleMove move = fairy.AvailableMoves[j];

                output = outputs[i++];
                Assert.AreEqual($"{j + 1}. {move.Description}\n", output.Message);
            }
        }
        public override BattleMoveWithTarget SetupMove(Team ownTeam, Team enemyTeam)
        {
            BattleMoveWithTarget ret;

            BattleMove move = BeforeSelectMove();

            if (move == null)
            {
                HumanControlledEnemyMenu menu = new HumanControlledEnemyMenu(_input, _output, _menuFactory);

                menu.Build(this, ownTeam, enemyTeam, null);

                MenuSelection menuSelection = menu.GetInput();

                move            = menuSelection.Move;
                _selectedTarget = menuSelection.Target;
                ret             = new BattleMoveWithTarget(menuSelection, this);
            }
            else
            {
                ret = new BattleMoveWithTarget(move, _selectedTarget, this);
            }

            AfterSelectMove(move);

            return(ret);
        }
Example #16
0
        public override MenuSelection GetInput(BattleMove move, IMoveExecutor moveExecutor)
        {
            MenuSelection ret;

            if (EchoBattleMoveInput)
            {
                ret = new MenuSelection(move.Description, move, Owner, moveExecutor);
            }
            else
            {
                if (_requiresBattleMoveMenuSelections.Count > 0)
                {
                    PrintFullMenuPrompt();
                    ret = _requiresBattleMoveMenuSelections.Dequeue();
                }
                else if (_menuSelections.Count > 0)
                {
                    PrintFullMenuPrompt();
                    ret = _menuSelections.Dequeue();
                }
                else
                {
                    ret = InnerMenu?.GetInput() ?? base.GetInput();
                }
            }

            return(ret);
        }
Example #17
0
        public override void Entered(object param)
        {
            mUnitBase.skillComp.BreakSkill();
            BattleMove moveInstruction = param as BattleMove;

            mMoveAngle = moveInstruction.MoveAngle;
            Logger.LogInfo("设置移动指令  " + mMoveAngle);
        }
Example #18
0
        public override MenuSelection GetInput(BattleMove move, IMoveExecutor moveExecutor)
        {
            BuildMenuActions(move);

            var originalRet = base.GetInput();

            return((originalRet.Description == "back") ? new MenuSelection("back", null, null) : new MenuSelection("", move, originalRet.Target, moveExecutor));
        }
Example #19
0
        /// <summary>
        /// Initialize the modify event.
        /// </summary>
        /// <param name="timeline">The timeline this event is part of.</param>
        /// <param name="start">The start of the event.</param>
        /// <param name="dependentOn">An optional event to be dependent upon, ie. wait for.</param>
        /// <param name="move">The move to calculate impact from.</param>
        protected virtual void Initialize(Timeline timeline, float start, TimelineEvent dependentOn, BattleMove move)
        {
            //Call the base method.
            base.Initialize(timeline, start, dependentOn);

            //Initialize the variables.
            _Move = move;
        }
Example #20
0
 public void ReadFromByteArray(ByteArray byteArray)
 {
     this.Player    = byteArray.ReadUTF();
     this.Move      = BattleMoveHelper.ReadFromByteArray(byteArray);
     this.Pokemon   = PokemonIndexHelper.ReadFromByteArray(byteArray);
     this.Target    = TargetIndexHelper.ReadFromByteArray(byteArray);
     this.MoveIndex = byteArray.ReadByte();
 }
Example #21
0
        public void BattleMoveQueue_SortOperation_DefaultsBySpeedAndPriority()
        {
            TestHumanFighter fighter1 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter2 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter3 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter4 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter5 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter6 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter7 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter8 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);
            TestHumanFighter fighter9 = (TestHumanFighter)TestFighterFactory.GetFighter(TestFighterType.TestHuman, 1);

            TestHumanFighter[] expectedOrderedFighters =
            {
                fighter9, fighter6, fighter3, //the high priority
                fighter8, fighter5, fighter2, //the med priority
                fighter7, fighter4, fighter1  //the low priority
            };

            fighter1.SetSpeed(0);
            fighter2.SetSpeed(0);
            fighter3.SetSpeed(0);
            fighter4.SetSpeed(1);
            fighter5.SetSpeed(1);
            fighter6.SetSpeed(1);
            fighter7.SetSpeed(2);
            fighter8.SetSpeed(2);
            fighter9.SetSpeed(2);

            BattleMove lowPriorityMove  = new BattleMove("foo", BattleMoveType.DoNothing, TargetType.Self, -1);
            BattleMove medPriorityMove  = new BattleMove("bar", BattleMoveType.DoNothing, TargetType.Self);
            BattleMove highPriorityMove = new BattleMove("baz", BattleMoveType.DoNothing, TargetType.Self, 1);

            List <BattleMoveWithTarget> initializerList = new List <BattleMoveWithTarget>
            {
                new BattleMoveWithTarget(lowPriorityMove, fighter1, fighter1),
                new BattleMoveWithTarget(lowPriorityMove, fighter4, fighter4),
                new BattleMoveWithTarget(lowPriorityMove, fighter7, fighter7),
                new BattleMoveWithTarget(medPriorityMove, fighter2, fighter2),
                new BattleMoveWithTarget(medPriorityMove, fighter5, fighter5),
                new BattleMoveWithTarget(medPriorityMove, fighter8, fighter8),
                new BattleMoveWithTarget(highPriorityMove, fighter3, fighter3),
                new BattleMoveWithTarget(highPriorityMove, fighter6, fighter6),
                new BattleMoveWithTarget(highPriorityMove, fighter9, fighter9)
            };

            BattleMoveQueue queue = new BattleMoveQueue(initializerList);

            queue.Sort();

            for (int i = 0; i < 9; ++i)
            {
                BattleMoveWithTarget move  = queue.Pop();
                IFighter             owner = move.Owner;
                Assert.AreEqual(expectedOrderedFighters[i], owner, $"i: {i}");
            }
        }
Example #22
0
    public AttackEffect theEffect;     //the effect itself

    public void copy(BattleMove other) //a copy constructor
    {
        this.theType    = other.theType;
        this.moveName   = other.moveName;
        this.movePower  = other.movePower;
        this.moveMpCost = other.moveMpCost;
        this.moveSpCost = other.moveSpCost;
        this.theEffect  = other.theEffect;
    }
    // Use this for initialization
    void Start()
    {
        Current_move = Battle_moves [0];

        Original_HP = HP;
        HP_Bar_UI_quad.GetComponent <Renderer> ().material.color = Color.green;
        Old_HP = HP;
        New_HP = HP;
    }
        /// <summary>
        /// Initialize the modify event.
        /// </summary>
        /// <param name="timeline">The timeline this event is part of.</param>
        /// <param name="start">The start of the event.</param>
        /// <param name="dependentOn">An optional event to be dependent upon, ie. wait for.</param>
        /// <param name="move">The move to modify.</param>
        /// <param name="character">The character whos state of control will be modified.</param>
        /// <param name="control">The new state of control.</param>
        protected virtual void Initialize(Timeline timeline, float start, TimelineEvent dependentOn, BattleMove move, Creature character, bool control)
        {
            //Call the base method.
            base.Initialize(timeline, start, dependentOn);

            //Initialize the variables.
            _Move = move;
            _Character = character;
            _HasControl = control;
        }
Example #25
0
        public override BattleMove SelectMove(Team ownTeam, Team enemyTeam)
        {
            double[] chancesArray = GenerateMoveChances();

            int whichMoveIndex = ChanceService.WhichEventOccurs(chancesArray);

            BattleMove ret = AvailableMoves[whichMoveIndex];

            return(ret);
        }
Example #26
0
        public void ShadeFiltersBasicAttackFromExecutableMoves()
        {
            List <BattleMove> availableMoves  = _shade1.AvailableMoves;
            List <BattleMove> executableMoves = _shade1.GetExecutableMoves(_humanTeam);

            Assert.AreEqual(1, availableMoves.Count - executableMoves.Count);

            BattleMove filteredMove = availableMoves.FirstOrDefault(bm => !executableMoves.Contains(bm));

            Assert.AreEqual(BattleMoveType.Attack, filteredMove?.MoveType);
        }
Example #27
0
        public void FirstBattle_BarbarianDoesNothingWhileEquippedWithShield()
        {
            _barbarian.PreBattleSetup(_enemyTeam, _humanTeam, _output, BattleConfigurationSpecialFlag.FirstBarbarianBattle);
            BattleMoveWithTarget moveWithTarget = _barbarian.GetZeroTurnMove(_enemyTeam, _humanTeam);
            ShieldMove           move           = moveWithTarget.Move as ShieldMove;

            _barbarian.SetBattleShield(move?.Shield as BattleShield);

            BattleMove battleMove = _barbarian.SelectMove(_enemyTeam, _humanTeam);

            Assert.IsAssignableFrom <DoNothingMove>(battleMove);
        }
Example #28
0
        protected BattleMove AfterSelectMove(BattleMove move)
        {
            var multiMove = move as MultiTurnBattleMove;

            if (multiMove != null)
            {
                _multiMove      = multiMove;
                _multiMoveIndex = 1;
            }

            return(move);
        }
Example #29
0
    public void EnemyAttack()
    {
        List <BattleChar> players       = activeBattlers.Where(a => a.isPlayer && a.currentHp > 0).ToList();
        BattleChar        defendingChar = players[Random.Range(0, players.Count)];
        //character attack
        int        selectAttack = Random.Range(0, activeBattlers[currentTurn].movesAvailable.Length);
        BattleMove battleMove   = movesList.Where(m => m.moveName == activeBattlers[currentTurn].movesAvailable[selectAttack]).FirstOrDefault();

        Instantiate(battleMove.theEffect, defendingChar.transform.position, defendingChar.transform.rotation);
        Instantiate(enemyAttackEffect, activeBattlers[currentTurn].transform.position, activeBattlers[currentTurn].transform.rotation);
        DealDamage(defendingChar, battleMove.movePower);
    }
        public void TestEnemyFighter_GetMove_CorrectlyGetsIndefiniteMove()
        {
            AttackBattleMove move = new AttackBattleMove("foo", TargetType.SingleEnemy, 100, 0);

            _enemy.SetMove(move);

            for (var i = 0; i < 10; ++i)
            {
                BattleMove returnedMove = _enemy.GetMove();

                Assert.AreEqual(move, returnedMove);
            }
        }
        public IFighter GetMoveTarget(BattleMove moveToExecute = null)
        {
            IFighter ret = null;

            if (_moveTarget != null)
            {
                ret = _moveTarget;
            }
            else if (moveToExecute != null && (moveToExecute.TargetType == TargetType.Self || moveToExecute.TargetType == TargetType.Field))
            {
                ret = this;
            }
            return(ret);
        }
Example #32
0
        public void TestUndoDebuffsEffect_IndividualEffect()
        {
            StatMultiplierStatus lowerAttackStatus    = new StatMultiplierStatus(3, StatType.Strength, 1.0 / 3);
            StatusMove           lowerEnemyAttackMove = new StatusMove("raise attack", TargetType.SingleEnemy, lowerAttackStatus);

            UndoDebuffsStatus undoDebuffStatus = new UndoDebuffsStatus(1);
            StatusMove        undoDebuffMove   = new StatusMove("reset stats", TargetType.SingleAlly, undoDebuffStatus);

            TestHumanFighter fighter2 = new TestHumanFighter("foo 2", 1);

            _humanTeam = new TestTeam(_humanFighter, fighter2);

            //enemy won't be killed if the status isn't assigned to _fighter2
            _enemy.SetHealth(3);
            _enemy.SetSpeed(2);
            _enemy.SetMove(lowerEnemyAttackMove);
            _chanceService.PushEventOccurs(true); //status hits
            _enemy.SetMoveTarget(fighter2);

            _humanFighter.SetSpeed(1);
            _humanFighter.SetMove(undoDebuffMove);
            _chanceService.PushEventOccurs(true); //status hits
            _humanFighter.SetMoveTarget(fighter2);
            _logger.Subscribe(EventType.StatusAdded, fighter2);
            _logger.Subscribe(EventType.StatusRemoved, fighter2);

            BattleMove attack = MoveFactory.Get(BattleMoveType.Attack);

            fighter2.SetStrength(3);
            fighter2.SetMove(attack);
            fighter2.SetMoveTarget(_enemy);
            _chanceService.PushEventOccurs(true);  //attack hits
            _chanceService.PushEventOccurs(false); //attack is not a crit

            //once Statuses are removed after battle, won't be able to
            _battleManager.Battle(_humanTeam, _enemyTeam);

            List <EventLog> logs = _logger.Logs;

            Assert.AreEqual(2, logs.Count);

            EventLog log = logs[1];

            Assert.AreEqual(EventType.StatusRemoved, log.Type);
            StatusRemovedEventArgs e = log.E as StatusRemovedEventArgs;

            Assert.NotNull(e);
            Assert.IsTrue(lowerAttackStatus.AreEqual(e.Status));
        }
 /// <summary>
 /// Constructor for a modify event.
 /// </summary>
 /// <param name="timeline">The timeline this event is part of.</param>
 /// <param name="start">The start of the event.</param>
 /// <param name="dependentOn">An optional event to be dependent upon, ie. wait for.</param>
 /// <param name="move">The move who will be modified.</param>
 /// <param name="isCancelable">Whether the move can be cancelled or not.</param>
 public ModifyCancelableEvent(Timeline timeline, float start, TimelineEvent dependentOn, BattleMove move, bool isCancelable)
 {
     Initialize(timeline, start, dependentOn, move, isCancelable);
 }
 /// <summary>
 /// Constructor for a modify event.
 /// </summary>
 /// <param name="timeline">The timeline this event is part of.</param>
 /// <param name="start">The start of the event.</param>
 /// <param name="dependentOn">An optional event to be dependent upon, ie. wait for.</param>
 /// <param name="move">The move to modify.</param>
 /// <param name="character">The character whos state of control will be modified.</param>
 /// <param name="control">The new state of control.</param>
 public ModifyControlEvent(Timeline timeline, float start, TimelineEvent dependentOn, BattleMove move, Creature character, bool control)
 {
     Initialize(timeline, start, dependentOn, move, character, control);
 }
Example #35
0
 /// <summary>
 /// Constructor for a recoil event.
 /// </summary>
 /// <param name="timeline">The timeline this event is part of.</param>
 /// <param name="start">The start of the event.</param>
 /// <param name="dependentOn">An optional event to be dependent upon, ie. wait for.</param>
 /// <param name="move">The move to calculate impact from.</param>
 public ImpactEvent(Timeline timeline, float start, TimelineEvent dependentOn, BattleMove move)
 {
     Initialize(timeline, start, dependentOn, move);
 }