public void can_unembed_runes_on_owned_items() { var owner = new PlayerBuilder() .With(i => i.Id, 1010) .With(i => i.Location, "somewhere") .BuildAndSave(); var ownedItem = new ItemBuilder() .With(i => i.Id, 600) .With(i => i.Level, 1) .With(i => i.Owner, owner) .With(i => i.dbLocationName, String.Empty) .With(i => i.ItemSource, new ItemSourceBuilder() .With(i => i.ItemType, PvPStatics.ItemType_Pet) .BuildAndSave() ).BuildAndSave(); var rune2 = new ItemBuilder() .With(i => i.Id, 1000) .With(i => i.IsEquipped, false) .With(i => i.ItemSource, new ItemSourceBuilder() .With(i => i.ItemType, PvPStatics.ItemType_Rune) .BuildAndSave()) .BuildAndSave(); ownedItem.AttachRune(rune); ownedItem.AttachRune(rune2); owner.GiveItem(ownedItem); ownedItem.RemoveRunes(); Assert.That(ownedItem.Runes, Is.Empty); Assert.That(rune.EmbeddedOnItem, Is.Null); Assert.That(rune.IsEquipped, Is.False); Assert.That(rune.Owner.Id, Is.EqualTo(owner.Id)); Assert.That(rune.dbLocationName, Is.Empty); Assert.That(rune2.EmbeddedOnItem, Is.Null); Assert.That(rune2.IsEquipped, Is.False); Assert.That(rune2.Owner.Id, Is.EqualTo(owner.Id)); Assert.That(rune2.dbLocationName, Is.Empty); }
public void ChangeOwner_transfers_runes() { var oldOwner = new PlayerBuilder() .With(p => p.Id, 1) .With(p => p.Location, "somewhere") .BuildAndSave(); var newOwner = new PlayerBuilder() .With(p => p.Id, 1) .With(p => p.Location, "somewhere") .BuildAndSave(); var item = new ItemBuilder() .With(i => i.Id, 100) .With(i => i.IsEquipped, false) .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-8)) .With(i => i.ItemSource, new ItemSourceBuilder() .With(i => i.ItemType, PvPStatics.ItemType_Shirt) .BuildAndSave()) .BuildAndSave(); var rune = new ItemBuilder() .With(i => i.IsEquipped, true) .With(i => i.Owner, oldOwner) .With(i => i.TimeDropped, DateTime.UtcNow.AddHours(-8)) .With(i => i.ItemSource, new ItemSourceBuilder() .With(i => i.ItemType, PvPStatics.ItemType_Rune) .BuildAndSave()) .BuildAndSave(); item.AttachRune(rune); oldOwner.GiveItem(item); item.ChangeOwner(newOwner); Assert.That(item.Owner.Id, Is.EqualTo(newOwner.Id)); Assert.That(item.Runes, Has.Exactly(1).Items); Assert.That(item.TimeDropped, Is.EqualTo(DateTime.UtcNow).Within(1).Minutes); Assert.That(rune.EmbeddedOnItem.Id, Is.EqualTo(100)); Assert.That(rune.IsEquipped, Is.True); }
public void should_get_count_of_item_type() { // include this item, correct type var item1 = new ItemBuilder() .With(i => i.ItemSource, new ItemSourceBuilder() .With(i => i.Id, 5) .BuildAndSave()) .BuildAndSave(); // exclude this item, different type var item2 = new ItemBuilder() .With(i => i.ItemSource, new ItemSourceBuilder() .With(i => i.Id, 7) .BuildAndSave()) .BuildAndSave(); var player = new PlayerBuilder() .With(i => i.Items, new List <Item>()) .BuildAndSave(); player.GiveItem(item1); Assert.That(player.GetCountOfItem(5), Is.EqualTo(1)); }
public void can_throw_tg_bomb() { var regularGuyForm = new FormSourceBuilder() .With(p => p.AltSexFormSource, new FormSourceBuilder() .With(p => p.FriendlyName, "Alt Sex Regular Guy -> Regular Girl Form") .With(p => p.Gender, PvPStatics.GenderFemale) .BuildAndSave()) .With(p => p.FriendlyName, RegularGuy) .With(p => p.Gender, PvPStatics.GenderMale) .BuildAndSave(); var regularGirlForm = new FormSourceBuilder() .With(p => p.AltSexFormSource, new FormSourceBuilder() .With(p => p.FriendlyName, "Alt Sex Regular Girl -> Regular Guy Form") .With(p => p.Gender, PvPStatics.GenderMale) .BuildAndSave()) .With(p => p.FriendlyName, RegularGirl) .With(p => p.Gender, PvPStatics.GenderMale) .BuildAndSave(); var nonBaseForm = new FormSourceBuilder() .With(p => p.AltSexFormSource, null) .With(p => p.FriendlyName, "Some Other Form") .BuildAndSave(); var bomb = new ItemBuilder() .With(i => i.ItemSource, new ItemSourceBuilder().BuildAndSave()) .With(i => i.Id, 5) .BuildAndSave(); var thrower = new PlayerBuilder() .With(p => p.Id, 5) .With(p => p.FirstName, "Orb") .With(p => p.LastName, "Thrower") .With(p => p.Location, TavernLocation) .With(p => p.Items, new List <Item>()) .With(p => p.XP, 3) .With(i => i.User, new UserBuilder() .With(u => u.Stats, new List <Stat>()) .BuildAndSave()) .BuildAndSave(); thrower.GiveItem(bomb); // should get hit and turned into Regular Guy var femaleBystander = new PlayerBuilder() .With(p => p.Id, 6) .With(p => p.FirstName, "Female") .With(p => p.LastName, "Bystander") .With(p => p.Location, TavernLocation) .With(p => p.Gender, PvPStatics.GenderFemale) .With(p => p.FormSource, regularGirlForm) .With(p => p.PlayerLogs, new List <PlayerLog>()) .BuildAndSave(); // should get hit and turned into Regular Girl var maleBystander = new PlayerBuilder() .With(p => p.Id, 7) .With(p => p.Location, TavernLocation) .With(p => p.FirstName, "Male") .With(p => p.LastName, "Bystander") .With(p => p.Gender, PvPStatics.GenderMale) .With(p => p.FormSource, regularGuyForm) .With(p => p.PlayerLogs, new List <PlayerLog>()) .BuildAndSave(); // shouldn't get hit, in SuperProtection mode var wrongMode = new PlayerBuilder() .With(p => p.Id, 8) .With(p => p.FirstName, "Super") .With(p => p.LastName, "Protection") .With(p => p.Location, TavernLocation) .With(p => p.Gender, PvPStatics.GenderMale) .With(p => p.FormSource, regularGuyForm) .With(p => p.GameMode, (int)GameModeStatics.GameModes.Superprotection) .With(p => p.PlayerLogs, new List <PlayerLog>()) .BuildAndSave(); // shouldn't get hit, offline var offline = new PlayerBuilder() .With(p => p.Id, 9) .With(p => p.FirstName, "Off") .With(p => p.LastName, "Line") .With(p => p.Location, TavernLocation) .With(p => p.Gender, PvPStatics.GenderMale) .With(p => p.FormSource, regularGuyForm) .With(p => p.LastActionTimestamp, DateTime.UtcNow.AddMinutes(-1 - TurnTimesStatics.GetOfflineAfterXMinutes())) .With(p => p.PlayerLogs, new List <PlayerLog>()) .BuildAndSave(); // shouldn't get hit, not in a base form var nonBaseFormPlayer = new PlayerBuilder() .With(p => p.Id, 10) .With(p => p.FirstName, "Non") .With(p => p.LastName, "Base") .With(p => p.Location, TavernLocation) .With(p => p.Gender, PvPStatics.GenderMale) .With(p => p.FormSource, nonBaseForm) .With(p => p.PlayerLogs, new List <PlayerLog>()) .BuildAndSave(); Assert.That(Repository.Execute(new ThrowTGBomb { ItemId = bomb.Id, PlayerId = thrower.Id }), Is.EqualTo( "You throw your TG Splash Orb and swap the sex of 2 other mages near you: <b>Female Bystander</b> and <b>Male Bystander</b> and gain <b>6</b> XP!")); var players = DataContext.AsQueryable <Player>(); var loadedThrower = players.First(p => p.Id == thrower.Id); Assert.That(loadedThrower.XP, Is.EqualTo(9)); Assert.That(loadedThrower.User.Stats.First().AchievementType, Is.EqualTo(StatsProcedures.Stat__TgOrbVictims)); Assert.That(loadedThrower.User.Stats.First().Amount, Is.EqualTo(2)); var loadedfemaleBystander = players.First(p => p.Id == femaleBystander.Id); Assert.That(loadedfemaleBystander.FormSource.FriendlyName, Is.EqualTo("Alt Sex Regular Girl -> Regular Guy Form")); Assert.That(loadedfemaleBystander.Gender, Is.EqualTo(PvPStatics.GenderMale)); Assert.That(loadedfemaleBystander.PlayerLogs.First().Message, Is.EqualTo( "You yelp and feel your body change to that of the opposite sex from <b>Orb Thrower</b>'s use of a TG Splash Orb in your location!")); var loadedMaleBystander = players.First(p => p.Id == maleBystander.Id); Assert.That(loadedMaleBystander.FormSource.FriendlyName, Is.EqualTo("Alt Sex Regular Guy -> Regular Girl Form")); Assert.That(loadedMaleBystander.Gender, Is.EqualTo(PvPStatics.GenderFemale)); Assert.That(loadedMaleBystander.PlayerLogs.First().Message, Is.EqualTo( "You yelp and feel your body change to that of the opposite sex from <b>Orb Thrower</b>'s use of a TG Splash Orb in your location!")); Assert.That(players.First(p => p.Id == wrongMode.Id).FormSource.FriendlyName, Is.EqualTo(wrongMode.FormSource.FriendlyName)); // unchanged Assert.That(players.First(p => p.Id == offline.Id).FormSource.FriendlyName, Is.EqualTo(offline.FormSource.FriendlyName)); // unchanged Assert.That(players.First(p => p.Id == nonBaseFormPlayer.Id).FormSource.FriendlyName, Is.EqualTo(nonBaseFormPlayer.FormSource.FriendlyName)); // unchanged }