using System; using System.Collections.Generic; using System.Text; namespace SalsaModel { enum GrabBy { Nothing, LeftHand, RightHand, } class Hold { public Hold(GrabBy left, GrabBy right) { Left = left; Right = right; } public readonly GrabBy Left; public readonly GrabBy Right; internal GrabBy Get(PositionModel.Side side) { if (side == PositionModel.Side.Left) return Left; else return Right; } internal GrabBy GetOther(PositionModel.Side leaderHoldSide) { return Get(PositionModel.Other(leaderHoldSide)); } /// /// If the hold on the given side is a hand hold, returns the side. /// Otherwise, throws. Really, you should only call this once you know that it's /// a hand hold. /// internal PositionModel.Side GetHandSide(PositionModel.Side leaderHoldSide) { switch (Get(leaderHoldSide)) { case GrabBy.Nothing: throw new Exception("Can't lead with nothing"); case GrabBy.LeftHand: return PositionModel.Side.Left; break; case GrabBy.RightHand: return PositionModel.Side.Right; break; default: throw new Exception("Grab location " + Get(leaderHoldSide).ToString() + " is not a hand hold"); } } } }