public void GetByID_OneItem_ReturnsPCSkillPool() { // Arrange var id = Guid.NewGuid(); PCSkillPool entity = new PCSkillPool { ID = id }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <PCSkillPool>(entity)); // Assert Assert.AreNotSame(entity, _cache.GetByID(id)); }
public void GetByID_TwoItems_ReturnsCorrectObject() { // Arrange var id1 = Guid.NewGuid(); var id2 = Guid.NewGuid(); PCSkillPool entity1 = new PCSkillPool { ID = id1 }; PCSkillPool entity2 = new PCSkillPool { ID = id2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <PCSkillPool>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <PCSkillPool>(entity2)); // Assert Assert.AreNotSame(entity1, _cache.GetByID(id1)); Assert.AreNotSame(entity2, _cache.GetByID(id2)); }
public void GetByID_RemovedItem_ReturnsCorrectObject() { // Arrange var id1 = Guid.NewGuid(); var id2 = Guid.NewGuid(); PCSkillPool entity1 = new PCSkillPool { ID = id1 }; PCSkillPool entity2 = new PCSkillPool { ID = id2 }; // Act MessageHub.Instance.Publish(new OnCacheObjectSet <PCSkillPool>(entity1)); MessageHub.Instance.Publish(new OnCacheObjectSet <PCSkillPool>(entity2)); MessageHub.Instance.Publish(new OnCacheObjectDeleted <PCSkillPool>(entity1)); // Assert Assert.Throws <KeyNotFoundException>(() => { _cache.GetByID(id1); }); Assert.AreNotSame(entity2, _cache.GetByID(id2)); }
private static void OnModuleEnter() { NWPlayer player = _.GetEnteringObject(); if (!player.IsPlayer) { return; } var dbPlayer = DataService.Player.GetByID(player.GlobalID); // VERSION 2: Background items are no longer plot because item level no longer dictates your skill XP gain. if (dbPlayer.VersionNumber < 2) { string[] resrefs = { "blaster_s", "rifle_s", "powerglove_t", "baton_s", "doubleaxe_z", "kukri_d", "greatsword_s", "scanner_r_h", "harvest_r_h", "man_armor" }; foreach (var resref in resrefs) { NWItem item = _.GetItemPossessedBy(player, resref); if (item.IsValid) { item.IsPlot = false; } } dbPlayer.VersionNumber = 2; } // VERSION 3: Force feats need to be removed since force powers were reworked. if (dbPlayer.VersionNumber < 3) { // These IDs come from the Feat.2da file. NWNXCreature.RemoveFeat(player, Feat.DeprecatedForceBreach); // Force Breach NWNXCreature.RemoveFeat(player, Feat.DeprecatedForceLightning); // Force Lightning NWNXCreature.RemoveFeat(player, Feat.DeprecatedForceHeal1); // Force Heal NWNXCreature.RemoveFeat(player, Feat.DeprecatedDarkHeal); // Dark Heal NWNXCreature.RemoveFeat(player, Feat.DeprecatedForceSpread); // Force Spread NWNXCreature.RemoveFeat(player, Feat.DeprecatedDarkSpread); // Dark Spread NWNXCreature.RemoveFeat(player, Feat.DeprecatedForcePush); // Force Push NWNXCreature.RemoveFeat(player, Feat.DeprecatedForceAura); // Force Aura NWNXCreature.RemoveFeat(player, Feat.DeprecatedDrainLife); // Drain Life NWNXCreature.RemoveFeat(player, Feat.DeprecatedChainspell); // Chainspell dbPlayer.VersionNumber = 3; } // VERSION 4: Give the Uncanny Dodge 1 feat to all characters. if (dbPlayer.VersionNumber < 4) { NWNXCreature.AddFeatByLevel(player, Feat.UncannyDodge1, 1); dbPlayer.VersionNumber = 4; } // VERSION 5: We're doing another Force rework, so remove any force feats the player may have acquired. if (dbPlayer.VersionNumber < 5) { NWNXCreature.RemoveFeat(player, Feat.DeprecatedForceBreach); // Force Breach NWNXCreature.RemoveFeat(player, Feat.DeprecatedForceLightning); // Force Lightning NWNXCreature.RemoveFeat(player, Feat.DeprecatedForceHeal1); // Force Heal I NWNXCreature.RemoveFeat(player, Feat.DeprecatedAbsorptionField); // Absorption Field NWNXCreature.RemoveFeat(player, Feat.DeprecatedForceSpread); // Force Spread NWNXCreature.RemoveFeat(player, Feat.DeprecatedForcePush); // Force Push NWNXCreature.RemoveFeat(player, Feat.DeprecatedForceAura); // Force Aura NWNXCreature.RemoveFeat(player, Feat.DeprecatedDrainLife); // Drain Life NWNXCreature.RemoveFeat(player, Feat.DeprecatedChainspell); // Chainspell NWNXCreature.RemoveFeat(player, Feat.DeprecatedForceHeal2); // Force Heal II NWNXCreature.RemoveFeat(player, Feat.DeprecatedForceHeal3); // Force Heal III NWNXCreature.RemoveFeat(player, Feat.DeprecatedForceHeal4); // Force Heal IV dbPlayer.VersionNumber = 5; } // VERSION 6: Remove AC from all items the player is carrying. If possible, // grant +1 durability and +1 max durability for every 2 AC the item has. if (dbPlayer.VersionNumber < 6) { ProcessVersion6ItemChanges(player); dbPlayer.VersionNumber = 6; } // VERSION 7: Give 40 language ranks to players, for their distribution. if (dbPlayer.VersionNumber < 7) { var ranks = new PCSkillPool { PlayerID = dbPlayer.ID, SkillCategoryID = 8, // 8 = Languages Levels = 40 }; DataService.SubmitDataChange(ranks, DatabaseActionType.Insert); dbPlayer.VersionNumber = 7; } // VERSION 8: Remove armor restrictions for a number of perks. Ensure player has the feat if they have the perk purchased. if (dbPlayer.VersionNumber < 8) { // Point Blank Shot if (PerkService.GetPCPerkByID(player.GlobalID, (int)PerkType.PointBlankShot) != null) { NWNXCreature.AddFeat(player, Feat.PointBlankShot); } // Rapid Reload if (PerkService.GetPCPerkByID(player.GlobalID, (int)PerkType.RapidReload) != null) { NWNXCreature.AddFeat(player, Feat.RapidReload); } dbPlayer.VersionNumber = 8; } // VERSION 9: Remove Weapon Finesse if player currently has it. if (dbPlayer.VersionNumber < 9) { if (GetHasFeat(Feat.WeaponFinesse, player)) { NWNXCreature.RemoveFeat(player, Feat.WeaponFinesse); } dbPlayer.VersionNumber = 9; } DataService.SubmitDataChange(dbPlayer, DatabaseActionType.Update); }
private static void OnModuleEnter() { NWPlayer player = _.GetEnteringObject(); if (!player.IsPlayer) { return; } var dbPlayer = DataService.Get <Player>(player.GlobalID); // VERSION 2: Background items are no longer plot because item level no longer dictates your skill XP gain. if (dbPlayer.VersionNumber < 2) { string[] resrefs = { "blaster_s", "rifle_s", "powerglove_t", "baton_s", "doubleaxe_z", "kukri_d", "greatsword_s", "scanner_r_h", "harvest_r_h", "man_armor" }; foreach (var resref in resrefs) { NWItem item = _.GetItemPossessedBy(player, resref); if (item.IsValid) { item.IsPlot = false; } } dbPlayer.VersionNumber = 2; } // VERSION 3: Force feats need to be removed since force powers were reworked. if (dbPlayer.VersionNumber < 3) { // These IDs come from the Feat.2da file. NWNXCreature.RemoveFeat(player, 1135); // Force Breach NWNXCreature.RemoveFeat(player, 1136); // Force Lightning NWNXCreature.RemoveFeat(player, 1137); // Force Heal NWNXCreature.RemoveFeat(player, 1138); // Dark Heal NWNXCreature.RemoveFeat(player, 1143); // Force Spread NWNXCreature.RemoveFeat(player, 1144); // Dark Spread NWNXCreature.RemoveFeat(player, 1145); // Force Push NWNXCreature.RemoveFeat(player, 1125); // Force Aura NWNXCreature.RemoveFeat(player, 1152); // Drain Life NWNXCreature.RemoveFeat(player, 1134); // Chainspell dbPlayer.VersionNumber = 3; } // VERSION 4: Give the Uncanny Dodge 1 feat to all characters. if (dbPlayer.VersionNumber < 4) { NWNXCreature.AddFeatByLevel(player, FEAT_UNCANNY_DODGE_1, 1); dbPlayer.VersionNumber = 4; } // VERSION 5: We're doing another Force rework, so remove any force feats the player may have acquired. if (dbPlayer.VersionNumber < 5) { NWNXCreature.RemoveFeat(player, 1135); // Force Breach NWNXCreature.RemoveFeat(player, 1136); // Force Lightning NWNXCreature.RemoveFeat(player, 1137); // Force Heal I NWNXCreature.RemoveFeat(player, 1140); // Absorption Field NWNXCreature.RemoveFeat(player, 1143); // Force Spread NWNXCreature.RemoveFeat(player, 1145); // Force Push NWNXCreature.RemoveFeat(player, 1125); // Force Aura NWNXCreature.RemoveFeat(player, 1152); // Drain Life NWNXCreature.RemoveFeat(player, 1134); // Chainspell NWNXCreature.RemoveFeat(player, 1162); // Force Heal II NWNXCreature.RemoveFeat(player, 1163); // Force Heal III NWNXCreature.RemoveFeat(player, 1164); // Force Heal IV dbPlayer.VersionNumber = 5; } // VERSION 6: Remove AC from all items the player is carrying. If possible, // grant +1 durability and +1 max durability for every 2 AC the item has. if (dbPlayer.VersionNumber < 6) { ProcessVersion6ItemChanges(player); dbPlayer.VersionNumber = 6; } // VERSION 7: Give 40 language ranks to players, for their distribution. if (dbPlayer.VersionNumber < 7) { var ranks = new PCSkillPool { PlayerID = dbPlayer.ID, SkillCategoryID = 8, // 8 = Languages Levels = 40 }; DataService.SubmitDataChange(ranks, DatabaseActionType.Insert); dbPlayer.VersionNumber = 7; } DataService.SubmitDataChange(dbPlayer, DatabaseActionType.Update); }