public async Task <StormState> GetStateAsync(Replay replay, StormState currentState) { TimeSpan?elapsed = await heroesOfTheStorm.TryGetTimerAsync(); if (elapsed != null && elapsed != TimeSpan.Zero) { TimeSpan next = replayHelper.RemoveNegativeOffset(elapsed.Value); if (replayHelper.IsNearEnd(replay, next)) { return(new StormState(next, GameState.EndOfGame)); } if (next <= TimeSpan.Zero) { return(new StormState(next, GameState.StartOfGame)); } if (next > currentState.Timer) { return(new StormState(next, GameState.Running)); } if (next < currentState.Timer) { return(new StormState(next, GameState.Paused)); } return(new StormState(next, currentState.State)); } if (replayHelper.IsNearEnd(replay, currentState.Timer)) { return(new StormState(currentState.Timer, GameState.EndOfGame)); } return(currentState); }
public async Task <StormState> GetStateAsync(StormReplay stormReplay, StormState currentState) { return(await stateTool.GetStateAsync(stormReplay.Replay, currentState)); }
public static bool IsStart(this StormState stormState) => stormState.State == GameState.StartOfGame;
public static bool IsPaused(this StormState stormState) => stormState.State == GameState.Paused;
public static bool IsRunning(this StormState stormState) => stormState.State == GameState.Running;
public static bool IsEnd(this StormState stormState) => stormState.State == GameState.EndOfGame;