public ActionResult <ApiFightTextSimulationResult> PostHtml([FromBody] string xmlFight)
        {
            try
            {
                ApiFightTextSimulationResult res  = new ApiFightTextSimulationResult();
                FightSimulation       sim         = new FightSimulation(Program.World, xmlFight);
                StringWriter          log         = new StringWriter();
                StringWriter          html        = new StringWriter();
                FightSimulationResult fightResult = sim.Run(log);
                fightResult.WriteToHtml(html);
                log.Flush();
                html.Flush();
                res.Text = html.ToString();
                res.Log  = log.ToString();

                if (res.Log.Length > (1024 * 1024))
                {
                    res.Log = res.Log.Substring(0, (1024 * 1024)) + " ...";
                }

                return(res);
            }
            catch (Exception e)
            {
                return(StatusCode(400, e));
            }
        }
        public ActionResult <FileResult> PostCsvFile([FromBody] string xmlFight)
        {
            try
            {
                ApiFightTextSimulationResult res  = new ApiFightTextSimulationResult();
                FightSimulation       sim         = new FightSimulation(Program.World, xmlFight);
                StringWriter          log         = new StringWriter();
                StringWriter          csv         = new StringWriter();
                FightSimulationResult fightResult = sim.Run(log);
                fightResult.WriteToCsv(csv);
                log.Flush();
                csv.Flush();
                res.Text = csv.ToString();
                res.Log  = log.ToString();


                using (MemoryStream memoryStream = new MemoryStream())
                {
                    using (ZipArchive archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
                    {
                        ZipArchiveEntry outputFile = archive.CreateEntry("homm3-damage-simulation.csv");

                        using (Stream entryStream = outputFile.Open())
                            using (StreamWriter streamWriter = new StreamWriter(entryStream))
                            {
                                entryStream.Write(System.Text.Encoding.Unicode.GetBytes(res.Text));
                                //streamWriter.Write(res.Text);
                            }

                        outputFile = archive.CreateEntry("homm3-damage-simulation-log.txt");
                        using (Stream entryStream = outputFile.Open())
                            using (StreamWriter streamWriter = new StreamWriter(entryStream))
                            {
                                entryStream.Write(System.Text.Encoding.Unicode.GetBytes(res.Log));
                                //streamWriter.Write(res.Log);
                            }
                    }


                    memoryStream.Seek(0, SeekOrigin.Begin);
                    FileResult fr = new FileContentResult(memoryStream.ToArray(), "application/zip");
                    fr.FileDownloadName = "homm3-damage-simulation.zip";
                    return(fr);
                }
            }
            catch (Exception e)
            {
                return(StatusCode(400, e));
            }
        }
        public ActionResult <ApiFightTextSimulationResult> PostCsv([FromBody] string xmlFight)
        {
            ApiFightTextSimulationResult res  = new ApiFightTextSimulationResult();
            FightSimulation       sim         = new FightSimulation(Program.World, xmlFight);
            StringWriter          log         = new StringWriter();
            StringWriter          csv         = new StringWriter();
            FightSimulationResult fightResult = sim.Run(log);

            fightResult.WriteToCsv(csv);
            log.Flush();
            csv.Flush();
            res.Text = csv.ToString();
            res.Log  = log.ToString();

            return(res);
        }