Beispiel #1
0
 private void ExecuteEditActor(object actorObj)
 {
     if (actorObj is Model.Actor)
     {
         CreateActorWindowViewModel createActorWindowViewModel = new CreateActorWindowViewModel();
         if (actorObj is Model.PlayerActor)
         {
             createActorWindowViewModel.LoadPlayerActor(actorObj as Model.PlayerActor);
             Model.PlayerActor playerActor = createActorWindowViewModel.GetPlayerActor();
             if (playerActor != null)
             {
                 ActorLibrary.EditActor(actorObj as Model.PlayerActor, playerActor);
                 Encounter.UpdateActor(actorObj as Model.PlayerActor);
             }
         }
         else if (actorObj is Model.Creature)
         {
             createActorWindowViewModel.LoadCreature(actorObj as Model.Creature);
             Model.Creature creature = createActorWindowViewModel.GetCreature();
             if (creature != null)
             {
                 ActorLibrary.EditActor(actorObj as Model.Creature, creature);
             }
         }
     }
 }
Beispiel #2
0
 private void Catch(Model.Creature creature)
 {
     if (creature == Leader)
     {
         gsApi.MoveTo(Leader.IsMoving ? Leader.Destination : Leader.Position);
     }
 }
Beispiel #3
0
        private void ExecuteCreateCreature()
        {
            CreateActorWindowViewModel createActorWindowViewModel = new CreateActorWindowViewModel();

            Model.Creature creature = createActorWindowViewModel.GetCreature();
            if (creature != null)
            {
                ActorLibrary.AddActor(creature);
            }
        }
Beispiel #4
0
        private void ExecuteOpenImportWindow()
        {
            ImportStatBlockWindowViewModel importVM = new ImportStatBlockWindowViewModel();

            Model.Creature creature = importVM.GetCreature();
            if (creature != null)
            {
                LoadCreature(creature);
            }
        }
Beispiel #5
0
 public void Bind(Model.Creature creature)
 {
     Leader = creature;
     Queue.Enqueue(creature.Position);
     if (creature.Position != creature.Destination)
     {
         Last = creature.Destination;
     }
     Next();
 }
Beispiel #6
0
        public void ApplyFilter(object sender, FilterEventArgs e)
        {
            Model.Creature enemy = (Model.Creature)e.Item;

            if (String.IsNullOrWhiteSpace(EnemyFilter) || EnemyFilter.Length == 0)
            {
                e.Accepted = true;
            }
            else
            {
                e.Accepted = enemy.ActorName.Contains(EnemyFilter, StringComparison.OrdinalIgnoreCase);
            }
        }
Beispiel #7
0
 public double Distance(Model.Creature creature)         // ToDo IPosition : Library.Point? Position
 {
     if (creature == this)
     {
         return(0);
     }
     else if (creature != null)
     {
         return((new Library.Interval(Position, creature.Position)).Length);
     }
     else
     {
         throw new ArgumentNullException();
     }
 }
Beispiel #8
0
        private void OnAttack(Model.Creature creature)
        {
            if (!Memory.Attackers.Contains(creature))
            {
                Memory.Attackers.Add(creature);                 // Todo LastAttackTime & AttackersTimer::OnElapsed => Attackers.remove(a.lastAttackTime > n & Nature.aggro...)
                // Todo clear damage
            }

            /*if(Attackers.Select(a => a.Danger).Sum() > current_danger_limit)
             *      escape();
             * else
             *      // Если уже сражаемся и AP умный, то не меняем цель (может если цель слабая то переключаемся на неё?)
             *      // Иначе входим в режим сражения*/
            // Todo Кеширование результатов анализа с удалением по времени и ручным удалением при некой кондиции (например при связанном событии)
        }
Beispiel #9
0
 private void OnAttack(Model.Creature creature)
 {
     lock (Sync)
     {
         EventQueue.Enqueue(() =>
         {
             if (Attack != null)
             {
                 Attack(creature);
             }
         });
         Wake(new Result.Attack()
         {
             Creature = creature
         });
     }
 }
Beispiel #10
0
 private void OnSkillCanceled(Model.Creature creature)
 {
     lock (Sync)
     {
         EventQueue.Enqueue(() =>
         {
             if (SkillCanceled != null)
             {
                 SkillCanceled(creature);
             }
         });
         Wake(new Result.SkillCanceled()
         {
             Creature = creature
         });
     }
 }
Beispiel #11
0
 private void OnCreatureUpdate(Model.Creature creature)
 {
     lock (Sync)
     {
         EventQueue.Enqueue(() =>
         {
             if (CreatureUpdate != null)
             {
                 CreatureUpdate(creature);
             }
         });
         Wake(new Result.CreatureUpdated()
         {
             Creature = creature
         });
     }
 }
Beispiel #12
0
 private void OnFinishMoving(Model.Creature creature)
 {
     lock (Sync)
     {
         EventQueue.Enqueue(() =>
         {
             if (FinishMoving != null)
             {
                 FinishMoving(creature);
             }
         });
         Wake(new Result.FinishMoving()
         {
             Creature = creature
         });
     }
 }
Beispiel #13
0
 private void OnTargetChanged(Model.Creature creature, Model.Creature target)
 {
     lock (Sync)
     {
         EventQueue.Enqueue(() =>
         {
             if (TargetChanged != null)
             {
                 TargetChanged(creature, target);
             }
         });
         Wake(new Result.TargetChanged()
         {
             Creature = creature,
             Target   = target
         });
     }
 }
Beispiel #14
0
 private void OnDie(Model.Creature creature, Lineage.ReturnPoint?points = null)
 {
     lock (Sync)
     {
         EventQueue.Enqueue(() =>
         {
             if (Die != null)
             {
                 Die(creature, points);
             }
         });
         Wake(new Result.Die()
         {
             Creature = creature,
             Points   = points
         });
     }
 }
Beispiel #15
0
        public static Model.Creature ParseMM4Text(string text)
        {
            Model.CreatureAttributes attributes = new Model.CreatureAttributes();

            if (text != "")
            {
                string[] lines       = text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
                string   currentLine = "";
                try
                {
                    for (int l = 0; l < lines.Count(); ++l)
                    {
                        currentLine = lines[l];

                        // Parse one-line data types
                        ParseChallengeRating(attributes, currentLine);
                        ParseSaves(attributes, currentLine);
                        ParseBaseAttackAndGrapple(attributes, currentLine);
                        ParseSpaceAndReach(attributes, currentLine);
                        ParseAbilities(attributes, currentLine);
                        ParseResistances(attributes, currentLine);
                        ParseSpellResistance(attributes, currentLine);
                        ParseImmunities(attributes, currentLine);
                        ParseSpeed(attributes, currentLine);
                        ParseArmorClass(attributes, currentLine);
                        ParseAlignmentSizeAndType(attributes, currentLine);
                        ParseInitiative(attributes, currentLine);
                        ParseHitPoints(attributes, currentLine);
                        ParseFeats(attributes, currentLine);
                        ParseAttacks(attributes, currentLine);
                    }
                }
                catch (FormatException e)
                {
                    MessageBox.Show("Cannot parse:\n" + currentLine);
                    throw e;
                }
            }

            Model.Creature creature = new Model.Creature(attributes);

            return(creature);
        }
        public Model.Creature GetCreature()
        {
            bool   askForInput = true;
            string feedback    = null;

            Model.Creature creature = null;
            while (askForInput)
            {
                View.ImportStatBlockWindow importStatBlockWindow = new View.ImportStatBlockWindow(feedback);
                importStatBlockWindow.DataContext = this;

                if (importStatBlockWindow.ShowDialog() == true)
                {
                    try
                    {
                        if (ImportFormat == ImportFormat.SRD)
                        {
                            creature    = StatBlockImporter.ParseSRDText(StatBlockText);
                            askForInput = false;
                        }
                        else if (ImportFormat == ImportFormat.MM4)
                        {
                            creature    = StatBlockImporter.ParseMM4Text(StatBlockText);
                            askForInput = false;
                        }
                    }
                    catch (FormatException)
                    {
                        feedback = "Invalid format";
                    }
                }
                else
                {
                    askForInput = false;
                }
            }

            return(creature);
        }
Beispiel #17
0
 public void LoadCreature(Model.Creature creature)
 {
     ActorName            = creature.ActorName;
     InitiativeMod        = Methods.GetSignedNumberString(creature.InitiativeMod);
     SelectedCreatureType = CreatureTypes.IndexOf(Methods.GetCreatureTypeString(creature.Type));
     ChallengeRating      = creature.ChallengeRating.ToString();
     AttackSets           = creature.AttackSets;
     Strength             = creature.Strength.ToString();
     Dexterity            = creature.Dexterity.ToString();
     Constitution         = creature.Constitution.ToString();
     Intelligence         = creature.Intelligence.ToString();
     Wisdom               = creature.Wisdom.ToString();
     Charisma             = creature.Charisma.ToString();
     BaseAttackBonus      = Methods.GetSignedNumberString(creature.BaseAttackBonus);
     GrappleModifier      = Methods.GetSignedNumberString(creature.GrappleModifier);
     HitPoints            = creature.HitPoints.ToString();
     HitDice              = creature.HitDice.ToString();
     SelectedHitDie       = DieTypes.IndexOf(Methods.GetDieTypeString(creature.HitDieType));
     ArmorClass           = creature.ArmorClass.ToString();
     TouchArmorClass      = creature.TouchArmorClass.ToString();
     FlatFootedArmorClass = creature.FlatFootedArmorClass.ToString();
     Speeds               = creature.Speed;
     Space             = creature.Space.ToString();
     Reach             = creature.Reach.ToString();
     FortitudeSave     = Methods.GetSignedNumberString(creature.FortitudeSave);
     ReflexSave        = Methods.GetSignedNumberString(creature.ReflexSave);
     WillSave          = Methods.GetSignedNumberString(creature.WillSave);
     Feats             = creature.Feats;
     SelectedSize      = Sizes.IndexOf(Methods.GetSizeString(creature.Size));
     DamageReductions  = creature.DamageReductions;
     Immunities        = creature.Immunities;
     EnergyResistances = creature.EnergyResistances;
     SpellResistance   = creature.SpellResistance.ToString();
     FastHealing       = creature.FastHealing.ToString();
     SpecialAttacks    = creature.SpecialAttacks;
     SpecialQualities  = creature.SpecialQualities;
 }
Beispiel #18
0
 public CreatureInitiativeViewModel(Model.Creature creature, EncounterViewModel encounterViewModel)
 {
     _actor = creature.Clone();
     InitWeaponList(encounterViewModel);
     InitCommands();
 }
Beispiel #19
0
        // Todo: OnCreatureInfo => Memory.AddNpc|AddPlayer

        private void OnChatMessage(Lineage.Channel channel, string message, string from, Model.Creature author)
        {
            // Todo: Speech
        }
Beispiel #20
0
 public void Bind(Model.Creature creature)
 {
     this.Leader = creature;
     Catch(creature);
 }
Beispiel #21
0
        public static Model.Creature ParseSRDText(string text)
        {
            Model.CreatureAttributes attributes = new Model.CreatureAttributes();

            if (text != null && text != "")
            {
                string[] lines       = text.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
                string   currentLine = "";
                try
                {
                    foreach (string line in lines)
                    {
                        currentLine = line;
                        if (currentLine != "")
                        {
                            string[] splitLine = line.Split(':');
                            if (splitLine.Length != 2)
                            {
                                throw new FormatException();
                            }
                            else
                            {
                                string     identifier = splitLine[0];
                                string     entry      = splitLine[1];
                                List <int> numbers    = GetNumbersFromString(entry);
                                string[]   words      = splitLine[1].Split((char[])null, StringSplitOptions.RemoveEmptyEntries);

                                if (identifier == "Size/Type")
                                {
                                    attributes.Size = Methods.GetSizeFromString(words[0]);
                                    string typeStr = string.Join(" ", words.Skip(1));

                                    string typePattern = @"\s*(?<Type>\w+)\s*(\((?<SubTypes>\D+)\))?";
                                    Regex  typeRegex   = new Regex(typePattern, RegexOptions.IgnoreCase);
                                    Match  typeMatch   = typeRegex.Match(typeStr);

                                    if (typeMatch.Success)
                                    {
                                        attributes.Type = Methods.GetCreatureTypeFromString(typeMatch.Groups["Type"].Value);

                                        /*
                                         * if (typeMatch.Groups.Count > 1)
                                         * {
                                         *      string subTypes = typeMatch.Groups["SubTypes"].Value;
                                         *
                                         *      string subTypePattern = @"\s*(?<Type>\w+)\s*(\((?<SubTypes>\D+)\))?";
                                         *      Regex subTypeRegex = new Regex(subTypePattern, RegexOptions.IgnoreCase);
                                         *      Match subTypeMatch = subTypeRegex.Match(entry);
                                         *
                                         *      if (subTypeMatch.Success)
                                         *      {
                                         *              attributes.Subtypes = Methods.GetCreatureSubTypeFromString();
                                         *      }
                                         * }
                                         */
                                    }
                                }
                                else if (identifier == "Hit Dice")
                                {
                                    string hpPattern = @"\s?(?<NumHD>\d+)(?<HDType>[dD]\d+)\s?(?<HDMod>[\+\-]\d+)?\s?\((?<HP>\d+)\s?hp\)";
                                    Regex  hpRegex   = new Regex(hpPattern, RegexOptions.IgnoreCase);
                                    Match  hpMatch   = hpRegex.Match(entry);

                                    if (hpMatch.Success)
                                    {
                                        attributes.HitDice    = Convert.ToInt32(hpMatch.Groups["NumHD"].Value);
                                        attributes.HitDieType = Methods.GetDieTypeFromString(hpMatch.Groups["HDType"].Value);
                                        attributes.HitPoints  = Convert.ToInt32(hpMatch.Groups["HP"].Value);
                                    }
                                }
                                else if (identifier == "Initiative")
                                {
                                    attributes.InitiativeMod = numbers[0];
                                }
                                else if (identifier == "Speed")
                                {
                                    char[] commaChar = { ',' };

                                    foreach (string speedStr in entry.Split(commaChar, StringSplitOptions.RemoveEmptyEntries))
                                    {
                                        string speedPattern = @"\s?(?<Type>\D*)\s(?<Speed>\d+)\s*ft.\s*(\((?<Manouverability>\w+)\))?";
                                        Regex  speedRegex   = new Regex(speedPattern, RegexOptions.IgnoreCase);
                                        Match  speedMatch   = speedRegex.Match(speedStr);

                                        if (speedMatch.Success)
                                        {
                                            Types.Manouverability manouverability = Types.Manouverability.None;
                                            if (speedMatch.Groups["Manouverability"].Success)
                                            {
                                                manouverability = Methods.GetManouverabilityFromString(speedMatch.Groups["Manouverability"].Value);
                                            }
                                            int    distance       = Convert.ToInt32(speedMatch.Groups["Speed"].Value);
                                            string movementString = speedMatch.Groups["Type"].Value.Trim();
                                            if (movementString.Equals(""))
                                            {
                                                attributes.Speed.LandSpeed = distance;
                                            }
                                            else
                                            {
                                                Types.Movement movementType = Methods.GetMovementTypeFromString(movementString);
                                                attributes.Speed.Speeds.Add(new Model.Speed(distance, movementType, manouverability));
                                            }
                                        }
                                    }
                                }
                                else if (identifier == "Armor Class")
                                {
                                    string acPattern = @"(?<AC>\d+)\s\(.*\),\s*touch\s*(?<TouchAC>\d+),\s*flat\-footed\s*(?<FFAC>\d+)";
                                    Regex  acRegex   = new Regex(acPattern, RegexOptions.IgnoreCase);
                                    Match  acMatch   = acRegex.Match(entry);

                                    if (acMatch.Success)
                                    {
                                        attributes.ArmorClass           = Convert.ToInt32(acMatch.Groups["AC"].Value);
                                        attributes.TouchArmorClass      = Convert.ToInt32(acMatch.Groups["TouchAC"].Value);
                                        attributes.FlatFootedArmorClass = Convert.ToInt32(acMatch.Groups["FFAC"].Value);
                                    }
                                }
                                else if (identifier == "Base Attack/Grapple")
                                {
                                    attributes.BaseAttackBonus = numbers[0];
                                    attributes.GrappleModifier = numbers[1];
                                }
                                else if (identifier == "Attack" || identifier == "Full Attack")
                                {
                                    string[] orStr = { "or" };
                                    foreach (string attackSetStr in entry.Split(orStr, StringSplitOptions.RemoveEmptyEntries))
                                    {
                                        Model.AttackSet attackSet = new Model.AttackSet
                                        {
                                            Name = identifier,
                                        };

                                        string          attackPattern = @"(?<NumAttacks>\d+)?\s?(?<Name>(?!and\b)\b\D+)\s(?<AttackMod>[\+\-]\d+)\s(?<Type>\D+\s?\D*)\s\((?<Damage>[^\(]*)\)";
                                        Regex           attackRegex   = new Regex(attackPattern, RegexOptions.IgnoreCase);
                                        MatchCollection attackMatches = attackRegex.Matches(attackSetStr);
                                        foreach (Match attackMatch in attackMatches)
                                        {
                                            int    numAttacks = 1;
                                            string name       = attackMatch.Groups["Name"].Value;
                                            if (attackMatch.Groups["NumAttacks"].Value != "")
                                            {
                                                numAttacks = Convert.ToInt32(attackMatch.Groups["NumAttacks"].Value);
                                                PluralizationService ps = PluralizationService.CreateService(CultureInfo.GetCultureInfo("en-us"));
                                                name = ps.Singularize(name);
                                            }

                                            name = char.ToUpper(name[0]) + name.Substring(1);

                                            for (int i = 0; i < numAttacks; ++i)
                                            {
                                                Model.Attack attack = new Model.Attack();

                                                attack.Name     = name;
                                                attack.Modifier = Convert.ToInt32(attackMatch.Groups["AttackMod"].Value);
                                                attack.Type     = Methods.GetAttackTypeFromString(attackMatch.Groups["Type"].Value);

                                                string          damageStr     = attackMatch.Groups["Damage"].Value;
                                                string          damagePattern = @"(?<NumDice>\d+)(?<Die>d\d+)(?<DamageMod>[\+\-]?\d*)\s?(?<DamageType>(?!plus\b)\b\w+)?";
                                                Regex           damageRegex   = new Regex(damagePattern, RegexOptions.IgnoreCase);
                                                MatchCollection damageMatches = damageRegex.Matches(damageStr);

                                                foreach (Match damageMatch in damageMatches)
                                                {
                                                    Model.Damage damage = new Model.Damage();
                                                    damage.NumDice = Convert.ToInt32(damageMatch.Groups["NumDice"].Value);
                                                    damage.Die     = Methods.GetDieTypeFromString(damageMatch.Groups["Die"].Value);
                                                    if (damageMatch.Groups["DamageMod"].Value != "")
                                                    {
                                                        damage.Modifier = Convert.ToInt32(damageMatch.Groups["DamageMod"].Value);
                                                    }
                                                    if (damageMatch.Groups["DamageType"].Value != "")
                                                    {
                                                        damage.DamageDescriptorSet.Add(Methods.GetDamageTypeFromString(damageMatch.Groups["DamageType"].Value));
                                                    }
                                                    attack.Damages.Add(damage);
                                                }

                                                attackSet.Attacks.Add(attack);
                                            }
                                        }

                                        attributes.AttackSets.Add(attackSet);
                                    }
                                }
                                else if (identifier == "Space/Reach")
                                {
                                    attributes.Space = numbers[0];
                                    attributes.Reach = numbers[1];
                                }
                                else if (identifier == "Special Attacks")
                                {
                                    attributes.SpecialAttacks = entry.Trim();
                                }
                                else if (identifier == "Special Qualities")
                                {
                                    foreach (string specialQuality in entry.Split(','))
                                    {
                                        attributes.SpecialQualities.Add(specialQuality.Trim());
                                    }

                                    string          drPattern = @"damage reduction (?<Value>\d+)\/(?<Types>.+?)(\,|\z)";
                                    Regex           drRegex   = new Regex(drPattern, RegexOptions.IgnoreCase);
                                    MatchCollection drMatches = drRegex.Matches(entry);

                                    foreach (Match drMatch in drMatches)
                                    {
                                        Model.DamageReduction dr = new Model.DamageReduction();
                                        dr.Value       = Convert.ToInt32(drMatch.Groups["Value"].Value);
                                        dr.DamageTypes = GetDamageDescriptorSetFromString(drMatch.Groups["Types"].Value, "and");
                                        attributes.DamageReductions.Add(dr);
                                    }

                                    string          immunityPattern = @"immunity to (?<Types>.+?)(\,|\z)";
                                    Regex           immunityRegex   = new Regex(immunityPattern, RegexOptions.IgnoreCase);
                                    MatchCollection immunityMatches = immunityRegex.Matches(entry);

                                    foreach (Match immunityMatch in immunityMatches)
                                    {
                                        Model.DamageDescriptorSet damageTypes = GetDamageDescriptorSetFromString(immunityMatch.Groups["Types"].Value, "and");
                                        foreach (Types.Damage damageType in damageTypes.ToList())
                                        {
                                            if (damageType != Types.Damage.Magic)                                             // Immunity to magic does not mean immunity to magic weapons
                                            {
                                                attributes.Immunities.Add(damageType);
                                            }
                                        }
                                    }

                                    string resistancesPattern = @"resistance to (?<Types>.+?)(\,|\z)";
                                    Regex  resistancesRegex   = new Regex(resistancesPattern, RegexOptions.IgnoreCase);
                                    Match  resistancesMatch   = resistancesRegex.Match(entry);

                                    if (resistancesMatch.Success)
                                    {
                                        string          resistancePattern = @"(?<Type>[a-z]+)\s(?<Value>\d+)";
                                        Regex           resistanceRegex   = new Regex(resistancePattern, RegexOptions.IgnoreCase);
                                        MatchCollection resistanceMatches = resistanceRegex.Matches(resistancesMatch.Groups["Types"].Value);

                                        foreach (Match resistanceMatch in resistanceMatches)
                                        {
                                            Model.EnergyResistance res = new Model.EnergyResistance();
                                            res.Value      = Convert.ToInt32(resistanceMatch.Groups["Value"].Value);
                                            res.EnergyType = Methods.GetDamageTypeFromString(resistanceMatch.Groups["Type"].Value);
                                            attributes.EnergyResistances.Add(res);
                                        }
                                    }

                                    string spellResistancePattern = @"spell resistance (?<Value>\d+)(\,|\z)";
                                    Regex  spellResistanceRegex   = new Regex(spellResistancePattern, RegexOptions.IgnoreCase);
                                    Match  spellResistanceMatch   = spellResistanceRegex.Match(entry);

                                    if (spellResistanceMatch.Success)
                                    {
                                        attributes.SpellResistance = Convert.ToInt32(spellResistanceMatch.Groups["Value"].Value);
                                    }

                                    string regenerationPattern = @"regeneration (?<Value>\d+)(\,|\z)";
                                    Regex  regenerationRegex   = new Regex(regenerationPattern, RegexOptions.IgnoreCase);
                                    Match  regenerationMatch   = regenerationRegex.Match(entry);

                                    if (regenerationMatch.Success)
                                    {
                                        attributes.FastHealing = Convert.ToInt32(regenerationMatch.Groups["Value"].Value);
                                    }

                                    string fastHealingPattern = @"fast healing (?<Value>\d+)(\,|\z)";
                                    Regex  fastHealingRegex   = new Regex(fastHealingPattern, RegexOptions.IgnoreCase);
                                    Match  fastHealingMatch   = fastHealingRegex.Match(entry);

                                    if (fastHealingMatch.Success)
                                    {
                                        attributes.FastHealing = Convert.ToInt32(fastHealingMatch.Groups["Value"].Value);
                                    }
                                }
                                else if (identifier == "Saves")
                                {
                                    attributes.FortitudeSave = numbers[0];
                                    attributes.ReflexSave    = numbers[1];
                                    attributes.WillSave      = numbers[2];
                                }
                                else if (identifier == "Abilities")
                                {
                                    string attributePattern = @"Str\s(?<Value>\w+)";
                                    Regex  attributeRegex   = new Regex(attributePattern, RegexOptions.IgnoreCase);
                                    Match  attributeMatch   = attributeRegex.Match(entry);

                                    if (attributeMatch.Success)
                                    {
                                        try
                                        {
                                            attributes.Strength = Convert.ToInt32(attributeMatch.Groups["Value"].Value);
                                        }
                                        catch (FormatException)
                                        {
                                            attributes.Strength = 0;
                                        }
                                    }

                                    attributePattern = @"Dex\s(?<Value>\w+)";
                                    attributeRegex   = new Regex(attributePattern, RegexOptions.IgnoreCase);
                                    attributeMatch   = attributeRegex.Match(entry);

                                    if (attributeMatch.Success)
                                    {
                                        try
                                        {
                                            attributes.Dexterity = Convert.ToInt32(attributeMatch.Groups["Value"].Value);
                                        }
                                        catch (FormatException)
                                        {
                                            attributes.Dexterity = 0;
                                        }
                                    }

                                    attributePattern = @"Con\s(?<Value>\w+)";
                                    attributeRegex   = new Regex(attributePattern, RegexOptions.IgnoreCase);
                                    attributeMatch   = attributeRegex.Match(entry);

                                    if (attributeMatch.Success)
                                    {
                                        try
                                        {
                                            attributes.Constitution = Convert.ToInt32(attributeMatch.Groups["Value"].Value);
                                        }
                                        catch (FormatException)
                                        {
                                            attributes.Constitution = 0;
                                        }
                                    }

                                    attributePattern = @"Int\s(?<Value>\w+)";
                                    attributeRegex   = new Regex(attributePattern, RegexOptions.IgnoreCase);
                                    attributeMatch   = attributeRegex.Match(entry);

                                    if (attributeMatch.Success)
                                    {
                                        try
                                        {
                                            attributes.Intelligence = Convert.ToInt32(attributeMatch.Groups["Value"].Value);
                                        }
                                        catch (FormatException)
                                        {
                                            attributes.Intelligence = 0;
                                        }
                                    }

                                    attributePattern = @"Wis\s(?<Value>\w+)";
                                    attributeRegex   = new Regex(attributePattern, RegexOptions.IgnoreCase);
                                    attributeMatch   = attributeRegex.Match(entry);

                                    if (attributeMatch.Success)
                                    {
                                        try
                                        {
                                            attributes.Wisdom = Convert.ToInt32(attributeMatch.Groups["Value"].Value);
                                        }
                                        catch (FormatException)
                                        {
                                            attributes.Wisdom = 0;
                                        }
                                    }

                                    attributePattern = @"Cha\s(?<Value>\w+)";
                                    attributeRegex   = new Regex(attributePattern, RegexOptions.IgnoreCase);
                                    attributeMatch   = attributeRegex.Match(entry);

                                    if (attributeMatch.Success)
                                    {
                                        try
                                        {
                                            attributes.Charisma = Convert.ToInt32(attributeMatch.Groups["Value"].Value);
                                        }
                                        catch (FormatException)
                                        {
                                            attributes.Charisma = 0;
                                        }
                                    }
                                }
                                else if (identifier == "Feats")
                                {
                                    foreach (string feat in entry.Split(','))
                                    {
                                        attributes.Feats.Add(feat.Trim());
                                    }

                                    if (attributes.WeaponFinesse)
                                    {
                                        foreach (Model.AttackSet attackSet in attributes.AttackSets)
                                        {
                                            foreach (Model.Attack attack in attackSet.Attacks)
                                            {
                                                attack.Ability = Types.Ability.Dexterity;
                                            }
                                        }
                                    }
                                }
                                else if (identifier == "Challenge Rating")
                                {
                                    if (numbers.Count == 2)
                                    {
                                        attributes.ChallengeRating = numbers[0] / numbers[1];
                                    }
                                    else if (numbers.Count == 1)
                                    {
                                        attributes.ChallengeRating = numbers[0];
                                    }
                                    else
                                    {
                                        attributes.ChallengeRating = 1;
                                    }
                                }
                            }
                        }
                    }
                }
                catch (FormatException e)
                {
                    MessageBox.Show("Cannot parse:\n" + currentLine);
                    throw e;
                }
            }

            Model.Creature creature = new Model.Creature(attributes);

            return(creature);
        }
Beispiel #22
0
 private void OnChatMessage(Lineage.Channel channel, string message, string name, Model.Creature author = null)
 {
     lock (Sync)
     {
         EventQueue.Enqueue(() =>
         {
             if (ChatMessage != null)
             {
                 ChatMessage(channel, message, name, author);
             }
         });
         Wake(new Result.ChatMessage()
         {
             Channel = channel,
             Message = message,
             Name    = name,
             Author  = author,
         });
     }
 }
Beispiel #23
0
 public Base(string command, string args, Model.Creature author, Server.Game.Api gsApi)         // ?
 {
     throw new NotImplementedException();
 }
Beispiel #24
0
        public Model.Creature GetCreature()
        {
            bool   askForInput = true;
            string feedback    = null;

            Model.Creature creature = null;
            while (askForInput)
            {
                View.CreateCreatureWindow createCreatureWindow = new View.CreateCreatureWindow(feedback);
                createCreatureWindow.DataContext = this;
                if (createCreatureWindow.ShowDialog() == true)
                {
                    try
                    {
                        Model.CreatureAttributes creatureAttributes = new Model.CreatureAttributes
                        {
                            InitiativeMod        = Convert.ToInt32(InitiativeMod),
                            Type                 = Methods.GetCreatureTypeFromString(CreatureTypes.ElementAt(SelectedCreatureType)),
                            ChallengeRating      = Convert.ToSingle(ChallengeRating),
                            AttackSets           = AttackSets,
                            Strength             = Convert.ToInt32(Strength),
                            Dexterity            = Convert.ToInt32(Dexterity),
                            Constitution         = Convert.ToInt32(Constitution),
                            Intelligence         = Convert.ToInt32(Intelligence),
                            Wisdom               = Convert.ToInt32(Wisdom),
                            Charisma             = Convert.ToInt32(Charisma),
                            BaseAttackBonus      = Convert.ToInt32(BaseAttackBonus),
                            GrappleModifier      = Convert.ToInt32(GrappleModifier),
                            HitPoints            = Convert.ToInt32(HitPoints),
                            HitDice              = Convert.ToInt32(HitDice),
                            HitDieType           = Methods.GetDieTypeFromString(DieTypes.ElementAt(SelectedHitDie)),
                            ArmorClass           = Convert.ToInt32(ArmorClass),
                            TouchArmorClass      = Convert.ToInt32(TouchArmorClass),
                            FlatFootedArmorClass = Convert.ToInt32(FlatFootedArmorClass),
                            Speed                = Speeds,
                            Space                = Convert.ToInt32(Space),
                            Reach                = Convert.ToInt32(Reach),
                            FortitudeSave        = Convert.ToInt32(FortitudeSave),
                            ReflexSave           = Convert.ToInt32(ReflexSave),
                            WillSave             = Convert.ToInt32(WillSave),
                            Feats                = Feats,
                            Size                 = Methods.GetSizeFromString(Sizes.ElementAt(SelectedSize)),
                            DamageReductions     = DamageReductions,
                            Immunities           = Immunities,
                            EnergyResistances    = EnergyResistances,
                            SpellResistance      = Convert.ToInt32(SpellResistance),
                            FastHealing          = Convert.ToInt32(FastHealing),
                            SpecialAttacks       = SpecialAttacks,
                            SpecialQualities     = SpecialQualities,
                        };
                        creature = new Model.Creature(creatureAttributes)
                        {
                            ActorName = ActorName,
                        };
                        askForInput = false;
                    }
                    catch (FormatException)
                    {
                        feedback = "Invalid format";
                    }
                }
                else
                {
                    askForInput = false;
                }
            }

            return(creature);
        }
Beispiel #25
0
 public override void ReadActorXML(XmlNode xmlNode)
 {
     Model.Creature creature = new Model.Creature(xmlNode);
     Actor = creature;
 }