Exemple #1
0
        private void RollStartEquipment(IInventoryModule inventory, HumanPerson person)
        {
            var headDropScheme = GetHeads();

            FillSlot(person, headDropScheme, HEAD_SLOT_INDEX);

            var armorDropScheme = GetArmors();

            FillSlot(person, armorDropScheme, BODY_SLOT_INDEX);

            var mainWeaponDropScheme = GetMainWeapons();

            FillSlot(person, mainWeaponDropScheme, MAIN_HAND_SLOT_INDEX);

            var offWeaponDropScheme = GetOffWeapons();

            FillSlot(person, offWeaponDropScheme, OFF_HAND_SLOT_INDEX);

            var startPropDropScheme = GetStartProps();
            var startProps          = _dropResolver.Resolve(new[] { startPropDropScheme });

            foreach (var prop in startProps)
            {
                AddPropToInventory(inventory, prop);
            }

            AddResource(inventory, "packed-food", 1);
            AddResource(inventory, "water-bottle", 1);
            AddResource(inventory, "med-kit", 1);
            AddEquipment(inventory, "pick-axe");
            AddEquipment(inventory, "shovel");
            AddEquipment(inventory, "shotgun");
            AddResource(inventory, "bullet-45", 100);
        }
Exemple #2
0
        protected override void RollStartEquipment(IInventoryModule inventory, HumanPerson person)
        {
            var templates      = GetPersonTemplateByFraction(person.Fraction, SchemeService);
            var rolledTemplate = Dice.RollFromList(templates);

            person.PersonEquipmentTemplate = rolledTemplate.Name;

            var headDropScheme = rolledTemplate.HeadEquipments;

            FillSlot(person, headDropScheme, HeadSlotIndex);

            var armorDropScheme = rolledTemplate.BodyEquipments;

            FillSlot(person, armorDropScheme, BodySlotIndex);

            var mainWeaponDropScheme = rolledTemplate.MainHandEquipments;

            FillSlot(person, mainWeaponDropScheme, MainHandSlotIndex);

            var offWeaponDropScheme = rolledTemplate.OffHandEquipments;

            FillSlot(person, offWeaponDropScheme, OffHandSlotIndex);

            var startPropDropScheme = rolledTemplate.InventoryProps;
            var startProps          = DropResolver.Resolve(new[] { startPropDropScheme });

            foreach (var prop in startProps)
            {
                AddPropToInventory(inventory, prop);
            }

            AddDefaultProps(inventory);
        }
        public static HumanPersonStorageData Create(HumanPerson humanPerson)
        {
            if (humanPerson is null)
            {
                throw new ArgumentNullException(nameof(humanPerson));
            }

            var storageData = new HumanPersonStorageData
            {
                Survival = humanPerson.GetModule <ISurvivalModule>().Stats.Select(x => new HumanSurvivalStatStorageData
                {
                    Type  = x.Type,
                    Value = x.ValueShare
                }).ToArray(),

                Equipments = humanPerson.GetModule <IEquipmentModule>().Select(CreateEquipmentStorageData).ToArray(),

                Inventory = humanPerson.GetModule <IInventoryModule>().CalcActualItems().Select(CreatePropStorageData)
                            .ToArray(),

                Perks = humanPerson.GetModule <IEvolutionModule>().Perks.Select(CreatePerkStorageData).ToArray()
            };

            return(storageData);
        }
        protected override void RollStartEquipment(IInventoryModule inventory, HumanPerson person)
        {
            var headDropScheme = GetHeads();

            FillSlot(person, headDropScheme, HeadSlotIndex);

            var armorDropScheme = GetArmors();

            FillSlot(person, armorDropScheme, BodySlotIndex);

            var mainWeaponDropScheme = GetMainWeapons();

            FillSlot(person, mainWeaponDropScheme, MainHandSlotIndex);

            var offWeaponDropScheme = GetOffWeapons();

            FillSlot(person, offWeaponDropScheme, OffHandSlotIndex);

            var startPropDropScheme = GetStartProps();
            var startProps          = DropResolver.Resolve(new[] { startPropDropScheme });

            foreach (var prop in startProps)
            {
                AddPropToInventory(inventory, prop);
            }

            AddDefaultProps(inventory);

            AddEquipment(inventory, "pick-axe");
            AddEquipment(inventory, "shovel");
            AddEquipment(inventory, "shotgun");
            AddResource(inventory, "bullet-45", 100);
        }
Exemple #5
0
        public void SetEquipment_SetSingleEquipment_HasActs()
        {
            // ARRANGE
            var slotSchemes = new[] {
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var personScheme = new PersonScheme
            {
                Slots = slotSchemes
            };

            var defaultActScheme = new TacticalActScheme {
                Stats = new TacticalActStatsSubScheme
                {
                    Efficient = new Range <float>(1, 1)
                },
                Dependency = new[] {
                    new TacticalActDependencySubScheme(CombatStatType.Melee, 1)
                }
            };

            var person = new HumanPerson(personScheme, defaultActScheme, null);

            var propScheme = new PropScheme
            {
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[] { EquipmentSlotTypes.Hand }
                }
            };

            var tacticalActScheme = new TacticalActScheme
            {
                Stats = new TacticalActStatsSubScheme
                {
                    Efficient = new Range <float>(1, 1),
                },
                Dependency = new[] {
                    new TacticalActDependencySubScheme(CombatStatType.Undefined, 1)
                }
            };

            var equipment = new Equipment(propScheme, new[] { tacticalActScheme });

            const int expectedSlotIndex = 0;



            // ACT

            person.EquipmentCarrier.SetEquipment(equipment, expectedSlotIndex);



            // ARRANGE
            person.TacticalActCarrier.Acts[0].Stats.Should().Be(tacticalActScheme.Stats);
        }
Exemple #6
0
        public static IActorViewModel CreateHumanActorVm([NotNull] IPlayer player,
                                                         [NotNull] ISchemeService schemeService,
                                                         [NotNull] ISurvivalRandomSource survivalRandomSource,
                                                         [NotNull] IPersonScheme personScheme,
                                                         [NotNull] IActorManager actorManager,
                                                         [NotNull] IMapNode startNode)
        {
            var inventory = new Inventory();

            var evolutionData = new EvolutionData(schemeService);

            var defaultActScheme = schemeService.GetScheme <ITacticalActScheme>(personScheme.DefaultAct);

            var person = new HumanPerson(personScheme,
                                         defaultActScheme,
                                         evolutionData,
                                         survivalRandomSource,
                                         inventory);

            var actor = new Actor(person, player, startNode);

            actorManager.Add(actor);

            var actorViewModel = new TestActorViewModel
            {
                Actor = actor
            };

            return(actorViewModel);
        }
        public IPerson Create(string personSchemeSid, IFraction fraction)
        {
            var personScheme = _schemeService.GetScheme <IPersonScheme>(personSchemeSid);

            var person = new HumanPerson(personScheme, fraction);

            var attributes = new[]
            {
                new PersonAttribute(PersonAttributeType.PhysicalStrength, 10),
                new PersonAttribute(PersonAttributeType.Dexterity, 10),
                new PersonAttribute(PersonAttributeType.Perception, 10),
                new PersonAttribute(PersonAttributeType.Constitution, 10)
            };
            var attributesModule = new AttributesModule(attributes);

            person.AddModule(attributesModule);

            var inventoryModule = new InventoryModule();

            person.AddModule(inventoryModule);

            var equipmentModule = new EquipmentModule(personScheme.Slots);

            person.AddModule(equipmentModule);

            var сonditionModule = new ConditionsModule();

            person.AddModule(сonditionModule);

            var evolutionModule = new EvolutionModule(_schemeService);

            person.AddModule(evolutionModule);

            var survivalModule = new HumanSurvivalModule(personScheme, _survivalRandomSource, attributesModule,
                                                         сonditionModule, evolutionModule, equipmentModule);

            person.AddModule(survivalModule);

            var defaultActScheme  = _schemeService.GetScheme <ITacticalActScheme>(person.Scheme.DefaultActs.First());
            var defaultActSchemes = new[] { defaultActScheme };
            var combatActModule   = new CombatActModule(
                defaultActSchemes,
                equipmentModule,
                сonditionModule,
                evolutionModule);

            person.AddModule(combatActModule);

            var combatStatsModule = new CombatStatsModule(evolutionModule, equipmentModule);

            person.AddModule(combatStatsModule);

            var diseaseModule = new DiseaseModule(сonditionModule);

            person.AddModule(diseaseModule);

            return(person);
        }
        public void TwoInterfaces_TryValidate_Ok()
        {
            var person = new HumanPerson {
                Name = "Hyacinth", EyeCount = 2, FootCount = 2
            };

            ModelValidator.TryValidateObject(person, Results).Should().BeTrue();
            Results.Should().BeEmpty();
        }
Exemple #9
0
        public IPerson Create(string personSchemeSid)
        {
            var personScheme = _schemeService.GetScheme <IPersonScheme>(personSchemeSid);

            var person = new HumanPerson(personScheme);

            var attributeModule = RollAndAddPersonAttributesToPerson(person);

            var movingModule = new MovingModule(attributeModule);

            person.AddModule(movingModule);

            var inventoryModule = new InventoryModule();

            person.AddModule(inventoryModule);

            var equipmentModule = new EquipmentModule(personScheme.Slots);

            person.AddModule(equipmentModule);

            var effectsModule = new EffectsModule();

            person.AddModule(effectsModule);

            var evolutionModule = new EvolutionModule(_schemeService);

            person.AddModule(evolutionModule);
            RollTraitPerks(evolutionModule);

            var survivalModule = new HumanSurvivalModule(personScheme, _survivalRandomSource, attributeModule, effectsModule, evolutionModule, equipmentModule)
            {
                PlayerEventLogService = PlayerEventLogService
            };

            person.AddModule(survivalModule);

            RollStartEquipment(inventoryModule, person);

            var defaultActScheme = _schemeService.GetScheme <ITacticalActScheme>(person.Scheme.DefaultAct);
            var combatActModule  = new CombatActModule(defaultActScheme, equipmentModule, effectsModule, evolutionModule);

            person.AddModule(combatActModule);

            var combatStatsModule = new CombatStatsModule(evolutionModule, equipmentModule);

            person.AddModule(combatStatsModule);

            var diseaseModule = new DiseaseModule();

            person.AddModule(diseaseModule);

            person.PlayerEventLogService = PlayerEventLogService;

            return(person);
        }
        public void SetEquipment_SetSingleEquipment_HasActs()
        {
            // ARRANGE
            var slotSchemes = new[] {
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var personScheme = new PersonScheme
            {
                Slots = slotSchemes
            };

            var defaultActScheme = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme()
            };

            var evolutionDataMock = new Mock <IEvolutionData>();
            var evolutionData     = evolutionDataMock.Object;

            var survivalRandomSourceMock = new Mock <ISurvivalRandomSource>();
            var survivalRandomSource     = survivalRandomSourceMock.Object;

            var person = new HumanPerson(personScheme, defaultActScheme, evolutionData, survivalRandomSource);

            var propScheme = new TestPropScheme
            {
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[] { EquipmentSlotTypes.Hand }
                }
            };

            var tacticalActScheme = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme()
            };

            var equipment = new Equipment(propScheme, new[] { tacticalActScheme });

            const int expectedSlotIndex = 0;



            // ACT

            person.EquipmentCarrier[expectedSlotIndex] = equipment;



            // ARRANGE
            person.TacticalActCarrier.Acts[0].Stats.Should().Be(tacticalActScheme.Stats);
        }
        public void TwoInterfaces_TryValidate_Fail()
        {
            var person = new HumanPerson {
                Name = "Clumsy Cyclops", EyeCount = 1, FootCount = 1
            };

            ModelValidator.TryValidateObject(person, Results).Should().BeFalse();
            Results.Select(x => x.ErrorMessage).Should().Contain(m => m.Contains("EyeCount"));
            Results.Select(x => x.ErrorMessage).Should().Contain(m => m.Contains("FootCount"));
            Results.Count.Should().Be(2);
        }
Exemple #12
0
    private ActorViewModel CreateHumanActorVm([NotNull] IPlayer player,
                                              [NotNull] PersonScheme personScheme,
                                              [NotNull] IActorManager actorManager,
                                              [NotNull] IMapNode startNode,
                                              [NotNull] IEnumerable <MapNodeVM> nodeVMs)
    {
        if (_personManager.Person == null)
        {
            var inventory = new Inventory();

            var evolutionData = new EvolutionData(_schemeService);
            //evolutionData.PerkLeveledUp += (sender, args) => Debug.Log("LevelUp");

            var defaultActScheme = _schemeService.GetScheme <TacticalActScheme>(personScheme.DefaultAct);

            var person = new HumanPerson(personScheme, defaultActScheme, evolutionData, inventory);

            _personManager.Person = person;

            AddEquipmentToActor(inventory, "battle-axe");
            AddEquipmentToActor(inventory, "short-sword");
            AddEquipmentToActor(inventory, "steel-helmet");
            AddEquipmentToActor(inventory, "steel-armor");
            AddEquipmentToActor(inventory, "pistol");
        }

        var actor = new Actor(_personManager.Person, player, startNode, _personManager.ActorState);

        _personManager.ActorState = actor.State;

        actorManager.Add(actor);

        var actorVm      = Instantiate(ActorPrefab, transform);
        var actorGraphic = Instantiate(HumanoidGraphicPrefab, actorVm.transform);

        actorGraphic.transform.position = new Vector3(0, 0.2f, 0);
        actorVm.GraphicRoot             = actorGraphic;

        var graphicController = actorVm.gameObject.AddComponent <HumanActorGraphicController>();

        graphicController.Actor   = actor;
        graphicController.Graphic = actorGraphic;

        var actorNodeVm   = nodeVMs.Single(x => x.Node == actor.Node);
        var actorPosition = actorNodeVm.transform.position + new Vector3(0, 0, -1);

        actorVm.transform.position = actorPosition;
        actorVm.Actor = actor;

        actorVm.Actor.OpenedContainer += PlayerActorOnOpenedContainer;
        actorVm.Actor.UsedAct         += ActorOnUsedAct;

        return(actorVm);
    }
Exemple #13
0
        public static IActorViewModel CreateHumanActorVm([NotNull] IPlayer player,
                                                         [NotNull] ISchemeService schemeService,
                                                         [NotNull] ISurvivalRandomSource survivalRandomSource,
                                                         [NotNull] IPersonScheme personScheme,
                                                         [NotNull] IActorManager actorManager,
                                                         [NotNull] IGraphNode startNode)
        {
            if (player is null)
            {
                throw new System.ArgumentNullException(nameof(player));
            }

            if (schemeService is null)
            {
                throw new System.ArgumentNullException(nameof(schemeService));
            }

            if (survivalRandomSource is null)
            {
                throw new System.ArgumentNullException(nameof(survivalRandomSource));
            }

            if (personScheme is null)
            {
                throw new System.ArgumentNullException(nameof(personScheme));
            }

            if (actorManager is null)
            {
                throw new System.ArgumentNullException(nameof(actorManager));
            }

            if (startNode is null)
            {
                throw new System.ArgumentNullException(nameof(startNode));
            }

            var person = new HumanPerson(personScheme);

            var actor = new Actor(person, player, startNode);

            actorManager.Add(actor);

            var actorViewModel = new TestActorViewModel
            {
                Actor = actor
            };

            return(actorViewModel);
        }
Exemple #14
0
        protected void FillSlot(HumanPerson person, IDropTableScheme?dropScheme, int slotIndex)
        {
            if (dropScheme is null)
            {
                return;
            }

            // Генерируем предметы.
            // Выбираем предмет, как экипировку в слот.
            // Если он может быть экипирован, то устанавливаем в слот.
            // Остальные дропнутые предметы складываем просто в инвентарь.
            // Если текущий предмет невозможно экипировать, то его тоже помещаем в инвентарь.

            var inventory     = person.GetModule <IInventoryModule>();
            var dropedProps   = DropResolver.Resolve(new[] { dropScheme });
            var usedEquipment = dropedProps.OfType <Equipment>().FirstOrDefault();

            if (usedEquipment != null)
            {
                var equipmentModule = person.GetModule <IEquipmentModule>();
                var canBeEquiped    = CanBeEquiped(equipmentModule, slotIndex, usedEquipment);
                if (canBeEquiped)
                {
                    AddEquipment(equipmentModule, slotIndex, usedEquipment);
                    var unusedMainWeaponDrops = dropedProps.Where(x => x != usedEquipment).ToArray();
                    foreach (var prop in unusedMainWeaponDrops)
                    {
                        AddPropToInventory(inventory, prop);
                    }
                }
                else
                {
                    foreach (var prop in dropedProps)
                    {
                        AddPropToInventory(inventory, prop);
                    }
                }
            }
            else
            {
                foreach (var prop in dropedProps)
                {
                    AddPropToInventory(inventory, prop);
                }
            }
        }
        public static HumanPersonStorageData Create(HumanPerson humanPerson)
        {
            var storageData = new HumanPersonStorageData();

            storageData.Survival = humanPerson.Survival.Stats.Select(x => new HumanSurvivalStatStorageData
            {
                Type  = x.Type,
                Value = x.ValueShare
            }).ToArray();

            storageData.Equipments = humanPerson.EquipmentCarrier.Select(CreateEquipmentStorageData).ToArray();

            storageData.Inventory = humanPerson.Inventory.CalcActualItems().Select(CreatePropStorageData).ToArray();

            storageData.Perks = humanPerson.EvolutionData.Perks.Select(CreatePerkStorageData).ToArray();

            return(storageData);
        }
Exemple #16
0
        private IActor CreateHumanActor([NotNull] IPlayer player,
                                        [NotNull] PersonScheme personScheme,
                                        [NotNull] IMapNode startNode)
        {
            var schemeService = Container.GetInstance <ISchemeService>();

            var evolutionData = new EvolutionData(schemeService);

            var inventory = new Inventory();

            var defaultActScheme = schemeService.GetScheme <TacticalActScheme>(personScheme.DefaultAct);

            var person = new HumanPerson(personScheme, defaultActScheme, evolutionData, inventory);

            var actor = new Actor(person, player, startNode);

            return(actor);
        }
        public void TwoInterfaces_Validate_Fail()
        {
            var person = new HumanPerson {
                Name = "Clumsy Cyclops", EyeCount = 1, FootCount = 1
            };

            person.Invoking(p => ModelValidator.ValidateObject(person))
            .ShouldThrow <ValidationException>()
            .Which.Message.Should().Match(m => m.Contains("EyeCount") || m.Contains("FootCount"));

            person.EyeCount = 2;
            person.Invoking(p => ModelValidator.ValidateObject(person))
            .ShouldThrow <ValidationException>()
            .WithMessage("*FootCount*");

            person.Name = null;
            person.Invoking(p => ModelValidator.ValidateObject(person))
            .ShouldThrow <ValidationException>()
            .WithMessage("*Name*required*");
        }
        public void HumanPerson_SwordSkillsPerk_DamageOfActIsIncreased()
        {
            // ARRANGE

            var slotSchemes = new[] {
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var personScheme = new PersonScheme
            {
                Hp    = 10,
                Slots = slotSchemes
            };

            var defaultActScheme = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme()
            };

            var perkMock = new Mock <IPerk>();

            perkMock.SetupGet(x => x.CurrentLevel).Returns(new PerkLevel(0, 0));
            perkMock.SetupGet(x => x.Scheme).Returns(new PerkScheme
            {
                Levels = new[] {
                    new PerkLevelSubScheme {
                        Rules = new [] {
                            new PerkRuleSubScheme {
                                Type   = PersonRuleType.Damage,
                                Level  = PersonRuleLevel.Absolute,
                                Params = "{\"WeaponTags\":[\"sword\"]}"
                            }
                        }
                    }
                }
            });
            var perk = perkMock.Object;

            var stats = new SkillStatItem[0];

            var evolutionDataMock = new Mock <IEvolutionData>();

            evolutionDataMock.SetupGet(x => x.Perks).Returns(new[] { perk });
            evolutionDataMock.SetupGet(x => x.Stats).Returns(stats);
            var evolutionData = evolutionDataMock.Object;

            var survivalRandomSourceMock = new Mock <ISurvivalRandomSource>();
            var survivalRandomSource     = survivalRandomSourceMock.Object;

            var swordScheme = new TestPropScheme
            {
                Tags  = new[] { "sword" },
                Equip = new TestPropEquipSubScheme
                {
                    SlotTypes = new[] { EquipmentSlotTypes.Hand }
                }
            };

            var swordAct = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme
                {
                    Effect    = TacticalActEffectType.Damage,
                    Efficient = new Roll(1, 1)
                }
            };

            var equipment = new Equipment(swordScheme, new ITacticalActScheme[] { swordAct });



            // ACT
            var person = new HumanPerson(personScheme, defaultActScheme, evolutionData, survivalRandomSource);

            person.EquipmentCarrier[0] = equipment;



            // ASSERT
            var testedAct = person.TacticalActCarrier.Acts[0];

            testedAct.Efficient.Modifiers.ResultBuff.Should().Be(10);
        }
        public HumanPerson Restore(ISchemeService schemeService,
                                   ISurvivalRandomSource survivalRandomSource,
                                   IPropFactory propFactory)
        {
            if (schemeService is null)
            {
                throw new ArgumentNullException(nameof(schemeService));
            }

            if (survivalRandomSource is null)
            {
                throw new ArgumentNullException(nameof(survivalRandomSource));
            }

            if (propFactory is null)
            {
                throw new ArgumentNullException(nameof(propFactory));
            }

            var storedPerson = this;

            var personScheme = schemeService.GetScheme <IPersonScheme>("human-person");

            var inventory = new InventoryModule();

            var evolutionData = new EvolutionModule(schemeService);

            RestoreEvolutionData(schemeService, storedPerson, evolutionData);

            var person = new HumanPerson(personScheme);

            //TODO Создать необходимые модули и заполнить их.

            foreach (var survivalStoredItem in storedPerson.Survival)
            {
                var normalizedValueShare = RangeHelper.NormalizeShare(survivalStoredItem.Value);

                var stat = person.GetModule <ISurvivalModule>().Stats.Single(x => x.Type == survivalStoredItem.Type);

                stat.SetShare(normalizedValueShare);
            }

            foreach (var storedProp in storedPerson.Inventory)
            {
                var   propScheme = schemeService.GetScheme <IPropScheme>(storedProp.Sid);
                IProp prop;
                switch (storedProp.Type)
                {
                case PropType.Resource:
                    prop = propFactory.CreateResource(propScheme, storedProp.Count);
                    break;

                case PropType.Equipment:
                    var equipment = propFactory.CreateEquipment(propScheme);
                    equipment.Durable.Value = storedProp.Durable;
                    prop = equipment;

                    break;

                default:
                    throw new Exception();
                }

                inventory.Add(prop);
            }

            for (var i = 0; i < storedPerson.Equipments.Length; i++)
            {
                var storedEquipment = storedPerson.Equipments[i];

                if (storedEquipment == null)
                {
                    continue;
                }

                var equipmentScheme = schemeService.GetScheme <IPropScheme>(storedEquipment.Sid);

                var equipment = propFactory.CreateEquipment(equipmentScheme);
                equipment.Durable.Value = storedEquipment.Durable;

                person.GetModule <IEquipmentModule>()[i] = equipment;
                //TODO Уменьшать прочность согласно сохранённым данным
            }

            return(person);
        }
Exemple #20
0
        private static IActor CreateHumanActor(HumanPlayer humanPlayer,
                                               ISchemeService schemeService,
                                               ISurvivalRandomSource survivalRandomSource,
                                               IPropFactory propFactory,
                                               ISectorManager sectorManager,
                                               IActorManager actorManager)
        {
            var personScheme = schemeService.GetScheme <IPersonScheme>("human-person");

            var playerActorStartNode = sectorManager.CurrentSector.Map.Regions
                                       .SingleOrDefault(x => x.IsStart).Nodes
                                       .First();

            if (humanPlayer.MainPerson == null)
            {
                var inventory = new Inventory();

                var evolutionData = new EvolutionData(schemeService);

                var defaultActScheme = schemeService.GetScheme <ITacticalActScheme>(personScheme.DefaultAct);

                var person = new HumanPerson(personScheme, defaultActScheme, evolutionData, survivalRandomSource, inventory);

                humanPlayer.MainPerson = person;


                var classRoll = new Random().Next(1, 3);
                switch (classRoll)
                {
                case 1:
                    AddEquipmentToActor(person.EquipmentCarrier, 2, "short-sword", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 1, "steel-armor", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 3, "wooden-shield", schemeService, propFactory);
                    break;

                case 2:
                    AddEquipmentToActor(person.EquipmentCarrier, 2, "battle-axe", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 3, "battle-axe", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 0, "highlander-helmet", schemeService, propFactory);
                    break;

                case 3:
                    AddEquipmentToActor(person.EquipmentCarrier, 2, "bow", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 1, "leather-jacket", schemeService, propFactory);
                    AddEquipmentToActor(inventory, "short-sword", schemeService, propFactory);
                    AddResourceToActor(inventory, "arrow", 10, schemeService, propFactory);
                    break;

                case 4:
                    AddEquipmentToActor(person.EquipmentCarrier, 2, "fireball-staff", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 1, "scholar-robe", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 0, "wizard-hat", schemeService, propFactory);
                    AddResourceToActor(inventory, "mana", 15, schemeService, propFactory);
                    break;

                case 5:
                    AddEquipmentToActor(person.EquipmentCarrier, 2, "pistol", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 0, "elder-hat", schemeService, propFactory);
                    AddResourceToActor(inventory, "bullet-45", 5, schemeService, propFactory);

                    AddResourceToActor(inventory, "packed-food", 1, schemeService, propFactory);
                    AddResourceToActor(inventory, "water-bottle", 1, schemeService, propFactory);
                    AddResourceToActor(inventory, "med-kit", 1, schemeService, propFactory);

                    AddResourceToActor(inventory, "mana", 5, schemeService, propFactory);
                    AddResourceToActor(inventory, "arrow", 3, schemeService, propFactory);
                    break;
                }

                AddResourceToActor(inventory, "packed-food", 1, schemeService, propFactory);
                AddResourceToActor(inventory, "water-bottle", 1, schemeService, propFactory);
                AddResourceToActor(inventory, "med-kit", 1, schemeService, propFactory);
            }

            var actor = new Actor(humanPlayer.MainPerson, humanPlayer, playerActorStartNode);

            actorManager.Add(actor);

            return(actor);
        }
    private ActorViewModel CreateHumanActorViewModel([NotNull] IPlayer player,
                                                     [NotNull] IPersonScheme personScheme,
                                                     [NotNull] IActorManager actorManager,
                                                     [NotNull] ISurvivalRandomSource survivalRandomSource,
                                                     [NotNull] IMapNode startNode,
                                                     [NotNull] IEnumerable <MapNodeVM> nodeVMs)
    {
        if (_humanPlayer.MainPerson == null)
        {
            var inventory = new Inventory();

            var evolutionData = new EvolutionData(_schemeService);

            var defaultActScheme = _schemeService.GetScheme <ITacticalActScheme>(personScheme.DefaultAct);

            var person = new HumanPerson(personScheme, defaultActScheme, evolutionData, survivalRandomSource, inventory);

            _humanPlayer.MainPerson = person;


            var classRoll = UnityEngine.Random.Range(1, 6);
            switch (classRoll)
            {
            case 1:
                AddEquipmentToActor(person.EquipmentCarrier, 2, "short-sword");
                AddEquipmentToActor(person.EquipmentCarrier, 1, "steel-armor");
                AddEquipmentToActor(person.EquipmentCarrier, 3, "wooden-shield");
                break;

            case 2:
                AddEquipmentToActor(person.EquipmentCarrier, 2, "battle-axe");
                AddEquipmentToActor(person.EquipmentCarrier, 3, "battle-axe");
                AddEquipmentToActor(person.EquipmentCarrier, 0, "highlander-helmet");
                break;

            case 3:
                AddEquipmentToActor(person.EquipmentCarrier, 2, "bow");
                AddEquipmentToActor(person.EquipmentCarrier, 1, "leather-jacket");
                AddEquipmentToActor(inventory, "short-sword");
                AddResourceToActor(inventory, "arrow", 10);
                break;

            case 4:
                AddEquipmentToActor(person.EquipmentCarrier, 2, "fireball-staff");
                AddEquipmentToActor(person.EquipmentCarrier, 1, "scholar-robe");
                AddEquipmentToActor(person.EquipmentCarrier, 0, "wizard-hat");
                AddResourceToActor(inventory, "mana", 15);
                break;

            case 5:
                AddEquipmentToActor(person.EquipmentCarrier, 2, "pistol");
                AddEquipmentToActor(person.EquipmentCarrier, 0, "elder-hat");
                AddResourceToActor(inventory, "bullet-45", 5);

                AddResourceToActor(inventory, "packed-food", 1);
                AddResourceToActor(inventory, "water-bottle", 1);
                AddResourceToActor(inventory, "med-kit", 1);

                AddResourceToActor(inventory, "mana", 5);
                AddResourceToActor(inventory, "arrow", 3);
                break;
            }

            AddResourceToActor(inventory, "packed-food", 1);
            AddResourceToActor(inventory, "water-bottle", 1);
            AddResourceToActor(inventory, "med-kit", 1);
        }

        var actor = new Actor(_humanPlayer.MainPerson, player, startNode);

        actorManager.Add(actor);

        var actorViewModelObj = _container.InstantiatePrefab(ActorPrefab, transform);
        var actorViewModel    = actorViewModelObj.GetComponent <ActorViewModel>();
        var actorGraphic      = Instantiate(HumanoidGraphicPrefab, actorViewModel.transform);

        actorGraphic.transform.position = new Vector3(0, 0.2f, 0);
        actorViewModel.GraphicRoot      = actorGraphic;

        var graphicController = actorViewModel.gameObject.AddComponent <HumanActorGraphicController>();

        graphicController.Actor   = actor;
        graphicController.Graphic = actorGraphic;

        var actorNodeVm   = nodeVMs.Single(x => x.Node == actor.Node);
        var actorPosition = actorNodeVm.transform.position + new Vector3(0, 0, -1);

        actorViewModel.transform.position = actorPosition;
        actorViewModel.Actor     = actor;
        actorViewModel.Selected += HumanActorViewModel_Selected;

        actor.OpenedContainer      += PlayerActorOnOpenedContainer;
        actor.UsedAct              += ActorOnUsedAct;
        actor.Person.Survival.Dead += HumanPersonSurvival_Dead;

        return(actorViewModel);
    }
        public void TwoInterfaces_Validate_Fail()
        {
            var person = new HumanPerson {Name = "Clumsy Cyclops", EyeCount = 1, FootCount = 1};
            person.Invoking(p => ModelValidator.ValidateObject(person))
                  .ShouldThrow<ValidationException>()
                  .Which.Message.Should().Match(m => m.Contains("EyeCount") || m.Contains("FootCount"));

            person.EyeCount = 2;
            person.Invoking(p => ModelValidator.ValidateObject(person))
                  .ShouldThrow<ValidationException>()
                  .WithMessage("*FootCount*");

            person.Name = null;
            person.Invoking(p => ModelValidator.ValidateObject(person))
                  .ShouldThrow<ValidationException>()
                  .WithMessage("*Name*required*");
        }
Exemple #23
0
        public void HumanPerson_PerkLeveledUp_StatsRecalculated()
        {
            // ARRANGE

            var slotSchemes = new[] {
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var personScheme = new PersonScheme
            {
                Slots = slotSchemes
            };

            var defaultActScheme = new TacticalActScheme
            {
                Stats = new TacticalActStatsSubScheme
                {
                    Efficient = new Range <float>(1, 1)
                },
                Dependency = new[] {
                    new TacticalActDependencySubScheme(CombatStatType.Melee, 1)
                }
            };

            var perkMock = new Mock <IPerk>();

            perkMock.SetupGet(x => x.CurrentLevel).Returns(new PerkLevel(0, 0));
            perkMock.SetupGet(x => x.Scheme).Returns(new PerkScheme
            {
                Levels = new[] {
                    new PerkLevelSubScheme {
                        Rules = new [] {
                            new PerkRuleSubScheme {
                                Type  = PersonRuleType.Ballistic,
                                Level = PersonRuleLevel.Normal
                            }
                        }
                    }
                }
            });
            var perk = perkMock.Object;

            var evolutionDataMock = new Mock <IEvolutionData>();

            evolutionDataMock.SetupGet(x => x.Perks)
            .Returns(new[] { perk });
            var evolutionData = evolutionDataMock.Object;



            // ACT
            var person = new HumanPerson(personScheme, defaultActScheme, evolutionData);



            // ASSERT
            var testedStat = person.CombatStats.Stats.Single(x => x.Stat == CombatStatType.Ballistic);

            testedStat.Value.Should().Be(11);
        }
        public void HumanPerson_EquipPropWithHungerResistance_DownPassOfSatietyDescreased()
        {
            // ARRANGE

            const int START_PERSON_HP   = 10;
            const int EXPECTED_DOWNPASS = 2;



            var personScheme = new TestPersonScheme
            {
                Hp    = START_PERSON_HP,
                Slots = new[] {
                    new PersonSlotSubScheme
                    {
                        Types = EquipmentSlotTypes.Aux
                    }
                },

                SurvivalStats = new[]
                {
                    new TestPersonSurvivalStatSubScheme
                    {
                        Type       = PersonSurvivalStatType.Satiety,
                        MinValue   = -100,
                        MaxValue   = 100,
                        StartValue = 0
                    },

                    new TestPersonSurvivalStatSubScheme
                    {
                        Type       = PersonSurvivalStatType.Hydration,
                        MinValue   = -100,
                        MaxValue   = 100,
                        StartValue = 0
                    }
                }
            };

            var defaultAct = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme
                {
                    Efficient = new Roll(6, 1)
                }
            };

            var evolutionDataMock = new Mock <IEvolutionData>();
            var evolutionData     = evolutionDataMock.Object;

            var survivalRandomSourceMock = new Mock <ISurvivalRandomSource>();
            var survivalRandomSource     = survivalRandomSourceMock.Object;

            var person = new HumanPerson(personScheme, defaultAct, evolutionData, survivalRandomSource);

            var armorPropScheme = new TestPropScheme
            {
                Equip = new TestPropEquipSubScheme
                {
                    Rules = new[]
                    {
                        new PersonRule(EquipCommonRuleType.HungerResistance, PersonRuleLevel.Normal)
                    },
                    SlotTypes = new[]
                    {
                        EquipmentSlotTypes.Aux
                    }
                }
            };

            var satietyStat = person.Survival.Stats.SingleOrDefault(x => x.Type == SurvivalStatType.Satiety);

            var armorProp = new Equipment(armorPropScheme);



            // ACT
            person.EquipmentCarrier[0] = armorProp;



            // ASSERT
            satietyStat.DownPassRoll.Should().Be(EXPECTED_DOWNPASS);
        }
        public void HumanPerson_EquipPropWithHpBonusWithNoHalfHp_HpStays()
        {
            // ARRANGE

            const int START_PERSON_HP = 10;
            const int NORMAL_HP_BONUS = 3;

            const int EXPECTED_PERSON_HP     = 6;
            const int EXPECTED_PERSON_MAX_HP = START_PERSON_HP + NORMAL_HP_BONUS;

            var personScheme = new TestPersonScheme
            {
                Hp    = START_PERSON_HP,
                Slots = new[] {
                    new PersonSlotSubScheme
                    {
                        Types = EquipmentSlotTypes.Body
                    }
                }
            };

            var defaultAct = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme
                {
                    Efficient = new Roll(6, 1)
                }
            };

            var evolutionDataMock = new Mock <IEvolutionData>();
            var evolutionData     = evolutionDataMock.Object;

            var survivalRandomSourceMock = new Mock <ISurvivalRandomSource>();
            var survivalRandomSource     = survivalRandomSourceMock.Object;

            var person = new HumanPerson(personScheme, defaultAct, evolutionData, survivalRandomSource);

            var armorPropScheme = new TestPropScheme
            {
                Equip = new TestPropEquipSubScheme
                {
                    Rules = new[]
                    {
                        new PersonRule(EquipCommonRuleType.Health, PersonRuleLevel.Normal)
                    },
                    SlotTypes = new[]
                    {
                        EquipmentSlotTypes.Body
                    }
                }
            };

            var armorProp = new Equipment(armorPropScheme, new ITacticalActScheme[0]);

            var hpStat = person.Survival.Stats.SingleOrDefault(x => x.Type == SurvivalStatType.Health);

            person.Survival.DecreaseStat(SurvivalStatType.Health, hpStat.Value / 2);



            // ACT
            person.EquipmentCarrier[0] = armorProp;



            // ASSERT
            hpStat.Range.Max.Should().Be(EXPECTED_PERSON_MAX_HP);
            hpStat.Value.Should().Be(EXPECTED_PERSON_HP);
        }
        public void HumanPerson_PerkLeveledUp_StatsRecalculated()
        {
            // ARRANGE

            var slotSchemes = new[] {
                new PersonSlotSubScheme {
                    Types = EquipmentSlotTypes.Hand
                }
            };

            var personScheme = new PersonScheme
            {
                Slots = slotSchemes
            };

            var defaultActScheme = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme()
            };

            var perkMock = new Mock <IPerk>();

            perkMock.SetupGet(x => x.CurrentLevel).Returns(new PerkLevel(0, 0));
            perkMock.SetupGet(x => x.Scheme).Returns(new PerkScheme
            {
                Levels = new[] {
                    new PerkLevelSubScheme {
                        Rules = new [] {
                            new PerkRuleSubScheme {
                                Type  = PersonRuleType.Ballistic,
                                Level = PersonRuleLevel.Lesser
                            }
                        }
                    }
                }
            });
            var perk = perkMock.Object;

            var stats = new[] {
                new SkillStatItem {
                    Stat = SkillStatType.Ballistic, Value = 10
                }
            };

            var evolutionDataMock = new Mock <IEvolutionData>();

            evolutionDataMock.SetupGet(x => x.Perks).Returns(new[] { perk });
            evolutionDataMock.SetupGet(x => x.Stats).Returns(stats);
            var evolutionData = evolutionDataMock.Object;

            var survivalRandomSourceMock = new Mock <ISurvivalRandomSource>();
            var survivalRandomSource     = survivalRandomSourceMock.Object;



            // ACT
            var person = new HumanPerson(personScheme, defaultActScheme, evolutionData, survivalRandomSource);



            // ASSERT
            var testedStat = person.EvolutionData.Stats.Single(x => x.Stat == SkillStatType.Ballistic);

            testedStat.Value.Should().Be(11);
        }
 public void TwoInterfaces_TryValidate_Ok()
 {
     var person = new HumanPerson {Name = "Hyacinth", EyeCount = 2, FootCount = 2};
     ModelValidator.TryValidateObject(person, Results).Should().BeTrue();
     Results.Should().BeEmpty();
 }
        private static IActor CreateHumanActor(HumanPlayer humanPlayer,
                                               ISchemeService schemeService,
                                               ISurvivalRandomSource survivalRandomSource,
                                               IPropFactory propFactory,
                                               ISectorManager sectorManager,
                                               IActorManager actorManager)
        {
            var personScheme = schemeService.GetScheme <IPersonScheme>("human-person");

            var playerActorStartNode = sectorManager.CurrentSector.Map.Regions
                                       .SingleOrDefault(x => x.IsStart).Nodes
                                       .First();

            if (humanPlayer.MainPerson == null)
            {
                var inventory = new Inventory();

                var evolutionData = new EvolutionData(schemeService);

                var defaultActScheme = schemeService.GetScheme <ITacticalActScheme>(personScheme.DefaultAct);

                var person = new HumanPerson(personScheme, defaultActScheme, evolutionData, survivalRandomSource, inventory);

                humanPlayer.MainPerson = person;

                // TODO Использовать генератор персонажа, как в игре.
                // Для этого нужно научить ботов корректно использовать оружие дальнего боя и посохи лечения.
                var classRoll = new Random().Next(1, 3);
                switch (classRoll)
                {
                case 1:
                    AddEquipmentToActor(person.EquipmentCarrier, 2, "short-sword", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 1, "steel-armor", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 3, "wooden-shield", schemeService, propFactory);
                    break;

                case 2:
                    AddEquipmentToActor(person.EquipmentCarrier, 2, "battle-axe", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 3, "battle-axe", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 0, "highlander-helmet", schemeService, propFactory);
                    break;

                case 3:
                    AddEquipmentToActor(person.EquipmentCarrier, 2, "bow", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 1, "leather-jacket", schemeService, propFactory);
                    AddEquipmentToActor(inventory, "short-sword", schemeService, propFactory);
                    AddResourceToActor(inventory, "arrow", 10, schemeService, propFactory);
                    break;

                case 4:
                    AddEquipmentToActor(person.EquipmentCarrier, 2, "fireball-staff", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 1, "scholar-robe", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 0, "wizard-hat", schemeService, propFactory);
                    AddResourceToActor(inventory, "mana", 15, schemeService, propFactory);
                    break;

                case 5:
                    AddEquipmentToActor(person.EquipmentCarrier, 2, "pistol", schemeService, propFactory);
                    AddEquipmentToActor(person.EquipmentCarrier, 0, "elder-hat", schemeService, propFactory);
                    AddResourceToActor(inventory, "bullet-45", 5, schemeService, propFactory);

                    AddResourceToActor(inventory, "packed-food", 1, schemeService, propFactory);
                    AddResourceToActor(inventory, "water-bottle", 1, schemeService, propFactory);
                    AddResourceToActor(inventory, "med-kit", 1, schemeService, propFactory);

                    AddResourceToActor(inventory, "mana", 5, schemeService, propFactory);
                    AddResourceToActor(inventory, "arrow", 3, schemeService, propFactory);
                    break;

                default:
                    throw new InvalidOperationException("Эта комбинация начальной экипировки не поддерживается.");
                }

                AddResourceToActor(inventory, "packed-food", 1, schemeService, propFactory);
                AddResourceToActor(inventory, "water-bottle", 1, schemeService, propFactory);
                AddResourceToActor(inventory, "med-kit", 1, schemeService, propFactory);
            }

            var actor = new Actor(humanPlayer.MainPerson, humanPlayer, playerActorStartNode);

            actorManager.Add(actor);

            return(actor);
        }
Exemple #29
0
        public IPerson Create(string personSchemeSid, IFraction fraction)
        {
            var personScheme = SchemeService.GetScheme <IPersonScheme>(personSchemeSid);

            var person = new HumanPerson(personScheme, fraction);

            var attributeModule = RollAndAddPersonAttributesToPerson(person);

            var movingModule = new MovingModule(attributeModule);

            person.AddModule(movingModule);

            var inventoryModule = new InventoryModule();

            person.AddModule(inventoryModule);

            var notNullSlots    = personScheme.Slots.Select(x => x !).ToArray();
            var equipmentModule = new EquipmentModule(notNullSlots);

            person.AddModule(equipmentModule);

            var effectsModule = new ConditionsModule();

            person.AddModule(effectsModule);

            var evolutionModule = new EvolutionModule(SchemeService);

            person.AddModule(evolutionModule);
            RollTraitPerks(evolutionModule);

            var survivalModule = new HumanSurvivalModule(personScheme, _survivalRandomSource, attributeModule,
                                                         effectsModule, evolutionModule, equipmentModule)
            {
                PlayerEventLogService = PlayerEventLogService
            };

            person.AddModule(survivalModule);

            RollStartEquipment(inventoryModule, person);

            if (person.Scheme.DefaultActs is null)
            {
                throw new InvalidOperationException();
            }

            var defaultActSchemes =
                person.Scheme.DefaultActs.Select(x => SchemeService.GetScheme <ITacticalActScheme>(x));
            var combatActModule = new CombatActModule(
                defaultActSchemes,
                equipmentModule,
                effectsModule,
                evolutionModule);

            person.AddModule(combatActModule);

            var combatStatsModule = new CombatStatsModule(evolutionModule, equipmentModule);

            person.AddModule(combatStatsModule);

            var diseaseModule = new DiseaseModule(effectsModule);

            person.AddModule(diseaseModule);

            var fowModule = new FowData();

            person.AddModule(fowModule);

            person.PlayerEventLogService = PlayerEventLogService;

            return(person);
        }
 protected abstract void RollStartEquipment(IInventoryModule inventory, HumanPerson person);
        public void HumanPerson_MultipleDifferentArmor_AllArmorsInStats()
        {
            // ARRANGE

            var personScheme = new TestPersonScheme
            {
                Slots = new[] {
                    new PersonSlotSubScheme
                    {
                        Types = EquipmentSlotTypes.Head
                    },
                    new PersonSlotSubScheme
                    {
                        Types = EquipmentSlotTypes.Body
                    }
                }
            };

            var defaultAct = new TestTacticalActScheme
            {
                Stats = new TestTacticalActStatsSubScheme
                {
                    Efficient = new Roll(6, 1)
                }
            };

            var evolutionDataMock = new Mock <IEvolutionData>();
            var evolutionData     = evolutionDataMock.Object;

            var survivalRandomSourceMock = new Mock <ISurvivalRandomSource>();
            var survivalRandomSource     = survivalRandomSourceMock.Object;

            var person = new HumanPerson(personScheme, defaultAct, evolutionData, survivalRandomSource);

            var armorHeadPropScheme = new TestPropScheme
            {
                Equip = new TestPropEquipSubScheme
                {
                    Armors = new IPropArmorItemSubScheme[]
                    {
                        new TestPropArmorItemSubScheme {
                            Impact          = ImpactType.Kinetic,
                            ArmorRank       = 1,
                            AbsorbtionLevel = PersonRuleLevel.Lesser
                        },
                        new TestPropArmorItemSubScheme {
                            Impact          = ImpactType.Psy,
                            ArmorRank       = 10,
                            AbsorbtionLevel = PersonRuleLevel.Normal
                        }
                    },
                    SlotTypes = new[] {
                        EquipmentSlotTypes.Head
                    }
                }
            };

            var armorBodyPropScheme = new TestPropScheme
            {
                Equip = new TestPropEquipSubScheme
                {
                    Armors = new IPropArmorItemSubScheme[]
                    {
                        new TestPropArmorItemSubScheme {
                            Impact          = ImpactType.Kinetic,
                            ArmorRank       = 18,
                            AbsorbtionLevel = PersonRuleLevel.Normal
                        }
                    },
                    SlotTypes = new[] {
                        EquipmentSlotTypes.Body
                    }
                }
            };

            var armorHeadProp = new Equipment(armorHeadPropScheme, new ITacticalActScheme[0]);
            var armorBodyProp = new Equipment(armorBodyPropScheme, new ITacticalActScheme[0]);



            // ACT
            person.EquipmentCarrier[0] = armorHeadProp;
            person.EquipmentCarrier[1] = armorBodyProp;



            // ASSERT
            person.CombatStats.DefenceStats.Armors[0].Impact.Should().Be(ImpactType.Kinetic);
            person.CombatStats.DefenceStats.Armors[0].ArmorRank.Should().Be(1 + 9 + 6);
            person.CombatStats.DefenceStats.Armors[0].AbsorbtionLevel.Should().Be(PersonRuleLevel.Lesser);

            person.CombatStats.DefenceStats.Armors[1].Impact.Should().Be(ImpactType.Psy);
            person.CombatStats.DefenceStats.Armors[1].ArmorRank.Should().Be(10);
            person.CombatStats.DefenceStats.Armors[1].AbsorbtionLevel.Should().Be(PersonRuleLevel.Normal);
        }
Exemple #32
0
        private static void Main()
        {
            var humanPerson = new HumanPerson();

            WriteLine("Person: {0}", humanPerson);
        }
 public void TwoInterfaces_TryValidate_Fail()
 {
     var person = new HumanPerson {Name = "Clumsy Cyclops", EyeCount = 1, FootCount = 1};
     ModelValidator.TryValidateObject(person, Results).Should().BeFalse();
     Results.Select(x => x.ErrorMessage).Should().Contain(m => m.Contains("EyeCount"));
     Results.Select(x => x.ErrorMessage).Should().Contain(m => m.Contains("FootCount"));
     Results.Count.Should().Be(2);
 }