Skip to content

Commit

Permalink
[#11]: add helper to order players
Browse files Browse the repository at this point in the history
  • Loading branch information
3k-dome committed May 1, 2023
1 parent 829dc51 commit e7614e0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions catan-lib/Helpers/PlayerEncoding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using CatanLib.Interfaces.Components;

namespace CatanLib.Helpers
{
public static class PlayerEncoding
{
public static IEnumerable<IPlayer> Order(IEnumerable<IPlayer> players, IPlayer current)
{
IEnumerable<IPlayer> opponets = players.Where(player => player.Number != current.Number)
.OrderByDescending(player => player.Number);

opponets = opponets.Append(current);
return opponets.Reverse();
}
}
}

0 comments on commit e7614e0

Please sign in to comment.