Пример #1
0
        private void DropShip(kcsapi_battleresult source)
        {
            if (source.api_get_ship == null)
            {
                return;
            }

            this.DroppedShips.Add(new DroppedShip(source.api_get_ship));
        }
Пример #2
0
        public Modes.BattleResult Append(KanColleClient kanColleClient, kcsapi_battleresult br, bool isFirstBattle)
        {
            var newItem = new Modes.BattleResult(kanColleClient, br)
            {
                IsFirstBattle = isFirstBattle
            };

            return(Append(kanColleClient, newItem));
        }
Пример #3
0
        private void BattleResult(kcsapi_battleresult br)
        {
            if (br.api_get_ship == null)
            {
                return;
            }

            this.Log(LogType.ShipDrop, "{0},{1},{2},{3},{4}", br.api_get_ship.api_ship_name, br.api_quest_name, br.api_enemy_info.api_deck_name, br.api_win_rank, DateTime.Now.ToString("M/d/yyyy H:mm"));
        }
Пример #4
0
        private void BattleResult(kcsapi_battleresult br)
        {
            if (br.api_get_ship == null)
            {
                return;
            }

            Log(LogType.ShipDrop, "{0},{1},{2},{3},{4}", KanColleClient.Current.Translations.GetTranslation(br.api_get_ship.api_ship_name, TranslationType.Ships, br),
                KanColleClient.Current.Translations.GetTranslation(br.api_quest_name, TranslationType.OperationMaps, br),
                KanColleClient.Current.Translations.GetTranslation(br.api_enemy_info.api_deck_name, TranslationType.OperationSortie, br),
                br.api_win_rank, DateTime.Now.ToString("M/d/yyyy H:mm"));
        }
Пример #5
0
        private void AppendBattleResult(kcsapi_battleresult br)
        {
            AMing.Plugins.Core.GenericMessager.Current.SendToLogs(br == null ? string.Empty : br.ToStringContentAndType());

            if (br == null)
            {
                return;
            }

            OnBattleEnd(KanColleClient.Current, br, isFirstBattle);
            isFirstBattle = false;//重置
        }
Пример #6
0
 private void OnBattleEnd(KanColleClient kanColleClient, kcsapi_battleresult br, bool isFirstBattle)
 {
     if (BattleEnd != null)
     {
         BattleEnd(this, new Modes.BattleEndEventArgs
         {
             KanColleClient = kanColleClient,
             BattleResult   = br,
             IsFirstBattle  = isFirstBattle
         });
     }
 }
Пример #7
0
 public BattleResult(kcsapi_battleresult raw)
 {
     Rank       = (Ranking)Enum.Parse(typeof(Ranking), raw.api_win_rank, true);
     AdmiralExp = raw.api_get_exp;
     BaseExp    = raw.api_get_base_exp;
     MapName    = raw.api_quest_name ?? "";
     FleetName  = raw.api_enemy_info?.api_deck_name ?? "";
     MvpId      = raw.api_mvp;
     if (raw.api_get_ship != null)
     {
         DropShip = new ShipNameType(raw.api_get_ship.api_ship_id);
     }
 }
Пример #8
0
        private void BattleResult(kcsapi_battleresult data)
        {
            var arg = new BattleResultEventArgs
            {
                IsFirstCombat = isFirstCombat,
                MapAreaId     = mapId,
                EnemyName     = data.api_enemy_info.api_deck_name,
                EnemyShips    = enemyShips,
                Rank          = data.api_win_rank
            };

            isFirstCombat = false;

            BattleResultEvent?.Invoke(this, arg);
        }
Пример #9
0
        private void BattleResult(kcsapi_battleresult br)
        {
            string ShipName = "";
            string ShipType = "";

            if (br.api_get_ship != null)
            {
                ShipName = KanColleClient.Current.Translations.GetTranslation(br.api_get_ship.api_ship_name, TranslationType.Ships, false, br);
            }
            ShipType = KanColleClient.Current.Translations.GetTranslation(br.api_quest_name, TranslationType.OperationMaps, false, br);

            Log(LogType.ShipDrop, "{0},{1},{2},{3},{4}", DateTime.Now.ToString("yyyy/M/d H:mm"), ShipName, ShipType,
                KanColleClient.Current.Translations.GetTranslation(br.api_enemy_info.api_deck_name, TranslationType.OperationSortie, false, br, -1),
                br.api_win_rank);
        }
Пример #10
0
        private void BattleResult(kcsapi_battleresult br)
        {
            try
            {
                if (br.api_get_ship == null)
                {
                    return;
                }

                Log(br.api_get_ship.api_ship_name,
                    br.api_quest_name,
                    br.api_enemy_info.api_deck_name,
                    br.api_win_rank);
            }
            catch { }
        }
Пример #11
0
        private void BattleResult(kcsapi_battleresult br)
        {
            if (br.api_get_ship == null)
            {
                return;
            }
            var logitem = new ShipDrop
            {
                Result     = KanColleClient.Current.Translations.GetTranslation(br.api_get_ship.api_ship_name, TranslationType.Ships, br),
                Operation  = KanColleClient.Current.Translations.GetTranslation(br.api_quest_name, TranslationType.OperationMaps, br),
                EnemyFleet = KanColleClient.Current.Translations.GetTranslation(br.api_enemy_info.api_deck_name, TranslationType.OperationSortie, br),
                Rank       = br.api_win_rank
            };

            Log(logitem);
        }
Пример #12
0
 private void BattleResult(kcsapi_battleresult br)
 {
     try
     {
         this.Log(LogType.ShipDrop,
                  br.api_get_ship == null ? "N/A" : br.api_get_ship.api_ship_name, //Result
                  br.api_quest_name,                                               //Operation
                  br.api_enemy_info.api_deck_name,                                 //Enemy Fleet
                  br.api_win_rank                                                  //Rank
                  );
     }
     catch (Exception)
     {
         // ignored
     }
 }
Пример #13
0
        private void DropShip(kcsapi_battleresult source)
        {
            if (source.api_get_ship == null)
            {
                return;
            }

            var target = KanColleClient.Current.Master.Ships[source.api_get_ship.api_ship_id];

            if (target == null)
            {
                return;
            }

            this.droppedItemsCount += target.RawData.api_defeq.Count(x => x != -1);
            this.RaisePropertyChanged("SlotItemsCount");
        }
Пример #14
0
        private void BattleResult(kcsapi_battleresult br)
        {
            if (br.api_quest_level != null)
            {
                StorieResult++;
            }
            //MessageBox.Show("api_enemy_info.api_level " + br.api_enemy_info.api_level);
            //MessageBox.Show("api_quest_level " + br.api_quest_level.ToString());
            //if (br.api_get_ship == null)
            //    return;

            //Log(LogType.ShipDrop, "{0},{1},{2},{3},{4}", DateTime.Now.ToString(this.LogTimestampFormat),
            //    br.api_get_ship.api_ship_name,
            //    br.api_quest_name,
            //    br.api_enemy_info.api_deck_name,
            //    br.api_win_rank);
        }
Пример #15
0
        private void BattleResult(kcsapi_battleresult br)
        {
            try
            {
                if (br.api_get_ship == null)
                {
                    return;
                }

                this.Log(LogType.ShipDrop,
                         KanColleClient.Current.Translations.GetTranslation(br.api_get_ship.api_ship_name, TranslationType.Ships, br),             //Result
                         KanColleClient.Current.Translations.GetTranslation(br.api_quest_name, TranslationType.OperationMaps, br),                 //Operation
                         KanColleClient.Current.Translations.GetTranslation(br.api_enemy_info.api_deck_name, TranslationType.OperationSortie, br), //Enemy Fleet
                         br.api_win_rank                                                                                                           //Rank
                         );
            }
            catch (Exception)
            {
                // ignored
            }
        }
Пример #16
0
 private void BattleResult(kcsapi_battleresult br)
 {
     if (br.api_get_ship == null)
     {
         if (HoppoPluginSettings.Current.EnableNullDropLogging)
         {
             Log(LogType.ShipDrop, "{0},{1},{2},{3},{4}", DateTime.Now.ToString(this.LogTimestampFormat),
                 "无掉落",
                 br.api_quest_name,
                 br.api_enemy_info.api_deck_name,
                 br.api_win_rank);
         }
     }
     else
     {
         Log(LogType.ShipDrop, "{0},{1},{2},{3},{4}", DateTime.Now.ToString(this.LogTimestampFormat),
             br.api_get_ship.api_ship_name,
             br.api_quest_name,
             br.api_enemy_info.api_deck_name,
             br.api_win_rank);
     }
 }
Пример #17
0
        private void DropShip(kcsapi_battleresult source)
        {
            try
            {
                if (source.api_get_ship == null)
                {
                    return;
                }

                var target = KanColleClient.Current.Master.Ships[source.api_get_ship.api_ship_id];
                if (target == null)
                {
                    return;
                }

                this.droppedItemsCount += target.RawData.api_defeq.Count(x => x != -1);
                this.RaisePropertyChanged("SlotItemsCount");
            }
            catch (Exception ex)
            {
                // defeq が消えてるっぽい暫定対応 (雑)
                Debug.WriteLine(ex);
            }
        }
Пример #18
0
 private void BattleResult(kcsapi_battleresult br)
 {
     Log("drop,{0},{1},{2},{3}", br.api_get_ship != null ? br.api_get_ship.api_ship_name : "", br.api_quest_name, br.api_enemy_info.api_deck_name, br.api_win_rank);
 }
Пример #19
0
        public void AddTranslation(Object rawData, TranslationType type)
        {
            if (rawData == null || !this.EnableAddUntranslated)
            {
                return;
            }

            try
            {
                switch (type)
                {
                case TranslationType.Ships:
                    if (this.shipsXml == null)
                    {
                        this.shipsXml = new XDocument();
                        this.shipsXml.Add(new XElement("Ships"));
                        // ReSharper disable once PossibleNullReferenceException
                        this.shipsXml.Root.SetAttributeValue("Version", "0.0.0");
                        this.ShipsVersion = "0.0.0";
                    }

                    kcsapi_mst_ship shipData = rawData as kcsapi_mst_ship;

                    if (shipData == null)
                    {
                        return;
                    }

                    // ReSharper disable once PossibleNullReferenceException
                    this.shipsXml.Root.Add(new XElement("Ship",
                                                        new XElement("JP-Name", shipData.api_name),
                                                        new XElement("TR-Name", shipData.api_name)
                                                        ));

                    this.shipsXml.Save("Translations\\Ships.xml");
                    break;

                case TranslationType.ShipTypes:
                    if (this.shipTypesXml == null)
                    {
                        this.shipTypesXml = new XDocument();
                        this.shipTypesXml.Add(new XElement("ShipTypes"));
                        // ReSharper disable once PossibleNullReferenceException
                        this.shipTypesXml.Root.SetAttributeValue("Version", "0.0.0");
                        this.ShipTypesVersion = "0.0.0";
                    }

                    kcsapi_mst_stype typeData = rawData as kcsapi_mst_stype;

                    if (typeData == null)
                    {
                        return;
                    }

                    // ReSharper disable once PossibleNullReferenceException
                    this.shipTypesXml.Root.Add(new XElement("Type",
                                                            new XElement("ID", typeData.api_id),
                                                            new XElement("JP-Name", typeData.api_name),
                                                            new XElement("TR-Name", typeData.api_name)
                                                            ));

                    this.shipTypesXml.Save("Translations\\ShipTypes.xml");
                    break;

                case TranslationType.Equipment:
                    if (this.equipmentXml == null)
                    {
                        this.equipmentXml = new XDocument();
                        this.equipmentXml.Add(new XElement("Equipment"));
                        // ReSharper disable once PossibleNullReferenceException
                        this.equipmentXml.Root.SetAttributeValue("Version", "0.0.0");
                        this.EquipmentVersion = "0.0.0";
                    }

                    kcsapi_mst_slotitem eqiupData = rawData as kcsapi_mst_slotitem;

                    if (eqiupData == null)
                    {
                        return;
                    }

                    // ReSharper disable once PossibleNullReferenceException
                    this.equipmentXml.Root.Add(new XElement("Item",
                                                            new XElement("JP-Name", eqiupData.api_name),
                                                            new XElement("TR-Name", eqiupData.api_name)
                                                            ));

                    this.equipmentXml.Save("Translations\\Equipment.xml");
                    break;

                case TranslationType.OperationMaps:
                case TranslationType.OperationSortie:
                    if (this.operationsXml == null)
                    {
                        this.operationsXml = new XDocument();
                        this.operationsXml.Add(new XElement("Operations"));
                        // ReSharper disable once PossibleNullReferenceException
                        this.operationsXml.Root.SetAttributeValue("Version", "0.0.0");
                        this.OperationsVersion = "0.0.0";
                    }

                    kcsapi_battleresult operationsData = rawData as kcsapi_battleresult;

                    if (operationsData == null)
                    {
                        return;
                    }

                    if (type == TranslationType.OperationMaps)
                    {
                        // ReSharper disable once PossibleNullReferenceException
                        this.operationsXml.Root.Add(new XElement("Map",
                                                                 new XElement("JP-Name", operationsData.api_quest_name),
                                                                 new XElement("TR-Name", operationsData.api_quest_name)
                                                                 ));
                    }
                    else
                    {
                        // ReSharper disable once PossibleNullReferenceException
                        this.operationsXml.Root.Add(new XElement("Sortie",
                                                                 new XElement("JP-Name", operationsData.api_enemy_info.api_deck_name),
                                                                 new XElement("TR-Name", operationsData.api_enemy_info.api_deck_name)
                                                                 ));
                    }

                    this.operationsXml.Save("Translations\\Operations.xml");
                    break;

                case TranslationType.Quests:
                case TranslationType.QuestTitle:
                case TranslationType.QuestDetail:
                    if (this.questsXml == null)
                    {
                        this.questsXml = new XDocument();
                        this.questsXml.Add(new XElement("Quests"));
                        // ReSharper disable once PossibleNullReferenceException
                        this.questsXml.Root.SetAttributeValue("Version", "0.0.0");
                        this.QuestsVersion = "0.0.0";
                    }

                    kcsapi_quest questData = rawData as kcsapi_quest;

                    if (questData == null)
                    {
                        return;
                    }

                    IEnumerable <XElement> foundTranslation = this.questsXml.Descendants("Quest").Where(
                        b => b.Element("ID") != null && b.Element("JP-Name") != null && b.Element("JP-Detail") != null && b.Element("ID").Value.Equals(questData.api_no.ToString())
                        );

                    // ReSharper disable PossibleMultipleEnumeration
                    if (foundTranslation.Any())
                    {
                        foreach (XElement el in foundTranslation)
                        {
                            if (el.Element("JP-Name") == null)
                            {
                                el.Add(new XElement("JP-Name", questData.api_title));
                            }
                            else
                            {
                                el.Element("JP-Name").Value = questData.api_title;
                            }
                            if (el.Element("JP-Detail") == null)
                            {
                                el.Add(new XElement("JP-Detail", questData.api_detail));
                            }
                            else
                            {
                                el.Element("JP-Detail").Value = questData.api_detail;
                            }
                        }
                    }
                    else
                    {
                        int  n;
                        bool needAdd = true;
                        IEnumerable <XElement> foundTranslationDetail = this.questsXml.Descendants("Quest").Where(b => b.Element("JP-Detail").Value.Equals(questData.api_detail));
                        IEnumerable <XElement> foundTranslationTitle  = this.questsXml.Descendants("Quest").Where(b => b.Element("JP-Name").Value.Equals(questData.api_title));

                        // Check the current list for any errors and fix them before writing a whole new element.
                        if (type == TranslationType.QuestTitle && foundTranslationDetail.Any())
                        {
                            // The title is wrong, but the detail is right. Fix the title.
                            foreach (XElement el in foundTranslationDetail)
                            {
                                if (!Int32.TryParse(el.Element("ID").Value, out n))
                                {
                                    if (el.Element("JP-Name") == null)
                                    {
                                        el.Add(new XElement("JP-Name", questData.api_title));
                                    }
                                    else
                                    {
                                        el.Element("JP-Name").Value = questData.api_title;
                                    }
                                    needAdd = false;
                                }
                            }
                        }
                        else if (type == TranslationType.QuestDetail && foundTranslationTitle.Any())
                        {
                            // We found an existing detail, the title must be broken. Fix it.
                            foreach (XElement el in foundTranslationTitle)
                            {
                                if (!Int32.TryParse(el.Element("ID").Value, out n))
                                {
                                    if (el.Element("JP-Detail") == null)
                                    {
                                        el.Add(new XElement("JP-Detail", questData.api_detail));
                                    }
                                    else
                                    {
                                        el.Element("JP-Detail").Value = questData.api_detail;
                                    }
                                    needAdd = false;
                                }
                            }
                        }

                        if (needAdd)
                        {
                            // The quest doesn't exist at all. Add it.
                            // ReSharper disable once PossibleNullReferenceException
                            this.questsXml.Root.Add(new XElement("Quest",
                                                                 new XElement("ID", questData.api_no),
                                                                 new XElement("JP-Name", questData.api_title),
                                                                 new XElement("TR-Name", questData.api_title),
                                                                 new XElement("JP-Detail", questData.api_detail),
                                                                 new XElement("TR-Detail", questData.api_detail)
                                                                 ));
                        }
                    }
                    // ReSharper restore PossibleMultipleEnumeration

                    this.questsXml.Save("Translations\\Quests.xml");
                    break;

                case TranslationType.Expeditions:
                case TranslationType.ExpeditionTitle:
                case TranslationType.ExpeditionDetail:
                    if (this.expeditionsXml == null)
                    {
                        this.expeditionsXml = new XDocument();
                        this.expeditionsXml.Add(new XElement("Expeditions"));
                        // ReSharper disable once PossibleNullReferenceException
                        this.expeditionsXml.Root.SetAttributeValue("Version", "0.0.0");
                        this.ExpeditionsVersion = "0.0.0";
                    }

                    kcsapi_mission expeditionData = rawData as kcsapi_mission;

                    if (expeditionData == null)
                    {
                        return;
                    }

                    IEnumerable <XElement> foundTranslationExpedition = this.expeditionsXml.Descendants("Expedition").Where(b => b.Element("ID").Value.Equals(expeditionData.api_id.ToString()));

                    // Check the current list for any errors and fix them before writing a whole new element.
                    // ReSharper disable PossibleMultipleEnumeration
                    if (foundTranslationExpedition.Any())
                    {
                        foreach (var el in foundTranslationExpedition)
                        {
                            if (el.Element("JP-Name") == null)
                            {
                                el.Add(new XElement("JP-Name", expeditionData.api_name));
                            }
                            else
                            {
                                el.Element("JP-Name").Value = expeditionData.api_name;
                            }
                            if (el.Element("JP-Detail") == null)
                            {
                                el.Add(new XElement("JP-Detail", expeditionData.api_details));
                            }
                            else
                            {
                                el.Element("JP-Detail").Value = expeditionData.api_details;
                            }
                        }
                    }
                    else
                    {
                        // The quest doesn't exist at all. Add it.
                        // ReSharper disable once PossibleNullReferenceException
                        this.expeditionsXml.Root.Add(new XElement("Expedition",
                                                                  new XElement("ID", expeditionData.api_id),
                                                                  new XElement("JP-Name", expeditionData.api_name),
                                                                  new XElement("TR-Name", expeditionData.api_name),
                                                                  new XElement("JP-Detail", expeditionData.api_details),
                                                                  new XElement("TR-Detail", expeditionData.api_details)
                                                                  ));
                    }

                    this.expeditionsXml.Save("Translations\\Expeditions.xml");
                    // ReSharper restore PossibleMultipleEnumeration
                    break;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
Пример #20
0
 public BattleResultEventArgs(TrackerMapInfo MapInfo, TrackerEnemyShip[] enemyShips, kcsapi_battleresult data)
 {
     IsFirstCombat = MapInfo.IsFirstCombat;
     MapAreaId     = MapInfo.MapId;
     EnemyName     = data.api_enemy_info.api_deck_name;
     EnemyShips    = enemyShips;
     Rank          = data.api_win_rank;
 }
Пример #21
0
        public void AddTranslation(Object RawData, TranslationType Type)
        {
            if (RawData == null || !EnableAddUntranslated)
            {
                return;
            }

            try
            {
                switch (Type)
                {
                case TranslationType.Ships:
                    if (ShipsXML == null)
                    {
                        ShipsXML = new XDocument();
                        ShipsXML.Add(new XElement("Ships"));
                    }

                    kcsapi_mst_ship ShipData = RawData as kcsapi_mst_ship;

                    if (ShipData == null)
                    {
                        return;
                    }

                    ShipsXML.Root.Add(new XElement("Ship",
                                                   new XElement("JP-Name", ShipData.api_name),
                                                   new XElement("TR-Name", ShipData.api_name)
                                                   ));

                    ShipsXML.Save(Path.Combine(MainFolder, "Translations", "Ships.xml"));
                    break;

                case TranslationType.ShipTypes:
                    if (ShipTypesXML == null)
                    {
                        ShipTypesXML = new XDocument();
                        ShipTypesXML.Add(new XElement("ShipTypes"));
                    }

                    kcsapi_mst_stype TypeData = RawData as kcsapi_mst_stype;

                    if (TypeData == null)
                    {
                        return;
                    }

                    ShipTypesXML.Root.Add(new XElement("Type",
                                                       new XElement("ID", TypeData.api_id),
                                                       new XElement("JP-Name", TypeData.api_name),
                                                       new XElement("TR-Name", TypeData.api_name)
                                                       ));

                    ShipTypesXML.Save(Path.Combine(MainFolder, "Translations", "ShipTypes.xml"));
                    break;

                case TranslationType.Equipment:
                    if (EquipmentXML == null)
                    {
                        EquipmentXML = new XDocument();
                        EquipmentXML.Add(new XElement("Equipment"));
                    }

                    kcsapi_mst_slotitem EqiupData = RawData as kcsapi_mst_slotitem;

                    if (EqiupData == null)
                    {
                        return;
                    }

                    EquipmentXML.Root.Add(new XElement("Item",
                                                       new XElement("JP-Name", EqiupData.api_name),
                                                       new XElement("TR-Name", EqiupData.api_name)
                                                       ));

                    EquipmentXML.Save(Path.Combine(MainFolder, "Translations", "Equipment.xml"));
                    break;

                case TranslationType.OperationMaps:
                case TranslationType.OperationSortie:
                    if (OperationsXML == null)
                    {
                        OperationsXML = new XDocument();
                        OperationsXML.Add(new XElement("Operations"));
                    }

                    kcsapi_battleresult OperationsData = RawData as kcsapi_battleresult;

                    if (OperationsData == null)
                    {
                        return;
                    }

                    if (Type == TranslationType.OperationMaps)
                    {
                        OperationsXML.Root.Add(new XElement("Map",
                                                            new XElement("JP-Name", OperationsData.api_quest_name),
                                                            new XElement("TR-Name", OperationsData.api_quest_name)
                                                            ));
                    }
                    else
                    {
                        OperationsXML.Root.Add(new XElement("Sortie",
                                                            new XElement("JP-Name", OperationsData.api_enemy_info.api_deck_name),
                                                            new XElement("TR-Name", OperationsData.api_enemy_info.api_deck_name)
                                                            ));
                    }

                    OperationsXML.Save(Path.Combine(MainFolder, "Translations", "Operations.xml"));
                    break;

                case TranslationType.Quests:
                case TranslationType.QuestTitle:
                case TranslationType.QuestDetail:
                    if (QuestsXML == null)
                    {
                        QuestsXML = new XDocument();
                        QuestsXML.Add(new XElement("Quests"));
                    }

                    kcsapi_quest QuestData = RawData as kcsapi_quest;

                    if (QuestData == null)
                    {
                        return;
                    }

                    IEnumerable <XElement> FoundTranslationID = QuestsXML.Descendants("Quest").Where(b => b.Element("ID").Value.Equals(QuestData.api_no));
                    //이 부분에 의심이 가지만 확증은 없음
                    if (Type == TranslationType.QuestTitle || Type == TranslationType.QuestDetail && FoundTranslationID != null && FoundTranslationID.Any())
                    {
                        foreach (XElement el in FoundTranslationID)
                        {
                            el.Element("ID").Value = QuestData.api_no.ToString();
                        }
                    }
                    else
                    {
                        // The quest doesn't exist at all. Add it.
                        QuestsXML.Root.Add(new XElement("Quest",
                                                        new XElement("ID", QuestData.api_no),
                                                        new XElement("JP-Name", QuestData.api_title),
                                                        new XElement("TR-Name", "[" + QuestData.api_no.ToString() + "]" + QuestData.api_title),
                                                        new XElement("JP-Detail", QuestData.api_detail),
                                                        new XElement("TR-Detail", "[" + QuestData.api_no.ToString() + "]" + QuestData.api_detail)
                                                        ));
                    }

                    QuestsXML.Save(Path.Combine(MainFolder, "Translations", "Quests.xml"));
                    break;

                case TranslationType.Expeditions:
                case TranslationType.ExpeditionTitle:
                case TranslationType.ExpeditionDetail:
                    if (ExpeditionXML == null)
                    {
                        ExpeditionXML = new XDocument();
                        ExpeditionXML.Add(new XElement("Expeditions"));
                    }

                    kcsapi_mission MissionData = RawData as kcsapi_mission;

                    if (MissionData == null)
                    {
                        return;
                    }

                    FoundTranslationID = ExpeditionXML.Descendants("Expedition").Where(b => b.Element("ID").Value.Equals(MissionData.api_id));
                    if (Type == TranslationType.ExpeditionTitle || Type == TranslationType.ExpeditionDetail && FoundTranslationID != null && FoundTranslationID.Any())
                    {
                        foreach (XElement el in FoundTranslationID)
                        {
                            el.Element("ID").Value = MissionData.api_id.ToString();
                        }
                    }
                    else
                    {
                        // The quest doesn't exist at all. Add it.
                        ExpeditionXML.Root.Add(new XElement("Expedition",
                                                            new XElement("ID", MissionData.api_id),
                                                            new XElement("JP-Name", MissionData.api_name),
                                                            new XElement("TR-Name", "[" + MissionData.api_id.ToString() + "]" + MissionData.api_name),
                                                            new XElement("JP-Detail", MissionData.api_details),
                                                            new XElement("TR-Detail", "[" + MissionData.api_id.ToString() + "]" + MissionData.api_details)
                                                            ));
                    }

                    ExpeditionXML.Save(Path.Combine(MainFolder, "Translations", "Expeditions.xml"));
                    break;
                }
            }
            catch { }
        }
Пример #22
0
 private void Update(kcsapi_battleresult data)
 {
     _BattleHistory.BattleResult = new BattleResult(data);
     _Repository.Insert(_BattleHistory);
 }
Пример #23
0
        public void AddTranslation(Object RawData, TranslationType Type)
        {
            if (RawData == null || !EnableAddUntranslated)
            {
                return;
            }

            try
            {
                switch (Type)
                {
                case TranslationType.Ships:
                    if (ShipsXML == null)
                    {
                        ShipsXML = new XDocument();
                        ShipsXML.Add(new XElement("Ships"));
                        ShipsXML.Root.SetAttributeValue("Version", "0.0.0");
                        ShipsVersion = "0.0.0";
                    }

                    kcsapi_mst_ship ShipData = RawData as kcsapi_mst_ship;

                    if (ShipData == null)
                    {
                        return;
                    }

                    ShipsXML.Root.Add(new XElement("Ship",
                                                   new XElement("JP-Name", ShipData.api_name),
                                                   new XElement("TR-Name", ShipData.api_name)
                                                   ));

                    ShipsXML.Save("Translations\\" + CurrentCulture + "Ships.xml");
                    break;

                case TranslationType.ShipTypes:
                    if (ShipTypesXML == null)
                    {
                        ShipTypesXML = new XDocument();
                        ShipTypesXML.Add(new XElement("ShipTypes"));
                        ShipTypesXML.Root.SetAttributeValue("Version", "0.0.0");
                        ShipTypesVersion = "0.0.0";
                    }

                    kcsapi_mst_stype TypeData = RawData as kcsapi_mst_stype;

                    if (TypeData == null)
                    {
                        return;
                    }

                    ShipTypesXML.Root.Add(new XElement("Type",
                                                       new XElement("ID", TypeData.api_id),
                                                       new XElement("JP-Name", TypeData.api_name),
                                                       new XElement("TR-Name", TypeData.api_name)
                                                       ));

                    ShipTypesXML.Save("Translations\\" + CurrentCulture + "ShipTypes.xml");
                    break;

                case TranslationType.Equipment:
                    if (EquipmentXML == null)
                    {
                        EquipmentXML = new XDocument();
                        EquipmentXML.Add(new XElement("Equipment"));
                        EquipmentXML.Root.SetAttributeValue("Version", "0.0.0");
                        EquipmentVersion = "0.0.0";
                    }

                    kcsapi_mst_slotitem EqiupData = RawData as kcsapi_mst_slotitem;

                    if (EqiupData == null)
                    {
                        return;
                    }

                    EquipmentXML.Root.Add(new XElement("Item",
                                                       new XElement("JP-Name", EqiupData.api_name),
                                                       new XElement("TR-Name", EqiupData.api_name)
                                                       ));

                    EquipmentXML.Save("Translations\\" + CurrentCulture + "Equipment.xml");
                    break;

                case TranslationType.OperationMaps:
                case TranslationType.OperationSortie:
                    if (OperationsXML == null)
                    {
                        OperationsXML = new XDocument();
                        OperationsXML.Add(new XElement("Operations"));
                        OperationsXML.Root.SetAttributeValue("Version", "0.0.0");
                        OperationsVersion = "0.0.0";
                    }

                    kcsapi_battleresult OperationsData = RawData as kcsapi_battleresult;

                    if (OperationsData == null)
                    {
                        return;
                    }

                    if (Type == TranslationType.OperationMaps)
                    {
                        OperationsXML.Root.Add(new XElement("Map",
                                                            new XElement("JP-Name", OperationsData.api_quest_name),
                                                            new XElement("TR-Name", OperationsData.api_quest_name)
                                                            ));
                    }
                    else
                    {
                        OperationsXML.Root.Add(new XElement("Sortie",
                                                            new XElement("JP-Name", OperationsData.api_enemy_info.api_deck_name),
                                                            new XElement("TR-Name", OperationsData.api_enemy_info.api_deck_name)
                                                            ));
                    }

                    OperationsXML.Save("Translations\\" + CurrentCulture + "Operations.xml");
                    break;

                case TranslationType.Quests:
                case TranslationType.QuestTitle:
                case TranslationType.QuestDetail:
                    if (QuestsXML == null)
                    {
                        QuestsXML = new XDocument();
                        QuestsXML.Add(new XElement("Quests"));
                        QuestsXML.Root.SetAttributeValue("Version", "0.0.0");
                        QuestsVersion = "0.0.0";
                    }

                    kcsapi_quest QuestData = RawData as kcsapi_quest;

                    if (QuestData == null)
                    {
                        return;
                    }

                    IEnumerable <XElement> FoundTranslationDetail = QuestsXML.Descendants("Quest").Where(b => b.Element("JP-Detail").Value.Equals(QuestData.api_detail));
                    IEnumerable <XElement> FoundTranslationTitle  = QuestsXML.Descendants("Quest").Where(b => b.Element("JP-Name").Value.Equals(QuestData.api_title));

                    // Check the current list for any errors and fix them before writing a whole new element.
                    if (Type == TranslationType.QuestTitle && FoundTranslationDetail != null && FoundTranslationDetail.Any())
                    {
                        // The title is wrong, but the detail is right. Fix the title.
                        foreach (XElement el in FoundTranslationDetail)
                        {
                            el.Element("JP-Name").Value = QuestData.api_title;
                        }
                    }
                    else if (Type == TranslationType.QuestDetail && FoundTranslationTitle != null && FoundTranslationTitle.Any())
                    {
                        // We found an existing detail, the title must be broken. Fix it.
                        foreach (XElement el in FoundTranslationTitle)
                        {
                            el.Element("JP-Detail").Value = QuestData.api_detail;
                        }
                    }
                    else
                    {
                        // The quest doesn't exist at all. Add it.
                        QuestsXML.Root.Add(new XElement("Quest",
                                                        new XElement("ID", QuestData.api_no),
                                                        new XElement("JP-Name", QuestData.api_title),
                                                        new XElement("TR-Name", QuestData.api_title),
                                                        new XElement("JP-Detail", QuestData.api_detail),
                                                        new XElement("TR-Detail", QuestData.api_detail)
                                                        ));
                    }

                    QuestsXML.Save("Translations\\" + CurrentCulture + "Quests.xml");
                    break;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
Пример #24
0
		public void UpdateSortieInfo(kcsapi_battleresult data)
		{
			SortieInfo.BattleRank = data.api_win_rank;
		}