public Monster NewInstanceOfMonsterLivingHere()
        {
            if (!HasAMonster)
            {
                return(null);
            }

            // Total the percentages of all monsters at this location
            int totalPercentages = _monstersAtLocation.Values.Sum();

            // Select a random number between 1 and the total (in case the total of percentages is not 100)
            int randomNumber = RandomNumberGenerator.NumberBetween(1, totalPercentages);

            // Loop through the monster list, adding the monster's percentage chance of appearing to the running total variable
            // When the random number is lower then the runningTotal, that is the monster to return.
            int runningTotal = 0;

            foreach (KeyValuePair <int, int> monsterKeyValuePair in _monstersAtLocation)
            {
                runningTotal += monsterKeyValuePair.Value;

                if (randomNumber <= runningTotal)
                {
                    return(World.MonsterByID(monsterKeyValuePair.Key).NewInstanceOfMonster());
                }
            }

            // In case there was a problem, return the last monster in the list.
            return(World.MonsterByID(_monstersAtLocation.Keys.Last()).NewInstanceOfMonster());
        }
Exemple #2
0
        private void SetCurrentMonsterAtLocation(Location newLocation)
        {
            //does the locatoin have a monster?
            if (newLocation.MonsterLivingHere != null)
            {
                RaiseMessage("You see a " + newLocation.MonsterLivingHere.Name);

                Monster standardMonster = World.MonsterByID(newLocation.MonsterLivingHere.ID);

                _currentMonster = new Monster(standardMonster.ID, standardMonster.Name, standardMonster.MaximumDamage,
                                              standardMonster.RewardExperiencePoints, standardMonster.RewardGold, standardMonster.CurrentHitPoints,
                                              standardMonster.MaximumHitPoints);

                foreach (LootItem lootItem in standardMonster.LootTable)
                {
                    _currentMonster.LootTable.Add(lootItem);
                }
            }
            else
            {
                _currentMonster = null;
            }
        }
Exemple #3
0
        private void SpawnMonster(Location newLocation)
        {
            // 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.MaximumDamage,
                                              standardMonster.RewardExperiencePoints, standardMonster.RewardGold, standardMonster.CurrentHitPoints, standardMonster.MaximumHitPoints);

                foreach (LootItem lootItem in standardMonster.LootTable)
                {
                    _currentMonster.LootTable.Add(lootItem);
                }
            }
            else
            {
                _currentMonster = null;
            }
        }
        public Monster NewInstanceOfMonsterLivingHere()
        {
            if (!HasAMonster)
            {
                return(null);
            }

            var totalPercentages = _monstersAtLocation.Values.Sum();

            var randomNumber = RandomNumberGenerator.NumberBetween(1, totalPercentages);

            var runningTotal = 0;

            foreach (var monsterKeyValuePair in _monstersAtLocation)
            {
                runningTotal += monsterKeyValuePair.Value;
                if (randomNumber <= runningTotal)
                {
                    return(World.MonsterByID(monsterKeyValuePair.Key).NewInstanceOfMonster());
                }
            }
            return(World.MonsterByID(_monstersAtLocation.Keys.Last()).NewInstanceOfMonster());
        }
Exemple #5
0
        public Monster NewInstanceOfMonsterLivingHere()
        {
            if (!HasAmonster)
            {
                return(null);
            }

            // If this location only has a monster appear some of the times,
            // check if a monster should appear this time.
            if (MonsterAppearanceChance > 0)
            {
                // Gets a random number between 1 and 100.
                // If the number is less than, or equal to, the MonsterAppearanceChance, create a monster
                bool monsterAppeared = RandomNumberGen.NumberBetween(1, 100) <= MonsterAppearanceChance;

                // If no monster appeared, return null (no monster this time)
                if (!monsterAppeared)
                {
                    return(null);
                }
            }

            int totalPercentages = _monsterAtLocation.Values.Sum();
            int randomNumber     = RandomNumberGen.NumberBetween(1, totalPercentages);
            int runningTotal     = 0;

            foreach (KeyValuePair <int, int> monsterKeyValuePair in _monsterAtLocation)
            {
                runningTotal += monsterKeyValuePair.Value;

                if (randomNumber <= runningTotal)
                {
                    return(World.MonsterByID(monsterKeyValuePair.Key).NewInstanceOfMonster());
                }
            }
            return(World.MonsterByID(_monsterAtLocation.Keys.Last()).NewInstanceOfMonster());
        }
Exemple #6
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;

            // Completely heal the player
            CurrentHitPoints = MaximumHitPoints;

            // 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.MaximumDamage,
                                              standardMonster.RewardExperiencePoints, standardMonster.RewardGold, standardMonster.CurrentHitPoints, standardMonster.MaximumHitPoints);

                foreach (LootItem lootItem in standardMonster.LootTable)
                {
                    _currentMonster.LootTable.Add(lootItem);
                }
            }
            else
            {
                _currentMonster = null;
            }
        }
Exemple #7
0
        /* Function to move the player to a new location */
        public void MoveTo(Location newLocation)
        {
            //Does the location have any required items
            if (!HasRequiredItemToEnterThisLocation(newLocation))
            {
                // rtbMessages.Text += "You must have a " + newLocation.ItemRequiredToEnter.Name + " to enter this location." + Environment.NewLine;
                return;
            }

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

            // Show/hide available movement buttons
            // btnNorth.Visible = (newLocation.LocationToNorth != null);
            // btnEast.Visible = (newLocation.LocationToEast != null);
            // btnSouth.Visible = (newLocation.LocationToSouth != null);
            // btnWest.Visible = (newLocation.LocationToWest != null);

            // Display current location name and description
            // rtbLocation.Text = newLocation.Name + Environment.NewLine;
            // rtbLocation.Text += newLocation.Description + Environment.NewLine;

            // Completely heal the player
            CurrentHitPoints = MaximumHitPoints;

            // Update Hit Points in UI
            // lblHitPoints.Text = _player.CurrentHitPoints.ToString(); // data binding takes care of this

            // 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)
                        {
                            completeQuest(newLocation);
                        }
                    }
                }
                else
                {
                    // The player does not already have the quest

                    // Display the messages

                    /* rtbMessages.Text += "You received the " + newLocation.QuestAvailableHere.Name + " quest." + Environment.NewLine;
                     * rtbMessages.Text += newLocation.QuestAvailableHere.Description + Environment.NewLine;
                     * rtbMessages.Text += "To complete this, come back with:" + Environment.NewLine; */
                    foreach (QuestCompletionItem qci in newLocation.QuestAvailableHere.QuestCompletionItems)
                    {
                        if (qci.Quantity == 1)
                        {
                            RaiseMessage(qci.Quantity.ToString() + " " + qci.Details.Name + Environment.NewLine);
                        }
                        else
                        {
                            RaiseMessage(qci.Quantity.ToString() + " " + qci.Details.NamePlural + Environment.NewLine);
                        }
                    }
                    // rtbMessages.Text += Environment.NewLine;

                    // 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 + "!" + Environment.NewLine);

                // Make a new monster and add its loot table, 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.MaximumDamage,
                                              standardMonster.RewardExperiencePoints, standardMonster.RewardGold, standardMonster.CurrentHitPoints, standardMonster.MaximumHitPoints);

                foreach (LootItem lootItem in standardMonster.LootTable)
                {
                    _currentMonster.LootTable.Add(lootItem);
                }

                // Prepare UI for combat

                /* cboWeapons.Visible = Weapons.Any();
                 * cboPotions.Visible = Potions.Any();
                 * btnUseWeapon.Visible = Weapons.Any();
                 * btnUsePotion.Visible = Potions.Any();*/
            }
            else
            {
                _currentMonster = null;

                /*cboWeapons.Visible = false;
                 * cboPotions.Visible = false;
                 * btnUseWeapon.Visible = false;
                 * btnUsePotion.Visible = false;*/
            }
        }
Exemple #8
0
        public void MoveTo(Location newLocation)
        {
            if (!HasRequiredItemToEnterThisLocation(newLocation))
            {
                RaiseMessage("你必須" + newLocation.ItemRequiredToEnter.Name + "才能進入此區域");
                return;
            }



            CurrentLocation  = newLocation;
            CurrentHitPoints = MaxHitPoints;

            if (newLocation.QuestAvailableHere != null)
            {
                bool playerAlreadyHasQuest      = HasThisQuest(newLocation.QuestAvailableHere);
                bool playerAlreadyCompleteQuest = CompletedThisQuest(newLocation.QuestAvailableHere);

                if (playerAlreadyHasQuest)
                {
                    if (!playerAlreadyCompleteQuest)
                    {
                        bool playerHasAllItemsToCompleteQuest =
                            HasAllQuestCompletedItem(newLocation.QuestAvailableHere);

                        if (playerHasAllItemsToCompleteQuest)
                        {
                            RaiseMessage("");
                            RaiseMessage("你完成了" + newLocation.QuestAvailableHere.Name + "任務");
                            RemoveQuestCompletionItems(newLocation.QuestAvailableHere);

                            RaiseMessage("妳得到了: " + newLocation.QuestAvailableHere.RewardEXP.ToString() + "經驗值");
                            RaiseMessage("以及" + newLocation.QuestAvailableHere.RewardGold + "黃金");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardItem.Name, true);

                            AddEXPPoints(newLocation.QuestAvailableHere.RewardEXP);
                            Gold += newLocation.QuestAvailableHere.RewardGold;

                            AddItemToInventory(newLocation.QuestAvailableHere.RewardItem);

                            MarkQuestCompleted(newLocation.QuestAvailableHere);
                        }
                    }
                }
                else
                {
                    RaiseMessage("你得到了" + newLocation.QuestAvailableHere.Name + "任務");
                    RaiseMessage(newLocation.QuestAvailableHere.Description);
                    RaiseMessage("為了完成任務,需要物品:");

                    foreach (QuestCompletionItem qui in newLocation.QuestAvailableHere.QuestCompletionItems)
                    {
                        if (qui.Quantity == 1)
                        {
                            RaiseMessage(qui.Quantity + " " + qui.Details.Name);
                        }

                        else
                        {
                            RaiseMessage(qui.Quantity + " " + qui.Details.NamePlural);
                        }
                    }

                    RaiseMessage(" ");

                    Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere));
                }
            }

            if (newLocation.MonsterLivingHere != null)
            {
                RaiseMessage("你看到了" + newLocation.MonsterLivingHere.Name);
                Monster standardMonster = World.MonsterByID(newLocation.MonsterLivingHere.ID);

                _currentMonster = new Monster(standardMonster.ID, "standardMonster.Name", standardMonster.MaxDamage,
                                              standardMonster.RewardEXP, standardMonster.RewardGold, standardMonster.CurrentHitPoints,
                                              standardMonster.MaxHitPoints);

                foreach (LootItem lootItem in standardMonster.LootTable)
                {
                    _currentMonster.LootTable.Add(lootItem);
                }
            }
            else
            {
                _currentMonster = null;
            }
        }
 public void AddMonster(int id, int num)
 {
     MonsterLivingHere = World.MonsterByID(id);
 }
Exemple #10
0
        /**
         * This is the Room constructor. It creates a Room object with the passed variables then assignd
         * those to the class variables.
         */
        #region Constructor
        public Room(int id, String name, String descript, int exit1, int exit2, int exit3, int exit4, int idMonster, int idRmLoot, int idRmNPC)
        {
            this.ID              = id;
            this.RoomName        = name;
            this.RoomDescript    = descript;
            this.LocationToNorth = exit1;
            this.LocationToEast  = exit2;
            this.LocationToSouth = exit3;
            this.LocationToWest  = exit4;

            #region Monster List Add
            if (idMonster != 5) // 5 == dragon (Monster.Txt)
            {
                if (idMonster > -1)
                {
                    Random rand = new Random();

                    //int rmMobCatch = rand.Next(1, 5);
                    int rmMobCatch = RandomNumberGenerator.NumberBetween(0, 3); // 0 - 3 goblin - dog (element index)
                    this.RoomMonsters = new Monster(World.Monsters[rmMobCatch]);
                    this.RoomMob.Add(RoomMonsters);
                }
            }
            else
            {
                this.RoomMob.Add(World.MonsterByID(idMonster));
            }
            #endregion

            #region Room Loot
            if (idRmLoot > -1)
            {
                if (idRmLoot > 200 && idRmLoot <= 300)
                {
                    Item rmLoot = World.Items.SingleOrDefault(ii => ii.ID == idRmLoot);
                    RoomLoot.Add(new Item(rmLoot.ID, rmLoot.Name, rmLoot.NamePlural, rmLoot.Desc, rmLoot.Price, rmLoot.Equiptable));
                }
                else if (idRmLoot > 100 && idRmLoot <= 200)
                {
                    IWeapon rmLoot = World.Weapons.SingleOrDefault(ii => ii.ID == idRmLoot);
                    RoomLoot.Add(new Weapon(rmLoot.ID, rmLoot.Name, rmLoot.NamePlural, rmLoot.Desc, rmLoot.Price, rmLoot.Damage, rmLoot.DamageType, rmLoot.Equiptable, rmLoot.WearLocation));
                }
            }
            #endregion


            #region NPC Load
            if (idRmNPC != -1)
            {
                if (idRmNPC == 601) // 601== Bob the Cook (NPC.Txt)
                {
                    this.RoomNPC = new NPC(World.NPCByID(idRmNPC));
                    this.RmNPC.Add(RoomNPC);
                }
                else if (idRmNPC == 602) // 602== Dragon Trainer (NPC.Txt)
                {
                    this.RoomNPC = new NPC(World.NPCByID(idRmNPC));
                    this.RmNPC.Add(World.NPCByID(idRmNPC));
                }
            }
            #endregion
        }
Exemple #11
0
        public void MoveTo(Location newLocation)
        {
            if (!HasRequiredItemToEnterThisLocation(newLocation))
            {
                RaiseMessage("You must have a " + newLocation.ItemRequeredToEnter.Name +
                             " to enter this location.");
                return;
            }

            CurrentLocation = newLocation;

            CurrentHitPoints = MaximumHitPoints;

            if (newLocation.QuestAvailableHere != null)
            {
                bool playerAlreadyHasQuest = HasThisQuest(newLocation.QuestAvailableHere);

                bool playerAlreadyCompletedQuest = CompletedThisQuest(newLocation.QuestAvailableHere);

                if (playerAlreadyHasQuest)
                {
                    if (!playerAlreadyCompletedQuest)
                    {
                        bool playerHasAllItemsToCompleteQuest = HasAllQuestCompletionItems(newLocation.QuestAvailableHere);

                        if (playerHasAllItemsToCompleteQuest)
                        {
                            RaiseMessage("");
                            RaiseMessage("You complete the " + newLocation.QuestAvailableHere.Name +
                                         " quest.");

                            RemoveQuestCompletionItems(newLocation.QuestAvailableHere);

                            RaiseMessage("You receive: ");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardExperiancePoints.ToString() + " experience points");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardGold.ToString() + " gold");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardItem.Name, true);

                            AddExperiancePoint(newLocation.QuestAvailableHere.RewardExperiancePoints);
                            Gold += newLocation.QuestAvailableHere.RewardGold;

                            AddItemToInventory(newLocation.QuestAvailableHere.RewardItem);

                            MarkQuestCompleted(newLocation.QuestAvailableHere);
                        }
                    }
                }
                else
                {
                    RaiseMessage("You receive the " + newLocation.QuestAvailableHere.Name + " quest.");

                    RaiseMessage(newLocation.QuestAvailableHere.Description);

                    RaiseMessage("To complete it, return with:" + Environment.NewLine);

                    foreach (QuestCompetionItem questCompetionItem in newLocation.QuestAvailableHere.QuestCompetionItems)
                    {
                        if (questCompetionItem.Quantity == 1)
                        {
                            RaiseMessage(questCompetionItem.Quantity.ToString() + " " + questCompetionItem.Details.Name);
                        }
                        else
                        {
                            RaiseMessage(questCompetionItem.Quantity.ToString() + " " + questCompetionItem.Details.NamePlural);
                        }
                    }
                    RaiseMessage("");

                    Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere));
                }
            }

            if (newLocation.MonsterLivingHere != null)
            {
                RaiseMessage("You see a" + newLocation.MonsterLivingHere.Name);

                Monster standardMonster = World.MonsterByID(newLocation.MonsterLivingHere.ID);

                _currentMonster = new Monster(standardMonster.ID, standardMonster.Name,
                                              standardMonster.MaximumDamage, standardMonster.RewardExperiancePoints,
                                              standardMonster.RewardGold, standardMonster.CurrentHitPoints, standardMonster.MaximumHitPoints);

                foreach (LootItem lootItem in standardMonster.LootTable)
                {
                    _currentMonster.LootTable.Add(lootItem);
                }
            }
            else
            {
                _currentMonster = null;
            }
        }
        public void MoveTo(Location location)
        {
            //Does the location have any required items
            if (!PlayerDoesNotHaveTheItemRequiredToEnter(location))
            {
                RaiseMessage($"You must have a {location.ItemRequiredToEnter.Name} to enter this location." +
                             Environment.NewLine);
                return;
            }

            //Update the player's current location
            CurrentLocation = location;

            //Completely heal the player
            CurrentHitPoints = MaximumHitPoints;

            if (location.HasAQuest)
            {
                //See if the player already has the quest
                if (HasThisQuest(location.QuestAvailableHere))
                {
                    //If the player has not completed quest
                    if (!CompletedThisQuest(location.QuestAvailableHere))
                    {
                        //The player has all required items to complete the quest
                        if (HasAllQuestCompletionItems(location.QuestAvailableHere))
                        {
                            //Display message
                            RaiseMessage(Environment.NewLine);
                            RaiseMessage($"You completed the {location.QuestAvailableHere.Name} quest." + Environment.NewLine);

                            RemoveQuestCompletionItems(location.QuestAvailableHere);

                            //Give quest rewards
                            RaiseMessage("You receive " + Environment.NewLine);
                            RaiseMessage($"{location.QuestAvailableHere.RewardExperiencePoints} experience points" + Environment.NewLine);
                            RaiseMessage($"{location.QuestAvailableHere.RewardGold} gold" + Environment.NewLine);
                            RaiseMessage(location.QuestAvailableHere.RewardItem.Name + Environment.NewLine);
                            RaiseMessage(Environment.NewLine);

                            AddExperiencePoints(location.QuestAvailableHere.RewardExperiencePoints);

                            Gold += location.QuestAvailableHere.RewardGold;

                            //Add reward item to player inventory
                            AddItemToInventory(location.QuestAvailableHere.RewardItem);

                            //Mark the quest as completed
                            MarkQuestCompleted(location.QuestAvailableHere);
                        }
                    }
                }
                else
                {
                    //The player does not have the quest

                    //Display the messages
                    RaiseMessage($"You received the {location.QuestAvailableHere.Name} quest." + Environment.NewLine);
                    RaiseMessage(location.QuestAvailableHere.Description + Environment.NewLine);
                    RaiseMessage("To complete it, return with " + Environment.NewLine);

                    foreach (QuestCompletionItem qci in location.QuestAvailableHere.QuestCompletionItems)
                    {
                        if (qci.Quantity == 1)
                        {
                            RaiseMessage($"{qci.Quantity} {qci.Details.Name}" + Environment.NewLine);
                        }
                        else
                        {
                            RaiseMessage($"{qci.Quantity} {qci.Details.NamePlural}" + Environment.NewLine);
                        }
                    }

                    RaiseMessage(Environment.NewLine);

                    //Add the quest to the player's quest list
                    Quests.Add(new PlayerQuest(location.QuestAvailableHere));
                }
            }
            //Does the location have a monster?
            if (location.MonsterLivingHere != null)
            {
                RaiseMessage($"You see a {location.MonsterLivingHere.Name}" + Environment.NewLine);

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

                currentMonster = new Monster(standardMonster.ID, standardMonster.Name, standardMonster.MaximumDamage, standardMonster.RewardExperiencePoints,
                                             standardMonster.RewardGold, standardMonster.CurrentHitPoints, standardMonster.MaximumHitPoints);

                foreach (LootItem lootItem in standardMonster.LootTable)
                {
                    currentMonster.LootTable.Add(lootItem);
                }
            }

            else
            {
                currentMonster = null;
            }
        }
Exemple #13
0
        public void MoveTo(Location location)
        {
            if (PlayerDoesNotHaveTheRequiredItemToEnter(location))
            {
                RaiseMessage("You must have a " + location.ItemRequiredToEnter.Name + " to enter this location.");
                return;
            }

            CurrentLocation = location;

            FullHeal();

            if (location.HasAQuest)
            {
                bool playerAlreadyHasQuest       = HasThisQuest(location.QuestAvailableHere);
                bool playerAlreadyCompletedQuest = CompletedThisQuest(location.QuestAvailableHere);

                if (playerAlreadyHasQuest)
                {
                    if (!playerAlreadyCompletedQuest)
                    {
                        bool playerHasAllItemsToCompleteQuest = HasAllQuestCompletionItems(location.QuestAvailableHere);

                        if (playerHasAllItemsToCompleteQuest)
                        {
                            RaiseMessage("");
                            RaiseMessage("You complete the '" + location.QuestAvailableHere.Name + "' quest.");

                            RemoveQuestCompletionItems(location.QuestAvailableHere);

                            RaiseMessage("You receive: ");
                            RaiseMessage(location.QuestAvailableHere.RewardExperiencePoints + " experience points");
                            RaiseMessage(location.QuestAvailableHere.RewardGold + " gold");
                            RaiseMessage(location.QuestAvailableHere.RewardItem.Name, true);

                            AddExperiencePoints(location.QuestAvailableHere.RewardExperiencePoints);
                            Gold += location.QuestAvailableHere.RewardGold;

                            AddItemToInventory(location.QuestAvailableHere.RewardItem);

                            MarkQuestCompleted(location.QuestAvailableHere);
                        }
                    }
                }
                else
                {
                    RaiseMessage("You receive the " + location.QuestAvailableHere.Name + " quest.");
                    RaiseMessage(location.QuestAvailableHere.Description);
                    RaiseMessage("To complete it, return with:");
                    foreach (QuestCompletionItem qci in location.QuestAvailableHere.QuestCompletionItems)
                    {
                        if (qci.Quantity == 1)
                        {
                            RaiseMessage(qci.Quantity + " " + qci.Details.Name);
                        }
                        else
                        {
                            RaiseMessage(qci.Quantity + " " + qci.Details.NamePlural);
                        }
                    }
                    RaiseMessage("");

                    Quests.Add(new PlayerQuest(location.QuestAvailableHere));
                }
            }

            if (location.MonsterLivingHere != null)
            {
                RaiseMessage("You see a " + location.MonsterLivingHere.Name);

                Monster standardMonster = World.MonsterByID(location.MonsterLivingHere.ID);

                _currentMonster = new Monster(standardMonster.ID, standardMonster.Name, standardMonster.MaximumDamage,
                                              standardMonster.RewardExperiencePoints, standardMonster.RewardGold, standardMonster.CurrentHitPoints, standardMonster.MaximumHitPoints);

                foreach (LootItem lootItem in standardMonster.LootTable)
                {
                    _currentMonster.LootTable.Add(lootItem);
                }
            }
            else
            {
                _currentMonster = null;
            }
        }
        public void MoveTo(Location newLocation)
        {
            // Make sure _player has any required item for the new location
            if (!HasRequiredItemToEnterThisLocation(newLocation))
            {
                RaiseMessage("You must have a " + newLocation.ItemRequiredToEnter.Name +
                             " to enter this location.");
                return;  // return without moving to the new location
            }

            // We have any required item, or there wasn't an item required,
            // so update the player's current location
            CurrentLocation = newLocation;

            CompletelyHeal();

            #region QuestInNewLocation
            if (newLocation.HasAQuest)
            {
                if (PlayerDoesNotHaveThisQuest(newLocation.QuestAvailableHere))
                {
                    GiveQuestToPlayer(newLocation);
                }
                else // Player doesn't have the quest yet - so add it to his quest list
                {
                    if (PlayerHasNotCompleted(newLocation.QuestAvailableHere) &&
                        PlayerHasAllQuestCompletionItems(newLocation.QuestAvailableHere))
                    {
                        // Quest is completed!!
                        CompleteQuestAndGiveRewards(newLocation);
                    }
                } // end player has this quest / or not
            }     // end quest is available here
            #endregion

            #region MonsterLivingHere
            // 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.MaximumDamage, standardMonster.RewardExperiencePoints,
                                              standardMonster.RewardGold, standardMonster.CurrentHitPoints,
                                              standardMonster.MaximumHitPoints);

                foreach (LootItem lootItem in standardMonster.LootTable)
                {
                    _currentMonster.LootTable.Add(lootItem);
                }
            }
            else // There is not a MonsterLivingHere
            {
                _currentMonster = null;
            }
            #endregion
        }