public Guid CreateBountyCharacter(Character character)
        {
            if(ModelState.IsValid)
            {
                character.Id = Guid.NewGuid();
                character.UserId = Guid.Empty;
                character.AvatarId = this.avatar.GetAvatarBasedOnClass(character.PlayerClassId).Single().id;

                this.db.Characters.Add(character);
                this.db.SaveChanges();
            }

            return character.Id;
        }
예제 #2
0
        public string CharacterShard(Guid characterId)
        {
            Character character = new Character();

            return character.CharacterShard(characterId);
        }
예제 #3
0
        public string GetClassStyle(string className)
        {
            Character character = new Character();

            return character.GetClassStyle(className);
        }
예제 #4
0
        public string CharacterAllegience(Guid characterId)
        {
            Character character = new Character();

            return character.CharacterAllegience(characterId);
        }
예제 #5
0
        public string CharacterClass(Guid characterId)
        {
            Character character = new Character();

            return character.CharacterClass(characterId);
        }
예제 #6
0
        public void AddBountyNotificationMessage(Bounty bounty, string messageType)
        {
            Account account = new Account();
            Character character = new Character();
            Favorite favorite = new Favorite();
            IQueryable<Favorite> favoritedCharacters;
            WatchedBounty watchedBounty = new WatchedBounty();
            IQueryable<WatchedBounty> watchedBounties;

            Message adminMessage;
            Message clientMessage;
            Message hunterMessage;
            Message targetMessage;
            Message favoriteMessage;
            Message watcherMessage;

            List<Guid> adminIds = new List<Guid>();
            IQueryable<Account> admins = account.GetAdminUserIds();

            foreach(Account admin in admins)
            {
                adminIds.Add(admin.Id);
            }

            DateTime dateCreated = DateTime.Now;

            string placedOn = bounty.CharacterName(bounty.PlacedOnId);
            string placedBy = bounty.CharacterName(bounty.PlacedById);
            string killedBy = string.Empty;
            string shard = bounty.CharacterShard(bounty.PlacedOnId);

            if(bounty.KilledById != null)
            {
                killedBy = bounty.CharacterName(bounty.KilledById.Value);
            }

            string targetDescription;
            if(bounty.Reason == string.Empty || bounty.Reason == null)
            {
                targetDescription = string.Format("A bounty has been placed on your head by {0} - {1} in the amount of {2}.", placedBy, shard, bounty.Amount);
            }
            else
            {
                targetDescription = string.Format("A bounty has been placed on your head by {0} - {1} in the amount of {2} for '{3}'.", placedBy, shard, bounty.Amount, bounty.Reason);
            }

            switch(messageType)
            {
                case "Pending Placement":
                    // Admin Notification
                    foreach(Guid adminId in adminIds)
                    {
                        adminMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = adminId,
                            DateCreated = dateCreated,
                            Subject = string.Format("Placement submitted for approval on {0} - {1}", placedOn, shard),
                            Description = string.Format("A bounty has been placed by {0} - {1} on {2} - {3} in the amount of {4} that is pending your approval", placedBy, shard, placedOn, shard, bounty.Amount),
                            IsRead = false,
                            IsAdminMessage = true
                        };

                        db.Messages.Add(adminMessage);
                    }

                    // Client Notification
                    clientMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.PlacedById),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty placement against {0} - {1} is Pending Approval", placedOn, shard),
                        Description = string.Format("We have recieved the bounty request against {0} - {1}. In order to finalize the bounty, you must deliver the bounty amount of {2} to one of our operatives. Once recieved, your bounty will be posted for every hunter in the galaxy to see in order to apprehend the target and bring them to whatever justice you so desired.", placedOn, shard, bounty.Amount),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(clientMessage);

                    db.SaveChanges();

                    break;

                case "Placement Approved":
                    // Client Notification
                    clientMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.PlacedById),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty placement against {0} - {1} has been Approved", placedOn, shard),
                        Description = string.Format("The bounty against {0} - {1} has been approved.  Every hunter in the galaxy will now be on the hunt. Once the target has been killed you will be alerted with photographic proof of the targets demise.", placedOn, bounty.Amount),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(clientMessage);

                    // Target Notification
                    targetMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.PlacedOnId),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty has been placed on {0} - {1}", placedOn, shard),
                        Description = targetDescription,
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(targetMessage);

                    // Favorited Notifications
                    favoritedCharacters = favorite.GetFavoritedCharacters(bounty.PlacedOnId);

                    foreach(Favorite favoritedCharacterItem in favoritedCharacters)
                    {
                        favoriteMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = favoritedCharacterItem.AccountId,
                            DateCreated = dateCreated,
                            Subject = string.Format("New bounty has been placed on {0} - {1}", placedOn, shard),
                            Description = string.Format("One of your favorited characters, {0} - {1}, has commited a crime against {2} - {3} and a bounty has been placed on their head.", placedOn, shard, placedBy, shard),
                            IsRead = false,
                            IsAdminMessage = false
                        };

                        db.Messages.Add(favoriteMessage);
                    }

                    db.SaveChanges();

                    break;

                case "Pending Completion":
                    // Admin Notification
                    foreach(Guid adminId in adminIds)
                    {
                        adminMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = adminId,
                            DateCreated = dateCreated,
                            Subject = string.Format("A bounty completion has been posted on {0} - {1} by {2} - {3}", placedOn, shard, killedBy, shard),
                            Description = string.Format("The bounty against {0} - {1} has been submitted for completion by {2} - {3}", placedOn, shard, killedBy, shard),
                            IsRead = false,
                            IsAdminMessage = true
                        };

                        db.Messages.Add(adminMessage);
                    }

                    // Hunter Notification
                    hunterMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.KilledById.Value),
                        DateCreated = dateCreated,
                        Subject = string.Format("The bounty being collected on {0} - {1} is pending approval for completion", placedOn, shard),
                        Description = string.Format("The bounty on {0} - {1} in the amount of {2} has been submitted for approval.  Once approved, the funds, minus any processing fees will be delivered to account.", placedOn, shard, bounty.Amount),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(hunterMessage);

                    // Watcher Notifications
                    watchedBounties = watchedBounty.GetWatchedBounties(bounty.Id);

                    foreach(WatchedBounty watchedBountyItem in watchedBounties)
                    {
                        watcherMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = watchedBountyItem.AccountId,
                            DateCreated = dateCreated,
                            Subject = string.Format("The bounty being collected on {0} - {1} is pending approval for completion", placedOn, shard),
                            Description = string.Format("The bounty on {0} - {1} has been submitted for approval by another brave hunter. For the time being, please refrain from hunting the target. In the event that the collection request is denied, you will be alerted and thehunt can continue.", placedOn, shard),
                            IsRead = false,
                            IsAdminMessage = false
                        };

                        db.Messages.Add(watcherMessage);
                    }

                    db.SaveChanges();

                    break;

                case "Completion Approved":
                    // Client Notification
                    clientMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.PlacedById),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty has been completed on {0} - {1}", placedOn, shard),
                        Description = string.Format("{0} - {1} has been killed by {2} - {3} and has successfully delivered your message, visual proof of the targets demise can be seen on the bounty details page.", placedOn, shard, killedBy, shard),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(clientMessage);

                    // Hunter Notification
                    hunterMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.KilledById.Value),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty has been completed on {0} - {1}", placedOn, shard),
                        Description = string.Format("The completion for the bounty on {0} - {1} in the amount of {2} has been approved. One of our representatives will be delivering the bounty amount minus any processing fees to you.  We congratulate you on your success and on an excellent hunt!", placedOn, shard, bounty.Amount),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(hunterMessage);

                    // Target Notification
                    targetMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.PlacedOnId),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty has been completed on {0} - {1}", placedOn, shard),
                        Description = string.Format("The bounty placed on your head has been completed by {0} - {1}.", killedBy, shard),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(targetMessage);

                    // Watcher Notifications
                    watchedBounties = watchedBounty.GetWatchedBounties(bounty.Id);

                    foreach(WatchedBounty watchedBountyItem in watchedBounties)
                    {
                        watcherMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = watchedBountyItem.AccountId,
                            DateCreated = dateCreated,
                            Subject = string.Format("Bounty has been completed on {0} - {1}", placedOn, shard),
                            Description = string.Format("The bounty placed on {0} - {1} has been collected by {0} - {1}.  We ask that at this time you no longer continue the hunt. This bounty has been removed from all watch lists.", placedOn, shard, placedOn, shard, killedBy),
                            IsRead = false,
                            IsAdminMessage = false
                        };

                        db.Messages.Add(watcherMessage);
                    }

                    // Favorited Notifications
                    favoritedCharacters = favorite.GetFavoritedCharacters(bounty.PlacedOnId);

                    foreach(Favorite favoritedCharacterItem in favoritedCharacters)
                    {
                        favoriteMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = favoritedCharacterItem.AccountId,
                            DateCreated = dateCreated,
                            Subject = string.Format("Bounty has been completed on {0} - {1}", placedOn, shard),
                            Description = string.Format("The bounty on one of your favorited characters, {0} - {1} has been completed. {2} - {3} was the one who tracked and killed {4} - {5}.", placedOn, shard, killedBy, shard, placedOn, shard),
                            IsRead = false,
                            IsAdminMessage = false
                        };

                        db.Messages.Add(favoriteMessage);
                    }

                    db.SaveChanges();

                    break;

                case "Placement Denied":

                    // Client Notification
                    clientMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.PlacedById),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty placed on {0} - {1} hase been denied", placedOn, shard),
                        Description = string.Format("The bounty placed on {0} - {1} in the amount of {2} has been denied.", placedOn, shard, bounty.Amount),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(clientMessage);

                    db.SaveChanges();
                    break;

                case "Completion Denied":
                    // Hunter Notification
                    hunterMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.KilledById.Value),
                        DateCreated = dateCreated,
                        Subject = string.Format("The bounty on {0} - {1} that was submitted for completion has been denied.", placedOn, shard),
                        Description = string.Format("The bounty on {0} - {1} that was submitted for completion has been denied.", placedOn, shard),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(hunterMessage);

                    // Watcher Notifications
                    watchedBounties = watchedBounty.GetWatchedBounties(bounty.Id);

                    foreach (WatchedBounty watchedBountyItem in watchedBounties)
                    {
                        watcherMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = watchedBountyItem.AccountId,
                            DateCreated = dateCreated,
                            Subject = string.Format("The bounty on {0} - {1} that was submitted for completion has been denied.", placedOn, shard),
                            Description = string.Format("The bounty on {0} - {1} that was submitted for completion has been denied. The target is still available to be hunted!", placedOn, shard),
                            IsRead = false,
                            IsAdminMessage = false
                        };

                        db.Messages.Add(watcherMessage);
                    }

                    db.SaveChanges();

                    break;

                case "Bounty Cancelled":
                    // Admin Notification
                    foreach (Guid adminId in adminIds)
                    {
                        adminMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = adminId,
                            DateCreated = dateCreated,
                            Subject = string.Format("The bounty placed on {0} - {1} has been cancelled by {1} - {1}", placedOn, shard, placedBy, shard),
                            Description = string.Format("The bounty placed on {0} - {1} has been cancelled by {1} - {1}", placedOn, shard, placedBy, shard),
                            IsRead = false,
                            IsAdminMessage = true
                        };

                        db.Messages.Add(adminMessage);
                    }

                    // Watcher Notifications
                    watchedBounties = watchedBounty.GetWatchedBounties(bounty.Id);

                    foreach (WatchedBounty watchedBountyItem in watchedBounties)
                    {
                        watcherMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = watchedBountyItem.AccountId,
                            DateCreated = dateCreated,
                            Subject = string.Format("The bounty on {0} - {1} has been cancelled by the client", placedOn, shard),
                            Description = string.Format("The bounty on {0} - {1} has been cancelled by the client. This bounty has been removed from your watch list", placedOn, shard),
                            IsRead = false,
                            IsAdminMessage = false
                        };

                        db.Messages.Add(watcherMessage);
                    }

                    // Favorited Notifications
                    favoritedCharacters = favorite.GetFavoritedCharacters(bounty.PlacedOnId);

                    foreach (Favorite favoritedCharacterItem in favoritedCharacters)
                    {
                        favoriteMessage = new Message
                        {
                            Id = Guid.NewGuid(),
                            UserId = favoritedCharacterItem.AccountId,
                            DateCreated = dateCreated,
                            Subject = string.Format("New bounty on {0} - {1} has been cancelled by the client", placedOn, shard),
                            Description = string.Format("The bounty on {0} - {1} has been cancelled by the client", placedOn, shard),
                            IsRead = false,
                            IsAdminMessage = false
                        };

                        db.Messages.Add(favoriteMessage);
                    }

                    // Target Notification
                    targetMessage = new Message
                    {
                        Id = Guid.NewGuid(),
                        UserId = character.GetCharacterUserId(bounty.PlacedOnId),
                        DateCreated = dateCreated,
                        Subject = string.Format("Bounty on {0} - {1} has been cancelled by the client", placedOn, shard),
                        Description = string.Format("The bounty placed on {0} - {1} has been cancelled by the client.", placedOn, shard),
                        IsRead = false,
                        IsAdminMessage = false
                    };

                    db.Messages.Add(targetMessage);

                    db.SaveChanges();

                    break;
            }
        }
예제 #7
0
        public ActionResult Create(Character character)
        {
            this.characterAddEditViewModel.Character = this.db.Characters.Find(character.Id);

            ModelState["Name"].Errors.Clear();

            var viewModel = new BountyCreateViewModel
            {
                Character = this.characterAddEditViewModel.Character
            };

            return View(viewModel);
        }
예제 #8
0
        public string GetFactionStyle(string factionName)
        {
            Character character = new Character();

            return character.GetFactionStyle(factionName);
        }
예제 #9
0
        public bool IsBountyOwner(Guid userId, Guid bountyId)
        {
            Character character = new Character();

            bool isBountyOwner = false;

            var bounty = this.db.Bounties.Find(bountyId);

            Guid characterUserId = character.GetCharacterById(bounty.PlacedById).Single().UserId;

            if(userId == characterUserId)
            {
                isBountyOwner = true;
            }

            return isBountyOwner;
        }
예제 #10
0
        public List<Guid> GetAllKillShotImageIdsByAccount(Guid accountId, string imageType)
        {
            Character character = new Character();

            var accountCharacters = character.GetAllCharactersForAnAccount(accountId);

            List<Guid> killShotImages = new List<Guid>();

            switch(imageType)
            {
                case "bountiesPlaced":
                    foreach(Character accountCharacter in accountCharacters)
                    {
                        IQueryable<Bounty> completedBountiesPlacedBy = this.db.Bounties.Where(b => b.PlacedById == accountCharacter.Id).Where(b => b.IsCompletionPending == false);

                        foreach(Bounty completedBounty in completedBountiesPlacedBy)
                        {
                            killShotImages.Add(completedBounty.KillShotImageId.Value);
                        }
                    }

                    break;

                case "targetsKilled":
                    foreach(Character accountCharacter in accountCharacters)
                    {
                        IQueryable<Bounty> completedBountiesKilledBy = this.db.Bounties.Where(b => b.KilledById == accountCharacter.Id).Where(b => b.IsCompletionPending == false);

                        foreach(Bounty completedBounty in completedBountiesKilledBy)
                        {
                            killShotImages.Add(completedBounty.KillShotImageId.Value);
                        }
                    }

                    break;

                case "bountiesPlacedOn":
                    foreach(Character accountCharacter in accountCharacters)
                    {
                        IQueryable<Bounty> completedBountiesPlacedOn = this.db.Bounties.Where(b => b.PlacedOnId == accountCharacter.Id).Where(b => b.IsCompletionPending == false);

                        foreach(Bounty completedBounty in completedBountiesPlacedOn)
                        {
                            killShotImages.Add(completedBounty.KillShotImageId.Value);
                        }
                    }

                    break;
            }

            return killShotImages;
        }
예제 #11
0
        public List<Bounty> GetAccountPendingBountiesPlaced(Guid accountId)
        {
            Character character = new Character();
            List<Bounty> pendingAccountBounties = new List<Bounty>();

            IEnumerable<Character> accountCharacters = character.GetAllCharactersForAnAccount(accountId);

            foreach(Character accountCharacter in accountCharacters)
            {
                IQueryable<Bounty> pendingBounties = this.GetPendingBountiesPlaced(accountCharacter.Id);

                if(pendingBounties.Count() != 0)
                {
                    foreach(Bounty pendingBounty in pendingBounties)
                    {
                        pendingAccountBounties.Add(pendingBounty);
                    }
                }
            }

            return pendingAccountBounties;
        }
예제 #12
0
        public List<Bounty> GetAccountBountiesPlacedOn(Guid accountId)
        {
            Character character = new Character();
            List<Bounty> accountBounties = new List<Bounty>();

            IEnumerable<Character> accountCharacters = character.GetAllCharactersForAnAccount(accountId);

            foreach(Character accountCharacter in accountCharacters)
            {
                IQueryable<Bounty> completedBounties = this.GetBountiesPlacedOn(accountCharacter.Id);

                if(completedBounties.Count() != 0)
                {
                    foreach(Bounty completedBounty in completedBounties)
                    {
                        accountBounties.Add(completedBounty);
                    }
                }
            }

            return accountBounties;
        }
예제 #13
0
        public double GetAccountAmountSpent(Guid accountId)
        {
            Character character = new Character();
            double totalSpent = 0;

            IEnumerable<Character> accountCharacters = character.GetAllCharactersForAnAccount(accountId);

            foreach(Character accountCharacter in accountCharacters)
            {
                IQueryable<Bounty> completedBounties = this.GetBountiesPlaced(accountCharacter.Id);

                if(completedBounties.Count() != 0)
                {
                    foreach(Bounty completedBounty in completedBounties)
                    {
                        totalSpent = totalSpent + completedBounty.Amount;
                    }
                }
            }

            return totalSpent;
        }
예제 #14
0
        public double GetAccountAmountEarned(Guid accountId)
        {
            Character character = new Character();
            double totalEarned = 0;

            IEnumerable<Character> accountCharacters = character.GetAllCharactersForAnAccount(accountId);

            foreach(Character accountCharacter in accountCharacters)
            {
                List<Bounty> completedBounties = this.GetBountiesCompleted(accountCharacter.Id);

                if(completedBounties.Count() != 0)
                {
                    foreach(Bounty completedBounty in completedBounties)
                    {
                        totalEarned = totalEarned + (completedBounty.Amount * 0.95);
                    }
                }
            }

            return totalEarned;
        }