Beispiel #1
0
        private void OnMapNext(string apiname, dynamic data)
        {
            EasyLogOut.Write("Plugin:OnMapNext");
            Codeplex.Data.DynamicJson json = data;
            //EasyLogOut.Write(data);
            EasyLogOut.Write(json);
            try
            {
                JObject root = JObject.Parse(json.ToString());
                var     next = root;
                if (m_lastStart != null)
                {
                    m_lastStart.Merge(next); //合并点数据

                    int bossId = (int)root.SelectToken(".api_bosscell_no")?.Value <int>();
                    m_battleBossIdList.Add(bossId);
                    //EasyLogOut.Write("合并Next完成");
                    //EasyLogOut.Write(m_lastStart.ToString(Formatting.Indented));
                }
            }
            catch (System.Exception ex)
            {
                EasyLogOut.Write(ex);
            }
        }
Beispiel #2
0
        public void AddData(BattleListCell battleListCell)
        {
            SQLiteCommand cmd = new SQLiteCommand();

            cmd.Connection  = m_sqliteConnection;
            cmd.CommandText = "INSERT INTO battlelist(Time,MapName,MapPointId,IsBoss,MapPointName,NewShipName,WinRank,DeckName,FullBattleData) " +
                              "VALUES(@Time,@MapName,@MapPointId,@IsBoss,@MapPointName,@NewShipName,@WinRank,@DeckName,@FullBattleData)";
            cmd.Parameters.Add("Time", DbType.DateTime).Value         = battleListCell.Time;
            cmd.Parameters.Add("MapName", DbType.String).Value        = battleListCell.MapName;
            cmd.Parameters.Add("MapPointId", DbType.Int32).Value      = battleListCell.MapPointId;
            cmd.Parameters.Add("IsBoss", DbType.Boolean).Value        = battleListCell.IsBoos;
            cmd.Parameters.Add("MapPointName", DbType.String).Value   = battleListCell.MapPointName;
            cmd.Parameters.Add("NewShipName", DbType.String).Value    = battleListCell.NewShipName;
            cmd.Parameters.Add("WinRank", DbType.String).Value        = battleListCell.WinRank;
            cmd.Parameters.Add("DeckName", DbType.String).Value       = battleListCell.DeckName;
            cmd.Parameters.Add("FullBattleData", DbType.String).Value = battleListCell.FullBattleData;


            try
            {
                cmd.ExecuteNonQuery();
            }
            catch (System.Exception ex)
            {
                EasyLogOut.Write(ex);
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            this.Title = "BattleList " + "1.0.0.3";


            EasyLogOut.Write("BattleListMainWindow:Start");
            LoadData();
        }
Beispiel #4
0
        public override Form GetToolWindow()
        {
            EasyLogOut.Write("Plugin:GetToolWindow调用");

            if (Directory.Exists(MAINEXE_PATH) == false)
            {
                Process.Start(MAINEXE_PATH);
            }

            return(null);
        }
Beispiel #5
0
        public void LoadData()
        {
            EasyLogOut.Write("Plugin:LoadData...");


            EasyLogOut.Write("Plugin:LoadData:LoadFromJson");
            m_battleList = new ArrayList();
            if (File.Exists(JSON_PATH_LIST))
            {
                m_battleList = JsonConvert.DeserializeObject <ArrayList>(File.ReadAllText(JSON_PATH_LIST));
            }
        }
Beispiel #6
0
        public Plugin()
        {
            EasyLogOut.Write("Plugin:加载中...");

            if (Directory.Exists(JSON_PATH) == false)
            {
                Directory.CreateDirectory(JSON_PATH);
            }

            if (Directory.Exists(@".\x64") == false)
            {
                Directory.CreateDirectory(@".\x64");
            }
            if (Directory.Exists(@".\x86") == false)
            {
                Directory.CreateDirectory(@".\x86");
            }

            if (Directory.Exists(@".\Plugins\x64") == false)
            {
                Directory.CreateDirectory(@".\Plugins\x64");
            }

            if (Directory.Exists(@".\Plugins\x86") == false)
            {
                Directory.CreateDirectory(@".\Plugins\x86");
            }

            EasyLogOut.Write("Plugin:释放SQLite.Interop.dll");

            if (File.Exists(@".\x86\SQLite.Interop.dll") == false)
            {
                File.WriteAllBytes(@".\x86\SQLite.Interop.dll", Properties.Resources.SQLite_x86_Interop);
            }
            if (File.Exists(@".\x64\SQLite.Interop.dll") == false)
            {
                File.WriteAllBytes(@".\x64\SQLite.Interop.dll", Properties.Resources.SQLite_x64_Interop);
            }

            EasyLogOut.Write("Plugin:释放Plugins目录的SQLite.Interop.dll");
            if (File.Exists(@".\Plugins\x86\SQLite.Interop.dll") == false)
            {
                File.WriteAllBytes(@".\Plugins\x86\SQLite.Interop.dll", Properties.Resources.SQLite_x86_Interop);
            }
            if (File.Exists(@".\Plugins\x64\SQLite.Interop.dll") == false)
            {
                File.WriteAllBytes(@".\Plugins\x64\SQLite.Interop.dll", Properties.Resources.SQLite_x64_Interop);
            }

            Task.Factory.StartNew(() => BattleList.Instance.Initialize(this));
        }
 private void buttonUpdate_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (VersionUpdate.m_updateCheckJson?.Property("url") != null)
         {
             Process.Start(VersionUpdate.m_updateCheckJson["url"].ToString());
         }
     }
     catch (System.Exception ex)
     {
         EasyLogOut.Write(ex, LogLevel.Error);
     }
 }
Beispiel #8
0
 private void OnCombinedBattleResult(string apiname, dynamic data)
 {
     EasyLogOut.Write("Plugin:OnCombinedBattleResult");
     Codeplex.Data.DynamicJson json = data;
     //EasyLogOut.Write(data);
     try
     {
         JObject root = JObject.Parse(json.ToString());
         SaveBattleResult(root);
     }
     catch (System.Exception ex)
     {
         EasyLogOut.Write(ex);
     }
 }
Beispiel #9
0
        private void OnMapStart(string apiname, dynamic data)
        {
            EasyLogOut.Write("Plugin:OnMapStart");
            Codeplex.Data.DynamicJson json = data;
            EasyLogOut.Write(data);
            try
            {
                JObject root = JObject.Parse(json.ToString());
                m_lastStart = root;
                m_battleBossIdList.Clear();

                int bossId = (int)root.SelectToken(".api_bosscell_no")?.Value <int>();
                m_battleBossIdList.Add(bossId);
            }
            catch (System.Exception ex)
            {
                EasyLogOut.Write(ex);
            }
        }
Beispiel #10
0
        public void Initialize(Plugin plugin)
        {
            EasyLogOut.Write("Plugin:初始化BattleList...");

            this.plugin = plugin;

            m_battleBossIdList = new List <int>();

            sqliteSaveList = new SQLiteSaveList();
            sqliteSaveList.Init();

            LoadData();
            APIObserver o = APIObserver.Instance;

            o["api_req_map/start"].ResponseReceived                    += OnMapStart;
            o["api_req_map/next"].ResponseReceived                     += OnMapNext;
            o["api_req_sortie/battleresult"].ResponseReceived          += OnBattleResult;
            o["api_req_combined_battle/battleresult"].ResponseReceived += OnCombinedBattleResult;
        }
Beispiel #11
0
        public void Init()
        {
            try
            {
                m_sqliteConnection = new SQLiteConnection("data source=" + SQLITE_PATH_LIST);

                if (m_sqliteConnection.State != System.Data.ConnectionState.Open)
                {
                    EasyLogOut.Write("Plugin:LoadData:SQLiteConnection");
                    m_sqliteConnection.Open();
                    SQLiteCommand cmd = new SQLiteCommand();
                    cmd.Connection  = m_sqliteConnection;
                    cmd.CommandText = "CREATE TABLE IF NOT EXISTS battlelist(id INTEGER PRIMARY KEY AUTOINCREMENT, Time DATETIME, MapName TEXT, MapPointId int, IsBoss BOOLEAN, MapPointName TEXT, NewShipName TEXT, WinRank TEXT, DeckName TEXT, FullBattleData TEXT)";
                    cmd.ExecuteNonQuery();
                }
            }
            catch (System.Exception ex)
            {
                EasyLogOut.Write(ex);
            }
        }
Beispiel #12
0
        private bool SaveBattleResult(JObject root)
        {
            try
            {
                if (m_lastStart == null)
                {
                    return(false);
                }

                Debug.WriteLine("战斗结果");
                EasyLogOut.Write(root.ToString(Formatting.Indented));

                //地图信息
                int    mapAreaId = m_lastStart["api_maparea_id"].ToObject <int>();
                int    mapInfoId = m_lastStart["api_mapinfo_no"].ToObject <int>();
                int    pointId   = m_lastStart["api_no"].Value <int>();
                string mapId     = m_lastStart["api_maparea_id"] + "-" + m_lastStart["api_mapinfo_no"]; //3-2


                string shipName = root.SelectToken("api_get_ship.api_ship_name")?.ToObject <string>();

                bool isBoss = m_lastStart["api_event_id"]?.Value <int>() == 5;
                //m_battleBossIdList.Exists(id => id == m_lastStart["api_no"].Value<int>()); //在每次Next的BossId中寻找

                //地图名及敌方信息
                string mapName  = root.SelectToken("api_quest_name")?.ToObject <string>() + $"({mapId})";
                string winRank  = root.SelectToken("api_win_rank")?.ToObject <string>();
                string deckName = root.SelectToken("api_enemy_info.api_deck_name")?.ToObject <string>();


                string pointName = MapPointService.GetMapPointName(mapAreaId, mapInfoId, pointId);
                //综合建成point信息

                var pointShow = (string.IsNullOrWhiteSpace(pointName) ? pointId.ToString() : pointName);

                string mapPointName = isBoss ? pointShow + "(Boss)" : pointShow;

                //string mapPointName = isBoss ? pointId + "(Boss)" : pointId.ToString();
                //需要重新规划map的显示
                //写出map的具体点位 使用poi的数据

                dynamic json = Codeplex.Data.DynamicJson.Parse(root.ToString());
                if ((int)json.api_get_flag[0] != 0)
                {
                    var useItemId  = (int)json.api_get_useitem.api_useitem_id;
                    var itemmaster = ElectronicObserver.Data.KCDatabase.Instance.MasterUseItems[useItemId];
                    shipName = shipName == null || string.IsNullOrWhiteSpace(shipName) ? itemmaster?.Name : shipName + " + " + itemmaster?.Name;
                }

                ElectronicObserver.Data.KCDatabase           db = ElectronicObserver.Data.KCDatabase.Instance;
                ElectronicObserver.Data.Battle.BattleManager bm = db.Battle;
                string fullBattleData = ElectronicObserver.Data.Battle.Detail.BattleDetailDescriptor.GetBattleDetail(bm);

                BattleListCell data = new BattleListCell()
                {
                    Time           = DateTime.Now,
                    MapName        = mapName,
                    MapPointId     = pointId,
                    MapPointName   = mapPointName,
                    NewShipName    = shipName,
                    IsBoos         = isBoss,
                    WinRank        = winRank,
                    DeckName       = deckName,
                    FullBattleData = fullBattleData
                };

                //输出sqlite格式
                sqliteSaveList.AddData(data);

                ////输出Json格式
                //m_battleList.Insert(0, data);
                //SaveData();


                return(true);
            }
            catch (System.Exception ex)
            {
                EasyLogOut.Write(ex);
                return(false);
            }
        }
Beispiel #13
0
 public override bool RunService(FormMain main)
 {
     EasyLogOut.Write("Plugin:RunService调用");
     return(true);
 }