예제 #1
0
        private async Task <EFMeansOfDeath> GetOrAddMeansOfDeath(string meansOfDeath, Reference.Game game)
        {
            var matchingMod = (await _modCache
                               .FirstAsync(mod => mod.Name == meansOfDeath && mod.Game == game));

            if (matchingMod != null)
            {
                return(matchingMod);
            }

            var mod = new EFMeansOfDeath()
            {
                Name = meansOfDeath,
                Game = game
            };

            mod = await _modCache.AddAsync(mod);

            return(mod);
        }
예제 #2
0
        private async Task <EFWeapon> GetOrAddWeapon(WeaponInfo weapon, Reference.Game game)
        {
            var matchingWeapon = (await _weaponCache
                                  .FirstAsync(wep => wep.Name == weapon.Name && wep.Game == game));

            if (matchingWeapon != null)
            {
                return(matchingWeapon);
            }

            matchingWeapon = new EFWeapon()
            {
                Name = weapon.Name,
                Game = game
            };

            matchingWeapon = await _weaponCache.AddAsync(matchingWeapon);

            return(matchingWeapon);
        }
예제 #3
0
        private async Task <EFWeaponAttachment> GetOrAddAttachment(AttachmentInfo attachment, Reference.Game game)
        {
            var matchingAttachment = (await _attachmentCache
                                      .FirstAsync(attach => attach.Name == attachment.Name && attach.Game == game));

            if (matchingAttachment != null)
            {
                return(matchingAttachment);
            }

            matchingAttachment = new EFWeaponAttachment()
            {
                Name = attachment.Name,
                Game = game
            };

            matchingAttachment = await _attachmentCache.AddAsync(matchingAttachment);

            return(matchingAttachment);
        }
예제 #4
0
        private async Task <EFHitLocation> GetOrAddHitLocation(string location, Reference.Game game)
        {
            var matchingLocation = (await _hitLocationCache
                                    .FirstAsync(loc => loc.Name == location && loc.Game == game));

            if (matchingLocation != null)
            {
                return(matchingLocation);
            }

            var hitLocation = new EFHitLocation()
            {
                Name = location,
                Game = game
            };

            hitLocation = await _hitLocationCache.AddAsync(hitLocation);

            return(hitLocation);
        }
예제 #5
0
        private async Task <EFWeaponAttachmentCombo> GetOrAddAttachmentCombo(EFWeaponAttachment[] attachments,
                                                                             Reference.Game game)
        {
            if (!attachments.Any())
            {
                return(null);
            }

            var allAttachments = attachments.ToList();

            if (allAttachments.Count() < 3)
            {
                for (var i = allAttachments.Count(); i <= 3; i++)
                {
                    allAttachments.Add(null);
                }
            }

            var matchingAttachmentCombo = (await _attachmentComboCache.FirstAsync(combo =>
                                                                                  combo.Game == game &&
                                                                                  combo.Attachment1Id == allAttachments[0].Id &&
                                                                                  combo.Attachment2Id == allAttachments[1]?.Id &&
                                                                                  combo.Attachment3Id == allAttachments[2]?.Id));

            if (matchingAttachmentCombo != null)
            {
                return(matchingAttachmentCombo);
            }

            matchingAttachmentCombo = new EFWeaponAttachmentCombo()
            {
                Game          = game,
                Attachment1Id = (int)allAttachments[0].Id,
                Attachment2Id = (int?)allAttachments[1]?.Id,
                Attachment3Id = (int?)allAttachments[2]?.Id,
            };

            matchingAttachmentCombo = await _attachmentComboCache.AddAsync(matchingAttachmentCombo);

            return(matchingAttachmentCombo);
        }