private void RemovePossibleChoices(Dictionary <Figure, int> possibleChoices) { foreach (var figure in Figures) { if (figure.StandingOn != null) { Dictionary <Figure, int> possibleChoicesCopy = new Dictionary <Figure, int>(possibleChoices); foreach (var KeyValue in possibleChoicesCopy) { int start = FieldWay.IndexOf(KeyValue.Key.StandingOn); int end = KeyValue.Value; if (start < FieldWay.IndexOf(figure.StandingOn) && end > FieldWay.IndexOf(figure.StandingOn)) { possibleChoices.Remove(KeyValue.Key); } } foreach (var KeyValue in possibleChoicesCopy) { if (KeyValue.Value == FieldWay.IndexOf(KeyValue.Key.StandingOn)) { possibleChoices.Remove(KeyValue.Key); } } } } }
private bool Move(int number, Figure figure) { int moveToo = number; if (figure.StandingOn != null) { moveToo += FieldWay.IndexOf(figure.StandingOn) - 1; } if (FieldWay[moveToo].Player != null) { if (FieldWay[moveToo].Player.Color == this.Color) { return(false); } } figure.Move(FieldWay[moveToo]); return(true); }
private void GetPossibleChoices(int diceNumber, Dictionary <Figure, int> possibleChoices) { foreach (var figure in Figures) { if (figure.StandingOn != null) { int possibleIndex = FieldWay.IndexOf(figure.StandingOn) + diceNumber - 1; if (possibleIndex > FieldWay.Count - 1) { continue; } if (FieldWay[possibleIndex].HasPlayer) { continue; } possibleChoices.Add(figure, possibleIndex); } } }
private bool KickPlayer(int diceNumber) { foreach (var figure in Figures) { if (figure.StandingOn != null) { int possibleIndex = FieldWay.IndexOf(figure.StandingOn) + diceNumber - 1; if (possibleIndex > FieldWay.Count - 1) { continue; } if (FieldWay[possibleIndex].HasPlayer && FieldWay[possibleIndex].Player.Color != Color) { figure.Move(FieldWay[0]); return(true); } } } return(false); }