コード例 #1
0
 /// <summary>
 /// Adds player to highscore list
 /// </summary>
 /// <param name="highscoreList"><The highscore list to update/param>
 private void AddPlayerToHighscoreList(IHighscore highscoreList)
 {
     string playerName = this.provider.Renderer.RenderInputMessage();
     this.player.Name = playerName;
     this.player.Moves = this.numberOfMoves.Counter;
     highscoreList.AddPlayer(this.player);
 }
コード例 #2
0
 private EngineFacade()
 {
     this.highscore = new Highscore();
     this.renderer = new ConsoleUIRenderer();
     this.provider = new BasicIOProvider<ConsoleUIRenderer>(this.renderer, this.highscore);
     this.gameEngine = new GameEngine(this.provider);
 }
コード例 #3
0
        /// <summary>
        /// Creates an instance of the <see cref="Highscore"/> class, otherwise - returns the existing instance.
        /// </summary>
        /// <returns>The <see cref="Highscore"/> instance</returns>
        public static IHighscore GetInstance()
        {
            if (instance == null)
            {
                instance = new Highscore();
            }

            return instance;
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the CommandContext class.
        /// </summary>
        /// <param name="logger">The logger to save messages.</param>
        /// <param name="board">The board object to be used in the game.</param>
        /// <param name="row">The row that needs to be popped.</param>
        /// <param name="col">The column that needs to be popped.</param>
        /// <param name="memory">The memory caretaker where a memento is saved.</param>
        /// <param name="score">The score container.</param>
        /// <param name="highscoreProcessor">The high score processor.</param>
        public CommandContext(ILogger logger, IBoard board, int row, int col, IBoardMemory memory, IHighscore score, IHighscoreProcessor highscoreProcessor)
        {
            this.Logger = logger;
            this.Board = board;
            this.ActiveRow = row;
            this.ActiveCol = col;
            this.Memory = memory;
            this.Score = score;
            this.HighscoreProcessor = highscoreProcessor;
            this.IsOver = false;

            this.CurrentMessage = this.Messages["welcome"];
        }
コード例 #5
0
        /// <summary>
        /// An override of base method - prints the given input high-score
        /// </summary>
        /// <param name="highscore">The high-score to be printed</param>
        public override void PrintHighscore(IHighscore highscore)
        {
            highscore.LoadData();

            StringBuilder sb = new StringBuilder();
            sb.AppendLine(GameOutputMessages.HighscoreMainMessage);
            foreach (IPlayer player in highscore.Players)
            {
                string highscoreLine = string.Format(
                    GameOutputMessages.HighscoreUserInformationMessage,
                    highscore.Players.IndexOf(player) + 1,
                    player.Name,
                    player.Moves);

                sb.AppendLine(highscoreLine);
            }

            this.RenderOutputMessage(sb.ToString());
        }
コード例 #6
0
        /// <summary>
        /// Saves high score to an existing file, otherwise one is created and high score is written.
        /// </summary>
        /// <param name="highscore">the score object</param>
        public void SaveHighscore(IHighscore highscore)
        {
            const string RootElementString = "highscores";

            XDocument score;

            if (File.Exists(Path))
            {
                score = XDocument.Load(Path);
            }
            else
            {
                score = new XDocument(new XElement(RootElementString));
            }

            var root = score.Root;

            root.Add(new XElement("score", new XElement("username", highscore.Username), new XElement("points", highscore.CurrentScore)));

            score.Save(Path);
        }
コード例 #7
0
ファイル: GameData.cs プロジェクト: bankoff/TeamWorks
 public GameData(IRenderer renderer, IHighscore highscore)
 {
     this.Renderer  = renderer;
     this.Highscore = highscore;
 }
コード例 #8
0
 /// <summary>
 /// An abstract method to print the high-score
 /// </summary>
 /// <param name="highscore">The high-score to be printed</param>
 public abstract void PrintHighscore(IHighscore highscore);
コード例 #9
0
 public HighscoreCommand(IBasicUIRenderer renderer, IHighscore highscore)
     : base(renderer)
 {
     this.Highscore = highscore;
 }