Пример #1
0
        public BodyPart(IStorageType storageType, float hitProbability, float damageFactor)
        {
            bodyPartImplementation = new Inventory(storageType);
            HitProbability = hitProbability;
            DamageFactor = damageFactor;

        }
Пример #2
0
        public DokanBackend(string pSource)
        {
            Storage = new T();
            Storage.Setup(pSource);

            path = pSource;
        }
Пример #3
0
        public void TestThatCreateUpdateCommandReturnsSqlCommandForUpdate(bool hasDescription)
        {
            Guid         identifier            = Guid.NewGuid();
            Guid         householdIdentifier   = Guid.NewGuid();
            IHousehold   householdMock         = DomainObjectMockBuilder.BuildHouseholdMock(householdIdentifier);
            int          sortOrder             = GetLegalSortOrder();
            Guid         storageTypeIdentifier = Guid.NewGuid();
            IStorageType storageTypeMock       = DomainObjectMockBuilder.BuildStorageTypeMock(storageTypeIdentifier);
            int          temperature           = GetLegalTemperature(storageTypeMock.TemperatureRange);
            DateTime     creationTime          = DateTime.Now;
            string       description           = hasDescription ? _fixture.Create <string>() : null;

            IStorageProxy sut = CreateSut(identifier, householdMock, sortOrder, storageTypeMock, temperature, creationTime, description);

            Assert.That(sut, Is.Not.Null);

            // ReSharper disable StringLiteralTypo
            new DbCommandTestBuilder("UPDATE Storages SET HouseholdIdentifier=@householdIdentifier,SortOrder=@sortOrder,StorageTypeIdentifier=@storageTypeIdentifier,Descr=@descr,Temperature=@temperature,CreationTime=@creationTime WHERE StorageIdentifier=@storageIdentifier")
            // ReSharper restore StringLiteralTypo
            .AddCharDataParameter("@storageIdentifier", identifier)
            .AddCharDataParameter("@householdIdentifier", householdIdentifier)
            .AddTinyIntDataParameter("@sortOrder", sortOrder, 4)
            .AddCharDataParameter("@storageTypeIdentifier", storageTypeIdentifier)
            // ReSharper disable StringLiteralTypo
            .AddVarCharDataParameter("@descr", description, 2048, true)
            // ReSharper restore StringLiteralTypo
            .AddTinyIntDataParameter("@temperature", temperature, 4)
            .AddDateTimeDataParameter("@creationTime", creationTime.ToUniversalTime())
            .Build()
            .Run(sut.CreateUpdateCommand());
        }
Пример #4
0
        protected virtual void SetupChampionBody(IBody body, IEnumerable <IGrabableItem> items)
        {
            var hands = new IStorageType[]
            {
                ActionHandStorageType.Instance,
                ReadyHandStorageType.Instance
            };

            var handsEnumerator = hands.Cast <IStorageType>().GetEnumerator();

            foreach (var i in items)
            {
                var carryLocations = i.FactoryBase.CarryLocation;
                var storage        = carryLocations.Except(hands.Concat(carryLocations.Where(x => !x.IsBodyPart))).FirstOrDefault();

                if (storage == null)
                {
                    storage = handsEnumerator.MoveNext() ? handsEnumerator.Current : BackPackStorageType.Instance;
                }

                if (storage == ConsumableStorageType.Instance)
                {
                    storage = BackPackStorageType.Instance;
                }

                if (!body.GetStorage(storage).AddItem(i))
                {
                    throw new InvalidOperationException("Shouldn't be possible.");
                }
            }
        }
        /// <summary>
        /// Build a mockup for a storage type.
        /// </summary>
        /// <returns>Mockup for a storage type.</returns>
        public static IStorageType BuildStorageTypeMock(Guid?storageTypeIdentifier = null, int?sortOrder = null)
        {
            Guid identifier = storageTypeIdentifier ?? Guid.NewGuid();

            IStorageType storageType = MockRepository.GenerateMock <IStorageType>();

            storageType.Stub(m => m.Identifier)
            .Return(identifier)
            .Repeat.Any();
            storageType.Stub(m => m.SortOrder)
            .Return(sortOrder ?? Fixture.Create <int>())
            .Repeat.Any();
            storageType.Stub(m => m.Temperature)
            .Return(Fixture.Create <int>())
            .Repeat.Any();
            storageType.Stub(m => m.TemperatureRange)
            .Return(BuildIntRange())
            .Repeat.Any();
            storageType.Stub(m => m.Creatable)
            .Return(Fixture.Create <bool>())
            .Repeat.Any();
            storageType.Stub(m => m.Editable)
            .Return(Fixture.Create <bool>())
            .Repeat.Any();
            storageType.Stub(m => m.Deletable)
            .Return(Fixture.Create <bool>())
            .Repeat.Any();
            storageType.Stub(m => m.Translation)
            .Return(BuildTranslationMock(identifier))
            .Repeat.Any();
            storageType.Stub(m => m.Translations)
            .Return(BuildTranslationMockCollection(identifier))
            .Repeat.Any();
            return(storageType);
        }
Пример #6
0
        public static int F312_xzzz_CHAMPION_GetStrength(ILiveEntity attackProvider, IStorageType P651_i_SlotIndex)
        {
            int L0935_i_Strength = rand.Next(16) + attackProvider.GetProperty(PropertyFactory <StrengthProperty> .Instance).MaxValue;
            var L0938_T_Thing    = attackProvider.Body.GetStorage(P651_i_SlotIndex).Storage.First();
            //if ((A0936_ui_ObjectWeight = F140_yzzz_DUNGEON_GetObjectWeight(L0938_T_Thing)) <= (A0937_ui_OneSixteenthMaximumLoad = F309_awzz_CHAMPION_GetMaximumLoad(L0939_ps_Champion) >> 4))
            int A0936_ui_ObjectWeight            = (int)L0938_T_Thing.FactoryBase.Weight;
            int A0937_ui_OneSixteenthMaximumLoad = attackProvider.GetProperty(PropertyFactory <LoadProperty> .Instance).MaxValue >> 4;

            if (A0936_ui_ObjectWeight <= A0937_ui_OneSixteenthMaximumLoad)
            {
                L0935_i_Strength += A0936_ui_ObjectWeight - 12;
            }
            else
            {
                int L0941_i_LoadThreshold;
                if (A0936_ui_ObjectWeight <= (L0941_i_LoadThreshold = A0937_ui_OneSixteenthMaximumLoad + ((A0937_ui_OneSixteenthMaximumLoad - 12) >> 1)))
                {
                    L0935_i_Strength += (A0936_ui_ObjectWeight - A0937_ui_OneSixteenthMaximumLoad) >> 1;
                }
                else
                {
                    L0935_i_Strength -= (A0936_ui_ObjectWeight - L0941_i_LoadThreshold) << 1;
                }
            }
            //if (M12_TYPE(L0938_T_Thing) == C05_THING_TYPE_WEAPON)
            if (L0938_T_Thing is Weapon)
            {
                //#ifdef C01_COMPILE_DM10aEN_DM10bEN /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                //                L0940_ps_WeaponInfo = &G238_as_Graphic559_WeaponInfo[((WEAPON*)G284_apuc_ThingData[C05_THING_TYPE_WEAPON])[M13_INDEX(L0938_T_Thing)].Type];
                //#endif
                //#ifdef C15_COMPILE_DM11EN_DM12EN_DM12GE_DM13aFR_DM13bFR_CSB20EN_CSB21EN /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                var L0940_ps_WeaponInfo = L0938_T_Thing as Weapon;
                //#endif
                L0935_i_Strength += L0940_ps_WeaponInfo.FactoryType.Strength;
                int A0936_ui_SkillLevel = 0;
                var A0937_ui_Class      = L0940_ps_WeaponInfo.FactoryType.Class;
                if ((A0937_ui_Class == WeaponClass.C000_CLASS_SWING_WEAPON) || (A0937_ui_Class == WeaponClass.C002_CLASS_DAGGER_AND_AXES))
                {
                    A0936_ui_SkillLevel = attackProvider.GetSkill(SkillFactory <SwingSkill> .Instance).SkillLevel;
                }
                if ((A0937_ui_Class != WeaponClass.C000_CLASS_SWING_WEAPON) && (A0937_ui_Class < WeaponClass.C016_CLASS_FIRST_BOW))
                {
                    A0936_ui_SkillLevel += attackProvider.GetSkill(SkillFactory <ThrowSkill> .Instance).SkillLevel;
                }
                if ((A0937_ui_Class >= WeaponClass.C016_CLASS_FIRST_BOW) && (A0937_ui_Class < WeaponClass.C112_CLASS_FIRST_MAGIC_WEAPON))
                {
                    A0936_ui_SkillLevel += attackProvider.GetSkill(SkillFactory <ShootSkill> .Instance).SkillLevel;
                }
                L0935_i_Strength += A0936_ui_SkillLevel << 1;
            }
            L0935_i_Strength = F306_xxxx_CHAMPION_GetStaminaAdjustedValue(attackProvider.GetProperty(PropertyFactory <StaminaProperty> .Instance), /*L0939_ps_Champion,*/ L0935_i_Strength);
            //if (M07_GET(L0939_ps_Champion->Wounds, (P651_i_SlotIndex == C00_SLOT_READY_HAND) ? MASK0x0001_READY_HAND : MASK0x0002_ACTION_HAND))
            if (attackProvider.Body.GetBodyStorage(P651_i_SlotIndex).IsWounded)
            {
                L0935_i_Strength >>= 1;
            }
            //return F026_a003_MAIN_GetBoundedValue(0, L0935_i_Strength >> 1, 100);
            return(MathHelper.Clamp(L0935_i_Strength >> 1, 0, 100));
        }
Пример #7
0
        /// <summary>
        /// Builds a mockup for a storage which can be used for unit testing.
        /// </summary>
        /// <returns>Mockup for a storage which can be used for unit testing.</returns>
        private IStorage BuildStorageMock(bool hasStorageType = true, IStorageType storageType = null)
        {
            IStorage storageMock = MockRepository.GenerateMock <IStorage>();

            storageMock.Stub(m => m.StorageType)
            .Return(hasStorageType ? storageType ?? BuildStorageTypeMock(StorageType.IdentifierForRefrigerator) : null)
            .Repeat.Any();
            return(storageMock);
        }
Пример #8
0
        /// <summary>
        /// Creates a data proxy to a given storage.
        /// </summary>
        /// <param name="household">Household where the storage are placed.</param>
        /// <param name="sortOrder">Sort order for the storage.</param>
        /// <param name="storageType">Storage type for the storage.</param>
        /// <param name="temperature">Temperature for the storage.</param>
        /// <param name="creationTime">Creation date and time for when the storage was created.</param>
        /// <param name="description">Description for the storage.</param>
        /// <param name="dataProvider">The data provider which the created data proxy should use.</param>
        public StorageProxy(IHousehold household, int sortOrder, IStorageType storageType, int temperature, DateTime creationTime, string description = null, IDataProviderBase <MySqlDataReader, MySqlCommand> dataProvider = null)
            : base(household, sortOrder, storageType, temperature, creationTime, description)
        {
            if (dataProvider == null)
            {
                return;
            }

            _dataProvider = (IFoodWasteDataProvider)dataProvider;
        }
Пример #9
0
        public Inventory(IStorageType type)
        {
            if (type == null)
                throw new ArgumentNullException();

            if (type.Size < 1)
                throw new ArgumentException("Invalid storage size!");

            Type = type;
            storage = new IGrabableItem[type.Size];
        }
        /// <summary>
        /// Validates whether a storage can be removed.
        /// </summary>
        /// <param name="storage">The storage to validate.</param>
        /// <returns>True when the storage can be removed otherwise false.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="storage"/> is null.</exception>
        public virtual bool CanRemoveStorage(IStorage storage)
        {
            ArgumentNullGuard.NotNull(storage, nameof(storage));

            IStorageType storageType = storage.StorageType;

            if (storageType == null)
            {
                return(true);
            }

            return(storageType.Deletable);
        }
Пример #11
0
        public void TestThatCanRemoveStorageCallsDeletableOnStorageTypeWhenStorageDoesHaveStorageType()
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            IStorageType storageTypeMock = BuildStorageTypeMock(StorageType.IdentifierForRefrigerator);
            IStorage     storageMock     = BuildStorageMock(storageType: storageTypeMock);

            sut.CanRemoveStorage(storageMock);

            storageTypeMock.AssertWasCalled(m => m.Deletable, opt => opt.Repeat.Once());
        }
Пример #12
0
        public void TestThatCanRemoveStorageReturnsDeletableFromStorageTypeWhenStorageDoesHaveCreatableStorageType(bool deletable)
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            IStorageType storageTypeMock = BuildStorageTypeMock(StorageType.IdentifierForRefrigerator, deletable: deletable);
            IStorage     storageMock     = BuildStorageMock(storageType: storageTypeMock);

            bool result = sut.CanRemoveStorage(storageMock);

            Assert.That(result, Is.EqualTo(deletable));
        }
Пример #13
0
        /// <summary>
        /// Creates a storage
        /// </summary>
        /// <param name="household">Household where the storage are placed.</param>
        /// <param name="sortOrder">Sort order for the storage.</param>
        /// <param name="storageType">Storage type for the storage.</param>
        /// <param name="description">Description for the storage.</param>
        /// <param name="temperature">Temperature for the storage.</param>
        /// <param name="creationTime">Creation date and time for when the storage was created.</param>
        /// <param name="domainObjectValidations">Implementation of the common validations used by domain objects in the food waste domain.</param>
        protected Storage(IHousehold household, int sortOrder, IStorageType storageType, string description, int temperature, DateTime creationTime, IDomainObjectValidations domainObjectValidations)
        {
            ArgumentNullGuard.NotNull(household, nameof(household))
            .NotNull(storageType, nameof(storageType))
            .NotNull(domainObjectValidations, nameof(domainObjectValidations));

            _domainObjectValidations = domainObjectValidations;

            _household    = household;
            _sortOrder    = ValidateSortOrder(sortOrder, nameof(sortOrder));
            _storageType  = storageType;
            _description  = description;
            _temperature  = ValidateTemperature(temperature, nameof(temperature));
            _creationTime = creationTime;
        }
Пример #14
0
        /// <summary>
        /// Builds a mockup for a storage type which can be used for unit testing.
        /// </summary>
        /// <returns>Mockup for a storage type which can be used for unit testing.</returns>
        private IStorageType BuildStorageTypeMock(Guid storageTypeIdentifier, bool?creatable = null, bool?deletable = null)
        {
            IStorageType storageTypeMock = MockRepository.GenerateMock <IStorageType>();

            storageTypeMock.Stub(m => m.Identifier)
            .Return(storageTypeIdentifier)
            .Repeat.Any();
            storageTypeMock.Stub(m => m.Creatable)
            .Return(creatable ?? _fixture.Create <bool>())
            .Repeat.Any();
            storageTypeMock.Stub(m => m.Deletable)
            .Return(deletable ?? _fixture.Create <bool>())
            .Repeat.Any();
            return(storageTypeMock);
        }
Пример #15
0
        public Inventory(IStorageType type)
        {
            if (type == null)
            {
                throw new ArgumentNullException();
            }

            if (type.Size < 1)
            {
                throw new ArgumentException("Invalid storage size!");
            }

            Type    = type;
            storage = new IGrabableItem[type.Size];
        }
        /// <summary>
        /// Validates whether a storage can be added to an existing storages collection.
        /// </summary>
        /// <param name="storage">The storage to validate.</param>
        /// <param name="existingStorageCollection">The existing storage collection.</param>
        /// <returns>True when the storage can be added to the existing storage collection otherwise false.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="storage"/> or <paramref name="existingStorageCollection"/> is null.</exception>
        public virtual bool CanAddStorage(IStorage storage, IEnumerable <IStorage> existingStorageCollection)
        {
            ArgumentNullGuard.NotNull(storage, nameof(storage))
            .NotNull(existingStorageCollection, nameof(existingStorageCollection));

            IStorageType storageType = storage.StorageType;

            if (storageType == null)
            {
                return(false);
            }

            if (storageType.Creatable)
            {
                return(true);
            }

            return(existingStorageCollection.Any(m => m.StorageType != null && m.StorageType.Identifier == storageType.Identifier) == false);
        }
Пример #17
0
        public void TestThatCanAddStorageReturnsTrueWhenStorageDoesHaveNonCreatableStorageTypeAndExistingStorageCollectionDoesNotContainStorageOfStorageType()
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            IStorageType           storageTypeMock           = BuildStorageTypeMock(StorageType.IdentifierForRefrigerator, false);
            IStorage               storageMock               = BuildStorageMock(storageType: storageTypeMock);
            IEnumerable <IStorage> existingStorageCollection = new List <IStorage>
            {
                BuildStorageMock(storageType: BuildStorageTypeMock(StorageType.IdentifierForFreezer)),
                BuildStorageMock(storageType: BuildStorageTypeMock(StorageType.IdentifierForKitchenCabinets)),
                BuildStorageMock(storageType: BuildStorageTypeMock(StorageType.IdentifierForShoppingBasket))
            };

            bool result = sut.CanAddStorage(storageMock, existingStorageCollection);

            Assert.That(result, Is.True);
        }
Пример #18
0
        public void TestThatCanAddStorageCallsCreatableOnStorageTypeWhenStorageDoesHaveStorageType()
        {
            IDomainObjectValidations sut = new DomainObjectValidations();

            Assert.That(sut, Is.Not.Null);

            IStorageType           storageTypeMock           = BuildStorageTypeMock(StorageType.IdentifierForRefrigerator);
            IStorage               storageMock               = BuildStorageMock(storageType: storageTypeMock);
            IEnumerable <IStorage> existingStorageCollection = new List <IStorage>
            {
                BuildStorageMock(storageType: BuildStorageTypeMock(StorageType.IdentifierForRefrigerator)),
                BuildStorageMock(storageType: BuildStorageTypeMock(StorageType.IdentifierForFreezer)),
                BuildStorageMock(storageType: BuildStorageTypeMock(StorageType.IdentifierForKitchenCabinets)),
                BuildStorageMock(storageType: BuildStorageTypeMock(StorageType.IdentifierForShoppingBasket))
            };

            sut.CanAddStorage(storageMock, existingStorageCollection);

            storageTypeMock.AssertWasCalled(m => m.Creatable, opt => opt.Repeat.Once());
        }
        public void TestThatGetUpdatesStorage()
        {
            Fixture fixture = new Fixture();
            Random  random  = new Random(fixture.Create <int>());

            IStorageType storageType = _householdDataRepository.Get <IStorageType>(StorageType.IdentifierForRefrigerator);

            Assert.That(storageType, Is.Not.Null);

            IHousehold household = _householdDataRepository.Insert(new Household(fixture.Create <string>()));

            try
            {
                IStorage storage = _householdDataRepository.Insert(new Storage(household, random.Next(1, 100), storageType, random.Next(storageType.TemperatureRange.StartValue, storageType.TemperatureRange.EndValue), DateTime.Now));
                try
                {
                    Assert.That(storage.Description, Is.Null);

                    storage.Description = fixture.Create <string>();
                    _householdDataRepository.Update(storage);

                    // ReSharper disable PossibleInvalidOperationException
                    IStorage result = _householdDataRepository.Get <IStorage>(storage.Identifier.Value);
                    // ReSharper restore PossibleInvalidOperationException
                    Assert.That(result, Is.Not.Null);
                    Assert.That(result.Description, Is.Not.Null);
                    Assert.That(result.Description, Is.Not.Empty);
                    Assert.That(result.Description, Is.EqualTo(storage.Description));
                }
                finally
                {
                    _householdDataRepository.Delete(storage);
                }
            }
            finally
            {
                _householdDataRepository.Delete(household);
            }
        }
Пример #20
0
        public static IStorageType storageTypeCreater(String storageType)
        {
            IStorageType istorageType = null;

            switch (storageType)
            {
            case LOCAL:
                istorageType = new LocalStorageType();
                break;

            case FTP:
                istorageType = new FtpStorageType();
                break;

            case FASTDFS:
                istorageType = new FastDfsStorageType();
                break;

            case HDFS:
                istorageType = new HdfsStorageType();
                break;
            }
            return(istorageType);
        }
Пример #21
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            FileClient fileClient = new FileClient();

            Console.WriteLine("卫语句输出");
            //if else
            fileClient.uploadFile("hdfs", "ifelse.txt");
            //with out if else
            fileClient.uploadFileWithoutElse("hdfs", "ifelse.txt");

            Console.WriteLine("工厂模式输出");
            //factory build object工厂模式
            IStorageType storageType = Factory.storageTypeCreater("hdfs");

            storageType.uploadFile("simpleFactory.txt");
            storageType = Factory.storageTypeCreater("fastdfs");
            storageType.uploadFile("simpleFactory.txt");
            storageType = Factory.storageTypeCreater("ftp");
            storageType.uploadFile("simpleFactory.txt");
            storageType = Factory.storageTypeCreater("local");
            storageType.uploadFile("simpleFactory.txt");

            Console.WriteLine("策略模式输出");
            //策略模式
            StorageContext storageContext = new StorageContext(new LocalStorageStrategy());

            storageContext.uploadFileAction("策略模式");
            storageContext = new StorageContext(new FtpStorageStrategy());
            storageContext.uploadFileAction("策略模式");
            storageContext = new StorageContext(new FastDfsStorageStrategy());
            storageContext.uploadFileAction("策略模式");
            storageContext = new StorageContext(new HdfsStorageStrategy());
            storageContext.uploadFileAction("策略模式");
        }
Пример #22
0
 public IBodyPart GetBodyStorage(IStorageType storageType) => BodyParts.FirstOrDefault(s => s.Type == storageType);
Пример #23
0
 public IInventory GetStorage(IStorageType type) => Storages.FirstOrDefault(s => s.Type == type);
Пример #24
0
        int F230_ezzz_GROUP_GetChampionDamage(/*group P493_ps_Group, int */ ILiveEntity P494_i_ChampionIndex)
        {
            var champion = P494_i_ChampionIndex; //&G407_s_Party.Champions[P494_i_ChampionIndex];
            //if (P494_i_ChampionIndex >= G305_ui_PartyChampionCount)
            //{
            //    return 0;
            //}

            //if (!champion->CurrentHealth)
            //{
            //    return 0;
            //}

            //TODO sleeping
            //if (G300_B_PartyIsSleeping)
            //{
            //    F314_gzzz_CHAMPION_WakeUp();
            //}

            int             L0563_i_DoubledMapDifficulty = AttackProvider.Location.Tile.Level.Difficulty << 1;
            CreatureFactory L0564_s_CreatureInfo         = AttackProvider.Factory; //G243_as_Graphic559_CreatureInfo[P493_ps_Group->Type];

            //F304_apzz_CHAMPION_AddSkillExperience(P494_i_ChampionIndex, C07_SKILL_PARRY, M58_EXPERIENCE(L0564_s_CreatureInfo.Properties));
            champion.GetSkill(SkillFactory <ParrySkill> .Instance).AddExperience(L0564_s_CreatureInfo.Experience);

            bool partySleeping = false;                                                                                      //TODO
            bool dextrityTest  = (champion.GetProperty(PropertyFactory <DextrityProperty> .Instance).Value < rand.Next(32) + /*L0564_s_CreatureInfo.Dexterity*/
                                  AttackProvider.GetProperty(PropertyFactory <DextrityProperty> .Instance).Value + L0563_i_DoubledMapDifficulty - 16) || rand.Next(4) == 0;
            bool luckTest = !F308_vzzz_CHAMPION_IsLucky(champion, 60);


            if (partySleeping || (dextrityTest && luckTest))
            {
                IStorageType A0561_ui_AllowedWound = GetAllowedWounds(L0564_s_CreatureInfo);

                int A0558_i_Attack;
                if ((A0558_i_Attack = (rand.Next(16) + L0564_s_CreatureInfo.Attack + L0563_i_DoubledMapDifficulty) -
                                      (champion.GetSkill(SkillFactory <ParrySkill> .Instance).SkillLevel << 1)) <= 1)
                {
                    if (rand.Next(2) > 0)
                    {
                        return(0);
                    }

                    A0558_i_Attack = rand.Next(4) + 2;
                }

                A0558_i_Attack >>= 1;
                A0558_i_Attack  += rand.Next(A0558_i_Attack) + rand.Next(4);
                A0558_i_Attack  += rand.Next(A0558_i_Attack);
                A0558_i_Attack >>= 2;
                A0558_i_Attack  += rand.Next(4) + 1;
                if (rand.Next(2) > 0)
                {
                    A0558_i_Attack -= rand.Next((A0558_i_Attack >> 1) + 1) - 1;
                }
                int A0558_i_Damage;
                if ((A0558_i_Damage = F321_AA29_CHAMPION_AddPendingDamageAndWounds_GetDamage(P494_i_ChampionIndex, A0558_i_Attack, new[] { A0561_ui_AllowedWound }, L0564_s_CreatureInfo.AttackType)) > 0)
                {
                    //TODO sounds F064_aadz_SOUND_RequestPlay_COPYPROTECTIOND(C09_SOUND_CHAMPION_0_DAMAGED + P494_i_ChampionIndex, G306_i_PartyMapX, G307_i_PartyMapY, C02_MODE_PLAY_ONE_TICK_LATER);
                    int A0559_ui_PoisonAttack;
                    if ((A0559_ui_PoisonAttack = L0564_s_CreatureInfo.PoisonAttack) > 0 && rand.Next(2) > 0 && ((A0559_ui_PoisonAttack = F307_fzzz_CHAMPION_GetStatisticAdjustedAttack(champion, PropertyFactory <VitalityProperty> .Instance, A0559_ui_PoisonAttack)) >= 0))
                    {
                        F322_lzzz_CHAMPION_Poison(P494_i_ChampionIndex, A0559_ui_PoisonAttack);
                    }
                    return(A0558_i_Damage);
                }
            }
            return(0);
        }
Пример #25
0
 public BodyPart(IStorageType storageType, float hitProbability, float damageFactor)
 {
     bodyPartImplementation = new Inventory(storageType);
     HitProbability         = hitProbability;
     DamageFactor           = damageFactor;
 }
Пример #26
0
 public IInventory GetStorage(IStorageType type) => Storages.FirstOrDefault(s => s.Type == type);
Пример #27
0
 /// <summary>
 /// Creates a storage.
 /// </summary>
 /// <param name="household">Household where the storage are placed.</param>
 /// <param name="sortOrder">Sort order for the storage.</param>
 /// <param name="storageType">Storage type for the storage.</param>
 /// <param name="temperature">Temperature for the storage.</param>
 /// <param name="creationTime">Creation date and time for when the storage was created.</param>
 /// <param name="description">Description for the storage.</param>
 public Storage(IHousehold household, int sortOrder, IStorageType storageType, int temperature, DateTime creationTime, string description = null)
     : this(household, sortOrder, storageType, description, temperature, creationTime, DomainObjectValidations.Create())
 {
 }
Пример #28
0
 /// <summary>
 /// Creates an instance of the data proxy to a given storage which should be used for unit testing.
 /// </summary>
 /// <returns>Instance of the data proxy to a given storage which should be used for unit testing.</returns>
 private IStorageProxy CreateSut(Guid storageIdentifier, IHousehold household, int sortOrder, IStorageType storageType, int temperature, DateTime creationTime, string description = null)
 {
     return(new StorageProxy(household, sortOrder, storageType, temperature, creationTime, description)
     {
         Identifier = storageIdentifier
     });
 }
Пример #29
0
 public IBodyPart GetBodyStoratge(IStorageType storageType) => BodyParts.FirstOrDefault(s => s.Type == storageType);
 public bool CanBeStoredIn(IStorageType storage) => locations.Contains(storage);
Пример #31
0
 public BodyPart(IStorageType storageType, float hitProbability, int injuryMultipler) : base(storageType)
 {
     HitProbability  = hitProbability;
     InjuryMultipler = injuryMultipler;
 }
 /// <summary>
 /// Creates an instance of the private class for testing the storage.
 /// </summary>
 /// <param name="household">Household where the storage are placed.</param>
 /// <param name="sortOrder">Sort order for the storage.</param>
 /// <param name="storageType">Storage type for the storage.</param>
 /// <param name="description">Description for the storage.</param>
 /// <param name="temperature">Temperature for the storage.</param>
 /// <param name="creationTime">Creation date and time for when the storage was created.</param>
 /// <param name="domainObjectValidations">Implementation of the common validations used by domain objects in the food waste domain.</param>
 public MyStorage(IHousehold household, int sortOrder, IStorageType storageType, string description, int temperature, DateTime creationTime, IDomainObjectValidations domainObjectValidations)
     : base(household, sortOrder, storageType, description, temperature, creationTime, domainObjectValidations)
 {
 }
        /// <summary>
        /// Build a mockup for a storage.
        /// </summary>
        /// <returns>Mockup for a storage.</returns>
        public static IStorage BuildStorageMock(IHousehold household = null, int?sortOrder = null, IStorageType storageType = null, bool hasDescription = true)
        {
            if (storageType == null)
            {
                storageType = BuildStorageTypeMock();
            }

            IStorage storage = MockRepository.GenerateMock <IStorage>();

            storage.Stub(m => m.Identifier)
            .Return(Guid.NewGuid())
            .Repeat.Any();
            storage.Stub(m => m.Household)
            .Return(household ?? BuildHouseholdMock())
            .Repeat.Any();
            storage.Stub(m => m.SortOrder)
            .Return(sortOrder ?? Random.Next(1, 100))
            .Repeat.Any();
            storage.Stub(m => m.StorageType)
            .Return(storageType)
            .Repeat.Any();
            storage.Stub(m => m.Description)
            .Return(hasDescription ? Fixture.Create <string>() : null)
            .Repeat.Any();
            storage.Stub(m => m.Temperature)
            .Return(Random.Next(storageType.TemperatureRange.StartValue, storageType.TemperatureRange.EndValue))
            .Repeat.Any();
            storage.Stub(m => m.CreationTime)
            .Return(DateTime.Now)
            .Repeat.Any();
            return(storage);
        }
        /// <summary>
        /// Deletes an identifiable domain object in the repository.
        /// </summary>
        /// <typeparam name="TIdentifiable">Type of the identifiable domain object.</typeparam>
        /// <param name="identifiable">Identifiable domain object to delete.</param>
        public void Delete <TIdentifiable>(TIdentifiable identifiable) where TIdentifiable : IIdentifiable
        {
            if (Equals(identifiable, null))
            {
                throw new ArgumentNullException(nameof(identifiable));
            }

            IHousehold household = identifiable as IHousehold;

            if (household != null)
            {
                Delete <IHousehold, IHouseholdProxy>(household);
                return;
            }

            IStorage storage = identifiable as IStorage;

            if (storage != null)
            {
                Delete <IStorage, IStorageProxy>(storage);
                return;
            }

            IStorageType storageType = identifiable as IStorageType;

            if (storageType != null)
            {
                Delete <IStorageType, IStorageTypeProxy>(storageType);
                return;
            }

            IHouseholdMember householdMember = identifiable as IHouseholdMember;

            if (householdMember != null)
            {
                Delete <IHouseholdMember, IHouseholdMemberProxy>(householdMember);
                return;
            }

            IPayment payment = identifiable as IPayment;

            if (payment != null)
            {
                Delete <IPayment, IPaymentProxy>(payment);
                return;
            }

            IFoodItem foodItem = identifiable as IFoodItem;

            if (foodItem != null)
            {
                Delete <IFoodItem, IFoodItemProxy>(foodItem);
                return;
            }

            IFoodGroup foodGroup = identifiable as IFoodGroup;

            if (foodGroup != null)
            {
                Delete <IFoodGroup, IFoodGroupProxy>(foodGroup);
                return;
            }

            IForeignKey foreignKey = identifiable as IForeignKey;

            if (foreignKey != null)
            {
                Delete <IForeignKey, IForeignKeyProxy>(foreignKey);
                return;
            }

            IStaticText staticText = identifiable as IStaticText;

            if (staticText != null)
            {
                Delete <IStaticText, IStaticTextProxy>(staticText);
                return;
            }

            IDataProvider dataProvider = identifiable as IDataProvider;

            if (dataProvider != null)
            {
                Delete <IDataProvider, IDataProviderProxy>(dataProvider);
                return;
            }

            ITranslation translation = identifiable as ITranslation;

            if (translation != null)
            {
                Delete <ITranslation, ITranslationProxy>(translation);
                return;
            }

            ITranslationInfo translationInfo = identifiable as ITranslationInfo;

            if (translationInfo != null)
            {
                Delete <ITranslationInfo, ITranslationInfoProxy>(translationInfo);
                return;
            }

            throw new NotSupportedException();
        }
Пример #35
0
 int F312_xzzz_CHAMPION_GetStrength(IStorageType P651_i_SlotIndex)
 {
     int L0935_i_Strength = rand.Next(16) + attackProvider.GetProperty(PropertyFactory<StrengthProperty>.Instance).MaxValue;
     var L0938_T_Thing = attackProvider.Body.GetStorage(P651_i_SlotIndex).Storage.First();
     //if ((A0936_ui_ObjectWeight = F140_yzzz_DUNGEON_GetObjectWeight(L0938_T_Thing)) <= (A0937_ui_OneSixteenthMaximumLoad = F309_awzz_CHAMPION_GetMaximumLoad(L0939_ps_Champion) >> 4))
     int A0936_ui_ObjectWeight = (int)L0938_T_Thing.Factory.Weight;
     int A0937_ui_OneSixteenthMaximumLoad = attackProvider.GetProperty(PropertyFactory<LoadProperty>.Instance).MaxValue >> 4;
     if (A0936_ui_ObjectWeight <= A0937_ui_OneSixteenthMaximumLoad)
     {
         L0935_i_Strength += A0936_ui_ObjectWeight - 12;
     }
     else
     {
         int L0941_i_LoadThreshold;
         if (A0936_ui_ObjectWeight <= (L0941_i_LoadThreshold = A0937_ui_OneSixteenthMaximumLoad + ((A0937_ui_OneSixteenthMaximumLoad - 12) >> 1)))
         {
             L0935_i_Strength += (A0936_ui_ObjectWeight - A0937_ui_OneSixteenthMaximumLoad) >> 1;
         }
         else
         {
             L0935_i_Strength -= (A0936_ui_ObjectWeight - L0941_i_LoadThreshold) << 1;
         }
     }
     //if (M12_TYPE(L0938_T_Thing) == C05_THING_TYPE_WEAPON)
     if (L0938_T_Thing is Weapon)
     {
         //#ifdef C01_COMPILE_DM10aEN_DM10bEN /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
         //                L0940_ps_WeaponInfo = &G238_as_Graphic559_WeaponInfo[((WEAPON*)G284_apuc_ThingData[C05_THING_TYPE_WEAPON])[M13_INDEX(L0938_T_Thing)].Type];
         //#endif
         //#ifdef C15_COMPILE_DM11EN_DM12EN_DM12GE_DM13aFR_DM13bFR_CSB20EN_CSB21EN /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
         var L0940_ps_WeaponInfo = L0938_T_Thing as Weapon;
         //#endif
         L0935_i_Strength += L0940_ps_WeaponInfo.FactoryType.Strength;
         int A0936_ui_SkillLevel = 0;
         var A0937_ui_Class = L0940_ps_WeaponInfo.FactoryType.Class;
         if ((A0937_ui_Class == WeaponClass.C000_CLASS_SWING_WEAPON) || (A0937_ui_Class == WeaponClass.C002_CLASS_DAGGER_AND_AXES))
         {
             A0936_ui_SkillLevel = attackProvider.GetSkill(SkillFactory<SwingSkill>.Instance).SkillLevel;
         }
         if ((A0937_ui_Class != WeaponClass.C000_CLASS_SWING_WEAPON) && (A0937_ui_Class < WeaponClass.C016_CLASS_FIRST_BOW))
         {
             A0936_ui_SkillLevel += attackProvider.GetSkill(SkillFactory<ThrowSkill>.Instance).SkillLevel;
         }
         if ((A0937_ui_Class >= WeaponClass.C016_CLASS_FIRST_BOW) && (A0937_ui_Class < WeaponClass.C112_CLASS_FIRST_MAGIC_WEAPON))
         {
             A0936_ui_SkillLevel += attackProvider.GetSkill(SkillFactory<ShootSkill>.Instance).SkillLevel;
         }
         L0935_i_Strength += A0936_ui_SkillLevel << 1;
     }
     L0935_i_Strength = F306_xxxx_CHAMPION_GetStaminaAdjustedValue(attackProvider.GetProperty(PropertyFactory<StaminaProperty>.Instance),/*L0939_ps_Champion,*/ L0935_i_Strength);
     //if (M07_GET(L0939_ps_Champion->Wounds, (P651_i_SlotIndex == C00_SLOT_READY_HAND) ? MASK0x0001_READY_HAND : MASK0x0002_ACTION_HAND))
     if (attackProvider.Body.GetBodyStoratge(P651_i_SlotIndex).IsWound)
     {
         L0935_i_Strength >>= 1;
     }
     //return F026_a003_MAIN_GetBoundedValue(0, L0935_i_Strength >> 1, 100);
     return MathHelper.Clamp(L0935_i_Strength >> 1, 0, 100);
 }
Пример #36
0
 public WoundInfo(bool useSharpDefense, IStorageType woundIndex)
 {
     UseSharpDefense = useSharpDefense;
     WoundIndex      = woundIndex;
 }