private void HandleBlueprintListPageResponse(int responseID) { DialogResponse response = GetResponseByID("BlueprintListPage", responseID); int blueprintID = (int)response.CustomData; if (blueprintID == -1) { ChangePage("CraftCategoriesPage"); return; } var model = CraftService.GetPlayerCraftingData(GetPC()); model.Blueprint = CraftService.GetBlueprintByID(blueprintID); model.BlueprintID = blueprintID; model.PlayerSkillRank = SkillService.GetPCSkillRank(GetPC(), model.Blueprint.SkillID); model.MainMinimum = model.Blueprint.MainMinimum; model.MainMaximum = model.Blueprint.MainMaximum; model.SecondaryMinimum = model.Blueprint.SecondaryMinimum; model.SecondaryMaximum = model.Blueprint.SecondaryMaximum; model.TertiaryMinimum = model.Blueprint.TertiaryMinimum; model.TertiaryMaximum = model.Blueprint.TertiaryMaximum; string header = CraftService.BuildBlueprintHeader(GetPC(), blueprintID, false); SetPageHeader("BlueprintDetailsPage", header); ChangePage("BlueprintDetailsPage"); }
public void OnConcentrationTick(NWCreature creature, NWObject target, int spellTier, int tick) { int amount; switch (spellTier) { case 1: amount = 5; break; case 2: amount = 6; break; case 3: amount = 7; break; case 4: amount = 8; break; case 5: amount = 10; break; default: throw new ArgumentOutOfRangeException(nameof(spellTier)); } var result = CombatService.CalculateAbilityResistance(creature, target.Object, SkillType.ForceAlter, ForceBalanceType.Dark); // +/- percent change based on resistance float delta = 0.01f * result.Delta; amount = amount + (int)(amount * delta); if (target.GetLocalInt("FORCE_DRAIN_IMMUNITY") == 1) { amount = 0; } creature.AssignCommand(() => { _.ApplyEffectToObject(DurationType.Instant, _.EffectDamage(amount, DamageType.Negative), target); }); // Only apply a heal if caster is not at max HP. Otherwise they'll get unnecessary spam. if (creature.CurrentHP < creature.MaxHP) { _.ApplyEffectToObject(DurationType.Instant, _.EffectHeal(amount), creature); } if (creature.IsPlayer) { SkillService.RegisterPCToNPCForSkill(creature.Object, target, SkillType.ForceAlter); } _.ApplyEffectToObject(DurationType.Instant, _.EffectVisualEffect(VisualEffect.Vfx_Com_Hit_Negative), target); }
public void InsertSkillByIdProfile_InvalidSkillObject_ShouldBeThrownValidationException() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); SkillService service = new SkillService(uow.Object); service.Insert(null); }
public void UpdateSkillByIdProfile_InvalidSkillObject_ShouldBeThrownValidationException() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); SkillService service = new SkillService(uow.Object); service.Update(It.IsAny <int>(), null); }
public void UpdateSkillOfProgrammer_ProgrammerSkillObjectInvalid_ShouldBeThrownValidationException() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); SkillService service = new SkillService(uow.Object); service.UpdateSkillOfProgrammer(1, null); }
public void InsertSkillToProgrammer_InvalidProgrammerSkillObject_ShouldBeThrownValidationException() { Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); SkillService service = new SkillService(uow.Object); service.InsertSkillToProgrammer(null); }
public void OnImpact(NWPlayer player, NWObject target, int perkLevel, int spellFeatID) { var spread = CustomEffectService.GetForceSpreadDetails(player); int skillRank = SkillService.GetPCSkillRank(player, SkillType.ForceSupport); if (spread.Level <= 0) { HealTarget(player, target, perkLevel, skillRank, (CustomFeatType)spellFeatID); } else { var members = player.PartyMembers.Where(x => _.GetDistanceBetween(x, target) <= spread.Range || Equals(x, target)); spread.Uses--; foreach (var member in members) { HealTarget(player, member, perkLevel, skillRank, (CustomFeatType)spellFeatID); } CustomEffectService.SetForceSpreadUses(player, spread.Uses); SkillService.RegisterPCToAllCombatTargetsForSkill(player, SkillType.ForceUtility, null); } _.PlaySound("v_imp_heal"); SkillService.RegisterPCToAllCombatTargetsForSkill(player, SkillType.ForceSupport, target.Object); }
protected override void InitializeInternal(SkillService skillService, IBattleUnit attacker) { _attackManager = new AttackManager(attacker) { AttackerDamageFactory = a => Convert.ToInt64(a.GetDamage() * DamageKoef) + BonusDamage }; }
private void ApplyEffect(NWCreature creature, NWObject target, int spellTier) { float radiusSize = _.RADIUS_SIZE_SMALL; Effect confusionEffect = _.EffectConfused(); // Handle effects for differing spellTier values switch (spellTier) { case 1: if ((creature.Wisdom > _.GetAbilityModifier(_.ABILITY_WISDOM, target) || creature == target) && _.GetDistanceBetween(creature.Object, target) <= radiusSize) { creature.AssignCommand(() => { _.ApplyEffectToObject(_.DURATION_TYPE_TEMPORARY, confusionEffect, target, 6.1f); // Play VFX _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, _.EffectVisualEffect(_.VFX_IMP_CONFUSION_S), target); }); if (creature.IsPlayer) { SkillService.RegisterPCToNPCForSkill(creature.Object, target, SkillType.ForceAlter); } } break; case 2: NWCreature targetCreature = _.GetFirstObjectInShape(_.SHAPE_SPHERE, radiusSize, creature.Location, 1, _.OBJECT_TYPE_CREATURE); while (targetCreature.IsValid) { if (targetCreature.RacialType == (int)CustomRaceType.Robot || _.GetIsReactionTypeHostile(targetCreature, creature) == 0) { // Do nothing against droids or non-hostile creatures, skip object targetCreature = _.GetNextObjectInShape(_.SHAPE_SPHERE, radiusSize, creature.Location, 1, _.OBJECT_TYPE_CREATURE); continue; } if (creature.Wisdom > targetCreature.Wisdom) { var targetCreatureCopy = targetCreature; // Closure can modify the iteration variable so we copy it first. creature.AssignCommand(() => { _.ApplyEffectToObject(_.DURATION_TYPE_TEMPORARY, confusionEffect, targetCreatureCopy, 6.1f); // Play VFX _.ApplyEffectToObject(_.DURATION_TYPE_INSTANT, _.EffectVisualEffect(_.VFX_IMP_CONFUSION_S), targetCreatureCopy); }); if (creature.IsPlayer) { SkillService.RegisterPCToNPCForSkill(creature.Object, targetCreature, SkillType.ForceAlter); } } targetCreature = _.GetNextObjectInShape(_.SHAPE_SPHERE, radiusSize, creature.Location, 1, _.OBJECT_TYPE_CREATURE); } break; default: throw new ArgumentOutOfRangeException(nameof(spellTier)); } }
private SkillService CreateSkillService() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new SkillService(); return(service); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { Location effectLocation; NWPlayer player = (user.Object); // Targeted a location or self. Locate nearest resource. if (!target.IsValid || Equals(user, target)) { ScanArea(user, targetLocation); DurabilityService.RunItemDecay(player, item, RandomService.RandomFloat(0.02f, 0.08f)); effectLocation = targetLocation; } else if (!string.IsNullOrWhiteSpace(target.GetLocalString("RESOURCE_RESREF"))) { ScanResource(user, target); DurabilityService.RunItemDecay(player, item, RandomService.RandomFloat(0.05f, 0.1f)); effectLocation = target.Location; } else { user.FloatingText("You cannot scan that object with this type of scanner."); return; } _.ApplyEffectAtLocation(DURATION_TYPE_INSTANT, _.EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3), effectLocation); if (user.IsPlayer && user.GetLocalInt(target.GlobalID.ToString()) == FALSE) { int scanningBonus = item.ScanningBonus; SkillService.GiveSkillXP(player, SkillType.Harvesting, 150); user.SetLocalInt(target.GlobalID.ToString(), 1 + scanningBonus); } }
public string IsValidTarget(NWCreature user, NWItem item, NWObject target, Location targetLocation) { if (!target.IsValid) { return("Please select a target to harvest."); } int qualityID = target.GetLocalInt("RESOURCE_QUALITY"); if (qualityID <= 0) { return("You cannot harvest that object."); } NWPlayer player = (user.Object); ResourceQuality quality = (ResourceQuality)qualityID; int tier = target.GetLocalInt("RESOURCE_TIER"); int rank = SkillService.GetPCSkillRank(player, SkillType.Harvesting); int difficulty = (tier - 1) * 10 + ResourceService.GetDifficultyAdjustment(quality); int delta = difficulty - rank; if (delta >= 5) { return("Your Harvesting skill rank is too low to harvest this resource."); } return(null); }
public void AddAndRetieveSkill() { //Arrange var context = GetSqlLiteContext(); var cvService = new CvService(new CvRepository(context), new Mapper().GetMapper()); var skillService = new SkillService(new SkillRepository(context), new Mapper().GetMapper()); var cv = new Cv() { Name = Constants.CvName, TagLine = Constants.CvTagLine, Blurb = Constants.CvBlurb }; var cvId = cvService.Add(cv, Constants.RootUrl).Id; //Act var skill = new Skill() { Name = "Continuous Delivery", Blurb = "Awesome at CI and CD", Order = 12 }; var newSkill = skillService.AddToCv(skill, cvId, Constants.RootUrl); //Assert var skills = skillService.GetForCv(cvId, Constants.RootUrl); var result = skills[0]; Assert.AreEqual(skill.Name, result.Name); Assert.AreEqual(skill.Blurb, result.Blurb); Assert.AreEqual(skill.Order, result.Order); Assert.AreEqual(cvId, result.CvId); }
public ExceptionTest() { MongoDBUtility mongoDBUtility = new MongoDBUtility(); context = mongoDBUtility.MongoDBContext; _userRepository = new UserRepository(context); _skillRepository = new SkillRepository(context); _userService = new UserService(_userRepository); _skillService = new SkillService(_skillRepository); _skill = new Skill { SkillName = ".Net core 3.1", SkillCategory = SkillCategory.DotNet, SkillLevel = SkillLevel.Intermediate, SkillType = SkillType.Programming, SkillTotalExperiance = 1 }; _user = new User { FirstName = "Dnyati", LastName = "Dube", Email = "*****@*****.**", Mobile = 9685744263, }; config = new ConfigurationBuilder().AddJsonFile("appsettings.test.json").Build(); }
public ActionResult DeleteSkill(SkillModel model) { try { #region " [ Declaration ] " SkillService _service = new SkillService(); #endregion #region " [ Main process ] " model.CreateBy = UserID; model.DeleteBy = UserID; model.DeleteDate = DateTime.Now; #endregion //Call to service return(this.Json(_service.Delete(model), JsonRequestBehavior.AllowGet)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, "DeleteSkill", UserID, ex); } }
public JsonResult GetSkillItem(Guid id) { try { #region " [ Declaration ] " SkillService _service = new SkillService(); #endregion #region " [ Main processing ] " var model = _service.GetItemByID(new SkillModel() { ID = id, CreateBy = UserID }); #endregion return(this.Json(model, JsonRequestBehavior.AllowGet)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, "GetSkillItem", UserID, ex); } }
public void UpdateSkills() { //Arrange var context = GetSqlLiteContext(); var cvService = new CvService(new CvRepository(context), new Mapper().GetMapper()); var skillService = new SkillService(new SkillRepository(context), new Mapper().GetMapper()); var cv = new Cv() { Name = Constants.CvName, TagLine = Constants.CvTagLine, Blurb = Constants.CvBlurb }; var cvId = cvService.Add(cv, Constants.RootUrl).Id; var skill = new Skill() { Name = "Continuous Delivery", Blurb = "Awesome at CI and CD", Order = 12 }; var newSkill = skillService.AddToCv(skill, cvId, Constants.RootUrl); var skillId = newSkill.Id; //Act var skillUpdate = new Skill() { Name = "C#", Blurb = "Been using it since 2001.", Order = 24 }; skillService.Update(skillId, skillUpdate); //Assert var result = skillService.Get(skillId, Constants.RootUrl); Assert.AreEqual(skillUpdate.Name, result.Name); Assert.AreEqual(skillUpdate.Blurb, result.Blurb); Assert.AreEqual(skillUpdate.Order, result.Order); Assert.AreEqual(cvId, result.CvId); }
public async Task AddSkill_WithValidData_ToExistingResume_WorksCorrectly() { var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var model = new Resume() { JobSeeker = new JobSeeker() { FirstName = "JobSeekerName1", LastName = "JobSeekerName2", User = new User() { UserName = "******" } } }; await context.AddAsync(model); context.SaveChanges(); var serviceModel = new SkillServiceModel() { Name = "SkillName1" }; var skillService = new SkillService(new EfRepository <Resume>(context), new EfRepository <Skill>(context)); var result = await skillService.AddSkill(model.Id, serviceModel); Assert.True(result); }
public AlexaController() { _signalRClientMethodsHelper = new SignalRClientMethodsHelper(); _employeeService = new EmployeeService(); _skillService = new SkillService(); _projectService = new ProjectService(); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { Location effectLocation; NWPlayer player = (user.Object); if (!string.IsNullOrWhiteSpace(target.GetLocalString("RESOURCE_RESREF"))) { ScanResource(user, target); DurabilityService.RunItemDecay(player, item, RandomService.RandomFloat(0.05f, 0.1f)); effectLocation = target.Location; } else { user.FloatingText("You cannot scan that object with this type of scanner."); return; } _.ApplyEffectAtLocation(DurationType.Instant, _.EffectVisualEffect(VisualEffect.Vfx_Fnf_Summon_Monster_3), effectLocation); if (user.IsPlayer && GetLocalBool(user, target.GlobalID.ToString()) == false) { int scanningBonus = item.ScanningBonus; SkillService.GiveSkillXP(player, SkillType.Harvesting, 150); user.SetLocalInt(target.GlobalID.ToString(), 1 + scanningBonus); } }
public IHttpActionResult Get(int id) { SkillService skillService = CreateSkillService(); var skill = skillService.GetSkillById(id); return(Ok(skill)); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { CustomEffectService.RemovePCCustomEffect(target.Object, CustomEffectType.Poison); foreach (Effect effect in target.Effects) { if (_.GetIsEffectValid(effect) == true) { var effectType = _.GetEffectType(effect); if (effectType == EffectTypeScript.Poison || effectType == EffectTypeScript.Disease || effectType == EffectTypeScript.AbilityDecrease) { _.RemoveEffect(target.Object, effect); } } } user.SendMessage("You successfully treat " + target.Name + "'s infection."); int rank = SkillService.GetPCSkillRank(user.Object, SkillType.Medicine); if (target.IsPlayer) { int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(300, item.RecommendedLevel, rank); SkillService.GiveSkillXP(user.Object, SkillType.Medicine, xp); } }
public async Task CreateSkillTest() { // Arrange var client = SetupMock_Skill(); var config = new Mock <IConfiguration>(); client.BaseAddress = new Uri("https://localhost:1111/"); config.SetupGet(s => s["SkillsURL"]).Returns("https://localhost:1111/"); var service = new SkillService(null, new NullLogger <SkillService>(), config.Object) { Client = client }; // Act var newSkill = new SkillDTO { Id = 9, XpCost = 5, Name = "NEWSKILL" }; var result = await service.CreateSkill(newSkill); // Assert Assert.IsNotNull(result); Assert.AreEqual(newSkill.Id, result.Id); Assert.AreEqual(newSkill.Name, result.Name); Assert.AreEqual(newSkill.XpCost, result.XpCost); }
public IHttpActionResult GetAll() { SkillService skillService = CreateSkillService(); var skills = skillService.GetSkills(); return(Ok(skills)); }
public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData) { NWArea area = user.Area; NWPlayer player = new NWPlayer(user); string structureID = area.GetLocalString("PC_BASE_STRUCTURE_ID"); Guid structureGuid = new Guid(structureID); PCBaseStructure pcbs = DataService.PCBaseStructure.GetByID(structureGuid); BaseStructure structure = DataService.BaseStructure.GetByID(pcbs.BaseStructureID); int repair = SkillService.GetPCSkillRank(player, SkillType.Piloting); int maxRepair = (int)structure.Durability - (int)pcbs.Durability; if (maxRepair < repair) { repair = maxRepair; } // TODO - add perks to make repairing faster/better/shinier/etc. // Maybe a perk to allow repairing in space, with ground repairs only otherwise? NWCreature ship = area.GetLocalObject("CREATURE"); if (ship.IsValid) { ship.SetLocalInt("HP", ship.GetLocalInt("HP") + repair); ship.FloatingText("Hull repaired: " + ship.GetLocalInt("HP") + "/" + ship.MaxHP); } pcbs.Durability += repair; DataService.SubmitDataChange(pcbs, DatabaseActionType.Update); player.SendMessage("Ship repaired for " + repair + " points. (Hull points: " + pcbs.Durability + "/" + structure.Durability + ")"); }
public async Task GetAllTest() { // Arrange var client = SetupMock_Skill(); var config = new Mock <IConfiguration>(); client.BaseAddress = new Uri("https://localhost:1111/"); config.SetupGet(s => s["SkillsURL"]).Returns("https://localhost:1111/"); var service = new SkillService(null, new NullLogger <SkillService>(), config.Object) { Client = client }; // Act var result = await service.GetAll(); // Assert Assert.IsNotNull(result); foreach (var skill in result) { var testItem = TestData.Skills().FirstOrDefault(s => s.Id == skill.Id); Assert.AreEqual(testItem.Name, skill.Name); Assert.AreEqual(testItem.XpCost, skill.XpCost); } }
public async Task AddSkill_ToNonExistingResume_ReturnsFalse() { var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var model = new Resume() { JobSeeker = new JobSeeker() { FirstName = "JobSeekerName1", LastName = "JobSeekerName2", User = new User() { UserName = "******" } } }; var serviceModel = new SkillServiceModel(); var skillService = new SkillService(new EfRepository <Resume>(context), new EfRepository <Skill>(context)); var result = await skillService.AddSkill(model.Id, serviceModel); Assert.False(result); }
public JsonResult GetSkillByGroup(Guid groupID) { try { #region " [ Declaration ] " SkillService _service = new SkillService(); #endregion #region " [ Main processing ] " var model = _service.GetAll(groupID, UserID); #endregion return(this.Json(model, JsonRequestBehavior.AllowGet)); } catch (ServiceException serviceEx) { throw serviceEx; } catch (DataAccessException accessEx) { throw accessEx; } catch (Exception ex) { throw new ControllerException(FILE_NAME, "GetSkillByGroup", UserID, ex); } }
public async Task UpdateAsync_WithInvalidData_ReturnsTrue() { string expectedResult = "Skill1"; var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var model = new Skill() { Name = expectedResult, Resume = new Resume() }; await context.AddAsync(model); context.SaveChanges(); var serviceModel = new SkillServiceModel() { Id = model.Id, }; var skillService = new SkillService(new EfRepository <Resume>(context), new EfRepository <Skill>(context)); var result = await skillService.UpdateAsync(serviceModel); Assert.False(result); var actualResult = (await context.Skills.SingleAsync(s => s.Id == model.Id)).Name; Assert.Equal(expectedResult, actualResult); }
public async Task RemoveExistingSkill_ReturnsTrue() { var context = new JobFinderDbContext(new DbContextOptionsBuilder <JobFinderDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options); var model = new Skill() { Name = "Skill1", Resume = new Resume() }; await context.AddAsync(model); context.SaveChanges(); var skillService = new SkillService(new EfRepository <Resume>(context), new EfRepository <Skill>(context)); var result = await skillService.RemoveSkill(model.Id); Assert.True(result); var dbModels = await context.Skills.AnyAsync(); Assert.False(dbModels); }
public static ISkillService<Skill> GetSkill() { ISkillService<SkillSmart.Dto.Skill> serviceObj = null; switch (sectionHandler.ConnectionStringName) { case DataBaseType.SKILLSMART_MONGO_DB: serviceObj = new SkillService(DatabaseFactory.CreateMongoDatabase()); break; default: serviceObj = new SkillService(DatabaseFactory.CreateMongoDatabase()); break; } return serviceObj; }
public SkillsController(IContextManager contextManager) { _fullService = new SkillService(contextManager); }