Пример #1
0
        public override IEnumerable Think()
        {
            Skill skill = null;
            List<Battler> doers = new List<Battler>();
            List<Battler> targets = new List<Battler>();

            Messenger.AddLine( false, "{0}の行動は?", Name );
            skill = CUIMessage.Select( Score.Skills, s => s.Name );

            #region Doer/Target
            var members = Battle.GetParty( this, false, true );
            if( skill.DoerNum.HasValue )
            {
                if( skill.DoerNum > members.Count() + 1 )
                {
                    yield break;
                }

                doers.Add( this );

                if( skill.DoerNum > 1 )
                {
                    Messenger.AddLine( false, "誰に協力してもらう?" );
                    doers.AddRange( CUIMessage.Select( members, skill.DoerNum.Value - 1, b => b.Name ) );
                }
            }
            else
            {
                doers.AddRange( members );
            }

            var rivals = Battle.GetRival( this, true );
            if( skill.TargetNum.HasValue )
            {
                if( rivals.Count() == 1 )
                {
                    targets.Add( rivals.First() );
                }
                else
                {
                    Messenger.AddLine( false, "だれに?" );
                    targets.AddRange( CUIMessage.Select( rivals, skill.TargetNum.Value, b => b.Name ) );
                }
            }
            else
            {
                targets.AddRange( rivals );
            }
            #endregion

            if( skill != null )
                Tactics = new Tactics( skill, doers, targets );

            Messenger.AddLine();

            yield break;
        }
Пример #2
0
        public virtual IEnumerable<EventNode> OnTurn()
        {
            IEnumerable<EventNode> result = null;

            if( Tactics != null && Tactics.Skill.CanExecute( Battle, this ) )
            {
                if( Tactics.Skill.aliveOnly && Tactics.Skill.TargetNum.HasValue && Tactics.Skill.TargetNum > Tactics.Targets.Count( x => x.IsAlive ) )
                {
                    var list = new List<Battler>( Tactics.Targets.Where( x => x.IsAlive ) );
                    var rivals = Battle.GetRival( this, Tactics.Skill.aliveOnly ).Except( list );
                    Tactics.Targets = list.Concat( rivals.GetRandom( Math.Min( rivals.Count(), Tactics.Skill.TargetNum.Value - list.Count ) ) );
                }
                if( Tactics.Skill.DoerNum.HasValue && Tactics.Skill.DoerNum > Tactics.Doers.Count( x => x.IsAlive ) )
                {
                    var list = new List<Battler>( Tactics.Targets.Where( x => x.IsAlive ) );
                    var members = Battle.GetParty( this, true, true ).Except( list );
                    if( Tactics.Skill.DoerNum - list.Count > members.Count() )
                        return Enumerable.Empty<EventNode>();
                    else
                        Tactics.Doers = list.Concat( members.GetRandom( Math.Min( members.Count(), Tactics.Skill.TargetNum.Value - list.Count ) ) );
                }

                result = Tactics.Skill.Subscribe( Battle, Tactics.Doers, Tactics.Targets );
            }
            else
            {
                result = Enumerable.Empty<EventNode>();
            }

            Tactics = null;
            return result;
        }
Пример #3
0
        public virtual IEnumerable Think()
        {
            var skill = Score.Skills.Where( x => x.CanExecute( Battle, this ) ).GetRandom();
            List<Battler> doers = new List<Battler>();
            List<Battler> targets = new List<Battler>();

            if( skill.TargetNum.HasValue )
            {
                for( int i = 0; i < skill.TargetNum; i++ )
                {
                    targets.Add( Battle.GetRival( this, true ).GetRandom() );
                }
            }
            else
            {
                targets = Battle.GetRival( this, true ).ToList();
            }

            if( skill.DoerNum.HasValue )
            {
                doers.Add( this );
                for( int i = 0; i < skill.DoerNum - 1; i++ )
                {
                    doers.Add( Battle.GetParty( this, true, true ).GetRandom() );
                }
            }
            else
            {
                doers = Battle.GetParty( this, true, true ).ToList();
            }

            Tactics = new Tactics( skill, new[] { this }, targets );
            yield break;
        }