Exemple #1
0
        public GqlHeroVoiceActor(FehContextFactory dbContextFactory, IDataLoaderContextAccessor accessor)
        {
            this.Name = nameof(HeroVoiceActor);

            this.Field(nameof(HeroVoiceActor.HeroId), x => x.HeroId);
            this.Field(nameof(HeroVoiceActor.Id), x => x.Id);
            this.Field(nameof(HeroVoiceActor.Language), x => (int)x.Language);
            this.Field(nameof(HeroVoiceActor.Sort), x => x.Sort);
            this.Field(nameof(HeroVoiceActor.VoiceActorId), x => x.VoiceActorId);

            /* Data Loader */

            this
            .Field <GqlVoiceActor, VoiceActor>()
            .Name(nameof(HeroVoiceActor.VoiceActor))
            .ResolveAsync(
                (context) =>
            {
                var service = new VoiceActorService(dbContextFactory.CreateDbContext());

                var loader = accessor.Context.GetOrAddBatchLoader <int, VoiceActor>(
                    $"{nameof(VoiceActor)}_{nameof(VoiceActorService.GetByIdsAsync)}",
                    service.GetByIdsAsync
                    );

                return(loader.LoadAsync(context.Source.VoiceActorId));
            }
                );
        }
Exemple #2
0
        public GqlHeroSkill(FehContextFactory dbContextFactory, IDataLoaderContextAccessor accessor)
        {
            this.Name = nameof(HeroSkill);

            this.Field(nameof(HeroSkill.DefaultRarity), x => x.DefaultRarity, nullable: true);
            this.Field(nameof(HeroSkill.HeroId), x => x.HeroId);
            this.Field(nameof(HeroSkill.Id), x => x.Id);
            this.Field(nameof(HeroSkill.SkillId), x => x.SkillId);
            this.Field(nameof(HeroSkill.SkillPosition), x => x.SkillPosition);
            this.Field(nameof(Skill.SkillType), x => (int)x.Skill.SkillType);
            this.Field(nameof(HeroSkill.UnlockRarity), x => x.UnlockRarity);

            /* Data Loader */

            this
            .Field <GqlSkill, Skill>()
            .Name(nameof(HeroSkill.Skill))
            .ResolveAsync(
                (context) =>
            {
                var service = new SkillService(dbContextFactory.CreateDbContext());

                var loader = accessor.Context.GetOrAddBatchLoader <Guid, Skill>(
                    $"{nameof(Skill)}_{nameof(SkillService.GetByIdsAsync)}",
                    service.GetByIdsAsync
                    );

                return(loader.LoadAsync(context.Source.SkillId));
            }
                );
        }
        public ExtractHeroAssetsScript(FehContextFactory dbContextFactory, string sourceDirectory, string targetDirectory, bool overwrite = false)
        {
            this._dbContext = dbContextFactory.CreateDbContext();

            this._sourceDirectory = sourceDirectory;
            this._targetDirectory = targetDirectory;

            this._overwrite = overwrite;
        }
        public ImportHeroesScript(FehContextFactory dbContextFactory, string sourceFile)
        {
            this._dbContext = dbContextFactory.CreateDbContext();

            this._sourceFiile = sourceFile;

            this._artistMap = this._dbContext
                              .Artists
                              .ToDictionaryAsync(
                x => x.Name.ToLower(),
                y => y
                )
                              .Result;
        }
Exemple #5
0
        public ImportHeroSkillsScript(FehContextFactory dbContextFactory, string sourceFile)
        {
            this._dbContext = dbContextFactory.CreateDbContext();

            this._sourceFiile = sourceFile;

            this._heroMap = this._dbContext
                            .Heroes
                            .ToDictionaryAsync(
                x => x.Tag,
                y => y
                )
                            .Result;

            this._skillMap = this._dbContext
                             .Skills
                             .ToDictionaryAsync(
                x => x.Tag,
                y => y
                )
                             .Result;
        }
Exemple #6
0
        public ImportVoiceActorsScript(FehContextFactory dbContextFactory, string sourceFile)
        {
            this._dbContext = dbContextFactory.CreateDbContext();

            this._sourceFiile = sourceFile;
        }
Exemple #7
0
        public GqlSkill(FehContextFactory dbContextFactory, IDataLoaderContextAccessor accessor)
        {
            this.Name = nameof(Skill);

            this.Field(nameof(Skill.AttackModifier), x => x.AttackModifier, nullable: true);
            this.Field(nameof(Skill.Cooldown), x => x.Cooldown, nullable: true);
            this.Field(nameof(Skill.CreatedAt), x => x.CreatedAt, type: typeof(DateTimeGraphType));
            this.Field(nameof(Skill.CreatedBy), x => x.CreatedBy);
            this.Field(nameof(Skill.DefenseModifier), x => x.DefenseModifier, nullable: true);
            this.Field(nameof(Skill.Description), x => x.Description, nullable: true);
            this.Field(nameof(Skill.GroupName), x => x.GroupName);
            this.Field(nameof(Skill.HitPointsModifier), x => x.HitPointsModifier, nullable: true);
            this.Field(nameof(Skill.Id), x => x.Id);
            this.Field(nameof(Skill.IsAvailableAsSacredSeal), x => x.IsAvailableAsSacredSeal);
            this.Field(nameof(Skill.IsExclusive), x => x.IsExclusive);
            this.Field(nameof(Skill.Might), x => x.Might, nullable: true);
            this.Field(nameof(Skill.ModifiedAt), x => x.ModifiedAt, type: typeof(DateTimeGraphType));
            this.Field(nameof(Skill.ModifiedBy), x => x.ModifiedBy);
            this.Field(nameof(Skill.Name), x => x.Name);
            this.Field(nameof(Skill.Range), x => x.Range, nullable: true);
            this.Field(nameof(Skill.ResistanceModifier), x => x.ResistanceModifier, nullable: true);
            this.Field(nameof(Skill.SkillPoints), x => x.SkillPoints);
            this.Field(nameof(Skill.SkillType), x => (int)x.SkillType);
            this.Field(nameof(Skill.SpeedModifier), x => x.SpeedModifier, nullable: true);
            this.Field(nameof(Skill.Tag), x => x.Tag);
            this.Field(nameof(Skill.Version), x => x.Version);
            this.Field(nameof(Skill.WeaponRefineType), x => (int?)x.WeaponRefineType, nullable: true);

            /* Data Loader */

            this
            .Field <ListGraphType <GqlSkillMovementType>, IEnumerable <SkillMovementType> >()
            .Name(nameof(Skill.SkillMovementTypes))
            .ResolveAsync(
                (context) =>
            {
                var service = new SkillMovementTypeService(dbContextFactory.CreateDbContext());

                var loader = accessor.Context.GetOrAddCollectionBatchLoader <Guid, SkillMovementType>(
                    $"{nameof(SkillMovementType)}_{nameof(SkillMovementTypeService.GetBySkillIdsAsync)}",
                    service.GetBySkillIdsAsync
                    );

                return(loader.LoadAsync(context.Source.Id));
            }
                );

            this
            .Field <ListGraphType <GqlSkillWeaponEffectiveness>, IEnumerable <SkillWeaponEffectiveness> >()
            .Name(nameof(Skill.SkillWeaponEffectivenesses))
            .ResolveAsync(
                (context) =>
            {
                var service = new SkillWeaponEffectivenessService(dbContextFactory.CreateDbContext());

                var loader = accessor.Context.GetOrAddCollectionBatchLoader <Guid, SkillWeaponEffectiveness>(
                    $"{nameof(SkillWeaponEffectiveness)}_{nameof(SkillWeaponEffectivenessService.GetBySkillIdsAsync)}",
                    service.GetBySkillIdsAsync
                    );

                return(loader.LoadAsync(context.Source.Id));
            }
                );

            this
            .Field <ListGraphType <GqlSkillWeaponType>, IEnumerable <SkillWeaponType> >()
            .Name(nameof(Skill.SkillWeaponTypes))
            .ResolveAsync(
                (context) =>
            {
                var service = new SkillWeaponTypeService(dbContextFactory.CreateDbContext());

                var loader = accessor.Context.GetOrAddCollectionBatchLoader <Guid, SkillWeaponType>(
                    $"{nameof(SkillWeaponType)}_{nameof(SkillWeaponTypeService.GetBySkillIdsAsync)}",
                    service.GetBySkillIdsAsync
                    );

                return(loader.LoadAsync(context.Source.Id));
            }
                );
        }
Exemple #8
0
        public GqlQuery(FehContextFactory dbContextFactory)
        {
            this
            .Field <ListGraphType <GqlAccessory>, List <Accessory> >()
            .Name("accessories")
            .ResolveAsync(
                (context) =>
            {
                var service = new AccessoryService(dbContextFactory.CreateDbContext());

                return(service.GetAllAsync());
            }
                );

            this
            .Field <GqlAccessory, Accessory>()
            .Name("accessory")
            .Argument <NonNullGraphType <GuidGraphType> >("id")
            .ResolveAsync(
                (context) =>
            {
                var id = context.GetArgument <Guid>("id");

                var service = new AccessoryService(dbContextFactory.CreateDbContext());

                return(service.GetByIdAsync(id));
            }
                );

            this
            .Field <ListGraphType <GqlArtist>, List <Artist> >()
            .Name("artists")
            .ResolveAsync(
                (context) =>
            {
                var service = new ArtistService(dbContextFactory.CreateDbContext());

                return(service.GetAllAsync());
            }
                );

            this
            .Field <GqlArtist, Artist>()
            .Name("artist")
            .Argument <NonNullGraphType <IntGraphType> >("id")
            .ResolveAsync(
                (context) =>
            {
                var id = context.GetArgument <int>("id");

                var service = new ArtistService(dbContextFactory.CreateDbContext());

                return(service.GetByIdAsync(id));
            }
                );

            this
            .Field <GqlEnumerations>()
            .Name("enumerations")
            .Resolve(x => new { });

            this
            .Field <ListGraphType <GqlHero>, List <Hero> >()
            .Name("heroes")
            .ResolveAsync(
                (context) =>
            {
                var service = new HeroService(dbContextFactory.CreateDbContext());

                return(service.GetAllAsync());
            }
                );

            this
            .Field <GqlHero, Hero>()
            .Name("hero")
            .Argument <NonNullGraphType <GuidGraphType> >("id")
            .ResolveAsync(
                (context) =>
            {
                var id = context.GetArgument <Guid>("id");

                var service = new HeroService(dbContextFactory.CreateDbContext());

                return(service.GetByIdAsync(id));
            }
                );

            this
            .Field <ListGraphType <GqlItem>, List <Item> >()
            .Name("items")
            .ResolveAsync(
                (context) =>
            {
                var service = new ItemService(dbContextFactory.CreateDbContext());

                return(service.GetAllAsync());
            }
                );

            this
            .Field <GqlItem, Item>()
            .Name("item")
            .Argument <NonNullGraphType <GuidGraphType> >("id")
            .ResolveAsync(
                (context) =>
            {
                var id = context.GetArgument <Guid>("id");

                var service = new ItemService(dbContextFactory.CreateDbContext());

                return(service.GetByIdAsync(id));
            }
                );

            this
            .Field <ListGraphType <GqlSkill>, List <Skill> >()
            .Name("skills")
            .ResolveAsync(
                (context) =>
            {
                var service = new SkillService(dbContextFactory.CreateDbContext());

                return(service.GetAllAsync());
            }
                );

            this
            .Field <GqlSkill, Skill>()
            .Name("skill")
            .Argument <NonNullGraphType <GuidGraphType> >("id")
            .ResolveAsync(
                (context) =>
            {
                var id = context.GetArgument <Guid>("id");

                var service = new SkillService(dbContextFactory.CreateDbContext());

                return(service.GetByIdAsync(id));
            }
                );

            this
            .Field <ListGraphType <GqlVoiceActor>, List <VoiceActor> >()
            .Name("voiceActors")
            .ResolveAsync(
                (context) =>
            {
                var service = new VoiceActorService(dbContextFactory.CreateDbContext());

                return(service.GetAllAsync());
            }
                );

            this
            .Field <GqlVoiceActor, VoiceActor>()
            .Name("voiceActor")
            .Argument <NonNullGraphType <IntGraphType> >("id")
            .ResolveAsync(
                (context) =>
            {
                var id = context.GetArgument <int>("id");

                var service = new VoiceActorService(dbContextFactory.CreateDbContext());

                return(service.GetByIdAsync(id));
            }
                );
        }
Exemple #9
0
        public GqlHero(FehContextFactory dbContextFactory, IDataLoaderContextAccessor accessor)
        {
            this.Name = nameof(Hero);

            this.Field(nameof(Hero.AdditionDate), x => x.AdditionDate);
            this.Field(nameof(Hero.ArtistId), x => x.ArtistId);
            this.Field(nameof(Hero.AttackGrowthRate), x => x.AttackGrowthRate);
            this.Field(nameof(Hero.BaseAttack), x => x.BaseAttack);
            this.Field(nameof(Hero.BaseDefense), x => x.BaseDefense);
            this.Field(nameof(Hero.BaseHitPoints), x => x.BaseHitPoints);
            this.Field(nameof(Hero.BaseResistance), x => x.BaseResistance);
            this.Field(nameof(Hero.BaseSpeed), x => x.BaseSpeed);
            this.Field(nameof(Hero.BVID).ToLowerInvariant(), x => x.BVID);
            this.Field(nameof(Hero.Color), x => (int)x.Color);
            this.Field(nameof(Hero.CreatedAt), x => x.CreatedAt, type: typeof(DateTimeGraphType));
            this.Field(nameof(Hero.CreatedBy), x => x.CreatedBy);
            this.Field(nameof(Hero.DefenseGrowthRate), x => x.DefenseGrowthRate);
            this.Field(nameof(Hero.Description), x => x.Description);
            this.Field(nameof(Hero.Element), x => (int?)x.Element, nullable: true);
            this.Field(nameof(Hero.Gender), x => (int)x.Gender);
            this.Field(nameof(Hero.HitPointsGrowthRate), x => x.HitPointsGrowthRate);
            this.Field(nameof(Hero.Id), x => x.Id);
            this.Field(nameof(Hero.IsDuoHero), x => x.IsDuoHero);
            this.Field(nameof(Hero.IsLegendaryHero), x => x.IsLegendaryHero);
            this.Field(nameof(Hero.IsMythicHero), x => x.IsMythicHero);
            this.Field(nameof(Hero.IsResplendentHero), x => x.IsResplendentHero);
            this.Field(nameof(Hero.LegendaryHeroBoostType), x => (int?)x.LegendaryHeroBoostType, nullable: true);
            this.Field(nameof(Hero.ModifiedAt), x => x.ModifiedAt, type: typeof(DateTimeGraphType));
            this.Field(nameof(Hero.ModifiedBy), x => x.ModifiedBy);
            this.Field(nameof(Hero.MovementType), x => (int)x.MovementType);
            this.Field(nameof(Hero.MythicHeroBoostType), x => (int?)x.MythicHeroBoostType, nullable: true);
            this.Field(nameof(Hero.Name), x => x.Name);
            this.Field(nameof(Hero.Origin), x => x.Origin);
            this.Field(nameof(Hero.ReleaseDate), x => x.ReleaseDate);
            this.Field(nameof(Hero.ResistanceGrowthRate), x => x.ResistanceGrowthRate);
            this.Field(nameof(Hero.SpeedGrowthRate), x => x.SpeedGrowthRate);
            this.Field(nameof(Hero.Tag), x => x.Tag);
            this.Field(nameof(Hero.Title), x => x.Title);
            this.Field(nameof(Hero.Version), x => x.Version);
            this.Field(nameof(Hero.Weapon), x => (int)x.Weapon);

            /* Data Loader */

            this
            .Field <GqlArtist, Artist>()
            .Name(nameof(Hero.Artist))
            .ResolveAsync(
                (context) =>
            {
                var service = new ArtistService(dbContextFactory.CreateDbContext());

                var loader = accessor.Context.GetOrAddBatchLoader <int, Artist>(
                    $"{nameof(Artist)}_{nameof(ArtistService.GetByIdsAsync)}",
                    service.GetByIdsAsync
                    );

                return(loader.LoadAsync(context.Source.ArtistId));
            }
                );

            this
            .Field <ListGraphType <GqlHeroSkill>, IEnumerable <HeroSkill> >()
            .Name(nameof(Hero.HeroSkills))
            .ResolveAsync(
                (context) =>
            {
                var service = new HeroSkillService(dbContextFactory.CreateDbContext());

                var loader = accessor.Context.GetOrAddCollectionBatchLoader <Guid, HeroSkill>(
                    $"{nameof(HeroSkill)}_{nameof(HeroSkillService.GetByHeroIdsAsync)}",
                    service.GetByHeroIdsAsync
                    );

                return(loader.LoadAsync(context.Source.Id));
            }
                );

            this
            .Field <ListGraphType <GqlHeroVoiceActor>, IEnumerable <HeroVoiceActor> >()
            .Name(nameof(Hero.HeroVoiceActors))
            .Argument <NonNullGraphType <IntGraphType> >("language")
            .ResolveAsync(
                (context) =>
            {
                var service = new HeroVoiceActorService(dbContextFactory.CreateDbContext());

                var language = (Languages)context.GetArgument <int>("language");

                var loader = accessor.Context.GetOrAddCollectionBatchLoader(
                    $"{nameof(HeroVoiceActor)}_{nameof(HeroVoiceActorService.GetByHeroIdsAsync)}",
                    service.GetByHeroIdsAsync(language)
                    );

                return(loader.LoadAsync(context.Source.Id));
            }
                );
        }