示例#1
0
        public void IsSetTest()
        {
            var xbit = new ExtendedBitvector();

            xbit.SetBit(8);

            Assert.That(xbit.IsSet(8), Is.True);
        }
        public void ReadBitvectorWithSpacesReturnsValidObject(string stringToRead, int valueToCheck, bool expectedValue)
        {
            TextReaderProxy proxy = new TextReaderProxy(new StringReader("2 & 4 & 8~"));

            ExtendedBitvector result = proxy.ReadBitvector();

            Assert.That(result, Is.Not.Null);
            Assert.That(result.IsSet((int)valueToCheck), Is.EqualTo(expectedValue));
        }
示例#3
0
 public CharacterInstance(long id, string name)
     : base(id, name)
 {
     SavingThrows = new SavingThrowData();
     LuaVM        = new LuaInterfaceProxy();
     Timers       = new List <TimerData>();
     Act          = new ExtendedBitvector();
     AffectedBy   = new ExtendedBitvector();
 }
示例#4
0
        public void RemoveBitTest()
        {
            var xbit = new ExtendedBitvector();

            xbit.SetBit(8);
            xbit.RemoveBit(8);

            Assert.That(xbit.IsSet(8), Is.False);
        }
        public static ExtendedBitvector GetAttacks(this MobileTemplate template)
        {
            var bv    = new ExtendedBitvector();
            var words = template.Attacks.Split(' ');

            foreach (var word in words)
            {
                bv.SetBit((int)EnumerationExtensions.GetEnumIgnoreCase <AttackTypes>(word));
            }
            return(bv);
        }
        public static ExtendedBitvector GetAffected(this MobileTemplate template)
        {
            var bv    = new ExtendedBitvector();
            var words = template.GetStatistic <string>(StatisticTypes.AffectedByFlags).Split(' ');

            foreach (var word in words)
            {
                bv.SetBit((int)EnumerationExtensions.GetEnumIgnoreCase <AffectedByTypes>(word));
            }
            return(bv);
        }
示例#7
0
        public static string extra_bit_name(ExtendedBitvector extra_flags)
        {
            var sb = new StringBuilder();

            foreach (var type in Enum.GetValues(typeof(ItemExtraFlags))
                     .Cast <ItemExtraFlags>()
                     .Where(type => extra_flags.IsSet((int)type)))
            {
                sb.AppendFormat(" {0}", type.GetName());
            }
            return(sb.ToString());
        }
示例#8
0
        public static string affect_bit_name(ExtendedBitvector vector)
        {
            var sb = new StringBuilder();

            foreach (var type in Enum.GetValues(typeof(AffectedByTypes))
                     .Cast <AffectedByTypes>()
                     .Where(type => vector.IsSet((int)type)))
            {
                sb.AppendFormat(" {0}", type.GetName());
            }
            return(sb.ToString());
        }
        public static ExtendedBitvector GetDefenses(this MobileTemplate template)
        {
            var flags = new ExtendedBitvector();
            var words = template.Defenses.Split(' ');

            foreach (var word in words)
            {
                flags.SetBit((int)EnumerationExtensions.GetEnumIgnoreCase <DefenseTypes>(word));
            }

            return(flags);
        }
示例#10
0
        public ObjectTemplate(long id, string name)
            : base(id, name)
        {
            Values            = new ExpandoObject();
            ExtraDescriptions = new List <ExtraDescriptionData>();
            Affects           = new List <AffectData>();
            Spells            = new List <string>();
            ExtraFlags        = new ExtendedBitvector();

            ShortDescription = $"A newly created {name}";
            Description      = $"Somebody dropped a newly created {name} here.";
            Type             = ItemTypes.Trash;
            Weight           = 1;
        }
示例#11
0
        private static void RemoveDevotion(PlayerInstance ch)
        {
            if (CheckFunctions.CheckIfNullObject(ch, ch.PlayerData.CurrentDeity,
                                                 "You have already chosen to worship no deities."))
            {
                return;
            }

            var deity = ch.PlayerData.CurrentDeity;

            --deity.Worshippers;
            if (deity.Worshippers < 0)
            {
                deity.Worshippers = 0;
            }

            ch.PlayerData.Favor = -2500;
            ch.MentalState      = -80;
            ch.SendTo("A terrible curse afflicts you as you forsake a deity!");

            ch.AffectedBy.RemoveBits(deity.Affected);
            ch.Resistance.RemoveBit(deity.Element);
            ch.Susceptibility.RemoveBit(deity.Suscept);

            var af = new AffectData
            {
                Type      = AffectedByTypes.Blind,
                Location  = ApplyTypes.HitRoll,
                Modifier  = -4,
                Duration  = 50 * GameConstants.GetConstant <int>("AffectDurationConversionValue"),
                BitVector = ExtendedBitvector.Meb((int)AffectedByTypes.Blind)
            };

            ch.AddAffect(af);

            // TODO Save the deity data to the database
            // save_deity(ch->pcdata->deity);

            ch.SendTo("You cease to worship any deity.");
            ch.PlayerData.CurrentDeity = null;
            save.save_char_obj(ch);
        }
示例#12
0
 public AffectData()
 {
     BitVector = new ExtendedBitvector();
 }
示例#13
0
 public static bool CheckIfSet(CharacterInstance ch, ExtendedBitvector bits, int bitToCheck, string message = "")
 {
     return(bits.IsSet(bitToCheck) && SendToChar(ch, message));
 }
示例#14
0
 public RaceData(long id, string name) : base(id, name)
 {
     WhereNames   = new List <string>();
     SavingThrows = new SavingThrowData();
     AffectedBy   = new ExtendedBitvector();
 }
示例#15
0
        public void IsEmptyTest()
        {
            var xbit = new ExtendedBitvector();

            Assert.That(xbit.IsEmpty(), Is.True);
        }