コード例 #1
0
ファイル: Defenders.cs プロジェクト: arturcp/Samjokgo
 public Defenders(Generate generate)
 {
     this.Units = Util.ScrambleList<Unit>(generate.UnitDefenderList());
     this.Powers = new List<HeroPower>();
     this.Heroes = generate.HeroDefenderList();
     this.Title = "Defensores";
 }
コード例 #2
0
ファイル: Attackers.cs プロジェクト: arturcp/Samjokgo
 public Attackers(Generate generate)
 {
     this.Units = Util.ScrambleList<Unit>(generate.UnitAttackerList());
     this.Powers = new List<HeroPower>();
     this.Heroes = generate.HeroAttackerList();
     this.Title = "Atacantes";
 }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: arturcp/Samjokgo
        public ActionResult Show()
        {
            Combat.Log.Clear();
            Generate generate = new Generate(Request);
            UnitFactory.StartUnitFactory();
            DateTime startTime = DateTime.Now;

            Attackers attackers = new Attackers(generate);
            Defenders defenders = new Defenders(generate);

            int turns = attackers.Units.Count.BiggerThan(defenders.Units.Count)? attackers.Units.Count : defenders.Units.Count;
            int rounds = ReadIntFromRequest("rounds");

            generate.HeroesPowers(turns, attackers, defenders);

            int i = 1;
            while (i <= rounds && defenders.Units.Count + defenders.Heroes.Count > 0 && attackers.Units.Count + attackers.Heroes.Count > 0)
            {
                Combat.Log.Add(string.Format("<h2>Round {0}</h2><p>Atacando: {1} unidades</p><p>Defendendo: {2} unidades</p>", i, attackers.Units.Count, defenders.Units.Count));
                Combat.StartCombat(turns, attackers, defenders);

                #region LOG
                Combat.Log.Add(attackers.PV());
                Combat.Log.Add(defenders.PV());
                generate.RoundReport(i, attackers, defenders);
                #endregion

                #region RESET
                generate.RoundResetUnitLives(attackers.Units);
                generate.RoundResetUnitLives(defenders.Units);
                attackers.ResetHeroes();
                defenders.ResetHeroes();
                #endregion

                turns = attackers.Units.Count.BiggerThan(defenders.Units.Count)? attackers.Units.Count : defenders.Units.Count;
                generate.HeroesPowers(turns, attackers, defenders);
                i++;
            }
            DateTime finishTime = DateTime.Now;
            TimeSpan ts = finishTime.Subtract(startTime);
            ViewData["TimeSpent"] = ts;
            ViewData["Rounds"] = rounds;
            return View();
        }