Example #1
0
        internal static Piece PopBeetleStack(BeetleStack oldStack)
        {
            if (oldStack.height == 1)
            {
                return(oldStack.bottom);
            }
            var newStack = new BeetleStack(oldStack.bottom, oldStack.secondLevel);

            switch (oldStack.height)
            {
            case 2:
                return(newStack);

            case 3:
                newStack._pieces[2] = oldStack.thirdLevel;
                newStack._topLevel  = 2;
                break;

            case 4:
                newStack._pieces[2] = oldStack.thirdLevel;
                newStack._pieces[3] = oldStack.fourthLevel;
                newStack._topLevel  = 3;
                break;

            default:
                throw new Exception("Too many levels!");
            }
            return(newStack);
        }
Example #2
0
        public override bool Equals(Piece obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (!(obj is BeetleStack))
            {
                return(false);
            }
            BeetleStack other = (BeetleStack)obj;

            if (!(this.fifthLevel == other.fifthLevel))
            {
                return(false);
            }
            if (!(this.fourthLevel == other.fourthLevel))
            {
                return(false);
            }
            if (!(this.thirdLevel == other.thirdLevel))
            {
                return(false);
            }
            if (!(this.secondLevel == other.secondLevel))
            {
                return(false);
            }
            if (!(this.bottom == other.bottom))
            {
                return(false);
            }
            return(true);
        }
Example #3
0
 internal BeetleStack(Beetle newPiece, BeetleStack originalStack)
     : base(originalStack.color, originalStack.number)
 {
     _topLevel          = originalStack._topLevel + 1;
     this._pieces[0]    = originalStack.bottom;
     this._pieces[1]    = originalStack.secondLevel;
     this._pieces[2]    = originalStack.thirdLevel;
     this._pieces[3]    = originalStack.fourthLevel;
     this._pieces[4]    = originalStack.fifthLevel;
     _pieces[_topLevel] = newPiece;
 }