예제 #1
0
 public ChessNote(ChessPlayer oper, ChessPlayer target, string text, int expires)
 {
     OperatorId    = oper?.Id ?? 0;
     Target        = target;
     TargetId      = target.Id;
     GivenAt       = DateTime.Now;
     ExpiresInDays = expires;
     Text          = text;
 }
예제 #2
0
        DateTime lastPlayedAgainst(ChessPlayer p1, ChessPlayer p2)
        {
            DateTime last   = DateTime.Now.AddDays(-1000);
            var      games  = DB.GetGamesWith(p1);
            var      withP2 = games.Where(x => x.LoserId == p2.Id || x.WinnerId == p2.Id);

            foreach (var x in withP2)
            {
                if (x.Timestamp > last)
                {
                    last = x.Timestamp;
                }
            }
            return(last);
        }
예제 #3
0
 string getCapacity(ChessPlayer player)
 {
     if (player == null)
     {
         return("unknown");
     }
     if (player.Permission.HasFlag(ChessPerm.Arbiter))
     {
         return("Arbiter");
     }
     if (player.Permission.HasFlag(ChessPerm.ChiefJustice))
     {
         return("Chief Justice of the Court Of Appeals");
     }
     if (player.Permission.HasFlag(ChessPerm.Justice))
     {
         return("Associate Justice of the Court Of Appeals");
     }
     if (player.Permission.HasFlag(ChessPerm.Moderator))
     {
         return("Moderator");
     }
     return("something");
 }
예제 #4
0
 int getArbVote(ChessPlayer player, ChessPlayer other)
 {
     return(player.ArbVotes.FirstOrDefault(x => x.VoteeId == other.Id)?.Score ?? 0);
 }
예제 #5
0
 public ChessBan(ChessPlayer target, ChessPlayer oper)
 {
     TargetId   = target.Id;
     Target     = target;
     OperatorId = oper.Id;
 }
예제 #6
0
 public ArbiterVote(ChessPlayer voter)
 {
     Voter   = voter;
     VoterId = voter.Id;
 }
예제 #7
0
 public ChessDateScore(ChessPlayer player)
 {
     Player   = player;
     PlayerId = player.Id;
 }
예제 #8
0
 public IQueryable <ChessBan> GetBansAgainst(ChessPlayer player)
 => GetBansAgainst(player.Id);
예제 #9
0
 public IEnumerable <ChessGame> GetCurrentGamesWith(ChessPlayer player)
 => GetCurrentGamesWith(player.Id);
예제 #10
0
 public IQueryable <ChessGame> GetGamesWith(ChessPlayer player)
 {
     return(GetGamesWith(player.Id));
 }