public double LeaveChair(Player player) { if (TableLocationOfActivePlayers.Values.Contains(player)) { foreach (var chair in TableLocationOfActivePlayers.Keys) { if (TableLocationOfActivePlayers[chair] == player) { TableLocationOfActivePlayers.Remove(chair); ActivePlayersByID.Remove(player.GetHashCode()); chair.Release(); return(player.StandUp()); } } } throw new PlayerNotFoundException("Can't find player at the table"); }
public bool TakeChair(Player player, int index) { try { var result = PassivePlayers.Where(item => item == player); if (result.Count() != 1 || !chairs[index].Take()) { return(false); } // register player location at the table. TableLocationOfActivePlayers.Add(chairs[index], player); return(true); } catch (IndexOutOfRangeException) { throw new RoomRulesException("chair index does not exists"); } }