Exemplo n.º 1
0
 public NpcGenerator(CharacterCombatModel model, int firstIndex, int lastIndex)
 {
     this.model = model;
     generator  = new NameGenerator();
     firstName  = generator.GenerateFirstName(firstIndex);
     lastName   = generator.GenerateLastName(lastIndex);
 }
        // update character to DB
        public void UpdateCharacter(CharacterCombatModel model)
        {
            var ctx = new ProjectStrawberryEntities();

            var character = ctx.Characters.FirstOrDefault(c => c.Id == model.Id);

            character.Alive  = model.Alive;
            character.Gold   = model.Gold;
            character.Health = model.Health;
            character.Level  = model.Level;

            ctx.SaveChanges();
        }
Exemplo n.º 3
0
        public CharacterCombatModel GenerateMirrorNpc()
        {
            ctx = new ProjectStrawberryEntities();

            npcLevel     = model.Level;
            npcAttribute = 60 + (npcLevel - 1) * 15;
            var mainHandWeaponType = model.MainHand.WeaponType.Name.ToLower();

            if (model.MainHand != null)
            {
                npcAttribute -= model.MainHand.ReqWeaponMastery;
            }

            if (model.OffHand.shld != null)
            {
                vitality = Math.Round(npcAttribute * 0.50);
                strength = Math.Round(npcAttribute * 0.25);
                block    = Math.Round(npcAttribute * 0.25);
            }
            else if (mainHandWeaponType == "axe")
            {
                vitality  = Math.Round(npcAttribute * 0.55);
                strength  = Math.Round(npcAttribute * 0.25);
                quickness = Math.Round(npcAttribute * 0.10);
                evasion   = Math.Round(npcAttribute * 0.05);
                parry     = Math.Round(npcAttribute * 0.05);
                axe       = model.Axe;
            }
            else if (mainHandWeaponType == "dagger")
            {
                vitality = Math.Round(npcAttribute * 0.50);
                strength = Math.Round(npcAttribute * 0.25);
                evasion  = Math.Round(npcAttribute * 0.25);
                dagger   = model.Dagger;
            }
            else if (mainHandWeaponType == "mace")
            {
                vitality = Math.Round(npcAttribute * 0.40);
                strength = Math.Round(npcAttribute * 0.40);
                parry    = Math.Round(npcAttribute * 0.20);
                mace     = model.Mace;
            }
            else if (mainHandWeaponType == "polearm")
            {
                vitality = Math.Round(npcAttribute * 0.50);
                strength = Math.Round(npcAttribute * 0.35);
                evasion  = Math.Round(npcAttribute * 0.15);
                polearm  = model.Polearm;
            }
            else if (mainHandWeaponType == "spear")
            {
                vitality  = Math.Round(npcAttribute * 0.50);
                strength  = Math.Round(npcAttribute * 0.30);
                quickness = Math.Round(npcAttribute * 0.20);
                spear     = model.Spear;
            }
            else if (mainHandWeaponType == "sword")
            {
                vitality = Math.Round(npcAttribute * 0.45);
                strength = Math.Round(npcAttribute * 0.30);
                parry    = Math.Round(npcAttribute * 0.25);
                sword    = model.Sword;
            }
            else
            {
                vitality = Math.Round(npcAttribute * 0.65);
                strength = Math.Round(npcAttribute * 0.35);
            }

            var npc = new CharacterCombatModel()
            {
                Name      = firstName + " " + lastName,
                Vitality  = (int)vitality,
                Axe       = (int)axe,
                Block     = (int)block,
                Dagger    = (int)dagger,
                Evasion   = (int)evasion,
                Health    = (int)vitality,
                Level     = npcLevel,
                Mace      = (int)mace,
                Parry     = (int)parry,
                Polearm   = (int)polearm,
                Quickness = (int)quickness,
                Spear     = (int)spear,
                Stamina   = (int)stamina,
                Strength  = (int)strength,
                Sword     = (int)sword,
            };

            var fist = new WeaponModel()
            {
                MinimumDamage = 0,
                MaximumDamage = 0,
                Name          = "fist",
                TwoHanded     = false,
                WeaponType    = new WeaponTypeModel()
                {
                    Name = "else"
                },
            };

            var skin = new ArmorModel()
            {
                ArmorValue = 0,
                Name       = "skin",
            };

            if (model.MainHand != null)
            {
                npc.MainHand = model.MainHand;
            }
            else
            {
                npc.MainHand = fist;
            }

            if (model.OffHand != null && !model.MainHand.TwoHanded)
            {
                npc.OffHand = model.OffHand;
            }

            npc.Equipment = model.Equipment;
            return(npc);
        }
        // generate model then return
        public CharacterCombatModel ModelizeCharacter(int id)
        {
            var ctx = new ProjectStrawberryEntities();

            var character = ctx.Characters.FirstOrDefault(c => c.Id == id);

            var modelCharacter = new CharacterCombatModel();

            modelCharacter.Alive      = character.Alive;
            modelCharacter.Axe        = character.Axe;
            modelCharacter.Block      = character.Block;
            modelCharacter.Dagger     = character.Dagger;
            modelCharacter.Evasion    = character.Evasion;
            modelCharacter.Experience = character.Experience;
            modelCharacter.Gold       = character.Gold;
            modelCharacter.Health     = character.Health;
            modelCharacter.Id         = character.Id;
            modelCharacter.Mace       = character.Mace;
            modelCharacter.Name       = character.Name;
            modelCharacter.Parry      = character.Parry;
            modelCharacter.Polearm    = character.Polearm;
            modelCharacter.Quickness  = character.Quickness;
            modelCharacter.Spear      = character.Spear;
            modelCharacter.Stamina    = character.Stamina;
            modelCharacter.Strength   = character.Strength;
            modelCharacter.Sword      = character.Sword;
            modelCharacter.Vitality   = character.Vitality;
            modelCharacter.OffHand    = new OffHandModel()
            {
                shld = null, wep = null
            };

            List <ArmorModel> equipment = new List <ArmorModel>();

            foreach (var e in character.EquipmentCharacters)
            {
                if (e.Armor != null)
                {
                    if (e.Equipped)
                    {
                        equipment.Add(new ArmorModel
                        {
                            Name           = e.Armor.Name,
                            ArmorValue     = e.Armor.ArmorValue,
                            ArmorTypeId    = e.Armor.ArmorTypeId,
                            ModelArmorType = new ArmorTypeModel()
                            {
                                Name = e.Armor.ArmorType.Name
                            },
                        });
                    }
                }
                else if (e.Shield != null)
                {
                    if (e.OffHandEquipped)
                    {
                        modelCharacter.OffHand.shld = new ShieldModel
                        {
                            BlockValue       = e.Shield.BlockValue,
                            Name             = e.Shield.Name,
                            ReqShieldMastery = e.Shield.ReqShieldMastery,
                        };
                    }
                }
                else if (e.Weapon != null)
                {
                    if (e.MainHandEquipped)
                    {
                        modelCharacter.MainHand = new WeaponModel
                        {
                            MinimumDamage = e.Weapon.MinimumDamage,
                            MaximumDamage = e.Weapon.MaximumDamage,
                            Name          = e.Weapon.Name,
                            WeaponType    = new WeaponTypeModel {
                                Id = e.Weapon.WeaponType.Id, Name = e.Weapon.WeaponType.Name
                            },
                            ReqWeaponMastery = e.Weapon.ReqWeaponMastery,
                            TwoHanded        = e.Weapon.TwoHanded,
                        };
                    }
                    else if (e.OffHandEquipped)
                    {
                        modelCharacter.OffHand.wep = new WeaponModel
                        {
                            MinimumDamage = e.Weapon.MinimumDamage,
                            MaximumDamage = e.Weapon.MaximumDamage,
                            Name          = e.Weapon.Name,
                            WeaponType    = new WeaponTypeModel {
                                Id = e.Weapon.WeaponType.Id, Name = e.Weapon.WeaponType.Name
                            },
                            ReqWeaponMastery = e.Weapon.ReqWeaponMastery,
                            TwoHanded        = e.Weapon.TwoHanded,
                        };
                    }
                }
            }

            modelCharacter.Equipment = equipment;


            return(modelCharacter);
        }