public static NewGameData Convert(NewGameInput newGameInput)
        {
            var newGameData = new NewGameData(newGameInput.Name, newGameInput.Totem.Value, newGameInput.Opponent1, newGameInput.Opponent2,
            newGameInput.Opponent3);

              return newGameData;
        }
 public static void Execute(string username, NewGameData newGameData)
 {
     using (var context = new MonopolyDotNetDbContext())
       {
     var game = new Game(newGameData, username);
     context.Games.Add(game);
     context.SaveChanges();
       }
 }
        public static Game StartGame()
        {
            var username = Guid.NewGuid().ToString("D");
              var newGameData = new NewGameData("Tron", Totem.Dog, "Rube", "Chester", "Adolf");

              CreateGameCommand.Execute(username, newGameData);
              var game = FindGameByUsernameQuery.Execute(username);
              return game;
        }
Beispiel #4
0
    /// <summary>
    /// Returns the players response accuracy.
    /// The perfect accuracy would be 1, most inaccuracy is 0.
    /// </summary>
    protected float GetAccuracy(Trial t, float time)
    {
        NewGameData data = sessionData.gameData as NewGameData;
        bool        hasResponseTimeLimit = data.ResponseTimeLimit > 0;

        float rTime           = time - data.GuessTimeLimit;
        float totalTimeWindow = hasResponseTimeLimit ?
                                data.ResponseTimeLimit : (t as NewGameTrial).duration;

        return(1f - (rTime / (totalTimeWindow - data.GuessTimeLimit)));
    }
    /// <summary>
    /// Parses Game specific variables for this Trial from the given XmlElement.
    /// If no parsable attributes are found, or fail, then it will generate some from the given GameData.
    /// Used when parsing a Trial that IS defined in the Session file.
    /// </summary>
    public override void ParseGameSpecificVars(XmlNode n, SessionData session)
    {
        base.ParseGameSpecificVars(n, session);

        NewGameData data = (NewGameData)(session.gameData);

        if (!XMLUtil.ParseAttribute(n, NewGameData.ATTRIBUTE_DURATION, ref duration, true))
        {
            duration = data.GeneratedDuration;
        }
    }
Beispiel #6
0
 public Game(NewGameData newGameData, string username)
 {
     Players = new List<Player>();
       Players.AddRange(newGameData.GetPlayers());
       Username = username;
 }
Beispiel #7
0
    /// <summary>
    /// Returns True if the given response time is considered valid.
    /// </summary>
    protected bool IsValidResponse(float time)
    {
        NewGameData data = sessionData.gameData as NewGameData;

        return(data.ResponseTimeLimit <= 0 || time < data.ResponseTimeLimit);
    }
Beispiel #8
0
    /// <summary>
    /// Returns True if the given response time is considered a guess.
    /// </summary>
    protected bool IsGuessResponse(float time)
    {
        NewGameData data = sessionData.gameData as NewGameData;

        return(data.GuessTimeLimit > 0 && time < data.GuessTimeLimit);
    }