title: Trouble with simple battle game in C#
body: <p>The main idea is to each member on <code>team1</code> attack a random enemy on <code>team2</code>. The damage dealt is based on a spell casted at random from a <code>Grimoire</code> book.</p>
  
  <p><strong>My Code:</strong></p>
  
  <pre><code>using System;
  
  namespace simple_test
  {
      class Program
      {
          public class IceLance : Hechizo //hechizo == spell
          {
              public IceLance(uint d) : base(20)
              {
                  danio = d; // danio == damage
                  return;
              }
  
              public override void Castear() // castear == cast
              {
                  Console.WriteLine("Ice Lance");
              }
  
              protected uint danio = 5; // danio == damage
  
  
  
  
          }
  
          public abstract class Hechizo
          {
              protected Hechizo(uint c)
              {
                  costo = c; // costo == cost
              }
  
  
              public abstract void Castear();
  
              protected uint costo = 1;
  
              public uint Costo
              {
                  get { return costo; }
              }
          }
          public class Personaje // personaje == character 
          {
              public Personaje()
              { }
              public Personaje(uint s)
              {
                  salud = s;
              }
  
  
              public void RecibirDanio(uint d) // RecibirDanio == RecieveDamage 
              {
                  salud -= d; // salud = salud - d // salud == Health
              }
  
  
              public virtual void Ataque() // Ataque == Attack
              {
                  Console.WriteLine("Ataque melee");
                  return;
              }
  
              public bool IsVivo() // IsVivo == IsAlive
              {
                  return salud &gt; 0;
              }
  
              protected uint salud = 100;
          }
  
  
          public class Humano : Personaje // Humano == Human
          {
              public Humano() : base()
              { }
              public Humano(uint s, uint m) : base(s)
              {
                  mana = m;
              }
  
  
  
              public void CastearGrimorio(int idx)
              {
                  if ((grimorio == null) ||
                    (idx &gt;= grimorio.Length) || (grimorio[idx] == null))
                      return;
                  uint c = grimorio[idx].Costo;
                  if (mana &gt;= c)
                  {
                      mana -= c;
                      grimorio[idx].Castear();
                  }
              }
  
  
              public void AprenderHechizo(Hechizo h) // AprenderHechizo == LearnSpell
              {
                  if (grimorio == null)
                  {
                      grimorio = new Hechizo[1];
                  }
                  else
                  {
                      Hechizo[] nuevoGrimorio = new Hechizo[grimorio.Length + 1];
                      for (uint i = 0; i &lt; grimorio.Length; ++i)
                      {
                          nuevoGrimorio[i] = grimorio[i];
                      }
                      grimorio = nuevoGrimorio;
                  }
                  grimorio[grimorio.Length - 1] = h;
              }
  
              public override void Ataque()
              {
                  if (grimorio == null)
                      Console.WriteLine("Sin mana :(");
                  else
                      CastearGrimorio(rnd.Next(0, grimorio.Length));//con esto lanza hechizos al azar
                  return;
              }
  
  
              private uint mana = 10;
  
  
              private Hechizo[] grimorio;
              private Random rnd = new Random();
  
          }
  
          static public bool TodosMuertos(Personaje[] team) // TodosMuertos == AllDead
          {
              for (int i = 0; i &lt; team.Length; ++i)
              {
                  if (team[i].IsVivo())
                  {
                      return false;
                  }
              }
              return true;
          }
          static void Main(string[] args)
          {
              Personaje[] team1 = new Personaje[41];
              for (int i = 0; i &lt; 3; ++i)
              {
                  Humano mage = new Humano(80, 100);
                  mage.AprenderHechizo(new IceLance(20));
                  mage.AprenderHechizo(new IceLance(10));
                  mage.AprenderHechizo(new IceLance(0));
                  team1[i] = mage;
              }
  
              Personaje[] team2 = new Personaje[41];
              for (int i = 0; i &lt; 3; ++i)
              {
                  Humano mage = new Humano(80, 100);
                  mage.AprenderHechizo(new IceLance(20));
                  mage.AprenderHechizo(new IceLance(10));
                  mage.AprenderHechizo(new IceLance(0));
                  team2[i] = mage;
              }
  
              while (!TodosMuertos(team1) &amp;&amp; !TodosMuertos(team2)) // turnos
              {
                  Console.WriteLine("team1");
  
                  for (int i = 0; i &lt; team1.Length; ++i)
                  {
  
  
                      if (team1[i].IsVivo())
                      {
  
                          team1[i].Ataque();
                          // Here should go the RecieveDamage funtion
  
  
                      }
  
  
                      Console.ReadKey();
  
  
  
                  }
              }  
          }
      }
  }
  </code></pre>
  
  <p>This one is a simplified version of the code, i.e. it only has one class and one spell.
  I'm not sure how to write the part of how to select a member of the opposite team and in base of the spell casted <code>receiveDamage</code> according to its damage.</p>
  
  <p>PS: I added some references to the spanish language used in the code</p>