Beispiel #1
0
        public Combat(Player player, Monster monster)
        {
            _player = player;
            _monster = monster;

            playerInit = RollInitiative(_player);
            monsterInit = RollInitiative(_monster);
        }
Beispiel #2
0
        private static void PopulateMonsters()
        {
            Monster rat = new Monster(MONSTER_ID_RAT, "Rat", 10, 0, 1, 1, 10, 0, RandomNumberGenerator.NumberBetween(1, 3));
            rat.SetAttributes(2, 11, 9, 2, 10, 4);
            rat.lootTable.Add(new LootItem(ItemByID(ITEM_ID_RAT_TAIL), 75, false));
            rat.lootTable.Add(new LootItem(ItemByID(ITEM_ID_PIECE_OF_FUR), 75, true));

            Monster snake = new Monster(MONSTER_ID_SNAKE, "Snake", 12, 4, 3, 8, 50, 0, RandomNumberGenerator.NumberBetween(4, 22));
            snake.SetAttributes(15, 14, 12, 1, 10, 3);
            snake.lootTable.Add(new LootItem(ItemByID(ITEM_ID_SNAKE_FANG), 75, false));
            snake.lootTable.Add(new LootItem(ItemByID(ITEM_ID_SNAKESKIN), 75, true));

            Monster giantSpider = new Monster(MONSTER_ID_GIANT_SPIDER, "Giant spider", 12, 4, 1, 1, 10, 00, RandomNumberGenerator.NumberBetween(1, 3));
            giantSpider.SetAttributes(2, 14, 8, 1, 10, 2);
            giantSpider.lootTable.Add(new LootItem(ItemByID(ITEM_ID_SPIDER_FANG), 75, true));
            giantSpider.lootTable.Add(new LootItem(ItemByID(ITEM_ID_SPIDER_SILK), 25, false));

            monsters.Add(rat);
            monsters.Add(snake);
            monsters.Add(giantSpider);
        }
Beispiel #3
0
        public void MoveTo(Location newLocation)
        {
            //Does the location have any required items
            if (!HasRequiredItemToEnterThisLocation(newLocation))
            {
               RaiseMessage("You must have a " + newLocation.itemRequiredToEnter.name + " to enter this location.");
                return;
            }

            // Update the player's current location
            currentLocation = newLocation;

            // Does the location have a quest?
            if (newLocation.questAvailableHere != null)
            {
                // See if the player already has the quest, and if they've completed it
                bool playerAlreadyHasQuest = HasThisQuest(newLocation.questAvailableHere);
                bool playerAlreadyCompletedQuest = CompletedThisQuest(newLocation.questAvailableHere);

                // See if the player already has the quest
                if (playerAlreadyHasQuest)
                {
                    // If the player has not completed the quest yet
                    if (!playerAlreadyCompletedQuest)
                    {
                        // See if the player has all the items needed to complete the quest
                        bool playerHasAllItemsToCompleteQuest = HasAllQuestCompletionItems(newLocation.questAvailableHere);

                        // The player has all items required to complete the quest
                        if (playerHasAllItemsToCompleteQuest)
                        {
                            // Display message
                            RaiseMessage("");
                            RaiseMessage("You complete the '" + newLocation.questAvailableHere.name + "' quest.");

                            // Remove quest items from inventory
                            RemoveQuestCompletionItems(newLocation.questAvailableHere);

                            // Give quest rewards
                            RaiseMessage("You receive: ");
                            RaiseMessage(newLocation.questAvailableHere.rewardExperiencePoints + " experience points");
                            RaiseMessage(newLocation.questAvailableHere.rewardGold + " gold");
                            RaiseMessage(newLocation.questAvailableHere.rewardItem.name, true);

                            AddExperiencePoints(newLocation.questAvailableHere.rewardExperiencePoints);
                            gold += newLocation.questAvailableHere.rewardGold;

                            // Add the reward item to the player's inventory
                            AddItemToInventory(newLocation.questAvailableHere.rewardItem);

                            // Mark the quest as completed
                            MarkQuestCompleted(newLocation.questAvailableHere);
                        }
                    }
                }
                else
                {
                    // The player does not already have the quest

                    // Display the messages
                    RaiseMessage("You receive the " + newLocation.questAvailableHere.name + " quest.");
                    RaiseMessage(newLocation.questAvailableHere.description);
                    RaiseMessage("To complete it, return with:");
                    foreach (QuestCompletionItem qci in newLocation.questAvailableHere.questCompletionItems)
                    {
                        if (qci.quantity == 1)
                        {
                            RaiseMessage(qci.quantity + " " + qci.details.name);
                        }
                        else
                        {
                            RaiseMessage(qci.quantity + " " + qci.details.namePlural);
                        }
                    }
                    RaiseMessage("");

                    // Add the quest to the player's quest list
                    quests.Add(new PlayerQuest(newLocation.questAvailableHere));
                }
            }

            // Does the location have a monster?
            if (newLocation.monsterLivingHere != null)
            {
                RaiseMessage("You see a " + newLocation.monsterLivingHere.name);

                // Make a new monster, using the values from the standard monster in the World.Monster list
                Monster standardMonster = World.MonsterByID(newLocation.monsterLivingHere.ID);

                _currentMonster = new Monster(standardMonster.ID, standardMonster.name, standardMonster.AC, standardMonster.attackMod, standardMonster.minimumDamage, standardMonster.maximumDamage,
                    standardMonster.rewardExperiencePoints, standardMonster.rewardGold, standardMonster.maximumHitPoints);

                foreach (LootItem lootItem in standardMonster.lootTable)
                {
                    _currentMonster.lootTable.Add(lootItem);
                }
            }
            else
            {
                _currentMonster = null;
            }
        }