Esempio n. 1
0
 private static void AddStat(StatTag tag, CombinationStrategy combinator, string nameShort, bool useBinaryEditor = false)
 {
     if (!stats.ContainsKey(tag))
     {
         stats[tag] = new Stat(tag, combinator, nameShort, useBinaryEditor);
     }
 }
Esempio n. 2
0
 private Stat(StatTag tag, CombinationStrategy combinator, String nameShort, bool useBinaryEditor)
 {
     this.combinator      = combinator;
     this.tag             = tag;
     this.nameShort       = nameShort;
     this.useBinaryEditor = useBinaryEditor;
 }
Esempio n. 3
0
 private Stat(StatTag tag, CombinationStrategy combinator, string nameShort, string nameLong, bool useBinaryEditor)
 {
     Combinator      = combinator;
     Tag             = tag;
     NameShort       = nameShort;
     NameLong        = nameLong;
     UseBinaryEditor = useBinaryEditor;
 }
Esempio n. 4
0
 public static Stat Get(StatTag tag)
 {
     if (stats == null || !stats.ContainsKey(tag))
     {
         InitializeStats();
     }
     return(stats[tag]);
 }
Esempio n. 5
0
        public void adding_a_tag_appends_it_with_a_hash()
        {
            var logs        = new List <string>();
            var contextMock = new Mock <ILambdaLogger>(MockBehavior.Strict);

            contextMock.Setup(logger => logger.LogLine(It.IsAny <string>()))
            .Callback((string s) => logs.Add(s));

            var metrics = new DogMetrics(contextMock.Object);
            var colour  = new StatTag("colour", "blue");

            metrics.Gauge("mystat", 1, 1D, colour);

            Assert.True(logs.Count == 1);
            Assert.True(logs.First().Contains("|#colour:blue"),
                        $@"Expected the tag string: ""|#colour:blue"" but couldn't find it in <{logs.First()}>");
        }
Esempio n. 6
0
        public void a_tag_need_not_have_value()
        {
            var logs        = new List <string>();
            var contextMock = new Mock <ILambdaLogger>(MockBehavior.Strict);

            contextMock.Setup(logger => logger.LogLine(It.IsAny <string>()))
            .Callback((string s) => logs.Add(s));

            var metrics  = new DogMetrics(contextMock.Object);
            var isBlue   = new StatTag("isBlue");
            var isCircle = new StatTag("isCircle");

            metrics.Gauge("mystat", 1, 1D, isBlue, isCircle);

            Assert.True(logs.Count == 1);
            Assert.True(logs.First().Contains("|#isBlue,isCircle"),
                        $@"Expected the tag string: ""|#isBlue,isCircle"" but couldn't find it in <{logs.First()}>");
        }
Esempio n. 7
0
        public void multiple_tags_are_separated_by_comma()
        {
            var logs        = new List <string>();
            var contextMock = new Mock <ILambdaLogger>(MockBehavior.Strict);

            contextMock.Setup(logger => logger.LogLine(It.IsAny <string>()))
            .Callback((string s) => logs.Add(s));

            var metrics = new DogMetrics(contextMock.Object);
            var colour  = new StatTag("colour", "blue");
            var shape   = new StatTag("shape", "circle");

            metrics.Gauge("mystat", 1, 1D, colour, shape);

            Assert.True(logs.Count == 1);
            Assert.True(logs.First().Contains("|#colour:blue,shape:circle"),
                        $@"Expected the tag string: ""|#colour:blue,shape:circle"" but couldn't find it in <{logs.First()}>");
        }
Esempio n. 8
0
    // === OPERATIONS ===

    public void Add(StatTag tag, float value)
    {
        stats[tag] += value;
    }
Esempio n. 9
0
 public float this[StatTag tag] {
     get { return(stats.ContainsKey(tag) ? stats[tag] : 0); }
     set { stats[tag] = value; }
 }
Esempio n. 10
0
 private static void AddFlag(StatTag tag)
 {
     stats[tag] = new Stat(tag, CombinationAdditive.Instance(), tag.ToString(), null, true);
 }
Esempio n. 11
0
 private static void AddStat(StatTag tag, string longName = null)
 {
     stats[tag] = new Stat(tag, CombinationAdditive.Instance(), tag.ToString(), longName, false);
 }
Esempio n. 12
0
 public bool Is(StatTag tag)
 {
     return(stats[tag] > 0.0f);
 }
Esempio n. 13
0
    // === RPG =====================================================================================

    public float Get(StatTag tag)
    {
        return(unit.stats.Get(tag));
    }
Esempio n. 14
0
 private static void AddStat(StatTag tag, CombinationStrategy combinator, string nameShort, bool useBinaryEditor)
 {
     stats[tag] = new Stat(tag, combinator, nameShort, useBinaryEditor);
 }
Esempio n. 15
0
 public void Sub(StatTag tag, float value)
 {
     Add(tag, -value);
 }
Esempio n. 16
0
    // === ACCESSORS ===

    public float Get(StatTag tag)
    {
        return(stats[tag]);
    }
Esempio n. 17
0
 public bool Is(StatTag tag)
 {
     return(unit.stats.Is(tag));
 }
Esempio n. 18
0
 public void Set(StatTag tag, float value)
 {
     stats[tag] = value;
 }
Esempio n. 19
0
 public float this[StatTag tag] {
     get { return(stats[tag]); }
     set { stats[tag] = value; }
 }