示例#1
0
 protected void EmitEditingFinished(object value, FinishReason reason)
 {
     if (this.EditingFinished != null)
     {
         this.EditingFinished(this, new PropertyEditingFinishedEventArgs(this.parent, value, reason));
     }
 }
 // Token: 0x060020AE RID: 8366 RVA: 0x0004DA8B File Offset: 0x0004CA8B
 public static bool Parse(string str, out FinishReason value)
 {
     if (FinishReasonConverter.typeMap.TryGetValue(str, out value))
     {
         return(true);
     }
     value = FinishReason.Unknown;
     return(false);
 }
示例#3
0
        //
        // Called when the review has completed (for better or worse)
        //
        private void OnReviewFinished(FinishReason finishReason)
        {
            m_logger.Log("Review state finished - {0}", finishReason);

            // Only delete the file in certain situations

            // Keep the patch file, delete the original if we created it
            if (finishReason == FinishReason.Success || finishReason == FinishReason.Closing)
            {
                Utilities.Storage.Keep(m_reviewSource.Patch, "Changes.patch", m_reviewSource.Source == Review.Review.Source.Files, m_logger);
            }

            // Go back to the final state
            if (finishReason == FinishReason.Success)
            {
                UpdateCreateReviewDialogState(State.Terminate);
            }
            else if (finishReason == FinishReason.Error)
            {
                UpdateCreateReviewDialogState(State.Idle);
            }
        }
示例#4
0
 public PropertyEditingFinishedEventArgs(PropertyEditor editor, object value, FinishReason reason)
     : base(editor, value)
 {
     this.reason = reason;
 }
示例#5
0
 // Token: 0x060016F4 RID: 5876 RVA: 0x000282D0 File Offset: 0x000272D0
 public virtual void FinishEntrant(long personaId, FinishReason reason)
 {
     this.FindEntrant(personaId).ScoringState.FinishReason = reason;
 }
示例#6
0
 protected void OnEditingFinished(FinishReason reason)
 {
     this.OnEditingFinished(this, new PropertyEditingFinishedEventArgs(this, this.DisplayedValue, reason));
 }
示例#7
0
 public PropertyEditingFinishedEventArgs(PropertyEditor editor, object value, FinishReason reason) : base(editor, value)
 {
     this.reason = reason;
 }
示例#8
0
 /// <summary>
 /// Finish the action with the specified reason, invoke the callback.
 /// </summary>
 /// <param name="completed">reason for completion</param>
 public void Finish(FinishReason reason)
 {
     this.onFinished.Invoke(reason);
 }
 // Token: 0x060002E5 RID: 741 RVA: 0x00004E2A File Offset: 0x00003E2A
 public void SetFinishReason(FinishReason reason)
 {
     InternalOpponent._EASharpBinding_296(this.mSelf, (int)reason);
 }
示例#10
0
 // Token: 0x0600135B RID: 4955 RVA: 0x0001BFDC File Offset: 0x0001AFDC
 public FinishEntrant(InstancedEvent evnt, EntrantInfo entrant, FinishReason finishReason) : base(evnt, entrant)
 {
     this.finishReason = finishReason;
 }
		protected void OnEditingFinished(FinishReason reason)
		{
			this.OnEditingFinished(this, new PropertyEditingFinishedEventArgs(this, this.DisplayedValue, reason));
		}
示例#12
0
 public static FinishReasonDto ToDto(this FinishReason model) =>
 model switch
 {
 // Token: 0x06001353 RID: 4947 RVA: 0x0001BEA4 File Offset: 0x0001AEA4
 public EntrantInterupt(InstancedEvent @event, EntrantInfo entrant, uint port, FinishReason finishReason) : base(@event, entrant, port)
 {
     this.finishReason = finishReason;
 }
示例#14
0
 // Token: 0x060017FF RID: 6143 RVA: 0x0002ADE7 File Offset: 0x00029DE7
 public virtual bool IsFinishReason(FinishReason reason)
 {
     return((this.finishReason & reason) == reason);
 }
示例#15
0
        private async Task <GameResult> FinishGame(string gameId, FinishReason reason, string forfeitPlayer = null)
        {
            // Todo end game logic
            var game = gameCache.ActiveGames.SingleOrDefault(x => x.Id == gameId)?.ToDto <Game>();

            if (game == null)
            {
                throw new ArgumentException("Invalid game id");
            }

            game.Status       = GameStatus.Finished;
            game.FinishReason = reason;
            game.FinishDate   = DateTime.UtcNow;

            game.P1FinalScore = game.PlayMoves
                                .Where(m => m.Player == game.Player01.UserName)
                                .Sum(m => m.Score) - game.Player01.Rack.Sum(l => l.Char.LetterValue(game.Language));
            if (game.P1FinalScore < 0)
            {
                game.P1FinalScore = 0;
            }

            game.P2FinalScore = game.PlayMoves
                                .Where(m => m.Player == game.Player02.UserName)
                                .Sum(m => m.Score) - game.Player02.Rack.Sum(l => l.Char.LetterValue(game.Language));
            if (game.P2FinalScore < 0)
            {
                game.P2FinalScore = 0;
            }

            IGamePlayer winner;
            IGamePlayer looser;

            if (reason == FinishReason.Forfeit)
            {
                looser = game.GetPlayer(forfeitPlayer);
                if (game == null)
                {
                    throw new ApplicationException("Forfeit must have a forfeit player");
                }
                winner = game.Player01.UserName == looser.UserName
                    ? game.Player02
                    : game.Player01;
            }
            else
            {
                if (game.P1FinalScore > game.P2FinalScore)
                {
                    winner = game.Player01;
                    looser = game.Player02;
                }
                else if (game.P2FinalScore > game.P1FinalScore)
                {
                    winner = game.Player02;
                    looser = game.Player01;
                }
                else
                {
                    winner = null;
                    looser = null;
                }
            }
            game.Winner = winner?.UserName;

            // todo save game to db
            await gameRepository.Update(game.ToDataModel());

            gameCache.RemoveGame(game.Id);
            await logger.InfoAsync($"GAME OVER! Winner:[{game.Winner}] Duration:[{Math.Round((game.FinishDate.Value-game.CreationDate).TotalMinutes,2)}]", context : game.Id);

            var res = new GameResult
            {
                GameId      = game.Id,
                Player1     = game.Player01.UserName,
                Player2     = game.Player02.UserName,
                Winner      = winner?.UserName,
                Duration    = Math.Round((game.FinishDate.Value - game.CreationDate).TotalMinutes, 2),
                P1Score     = game.PlayMoves.Where(m => m.Player == game.Player01.UserName).Sum(m => m.Score),
                P2Score     = game.PlayMoves.Where(m => m.Player == game.Player02.UserName).Sum(m => m.Score),
                P1PlayCount = game.PlayMoves.Where(m => m.Player == game.Player01.UserName).Count(),
                P2PlayCount = game.PlayMoves.Where(m => m.Player == game.Player02.UserName).Count(),
                Reason      = reason
            };

            res.P1Average = res.P1PlayCount == 0 ? 0 : res.P1Score / res.P1PlayCount;
            res.P2Average = res.P2PlayCount == 0 ? 0 : res.P2Score / res.P2PlayCount;

            statService.UpdateStats(game.Id);

            return(res);
        }