Ejemplo n.º 1
0
        public Hunt CreateHunt(Account user, Hunt huntTemplate)
        {
            if ((from hunt in _container.Hunts where hunt.Name == huntTemplate.Name select hunt).FirstOrDefault() != null)
                throw new HuntAlreadyExistsException();

            huntTemplate.Id = Guid.NewGuid();
            _container.AddToHunts(huntTemplate);
            _container.SaveChanges();

            return huntTemplate;
        }
Ejemplo n.º 2
0
        public void DenyObjective(Account admin, FoundObjective foundObjective)
        {
            if (foundObjective.Hunter.HuntInstance.EndTime < DateTime.Now)
                throw new HuntEndedException();

            if (foundObjective.Hunter.HuntInstance.Admin != admin)
                throw new SecurityException();

            foundObjective.Hunter.FoundObjectives.Remove(foundObjective);
            _container.SaveChanges();
            _notifier.NotifyObjectiveDenied(foundObjective);
        }
Ejemplo n.º 3
0
        public static HuntInstance CreateDummyHuntInstance()
        {
            var theObjective = new Objective()
                {
                    Id = new Guid("{81573EBA-C5AA-4423-B308-BCB3026AE771}"),
                    Name = "Find a fountain!",
                    Description = "It must be green.",
                    Score = 100
                };

            var theAdmin = new Account()
                {
                    Id = new Guid("{714DC8D9-42EA-43F2-8148-DDFAC1E585C5}"),
                    Name = "SuperTom"
                };

            var britAccount = new Account()
                {
                    Id = new Guid("{614DC8D9-42EA-43F2-8148-DDFAC1E585C6}"),
                    Name = "Brit"
                };

            var theHunt = new Hunt()
                {
                    Id = new Guid("{741BB781-531D-4354-A840-777E267A809E}"),
                    Name = "DummyHunt",
                    Description = "A dummy hunt!",
                    Creator = theAdmin,

                };

            var theInstance = new HuntInstance()
                {
                    Id = new Guid("{E41BB781-531D-4354-A840-777E267A809E}"),
                    Admin = theAdmin,
                    StartTime = new DateTime(2012, 12, 1, 12, 0, 0, 0),
                    EndTime = new DateTime(2012, 12, 2, 12, 0, 0, 0),
                    Hunt = theHunt
                };

            var britHunter = new Hunter()
                {
                    Id = new Guid("{F41BB781-531D-4354-A840-777E267A809E}"),
                    Account = britAccount,
                    HuntInstance = theInstance
                };

            theInstance.Hunters.Add(britHunter);
            theHunt.Objectives.Add(theObjective);
            theObjective.Hunt = theHunt;

            return theInstance;
        }
Ejemplo n.º 4
0
        public Account CreateAccount(string accountToken, string username, string authType, string profileImageUrl)
        {
            var account = new Account
                {
                    Id = Guid.NewGuid(),
                    Name = username,
                    AuthType = authType,
                    ProfileImageUrl = profileImageUrl,
                    AccountToken = accountToken
                };

            _container.Accounts.AddObject(account);
            _container.SaveChanges();
            return account;
        }
Ejemplo n.º 5
0
        public void JoinHunt(Account user, HuntInstance instance)
        {
            if (instance.EndTime < DateTime.Now)
                throw new HuntEndedException();

            if (instance.Hunters.Any(x => x.Account == user))
                throw new HuntAlreadyJoinedException();

            var hunter = new Hunter()
                {
                    Account = user,
                    Score = 0
                };

            instance.Hunters.Add(hunter);
            _container.SaveChanges();
            _notifier.NotifyHunterJoined(hunter);
        }
Ejemplo n.º 6
0
 public HuntInstance StartHunt(Account user, Hunt hunt)
 {
     return new HuntInstance();
 }
Ejemplo n.º 7
0
 public IQueryable<Hunt> ListHunts(Account user)
 {
     return (from hunt in _container.Hunts where hunt.Creator == user select hunt);
 }
Ejemplo n.º 8
0
 public void LeaveHunt(Account user, HuntInstance instance)
 {
 }
 /// <summary>
 /// Create a new Account object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="authType">Initial value of the AuthType property.</param>
 public static Account CreateAccount(global::System.Guid id, global::System.String name, global::System.String authType)
 {
     Account account = new Account();
     account.Id = id;
     account.Name = name;
     account.AuthType = authType;
     return account;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Accounts EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAccounts(Account account)
 {
     base.AddObject("Accounts", account);
 }