Exemplo n.º 1
0
 /// <summary>
 /// Shuffles this pile.
 /// </summary>
 public void Shuffle()
 {
     Undeployed.AddRange(Deployed);
     Deployed.Clear();
     foreach (var component in Undeployed)
     {
         component.InternalDesignation = Guid.NewGuid();
     }
     Undeployed = Undeployed.OrderBy(x => x.InternalDesignation).ToList();
     Undeployed = Undeployed.Distinct().ToList();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Draws a component from the pile.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="System.InvalidOperationException">Tried to draw from a component pile that was empty.  Component:  + typeof(T)</exception>
        public T Draw()
        {
            if (Undeployed.Count == 0)
            {
                throw new InvalidOperationException("Tried to draw from a component pile that was empty.  Component: " + typeof(T));
            }

            var ret = Undeployed.ElementAt(0);

            Undeployed.RemoveAt(0);
            Deployed.Add(ret);

            return(ret);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Discards the specified component.
 /// </summary>
 /// <param name="component">The component.</param>
 public void Discard(T component)
 {
     Undeployed.Add(component);
     Deployed.Remove(component);
 }