internal DiceRollResult onRollDice() { DiceRollResult diceRoll = new DiceRollResult(GameBoard); RollDice?.Invoke(this, diceRoll); return(diceRoll); }
private void InitPlayers() { System.Collections.SortedList playerRankSort = new System.Collections.SortedList(); int playerSortKey; // Initialize without rank for (var i = 0; i < PlayerRank.Length; i++) { PlayerRank[i].Initialize(this, i); } // Give every Player On dial for rank foreach (var p in PlayerRank) { _activePlayer = p.Index; NextPlayer?.Invoke(ActivePlayer); DiceRollResult result = p.DelegateDiceRoll(); playerSortKey = result.DiceSum * 10; while (playerRankSort.ContainsKey(-playerSortKey)) { playerSortKey += 1; } playerRankSort.Add(-playerSortKey, p); // negativ for sorting } playerRankSort.Values.CopyTo(PlayerRank, 0); // Initialize Part 2 with rank for (ushort i = 0; i < PlayerRank.Length; i++) { PlayerRank[i].Index = i; } _activePlayer = -1; RaisePlayerRankChanged(); }