Пример #1
0
        //Will probably have to be modified a little bit when we introduce spells, but maybe not
        private static void Kill(User.User player, List <string> commands)
        {
            //Has the round interval time elapsed?
            if (!CheckIfCanAttack(player.Player.LastCombatTime))
            {
                return;
            }

            //no target, no fight
            User.User enemy = GetTarget(player, commands);
            if (enemy == null)
            {
                return;
            }

            //For now when we get attacked we auto target that person
            TargetEachOther(player, enemy);

            //See if we can hit the other player
            double hitPercent = PercentHit(player, enemy);

            //get target block
            //block only lowers damage output, a really succesful block will make damage 0 or may even reflect back damage (maybe)
            //also block should take into consideration what is being used to block, obviosuly a shield is better but with a weapons parrying is much better than
            //block, as you may lose a combat round or your stance may be affected for the next round causing the defending player to waste a combat round
            //to get back into a good stance (well not a full round but it will affect
            //double chanceToBlock = GetAndEvaluateExpression("BlockChance", enemy.Player);

            //Get their main hand
            Items.Wearable mainHand = player.Player.Equipment.GetMainHandWeapon(player.Player);

            //Attack with the main hand
            WeaponHandAttack(player, enemy);
            //if they are wielding a weapon in their opposite hand then attack with it.
            if (player.Player.Equipment.GetWieldedWeapons().Count == 2)
            {
                WeaponHandAttack(player, enemy, true); //off-hand attack
            }

            //last time they attacked in a combat round
            player.Player.LastCombatTime = DateTime.Now.ToUniversalTime();

            //save as we progress through the fight, no quitting once you get going
            enemy.Player.Save();
            player.Player.Save();
        }
Пример #2
0
        public bool EquipItem(Items.Iitem item, Inventory inventory)
        {
            bool result = false;

            Items.Iweapon weaponItem = item as Items.Iweapon;
            if (weaponItem != null && weaponItem.IsWieldable)
            {
                //can't equip a wieldable weapon
            }
            else
            {
                if (!equipped.ContainsKey(item.WornOn))
                {
                    equipped.Add(item.WornOn, item);
                    if (inventory.inventory.Any(i => i.Id == item.Id))         //in case we are adding it from a load and not moving it from the inventory
                    {
                        inventory.inventory.RemoveWhere(i => i.Id == item.Id); //we moved the item over to equipped so we need it out of inventory
                    }
                    result = true;
                }
                else if (item.WornOn == Items.Wearable.WIELD_LEFT || item.WornOn == Items.Wearable.WIELD_RIGHT) //this item can go in the free hand
                {
                    Items.Wearable freeHand = Items.Wearable.WIELD_LEFT;                                        //we default to right hand for weapons
                    if (equipped.ContainsKey(freeHand))
                    {
                        freeHand = Items.Wearable.WIELD_RIGHT; //maybe this perosn is left handed
                    }
                    if (!equipped.ContainsKey(freeHand))       //ok let's equip this
                    {
                        item.WornOn = freeHand;
                        item.Save();
                        equipped.Add(freeHand, item);
                        if (inventory.inventory.Any(i => i.Id == item.Id))         //in case we are adding it from a load and not moving it from the inventory
                        {
                            inventory.inventory.RemoveWhere(i => i.Id == item.Id); //we moved the item over to equipped so we need it out of inventory
                        }
                        result = true;
                    }
                }
            }

            return(result);
        }