Esempio n. 1
0
        public string Fire()
        {
            string result = string.Empty;
            using (RNG rng = new RNG())
            {
                int hitNum = rng.d100();

                if (hitNum >= 96) // 96-100 is crit
                    result = "Crit! " + string.Join(", ", Target.HitFor(_weaponDamage * _critMultiplier));
                else if (hitNum >= 11) // 11-95 is hit
                    result = string.Join(", ", Target.HitFor(_weaponDamage));
                else // 0-10 is miss
                    result = "Missed!";
            }
            return result;
        }
Esempio n. 2
0
        private string repair(Ship target)
        {
            List<string> repaired = new List<string>();
            string result = string.Empty;
            using(RNG rand = new RNG())
            {
                foreach (ShipPart part in target.Equipment.Where(f => f.IsDestroyed))
                    if (rand.d100() > 50)
                    {
                        result = part.Repair(_repairAmount);
                        repaired.Add(part.Name+(!string.IsNullOrEmpty(result)?string.Format(" ({0} HPs)",result):string.Empty));
                    }
            }
            result = string.Format("Repaired {0} for {1} HPs", target.Name, target.HP.Add(_repairAmount).ToString());
            if(repaired.Count>0)
                result = result+string.Format(", and Repaired {0}", string.Join(", ",repaired.ToArray()));

            return result;
        }
Esempio n. 3
0
 public override string DoAction(EidosPart targetPart)
 {
     Eidos target = targetPart.Target;
     List<string> repaired = new List<string>();
     string result = string.Empty;
     using (RNG rand = new RNG())
     {
         foreach (EidosPart part in target.Parts.Where(f => f.IsDestroyed))
             if (rand.d100() > 50)
             {
                 result = part.Repair((int)ActionValues[0]);
                 repaired.Add(part.Name + (!string.IsNullOrEmpty(result) ? string.Format(" ({0} HPs)", result) : string.Empty));
             }
     }
     if (target is Ship)
     {
         result = string.Format("Repaired {0} for {1} HPs", target.Name, ((Ship)target).HP.Add((int)ActionValues[0]).ToString());
         if (repaired.Count > 0)
             result = result + string.Format(", and Repaired {0}", string.Join(", ", repaired.ToArray()));
     }
     else
         result = string.Format("Repaired {0}", string.Join(", ", repaired.ToArray()));
     return result;
 }
Esempio n. 4
0
        private void FightRound()
        {
            List<string> roundResults = new List<string>();
            roundResults.Add(string.Format("-=-=-=-=-=-=-=-=Round {0}: COMBAT=-=-=-=-=-=-=-=-", Round));
            using (RNG rand = new RNG())
            {
                if (rand.d100() > 50)
                {
                    roundResults.Add(string.Format("## Firing {0} ##", Ship1.ClassName));
                    roundResults.AddRange(Ship1.FireWeapons(Ship2));
                    roundResults.Add(string.Format("## Firing {0} ##", Ship2.ClassName));
                    roundResults.AddRange(Ship2.FireWeapons(Ship1));
                    roundResults.Add(string.Format("%% Recovering {0} %%", Ship1.ClassName));
                    roundResults.AddRange(Ship1.EndOfTurn());
                    roundResults.Add(string.Format("%% Recovering {0} %%", Ship2.ClassName));
                    roundResults.AddRange(Ship2.EndOfTurn());
                }
                else
                {
                    roundResults.Add(string.Format("## Firing {0} ##", Ship2.ClassName));
                    roundResults.AddRange(Ship2.FireWeapons(Ship1));
                    roundResults.Add(string.Format("## Firing {0} ##", Ship1.ClassName));
                    roundResults.AddRange(Ship1.FireWeapons(Ship2));
                    roundResults.Add(string.Format("%% Recovering {0} %%", Ship2.ClassName));
                    roundResults.AddRange(Ship2.EndOfTurn());
                    roundResults.Add(string.Format("%% Recovering {0} %%", Ship1.ClassName));
                    roundResults.AddRange(Ship1.EndOfTurn());
                }
            }

            roundResults.AddRange(results);
            results = roundResults;
            GridBind(results);

            if (Ship1.HP.Current <= 0 && Ship2.HP.Current <= 0)
            {
                MessageBox.Show(string.Format("Stalemate in {0} rounds!", Round.ToString()));
                victory = true;
                btnFight.Enabled = false;
                btnToTheDeath.Enabled = false;
                btnResetShips.Enabled = true;
            }
            else if (Ship1.HP.Current <= 0)
            {
                MessageBox.Show(string.Format("{0} (Ship 2) Wins in {1} rounds!",Ship2.ClassName, Round.ToString()));
                victory = true;
                btnFight.Enabled = false;
                btnToTheDeath.Enabled = false;
                btnResetShips.Enabled = true;
            }
            else if (Ship2.HP.Current <= 0)
            {
                MessageBox.Show(string.Format("{0} (Ship 1) Wins in {1} rounds!",Ship1.ClassName, Round.ToString()));
                victory = true;
                btnFight.Enabled = false;
                btnToTheDeath.Enabled = false;
                btnResetShips.Enabled = true;
            }

            Round++;
        }
Esempio n. 5
0
        /// <summary>
        /// Fires the weapon at its existing target with specific hit/crit chances
        /// </summary>
        /// <param name="hitAbove">Minimum number needed (out of 100) to hit the target</param>
        /// <param name="critAbove">Minimum number needed (out of 100) to critically-hit the target</param>
        /// <returns>Status result</returns>
        public List<string> Fire(int hitAbove, int critAbove)
        {
            Ship targetShip = (Ship)Target;
            List<string> result = new List<string>();
            _currentReload = _reloadTime;
            using (RNG rng = new RNG())
            {
                int hitNum = rng.d100();

                if (hitNum >= critAbove)
                {
                    result.Add(string.Format("{0} CRITS {1} for {2}",
                        this.Name,
                        targetShip.Name,
                        this.WeaponDamage
                        ));
                    result = result.Concat(targetShip.HitFor(_weaponDamage * _critMultiplier)).ToList<string>();
                }
                else if (hitNum >= hitAbove)
                {
                    result.Add(string.Format("{0} hits {1} for {2}",
                        this.Name,
                        targetShip.Name,
                        this.WeaponDamage
                        ));
                    result = result.Concat(targetShip.HitFor(_weaponDamage)).ToList<string>();
                }
                else
                    result.Add(string.Format("{0} Missed!", this.Name));
            }

            return result;
        }
Esempio n. 6
0
 void initLocations()
 {
     try
     {
         Location newLoc;
         for (int x = 0; x < GridDimensionX; x++)
         {
             for (int y = 0; y < GridDimensionY; y++)
             {
                 using (RNG rng = new RNG())
                 {
                     newLoc = new Location();
                     if (rng.d100() > 95)
                         newLoc.IsBlocked = true;
                     newLoc.Name = string.Format("Loc {0},{1}{2}",
                         x.ToString(),
                         y.ToString(),
                         (newLoc.IsBlocked ? Environment.NewLine + " (Blocked)" : string.Empty));
                     GameState.CombatLocations[x, y] = newLoc;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         if (LogEverything)
             Logger(ex);
     }
 }