Esempio n. 1
0
        string TranslateRecord(ClientBattleRecord value)
        {
            string temple = record_template [value.Type];

            switch (value.Type)
            {
            case RecordType.BattleAtkRec:
                string text = "";
                foreach (BattleAtkTar tar in value.battleAtkRec.tarList)
                {
                    string name = GetHeroNameByTempid(tar.defId);
                    if (tar.byLuck == 0)
                    {
                        text += string.Format("{0}闪避了", name);
                    }
                    else if (tar.byLuck == 1)
                    {
                        text += string.Format("{0}受到{1}点伤害", name, tar.dmg);
                    }
                    else if (tar.byLuck == 2)
                    {
                        text += string.Format("{0}受到{1}点暴击伤害", name, tar.dmg);
                    }
                    text += ",";
                }
                return(string.Format(temple, GetSkillNameById(value.battleAtkRec.skillId), text));

            case RecordType.BattleBufAddRec:
                text = "";
                foreach (uint tempid in value.battleBufAddRec.tempList)
                {
                    text += GetHeroNameByTempid(tempid);
                    text += ",";
                }
                return(string.Format(temple, text, GetBuffNameById(value.battleBufAddRec.buffId)));

            case RecordType.BattleBufRemoveRec:
                text = "";
                foreach (uint tempid in value.battleBufRemoveRec.tempList)
                {
                    text += GetHeroNameByHeroid(tempid);
                    text += ",";
                }
                return(string.Format(temple, text, GetBuffNameById(value.battleBufRemoveRec.buffId)));

            case RecordType.BattleDieRec:
                return(string.Format(temple, GetHeroNameByTempid(value.battleDieRec.tempId)));

            case RecordType.BattleHpRec:
                return(string.Format(temple, GetHeroNameByTempid(value.battleHpRec.tempId), value.battleHpRec.hp));

            case RecordType.BattleMpRec:
                return(string.Format(temple, GetHeroNameByTempid(value.battleMpRec.tempId), value.battleMpRec.curMp));

            default:
                return(string.Empty);
            }
            return(string.Empty);
        }
Esempio n. 2
0
        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);
        }