예제 #1
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;
        }
예제 #2
0
 public void NotifyHunterLeft(Hunter hunter)
 {
     var request =
         new ObjectPusherRequest(hunter.HuntInstance.Id.ToString("D"),
                                 EventTypes.HunterLeft.ToString(),
                                 new
                                     {
                                         id = hunter.Id.ToString("D"),
                                         name = hunter.Account.Name,
                                         profileImageUrl = hunter.Account.ProfileImageUrl
                                     });
     _provider.Trigger(request);
 }
예제 #3
0
        public void FoundObjective(Hunter hunter, Objective objective, string locationAndImage)
        {
            if (hunter.HuntInstance.EndTime < DateTime.Now)
                throw new HuntEndedException();

            var foundObjective = new FoundObjective()
                {
                    Objective = objective,
                    TimeFound = DateTime.Now
                    // todo: location and image
                };

            hunter.FoundObjectives.Add(foundObjective);

            _container.SaveChanges();
            _notifier.NotifyObjectiveFound(foundObjective);
        }
예제 #4
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);
        }
 /// <summary>
 /// Create a new Hunter object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="score">Initial value of the Score property.</param>
 public static Hunter CreateHunter(global::System.Guid id, global::System.Int16 score)
 {
     Hunter hunter = new Hunter();
     hunter.Id = id;
     hunter.Score = score;
     return hunter;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Hunters EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToHunters(Hunter hunter)
 {
     base.AddObject("Hunters", hunter);
 }