public void ItemEquipmentEvent() { var level = TestHelper.BuildLevel(); var armor = ItemData.MailArmor.Instantiate(level.Entity.Manager).Referenced; var nymph = CreatureData.WaterNymph.Instantiate(level, new Point(0, 1)); var player = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 2)); var manager = level.Entity.Manager; var languageService = manager.Game.Services.Language; Assert.Equal("The water nymph equips something on the torso.", languageService.GetString(new ItemEquipmentEvent( player, nymph, armor, SenseType.Sight, SenseType.Sound, EquipmentSlot.Torso))); Assert.Equal("Something equips a mail armor.", languageService.GetString(new ItemEquipmentEvent( player, nymph, armor, SenseType.Sound, SenseType.Sight, EquipmentSlot.Torso))); Assert.Equal("You equip something on the torso.", languageService.GetString(new ItemEquipmentEvent( player, player, armor, SenseType.Sight | SenseType.Touch, SenseType.Touch, EquipmentSlot.Torso))); var sword = ItemData.LongSword.Instantiate(level.Entity.Manager).Referenced; Assert.Equal("You equip the long sword in the main hand for melee.", languageService.GetString(new ItemEquipmentEvent( player, player, sword, SenseType.Sight | SenseType.Touch, SenseType.Sight | SenseType.Touch, EquipmentSlot.GraspPrimaryMelee))); }
public void Hp_and_ep_depend_on_might_and_focus_and_regenerate_with_xp() { var level = TestHelper.BuildLevel("."); var playerEntity = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 0)); ItemData.PotionOfOgreness.Instantiate(playerEntity); var manager = playerEntity.Manager; manager.Queue.ProcessQueue(manager); var being = playerEntity.Being; Assert.Equal(100, being.EnergyPointMaximum); Assert.Equal(100, being.EnergyPoints); Assert.Equal(100, being.HitPointMaximum); Assert.Equal(100, being.HitPoints); being.EnergyPoints -= 50; being.HitPoints -= 50; manager.XPSystem.AddPlayerXP(25, manager); manager.Queue.ProcessQueue(manager); Assert.Equal(60, being.EnergyPoints); Assert.Equal(60, being.HitPoints); TestHelper.ActivateAbility(ItemData.PotionOfOgreness.Name + ": Drink", playerEntity, manager); manager.Queue.ProcessQueue(manager); Assert.Equal(90, being.EnergyPointMaximum); Assert.Equal(60, being.EnergyPoints); Assert.Equal(120, being.HitPointMaximum); Assert.Equal(60, being.HitPoints); }
public void ItemConsumptionEvent() { var level = TestHelper.BuildLevel(); var flask = ItemData.FlaskOfHealing.Instantiate(level.Entity.Manager).Referenced; var potion = ItemData.PotionOfExperience.Instantiate(level.Entity.Manager).Referenced; var blob = CreatureData.AcidBlob.Instantiate(level, new Point(0, 0)); var player = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 2)); var manager = level.Entity.Manager; var languageService = manager.Game.Services.Language; Assert.Equal("The acid blob drinks from a flask of healing.", languageService.GetString( new ItemActivationEvent(player, flask, blob, blob, SenseType.Sight | SenseType.Sound, SenseType.Sight | SenseType.Sound, SenseType.Sight | SenseType.Sound, consumed: false, successful: true))); Assert.Equal("You drink from the flask of healing.", languageService.GetString( new ItemActivationEvent(player, flask, player, player, SenseType.Sight | SenseType.Sound, SenseType.Sight | SenseType.Touch, SenseType.Sight | SenseType.Touch, consumed: false, successful: true))); Assert.Equal("You drink the potion of experience.", languageService.GetString( new ItemActivationEvent(player, potion, player, player, SenseType.Sight | SenseType.Sound, SenseType.Sight | SenseType.Touch, SenseType.Sight | SenseType.Touch, consumed: true, successful: true))); }
public void Xp_gained_on_exploration() { var level = TestHelper.BuildLevel(@" ... >.. ..#"); level.Difficulty = 3; var player = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 0)); player.Position.Heading = Direction.West; var manager = player.Manager; manager.Queue.ProcessQueue(manager); Assert.Equal(9, player.Being.ExperiencePoints); var travelMessage = manager.TravelSystem.CreateTravelMessage(manager); travelMessage.Entity = player; travelMessage.TargetHeading = Direction.East; travelMessage.TargetCell = new Point(0, 0); manager.Enqueue(travelMessage); manager.Queue.ProcessQueue(manager); Assert.Equal(27, player.Being.ExperiencePoints); }
public void Races_level_up() { var level = TestHelper.BuildLevel("."); var playerEntity = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 0)); var player = playerEntity.Player; ItemData.PotionOfExperience.Instantiate(playerEntity, 13); ItemData.PotionOfElfness.Instantiate(playerEntity); var manager = playerEntity.Manager; manager.Queue.ProcessQueue(manager); Assert.Equal(0, player.SkillPoints); Assert.Equal(0, player.TraitPoints); Assert.Equal(0, player.MutationPoints); Assert.Equal(1000, player.NextLevelXP); Assert.Equal(14, manager.AbilitiesToAffectableRelationship[playerEntity.Id].Count()); Assert.Equal(2, manager.EntityItemsToContainerRelationship[playerEntity.Id].Count()); TestHelper.ActivateAbility(ItemData.PotionOfExperience.Name + ": Drink", playerEntity, manager); manager.Queue.ProcessQueue(manager); Assert.Equal(2, manager.XPSystem.GetXPLevel(playerEntity, manager)); Assert.Equal(3, player.SkillPoints); Assert.Equal(3, player.TraitPoints); Assert.Equal(0, player.MutationPoints); Assert.Equal(2000, player.NextLevelXP); var experienceAbility = manager.AffectableAbilitiesIndex[(playerEntity.Id, ItemData.PotionOfExperience.Name + ": Drink")];
public void Visibility_updated_on_travel() { var level = TestHelper.BuildLevel(TestMap); var nymph = CreatureData.WaterNymph.Instantiate(level, new Point(0, 1)); var player = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 2)); player.Position.Heading = Direction.West; var manager = player.Manager; ItemData.Dagger.Instantiate(nymph); manager.Queue.ProcessQueue(manager); var dagger = manager.EntityItemsToContainerRelationship[nymph.Id].Single(); Assert.Equal(SenseType.Sight, manager.SensorySystem.CanSense(player, nymph)); Assert.Equal(SenseType.Sight, manager.SensorySystem.SensedByPlayer(nymph, nymph.Position.LevelCell)); Assert.Equal(SenseType.Sight | SenseType.Touch | SenseType.Telepathy, manager.SensorySystem.CanSense(player, player)); Assert.Equal(SenseType.Sight | SenseType.Touch | SenseType.Telepathy, manager.SensorySystem.SensedByPlayer(player, player.Position.LevelCell)); Assert.Equal(SenseType.Sight, manager.SensorySystem.CanSense(player, dagger)); Assert.Equal(SenseType.Sight, manager.SensorySystem.SensedByPlayer(dagger, nymph.Position.LevelCell)); var expectedVisibleMap = @" . . ."; TestHelper.AssertVisibility(level, expectedVisibleMap, level.VisibleTerrain); var expectedKnownMap = @" . . ."; TestHelper.AssertTerrain(level, expectedKnownMap, level.KnownTerrain); var travelMessage = manager.TravelSystem.CreateTravelMessage(manager); travelMessage.Entity = player; travelMessage.TargetHeading = Direction.South; travelMessage.TargetCell = player.Position.LevelCell; manager.Enqueue(travelMessage); manager.Queue.ProcessQueue(manager); Assert.Equal(SenseType.None, manager.SensorySystem.CanSense(player, nymph)); Assert.Equal(SenseType.None, manager.SensorySystem.SensedByPlayer(nymph, nymph.Position.LevelCell)); Assert.Equal(SenseType.None, manager.SensorySystem.CanSense(player, dagger)); Assert.Equal(SenseType.None, manager.SensorySystem.SensedByPlayer(dagger, nymph.Position.LevelCell)); expectedVisibleMap = @" ..#"; TestHelper.AssertVisibility(level, expectedVisibleMap, level.VisibleTerrain); expectedKnownMap = @" . . ..#"; TestHelper.AssertTerrain(level, expectedKnownMap, level.KnownTerrain); }
public void Skills_add_abilities() { var level = TestHelper.BuildLevel("."); var playerEntity = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 0)); ItemData.SkillbookOfWaterSourcery.Instantiate(playerEntity); var manager = playerEntity.Manager; manager.Queue.ProcessQueue(manager); Assert.Null(manager.AffectableAbilitiesIndex[(playerEntity.Id, "ice shard")]);
public void Welcome() { var level = TestHelper.BuildLevel(); var player = PlayerRace.InstantiatePlayer("Conan the Barbarian", Sex.Male, level.Entity, new Point(0, 0)); var manager = level.Entity.Manager; var languageService = manager.Game.Services.Language; var message = languageService.Welcome(player); Assert.Equal("Welcome to the test branch, Conan the Barbarian!", message); }
public void DeathEvent() { var level = TestHelper.BuildLevel(); var blob = CreatureData.AcidBlob.Instantiate(level, new Point(0, 0)); var player = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 2)); var manager = level.Entity.Manager; var languageService = manager.Game.Services.Language; Assert.Equal("The acid blob dies.", languageService.GetString(new DeathEvent(player, blob, SenseType.Sight))); Assert.Equal("You die!", languageService.GetString(new DeathEvent(player, player, SenseType.Sight | SenseType.Touch))); }
public void Reserved_ep_does_not_replenish() { var level = TestHelper.BuildLevel("."); var playerEntity = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 0)); var manager = playerEntity.Manager; manager.Queue.ProcessQueue(manager); var being = playerEntity.Being; Assert.Equal(100, being.EnergyPointMaximum); Assert.Equal(100, being.EnergyPoints); Assert.Equal(0, being.ReservedEnergyPoints); being.EnergyPoints += 50; Assert.Equal(100, being.EnergyPoints); being.EnergyPoints -= 120; Assert.Equal(0, being.EnergyPoints); being.ReservedEnergyPoints = -50; Assert.Equal(0, being.ReservedEnergyPoints); being.EnergyPoints = 100; being.ReservedEnergyPoints = 60; Assert.Equal(40, being.EnergyPoints); being.EnergyPoints = 100; Assert.Equal(40, being.EnergyPoints); being.ReservedEnergyPoints = 150; Assert.Equal(100, being.ReservedEnergyPoints); Assert.Equal(0, being.EnergyPoints); being.ReservedEnergyPoints = 0; being.EnergyPoints = 50; being.EnergyPointMaximum = 200; manager.Queue.ProcessQueue(manager); Assert.Equal(200, being.EnergyPointMaximum); Assert.Equal(0, being.ReservedEnergyPoints); Assert.Equal(50, being.EnergyPoints); }
public void GetPossibleMovementDirections_returns_correct_directions() { var level = TestHelper.BuildLevel(@" .#. .>. ..."); var nymph = CreatureData.WaterNymph.Instantiate(level, new Point(0, 1)); var manager = nymph.Manager; var player = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 2)); manager.Queue.ProcessQueue(manager); Assert.Equal(new[] { Direction.North, Direction.Southeast }, manager.TravelSystem.GetPossibleMovementDirections(nymph.Position, safe: true, manager)); }
public void ItemDropEvent() { var level = TestHelper.BuildLevel(); var coins = ItemData.GoldCoin.Instantiate(level.Entity.Manager).Referenced; var blob = CreatureData.AcidBlob.Instantiate(level, new Point(0, 0)); var player = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 2)); var manager = level.Entity.Manager; var languageService = manager.Game.Services.Language; Assert.Equal("The acid blob drops 11 gold coins.", languageService.GetString(new ItemDropEvent( player, blob, coins, 11, SenseType.Sight | SenseType.Sound, SenseType.Sight | SenseType.Sound))); Assert.Equal("You drop 11 gold coins.", languageService.GetString(new ItemDropEvent( player, player, coins, 11, SenseType.Sight | SenseType.Sound, SenseType.Sight | SenseType.Sound))); }
public void LeveledUpEvent() { var level = TestHelper.BuildLevel(); var player1 = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 0)); var player2 = PlayerRace.InstantiatePlayer("Cudley", Sex.Female, level.Entity, new Point(0, 1)); var manager = level.Entity.Manager; var languageService = manager.Game.Services.Language; Assert.Equal("You level up! You gain 2 SP 1 TP 0 MP.", languageService.GetString(new LeveledUpEvent( player1, player1, manager.RacesToBeingRelationship[player1.Id].Single().Value.Race, 2, 1, 0))); Assert.Equal("Cudley levels up! She gains 3 SP 2 TP 1 MP.", languageService.GetString(new LeveledUpEvent( player1, player2, manager.RacesToBeingRelationship[player2.Id].Single().Value.Race, 3, 2, 1))); }
public void Knowledge_updated_on_travel() { var level = TestHelper.BuildLevel(TestMap); ItemData.Dagger.Instantiate(level, new Point(0, 0)); var nymph = CreatureData.WaterNymph.Instantiate(level, new Point(0, 0)); var player = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 2)); player.Position.Heading = Direction.West; var manager = player.Manager; manager.Queue.ProcessQueue(manager); var nymphKnowledge = manager.LevelKnowledgeToLevelEntityRelationship[nymph.Id]; var playerKnowledge = manager.LevelKnowledgeToLevelEntityRelationship[player.Id]; var dagger = manager.LevelItemsToLevelCellIndex[(level.EntityId, 0, 0)];
public void Abilities_can_be_assigned_to_slots() { var level = TestHelper.BuildLevel("."); var manager = level.Entity.Manager; var playerEntity = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 0)); manager.Queue.ProcessQueue(manager); GameEntity toggledAbility; using (var abilityEntityReference = manager.CreateEntity()) { toggledAbility = abilityEntityReference.Referenced; var ability = manager.CreateComponent <AbilityComponent>(EntityComponent.Ability); ability.Activation = ActivationType.WhileToggled; ability.OwnerEntity = playerEntity; toggledAbility.Ability = ability; } using (var effectEntityReference = manager.CreateEntity()) { var bleedingEffectEntity = effectEntityReference.Referenced; var effect = manager.CreateComponent <EffectComponent>(EntityComponent.Effect); effect.Duration = EffectDuration.Infinite; effect.EffectType = EffectType.ChangeProperty; effect.TargetName = nameof(BeingComponent.BleedingResistance); effect.Amount = 10; effect.ContainingAbilityId = toggledAbility.Id; bleedingEffectEntity.Effect = effect; } var setSlotMessage = manager.AbilitySlottingSystem.CreateSetAbilitySlotMessage(manager); setSlotMessage.AbilityEntity = toggledAbility; setSlotMessage.Slot = 0; manager.Enqueue(setSlotMessage); manager.Queue.ProcessQueue(manager); Assert.Equal(0, toggledAbility.Ability.Slot); Assert.True(toggledAbility.Ability.IsActive); Assert.Same(toggledAbility, manager.SlottedAbilitiesIndex[(playerEntity.Id, 0)]);
public void Xp_gained_on_enemy_death() { var level = TestHelper.BuildLevel(".."); var nymph = CreatureData.WaterNymph.Instantiate(level, new Point(0, 0)); var player = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(1, 0)); player.Position.Heading = Direction.West; var manager = player.Manager; manager.Queue.ProcessQueue(manager); Assert.Equal(2, player.Being.ExperiencePoints); nymph.Being.HitPoints = 0; manager.Queue.ProcessQueue(manager); Assert.Equal(302, player.Being.ExperiencePoints); }
public void Can_use_projectile_abilities_on_targets_in_LOS() { var level = TestHelper.BuildLevel(TestMap); var manager = level.Entity.Manager; var listener = new AbilityActivatedListener(); manager.Queue.Add(listener, AbilityActivationSystem.AbilityActivatedMessageName, -1); var playerEntity = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(2, 0)); playerEntity.Position.Heading = Direction.West; playerEntity.Player.SkillPoints = 5; manager.SkillAbilitiesSystem.BuyAbilityLevel(AbilityData.Conjuration, playerEntity); ItemData.Shortbow.Instantiate(playerEntity); var nymph = CreatureData.WaterNymph.Instantiate(level, new Point(2, 2)); var elemental = CreatureData.AirElemental.Instantiate(level, new Point(0, 0)); manager.Queue.ProcessQueue(manager); var bow = manager.EntityItemsToContainerRelationship[playerEntity.Id].Single(); var equipMessage = manager.ItemUsageSystem.CreateEquipItemMessage(manager); equipMessage.ActorEntity = playerEntity; equipMessage.ItemEntity = bow; equipMessage.Slot = EquipmentSlot.GraspBothRanged; manager.Enqueue(equipMessage); manager.Queue.ProcessQueue(manager); var nymphAbility = manager.AbilitiesToAffectableRelationship[nymph.Id] .First(a => (a.Ability.Activation & ActivationType.Slottable) != 0 && a.Ability.Template?.Type != AbilityType.DefaultAttack); Assert.Equal(0, nymphAbility.Ability.Slot); var attackAbility = manager.AffectableAbilitiesIndex[(playerEntity.Id, AbilityData.TwoHandedRangedAttack.Name)];
public void Active_abilities_are_updated_when_contained_effects_change() { var level = TestHelper.BuildLevel("."); var manager = level.Entity.Manager; var playerEntity = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 0)); manager.Queue.ProcessQueue(manager); GameEntity toggledAbility; using (var abilityEntityReference = manager.CreateEntity()) { toggledAbility = abilityEntityReference.Referenced; var ability = manager.CreateComponent <AbilityComponent>(EntityComponent.Ability); ability.Activation = ActivationType.WhileToggled; ability.OwnerEntity = playerEntity; toggledAbility.Ability = ability; } Assert.Null(toggledAbility.Ability.Slot); Assert.False(toggledAbility.Ability.IsActive); Assert.Null(manager.SlottedAbilitiesIndex[(playerEntity.Id, 0)]);
public void Cannot_unequip_items_in_use() { var level = TestHelper.BuildLevel("."); var playerEntity = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(0, 0)); var player = playerEntity.Player; player.NextAction = PlayerAction.Wait; var manager = playerEntity.Manager; ItemData.FieryAegis.Instantiate(playerEntity); manager.Queue.ProcessQueue(manager); var shieldEntity = manager.EntityItemsToContainerRelationship[playerEntity.Id].Single(); var equipMessage = manager.ItemUsageSystem.CreateEquipItemMessage(manager); equipMessage.ActorEntity = playerEntity; equipMessage.ItemEntity = shieldEntity; equipMessage.Slot = EquipmentSlot.GraspBothMelee; manager.Enqueue(equipMessage); manager.Queue.ProcessQueue(manager); var shieldAbility = manager.AbilitiesToAffectableRelationship[playerEntity.Id] .Select(a => a.Ability) .Single(a => (a.Activation & ActivationType.Slottable) != 0 && a.Template?.Type != AbilityType.DefaultAttack); var setSlotMessage = manager.AbilitySlottingSystem.CreateSetAbilitySlotMessage(manager); setSlotMessage.AbilityEntity = shieldAbility.Entity; setSlotMessage.Slot = 0; manager.Enqueue(setSlotMessage); manager.Queue.ProcessQueue(manager); Assert.True(shieldAbility.IsActive); Assert.Equal(30, playerEntity.Being.FireResistance); equipMessage = manager.ItemUsageSystem.CreateEquipItemMessage(manager); equipMessage.ActorEntity = playerEntity; equipMessage.ItemEntity = shieldEntity; manager.Enqueue(equipMessage); var moveItemMessage = manager.ItemMovingSystem.CreateMoveItemMessage(manager); moveItemMessage.ItemEntity = shieldEntity; moveItemMessage.TargetCell = new Point(0, 0); moveItemMessage.TargetLevelEntity = level.Entity; manager.Enqueue(moveItemMessage); manager.Queue.ProcessQueue(manager); Assert.Equal(EquipmentSlot.GraspBothMelee, shieldEntity.Item.EquippedSlot); Assert.Equal(0, shieldAbility.Slot); Assert.True(shieldAbility.IsActive); var deactivateMessage = manager.AbilityActivationSystem.CreateDeactivateAbilityMessage(manager); deactivateMessage.AbilityEntity = shieldAbility.Entity; deactivateMessage.ActivatorEntity = playerEntity; manager.Enqueue(deactivateMessage); manager.Queue.ProcessQueue(manager); Assert.Null(shieldAbility.Slot); Assert.False(shieldAbility.IsActive); Assert.Equal(0, playerEntity.Being.FireResistance); Assert.Equal(200, shieldAbility.CooldownTick); equipMessage = manager.ItemUsageSystem.CreateEquipItemMessage(manager); equipMessage.ActorEntity = playerEntity; equipMessage.ItemEntity = shieldEntity; manager.Enqueue(equipMessage); moveItemMessage = manager.ItemMovingSystem.CreateMoveItemMessage(manager); moveItemMessage.ItemEntity = shieldEntity; moveItemMessage.TargetCell = new Point(0, 0); moveItemMessage.TargetLevelEntity = level.Entity; manager.Enqueue(moveItemMessage); manager.Queue.ProcessQueue(manager); Assert.Equal(EquipmentSlot.GraspBothMelee, shieldEntity.Item.EquippedSlot); Assert.NotNull(manager.AffectableAbilitiesIndex[(playerEntity.Id, shieldAbility.Name)]);
public void AttackEvent() { var level = TestHelper.BuildLevel(@" ... ... ..."); var demogorgon = CreatureData.Demogorgon.Instantiate(level, new Point(0, 0)); var nymph = CreatureData.WaterNymph.Instantiate(level, new Point(0, 1)); var playerEntity = PlayerRace.InstantiatePlayer("Dudley", Sex.Male, level.Entity, new Point(1, 1)); playerEntity.Position.Heading = Direction.West; var manager = playerEntity.Manager; ItemData.LongSword.Instantiate(playerEntity); var player2Entity = PlayerRace.InstantiatePlayer("Cudley", Sex.Female, level.Entity, new Point(1, 0)); player2Entity.Position.Heading = Direction.North; manager.Queue.ProcessQueue(manager); var swordEntity = manager.EntityItemsToContainerRelationship[playerEntity.Id] .Single(e => e.Item.TemplateName == ItemData.LongSword.Name); var equipMessage = manager.ItemUsageSystem.CreateEquipItemMessage(manager); equipMessage.ActorEntity = playerEntity; equipMessage.ItemEntity = swordEntity; equipMessage.Slot = EquipmentSlot.GraspBothMelee; manager.Enqueue(equipMessage); manager.Queue.ProcessQueue(manager); playerEntity.Player.LogEntries.Clear(); player2Entity.Player.LogEntries.Clear(); Verify(demogorgon, nymph, playerEntity, player2Entity, manager.AbilitiesToAffectableRelationship[demogorgon.Id].ElementAt(3), success: true, "The Demogorgon stings the water nymph. (18 pts.)", "The Demogorgon stings something.", manager); Verify(demogorgon, nymph, playerEntity, player2Entity, manager.AbilitiesToAffectableRelationship[demogorgon.Id].ElementAt(3), success: false, "The Demogorgon tries to sting the water nymph, but misses.", "The Demogorgon tries to sting something, but misses.", manager); Verify(playerEntity, demogorgon, playerEntity, player2Entity, manager.AbilitiesToAffectableRelationship[playerEntity.Id] .Single(a => a.Ability.Slot == AbilitySlottingSystem.DefaultMeleeAttackSlot), success: true, "You slash the Demogorgon. (89 pts.)", "Dudley slashes the Demogorgon. (89 pts.)", manager); Verify(playerEntity, demogorgon, playerEntity, player2Entity, manager.AbilitiesToAffectableRelationship[playerEntity.Id] .Single(a => a.Ability.Slot == AbilitySlottingSystem.DefaultMeleeAttackSlot), success: false, "You try to slash the Demogorgon, but miss.", "Dudley tries to slash the Demogorgon, but misses.", manager); Verify(demogorgon, playerEntity, playerEntity, player2Entity, manager.AbilitiesToAffectableRelationship[demogorgon.Id].ElementAt(2), success: true, "The Demogorgon casts a spell at you! You are unaffected.", "The Demogorgon casts a spell at Dudley. He is unaffected.", manager); Verify(demogorgon, playerEntity, playerEntity, player2Entity, manager.AbilitiesToAffectableRelationship[demogorgon.Id].ElementAt(2), success: false, "The Demogorgon tries to cast a spell at you, but misses.", "The Demogorgon tries to cast a spell at Dudley, but misses.", manager); Verify(demogorgon, playerEntity, player2Entity, SenseType.Sight, SenseType.Sight, AbilityAction.Spell, manager, null, expectedMessage: "The Demogorgon tries to cast a spell at Dudley, but misses."); Verify(demogorgon, nymph, playerEntity, SenseType.Sound, SenseType.Sight, AbilityAction.Sting, manager, 11, expectedMessage: "You hear a noise."); Verify(nymph, playerEntity, playerEntity, SenseType.Sight | SenseType.Touch, SenseType.Sight | SenseType.Touch, AbilityAction.Punch, manager, 11, expectedMessage: "The water nymph punches you! [11 pts.]"); Verify(nymph, playerEntity, playerEntity, SenseType.Sight | SenseType.Touch, SenseType.Sight | SenseType.Touch, AbilityAction.Spit, manager, null, expectedMessage: "The water nymph tries to spit at you, but misses."); Verify(playerEntity, demogorgon, playerEntity, SenseType.Sight | SenseType.Touch, SenseType.Sight, AbilityAction.Hug, manager, 11, expectedMessage: "You squeeze the Demogorgon. (11 pts.)"); Verify(playerEntity, demogorgon, playerEntity, SenseType.Sight | SenseType.Touch, SenseType.Telepathy | SenseType.Touch, AbilityAction.Trample, manager, null, expectedMessage: "You try to trample the Demogorgon, but miss."); Verify(demogorgon, demogorgon, playerEntity, SenseType.Sight, SenseType.Sight, AbilityAction.Claw, manager, 11, expectedMessage: "The Demogorgon claws himself. (11 pts.)"); Verify(playerEntity, playerEntity, playerEntity, SenseType.Sight | SenseType.Touch, SenseType.Sight | SenseType.Touch, AbilityAction.Kick, manager, 12, expectedMessage: "You kick yourself! [12 pts.]"); Verify(nymph, playerEntity, playerEntity, SenseType.Sight | SenseType.Sound, SenseType.Sight | SenseType.Touch, AbilityAction.Scream, manager, 0, expectedMessage: "The water nymph screams at you! You are unaffected."); Verify(nymph, nymph, playerEntity, SenseType.Sight, SenseType.Sight, AbilityAction.Scream, manager, 0, expectedMessage: "The water nymph screams at herself. She is unaffected."); Verify(nymph, nymph, playerEntity, SenseType.Sound, SenseType.None, AbilityAction.Scream, manager, null, expectedMessage: "You hear a scream."); var dagger = ItemData.Dagger.Instantiate(playerEntity.Manager).Referenced; Verify(playerEntity, null, playerEntity, SenseType.Touch | SenseType.Telepathy, SenseType.Sight, AbilityAction.Slash, manager, null, weapon: dagger, expectedMessage: "You slash the air."); var bow = ItemData.Shortbow.Instantiate(playerEntity.Manager).Referenced; var arrow = ItemData.Arrow.Instantiate(playerEntity.Manager).Referenced; Verify(nymph, playerEntity, playerEntity, SenseType.Sight, SenseType.None, AbilityAction.Shoot, manager, null, weapon: bow, expectedMessage: null); Verify(nymph, playerEntity, playerEntity, SenseType.None, SenseType.Sight, AbilityAction.Hit, manager, 11, weapon: arrow, expectedMessage: "Something hits you! [11 pts.]"); Verify(nymph, playerEntity, playerEntity, SenseType.SoundDistant, SenseType.None, AbilityAction.Shoot, manager, null, weapon: bow, expectedMessage: null); Verify(nymph, playerEntity, playerEntity, SenseType.Sight, SenseType.Sight, AbilityAction.Hit, manager, null, weapon: arrow, expectedMessage: "An arrow misses you."); Verify(playerEntity, demogorgon, playerEntity, SenseType.Sight, SenseType.None, AbilityAction.Shoot, manager, null, weapon: bow, expectedMessage: null); Verify(playerEntity, demogorgon, playerEntity, SenseType.Sight, SenseType.Sight, AbilityAction.Hit, manager, 11, weapon: arrow, expectedMessage: "An arrow hits the Demogorgon. (11 pts.)"); Verify(nymph, demogorgon, playerEntity, SenseType.Sound, SenseType.None, AbilityAction.Shoot, manager, null, weapon: bow, expectedMessage: "You hear a noise."); Verify(nymph, demogorgon, playerEntity, SenseType.Sight, SenseType.Sight, AbilityAction.Hit, manager, 2, weapon: arrow, expectedMessage: "An arrow hits the Demogorgon. (2 pts.)"); var throwingKnife = ItemData.ThrowingKnife.Instantiate(playerEntity.Manager).Referenced; Verify(nymph, playerEntity, playerEntity, SenseType.Sound, SenseType.None, AbilityAction.Throw, manager, null, weapon: throwingKnife, expectedMessage: null); Verify(nymph, playerEntity, playerEntity, SenseType.Sight, SenseType.Sight, AbilityAction.Hit, manager, 11, weapon: throwingKnife, expectedMessage: "A throwing knife hits you! [11 pts.]"); Verify(playerEntity, null, playerEntity, SenseType.None, SenseType.None, AbilityAction.Hit, manager, null, weapon: throwingKnife, expectedMessage: null); Verify(nymph, demogorgon, playerEntity, SenseType.Sound, SenseType.None, AbilityAction.Throw, manager, null, weapon: throwingKnife, expectedMessage: "You hear a noise."); Verify(nymph, demogorgon, playerEntity, SenseType.None, SenseType.SoundDistant, AbilityAction.Hit, manager, 2, weapon: throwingKnife, expectedMessage: "You hear a distant noise."); }
private PlayerComponent CreatePlayer(string name) { uint seed; using (RandomNumberGenerator rng = new RNGCryptoServiceProvider()) { var rngData = new byte[4]; rng.GetBytes(rngData); seed = (uint)(rngData[0] | rngData[1] << 8 | rngData[2] << 16 | rngData[3] << 24); } var game = new Game { InitialSeed = seed, Random = new SimpleRandom { Seed = seed } }; Initialize(game); _dbContext.Games.Add(game); _dbContext.SaveChanges(); var manager = game.Manager; var surfaceBranch = Branch.Loader.Find("surface").Instantiate(game); var surfaceLevel = LevelGenerator.CreateEmpty(surfaceBranch, depth: 1, seed, manager); LevelGenerator.EnsureGenerated(surfaceLevel); var initialLevelConnection = manager.ConnectionsToLevelRelationship[surfaceLevel.EntityId].Single().Connection; var initialLevelEntity = manager.FindEntity(initialLevelConnection.TargetLevelId); LevelGenerator.EnsureGenerated(initialLevelEntity.Level); // TODO: Set correct sex var playerEntity = PlayerRace.InstantiatePlayer( name, Sex.Male, initialLevelEntity, initialLevelConnection.TargetLevelCell.Value); ItemData.FlaskOfHealing.Instantiate(playerEntity); ItemData.MailArmor.Instantiate(playerEntity); ItemData.LongSword.Instantiate(playerEntity); ItemData.Dagger.Instantiate(playerEntity); ItemData.Shortbow.Instantiate(playerEntity); ItemData.ThrowingKnives.Instantiate(playerEntity); ItemData.FireStaff.Instantiate(playerEntity); ItemData.FreezingFocus.Instantiate(playerEntity); ItemData.FieryAegis.Instantiate(playerEntity); ItemData.PotionOfOgreness.Instantiate(playerEntity); ItemData.PotionOfElfness.Instantiate(playerEntity); ItemData.PotionOfDwarfness.Instantiate(playerEntity); ItemData.PotionOfExperience.Instantiate(playerEntity, quantity: 6); ItemData.SkillbookOfConjuration.Instantiate(playerEntity); manager.LoggingSystem.WriteLog(game.Services.Language.Welcome(playerEntity), playerEntity, manager); Turn(playerEntity.Player); _dbContext.ChangeTracker.AcceptAllChanges(); _gameServices.SharedCache.Set(game, game, new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromHours(1))); return(playerEntity.Player); }