Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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;
        }
        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);
                }
            }
        }
Beispiel #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()));
        }
Beispiel #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);
        }
Beispiel #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;
        }
Beispiel #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);
                }
            }
        }
Beispiel #10
0
 protected abstract T CreateViewModel(ICalculationNode node, IStat stat);
Beispiel #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);
Beispiel #14
0
 public StatController(IStat _stat, IWorkersRepo _Repo)
 {
     stat        = _stat;
     workersRepo = _Repo;
 }
 public CalculationNodeViewModel(IStat stat, NodeType nodeType = NodeType.Total)
 => (Stat, NodeType) = (stat, nodeType);
Beispiel #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));
        }
Beispiel #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);
        }
Beispiel #18
0
 public void RemoveStat(IStat stat)
 {
     m_stats.Remove(stat.ID);
 }
Beispiel #19
0
 public void AddStat(IStat stat)
 {
     m_stats.Add(stat.ID, stat);
 }
 public void SetUp()
 {
     _testObject = new EnduranceStat();
 }
Beispiel #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));
 }
Beispiel #24
0
 public void Init()
 {
     _statImpl = new StatImpl();
 }
Beispiel #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);
 }
 public void SetUp()
 {
     _testObject = new StrengthStat();
 }
 private static UncappedSubtotalValue CreateSut(IStat stat = null) => new UncappedSubtotalValue(stat);
 public void SetUp()
 {
     _testObject = new AccuracyStat();
 }
Beispiel #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);
        }
Beispiel #30
0
 public IReadOnlyStatGraph GetOrAdd(IStat stat) => GetOrAddStatGraph(stat);
Beispiel #31
0
 public IndexModel(IMatch match, IStat stat)
 {
     _match  = match;
     _stat   = stat;
     Matches = new List <MatchDetail>();
 }
Beispiel #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;
 }
Beispiel #34
0
 public void SetUp()
 {
     stat = new PopularStat <string>(3);
 }
Beispiel #35
0
 public void SetUp()
 {
     _testObject = new CatchStat();
 }
Beispiel #36
0
 public void ApplyEffect(IStat target)
 {
     target.DurationEffectStep(this);
 }
Beispiel #37
0
 protected abstract bool IsResponsibleFor(IStat stat);
Beispiel #38
0
 public void SetUp()
 {
     _testObject = new SpeedStat();
 }
Beispiel #39
0
 private IStatGraph GetOrAddStatGraph(IStat stat) =>
 _statGraphs.GetOrAdd(stat, _statGraphFactory);
Beispiel #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);
        }
Beispiel #41
0
 public void Remove(IStat stat) => _statGraphs.Remove(stat);
Beispiel #42
0
 public void SetUp()
 {
     _testObject = new DodgeStat();
 }
Beispiel #43
0
 public int CompareTo(IStat other)
 {
     return(string.Compare(this.Name, other.Name, StringComparison.OrdinalIgnoreCase));
 }
 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();
Beispiel #47
0
 public StatNodeFactory(INodeFactory nodeFactory, IStat stat)
 {
     _nodeFactory = nodeFactory;
     _stat        = stat;
 }
 public NodeValue?GetValue(IStat stat, NodeType nodeType, PathDefinition path) =>
 throw CreateException();