Exemple #1
0
 public ControlRoomFactory(
     GameState gameState,
     CommandsGroup baseCommandsGroup)
 {
     _gameState         = gameState;
     _baseCommandsGroup = baseCommandsGroup;
 }
 public BuyCommandTests()
 {
     proc      = new MockMainProcess();
     gameState = new GameState();
     Game.SetMainProcess(proc);
     gameState.Miner = Miner.Default();
     gameState.Store = gameState.Store ?? new MinerStoreFactory(gameState, CommandsGroup.Empty(), proc.Gateway).Build();
 }
 public DiggerControlRoom(
     GameState gameState,
     string[] greeting,
     CommandsGroup commandsGroup)
     : base(gameState, greeting, GameMode.ControlRoom)
 {
     this.Name     = "control-room";
     CommandsGroup = commandsGroup;
 }
Exemple #4
0
 public MinerStore(
     GameState gameState,
     string[] greeting,
     CommandsGroup commandsGroup)
     : base(gameState, greeting, GameMode.Store)
 {
     CommandsGroup = commandsGroup;
     this.Name     = "store";
 }
 public LobbyRoom(
     GameState gameState,
     string[] greeting,
     GameMode activeMode,
     CommandsGroup commandGroup)
     : base(gameState, greeting, activeMode)
 {
     this.CommandsGroup = commandGroup;
 }
Exemple #6
0
 public ClaimsOfficeRoom(
     GameState gameState,
     string[] greeting,
     CommandsGroup commandsGroup,
     ClaimListings listings)
     : base(gameState, greeting, GameMode.Store)
 {
     CommandsGroup = commandsGroup;
     Listings      = listings;
     this.Name     = "Claims Office";
 }
Exemple #7
0
 public void Do(ICommand command)
 {
     command.Do();
     redo.Clear();
     if (isGrouping)
     {
         CommandsGroup group = undo.Peek() as CommandsGroup;
         group.undo.Push(command);
     }
     else
     {
         undo.Push(command);
     }
 }
Exemple #8
0
        public GameConsole()
        {
            gameState = new GameState
            {
                Running = true
            };

            var rewardsRepo        = new RewardRepository(@".\Resources\Dat\rewards.csv");
            var achievementsRepo   = new AchievementRepository(@".\Resources\Dat\achievements.csv", gameState);
            var gameItemsRepo      = new GameItemRepository(@".\Resources\Dat\gameItems.csv");
            var storeInventoryRepo = new StoryInventoryRepository(@".\Resources\Dat\storeInventory.csv");

            gateway = new DataGateway(rewardsRepo, gameItemsRepo, achievementsRepo, storeInventoryRepo);

            commandsGroup           = new TopCommandGroupFactory().Build();
            gameState.Lobby         = new LobbyRoom(gameState, new[] { "Welcome to the Lobby" }, GameMode.Lobby, commandsGroup);
            gameState.Store         = gameState.Store ?? new MinerStoreFactory(gameState, commandsGroup, gateway).Build();
            gameState.ControlRoom   = new ControlRoomFactory(gameState, commandsGroup).Build();
            gameState.ClaimsOffice  = new ClaimsOfficeRoomFactory(gameState, commandsGroup, gateway).Build();
            gameState.SaveDirectory = @"c:\chipMiner\saves";
            gameState.GameTime.Start();

            IsVisible = true;
            IsFocused = true;

            StartGame();
            hud = new HudConsole(gameState)
            {
                Position = new Point(0, 0)
            };
            input = new InputConsole(this, gameState)
            {
                Position = new Point(1, 34)
            };
            output = new OutputConsole(this, 83)
            {
                Position = new Point(1, 1)
            };
            events = new GameEventsConsole(this, 83)
            {
                Position = new Point(85, 1)
            };
            Children.Add(hud);
            Children.Add(input);
            Children.Add(output);
            Children.Add(events);
            Global.FocusedConsoles.Set(input);
        }
Exemple #9
0
 public Result <string> Command(string adapterName)
 {
     if (AdaptersGroup.GetGroup(adapterName).If(out var adapterGroup))
     {
         var commandName = adapterGroup.GetValue("command").DefaultTo(() => adapterName);
         if (CommandsGroup.GetGroup(commandName).If(out var commandGroup))
         {
             var command = new Command(commandGroup);
             return(command.Text.Success());
         }
         else
         {
             return($"Didn't find command group '{commandName}'".Failure <string>());
         }
     }
     else
     {
         return($"Didn't find adapter group '{adapterName}'".Failure <string>());
     }
 }
 public MinerStoreFactory(GameState gameState, CommandsGroup baseCommandsGroup, DataGateway gateway)
 {
     _gateway           = gateway;
     _gameState         = gameState;
     _baseCommandsGroup = baseCommandsGroup;
 }
Exemple #11
0
 public ClaimsOfficeRoomFactory(GameState gameState, CommandsGroup baseCommandsGroup, DataGateway gateway)
 {
     _gateway           = gateway;
     _gameState         = gameState;
     _baseCommandsGroup = baseCommandsGroup;
 }
Exemple #12
0
        public CommandsGroup Build()
        {
            var commandsGroup = new CommandsGroup();

            commandsGroup.LocalCommands = new List <CommandsDefinition>
            {
                new CommandsDefinition
                {
                    CommandText = "help",
                    Description = "Display all of the commands available.",
                    Command     = (userCommand, GameState) => new HelpCommand {
                        GameState = GameState
                    }
                },
                new CommandsDefinition
                {
                    CommandText = "store",
                    Description = "Opens the store mode and makes the store commands accessible.",
                    Execute     = (command, gameState) => { gameState.Store.EnterRoom(); }
                },
                new CommandsDefinition
                {
                    CommandText = "miner",
                    Description = "Displays the miner's current chip vault, tater tokens, and diggers",
                    Execute     = (userCommand, gameState) =>
                    {
                        var miner = gameState.Miner;
                        Game.WriteLine($"Name: {miner.Name}", PcmColor.Yellow);
                        Game.WriteLine($"Chip Vault:{miner.Inventory("rawchip").Count}", PcmColor.Yellow);
                        Game.WriteLine($"Tater Tokens:{miner.TaterTokens}", PcmColor.Yellow);
                        Game.WriteLine($"Diggers Count:{miner.Diggers.Count}", PcmColor.Yellow);
                        Game.WriteLine($"Lifetime Chips Dug:{miner.GetLifeTimeStat(Stats.LifetimeChips)}");
                    }
                },
                new CommandsDefinition
                {
                    CommandText = "vault",
                    Description = "Shows the number of chips currently in your vault.",
                    Execute     = (userCommand, gameState) =>
                    {
                        Game.WriteLine($"Chip Vault: {gameState.Miner.Inventory("rawchip").Count}");
                    }
                },
                new CommandsDefinition
                {
                    CommandText = "tokens",
                    Description = "Shows then number of tokens you currently have.",
                    Execute     = TokensHandler()
                },
                new CommandsDefinition
                {
                    CommandText = "exit",
                    Description = "Leaves the current room and returns you to the lobby.",
                    Execute     = (userCommand, gameState) =>
                    {
                        if (gameState.Mode == GameMode.Lobby)
                        {
                            return;
                        }
                        Game.WriteLine($"Leaving {gameState.Mode}...");
                        gameState.Lobby.EnterRoom();
                    }
                },
                new CommandsDefinition
                {
                    CommandText = "quit",
                    Description = "Ends the game.",
                    Execute     = (userCommand, gameState) => { gameState.Running = false; }
                },
                new CommandsDefinition
                {
                    CommandText = "end",
                    Description = "Ends the game.",
                    Execute     = (userCommand, gameState) => { gameState.Running = false; }
                },
                new CommandsDefinition
                {
                    CommandText = "inventory",
                    Description = "Shows the miners items inventory",
                    Execute     = (userCommand, gameState) =>
                    {
                        var table = new TableOutput(80);
                        table.AddHeaders("Name", "Quantity");
                        foreach (var minerInventoryItem in gameState.Miner.InventoryItems)
                        {
                            table.AddRow(minerInventoryItem.Name, minerInventoryItem.Count.ToString());
                        }

                        Game.Write(table);
                    }
                },
                new CommandsDefinition
                {
                    CommandText = "control-room",
                    Description = "Enter the control room. Control room commands become available",
                    Execute     = (userCommand, gameState) => { gameState.ControlRoom.EnterRoom(); }
                },
                new CommandsDefinition
                {
                    CommandText = "diggers",
                    Description = "Displays a list of all of the miner's equipped diggers.",
                    Execute     = (userCommand, gameState) =>
                    {
                        var table = new TableOutput(80, PcmColor.Yellow);
                        table.AddHeaders("Name", "Durability", "Density", "Hardness", "Hopper Space");
                        foreach (var digger in gameState.Miner.Diggers)
                        {
                            table.AddRow(digger.Name,
                                         digger.Durability.Current.ToString(),
                                         digger.MineClaim.ChipDensity.ToString(),
                                         digger.MineClaim.Hardness.ToString(),
                                         $"{digger.Hopper.Max - digger.Hopper.Count}/{digger.Hopper.Max}");
                        }

                        Game.Write(table);
                    }
                },
                new CommandsDefinition
                {
                    CommandText = "claims",
                    Description = "Shows the miners claims",
                    Execute     = (userCommand, gameState) =>
                    {
                        var table = new TableOutput(80);
                        table.AddHeaders("Id", "Price", "Density", "Hardness", "InUse");
                        foreach (var claimLease in gameState.Miner.ClaimLeases.GetAll())
                        {
                            table.AddRow(
                                claimLease.Id.ToString(),
                                claimLease.Price.ToString(),
                                claimLease.Claim.ChipDensity.ToString(),
                                claimLease.Claim.Hardness.ToString(),
                                claimLease.InUse ? "X" : "");
                        }

                        Game.Write(table);
                    }
                },
                new CommandsDefinition
                {
                    CommandText = "save",
                    Description = "Saves the current game.",
                    Execute     = SaveHandler()
                },
                new CommandsDefinition
                {
                    CommandText      = "load",
                    EntryDescription = "load || load [save name]",
                    Description      = "Loads shows games available to load, or loads the indicated saved game.",
                    Execute          = LoadHandler()
                },
                new CommandsDefinition
                {
                    CommandText = "claims-office",
                    Description = "Enter the claims office. Claims will be available for purchase.",
                    Execute     = (userCommand, gameState) => { gameState.ClaimsOffice.EnterRoom(); }
                }
            };
            return(commandsGroup);
        }