コード例 #1
0
ファイル: Game.cs プロジェクト: sfvicente/Dictator
        /// <summary>
        ///     Initiates the revolution and attempts to overthrown the government.
        /// </summary>
        /// <returns><c>true</c> if the revolution succeeded and the government has been overthrown; otherwise, <c>false</c>.</returns>
        private bool TryProcessGovernmentOverthrown()
        {
            userInterface.DisplayRevolutionScreen();

            bool hasGovernmentBeenOverthrown = true;

            if (DoesPlayerAttemptEscape())
            {
                AttemptEscape();
            }
            else
            {
                Dictionary <int, Group> possibleAllies = engine.FindPossibleAlliesForPlayer();

                if (possibleAllies.Count > 0)
                {
                    Revolutionary revolutionary       = engine.GetRevolutionary();
                    int           selectedAllyGroupId = userInterface.DisplayRevolutionAskForHelpDialog(revolutionary, possibleAllies);

                    if (engine.DoesGroupAcceptAllianceInRevolution(selectedAllyGroupId))
                    {
                        engine.SetPlayerAllyForRevolution(selectedAllyGroupId);
                    }
                    else
                    {
                        userInterface.DisplayRevolutionAllyLowPopularityScreen();
                    }
                }
                else
                {
                    userInterface.DisplayRevolutionNoAlliesScreen();
                }

                userInterface.DisplayRevolutionStartedScreen();

                bool doesRevolutionSucceed = engine.DoesRevolutionSucceed();

                if (doesRevolutionSucceed)
                {
                    userInterface.DisplayRevolutionOverthrownScreen();
                    engine.KillPlayer();
                }
                else
                {
                    DialogResult dialogResult = userInterface.DisplayRevolutionCrushedDialog();

                    if (dialogResult == DialogResult.Yes)
                    {
                        engine.PunishRevolutionaries();
                    }

                    engine.ApplyRevolutionCrushedEffects();
                    hasGovernmentBeenOverthrown = false;
                }
            }

            return(hasGovernmentBeenOverthrown);
        }
コード例 #2
0
        /// <summary>
        ///     Gets the revolutionary group and ally that initiated the revolution.
        /// </summary>
        /// <returns>The revolutionary group, their ally and combined strength.</returns>
        public Revolutionary GetRevolutionary()
        {
            Revolutionary revolutionary      = new Revolutionary();
            Group         revolutionaryGroup = revolution.RevolutionaryGroup;

            if (revolutionaryGroup != null)
            {
                revolutionary.RevolutionaryGroupName = revolutionaryGroup.Name;

                if (revolutionaryGroup.Ally != null)
                {
                    revolutionary.RevolutionaryGroupAllyName = revolutionaryGroup.Ally.Name;
                    revolutionary.CombinedStrength           = revolutionaryGroup.Strength + revolutionaryGroup.Ally.Strength;
                }
            }

            return(revolutionary);
        }
コード例 #3
0
        public int Show(Revolutionary revolutionary, Dictionary <int, Group> possibleAllies)
        {
            ConsoleEx.Clear(ConsoleColor.Gray, ConsoleColor.Black);
            ConsoleEx.WriteCenteredAt(5, $"{revolutionary.RevolutionaryGroupName} have joined with");
            ConsoleEx.WriteCenteredAt(6, $"{revolutionary.RevolutionaryGroupAllyName}");
            ConsoleEx.WriteAt(1, 7, $"  Their combined STRENGTH is {revolutionary.CombinedStrength} ");
            ConsoleEx.WriteAt(1, 9, "  WHO are you ASKING for HELP ? ");

            for (int i = 1; i < 7; i++)
            {
                if (possibleAllies.ContainsKey(i))
                {
                    ConsoleEx.WriteAt(6, 14 + i, $"{i} {possibleAllies[i].Name}");
                }
                else
                {
                    ConsoleEx.WriteEmptyLineAt(14 + i);
                }
            }

            return(GetOptionSelected(possibleAllies));
        }
コード例 #4
0
 public int DisplayRevolutionAskForHelpDialog(Revolutionary revolutionary, Dictionary <int, Group> possibleAllies) => revolutionAskForHelpDialog.Show(revolutionary, possibleAllies);