示例#1
0
        public GrimoireAbility(GrimoireLine line)
        {
            this.System = line.System;
            this.Job    = line.Job;
            this.Name   = line.Name;
            switch (this.System)
            {
            case "Class":
                //too complicated
                this.SlotCost = ResolveClassSlotCosts(line.Job, line.APOrSlotCost, line.Keywords);
                break;

            case "Job":
                if (line.APOrSlotCost <= 100)
                {
                    this.SlotCost = 2;
                }
                else if (line.APOrSlotCost < 150)
                {
                    this.SlotCost = 3;
                }
                else
                {
                    //150 or more AP
                    this.SlotCost = 4;
                }
                break;

            case "Crystal":
                if (line.APOrSlotCost < 4)
                {
                    this.SlotCost = 2;
                }
                else if (line.APOrSlotCost == 4)
                {
                    this.SlotCost = 3;
                }
                else
                {
                    //5 or more slots
                    this.SlotCost = 4;
                }
                break;
            }
            try
            {
                this.AbilityType = (AbilityType)Enum.Parse(typeof(AbilityType), line.Type);
            }
            catch
            {
                this.AbilityType = AbilityType.Support;
            }
            this.Delay     = line.Delay;
            this.Floor     = line.Floor;
            this.MP        = line.MP;
            this.MPPerTier = line.MPPerTier;
            this.CT        = line.CT;
            this.CoS       = line.CoS;
            try
            {
                this.Target = (TargetType)Enum.Parse(typeof(TargetType), line.Target);
            }
            catch
            {
                this.Target = TargetType.Null;
            }
            this.AttackType = AttackType.Null;
            if (line.Stat == "ATK")
            {
                this.AttackType = AttackType.Physical;
            }
            if (line.Stat == "MAG")
            {
                this.AttackType = AttackType.Magical;
            }
            if (this.AttackType == AttackType.Null)
            {
                if (line.Keywords.Contains("Magic"))
                {
                    this.AttackType = AttackType.MagicalEffect;
                }
                else if (line.Keywords.Contains("Technique"))
                {
                    this.AttackType = AttackType.PhysicalEffect;
                }
            }
            this.Power        = line.Power;
            this.PowerPerTier = line.PowerPerTier;
            this.Dice         = line.Dice;
            this.DicePerTier  = line.DicePerTier;
            string buildDieType = "d" + line.DieType.ToString();

            try
            {
                this.DieType = (DieType)Enum.Parse(typeof(DieType), buildDieType);
            }
            catch
            {
                this.DieType = DieType.Null;
            }
            this.Multiplier = line.Multiplier;
            this.Notes      = line.Notes;
            List <String> keywordsBroken = line.Keywords.Split(',').ToList <String>();
            Regex         rgx            = new Regex("[^a-zA-Z:]");

            this.Element = Element.Null;
            foreach (String key in keywordsBroken)
            {
                //do preprocessing to mung Elemental, Status, and Effect keywords
                String toAdd = rgx.Replace(key, "");
                if (key.Contains("Elemental"))
                {
                    //split at colon, element will be in split[1]
                    string[] parts = key.Split(':');
                    toAdd = "Elemental";
                    try
                    {
                        this.Element = (Element)Enum.Parse(typeof(Element), parts[1]);
                    }
                    catch
                    {
                        this.Element = Element.Null;
                    }
                }
                if (key.Contains("Status") || key.Contains("Effect"))
                {
                    toAdd = "StatusEffect";
                }
                if (key.Contains("Enhancement"))
                {
                    toAdd = "Enhancement";
                }
                try
                {
                    this.Keywords.Add((Keyword)Enum.Parse(typeof(Keyword), toAdd));
                }
                catch
                {
                    //couldn't recognise the keyword, do nothing.
                    Console.WriteLine("Could not recognise keyword " + toAdd);
                }
            }
        }
 public GrimoireAbility(GrimoireLine line)
 {
     this.System = line.System;
     this.Job = line.Job;
     this.Name = line.Name;
     switch (this.System)
     {
         case "Class":
             //too complicated
             this.SlotCost = ResolveClassSlotCosts(line.Job, line.APOrSlotCost, line.Keywords);
             break;
         case "Job":
             if (line.APOrSlotCost <= 100)
             {
                 this.SlotCost = 2;
             }
             else if (line.APOrSlotCost < 150)
             {
                 this.SlotCost = 3;
             }
             else
             {
                 //150 or more AP
                 this.SlotCost = 4;
             }
             break;
         case "Crystal":
             if (line.APOrSlotCost < 4)
             {
                 this.SlotCost = 2;
             }
             else if (line.APOrSlotCost == 4)
             {
                 this.SlotCost = 3;
             }
             else
             {
                 //5 or more slots
                 this.SlotCost = 4;
             }
             break;
     }
     try
     {
         this.AbilityType = (AbilityType)Enum.Parse(typeof(AbilityType), line.Type);
     }
     catch
     {
         this.AbilityType = AbilityType.Support;
     }
     this.Delay = line.Delay;
     this.Floor = line.Floor;
     this.MP = line.MP;
     this.MPPerTier = line.MPPerTier;
     this.CT = line.CT;
     this.CoS = line.CoS;
     try
     {
         this.Target = (TargetType)Enum.Parse(typeof(TargetType), line.Target);
     }
     catch
     {
         this.Target = TargetType.Null;
     }
     this.AttackType = AttackType.Null;
     if (line.Stat == "ATK") this.AttackType = AttackType.Physical;
     if (line.Stat == "MAG") this.AttackType = AttackType.Magical;
     if (this.AttackType == AttackType.Null)
     {
         if (line.Keywords.Contains("Magic"))
         {
             this.AttackType = AttackType.MagicalEffect;
         }
         else if(line.Keywords.Contains("Technique"))
         {
             this.AttackType = AttackType.PhysicalEffect;
         }
     }
     this.Power = line.Power;
     this.PowerPerTier = line.PowerPerTier;
     this.Dice = line.Dice;
     this.DicePerTier = line.DicePerTier;
     string buildDieType = "d" + line.DieType.ToString();
     try
     {
         this.DieType = (DieType)Enum.Parse(typeof(DieType), buildDieType);
     }
     catch
     {
         this.DieType = DieType.Null;
     }
     this.Multiplier = line.Multiplier;
     this.Notes = line.Notes;
     List<String> keywordsBroken = line.Keywords.Split(',').ToList<String>();
     Regex rgx = new Regex("[^a-zA-Z:]");
     this.Element = Element.Null;
     foreach (String key in keywordsBroken)
     {
         //do preprocessing to mung Elemental, Status, and Effect keywords
         String toAdd = rgx.Replace(key, "");
         if (key.Contains("Elemental"))
         {
             //split at colon, element will be in split[1]
             string[] parts = key.Split(':');
             toAdd = "Elemental";
             try
             {
                 this.Element = (Element)Enum.Parse(typeof(Element), parts[1]);
             }
             catch
             {
                 this.Element = Element.Null;
             }
         }
         if (key.Contains("Status") || key.Contains("Effect"))
         {
             toAdd = "StatusEffect";
         }
         if (key.Contains("Enhancement"))
         {
             toAdd = "Enhancement";
         }
         try
         {
             this.Keywords.Add((Keyword)Enum.Parse(typeof(Keyword), toAdd));
         }
         catch
         {
             //couldn't recognise the keyword, do nothing.
             Console.WriteLine("Could not recognise keyword " + toAdd);
         }
     }
 }