Пример #1
0
        public IModifier CreateModifier(IActor target, IActor source, IStat stat, int amount, int duration)
        {
            IModifier modifier = this.CreateModifier(target, source, stat, amount);
            modifier.SetAffectDuration(duration);

            return modifier;
        }
Пример #2
0
        public IModifier CreateModifier(IActor target, IActor source, IStat stat, int amount)
        {
            IModifier modifier = this.CreateModifier(target, source, amount);
            modifier.SetAffectedStat(stat);

            return modifier;
        }
Пример #3
0
        public virtual void AddAbility(IStat ability)
        {
            if (ability == null)
            {
                throw new ArgumentNullException(nameof(ability), "The ability argument can not be null.");
            }

            if (this.Stats.Contains(ability))
            {
                return;
            }

            this.Stats.Add(ability);
        }
Пример #4
0
        public void SetAffectedStat(IStat affectedTargetStat)
        {
            if (affectedTargetStat == null)
            {
                throw new ArgumentNullException(nameof(affectedTargetStat), "You can not use a null Stat for this modifier");
            }

            if (string.IsNullOrEmpty(affectedTargetStat.Name))
            {
                throw new ArgumentOutOfRangeException(nameof(affectedTargetStat), "The provided Stat does not have a name assigned to it.");
            }

            this.AffectedStat = affectedTargetStat;
        }
Пример #5
0
        public override void Bind(IStat item, StatsRecyclerAdapter adapter)
        {
            if (item is ActivatableStat model)
            {
                //if (TitleTextView != null)
                //{
                //    TitleTextView.Text = model.Name;
                //}

                if (TimeActivatedTextView != null)
                {
                    ClearDisposable();

                    TimeActivatedTextView.Text = model.TimeElapsed.ToFormattedString();

                    Disposable = Observable.Interval(TimeSpan.FromSeconds(1))
                                 .Select(p => model.TimeElapsed)
                                 .TakeUntil(time => TimeActivatedTextView == null)
                                 .RunOnUI()
                                 .Subscribe(time =>
                    {
#if DEBUG
                        Log.Info($"{GetType().Name}", $"{model.StatType} -> {time.ToFormattedString()}");
#endif
                        TimeActivatedTextView.Text = time.ToFormattedString();
                    },
                                            () =>
                    {
                        if (TimeActivatedTextView != null)
                        {
                            TimeActivatedTextView.Text = "EXPIRED";
                        }
                    });

                    adapter.AddTimeSubscription(Disposable);
                }
            }
        }
Пример #6
0
        private void InitReports()
        {
            logger.Info("Initialize reports");

            recentMatches = new DataIdentity <MatchInfo>()
                            .Report(MaxReportSize, m => m.EndTime, (m1, m2) => m1.GetIndex().CompareTo(m2.GetIndex()));

            popularServers = new DataIdentity <ServerInfo>()
                             .Select(s => new ServerReportResult
            {
                Server             = s,
                TotalMatchesPlayed = serverStatisticStorage.GetStatistics(s.Id)?.TotalMatchesPlayed ?? 0
            })
                             .Report(MaxReportSize,
                                     s => s.TotalMatchesPlayed,
                                     (s1, s2) => string.Compare(s1.Server.Id, s2.Server.Id, StringComparison.Ordinal));

            allServers = new DataIdentity <ServerInfo>()
                         .Report(s => s.Id, (s1, s2) => string.Compare(s1.Id, s2.Id, StringComparison.Ordinal));

            bestPlayers = new DataIdentity <PlayerInfo>().Where(p =>
            {
                var playerStat = playerStatisticStorage.GetStatistics(p.Name);
                return(playerStat.KillToDeathRatio != null && playerStat.TotalMatchesPlayed >= 10);
            })
                          .Select(p => new PlayerReportResult {
                Player = p, KillToDeathRatio = playerStatisticStorage.GetStatistics(p.Name).KillToDeathRatio
            })
                          .Report(MaxReportSize, p =>
            {
                if (p.KillToDeathRatio != null)
                {
                    return(p.KillToDeathRatio.Value);
                }
                throw new ArgumentException($"{nameof(p.KillToDeathRatio)} must be not null");
            },
                                  (p1, p2) => p1.Player.GetIndex().CompareTo(p2.Player.GetIndex()));
        }
Пример #7
0
        public void ExplicitlyRegistered()
        {
            var sut            = Calculator.Create();
            var modifierStat   = new Stat("m");
            var registeredStat =
                new Stat("r", explicitRegistrationType: ExplicitRegistrationTypes.UserSpecifiedValue(0));
            var   value  = new StatValue(registeredStat);
            IStat actual = null;

            sut.ExplicitlyRegisteredStats.CollectionChanged += (sender, args) =>
            {
                Assert.IsNull(actual);
                Assert.AreEqual(1, args.AddedItems.Count);
                Assert.IsEmpty(args.RemovedItems);
                actual = args.AddedItems.First().Item2;
            };

            sut.NewBatchUpdate().AddModifier(modifierStat, Form.BaseAdd, value).DoUpdate();
            Assert.IsNull(actual);
            var _ = sut.NodeRepository.GetNode(modifierStat).Value;

            Assert.AreEqual(registeredStat, actual);
        }
Пример #8
0
        /// <summary>
        /// Reads a <see cref="IStat"/> instance.
        /// </summary>
        /// <param name="s">The IO session.</param>
        /// <param name="stat">Out parameter; the read <see cref="IStat"/> instance.</param>
        public static void Read(IoSession s, out IStat stat)
        {
            int  theint;
            long thelong;
            Stat tmpStat = new Stat();

            stat = tmpStat;
            Read(s, out thelong);
            tmpStat.Czxid = thelong;

            Read(s, out thelong);
            tmpStat.Mzxid = thelong;

            Read(s, out thelong);
            tmpStat.Pzxid = thelong;

            Read(s, out theint);
            tmpStat.Version = theint;

            Read(s, out theint);
            tmpStat.Aversion = theint;

            Read(s, out theint);
            tmpStat.Cversion = theint;

            Read(s, out thelong);
            tmpStat.Ctime = thelong;

            Read(s, out thelong);
            tmpStat.Mtime = thelong;

            Read(s, out theint);
            tmpStat.DataLength = theint;

            Read(s, out theint);
            tmpStat.NumChildren = theint;
        }
Пример #9
0
        public override void Bind(IStat item, StatsRecyclerAdapter adapter)
        {
            if (item is ExpirableStat model)
            {
                //if (TitleTextView != null)
                //{
                //    TitleTextView.Text = model.Name;
                //}

                if (TimeLeftTextView != null)
                {
                    ClearDisposable();

                    UpdateTimeLeftText(TimeLeftTextView, model.TimeLeft);

                    Disposable = Observable
                                 .Interval(TimeSpan.FromSeconds(1))
                                 .Select(p => model.TimeLeft)
                                 .TakeUntil(time => time < TimeSpan.Zero || TimeLeftTextView == null)
                                 .RunOnUI()
                                 .Subscribe(timeLeft =>
                    {
#if DEBUG
                        Log.Info($"{GetType().Name}", $"{model.StatType} -> {timeLeft.ToFormattedString()}");
#endif
                        UpdateTimeLeftText(TimeLeftTextView, model.TimeLeft);
                    },
                                            () =>
                    {
                        ClearDisposable();
                    });

                    adapter.AddTimeSubscription(Disposable);
                }
            }
        }
Пример #10
0
 protected abstract T CreateViewModel(ICalculationNode node, IStat stat);
Пример #11
0
 private bool TryGetStatViewModel(IStat stat, out T statVm)
 {
     statVm = Stats.FirstOrDefault(s => SelectStat(s).Equals(stat));
     return(statVm != null);
 }
        private IReadOnlyCollection <PathDefinition> GetPaths(IValueCalculationContext context, IStat stat)
        {
            var originalPaths = context.GetPaths(stat);

            if (!_ailmentDamage.Equals(stat))
            {
                return(originalPaths);
            }

            var skillPaths = context.GetPaths(_skillDamage)
                             .Select(p => new PathDefinition(p.ModifierSource));
            var paths = new HashSet <PathDefinition>(originalPaths);

            paths.UnionWith(skillPaths);
            return(paths);
        }
 public RequirementUncappedSubtotalValue(IStat transformedStat, IValue transformedValue)
 => (_transformedStat, _transformedValue) = (transformedStat, transformedValue);
Пример #14
0
 public StatController(IStat _stat, IWorkersRepo _Repo)
 {
     stat        = _stat;
     workersRepo = _Repo;
 }
 public CalculationNodeViewModel(IStat stat, NodeType nodeType = NodeType.Total)
 => (Stat, NodeType) = (stat, nodeType);
Пример #16
0
        private static AilmentDamageUncappedSubtotalValue CreateSut(IStat ailmentDamage, IStat skillDamage)
        {
            var transformedValue = new FunctionalValue(c => c.GetValues(ailmentDamage, NodeType.PathTotal).Sum(), "");

            return(new AilmentDamageUncappedSubtotalValue(ailmentDamage, skillDamage, transformedValue));
        }
Пример #17
0
        /// <summary>
        /// Adds the specified stat to the character
        /// </summary>
        /// <param name="stat"></param>
        public void AddStat(IStat stat)
        {
            if (stat == null)
                return;

            if (Stats.Contains(stat))
                return;
            else
                Stats.Add(stat);
        }
Пример #18
0
 public void RemoveStat(IStat stat)
 {
     m_stats.Remove(stat.ID);
 }
Пример #19
0
 public void AddStat(IStat stat)
 {
     m_stats.Add(stat.ID, stat);
 }
Пример #20
0
 public void SetUp()
 {
     _testObject = new EnduranceStat();
 }
Пример #21
0
 public ModificationModifiedEventArgs(ModificationType type, IStat sender)
 {
     this.type = type;
     this.sender = sender;
 }
 private void Warn(string msg, IStat stat)
 {
     Warnings++;
      stat.Dump();
      RosterLib.Utility.Announce(string.Format("          Warning : {0} - {1} - {2}",
      NflWeek.WeekKey(":"), msg, stat.PlayerId));
 }
 private void Error(IStat stat)
 {
     Errors++;
      stat.Dump();
      RosterLib.Utility.Announce(string.Format("          Error : {0} - {1} - {2}",
      NflWeek.WeekKey(":"), stat.Error, stat.PlayerId));
 }
Пример #24
0
 public void Init()
 {
     _statImpl = new StatImpl();
 }
Пример #25
0
 /// <inheritdoc />
 protected override void NotifyComplete(int resultCode, byte[] data, IStat stat, string responsePath)
 {
     this.callback?.Invoke(resultCode, this.Path, this.Context, data, stat);
 }
Пример #26
0
 public void SetUp()
 {
     _testObject = new StrengthStat();
 }
Пример #27
0
 private static UncappedSubtotalValue CreateSut(IStat stat = null) => new UncappedSubtotalValue(stat);
Пример #28
0
 public void SetUp()
 {
     _testObject = new AccuracyStat();
 }
Пример #29
0
        //unlocked all quests
        //built all buildings - have ever built x
        //hired vendors
        //cash magnitude
        //craft all enchantments - have ever crafted x
        //relic notoriety
        //relic antiquity
        //find/identify a relic
        //resource value given to quests
        //days played


        public static void register(IStat stat)
        {
            stat.ID = allStatistics.Count;
            allStatistics.Add(stat);
        }
Пример #30
0
 public IReadOnlyStatGraph GetOrAdd(IStat stat) => GetOrAddStatGraph(stat);
Пример #31
0
 public IndexModel(IMatch match, IStat stat)
 {
     _match  = match;
     _stat   = stat;
     Matches = new List <MatchDetail>();
 }
Пример #32
0
 public bool Equals(IStat other)
 {
     return(this.Name.Equals(other.Name));
 }
 public AilmentDamageUncappedSubtotalValue(IStat ailmentDamage, IStat skillDamage, IValue transformedValue)
 {
     _ailmentDamage    = ailmentDamage;
     _skillDamage      = skillDamage;
     _transformedValue = transformedValue;
 }
Пример #34
0
 public void SetUp()
 {
     stat = new PopularStat <string>(3);
 }
Пример #35
0
 public void SetUp()
 {
     _testObject = new CatchStat();
 }
Пример #36
0
 public void ApplyEffect(IStat target)
 {
     target.DurationEffectStep(this);
 }
Пример #37
0
 protected abstract bool IsResponsibleFor(IStat stat);
Пример #38
0
 public void SetUp()
 {
     _testObject = new SpeedStat();
 }
Пример #39
0
 private IStatGraph GetOrAddStatGraph(IStat stat) =>
 _statGraphs.GetOrAdd(stat, _statGraphFactory);
Пример #40
0
        /// <summary>
        /// Removes the specified stat from the character
        /// </summary>
        /// <param name="stat"></param>
        public void RemoveStat(IStat stat)
        {
            if (Stats == null)
                return;

            if (Stats.Contains(stat))
                Stats.Remove(stat);
        }
Пример #41
0
 public void Remove(IStat stat) => _statGraphs.Remove(stat);
Пример #42
0
 public void SetUp()
 {
     _testObject = new DodgeStat();
 }
Пример #43
0
 public int CompareTo(IStat other)
 {
     return(string.Compare(this.Name, other.Name, StringComparison.OrdinalIgnoreCase));
 }
Пример #44
0
 public ConversionPathsWithSpecificSourceRule(IStat conversionSource)
 => _conversionSource = conversionSource;
        private static AilmentDamageBaseValue CreateSut(IStat ailmentDamage, IStat skillDamage)
        {
            var transformedValue = new FunctionalValue(c => c.GetValue(ailmentDamage, NodeType.BaseSet), "");

            return(new AilmentDamageBaseValue(skillDamage, transformedValue));
        }
 public IReadOnlyCollection <PathDefinition> GetPaths(IStat stat) =>
 throw CreateException();
Пример #47
0
 public StatNodeFactory(INodeFactory nodeFactory, IStat stat)
 {
     _nodeFactory = nodeFactory;
     _stat        = stat;
 }
 public NodeValue?GetValue(IStat stat, NodeType nodeType, PathDefinition path) =>
 throw CreateException();