Пример #1
0
        public static Stat2 <TKey> Stat2 <TKey, TValue, TCursor>(
            this Series <TKey, TValue, TCursor> series)
            where TCursor : ICursor <TKey, TValue, TCursor>
        {
            var stat = new Stat2 <TKey>();

            using (var cursor = series.GetEnumerator())
            {
                var first = true;
                while (cursor.MoveNext())
                {
                    if (first)
                    {
                        stat._start = cursor.CurrentKey;
                        first       = false;
                    }
                    stat.AddValue(DoubleUtil.GetDouble(cursor.CurrentValue));
                }

                stat._end      = cursor.CurrentKey;
                stat._endValue = DoubleUtil.GetDouble(cursor.CurrentValue);
            }

            return(stat);
        }
Пример #2
0
 public static FileStatistics ReadFromStat2(string path, Stat2 stat2)
 {
     return(new FileStatistics()
     {
         FileMode = stat2.FileMode,
         Size = stat2.Size,
         Time = stat2.Time,
         Path = path,
     });
 }
Пример #3
0
    public StageObject(FieldObjectEntity fieldObjectEntity, StageObjectEntity2 stageObjectEntity, FSM parentFsm)
        : base(fieldObjectEntity, true, parentFsm)
    {
        Assert.IsTrue(stageObjectEntity != null);

        this.stageObjectEntity = stageObjectEntity;
        this.stat = new Stat2<StageObjectStatType>(StatGenerator.ExportData<StageObjectStatType>(stageObjectEntity));
        this.status = new Status2<StageObjectStatusType>(stat,
            new Status2<StageObjectStatusType>.Init(StageObjectStatusType.hp, 0, StageObjectStatType.maxHP, StageObjectStatType.maxHP));

        Register(stat);
        Register(status);
    }
Пример #4
0
        public bool TryGetValue(TKey key, out Stat2 <TKey> value)
        {
            if (_lookUpCursor.Equals(default(TCursor)))
            {
                _lookUpCursor = _cursor.Clone();
            }

            if (_lookUpCursor.MoveAt(key, Lookup.EQ))
            {
                value = _lookUpCursor.CurrentValue;
                return(true);
            }

            value = default;
            return(false);
        }
Пример #5
0
        public void OnlineVarianceIsStable()
        {
            var count = 300000; // fails with 400k, small values become not equal
            var stat  = new Stat2 <int>();

            var forward  = new double[count + 1];
            var backward = new double[count + 1];

            for (int i = 1; i <= count; i++)
            {
                stat.AddValue(i);
                if (i > 1)
                {
                    forward[i] = stat.StDev;
                    //Console.WriteLine($"{i} - {stat.StDev}");
                }
            }

            for (int i = count; i >= 1; i--)
            {
                if (i > 1)
                {
                    backward[i] = stat.StDev;
                    //Console.WriteLine($"{i} - {stat.StDev}");
                }
                stat.RemoveValue(i);
            }

            for (int i = 1; i <= count; i++)
            {
                if (i > 1)
                {
                    Assert.AreEqual(forward[i], backward[i]);
                    if (i < 20 || i > count - 20)
                    {
                        // matches to Excel VAR.S/ STDEV.S
                        Console.WriteLine($"{i} - {forward[i]} - {backward[i]}");
                    }
                }
            }

            var statDt = new Stat2 <DateTime>();

            statDt.AnnualizedVolatility();
        }
Пример #6
0
    static Status2<HeroStatusType> InitStatus(ObjectHolder owner, Stat2 stat, SubClassEntity subClassEntity)
    {
        var blockAtt1 = TableLoader.GetTable<BlockEntity2>().Get(subClassEntity.attackBlock1);
        var blockAtt2 = TableLoader.GetTable<BlockEntity2>().Get(subClassEntity.attackBlock2);

        Status2<HeroStatusType> ret = new Status2<HeroStatusType>(stat,
            new Status2<HeroStatusType>.Init(HeroStatusType.hp, 0, HeroStatType.maxHP, 0),
            new Status2<HeroStatusType>.Init(HeroStatusType.ap, 0, HeroStatType.maxAP, 0),
            new Status2<HeroStatusType>.Init(HeroStatusType.mp, 0, HeroStatType.maxMP, 0),

            new Status2<HeroStatusType>.Init(HeroStatusType.attack1CP, 0, blockAtt1.maxCP1, 0),
            new Status2<HeroStatusType>.Init(HeroStatusType.attack1ChargeCount, 0, blockAtt1.maxChargeCount, 0),
            new Status2<HeroStatusType>.Init(HeroStatusType.attack2CP, 0, blockAtt2.maxCP1, 0),
            new Status2<HeroStatusType>.Init(HeroStatusType.attack2ChargeCount, 0, blockAtt2.maxChargeCount, 0),

            new Status2<HeroStatusType>.Init(HeroStatusType.speed, 0, HeroStatType.moveSpeed, 0));
        return ret;
    }
Пример #7
0
        /// <include file='.\ISyncService.xml' path='/SyncService/Stat/*'/>
        public FileStatistics Stat(string remotePath)
        {
            // create the stat request message.
            this.Socket.SendSyncRequest(SyncCommand.STAT, remotePath);

            // read the result, in a byte array containing 3 ints
            // (mode, size, time)
            var statv2 = new Stat2();

            statv2.ReadFrom(this.Socket);
            if (statv2.Command != SyncCommand.STAT)
            {
                throw new AdbException($"The server returned an invalid sync response.");
            }

            FileStatistics value = FileStatistics.ReadFromStat2(remotePath, statv2);

            return(value);
        }
Пример #8
0
        public static Stat2 <TKey> Stat2 <TKey, TValue>(this ISeries <TKey, TValue> series)
        {
            var stat = new Stat2 <TKey>();

            using (var cursor = series.GetSpecializedCursor())
            {
                var first = true;
                while (cursor.MoveNext())
                {
                    if (first)
                    {
                        stat._start = cursor.CurrentKey;
                        first       = false;
                    }
                    stat.AddValue(DoubleUtil.GetDouble(cursor.CurrentValue));
                }

                stat._end      = cursor.CurrentKey;
                stat._endValue = DoubleUtil.GetDouble(cursor.CurrentValue);
            }

            return(stat);
        }
Пример #9
0
    public HeroCharacter(FieldObjectEntity objectField, SubClassEntity subClassEntity, ClassLevelEntity levelEntity, TrainLevelEntity trainLevelEntity, bool toLeft, InGameUser user, PuzzlePanel puzzlePanel, Buff.Handle onBuff, Buff.Handle onDeBuff, FSM parentFsm)
        : base(objectField, toLeft, parentFsm)
    {
        this.subClassEntity = subClassEntity;
        this.user = user;
        this.puzzlePanel = puzzlePanel;

        this.stat = new Stat2<HeroStatType>(StatGenerator.ExportData<HeroStatType>(levelEntity, trainLevelEntity));
        this.status = InitStatus(this, stat, subClassEntity);

        Register(stat);
        Register(status);

        /*
        RegisterDeathCondition(x => x.Get(HeroStatusType.hp) == 0);
        RegisterBuffHandler(onBuff, onDeBuff);

        RegistActions();

        SkillCommand skillCommand = InitSkill(this, skillId, itemHeroLevel.Level);
        AddCommandSet("skill", 1, false, E_CommandConsume.Skill, null).TryAdd(skillCommand);
         * */
    }
Пример #10
0
 public void Reset()
 {
     _state = default(Stat2 <TKey>);
 }
Пример #11
0
 public void Dispose()
 {
     _state = default(Stat2 <TKey>);
 }
Пример #12
0
 protected void Register(Stat2 stat)
 {
     stats.Add(stat);
 }
Пример #13
0
    public void Add(Stat2 stat)
    {
        Assert.IsTrue(!stats.ContainsKey(stat.KeyType));

        stats.Add(stat.KeyType, stat);
    }