Example #1
0
 protected bool canHit()
 {
     if (RandomNumberGenerator.numberBetween(0, 1) == 1)
     {
         return(true);
     }
     return(false);
 }
Example #2
0
 public void monsterTurn()
 {
     if (this.canHit())
     {
         int damageToPlayer = RandomNumberGenerator.numberBetween(0, currentMonster.maxDamage);
         RaiseMessage("The " + currentMonster.name + " did " + damageToPlayer.ToString() + " damage points.");
         currentHitPoints -= damageToPlayer;
         if (currentHitPoints <= 0)
         {
             RaiseMessage("YOU GOT F****D BY " + currentMonster.name);
             moveTo(World.locationByID(World.LOCATION_ID_HOME));
         }
     }
     else
     {
         RaiseMessage(currentMonster.name + " missed!");
     }
 }
Example #3
0
        public void useWeapon(Weapon weapon)
        {
            if (canHit())
            {
                int damageToMonster = RandomNumberGenerator.numberBetween(weapon.minDamage + strength, weapon.maxDamage + strength);
                currentMonster.currentHitPoints -= damageToMonster;
                RaiseMessage("You hit the " + currentMonster.name + " for " + damageToMonster.ToString() + " points.");
                if (currentMonster.currentHitPoints <= 0)
                {
                    RaiseMessage("You defeated the " + currentMonster.name);
                    addExpierencePoints(currentMonster.rewardExpPoints);
                    RaiseMessage("You have received " + currentMonster.rewardExpPoints.ToString() + " xp points ");
                    gold += currentMonster.rewardGold;
                    RaiseMessage("You have receivved " + currentMonster.rewardGold.ToString() + " gold ");

                    List <InventoryItem> lootedItems = new List <InventoryItem>();
                    foreach (LootItem ii in currentMonster.lootTable)
                    {
                        if (RandomNumberGenerator.numberBetween(1, 100) <= ii.dropPercentage)
                        {
                            lootedItems.Add(new InventoryItem(ii.details, 1));
                        }
                    }
                    if (lootedItems.Count == 0)
                    {
                        foreach (LootItem ii in currentMonster.lootTable)
                        {
                            if (ii.isDefaultItem)
                            {
                                lootedItems.Add(new InventoryItem(ii.details, 1));
                            }
                        }
                    }
                    foreach (InventoryItem ii in lootedItems)
                    {
                        addItemtoInventory(ii.details);
                        if (ii.quantity == 1)
                        {
                            RaiseMessage("You have looted " + ii.quantity.ToString() + " " + ii.details.name);
                        }
                        else
                        {
                            RaiseMessage("You have looted " + ii.quantity.ToString() + " " + ii.details.namePlural);
                        }
                    }
                    checkKillQuestCompletion(World.QUEST_ID_CLEAR_ALCHEMIST_GARDEN, World.ITEM_ID_RAT_TAIL, 5);
                    checkKillQuestCompletion(World.QUEST_ID_CLEAR_FARMERS_FIELD, World.ITEM_ID_SNAKESKIN, 5);
                    //updateLabels();
                    moveTo(currentLocation);
                }
                else
                {
                    monsterTurn();
                }
            }
            else
            {
                RaiseMessage("You missed!");
                monsterTurn();
            }
        }