Beispiel #1
0
 public Player(Game game, User user, Field field, bool isFirst)
 {
     this.Game = game;
     this.User = user;
     this.SequenceNumber = game.Users.Count;
     this.Money = initialMoney;
     this.Position = field;
     this.OwnTurn = isFirst;
     this.HasMoved = false;
     this.HasPaid = false;
     this.CardUsed = false;
     this.IsBankrupted = false;
 }
 /// <summary>
 /// Registers a new user.
 /// </summary>
 /// <param name="email"></param>
 /// <param name="isGuest"></param>
 internal static void RegisterUser(string email, bool isGuest)
 {
     using (var ctx = new MonopolyModelContainer())
     {
         // check whether he is already in the system
         User user = ctx.Users.SingleOrDefault(u => u.Email == email);
         if (user == null)
         {
             user = new User() { Email = email, IsGuest = isGuest, GUID = Guid.NewGuid().ToString("N") };
             ctx.Users.Add(user);
             ctx.SaveChanges();
         }
         else if (!isGuest && user.IsGuest)
         {
             user.IsGuest = false;
             ctx.SaveChanges();
         }
     }
 }