private void OnPlayerFinished(object state) { object[] stateParams = (object[])state; int currentChallengeID = (int)stateParams[0]; PlayerFinishEventArgs e = (PlayerFinishEventArgs)stateParams[1]; if (e.TimeOrScore > 0) { uint?oldPosition, newPosition; bool newBest; RecordAdapter.CheckAndWriteNewRecord(e.Login, currentChallengeID, e.TimeOrScore, out oldPosition, out newPosition, out newBest); if (newBest) { string nickname = GetNickname(e.Login); if (nickname != null && newPosition <= Settings.MaxRecordsToReport && currentChallengeID == CurrentChallengeID) { DetermineLocalRecords(); OnPlayerNewRecord(e.Login, nickname, e.TimeOrScore, oldPosition, newPosition); } } SessionAdapter.AddSession(e.Login, currentChallengeID, Convert.ToUInt32(e.TimeOrScore)); } }
private void DetermineLocalRecords() { LocalRecords = RecordAdapter.GetTopRecordsForChallenge(CurrentChallengeID, Settings.MaxRecordsToReport).ToArray(); Context.ValueStore.SetOrUpdate(GlobalConstants.LOCAL_RECORDS, LocalRecords.ToArray()); Context.ValueStore.SetOrUpdate(GlobalConstants.FIRST_LOCAL_RECORD_TIMEORSCORE, LocalRecords.Length == 0 ? null : (int?)LocalRecords[0].TimeOrScore); }