예제 #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {

                Directory.CreateDirectory("\\temp\\uploads\\");
                string uploadPath = "\\temp\\uploads\\";

                FileUpload1.SaveAs(uploadPath + FileUpload1.FileName);
                FileUpload2.SaveAs(uploadPath + FileUpload2.FileName);

                r1 = new Robot();
                r2 = new Robot();
                Robot r1Old;
                Robot r2Old;

                int rounds = 10;

                r1.loadRobot(FileUpload1.FileName, uploadPath);
                r2.loadRobot(FileUpload2.FileName, uploadPath);

                r1Old = r1;
                r2Old = r2;

                RobotGame robotGame1 = new RobotGame(r1, r2, rounds);
                int result = robotGame1.fight();

                switch (result)
                {
                    case 1: StatusDiv.InnerText = r1.getNavn() + " wins"; break;
                    case 2: StatusDiv.InnerText = r1.getNavn() + " wins"; break;
                    default: StatusDiv.InnerText = "Nobody wins"; break;
                }

                Robot1_Data.InnerHtml = "<h2>" + r1.getNavn() + "</h2>";
                Robot1_Data.InnerHtml += "<ul><li>Liv: <span data-new='" + Convert.ToString(r1.getLiv()) + "'>" + Convert.ToString(r1Old.getLiv()) + "</span></li>";
                Robot1_Data.InnerHtml += "<li>Sejre: <span data-new='" + Convert.ToString(r1.getSejre()) + "'>" + Convert.ToString(r1Old.getSejre()) + "</span></li>";
                Robot1_Data.InnerHtml += "<li>Tab: <span data-new='" + Convert.ToString(r1.getTab()) + "'>" + Convert.ToString(r1Old.getTab()) + "</span></li>";
                Robot1_Data.InnerHtml += "<li>Uafgjort: <span data-new='" + Convert.ToString(r1.getUafgjort()) + "'>" + Convert.ToString(r1Old.getUafgjort()) + "</span></li></ul>";

                Robot2_Data.InnerHtml = "<h2>" + r2.getNavn() + "</h2>";
                Robot2_Data.InnerHtml += "<ul><li>Liv: <span data-new='" + Convert.ToString(r2.getLiv()) + "'>" + Convert.ToString(r2Old.getLiv()) + "</span></li>";
                Robot2_Data.InnerHtml += "<li>Sejre: <span data-new='" + Convert.ToString(r2.getSejre()) + "'>" + Convert.ToString(r2Old.getSejre()) + "</span></li>";
                Robot2_Data.InnerHtml += "<li>Tab: <span data-new='" + Convert.ToString(r2.getTab()) + "'>" + Convert.ToString(r2Old.getTab()) + "</span></li>";
                Robot2_Data.InnerHtml += "<li>Uafgjort: <span data-new='" + Convert.ToString(r2.getUafgjort()) + "'>" + Convert.ToString(r2Old.getUafgjort()) + "</span></li></ul>";

                Robot2_Data.InnerHtml += "<script>$(document).ready(function () { displayGameFlow('" + r1.getJSONData() + "','" + r2.getJSONData() + "', " + Convert.ToString(rounds) + "); });</script>";

                //System.IO.File.Copy(r1.getPath(), Server.MapPath("xmls" + FileUpload1.FileName), true);
                //System.IO.File.Copy(r2.getPath(), Server.MapPath("xmls" + FileUpload2.FileName), true);

                A2.HRef = Server.MapPath(r1.getPath());
                A3.HRef = Server.MapPath(r2.getPath());
            }
        }
예제 #2
0
 public RobotGame(Robot _r1, Robot _r2, int _rounds)
 {
     r1 = _r1;
     r2 = _r2;
     rounds = _rounds;
 }