Ejemplo n.º 1
0
        public bool SpellSuccess(Player origin, Player target, Skill.Model.Skill spell)
        {
            var spellSkill = origin.Skills.FirstOrDefault(x => x.SkillId.Equals(spell.Id));

            if (spellSkill == null)
            {
                // TODO: log error, we should never get here.
                return(false);
            }

            var spellProficiency = spellSkill.Proficiency;
            var success          = spell.Damage.Roll(1, 1,
                                                     101);

            if (success == 1 || success == 101)
            {
                _writer.WriteLine($"<p>You got distracted.</p>", origin.ConnectionId);
                return(false);
            }

            if (spellProficiency < success)
            {
                _writer.WriteLine($"<p>You lost concentration.</p>", origin.ConnectionId);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public Skill.Model.Skill Identify()
        {
            var skill = new Skill.Model.Skill()
            {
                Name        = "Identify",
                Description =
                    "Tells you the stats of a particular item that identify is cast upon.",
                ApplyLevelCheck = true,
                SavingThrow     = new SavingThrow(),
                Rounds          = 1,
                Cost            = new SkillCost()
                {
                    Table = new Dictionary <Cost, int>()
                    {
                        { Cost.Mana, 25 }
                    }
                },
                Type         = SkillType.Passive,
                StartsCombat = false,
                ValidTargets = ValidTargets.TargetObjectInventory | ValidTargets.TargetObjectEquipped,
                Damage       = new Dice()
                {
                },
                UsableFromStatus = CharacterStatus.Status.Standing
            };

            return(skill);
        }
Ejemplo n.º 3
0
        public Skill.Model.Skill CureWounds()
        {
            var magicMissile = new Skill.Model.Skill()
            {
                Name        = "Cure light wounds",
                Description =
                    "You channel positive energy that cures 1d8 + 1 per caster level",
                ApplyLevelCheck = true,
                SavingThrow     = new SavingThrow(),
                Rounds          = 1,
                Cost            = new SkillCost()
                {
                    Table = new Dictionary <Cost, int>()
                    {
                        { Cost.Mana, 25 }
                    }
                },
                Type         = SkillType.Affect,
                StartsCombat = false,
                ValidTargets = ValidTargets.TargetPlayerRoom | ValidTargets.TargetFightSelf,
                Damage       = new Dice()
                {
                    DiceMaxSize = 8,
                    DiceMinSize = 1,
                    DiceRoll    = 1
                },
                UsableFromStatus = CharacterStatus.Status.Standing | CharacterStatus.Status.Fighting
            };

            return(magicMissile);
        }
Ejemplo n.º 4
0
        public Skill.Model.Skill Bless()
        {
            var skill = new Skill.Model.Skill()
            {
                Name        = "Bless",
                Description =
                    "Blesses the target increases dam and hit chance",
                ApplyLevelCheck = true,
                SavingThrow     = new SavingThrow(),
                Rounds          = 1,
                Cost            = new SkillCost()
                {
                    Table = new Dictionary <Cost, int>()
                    {
                        { Cost.Mana, 25 }
                    }
                },
                Type         = SkillType.Affect,
                StartsCombat = false,
                ValidTargets = ValidTargets.TargetPlayerRoom,
                Damage       = new Dice()
                {
                },
                UsableFromStatus = CharacterStatus.Status.Standing | CharacterStatus.Status.Fighting
            };

            return(skill);
        }
Ejemplo n.º 5
0
        public Skill.Model.Skill MagicMissile()
        {
            var magicMissile = new Skill.Model.Skill()
            {
                Name        = "Magic Missile",
                Description =
                    "Fires a magical dart towards your target dealing 1d4+1 damage.",
                ApplyLevelCheck = true,
                SavingThrow     = new SavingThrow(),
                Rounds          = 1,
                Cost            = new SkillCost()
                {
                    Table = new Dictionary <Cost, int>()
                    {
                        { Cost.Mana, 25 }
                    }
                },
                Type         = SkillType.Damage,
                StartsCombat = true,
                ValidTargets = ValidTargets.TargetPlayerRoom | ValidTargets.TargetFightVictim,
                Damage       = new Dice()
                {
                    DiceMaxSize = 4,
                    DiceMinSize = 1,
                    DiceRoll    = 1
                },
                UsableFromStatus = CharacterStatus.Status.Standing | CharacterStatus.Status.Fighting
            };

            return(magicMissile);
        }
Ejemplo n.º 6
0
        public Skill.Model.Skill Armour()
        {
            var skill = new Skill.Model.Skill()
            {
                Name        = "Armour",
                Description =
                    "Baths the target in a protective white light",
                ApplyLevelCheck = true,
                SavingThrow     = new SavingThrow(),
                Rounds          = 1,
                Cost            = new SkillCost()
                {
                    Table = new Dictionary <Cost, int>()
                    {
                        { Cost.Mana, 25 }
                    }
                },
                Type         = SkillType.Affect,
                StartsCombat = false,
                ValidTargets = ValidTargets.TargetPlayerRoom | ValidTargets.TargetFightSelf,
                Damage       = new Dice()
                {
                },
                UsableFromStatus = CharacterStatus.Status.Standing | CharacterStatus.Status.Fighting
            };

            return(skill);
        }
Ejemplo n.º 7
0
        public Player CheckTarget(Skill.Model.Skill spell, string target, Room room, Player player)
        {
            if (string.IsNullOrEmpty(target) || target.Equals(spell.Name, StringComparison.CurrentCultureIgnoreCase))
            {
                return(null);
            }

            var victim = string.IsNullOrEmpty(target) ? player : GetTarget(target, room);

            if (victim == null)
            {
                _writer.WriteLine(
                    (spell.ValidTargets & ValidTargets.TargetPlayerWorld) != 0
                        ? "You can't find them in the realm."
                        : "You don't see them here.", player.ConnectionId);

                return(null);
            }

            //if (spell.StartsCombat && victim.Id == player.Id)
            //{
            //    _writer.WriteLine("Casting this on yourself is a bad idea.", player.ConnectionId);
            //    return null;
            //}

            return(victim);
        }
Ejemplo n.º 8
0
        public void ReciteSpellCharacter(Player origin, Player target, Skill.Model.Skill spell, Room room)
        {
            // not correct need to send to room
            if (origin.Id == target.Id)
            {
                _writer.WriteLine(
                    $"You close your eyes and utter the words, '{spell.Name}'.", origin.ConnectionId);

                foreach (var pc in room.Players)
                {
                    if (pc.ConnectionId.Equals(origin.ConnectionId))
                    {
                        continue;
                    }
                    _writer.WriteLine($"{origin.Name} closes {Helpers.GetPronoun(origin.Gender)} eyes and utters the words, '{ObsfucateSpellName(spell.Name)}'.", pc.ConnectionId);
                }
            }
            else if (origin != target)
            {
                var obsfucatedSpellName = ObsfucateSpellName(spell.Name);


                _writer.WriteLine($"You look at {target.Name} and utter the words, '{spell.Name}'.", origin.ConnectionId);
                _writer.WriteLine($"{origin.Name} looks at you and utters the words, '{(!Helpers.isCaster(target.ClassName) ? obsfucatedSpellName : spell.Name)}'.", target.ConnectionId);
                foreach (var pc in room.Players)
                {
                    if (pc.ConnectionId.Equals(origin.ConnectionId) ||
                        pc.ConnectionId.Equals(target.ConnectionId))
                    {
                        continue;
                    }
                    _writer.WriteLine($"{origin.Name} looks at {target.Name} and utters the words, '{(!Helpers.isCaster(pc.ClassName) ? obsfucatedSpellName : spell.Name)}'.", pc.ConnectionId);
                }
            }
        }
Ejemplo n.º 9
0
 public bool SpellAffectsCharacter(Skill.Model.Skill spell)
 {
     return((spell.ValidTargets & ValidTargets.TargetPlayerWorld) != 0 ||
            (spell.ValidTargets & ValidTargets.TargetFightVictim) != 0 ||
            (spell.ValidTargets & ValidTargets.TargetSelfOnly) != 0 ||
            (spell.ValidTargets & ValidTargets.TargetPlayerRoom) != 0 ||
            (spell.ValidTargets & ValidTargets.TargetFightSelf) != 0);
 }
        public Player ReturnTarget(Skill.Model.Skill spell, string target, Room room, Player player)
        {
            if ((spell.ValidTargets & ValidTargets.TargetSelfOnly) != 0)
            {
                if (string.IsNullOrEmpty(target) || target == "self")
                {
                    return(player);
                }

                _writer.WriteLine("You can only this spell on yourself", player.ConnectionId);
                return(null);
            }

            //If no argument, target is the PC/NPC the player is fighting
            if (player.Status == CharacterStatus.Status.Fighting && (spell.ValidTargets & ValidTargets.TargetFightVictim) != 0)
            {
                if (string.IsNullOrEmpty(target))
                {
                    return(CheckTarget(spell, player.Target, room, player));
                }
            }
            // casting spell on PC/NPC in room
            // example spells, magic missile, minor wounds
            if ((spell.ValidTargets & ValidTargets.TargetPlayerRoom) != 0)
            {
                return(CheckTarget(spell, target, room, player));
            }

            // casting spell on PC/NPC in the world
            // example spells, gate, summon, portal
            if ((spell.ValidTargets & ValidTargets.TargetPlayerWorld) != 0)
            {
                return(CheckTarget(spell, target, room, player));
            }


            // casting spell on PC/NPC in the world
            // example spells, gate, summon, portal
            if ((spell.ValidTargets & ValidTargets.TargetObjectInventory) != 0 || (spell.ValidTargets & ValidTargets.TargetObjectEquipped) != 0)
            {
                //find victim from player cache instead
                var item = player.Inventory.FirstOrDefault(x =>
                                                           x.Name.StartsWith(target, StringComparison.CurrentCultureIgnoreCase));

                if (item == null)
                {
                    //target not found
                    return(null);
                }


                //  return item;
            }


            return(player);
        }
Ejemplo n.º 11
0
        public bool ManaCheck(Skill.Model.Skill spell, Player player)
        {
            if (player.Attributes.Attribute[EffectLocation.Mana] < spell.Cost.Table[Cost.Mana])
            {
                _writer.WriteLine("You don't have enough mana.", player.ConnectionId);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 12
0
 public void ReciteSpellCharacter(Player origin, Player target, Skill.Model.Skill spell)
 {
     // not correct need to send to room
     if (origin.Id == target.Id)
     {
         _writer.WriteLine(
             $"{origin.Name} closes {Helpers.GetPronoun(origin.Gender)} eyes and utters the words, '{spell.Name}'.");
     }
     else if (origin != target)
     {
         _writer.WriteLine($"{origin.Name} stares at {target.Name} and utters the words, '{spell.Name}'.");
     }
 }
Ejemplo n.º 13
0
        public Player ReturnTarget(Skill.Model.Skill spell, string target, Room room, Player player)
        {
            if ((spell.ValidTargets & ValidTargets.TargetSelfOnly) != 0)
            {
                if (string.IsNullOrEmpty(target) || target == "self")
                {
                    return(player);
                }

                _writer.WriteLine("You can only cast this spell on yourself", player.ConnectionId);
                return(null);
            }


            if (player.Status != CharacterStatus.Status.Fighting && (spell.ValidTargets & ValidTargets.TargetFightVictim) != 0)
            {
                if (!string.IsNullOrEmpty(target) || target.Equals(spell.Name, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(CheckTarget(spell, target, room, player));
                }
            }

            //If no argument, target is the PC/NPC the player is fighting
            if (player.Status == CharacterStatus.Status.Fighting && (spell.ValidTargets & ValidTargets.TargetFightVictim) != 0)
            {
                if (string.IsNullOrEmpty(target) || target.Equals(spell.Name, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(CheckTarget(spell, player.Target, room, player));
                }
            }
            // casting spell on PC/NPC in room
            // example spells, magic missile, minor wounds
            if ((spell.ValidTargets & ValidTargets.TargetPlayerRoom) != 0)
            {
                return(CheckTarget(spell, target, room, player));
            }

            // casting spell on PC/NPC in the world
            // example spells, gate, summon, portal
            if ((spell.ValidTargets & ValidTargets.TargetPlayerWorld) != 0)
            {
                return(CheckTarget(spell, target, room, player));
            }

            return(player);
        }
Ejemplo n.º 14
0
        public Item.Item ReturnTargetItem(Skill.Model.Skill spell, string target, Room room, Player player)
        {
            if ((spell.ValidTargets & ValidTargets.TargetObjectInventory) != 0 || (spell.ValidTargets & ValidTargets.TargetObjectEquipped) != 0)
            {
                //find victim from player cache instead
                var item = player.Inventory.FirstOrDefault(x =>
                                                           x.Name.Contains(target, StringComparison.CurrentCultureIgnoreCase));

                if (item == null)
                {
                    //target not found
                    return(null);
                }


                return(item);
            }


            return(null);
        }
        public Player CheckTarget(Skill.Model.Skill spell, string target, Room room, Player player)
        {
            var victim = GetTarget(target, room);

            if (victim == null)
            {
                _writer.WriteLine(
                    (spell.ValidTargets & ValidTargets.TargetPlayerWorld) != 0
                        ? "You can't find them in the realm."
                        : "You don't see them here.", player.ConnectionId);

                return(null);
            }

            if (spell.StartsCombat && victim.Id == player.Id)
            {
                _writer.WriteLine("Casting this on yourself is a bad idea.", player.ConnectionId);
                return(null);
            }

            return(victim);
        }
Ejemplo n.º 16
0
        public SpellTests()
        {
            _Spells = new Spell.Model.Spell()
            {
                Name   = "Ogre strength",
                Effect = new Effect.Effect()
                {
                    Modifier = new EffectModifier()
                    {
                        Value          = 10,
                        PositiveEffect = true
                    },
                    Location = EffectLocation.Strength,
                    Name     = "OgreStrength",
                    Duration = new EffectModifier()
                    {
                        Value          = 10,
                        PositiveEffect = true,
                    },
                    Accumulate = true,
                    Id         = 1
                },
                Damage = new Dice()
                {
                    DiceRoll    = 1,
                    DiceMinSize = 10,
                    DiceMaxSize = 10
                },
                Description = "Makes you strong as an ogre",
                Rounds      = 1,
                SpellGroup  = new Sphere()
            };
            _player = new Player()
            {
                Name       = "Malleus",
                ClassName  = "Paladin",
                Status     = CharacterStatus.Status.Standing,
                Attributes = new Attributes()
                {
                    Attribute = new Dictionary <EffectLocation, int>
                    {
                        { EffectLocation.Mana, 250 },
                        { EffectLocation.Strength, 0 }
                    }
                },
                Spells = new List <Spell.Model.Spell>(),
                Skills = new List <SkillList>()
            };

            _player.Spells.Add(new Spell.Model.Spell()
            {
                Name = "chill touch",
                Cost = new SkillCost()
                {
                    Table = new Dictionary <Cost, int>
                    {
                        { Cost.Mana, 10 }
                    }
                }
            });
            _target = new Player()
            {
                Attributes = new Attributes()
                {
                    Attribute = new Dictionary <EffectLocation, int>
                    {
                        { EffectLocation.Strength, 0 },
                        { EffectLocation.Hitpoints, 2500 },
                    }
                }
            };
            _room   = new Room();
            _writer = new Mock <IWriteToClient>();
            _damage = new Mock <IDamage>();
            _spellTargetCharacter = new Mock <ISpellTargetCharacter>();
            _cache          = new Mock <ICache>();
            _updateClientUI = new Mock <IUpdateClientUI>();
            _mobScript      = new Mock <IMobScripts>();
            _spell          = new Spells(_writer.Object, _spellTargetCharacter.Object, _cache.Object, _damage.Object, _updateClientUI.Object, _mobScript.Object);

            var newSkill = new Skill.Model.Skill
            {
                Name = "magic missile",
                Id   = 1,
            };
        }
Ejemplo n.º 17
0
 public bool AddSkill(int id, Skill.Model.Skill skill)
 {
     return(_skillCache.TryAdd(id, skill));
 }
Ejemplo n.º 18
0
 public bool AffectsSelf(Skill.Model.Skill spell)
 {
     return
         ((spell.ValidTargets & ValidTargets.TargetSelfOnly) != 0 ||
          (spell.ValidTargets & ValidTargets.TargetFightSelf) != 0);
 }