public bool Process() { Debug.WriteLine("start LoadBattleResultEntry"); WorksheetEntry sheet = GetWorksheet("Battle"); if (sheet == null) { _finishCallback(false); return(false); } var list = Query(sheet); lock (((ICollection)_battleResultLog).SyncRoot) { foreach (var row in list) { var it = new LogData.BattleResultInfo(row); it.MemberID = _memberId; it.Number = _battleResultLog.Count + 1; _battleResultLog.Add(it); } } _finishCallback(true); return(true); }
public AddBattleResultEntry(SpreadSheetWrapper wrapper, LogData.BattleResultInfo info , LogStore.LogStore.LogUploadCompleted finishCallback) { _wrapper = wrapper; _info = info; _memberId = info.MemberID; _finishCallback = finishCallback; }
public override bool LoadBattleResult(string MemberID, IList <LogData.BattleResultInfo> battleLog, LogDownloadCompleted finishCallback) { string file = GetFilePath(MemberID, battlelog_filename); if (file == null) { finishCallback(false); return(false); } if (!File.Exists(file)) { finishCallback(false); return(false); } using (TextFieldParser parser = new TextFieldParser(file, System.Text.Encoding.UTF8)) { parser.TextFieldType = FieldType.Delimited; parser.SetDelimiters(","); lock (((ICollection)battleLog).SyncRoot) { while (!parser.EndOfData) { string[] row = parser.ReadFields(); var info = new LogData.BattleResultInfo(row); info.Number = battleLog.Count + 1; info.MemberID = MemberID; battleLog.Add(info); } } } finishCallback(true); return(true); }
/// <summary> /// 戦闘結果の追加 /// </summary> /// <param name="info">戦闘結果データ</param> public void AddBattleResult(LogData.BattleResultInfo info) { if (info == null) { Debug.WriteLine("invalid BattleResult(null)"); return; } lock (((ICollection)_battleLog).SyncRoot) { info.Number = _battleLog.Count + 1; _battleLog.Add(info); } _logStore.AddBattleResult(info, (bool bSucceeded) => { if (!(Properties.Settings.Default.SuppressSuceedWriteLog && bSucceeded)) { UpdateStatusMessage("戦闘結果の書き込みに{0}しました", bSucceeded ? "成功" : "失敗"); } }); _vlvBattleLog.UpdateList(); }
/// <summary> /// 戦闘終了 /kcsapi/api_req_sortie/battleresult /// </summary> /// <param name="JSON"></param> public LogData.BattleResultInfo Finish(string JSON, MemberData.Ship shipData, MemberData.Deck deckData, MasterData.Ship shipMaster, MemberData.Basic basicData) { // var json = DynamicJson.Parse(JSON); var json = JsonConvert.DeserializeObject <KCB.api_req_sortie.BattleResult>(JSON); if ((int)json.api_result != 1) { return(null); } var data = json.api_data; LogData.BattleResultInfo result = new LogData.BattleResultInfo(); result.MemberID = basicData.MemberID; result.Date = DateTime.Now; result.AreaName = data.api_quest_name; result.Rank = data.api_win_rank; //敵情報 result.Foe.DeckName = data.api_enemy_info.api_deck_name; Debug.WriteLine("FoeDeckName:" + result.Foe.DeckName); // double[] enemylist = (double[])data.api_ship_id; // for (int i = 1; i < enemylist.Count(); i++) for (int i = 1; i < data.api_ship_id.Count(); i++) { int enemyID = data.api_ship_id[i]; if (enemyID <= 0) { result.Foe.ShipList[i - 1] = ""; continue; } //何故かeliteとかflagの文字は読みに入ってる var t = shipMaster.LookupShipMaster(enemyID); if (t.Yomi.Length == 1) { result.Foe.ShipList[i - 1] = t.Name; } else { result.Foe.ShipList[i - 1] = string.Format("{0}({1})", t.Name, t.Yomi); } Debug.WriteLine(string.Format("ShipList({0})={1}", i - 1, result.Foe.ShipList[i - 1])); } //自軍情報 var fleet = deckData.GetFleet(battleFleetID); result.Friend.DeckName = fleet.Name; Debug.WriteLine("FriendDeckName:" + result.Friend.DeckName); for (int i = 0; i < fleet.Member.Count(); i++) { if (fleet.Member[i] <= 0) { result.Friend.ShipList[i] = ""; continue; } string header = ""; ///ロスト艦艇 if (data.api_lost_flag != null && (int)data.api_lost_flag[i + 1] != 0) { header = "x"; } //MVPは1オリジン if ((int)data.api_mvp == i + 1) { header = "*"; } var t = shipData.GetShip(fleet.Member[i]); result.Friend.ShipList[i] = string.Format("{0}{1}(Lv{2} HP{3})", header, t.ShipName, t.Level, t.HP); Debug.WriteLine(string.Format("ShipList({0})={1}", i, result.Friend.ShipList[i])); } ///ドロップ // if (data.IsDefined("api_get_ship")) if (data.api_get_ship != null) { result.ShipDropped = string.Format("{0}({1})", data.api_get_ship.api_ship_name, data.api_get_ship.api_ship_type); } Debug.WriteLine("GetShip:" + result.ShipDropped); return(result); }
public override bool LoadBattleResult(string MemberID, IList<LogData.BattleResultInfo> battleLog, LogDownloadCompleted finishCallback) { string file = GetFilePath(MemberID, battlelog_filename); if (file == null) { finishCallback(false); return false; } if (!File.Exists(file)) { finishCallback(false); return false; } using (TextFieldParser parser = new TextFieldParser(file, System.Text.Encoding.UTF8)) { parser.TextFieldType = FieldType.Delimited; parser.SetDelimiters(","); lock (((ICollection)battleLog).SyncRoot) { while (!parser.EndOfData) { string[] row = parser.ReadFields(); var info = new LogData.BattleResultInfo(row); info.Number = battleLog.Count + 1; info.MemberID = MemberID; battleLog.Add(info); } } } finishCallback(true); return true; }
public virtual bool AddBattleResult(LogData.BattleResultInfo info, LogUploadCompleted finishCallback) { finishCallback(true); return(true); }
public override bool AddBattleResult(LogData.BattleResultInfo info, LogUploadCompleted finishCallback) { _jobq.Add(new GSpread.Job.CreateIfNotExistSheet(info.MemberID, _wrapper)); _jobq.Add(new GSpread.Job.AddBattleResultEntry(_wrapper, info, finishCallback)); return(true); }
/// <summary> /// 戦闘終了 /kcsapi/api_req_sortie/battleresult /// </summary> /// <param name="JSON"></param> public LogData.BattleResultInfo Finish(string JSON, MemberData.Ship shipData, MemberData.Deck deckData,MasterData.Ship shipMaster,MemberData.Basic basicData) { // var json = DynamicJson.Parse(JSON); var json = JsonConvert.DeserializeObject<KCB.api_req_sortie.BattleResult>(JSON); if ((int)json.api_result != 1) return null; var data = json.api_data; LogData.BattleResultInfo result = new LogData.BattleResultInfo(); result.MemberID = basicData.MemberID; result.Date = DateTime.Now; result.AreaName = data.api_quest_name; result.Rank = data.api_win_rank; //敵情報 result.Foe.DeckName = data.api_enemy_info.api_deck_name; Debug.WriteLine("FoeDeckName:" + result.Foe.DeckName); // double[] enemylist = (double[])data.api_ship_id; // for (int i = 1; i < enemylist.Count(); i++) for (int i = 1; i < data.api_ship_id.Count(); i++) { int enemyID = data.api_ship_id[i]; if (enemyID <= 0) { result.Foe.ShipList[i - 1] = ""; continue; } //何故かeliteとかflagの文字は読みに入ってる var t = shipMaster.LookupShipMaster(enemyID); if (t.Yomi.Length == 1) result.Foe.ShipList[i - 1] = t.Name; else result.Foe.ShipList[i - 1] = string.Format("{0}({1})", t.Name, t.Yomi); Debug.WriteLine(string.Format("ShipList({0})={1}", i - 1, result.Foe.ShipList[i - 1])); } //自軍情報 var fleet = deckData.GetFleet(battleFleetID); result.Friend.DeckName = fleet.Name; Debug.WriteLine("FriendDeckName:" + result.Friend.DeckName); for (int i = 0; i < fleet.Member.Count(); i++) { if (fleet.Member[i] <= 0) { result.Friend.ShipList[i] = ""; continue; } string header = ""; ///ロスト艦艇 if (data.api_lost_flag != null && (int)data.api_lost_flag[i + 1] != 0) header = "x"; //MVPは1オリジン if ((int)data.api_mvp == i + 1) header = "*"; var t = shipData.GetShip(fleet.Member[i]); result.Friend.ShipList[i] = string.Format("{0}{1}(Lv{2} HP{3})", header, t.ShipName, t.Level, t.HP); Debug.WriteLine(string.Format("ShipList({0})={1}", i, result.Friend.ShipList[i])); } ///ドロップ // if (data.IsDefined("api_get_ship")) if(data.api_get_ship != null) result.ShipDropped = string.Format("{0}({1})", data.api_get_ship.api_ship_name, data.api_get_ship.api_ship_type); Debug.WriteLine("GetShip:" + result.ShipDropped); return result; }