Esempio n. 1
0
 public List<Awaken> GetAwakens(int awakenedCount = -1)
 {
     if(awakenedCount == -1)
     {
         awakenedCount = awokenSkills.Count();
     }
     List<MonsterCard.Awaken> AwakenCount = new List<MonsterCard.Awaken>();
     awakenedCount = (awakenedCount < awokenSkills.Count()) ? awakenedCount : awokenSkills.Count();
     for (int i = 0; i < awakenedCount; i++)
     {
         MonsterCard.Awaken awaken = awokenSkills[i];
         var awakenIndex = AwakenCount.FindIndex(item => item.Id == awaken.Id);
         if (awakenIndex != -1)
         {
             AwakenCount[awakenIndex] = new MonsterCard.Awaken(awaken.Id, AwakenCount[awakenIndex].Count + 1);
         }
         else
         {
             MonsterCard.Awaken newAwaken = new MonsterCard.Awaken(awaken.Id);
             AwakenCount.Add(newAwaken);
         }
     }
     return AwakenCount;
 }
Esempio n. 2
0
        public void ParseMonsters()
        {
            using (StreamReader file = File.OpenText(MonsterListFile))
            {
                JArray monstersJS = (JArray)JToken.ReadFrom(new JsonTextReader(file));
                foreach (JObject monsterJS in monstersJS.Children())
                {
                    MonsterCard monster = new MonsterCard();
                    IList<string> keys = monsterJS.Properties().Select(p => p.Name).ToList();
                    foreach (string key in keys)
                    {
                        switch (key)
                        {
                            case "id":
                                monster.Id = (int)monsterJS.Property("id").Value;
                                break;
                            case "type":
                                monster.Type = (MonsterType)((int)monsterJS.Property("type").Value);
                                break;
                            case "type2":
                                var type2 = monsterJS["type2"];
                                if(!JsonExtensions.IsNullOrEmpty(type2))
                                {
                                    monster.Type2 = (MonsterType)((int)type2);
                                }
                                break;
                            case "type3":
                                var type3 = monsterJS["type3"];
                                if (!JsonExtensions.IsNullOrEmpty(type3))
                                {
                                    monster.Type3 = (MonsterType)((int)type3);
                                }
                                break;
                            case "team_cost":
                                monster.Cost = (int)monsterJS.Property("team_cost").Value;
                                break;
                            case "element":
                                monster.Element = (MonsterElement)((int)monsterJS.Property("element").Value);
                                break;
                            case "element2":
                                JToken element2 = monsterJS["element2"];
                                if (!JsonExtensions.IsNullOrEmpty(element2))
                                {
                                    monster.Element2 = (MonsterElement)((int)element2);
                                }
                                break;
                            case "image40_size":
                                monster.Image40.Size = (int)monsterJS.Property("image40_size").Value;
                                break;
                            case "image40_href":
                                monster.Image40.HRef = (string)monsterJS.Property("image40_href").Value;
                                break;
                            case "image60_size":
                                monster.Image60.Size = (int)monsterJS.Property("image60_size").Value;
                                break;
                            case "image60_href":
                                monster.Image60.HRef = (string)monsterJS.Property("image60_href").Value;
                                break;
                            case "name":
                                monster.Name = (string)monsterJS.Property("name").Value;
                                break;
                            case "max_level": 
                                monster.LevelMax = (int)monsterJS.Property("max_level").Value;
                                break;
                            case "rarity":
                                monster.Rarity = (int)monsterJS.Property("rarity").Value;
                                break;
                            case "hp_max":
                                monster.MaxHP = (int)monsterJS.Property("hp_max").Value;
                                break;
                            case "hp_min":
                                monster.MinHP = (int)monsterJS.Property("hp_min").Value;
                                break;
                            case "hp_scale":
                                monster.HPScale = (int)monsterJS["hp_scale"];
                                break;
                            case "atk_max":
                                monster.MaxATK = (int)monsterJS["atk_max"];
                                break;
                            case "atk_min":
                                monster.MinATK = (int)monsterJS["atk_min"];
                                break;
                            case "atk_scale":
                                monster.ATKScale = (int)monsterJS["atk_scale"];
                                break;
                            case "rcv_max":
                                monster.MaxRCV = (int)monsterJS["rcv_max"];
                                break;
                            case "rcv_min":
                                monster.MinRCV = (int)monsterJS["rcv_min"];
                                break;
                            case "rcv_scale":
                                monster.RCVScale = (int)monsterJS["rcv_scale"];
                                break;
                            case "xp_curve":
                                monster.XPCurve = (int)monsterJS["xp_curve"];
                                break;
                            case "feed_xp":
                                monster.FeedXP = (int)monsterJS["feed_xp"];
                                break;
                            case "leader_skill":
                                monster.LeaderSkill = (string)monsterJS["leader_skill"];
                                break;
                            case "active_skill":
                                monster.ActiveSkill = (string)monsterJS["active_skill"];
                                break;
                            case "version":
                                monster.Version = (int)monsterJS["version"];
                                break;
                            case "jp_only":
                                if (monsterJS["jp_only"].ToString() == "true") { monster.JpOnly = true; }
                                else monster.JpOnly = false;
                                break;
                            case "name_jp":
                                monster.JpName = monsterJS["name_jp"].ToString();
                                break;
                            case "pdx_id":
                                var pdxID = monsterJS["pdx_id"];
                                if(!JsonExtensions.IsNullOrEmpty(pdxID))
                                {
                                    pdxID = (int)pdxID;
                                }
                                break;
                            case "us_id":
                                var usID = monsterJS["us_id"];
                                if (!JsonExtensions.IsNullOrEmpty(usID))
                                {
                                    pdxID = (int)usID;
                                }
                                break;
                            case "awoken_skills":
                                string[] numbers = System.Text.RegularExpressions.Regex.Split(monsterJS.Property("awoken_skills").Value.ToString(), @"\D+");
                                if (numbers.Length > 0)
                                {
                                    foreach (string value in numbers)
                                    {
                                        if (!string.IsNullOrEmpty(value))
                                        {
                                            int awakenId = int.Parse(value);
                                            MonsterCard.Awaken aw = new MonsterCard.Awaken(awakenId);
                                            monster.AddAwakening(aw);                          
                                        }
                                    }
                                }
                                break;
                            default:
                                Debug.WriteLine(key + " " + monsterJS.Property(key).Value.ToString());
                                break;
                        }

                    }
                    MonsterCards.Add(monster);
                }
            }
        }