示例#1
0
        public override Advisor DisplayChooseAdvisorToInfluence( Player p )
        {
            Advisor chosenAdvisor = null;
            switch( this.Mode )
            {
                case graphicsMode.CLI:
                    AdvisorCollection CanBeInfluenced = DiceAllocationManager.Instance.InfluenceableAdvisors( p );
                    Console.WriteLine( "\n{0}, choose an advisor to influence. (Enter 'p' to pass)", p.Name );
                    Console.WriteLine( "You may influence:" );
                    foreach( Advisor a in CanBeInfluenced )
                    {
                        Console.WriteLine( "{0}. {1} - {2}", a.Order, a.Name, a.Description );
                    }

                    bool exitLoop = false;
                    do
                    {
                        string choice =  Console.ReadLine();
                        if( choice.Equals( "p", StringComparison.OrdinalIgnoreCase ) )
                        {
                            Console.WriteLine( "{0} passed.", p.Name );
                            p.AllocateAllDice();
                            return null;
                        }
                        // TODO: Add a check for this value (should be > 0 and < 18 )
                        //
                        chosenAdvisor = GameManager.Instance.Advisors[int.Parse( choice ) - 1];
                        if( CanBeInfluenced.Contains( chosenAdvisor ) )
                        {
                            exitLoop = true;
                        }
                        else
                        {
                            exitLoop = false;
                            Console.WriteLine( "Invalid Selection!" );
                        }
                    }
                    while( !exitLoop );

                    //Bug:26 FIXED
                    // If the chosen advisor is already influenced, the player must be using the envoy, so we remove it
                    if( chosenAdvisor.IsInfluenced )
                    {
                        if( p.Envoy == true )
                        {
                            p.Envoy = false;
                        }
                        else
                        {
                            throw new Exception( "A player tried to influence an advisor that was already influenced, but he didn't have the envoy" );
                        }
                    }

                    Console.WriteLine( "{0} chose to influence the {1}.", p.Name, chosenAdvisor.Name );
                    break;
            }
            return chosenAdvisor;
        }