public WinGameCommand(INotifier notifier, IScoreboard scoreboard, IDataState data)
 {
     this.Data = data;
     this.Data.PlayTime = (DateTime.Now - this.Data.StartTime).TotalMinutes;
     this.Notifier = notifier;
     this.Scoreboard = scoreboard;
 }
Пример #2
0
        public async Task DisplayScoreboardAsync(IScoreboard scoreboard, ScoreboardPosition position)
        {
            var actualBoard = (Scoreboard)scoreboard;

            this.CurrentScoreboard = actualBoard;

            await this.client.QueuePacketAsync(new ScoreboardObjectivePacket
            {
                ObjectiveName = actualBoard.name,
                Mode          = ScoreboardMode.Create,
                Value         = actualBoard.Objective.Value,
                Type          = actualBoard.Objective.DisplayType
            });

            foreach (var(_, score) in actualBoard.scores)
            {
                await this.client.QueuePacketAsync(new UpdateScore
                {
                    EntityName    = score.DisplayText,
                    ObjectiveName = actualBoard.name,
                    Action        = 0,
                    Value         = score.Value
                });
            }

            await this.client.QueuePacketAsync(new DisplayScoreboard
            {
                ScoreName = actualBoard.name,
                Position  = position
            });
        }
 /// <summary>
 /// Initializes a new instance of the CommandContext class.
 /// </summary>
 /// <param name="game">Command context's IGame.</param>
 /// <param name="scoreboard">Command context'sIScoreboard.</param>
 /// <param name="boardHistory">Command context's IMemento.</param>
 public CommandContext(IGame game, IScoreboard scoreboard, IMemento boardHistory)
 {
     this.Game = game;
     this.ScoreboardInfo = scoreboard;
     this.BoardHistory = boardHistory;
     this.Moves = 0;
 }
Пример #4
0
 public TellrawObject(string text, string color, List <string> listFormats, IScoreboard scoreboards)
 {
     this.text        = text;
     this.color       = color;
     this.listFormats = listFormats;
     this.scoreboards = scoreboards;
 }
Пример #5
0
 /// <summary>
 /// Prevents a default instance of the <see cref="GameFifteenEngine"/> class from being created
 /// </summary>
 public GameFifteenEngine(
     IMatrixField field,
     IScoreboard scoreboardProxy,
     IRandomNumberGenerator random)
 {
     this.field      = field;
     this.scoreboard = scoreboardProxy;
     this.random     = random;
 }
 private LabyrinthEngine()
 {
     this.factory = new LabyrinthFactory();
     this.playfield = this.factory.CreatePlayfield();
     this.player = this.factory.CreatePlayer();
     this.dialogs = this.factory.CreateDialogs();
     this.scoreboard = this.factory.CreateScoreboard();
     this.save = new SaveSystem();
 }
 public ActionsController(IDataState data, INotifier notifier, INumberGenerator numberGenerator, IScoreboard scoreboard, ICommandsFactory commandsFactory, IActionsReader reader)
 {
     this.Data = data;
     this.ActionsReader = reader;
     this.Notifier = notifier;
     this.Scoreboard = scoreboard;
     this.CommandsFactory = commandsFactory;
     this.NumberGenerator = numberGenerator;
 }
 private LabyrinthEngine()
 {
     this.factory    = new LabyrinthFactory();
     this.playfield  = this.factory.CreatePlayfield();
     this.player     = this.factory.CreatePlayer();
     this.dialogs    = this.factory.CreateDialogs();
     this.scoreboard = this.factory.CreateScoreboard();
     this.save       = new SaveSystem();
 }
 /// <summary>
 /// Prevents a default instance of the <see cref="GameFifteenEngine"/> class from being created
 /// </summary>
 public GameFifteenEngine(
     IMatrixField field,
     IScoreboard scoreboardProxy,
     IRandomNumberGenerator random)
 {
     this.field = field;
     this.scoreboard = scoreboardProxy;
     this.random = random;
 }
 public Memento(ILabyrinthFactory factory, IPlayfield playfield, IPlayer player, IGameDialog dialogs, IScoreboard scoreboard, int numberOfMoves)
 {
     this.Factory = factory;
     this.Playfield = playfield;
     this.Player = player;
     this.Dialogs = dialogs;
     this.Scoreboard = scoreboard;
     this.NumberOfMoves = numberOfMoves;
 }
 public CommandsFactory(IDataState data, INotifier notifier, INumberGenerator numberGenerator, IScoreboard scoreboard)
 {
     this.Data = data;
     this.Notifier = notifier;
     this.Scoreboard = scoreboard;
     this.NumberGenerator = numberGenerator;
     this.CommandsList = new Dictionary<string, ICommand>();
     this.FourDigitNumberPattern = new Regex(FourDigitsPatternForRegex);
 }
 public TestObjectsFactory()
 {
     this.factory    = new LabyrinthFactory();
     this.playfield  = this.factory.CreatePlayfield();
     this.player     = this.factory.CreatePlayer();
     this.dialogs    = this.factory.CreateDialogs();
     this.scoreboard = this.factory.CreateScoreboard();
     this.save       = new SaveSystem();
 }
Пример #13
0
        /// <summary>
        /// The methods put the creation of the initial game objects in the correct order.
        /// </summary>
        /// <param name="objectBuilder">Gets a concrete builder, which will provide the needed objects.</param>
        /// <returns>Instance of the game engine.</returns>
        public GameEngine SetupGame(IGameObjectBuilder objectBuilder)
        {
            this.renderer = objectBuilder.CreteRenderer();
            this.player = objectBuilder.CreatePlayer();
            this.scoreboard = objectBuilder.CreateScoreboard();
            this.scoreBoardHandler = objectBuilder.CreteScoreBoardHanler(this.scoreboard);
            this.matrix = objectBuilder.CreateLabyrinthMatrix();

            return GameEngine.Instance(this.player, this.renderer, this.scoreBoardHandler, this.matrix);
        }
 public void LoadMemento(Memento restore)
 {
     Console.WriteLine("\nRestoring state --\n");
     this.factory       = restore.Factory;
     this.playfield     = restore.Playfield;
     this.player        = restore.Player;
     this.dialogs       = restore.Dialogs;
     this.scoreboard    = restore.Scoreboard;
     this.numberOfMoves = restore.NumberOfMoves;
 }
 /// <summary>
 /// The constructor setting a dictionary of commands and corresponding actions
 /// </summary>
 /// <param name="board">The current playing board</param>
 /// <param name="scoreboard">The current scoreboard</param>
 public CommandOperator(IBoard board, IScoreboard scoreboard)
 {
     this.commandExecutor = new Dictionary<string, Action<string>>()
     {
         ["exit"] = new EndGameCommand(board).Execute,
         ["top"] = new ShowScoreboardCommand(board, scoreboard).Execute,
         ["restart"] = new RestartCommand(board).Execute,
         ["play"] = new PlayCommand(board).Execute,
     };
 }
Пример #16
0
 public Executor(
     IContestContextFactory factory,
     IServiceProvider serviceProvider,
     IJobFileProvider files)
 {
     _factory         = factory;
     _serviceProvider = serviceProvider;
     _files           = files;
     _scoreboard      = serviceProvider.GetRequiredService <IScoreboard>();
 }
 public StandardOnePlayerMinesweeperEngine(IBoard board, IWpfInputProvider inputProvider, IRenderer renderer, ICommandOperator commandOperator, IScoreboard scoreboard, Player player)
 {
     this.board = board;
     this.inputProvider = inputProvider;
     this.renderer = renderer;
     this.commandOperator = commandOperator;
     this.scoreboard = scoreboard;
     this.currentPlayer = player;
     this.currentGameStateChange = new Notification(string.Empty, this.board.BoardState);
 }
 public void LoadMemento(Memento restore)
 {
     Console.WriteLine("\nRestoring state --\n");
     this.factory = restore.Factory;
     this.playfield = restore.Playfield;
     this.player = restore.Player;
     this.dialogs = restore.Dialogs;
     this.scoreboard = restore.Scoreboard;
     this.numberOfMoves = restore.NumberOfMoves;
 }
 public void TestMemento()
 {
     ILabyrinthFactory factory    = new LabyrinthFactory();
     IPlayfield        playfield  = factory.CreatePlayfield();
     IPlayer           player     = factory.CreatePlayer();
     IGameDialog       dialogs    = factory.CreateDialogs();
     IScoreboard       scoreboard = factory.CreateScoreboard();
     int     numberOfMoves        = 5;
     Memento testMemento          = new Memento(factory, playfield, player, dialogs, scoreboard, numberOfMoves);
 }
Пример #20
0
        /// <summary>
        /// The methods put the creation of the initial game objects in the correct order.
        /// </summary>
        /// <param name="objectBuilder">Gets a concrete builder, which will provide the needed objects.</param>
        /// <returns>Instance of the game engine.</returns>
        public GameEngine SetupGame(IGameObjectBuilder objectBuilder)
        {
            this.renderer          = objectBuilder.CreteRenderer();
            this.player            = objectBuilder.CreatePlayer();
            this.scoreboard        = objectBuilder.CreateScoreboard();
            this.scoreBoardHandler = objectBuilder.CreteScoreBoardHanler(this.scoreboard);
            this.matrix            = objectBuilder.CreateLabyrinthMatrix();

            return(GameEngine.Instance(this.player, this.renderer, this.scoreBoardHandler, this.matrix));
        }
 /// <summary>
 /// Initializes the application
 /// </summary>
 public void Initialize()
 {
     this.Data = new Data();
     this.ActionsReader = new ConsoleReader();
     this.Notifier = new ConsoleNotifier();
     this.NumberGenerator = new RandomNumberGenerator();
     this.Scoreboard = new Scoreboard(this.Notifier, ScoreSerializer.GetSerializer(), new PlayerNameReader());
     this.CommandsFactory = new CommandsFactory(this.Data, this.Notifier, this.NumberGenerator, this.Scoreboard);
     this.Controller = new ActionsController(this.Data, this.Notifier, this.NumberGenerator, this.Scoreboard, this.CommandsFactory, this.ActionsReader);
     this.ReadyToRun = true;
 }
        public void TestLoadMememntoMethod()
        {
            ILabyrinthFactory factory    = new LabyrinthFactory();
            IPlayfield        playfield  = factory.CreatePlayfield();
            IPlayer           player     = factory.CreatePlayer();
            IGameDialog       dialogs    = factory.CreateDialogs();
            IScoreboard       scoreboard = factory.CreateScoreboard();
            int     numberOfMoves        = 5;
            Memento testMemento          = new Memento(factory, playfield, player, dialogs, scoreboard, numberOfMoves);

            Labyrinth.Engine.LabyrinthEngine.Instance.LoadMemento(testMemento);
        }
        public void PrintWinMessage(uint mistakesCount, bool isHelpUsed, IScoreboard scoreboard, char[] wordToGuess)
        {
            this.PrintWordToGuess(wordToGuess);

            if (isHelpUsed)
            {
                Console.WriteLine(GlobalMessages.WinWithHelp, mistakesCount);
            }
            else
            {
                Console.WriteLine(GlobalMessages.Win, mistakesCount);
            }
        }
        public void PrintWinMessage(uint mistakesCount, bool isHelpUsed, IScoreboard scoreboard, char[] wordToGuess)
        {
            this.PrintWordToGuess(wordToGuess);

            if (isHelpUsed)
            {
                Console.WriteLine(GlobalMessages.WinWithHelp, mistakesCount);
            }
            else
            {
                Console.WriteLine(GlobalMessages.Win, mistakesCount);
            }
        }
        public void IntanceReturnsGameEngineObject()
        {
            this.localScoreBoard = new LocalScoreBoard();
            this.scoreBoard      = new ScoreBoardHandler(localScoreBoard);
            this.renderer        = new ConsoleRenderer();
            this.player          = new Player("Goshou");
            this.matrix          = new LabyrinthMatrix();

            this.game    = GameEngine.Instance(this.player, this.renderer, this.scoreBoard, this.matrix);
            this.context = this.game.GetCurrentContext();

            Assert.IsTrue(game is GameEngine);
            Assert.AreEqual(8, this.player.PositionRow);
        }
Пример #26
0
        /*   private Scoreboard scoreboard_press = new Scoreboard(ScoreboardTypes.NONE);
        *  private Scoreboard scoreboard_guidance = new Scoreboard(ScoreboardTypes.NONE);*/

        public TellrawForm()
        {
            InitializeComponent();
            objects                         = new List <TellrawObject>();
            scoreboards                     = new IScoreboard();
            scoreboard_press                = new Scoreboard(ScoreboardTypes.NONE);
            scoreboard_guidance             = new Scoreboard(ScoreboardTypes.NONE);
            scoreboards.Scoreboard_Press    = new Scoreboard(ScoreboardTypes.NONE);
            scoreboards.Scoreboard_Guidance = new Scoreboard(ScoreboardTypes.NONE);
            tellrawElementsForm             = new List <List <Control> >();
            this.controls                   = new List <Control>();
            controls.Add(this.constructorGroupBox);
            controls.Add(this.elementsTellraw);
        }
 public void Update(IPlayer player, IPlayfield playfield, int numberOfMoves, IScoreboard scoreboard, IGameDialog dialogs)
 {
     if (playfield.IsPlayerWinning(player))
     {
         Console.Write(dialogs.WinnerMessage(numberOfMoves));
         string name = Console.ReadLine();
         try
         {
             scoreboard.AddTopScoreToScoreboard(name, numberOfMoves);
         }
         finally
         {
         }
         Console.WriteLine();
         LabyrinthEngine.Instance.StartNewGame();
     }
 }
Пример #28
0
 public DefaultScoreKeeper(ITeamScore homeScore, ITeamScore awayScore, IScoreboard scoreboard)
 {
     _homeTeamScore = homeScore;
     _awayTeamScore = awayScore;
     _scoreboard    = scoreboard;
 }
Пример #29
0
 public IScoreBoardObserver CreteScoreBoardHanler(IScoreboard scoreboard)
 {
     return this.GameObjectBuilder.CreteScoreBoardHanler(scoreboard);
 }
        public void IntanceReturnsGameEngineObject()
        {
            this.localScoreBoard = new LocalScoreBoard();
            this.scoreBoard = new ScoreBoardHandler(localScoreBoard);
            this.renderer = new ConsoleRenderer();
            this.player = new Player("Goshou");
            this.matrix = new LabyrinthMatrix();

            this.game = GameEngine.Instance(this.player, this.renderer, this.scoreBoard, this.matrix);
            this.context = this.game.GetCurrentContext();

            Assert.IsTrue(game is GameEngine);
            Assert.AreEqual(8, this.player.PositionRow);
        }
        public void Update(IPlayer player, IPlayfield playfield, int numberOfMoves, IScoreboard scoreboard, IGameDialog dialogs)
        {
            if (playfield.IsPlayerWinning(player))
            {
                Console.Write(dialogs.WinnerMessage(numberOfMoves));
                string name = Console.ReadLine();
                try
                {
                    scoreboard.AddTopScoreToScoreboard(name, numberOfMoves);
                }
                finally
                {

                }
                Console.WriteLine();
                LabyrinthEngine.Instance.StartNewGame();
            }
        }
Пример #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GameContext"/> class.
 /// </summary>
 /// <param name="wordProvider">The object that will provide the word.</param>
 /// <param name="scoreboard">The scoreboard where the result will be kept.</param>
 public GameContext(IWordProvider wordProvider, IScoreboard scoreboard)
 {
     this.randWordProvider = wordProvider;
     this.Word = this.randWordProvider.GetWord();
     this.Scoreboard = scoreboard;
     this.CurrentMessage = GameContext.StartMessage;
     this.CurrentMistakes = 0;
     this.HasCheated = false;
     this.IsGameRunning = true;
 }
Пример #33
0
 public EngineViewModel(IStartScreen startScreen, IGameplay gameplay, IScoreboard scoreboard)
 {
     this.StartScreen = startScreen;
     this.Gameplay    = gameplay;
     this.Scoreboard  = scoreboard;
 }
Пример #34
0
        public ScoreboardManager(Server server)
        {
            this.server = server;

            this.DefaultScoreboard = this.CreateScoreboard("default");
        }
 /// <summary>
 /// Creates an object which will handle the relation with the database.
 /// </summary>
 /// <param name="scoreboard">A Scoreboard object to store the result.</param>
 public ScoreBoardHandler(IScoreboard scoreboard)
 {
     this.scoreboard = scoreboard;
 }
Пример #36
0
 /// <summary>
 /// Registers a new scoreboard.
 /// </summary>
 /// <param name="orderName">Name of the scoreboard.</param>
 /// <param name="scoreboard">The scoreboard itself.</param>
 public void AddScoreboard(string orderName, IScoreboard scoreboard)
 => _scoreboards.Add(orderName, scoreboard);
Пример #37
0
 public IntTeamScore(int score, IScoreboard scoreboard)
 {
     _score      = score;
     _scoreboard = scoreboard;
 }
 /// <summary>
 /// Creates a ShowScoreboard command instance
 /// </summary>
 /// <param name="board">The current playing board</param>
 /// <param name="scoreboard">The current scoreboard</param>
 public ShowScoreboardCommand(IBoard board, IScoreboard scoreboard)
 {
     this.board = board;
     this.scoreboard = scoreboard;
 }
 public IScoreBoardObserver CreteScoreBoardHanler(IScoreboard scoreboard)
 {
     return new ScoreBoardHandler(scoreboard);
 }
 public Memento(ILabyrinthFactory factory, IPlayfield playfield, IPlayer player, IGameDialog dialogs, IScoreboard scoreboard, int numberOfMoves)
 {
     this.Factory       = factory;
     this.Playfield     = playfield;
     this.Player        = player;
     this.Dialogs       = dialogs;
     this.Scoreboard    = scoreboard;
     this.NumberOfMoves = numberOfMoves;
 }
Пример #41
0
 public IScoreBoardObserver CreteScoreBoardHanler(IScoreboard scoreboard)
 {
     return(this.GameObjectBuilder.CreteScoreBoardHanler(scoreboard));
 }
Пример #42
0
        private void addTellraw_Click(object sender, EventArgs e)
        {
            List <string> word_orign = new List <string>();
            List <string> word       = new List <string>();

            word.Add("");
            word.Add("red");
            word.Add("yellow");
            word.Add("green");
            word.Add("blue");
            word.Add("white");
            word.Add("black");
            word.Add("aqua");
            word.Add("gold");
            word.Add("purple");
            word.Add("dark_red");
            word.Add("dark_yellow");
            word.Add("dark_green");
            word.Add("dark_blue");
            word.Add("dark_purple");
            word.Add("dark_aqua");
            word.Add("gray");

            int index = colorsTellraw.Items.IndexOf(colorsTellraw.Text);

            if (index == -1)
            {
                index = 0;
            }

            List <string> listFormatis = new List <string>();

            foreach (int indexChecked in listFormats.CheckedIndices)
            {
                switch (indexChecked)
                {
                case 0: listFormatis.Add("bold"); break;

                case 1: listFormatis.Add("italic"); break;

                case 2: listFormatis.Add("underlined"); break;

                case 3: listFormatis.Add("strikethrough"); break;

                case 4: listFormatis.Add("obfuscated"); break;
                }
            }

            IScoreboard iSc = new IScoreboard();

            iSc.Scoreboard_Press    = scoreboard_press;
            iSc.Scoreboard_Guidance = scoreboard_guidance;

            TellrawObject tellrawObject = new TellrawObject(this.textTellraw.Text, word[index], listFormatis, iSc);

            objects.Add(tellrawObject);
            this.textTellraw.Text   = "";
            this.colorsTellraw.Text = "Цвет";

            scoreboard_press    = new Scoreboard(ScoreboardTypes.NONE);
            scoreboard_guidance = new Scoreboard(ScoreboardTypes.NONE);


            UpdateElementsPanel();
        }
 public IScoreBoardObserver CreteScoreBoardHanler(IScoreboard scoreboard)
 {
     return(new ScoreBoardHandler(scoreboard));
 }
 public DisplayScoreboardCommand(IScoreboard scoreboard)
 {
     this.Scoreboard = scoreboard;
 }
 public TestObjectsFactory()
 {
     this.factory = new LabyrinthFactory();
     this.playfield = this.factory.CreatePlayfield();
     this.player = this.factory.CreatePlayer();
     this.dialogs = this.factory.CreateDialogs();
     this.scoreboard = this.factory.CreateScoreboard();
     this.save = new SaveSystem();
 }
 /// <summary>
 /// Creates an object which will handle the relation with the database.
 /// </summary>
 /// <param name="scoreboard">A Scoreboard object to store the result.</param>
 public ScoreBoardHandler(IScoreboard scoreboard)
 {
     this.scoreboard = scoreboard;
 }