public void can_create_tf_energy() { var player = new PlayerBuilder() .With(i => i.Id, 50) .BuildAndSave(); var caster = new PlayerBuilder() .With(i => i.Id, 987) .BuildAndSave(); var form = new FormSourceBuilder() .With(i => i.Id, 13) .BuildAndSave(); DomainRegistry.Repository.Execute(new CreateTFEnergy { PlayerId = player.Id, Amount = 100, FormSourceId = form.Id, CasterId = caster.Id }); Assert.That(DataContext.AsQueryable <TFEnergy>().Where(t => t.Owner.Id == 50 && t.Caster.Id == 987 && t.Amount == 100 && t.FormSource.Id == 13), Has.Exactly(1).Items); }
public void pets_automatically_equipped_to_new_owner_when_owner_has_no_existing_pet() { var petItemSource = new ItemSourceBuilder() .With(i => i.Id, 1000) .With(i => i.FriendlyName, "Squeaky Pet") .With(i => i.ItemType, PvPStatics.ItemType_Pet) .BuildAndSave(); var petFormSource = new FormSourceBuilder() .With(i => i.Id, 870) .With(i => i.MobilityType, PvPStatics.MobilityPet) .With(i => i.ItemSource, petItemSource) .BuildAndSave(); var cmd = new PlayerBecomesItem { AttackerId = attacker.Id, VictimId = victim.Id, NewFormId = petFormSource.Id }; Assert.That(DomainRegistry.Repository.Execute(cmd), Has.Property("AttackerLog").EqualTo("<br><b>You fully transformed Victim MgGee into a Squeaky Pet</b>!") .And.Property("VictimLog") .EqualTo("<br><b>You have been fully transformed into a Squeaky Pet!</b>!") .And.Property("LocationLog") .EqualTo("<br><b>Victim MgGee was completely transformed into a Squeaky Pet</b> here.")); var newItem = DataContext.AsQueryable <Item>().FirstOrDefault(i => i.FormerPlayer != null && i.FormerPlayer.Id == victim.Id); Assert.That(newItem, Is.Not.Null); Assert.That(newItem.Owner, Is.EqualTo(attacker)); Assert.That(newItem.IsEquipped, Is.True); }
public void throws_exception_if_itemSource_not_found() { var formSource = new FormSourceBuilder() .With(f => f.Id, 33) .BuildAndSave(); Assert.That( () => Repository.Execute(new SetFormSourceBecomesItemFK { FormSourceId = formSource.Id, ItemSourceId = -999 }), Throws.TypeOf <DomainException>().With.Message.EqualTo("ItemSource with Id '-999' could not be found")); }
public void Should_throw_exception_if_item_source_not_found() { var formSource2 = new FormSourceBuilder() .With(i => i.Id, 99) .With(i => i.ItemSource, null) .BuildAndSave(); var cmd = new PlayerBecomesItem { AttackerId = attacker.Id, VictimId = victim.Id, NewFormId = formSource2.Id }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo("Form is not inanimate or pet")); }
public void can_set_item_source_as_FK() { var itemSource = new ItemSourceBuilder() .With(i => i.Id, 50) .BuildAndSave(); var formSource = new FormSourceBuilder() .With(f => f.Id, 33) .BuildAndSave(); Assert.That( () => DomainRegistry.Repository.Execute(new SetFormSourceBecomesItemFK { FormSourceId = formSource.Id, ItemSourceId = itemSource.Id }), Throws.Nothing); Assert.That(DataContext.AsQueryable <FormSource>().First(t => t.Id == formSource.Id).ItemSource.Id, Is.EqualTo(itemSource.Id)); }
public void Should_find_player_by_id() { var user = new UserBuilder().With(u => u.Id, "guid").BuildAndSave(); var npc = new NPCBuilder().With(n => n.Id, 7).BuildAndSave(); var form = new FormSourceBuilder().With(n => n.Id, 101).BuildAndSave(); new PlayerBuilder() .With(p => p.Id, 23) .With(p => p.User, user) .With(p => p.NPC, npc) .With(p => p.FormSource, form) .BuildAndSave(); var cmd = new GetPlayer { PlayerId = 23 }; var foundPlayer = DomainRegistry.Repository.FindSingle(cmd); Assert.That(foundPlayer.Id, Is.EqualTo(23)); Assert.That(foundPlayer.NPC.Id, Is.EqualTo(7)); Assert.That(foundPlayer.FormSource.Id, Is.EqualTo(101)); }
public void can_save_xp_leaderboard() { new WorldBuilder() .With(i => i.RoundNumber, "Alpha Round 13") .With(i => i.TurnNumber, 5000) .With(i => i.RoundDuration, 5000) .With(i => i.ChaosMode, false) .BuildAndSave(); var form1 = new FormSourceBuilder() .With(f => f.Id, 100) .With(f => f.FriendlyName, "Moonwalker") .BuildAndSave(); var form2 = new FormSourceBuilder() .With(f => f.Id, 51) .With(f => f.FriendlyName, "Werewolf") .BuildAndSave(); var covenant = new CovenantBuilder() .With(c => c.Id, 912) .With(c => c.Name, "Shoemakers United") .BuildAndSave(); var secondPlace = new PlayerBuilder() .With(p => p.FirstName, "Person") .With(p => p.LastName, "One") .With(p => p.Id, 50) .With(p => p.GameMode, (int)GameModeStatics.GameModes.PvP) .With(p => p.Level, 14) .With(p => p.XP, 100) .With(p => p.FormSource, form2) .With(p => p.Gender, PvPStatics.GenderFemale) .BuildAndSave(); var firstPlaceHighestLevel = new PlayerBuilder() .With(p => p.FirstName, "Person") .With(p => p.LastName, "Two") .With(p => p.Id, 55) .With(p => p.GameMode, (int)GameModeStatics.GameModes.PvP) .With(p => p.Level, 15) .With(p => p.XP, 100) .With(p => p.FormSource, form1) .With(p => p.Mobility, PvPStatics.MobilityPet) .With(p => p.GameMode, (int)GameModeStatics.GameModes.PvP) .With(p => p.Gender, PvPStatics.GenderMale) .BuildAndSave(); var thirdPlaceTiedLevelLowerXP = new PlayerBuilder() .With(p => p.FirstName, "Person") .With(p => p.LastName, "Four") .With(p => p.Id, 65) .With(p => p.GameMode, (int)GameModeStatics.GameModes.Protection) .With(p => p.Level, 14) .With(p => p.XP, 99) .With(p => p.FormSource, form1) .With(p => p.Covenant, covenant) .BuildAndSave(); Assert.That(() => DomainRegistry.Repository.Execute(new SaveXpLeaderboards { RoundNumber = 13 }), Throws.Nothing); var leaders = DataContext.AsQueryable <TT.Domain.World.Entities.XpLeaderboardEntry>(); Assert.That(leaders, Has.Exactly(3).Items); var first = leaders.ElementAt(0); Assert.That(first.PlayerName, Is.EqualTo($"{firstPlaceHighestLevel.FirstName} {firstPlaceHighestLevel.LastName}")); Assert.That(first.FormName, Is.EqualTo(form1.FriendlyName)); Assert.That(first.FormSource.Id, Is.EqualTo(form1.Id)); Assert.That(first.Level, Is.EqualTo(firstPlaceHighestLevel.Level)); Assert.That(first.Mobility, Is.EqualTo(firstPlaceHighestLevel.Mobility)); Assert.That(first.CovenantName, Is.Null); Assert.That(first.Sex, Is.EqualTo(firstPlaceHighestLevel.Gender)); var second = leaders.ElementAt(1); Assert.That(second.PlayerName, Is.EqualTo($"{secondPlace.FirstName} {secondPlace.LastName}")); Assert.That(second.FormName, Is.EqualTo(form2.FriendlyName)); Assert.That(second.FormSource.Id, Is.EqualTo(form2.Id)); Assert.That(second.Sex, Is.EqualTo(secondPlace.Gender)); var third = leaders.ElementAt(2); Assert.That(third.PlayerName, Is.EqualTo($"{thirdPlaceTiedLevelLowerXP.FirstName} {thirdPlaceTiedLevelLowerXP.LastName}")); Assert.That(third.CovenantName, Is.EqualTo(covenant.Name)); }
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 }