public void SendPersonTo(Stall stall) { if (this.selection != null) { if (this.selection.CanUseStall(stall)) { this.selection.GoToStall(stall); this.Deselect(this.selection); this.UpdateWaitingLine(); } } }
public IEnumerable<Stall> GetNeighbors(Stall stall) { int stallIndex = this.stalls.IndexOf(stall); if (stallIndex > 0) yield return this.stalls[stallIndex - 1]; if (stallIndex < this.stalls.Count - 1) yield return this.stalls[stallIndex + 1]; }
public void ScoreStallChoice(Stall stall) { int neighbors = this.GetNeighborCount(stall); if (neighbors > 0) { this.AdjustScore(neighbors * (-15)); stall.Alert(neighbors * (-15), "Pee foul!"); } }
public int GetNeighborCount(Stall stall) { int stallIndex = this.stalls.IndexOf(stall); int neighbors = 0; if (stallIndex > 0 && this.stalls[stallIndex - 1].Person != null) ++neighbors; if (stallIndex < this.stalls.Count - 1 && this.stalls[stallIndex + 1].Person != null) ++neighbors; return neighbors; }