コード例 #1
0
ファイル: Shade.cs プロジェクト: Jsweeney1000/SimpleRPG
        protected override IEnumerable <IFighter> _getViableTargets(BattleMove move, Team enemyTeam)
        {
            IEnumerable <IFighter> viableTargets;

            StatusMove         moveAsStatusMove    = move as StatusMove;
            ShadeAbsorbingMove moveAsAbsorbingMove = move as ShadeAbsorbingMove;

            if (moveAsStatusMove != null && move.TargetType == TargetType.SingleEnemy)
            {
                viableTargets =
                    enemyTeam.Fighters.Where(f => !f.Statuses.Exists(s => s.AreEqual(moveAsStatusMove.Status)) && f.IsAlive());
            }
            else if (moveAsAbsorbingMove != null)
            {
                viableTargets = Team.Fighters.OfType <Shade>().Where(s => s.IsAlive() && s != this);
            }
            else
            {
                viableTargets = base._getViableTargets(move, enemyTeam);
            }

            return(viableTargets);
        }
コード例 #2
0
ファイル: ShadeTests.cs プロジェクト: Jsweeney1000/SimpleRPG
        public void BattleManager_CorrectlyPrintsShadeAbsorbMoveExecutionText()
        {
            //arrange
            ShadeAbsorbingMove absorbingMove = _shade1.GetExecutableMoves(_humanTeam).FirstOrDefault(m => m is ShadeAbsorbingMove) as ShadeAbsorbingMove;

            _humanFighter.SetMove(_doNothingMove, 1);
            _humanFighter.SetMove(_runawayMove);

            _chanceService.PushWhichEventsOccur(_absorptionMoveIndex, 0, _malevolenceChargeIndex, _malevolenceChargeIndex);
            _chanceService.PushWhichEventsOccur(_malevolenceChargeIndex, _malevolenceChargeIndex);

            SilentBattleConfiguration config = new SilentBattleConfiguration();

            //set up the output message now, before the display name chanegs from the absorption
            string expectedOutputMessage = $"{_shade1.DisplayName} {absorbingMove?.ExecutionText.Replace(Globals.TargetReplaceText, _shade2.DisplayName)}\n";

            //act
            _battleManager.Battle(_humanTeam, _shadeTeam, config: config);

            MockOutputMessage output = _output.GetOutputs()[0];

            Assert.AreEqual(expectedOutputMessage, output.Message);
        }