コード例 #1
0
        static (bool passed, string message) TestHopperUpgrade(ChipDigger digger, ChipsHopperUpgradeItem item)
        {
            var slot = digger.AvailableUpgrades.FirstOrDefault(x => x.Slot == DiggerUpgradeSlot.Hopper);

            if (slot == null)
            {
                return(false, "This digger doesn't have that upgrade slot available.");
            }

            if (item.RequiredSlotLevel > digger.Hopper.Level)
            {
                return(false,
                       $"You can not perform this upgrade.  You must first level this slot to {item.RequiredSlotLevel}");
            }

            if (item.Level > slot.MaxLevel)
            {
                return(false,
                       $"You can not perform this upgrade.  The maximum slot level for this digger is {slot.MaxLevel}");
            }

            if (item.Size < digger.Hopper.Max)
            {
                return(false,
                       $"You can not apply this upgrade. This digger can not use it.");
            }

            return(true, "Upgrade is available");
        }
コード例 #2
0
        public static (bool completed, string message) ApplyUpgrade(ChipDigger digger, DiggerUpgradeItem item)
        {
            if (item is ChipsHopperUpgradeItem)
            {
                var testResult = TestHopperUpgrade(digger, item as ChipsHopperUpgradeItem);
                if (!testResult.passed)
                {
                    return(testResult);
                }

                digger.UpgradeHopper(((ChipsHopperUpgradeItem)item).GetUpgrade());
                return(true, "Hopper upgraded to Large_Hopper");
            }

            if (item is BitUpgradeItem)
            {
                var testResult = TestBitUpgrade(digger, item as BitUpgradeItem);
                if (!testResult.passed)
                {
                    return(testResult);
                }

                digger.UpgradeBit(((BitUpgradeItem)item).GetUpgrade());
            }

            return(true, "Upgrade Applied");
        }
コード例 #3
0
        public void ChipDigger_Dig_HavingDurabilityEqualsZero_ReturnsEmptyScoop()
        {
            diggerState.Durability.Current = 0;
            var chipDigger = ChipDigger.FromState(diggerState);
            var scoop      = chipDigger.Dig(TimeSpan.FromSeconds(20));

            scoop.Failed.ShouldBeTrue();
        }
コード例 #4
0
        public void ChipDigger_HavingSiteHardnessIsSoft_DurabilityDecreasesBetween0and1()
        {
            var mineClaim  = new MineClaim(ChipDensity.Scarce, SiteHardness.Soft);
            var chipDigger = ChipDigger.StandardDigger(mineClaim);
            var scoop      = chipDigger.Dig(TimeSpan.FromSeconds(20));

            chipDigger.Durability.Current.ShouldBeGreaterThanOrEqualTo(0);
            chipDigger.Durability.Current.ShouldBeLessThanOrEqualTo(25);
        }
コード例 #5
0
        private static void ReportDiggerIdentityInfo(ChipDigger digger)
        {
            Game.ClearConsole();
            var headTable = new TableOutput(80, PcmColor.Yellow);

            headTable.AddHeaders("Name", "Class", "Equipped Date");
            headTable.AddRow($"{digger.Name}", $"{digger.Class.ToString()}",
                             $"{digger.FirstEquipped}");
            Game.Write(headTable);
        }
コード例 #6
0
        private static void ReportDiggerCoreStats(ChipDigger digger)
        {
            var vitalsTable = new TableOutput(80, PcmColor.Yellow);

            vitalsTable.AddHeaders("Stat", "Value");
            vitalsTable.AddRow("Site Hardness", digger.MineClaim.Hardness.ToString());
            vitalsTable.AddRow("Site Chip Density", digger.MineClaim.ChipDensity.ToString());
            vitalsTable.AddRow("Durablity (Left) / (Max)", $"{digger.Durability.Current} / {digger.Durability.Max}");
            vitalsTable.AddRow("Hopper", digger.Hopper.Name);
            vitalsTable.AddRow("Hopper Space (Left) / (Max)",
                               $"{digger.Hopper.Max - digger.Hopper.Count} / {digger.Hopper.Max}");
            Game.Write(vitalsTable);
        }
コード例 #7
0
        public void ChipDigger_HavingSiteChipDensityIsNormal_ChipsYieldIsBetween3and9()
        {
            var mineClaim = new MineClaimState {
                ChipDensity = ChipDensity.Normal
            };

            diggerState.MineClaim          = mineClaim;
            diggerState.Durability.Current = 1;
            var chipDigger = ChipDigger.FromState(diggerState);
            var scoop      = chipDigger.Dig(TimeSpan.FromSeconds(20));

            scoop.ChipsDug.ShouldBeGreaterThanOrEqualTo(3);
            scoop.ChipsDug.ShouldBeLessThanOrEqualTo(9);
        }
コード例 #8
0
        private static void ReportDiggerLifetimeStats(ChipDigger digger)
        {
            Game.WriteLine("Lifetime Statistics", PcmColor.Black, PcmColor.Yellow);
            var lifetimeTable = new TableOutput(80, PcmColor.Yellow);

            lifetimeTable.AddHeaders("Stat", "Value");
            lifetimeTable.AddRow("First Equipped", digger.FirstEquipped.ToString(CultureInfo.CurrentCulture));
            lifetimeTable.AddRow("Lifetime Digs", digger.GetLifeTimeStat(DiggerStats.LifetimeDigs).ToString());
            lifetimeTable.AddRow("Lifetime Chips", digger.GetLifeTimeStat(DiggerStats.LifetimeChips).ToString());
            lifetimeTable.AddRow("Lifetime Repairs", digger.GetLifeTimeStat(DiggerStats.LifetimeRepairs).ToString());
            lifetimeTable.AddRow("Lifetime Bolts Cost", digger.GetLifeTimeStat(DiggerStats.LifeTimeBoltsCost).ToString());
            lifetimeTable.AddRow("Lifetime Tokes Cost", digger.GetLifeTimeStat(DiggerStats.LifeTimeTokensCost).ToString());
            Game.Write(lifetimeTable);
        }
コード例 #9
0
        public void With_digger_bit_slot_available_but_upgrade_to_large_fails_upgrade()
        {
            var digger = ChipDigger.StandardDigger(MineClaim.Default);
            var item   = new BitUpgradeItem()
            {
                Name              = "better bit",
                Description       = "",
                Id                = 10,
                Level             = 3,
                RequiredSlotLevel = 0,
            };
            var result = DiggerUpgrader.ApplyUpgrade(digger, item);

            result.completed.ShouldBeFalse();
        }
コード例 #10
0
        public RepairCommandHandlerTests()
        {
            proc      = new MockMainProcess();
            gameState = new GameState();
            Game.SetMainProcess(proc);
            gameState.Miner = Miner.Default();

            var digger = ChipDigger.StandardDigger(new MineClaim(
                                                       PotatoChipMine.Core.ChipDensity.Normal,
                                                       SiteHardness.Firm
                                                       ));

            digger.Name = EXISTING_DIGGER_NAME;

            gameState.Miner.Diggers.Add(digger);
        }
コード例 #11
0
        private ChipDigger EquipDigger(MineClaim mineClaim)
        {
            var digger    = GameState.Miner.Inventory("standard_digger");
            var newDigger = ChipDigger.StandardDigger(mineClaim);

            newDigger.Name = diggerName;
            digger.Count--;
            GameState.Miner.Diggers.Add(newDigger);

            Game.Write($"Digger {newDigger.Name} has been equipped on ");
            Game.Write($"{newDigger.MineClaim.ChipDensity.ToString()} density", PcmColor.Blue);
            Game.Write(" with a ");
            Game.Write($"{newDigger.MineClaim.Hardness.ToString()} hardness", PcmColor.Cyan);
            Game.WriteLine(string.Empty);
            return(newDigger);
        }
コード例 #12
0
        private static void ReportDiggerUpgrades(ChipDigger digger)
        {
            Game.WriteLine("Available Upgrades", PcmColor.Black, PcmColor.Yellow);
            var upgradesTable = new TableOutput(80, PcmColor.Yellow);

            upgradesTable.AddHeaders("Name", "Max Level", "Current Level", "Slot");
            foreach (var diggerUpgrade in digger.AvailableUpgrades)
            {
                upgradesTable.AddRow(diggerUpgrade.Name,
                                     diggerUpgrade.MaxLevel.ToString(),
                                     diggerUpgrade.CurrentLevel.ToString(),
                                     diggerUpgrade.Slot.ToString()
                                     );
                upgradesTable.AddRow(diggerUpgrade.Description);
            }

            Game.Write(upgradesTable);
        }
コード例 #13
0
 public void AssignDigger(ChipDigger digger)
 {
     DiggerName = digger.Name;
 }
コード例 #14
0
        public override void HandleInput(UserCommand command)
        {
            switch (dialogStep)
            {
            case 1:
                if (string.IsNullOrEmpty(command.FullCommand))
                {
                    Game.WriteLine("A name is required!", PcmColor.Red, null, GameConsoles.Input);
                    return;
                }

                if (!GameState.Miner.Diggers.Any(x =>
                                                 string.Equals(x.Name, command.FullCommand, StringComparison.InvariantCultureIgnoreCase)))
                {
                    Game.WriteLine($"There is no digger named {command.CommandText}", PcmColor.Red, null,
                                   GameConsoles.Input);
                    return;
                }

                digger = GameState.Miner.Diggers.First(x =>
                                                       string.Equals(x.Name, command.FullCommand, StringComparison.InvariantCultureIgnoreCase));
                GameState.PromptText = "Enter upgrade item to use:";
                dialogStep++;
                break;

            case 2:
                itemEntryAttempts++;

                if (itemEntryAttempts > 3)
                {
                    Game.WriteLine($"We aren't able to help you with that.");
                    GameState.PromptText = null;
                    Game.PopScene();
                    return;
                }

                if (string.IsNullOrEmpty(command.FullCommand))
                {
                    Game.WriteLine("An upgrade item is required!", PcmColor.Red, null, GameConsoles.Input);
                    return;
                }

                item = GameState.Miner.InventoryItems.FirstOrDefault(x =>
                                                                     string.Equals(x.Item.Name, command.FullCommand, StringComparison.CurrentCultureIgnoreCase));
                if (item == null || item.Count < 1)
                {
                    Game.WriteLine($"You don't have any {command.FullCommand}!");
                    return;
                }

                if (!(item.Item is DiggerUpgradeItem))
                {
                    Game.WriteLine($"The item is not a digger upgrade!");
                    return;
                }

                var result = DiggerUpgrader.ApplyUpgrade(digger, item.Item as DiggerUpgradeItem);
                if (!result.completed)
                {
                    Game.WriteLine(result.message, PcmColor.Red, null, GameConsoles.Input);
                    Game.WriteLine($"{digger.Name} has not been upgraded. {item.Item.Name} isn't available yet.");
                    GameState.PromptText = null;
                    Game.PopScene();
                    return;
                }

                GameState.Miner.InventoryItems.FirstOrDefault(x =>
                                                              string.Equals(x.Item.Name, item.Item.Name, StringComparison.InvariantCultureIgnoreCase)).Count--;
                GameState.PromptText = null;
                Game.WriteLine($"{digger.Name} has been upgraded. {item.Item.Name}");
                Game.WriteLine(item.Item.Description);
                Game.PopScene();
                break;
            }
        }