public static void SaveByteStr(ulong id, byte[] cmd) { string folder = FileUtilNew.GetLocalPath() + "/battlelogs/"; if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } string path = folder + id; File.WriteAllBytes(path, cmd); }
private void OnReceiveBattleData(params object[] arg) { BattleData data = arg[0] as BattleData; if (data == null) { return; } string text = ""; text += "战斗id(battleID):" + data.battleId; text += WRAP; text += "攻击方初始状态:"; text += WRAP; heros.Clear(); for (int i = 0; i < data.atkTeam.heroList.Count; i++) { BattleHeroInfo info = data.atkTeam.heroList[i]; heros.Add(info.tempId, info); string template = "{0} heroId({1}),tempId({2}),位置{3},血量{4}/{6},怒气{5}"; text += string.Format(template, GetHeroNameByHeroid(info.heroId), info.heroId, info.tempId, info.pos, info.hp, info.mp, info.maxHp); text += WRAP; } text += "防御方方初始状态:"; text += WRAP; for (int i = 0; i < data.defTeam.heroList.Count; i++) { BattleHeroInfo info = data.defTeam.heroList[i]; heros.Add(info.tempId, info); string template = "{0} heroId({1}),tempId({2}),位置{3},血量{4}/{6},怒气{5}"; text += string.Format(template, GetHeroNameByHeroid(info.heroId), info.heroId, info.tempId, info.pos, info.hp, info.mp, info.maxHp); text += WRAP; } for (int i = 0; i < data.roundList.Count; i++) { text += string.Format("第{0}回合:", data.roundList[i].round); text += WRAP; for (int j = 0; j < data.roundList[i].records.Count; j++) { BattleHeroRecords records = data.roundList [i].records [j]; BattleHeroInfo info = heros[records.tempId]; string template = "{0}({1}) "; text += string.Format(template, GetHeroNameByHeroid(info.heroId), info.pos); for (int k = 0; k < records.recordList.Count; k++) { ClientBattleRecord record = (ClientBattleRecord)records.recordList [k]; text += TranslateRecord(record); text += WRAP; } } } text += "战斗结束"; string folder = FileUtilNew.GetLocalPath() + "/battlelogs/"; if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } else { string[] files = Directory.GetFiles(folder, "*.txt"); if (files.Length > 100) { Directory.Delete(folder, true); Directory.CreateDirectory(folder); } } lastpath = folder + data.battleId; File.WriteAllText(lastpath + ".txt", text, System.Text.UTF8Encoding.UTF8); }