示例#1
0
文件: Game.cs 项目: jeffreyrack/hodor
        // Created by Jeffrey Rackauckas
        // Create Date: 04/24/2014
        // The new Game class needs a constructer!
        public Game(User user)
        {
            Random rand = new Random();

            this.totalProblems = rand.Next(10, 31);
            this.currentProblemIndex = 0;
            this.correctAnswers = 0;
            this.correctStreak = 0;
            this.coinsGained = 0;
            this.problemTime = 0;

            //Addition or Subtraction problems
            if (rand.Next(0, 2) > 0)
            {
                this.problemHandler = Problem.AddProblem;
            }
            else
            {
                this.problemHandler = Problem.SubProblem;
            }

            //this.testDiff = Problem.Difficulty.Easy;
            if (user.GroupName != null)
            {
                this.testDiff = GroupList.Instance.GetByName(user.GroupName).Difficulty;
            }
            else
            {
                this.testDiff = Problem.Difficulty.Easy;
            }
            this.currentProblem = this.problemHandler(this.testDiff);
        }
示例#2
0
 /// <summary>
 /// Check whenver the given user 'usr' can authenticate using the password 'pwd'.
 /// </summary>
 /// <param name="usr">User to authenticate.</param>
 /// <param name="pwd">Password for user.</param>
 /// <returns>True if the password match.</returns>
 internal static bool Authenticate(User usr, string pwd)
 {
     Contract.Assert(usr != null);
     Contract.Assert(pwd != null);
     Contract.Assert(usr.Hash != null, "The selected teacher doesn't have a password set: "
         + "Users.xml is probably compromized, please remove it to get the default, or fix it.");
     return string.Equals(sha1Of(pwd), usr.Hash);
 }
示例#3
0
文件: User.cs 项目: jeffreyrack/hodor
#pragma warning restore 0067
        #endregion

        // Changed By: Jeffrey Rackauckas
        // Changed on: 4/24/2014.
        // Moved the main functionality of this to Game.cs
        public void newGame(User user)
        {
            user.Data.game = new Game(user);

        }
示例#4
0
文件: Game.cs 项目: jeffreyrack/hodor
 public static void CorrectAnswer(Game game, User CurrentUser)
 {
     game.correctAnswers++;
     game.correctStreak++;
     //display the coin change next to coins
     int thisProblemCoins = CoinsEarned(game.correctStreak);
     CurrentUser.addCoins(thisProblemCoins);
      //         currentUser.Data.coinsGained += thisProblemCoins;
     game.coinsGained += thisProblemCoins;
 }