示例#1
0
        public bool Do(IAdventurePlayer player, IAdventureItem item)
        {
            item.IsActive = false;
            player.ChatClient.PostDirectMessage(player, _message);

            return(true);
        }
示例#2
0
        public bool Do(IAdventurePlayer player, IAdventureItem item)
        {
            var location = player.CurrentLocation;

            if (item is null)
            {
                player.ChatClient.PostDirectMessage(player, $"You cannot see a {item.Name} here!");
                return(false);
            }

            if (item.IsOpen)
            {
                player.ChatClient.PostDirectMessage(player, $"The {item.Name} is already open!");
                return(false);
            }

            if (item.IsLocked)
            {
                player.ChatClient.PostDirectMessage(player, $"The {item.Name} is locked!");
                return(false);
            }

            player.ChatClient.PostDirectMessage(player, $"You have opened the {item.Name}.");
            item.IsOpen = true;
            return(true);
        }
示例#3
0
        public bool Do(IAdventurePlayer player, IAdventureItem item)
        {
            var location = player.CurrentLocation;

            if (item is null)
            {
                player.ChatClient.PostDirectMessage(player, $"You cannot see a {item.Name} here!");
                return(false);
            }

            if (!item.IsLocked)
            {
                player.ChatClient.PostDirectMessage(player, $"The {item.Name} is already unlocked!");
                return(false);
            }

            if (player.Inventory.GetItems().All(i => i.ItemId != item.ItemIdToUnlock))
            {
                player.ChatClient.PostDirectMessage(player, $"You need to find something with which to unlock the {item.Name}!");
                return(false);
            }

            player.ChatClient.PostDirectMessage(player, $"You try your {item.ItemIdToUnlock} ...");

            item.IsLocked = false;
            player.ChatClient.PostDirectMessage(player, $"The {item.Name} is now unlocked!");
            return(true);
        }
示例#4
0
        public bool Do(IAdventurePlayer player, IAdventureItem item)
        {
            if (!player.Clocks.ContainsKey(_clockName))
            {
                player.Clocks.Add(_clockName, 0);
            }

            return(true);
        }
        public bool Do(IAdventurePlayer player, IAdventureItem item)
        {
            if (player.CurrentLocation.LocationId.Equals(_atLocation))
            {
                player.ChatClient.PostDirectMessage(player, _message);
            }

            return(true);
        }
示例#6
0
        public bool Do(IAdventurePlayer player, IAdventureItem item = null)
        {
            if (!player.EventRecord.ContainsKey(_eventId))
            {
                return(false);
            }

            player.EventRecord[_eventId] += _value;
            return(true);
        }
示例#7
0
        public bool Do(IAdventurePlayer player, IAdventureItem item = null)
        {
            if (player.Statuses.Contains(_status))
            {
                return(false);
            }

            player.Statuses.Add(_status);
            return(true);
        }
示例#8
0
        private void RemoveTroll(IAdventurePlayer player, IAdventureItem troll, IAdventureLocation swOfChasm, IAdventureLocation neOfChasm)
        {
            var removeTroll1 = new RemoveFromLocation(troll, swOfChasm);
            var removeTroll2 = new RemoveFromLocation(troll, neOfChasm);

            removeTroll1.Do(player, troll);
            removeTroll2.Do(player, troll);

            AllowPassage(player);
        }
示例#9
0
        public bool Do(IAdventurePlayer player, IAdventureItem item)
        {
            if (!player.Inventory.Has(item.ItemId))
            {
                player.Inventory.AddItem(item);
                return(true);
            }

            return(false);
        }
示例#10
0
        public bool AddItemToContainer(IAdventureItem item, Item containerId)
        {
            var intoContainer = _items.FirstOrDefault(i => i.IsContainer && i.ItemId.Equals(containerId));

            if (intoContainer is null)
            {
                return(false);
            }

            intoContainer.Contents.Add(item);
            return(true);
        }
示例#11
0
        public bool RemoveItemContainer(IAdventureItem item)
        {
            var fromContainer = _items.FirstOrDefault(i => i.IsContainer && i.Contents.Contains(item));

            if (fromContainer is null)
            {
                return(false);
            }

            fromContainer.Contents.Remove(item);
            return(true);
        }
示例#12
0
 private void CreateNewInstance(IAdventurePlayer player, IAdventureItem locationItem)
 {
     if (locationItem.ContainerRequired())
     {
         player.Inventory.AddItemToContainer(ItemFactory.GetInstance(_game, locationItem.ItemId),
                                             locationItem.MustBeContainedIn);
     }
     else
     {
         player.Inventory.AddItem(ItemFactory.GetInstance(_game, locationItem.ItemId));
     }
 }
示例#13
0
        public override void Attack(IAdventurePlayer player, IAdventureItem troll, IAdventureItem weapon)
        {
            if (weapon != null)
            {
                player.ChatClient.PostDirectMessage(player, $"You try to to attack the dragon, but it breathes acid at your {weapon.Name}!");
                player.ChatClient.PostDirectMessage(player, $"You drop the ruined {weapon.Name} and it quickly dissolves into a puddle of slag!");
                var loseWeapon = new RemoveFromInventory();
                loseWeapon.Do(player, weapon);
            }

            return;
        }
示例#14
0
        public bool Do(IAdventurePlayer player, IAdventureItem item)
        {
            if (_location is null)
            {
                player.CurrentLocation.RemoveItem(_itemToRemove);
            }
            else
            {
                _location.RemoveItem(_itemToRemove);
            }

            return(true);
        }
示例#15
0
        public override void Give(IAdventurePlayer player, IAdventureItem item, IAdventureItem snake)
        {
            var removeItem = new RemoveFromInventory();

            removeItem.Do(player, item);

            // Place item in the Hall of the Mountain King
            Game.Dungeon.TryGetLocation(Location.HallOfMountainKing, out var location);
            var addToLocation = new AddToLocation(item, location);

            addToLocation.Do(player, item);

            player.ChatClient.PostDirectMessage(player, $"The snake hisses and snaps at you! It ignores the {item.Name}");
        }
示例#16
0
 public override void Attack(IAdventurePlayer player, IAdventureItem troll, IAdventureItem weapon = null)
 {
     if (weapon != null)
     {
         player.ChatClient.PostDirectMessage(player, $"You try to to attack the troll, but it snatches the {weapon.Name} from your puny grasp and casts it into the chasm!");
         var loseWeapon = new RemoveFromInventory();
         loseWeapon.Do(player, weapon);
     }
     else
     {
         player.ChatClient.PostDirectMessage(player, $"As you approach the hideous troll, it points at its sign and yells 'Pay troll!'");
         player.ChatClient.PostDirectMessage(player, $"The creature's foul breath drives you back, gasping for air.");
     }
 }
示例#17
0
        public bool Do(IAdventurePlayer player, IAdventureItem item)
        {
            if (item.ContainerRequired())
            {
                var container = player.Inventory.GetItems().FirstOrDefault(i => i.ItemId == item.MustBeContainedIn);
                container?.Contents.Remove(item);
            }
            else
            {
                player.Inventory.RemoveItem(item);
            }

            return(true);
        }
示例#18
0
        public bool Do(IAdventurePlayer player, IAdventureItem item)
        {
            if (_from == Location.Nowhere)
            {
                player.CurrentLocation.RemoveDestination(_destination);
            }
            else
            {
                if (!_game.Dungeon.TryGetLocation(_from, out var fromLocation))
                {
                    return(false);
                }

                fromLocation.RemoveDestination(_destination);
            }

            return(true);
        }
示例#19
0
        public bool Do(IAdventurePlayer player, IAdventureItem item)
        {
            if (_toLocation == Location.Nowhere)
            {
                player.CurrentLocation.AddMoves(_moves);
            }
            else
            {
                var found = _game.Dungeon.TryGetLocation(_toLocation, out var loc);

                if (found)
                {
                    loc.AddMoves(_moves);
                }
            }

            return(true);
        }
示例#20
0
        public override void Attack(IAdventurePlayer player, IAdventureItem troll, IAdventureItem weapon)
        {
            player.ChatClient.PostDirectMessage(player, "The snake hisses horribly and strikes it you!");

            if (weapon != null)
            {
                player.ChatClient.PostDirectMessage(player, $"You are so startled that you drop your {weapon.Name}!");

                var removeItem = new RemoveFromInventory();
                removeItem.Do(player, weapon);

                // Place item in the Hall of the Mountain King
                Game.Dungeon.TryGetLocation(Location.HallOfMountainKing, out var location);
                var addToLocation = new AddToLocation(weapon, location);
                addToLocation.Do(player, weapon);
            }

            return;
        }
示例#21
0
 private void AddInteractionsWhenSnakeKilled(IInteraction interaction, IAdventureItem snake)
 {
     interaction.RegisteredInteractions.Add(new Display("The bird spots the snake, and darts to attack it..."));
     interaction.RegisteredInteractions.Add(new RemoveFromLocation(snake));
     interaction.RegisteredInteractions.Add(
         new AddToLocation(ItemFactory.GetInstance(Game, Item.DeadSnake)));
     interaction.RegisteredInteractions.Add(new Display("After a furious battle, the snake lies dead on the floor!"));
     interaction.RegisteredInteractions.Add(new RemoveDestination(Game, Location.HallOfMountainKing));
     interaction.RegisteredInteractions.Add(new AddMoves(new List <IPlayerMove>
     {
         new PlayerMove("You get down on hands and knees and crawl into a low-ceilinged passage...", Location.LowPassage, "north", "n"),
         new PlayerMove(string.Empty, Location.SouthSideChamber, "south", "s"),
         new PlayerMove(string.Empty, Location.WestSideChamber, "west", "w"),
         new PlayerMove("You squeeze through a narrow, hidden crack...", Location.SecretEastWestCanyon, "secret"),
         new RandomMove("", new List <Location>
         {
             Location.HallOfMountainKing, Location.HallOfMountainKing, Location.SecretEastWestCanyon
         },
                        "southwest", "sw"),
     }, Game, Location.HallOfMountainKing));
 }
示例#22
0
        public override bool RunItemEvents(IAdventurePlayer player, IAdventureItem lamp)
        {
            if (lamp != null)
            {
                if (!player.EventRecord.ContainsKey(EventIds.HasLamp))
                {
                    player.EventRecord.Add(EventIds.HasLamp, 330);
                }
                else
                {
                    if (lamp.IsActive)
                    {
                        player.EventRecord[EventIds.HasLamp]--;
                    }
                }
            }

            if (player.EventRecord.ContainsKey(EventIds.HasLamp))
            {
                var lampTurns = player.EventRecord[EventIds.HasLamp];
                var theLamp   = player.Inventory.GetItems().FirstOrDefault(x => x.ItemId == Item.Lamp);

                if (theLamp != null)
                {
                    if (lampTurns > 0 && lampTurns <= 30)
                    {
                        player.ChatClient.PostDirectMessage(player, "Your lamp is going dim!");
                    }

                    if (lampTurns <= 0)
                    {
                        theLamp.IsActive = false;
                    }
                }
            }

            return(true);
        }
示例#23
0
        public override void Give(IAdventurePlayer player, IAdventureItem item, IAdventureItem troll)
        {
            // Destroy item
            var removeItem = new RemoveFromInventory();

            removeItem.Do(player, item);

            if (item.IsTreasure)
            {
                // Place item in the Troll's Cave
                Game.Dungeon.TryGetLocation(Location.TrollCave, out var location);

                var addToLocation = new AddToLocation(item, location);
                addToLocation.Do(player, item);

                // Troll will move away from the bridge
                player.ChatClient.PostDirectMessage(player,
                                                    $"The troll accepts your {item.Name}, appraises it with a critical eye, and retreats under its bridge!");
            }
            else
            {
                // The troll throws the item into the chasm
                player.ChatClient.PostDirectMessage(player,
                                                    $"The troll scowls at you and throws the {item.Name} into the chasm. 'Pay Troll!', it roars.");

                return;
            }

            Game.Dungeon.TryGetLocation(Location.SouthWestOfChasm, out var swOfChasm);
            Game.Dungeon.TryGetLocation(Location.NorthEastOfChasm, out var neOfChasm);
            RemoveTroll(player, troll, swOfChasm, neOfChasm);

            var clock = new StartClock("troll");

            clock.Do(player, troll);
        }
示例#24
0
 public RemoveFromLocation(IAdventureItem itemToRemove, IAdventureLocation location)
 {
     _itemToRemove = itemToRemove;
     _location     = location;
 }
示例#25
0
 public virtual bool RunItemEvents(IAdventurePlayer player, IAdventureItem item) => true;
示例#26
0
 public virtual void Attack(IAdventurePlayer player, IAdventureItem target)
 {
     player.ChatClient.PostDirectMessage(player, $"Why you are trying to attack a {target.Name}? That's not very productive!");
 }
示例#27
0
 public virtual void Give(IAdventurePlayer player, IAdventureItem itemInInventory, IAdventureItem recipient)
 {
     player.ChatClient.PostDirectMessage(player, $"I'm not sure why you are trying to give a {itemInInventory.Name} to a {recipient.Name}");
 }
示例#28
0
 public bool Do(IAdventurePlayer player, IAdventureItem item)
 {
     player.CurrentLocation.RemoveItem(_itemToRemove);
     return(true);
 }
示例#29
0
 public override void Attack(IAdventurePlayer player, IAdventureItem troll)
 {
     player.ChatClient.PostDirectMessage(player, "The snake hisses and snaps at you! You cannot get near enough to it to strike!");
 }
示例#30
0
 public RemoveFromLocation(IAdventureItem itemToRemove)
 {
     _itemToRemove = itemToRemove;
 }