public void TokenLesserEqualComparisonsWorkCorrectly()
        {
            //Arrange
            var output = new Output();

            var dateTimeString  = "2017-07-30 13:00:44";
            var dateTimeString2 = "2017-07-30 13:00:45";
            var dateTimeString3 = "2017-07-30 13:00:43";
            var dateTime        = DateTime.Parse(dateTimeString);
            var guid            = Guid.Parse("9E37E338-27B2-4F32-AFFA-DC74F017AF1D");
            var guid2           = Guid.Parse("9E37E338-27B2-4F32-AFFA-DC74F017AF1E");
            var guid3           = Guid.Parse("9E37E338-27B2-4F32-AFFA-DC74F017AF1C");
            var stringValue     = "test string";
            var stringValue2    = "west string";
            var stringValue3    = "sest string";
            var data            = new Dictionary <string, EntityProperty>
            {
                { "int1", new EntityProperty(1) },
                { "dbl1", new EntityProperty(1.0) },
                { "long1", new EntityProperty(1L) },
                { "dt1", new EntityProperty(dateTime) },
                { "guid1", new EntityProperty(guid) },
                { "string1", new EntityProperty(stringValue) },
            };


            var tests = new[]
            {
                new { Token = TokenValue.FromInt("1"), Variable = "int1" },
                new { Token = TokenValue.FromDouble("1.0"), Variable = "dbl1" },
                new { Token = TokenValue.FromLong("1"), Variable = "long1" },
                new { Token = TokenValue.FromDateTime(dateTimeString), Variable = "dt1" },
                new { Token = TokenValue.FromGuid(guid.ToString()), Variable = "guid1" },
                new { Token = TokenValue.FromString(stringValue), Variable = "string1" },
                new { Token = TokenValue.FromInt("2"), Variable = "int1" },
                new { Token = TokenValue.FromDouble("1.01"), Variable = "dbl1" },
                new { Token = TokenValue.FromLong("2"), Variable = "long1" },
                new { Token = TokenValue.FromDateTime(dateTimeString2), Variable = "dt1" },
                new { Token = TokenValue.FromGuid(guid2.ToString()), Variable = "guid1" },
                new { Token = TokenValue.FromString(stringValue2), Variable = "string1" },
                new { Token = TokenValue.FromInt("0"), Variable = "int1" },
                new { Token = TokenValue.FromDouble("0.99"), Variable = "dbl1" },
                new { Token = TokenValue.FromLong("0"), Variable = "long1" },
                new { Token = TokenValue.FromDateTime(dateTimeString3), Variable = "dt1" },
                new { Token = TokenValue.FromGuid(guid3.ToString()), Variable = "guid1" },
                new { Token = TokenValue.FromString(stringValue3), Variable = "string1" },
            };

            //Act
            foreach (var test in tests)
            {
                var variableValue = new TokenValue(data[test.Variable]);
                var compareOp     = new Token(TokenType.CompLe, "le");
                var result        = test.Token.Compare(compareOp, variableValue, out string _);
                output.WrapLine($@"{test.Token.ValueString()} {compareOp.Text} {variableValue.ValueString()} => {result}");
            }

            //Assert
            Approvals.Verify(output.Report);
        }
        public DivinationDistillate() : base()
        {
            const string cShield = "<style=cIsHealing>shield</style>";
            const string cHealth = "<style=cIsHealing>health</style>";

            Cooldown   = 30;
            Name       = new TokenValue("HC_LUCKJUICE", "Divination Distillate");
            PickupText = new TokenValue("HC_LUCKJUICE_PICKUP",
                                        $"<style=cIsHealing>Heal</style> both {cHealth} and {cShield} for a short period of time. <style=cIsUtility>Luck</style> increased while active.");
            Description = new TokenValue("HC_LUCKJUICE_DESC",
                                         $"Heal both {cHealth} and {cShield} for {DistillateDuration} seconds. Effects stops at full {cHealth} and full {cShield}." +
                                         $" While under effect, your <style=cIsUtility>luck</style> is greatly increased.");
            Lore = new TokenValue("HC_LUCKJUICE_LORE",
                                  "Knowledge is fermented in pain and loss\nDistilled with reflection\nTo quench the thirst of those\nWho dream of enlightenment\n\nOpportunity is ripened in risk and rain\nRefined in a single moment\nTo fuel the hunger of those\nWho crave for avarice\n\n<i>Divination Distillate's model, effect and lore are deratives of Grinding Gear Games' version.</i>");
            var cbuff = new CustomBuff(
                name: "HC_LUCKJUICE_BUFF",
                iconPath: HarbCratePlugin.assetPrefix + "Assets/HarbCrate/DivDistillate/texBuffLuck",
                buffColor: Color.Lerp(Color.red, Color.yellow, 0.5f),
                canStack: false,
                isDebuff: false
                );

            BuffAPI.Add(cbuff);
            DistillateBuff = cbuff.BuffDef;
            IsLunar        = false;
            IsEnigmaCompat = false;
            AssetPath      = HarbCratePlugin.assetPrefix + "Assets/HarbCrate/DivDistillate/LuckJuice.prefab";
            SpritePath     = HarbCratePlugin.assetPrefix + "Assets/HarbCrate/DivDistillate/luckjuice.png";
            DefaultScale  *= 21;
            SetupDisplayRules();
        }
        internal void ValidateThrowException()
        {
            var missingParams = new List <string>();

            if (string.IsNullOrEmpty(ConsumerKey.Trim()))
            {
                missingParams.Add(nameof(ConsumerKey));
            }

            if (string.IsNullOrEmpty(ConsumerSecret.Trim()))
            {
                missingParams.Add(nameof(ConsumerSecret));
            }

            if (string.IsNullOrEmpty(TokenValue.Trim()))
            {
                missingParams.Add(nameof(TokenValue));
            }

            if (string.IsNullOrEmpty(TokenSecret.Trim()))
            {
                missingParams.Add(nameof(TokenSecret));
            }

            if (missingParams.Any())
            {
                throw new BricklinkMissingCredentialsException(missingParams);
            }
        }
Beispiel #4
0
 public Fragment() : base()
 {
     Name = new TokenValue
     {
         Token = "HC_FRAGMENT",
         Value = "Fragment"
     };
     Description = new TokenValue
     {
         Token = "HC_FRAGMENT_DESC",
         Value =
             "Every 3 of these you collect get turned into an item of a higher tier."
     };
     PickupText = new TokenValue
     {
         Token = "HC_FRAGMENT_PICKUP",
         Value = "A fragment of something greater."
     };
     Lore = new TokenValue
     {
         Token = "HC_FRAGMENT_LORE",
         Value = "Do the stars tell us who we are?\nAfter wandering the stars for some decennia now, we can confidentily say,\n<b>\"yes\"</b>\nBecause you are either a spacefarer or you aren't.\nBut if asked if our fate is written there, I doubt it.\nThere's certainties everywhere if you are willing to look, but the stars are generally too far and too many to influence us.\n\nWe must choose our own fate, and grasp our own destiny."
     };
     AssetPath  = "Prefabs/PickupModels/PickupMystery";
     SpritePath = "Textures/MiscIcons/texMysteryIcon";
     Tier       = ItemTier.Tier1;
     Tags       = new ItemTag[]
     {
         ItemTag.AIBlacklist
     };
 }
Beispiel #5
0
        public async void PopulateGuildsAndChannels()
        {
            using var operation = ProgressManager.CreateOperation();

            try
            {
                var tokenValue = TokenValue?.Trim('"', ' ');
                if (string.IsNullOrWhiteSpace(tokenValue))
                {
                    return;
                }

                var token = new AuthToken(
                    IsBotToken ? AuthTokenType.Bot : AuthTokenType.User,
                    tokenValue
                    );

                _settingsService.LastToken = token;

                var discord = new DiscordClient(token);

                var guildChannelMap = new Dictionary <Guild, IReadOnlyList <Channel> >();
                await foreach (var guild in discord.GetUserGuildsAsync())
                {
                    guildChannelMap[guild] = await discord.GetGuildChannelsAsync(guild.Id);
                }

                GuildChannelMap = guildChannelMap;
                SelectedGuild   = guildChannelMap.Keys.FirstOrDefault();
            }
            catch (DiscordChatExporterException ex) when(!ex.IsCritical)
            {
                Notifications.Enqueue(ex.Message.TrimEnd('.'));
            }
        }
Beispiel #6
0
        private static int ParseInteger(RubyContext /*!*/ context, string /*!*/ str)
        {
            bool isNegative = false;

            if (str[0] == '-')
            {
                isNegative = true;
                str        = str.Remove(0, 1);
            }

            Tokenizer tokenizer = new Tokenizer(false, ErrorSink.Null);

            tokenizer.Initialize(context.CreateSnippet(str, SourceCodeKind.File));
            tokenizer.GetNextToken();
            TokenValue     value = tokenizer.TokenValue;
            TokenValueType type  = value.Type;

            tokenizer.GetNextToken();
            TokenValueType nextType = tokenizer.TokenValue.Type;

            // We are only interested in the whole string being a valid Integer
            if (type == TokenValueType.Integer && nextType == TokenValueType.None)
            {
                return(isNegative ? -value.Integer : value.Integer);
            }
            else
            {
                throw RubyExceptions.CreateTypeConversionError("String", "Integer");
            }
        }
Beispiel #7
0
        /// <summary>
        /// 客户端连接事件
        /// </summary>
        /// <param name="context"></param>
        /// <param name="next"></param>
        /// <returns></returns>
        public async Task Acceptor(HttpContext context, Func <Task> next)
        {
            if (!context.WebSockets.IsWebSocketRequest)
            {
                return;
            }
            TokenValue tokenValue = NewSessionTokenVerify(context);

            if (tokenValue == null)
            {
                return;
            }
            Guid SessionId = tokenValue.SessionId;
            var  socket    = await context.WebSockets.AcceptWebSocketAsync();

            var session = new WebSocketSession(socket, SessionId, tokenValue.clientExtraProps);

            this.NewSessionConnectedHandle(session);
            try
            {
                while (socket.State == WebSocketState.Open && ClusterServer.ContainsKey(session.SessionId))
                {//开始接受客户端消息
                    await ReceiveMessageHandle(context, session);
                }
                socket.Abort();
            }
            catch
            {
            }
            this.SessionClosedHandle(session);
        }
Beispiel #8
0
        private static int ParseInteger(RubyContext /*!*/ context, string /*!*/ str)
        {
            bool isNegative = false;

            if (str[0] == '-')
            {
                isNegative = true;
                str        = str.Remove(0, 1);
            }

            Tokenizer tokenizer = new Tokenizer();

            tokenizer.Initialize(new StringReader(str));
            Tokens     token     = tokenizer.GetNextToken();
            TokenValue value     = tokenizer.TokenValue;
            Tokens     nextToken = tokenizer.GetNextToken();

            // We are only interested in the whole string being a valid Integer
            if (token == Tokens.Integer && nextToken == Tokens.Integer)
            {
                return(isNegative ? -value.Integer1 : value.Integer1);
            }
            else
            {
                throw RubyExceptions.CreateTypeConversionError("String", "Integer");
            }
        }
        public void GivenTokenValue_WhenInitialize_PropertiesVerified()
        {
            const string testSubjectText = "TestSubject";
            var          subject         = new TokenValue <SyntaxType>(testSubjectText, SyntaxType.One);

            subject.Value.Should().Be(testSubjectText);
            subject.TokenType.Should().Be(SyntaxType.One);
        }
 public override ILexerState Trim()
 {
     if (LastState.HasValue && LastState.Value.GetType() == typeof(SpecialSymbolLexerState))
     {
         return(new SpecialSymbolLexerState(Sequence, TokenValue.With(v => v.Substring(Token.With(x => x.TokenValue.With(z => z.Length).Value))), LastState.Value, Parsers));
     }
     return(this);
 }
        public void GivenTokenValueWithTypeNotDefault_WhenInitialize_PropertiesShouldVerify()
        {
            const string testSubjectText = "TestSubject123";
            var          subject         = new TokenValue <SyntaxType>(testSubjectText, SyntaxType.Two);

            subject.Value.Should().Be(testSubjectText);
            subject.TokenType.Should().Be(SyntaxType.Two);
        }
Beispiel #12
0
 public AssertTokenizer /*!*/ Next()
 {
     _actualToken = _tokenizer.GetNextToken();
     _actualValue = _tokenizer.TokenValue;
     _actualSpan  = _tokenizer.TokenSpan;
     _allTokens.Add(_actualToken);
     _allValues.Add(_actualValue);
     return(this);
 }
 public BaseApiController()
 {
     LoginID = HttpContext.Current.Session["Username"];
     if (LoginID != null)
     {
         TokenValue = HttpContext.Current.Session[LoginID.ToString()] ?? "";
         HttpContext.Current.Request.Headers.Add("TokenValue", TokenValue.ToString());
     }
 }
Beispiel #14
0
        /// <summary>
        /// Gets or sets a value indicating whether current keyword is equal to the specified value.
        /// </summary>
        /// <param name="keyword">The keyword.</param>
        /// <returns>
        /// A value of <c>true</c> if current keyword is equal to the specified value; otherwise, <c>false</c>.
        /// </returns>
        public bool IsKeyword(string keyword)
        {
            if (TokenType != ConditionTokenType.Keyword)
            {
                return(false);
            }

            return(TokenValue.Equals(keyword, StringComparison.OrdinalIgnoreCase));
        }
Beispiel #15
0
        public TokenValue <T> Create()
        {
            var x = TokenLength;
            var r = new TokenValue <T>(_id, _hasOriginal ? _original : _value, _value, _position, TokenLength);

            Reset();
            var y = TokenLength;


            return(r);
        }
Beispiel #16
0
        public void DumpTokenDetail(TextWriter /*!*/ output, Tokenizer /*!*/ tokenizer, Tokens token)
        {
            TokenValue value = tokenizer.TokenValue;

            output.Write("{0}: ", Parser.GetTerminalName((int)token));

            switch (token)
            {
            default:
                break;

            case Tokens.Identifier:
                output.Write(value.String);
                break;

            case Tokens.Float:
                output.Write("{0}D", value.Double);
                break;

            case Tokens.Integer:
                output.Write(value.Integer1);
                break;

            case Tokens.BigInteger:
                output.Write("{0}BI", value.BigInteger.ToString(10));
                break;

            case Tokens.RegexpEnd:
                output.Write("RegexOptions({0})", (RubyRegexOptions)value.Integer1);
                break;

            case Tokens.StringContent:
                if (value.StringContent is string)
                {
                    output.Write("String(\"{0}\", {1})", Parser.EscapeString((string)value.StringContent), value.Encoding);
                }
                else
                {
                    output.Write("String({0}), {1}", BitConverter.ToString((byte[])value.StringContent), value.Encoding);
                }
                break;

            case Tokens.StringBegin:
            case Tokens.RegexpBegin:
            case Tokens.ShellStringBegin:
            case Tokens.SymbolBegin:
                output.Write(((Tokenizer.State)tokenizer.CurrentState).CurrentSequence);
                break;
            }

            output.Write(' ');
            output.Write(tokenizer.LexicalState);
            output.WriteLine();
        }
Beispiel #17
0
 public Token(TokenValue _tokenVal)
 {
     tokenText = null;
     if (_tokenVal <= TokenValue.Equals)
     {
         tokenVal = _tokenVal;
     }
     else
     {
         tokenVal = TokenValue.Error;
     }
 }
Beispiel #18
0
        /// <summary>
        /// 连接前的负载、授权,返回 ws 目标地址,
        /// 使用该地址连接 websocket 服务端
        /// </summary>
        /// <param name="SessionId">客户端id</param>
        /// <param name="clientExtraProps">客户端相关信息,比如ip</param>
        /// <returns>websocket 地址:ws://xxxx/ws?token=xxx</returns>
        public string PrevConnectServer(Guid SessionId, string clientExtraProps)
        {
            var        server     = SelectServer(SessionId);
            var        token      = TokenUtil.GeneratorToken();
            TokenValue tokenValue = new TokenValue()
            {
                SessionId        = SessionId,
                clientExtraProps = clientExtraProps
            };
            var tokenRedisKey = RedisKeyFormatUtil.GetConnectToken(this._appId, token);

            _redis.Set(tokenRedisKey, JsonConvert.SerializeObject(tokenValue), ConstData.TokenExpireTime);
            return($"ws://{server}{_pathMatch}?token={token}");
        }
Beispiel #19
0
        public void CorrectStartWhenCaptureDoesNotIncludeFirstCharacter()
        {
            const int expectedStart = 2;

            var capture = Stock.Tokens.CaptureAfter("a", expectedStart);

            // Sanity checks: if these asserts fail, The GenerateCapture function
            // did not set up the test correctly
            Assert.AreEqual(expectedStart, capture.Index);

            var to = new TokenValue <TestToken>(TestToken.One.ToString(), capture);

            Assert.AreEqual(expectedStart, to.Start, "Start should be the value of Index from the capture");
        }
Beispiel #20
0
 public override BloodPressureQuery AddValueFilter(string parameterName, TokenValue value)
 {
     if (parameterName == "_id")
     {
         if (!long.TryParse(value.Code, out long bpId))
         {
             throw new ArgumentException("BloodPressure Id must be an integer value.");
         }
         else
         {
             return(PredicateQuery(vp => vp.Id == bpId));
         }
     }
     return(base.AddValueFilter(parameterName, value));
 }
        public void HandleTokenParam()
        {
            var p1 = new TokenValue("NOK", "http://somewhere.nl/codes");

            Assert.AreEqual("http://somewhere.nl/codes|NOK", p1.ToString());

            var p2 = new TokenValue("y|n", "http://some|where.nl/codes");

            Assert.AreEqual(@"http://some\|where.nl/codes|y\|n", p2.ToString());

            var p3 = new TokenValue("NOK", matchAnyNamespace: true);

            Assert.AreEqual("NOK", p3.ToString());

            var p4 = new TokenValue("NOK", matchAnyNamespace: false);

            Assert.AreEqual("|NOK", p4.ToString());

            var p5 = TokenValue.Parse("http://somewhere.nl/codes|NOK");

            Assert.AreEqual("http://somewhere.nl/codes", p5.Namespace);
            Assert.AreEqual("NOK", p5.Value);
            Assert.IsFalse(p4.AnyNamespace);

            var p6 = TokenValue.Parse(@"http://some\|where.nl/codes|y\|n");

            Assert.AreEqual(@"http://some|where.nl/codes", p6.Namespace);
            Assert.AreEqual("y|n", p6.Value);
            Assert.IsFalse(p6.AnyNamespace);

            var p7 = TokenValue.Parse("|NOK");

            Assert.AreEqual(null, p7.Namespace);
            Assert.AreEqual("NOK", p7.Value);
            Assert.IsFalse(p7.AnyNamespace);

            var p8 = TokenValue.Parse("NOK");

            Assert.AreEqual(null, p8.Namespace);
            Assert.AreEqual("NOK", p8.Value);
            Assert.IsTrue(p8.AnyNamespace);

            var crit = Criterium.Parse("paramX=|NOK");
            var p9   = ((UntypedValue)crit.Operand).AsTokenValue();

            Assert.AreEqual("NOK", p9.Value);
            Assert.IsFalse(p9.AnyNamespace);
        }
Beispiel #22
0
        public void ConstructorAssignsValues()
        {
            const TestToken expectedToken    = TestToken.Two;
            const string    expectedValue    = "Value";
            const string    expectedOriginal = "Original";
            const int       expectedStart    = 10;
            const int       expectedLength   = 20;

            var to = new TokenValue <TestToken>(expectedToken, expectedOriginal, expectedValue, expectedStart, expectedLength);

            Assert.AreEqual(expectedToken, to.Id, "Token Id should be assigned from parameter");
            Assert.AreEqual(expectedOriginal, to.Original, "Original should be assigned from parameter");
            Assert.AreEqual(expectedValue, to.Value, "Value should be assigned from parameter");
            Assert.AreEqual(expectedStart, to.Start, "Start should be assigned from parameter");
            Assert.AreEqual(expectedLength, to.Length, "Length should be assigned from parameter");
        }
Beispiel #23
0
        /// <summary>
        /// 产生记号对象
        /// </summary>
        /// <param name="TokenWord">分析得到的单词</param>
        /// <param name="Index">当前序号</param>
        /// <returns>记号对象</returns>
        /// <remarks>Author:Alex Leo</remarks>
        public new static TokenRecord ProduceToken(string TokenWord, int Index)
        {
            TokenRecord Token = new TokenValue(Index + 1, TokenWord.Length);

            Token.TokenValueType = TokenValueTypeEnum.Number;
            double dblValue;

            if (double.TryParse(TokenWord, out dblValue))
            {
                Token.TokenValue = dblValue;
            }
            else
            {
                throw new SyntaxException(Index, TokenWord.Length, "表达式 " + TokenWord + " 无法转换成数值。");
            }

            return(Token);
        }
Beispiel #24
0
        public void ClonesWithNewValue()
        {
            const TestToken expectedToken    = TestToken.Two;
            const string    expectedValue    = "Value";
            const string    expectedOriginal = "Original";
            const int       expectedStart    = 10;
            const int       expectedLength   = 20;

            var source = new TokenValue <TestToken>(TestToken.DoNotUse, expectedOriginal, "this is not right", expectedStart, expectedLength);

            var to = source.Clone(expectedToken, expectedValue);

            Assert.AreEqual(expectedToken, to.Id, "Token Id should be assigned from source");
            Assert.AreEqual(expectedOriginal, to.Original, "Original should be assigned from source");
            Assert.AreEqual(expectedValue, to.Value, "Value should be assigned from parameter");
            Assert.AreEqual(expectedStart, to.Start, "Start should be assigned from source");
            Assert.AreEqual(expectedLength, to.Length, "Length should be assigned from source");
        }
 public override PatientQuery AddValueFilter(string parameterName, TokenValue value)
 {
     if (parameterName == ParameterNames.Id)
     {
         if (!long.TryParse(value.Code, out long patientId))
         {
             throw new ArgumentException("Patient Id must be an integer value.");
         }
         else
         {
             return(PredicateQuery(vp => vp.Id == patientId));
         }
     }
     else if (parameterName == "identifier")
     {
         return(PredicateQuery(vp => vp.PatientNumber == value.Code));
     }
     return(base.AddValueFilter(parameterName, value));
 }
        public void HandleComposites()
        {
            var pX = new CompositeValue(new ValueExpression[] { new StringValue("hello, world!"), new NumberValue(14.8M) });
            var pY = new TokenValue("NOK", "http://somesuch.org");
            var p1 = new ChoiceValue(new ValueExpression[] { pX, pY });

            Assert.AreEqual(@"hello\, world!$14.8,http://somesuch.org|NOK", p1.ToString());

            var crit1 = ChoiceValue.Parse(@"hello\, world$14.8,http://somesuch.org|NOK");

            Assert.AreEqual(2, crit1.Choices.Length);
            Assert.IsTrue(crit1.Choices[0] is CompositeValue);
            var comp1 = crit1.Choices[0] as CompositeValue;

            Assert.AreEqual(2, comp1.Components.Length);
            Assert.AreEqual("hello, world", ((UntypedValue)comp1.Components[0]).AsStringValue().Value);
            Assert.AreEqual(14.8M, ((UntypedValue)comp1.Components[1]).AsNumberValue().Value);
            Assert.AreEqual("http://somesuch.org|NOK", ((UntypedValue)crit1.Choices[1]).AsTokenValue().ToString());
        }
Beispiel #27
0
        public WrithingJar() : base()
        {
            Name        = new TokenValue("HC_WORMJAR", "The Writhing Jar");
            Description = new TokenValue("HC_WORMJAR_DESC",
                                         "Summons a <style=cIsHealing>friendly</style> Magma Worm and a <style=cDeath>HOSTILE</cstyle> <color=blue>Overloading Magma Worm</color>.");
            PickupText = new TokenValue("HC_WORMJAR_DESC",
                                        "Inside of you there's two worms. One is a friend, the other a monster. You are a <color=blue>monster</color>.");
            Lore = new TokenValue("HC_WORMJAR_LORE",
                                  "<style=cStack>Recovered from a half burned notebook, near unmarked research facility at [Redacted]</style>\r\n<style=cIsUtility>Day 4:</style>\nThe writings said the urn was the 'vessel of a great scourge', that it was a 'tremendous power that turned breath to smoke and flesh to ash'. Mikhail thinks it's just a jar of dead worms - probably a plague that they didn't understand and some leeches that they used to try and 'draw it out'.Or something. But... I'm not so sure. \n\n<style=cIsUtility>Day 12:</style>\nI've been having a dream lately, more or less the same every night. It's always there, almost like it's waiting. The air feels like being in an oven; heavy and so hot it feels like I'm going to burn up or dry out or both. I open up the lid, and reach inside. The skin on my fingers blisters and cracks. I push my hands in deeper and my flesh turns to char, and then to dust...but I don't feel anything. It's almost a relief, to be free from that heat. I fall inside, and my body turns to smoke that joins the darkness. It's a little bit unsettling, to be sure. And yet, I keep having this feeling like there's something more here. Something coiled just beneath the surface.\nI need to run some more tests. Maybe I can coax these dried husks back to life, or clone them, or something. Get some answers.\nI'll keep it to myself for now - Mikhail would just think I'm being stupid - but there is more to this jar than just a couple of silly little worms.\n<style=cStack>The rest of the log is unreadable.</style>");
            AssetPath      = HarbCratePlugin.assetPrefix + "Assets/HarbCrate/2_Worm_Jar/WormJar.prefab";
            SpritePath     = HarbCratePlugin.assetPrefix + "Assets/HarbCrate/2_Worm_Jar/worm.png";
            Cooldown       = 120f;
            IsLunar        = true;
            IsEnigmaCompat = true;

            hostileCard = Resources.Load <SpawnCard>("SpawnCards/CharacterSpawnCards/cscElectricWorm");
            friendCard  = Resources.Load <SpawnCard>("SpawnCards/CharacterSpawnCards/cscMagmaWorm");

            DefaultScale *= 2.3f;
            SetupDisplayRules();
        }
        public void DumpTokenDetail(TextWriter /*!*/ output, Tokenizer /*!*/ tokenizer, Tokens token)
        {
            TokenValue value = tokenizer.TokenValue;

            output.Write("{0}: ", Parser.TerminalToString((int)token));

            switch (value.Type)
            {
            case TokenValueType.None:
                break;

            case TokenValueType.Double:
                output.Write("{0}D", value.Double);
                break;

            case TokenValueType.Integer:
                output.Write(value.Integer);
                break;

            case TokenValueType.BigInteger:
                output.Write("{0}BI", value.BigInteger.ToString(10));
                break;

            case TokenValueType.RegexOptions:
                output.Write("RegexOptions({0})", (RubyRegexOptions)value.Integer);
                break;

            case TokenValueType.String:
                output.Write("String(\"{0}\")", Parser.EscapeString(value.String));
                break;

            case TokenValueType.StringTokenizer:
                output.Write(value.StringTokenizer);
                break;
            }

            output.Write(' ');
            output.Write(tokenizer.LexicalState);
            output.WriteLine();
        }
Beispiel #29
0
        public BrawnOverBrain() : base()
        {
            const string cShield = "<style=cIsHealing>shield</style>";
            const string cHealth = "<style=cIsHealing>health</style>";

            Name = new TokenValue
            {
                Token = "HC_BOB",
                Value = "Brawn over Brain"
            };
            Description = new TokenValue
            {
                Token = "HC_BOB_DESC",
                Value =
                    $"<style=cIsUtility>50%</style><style=cStack>(+0% per stack)</style> <style=cIsUtility>debuff reduction</style> whilst you have {cShield}."
                    + $" <style=cIsUtility>40%</style><style=cStack>(+15% per stack)</style>* of damage taken is taken from {cHealth} before {cShield}."
                    + $" This damage <b>cannot</b> kill while you have enough {cShield}."
            };
            PickupText = new TokenValue
            {
                Token = "HC_BOB_PICKUP",
                Value = $"A percentage of damage is taken from {cHealth} before {cShield}."
                        + $" <style=cIsUtility>50% debuff reduction</style> whilst you have {cShield}."
            };
            Lore = new TokenValue
            {
                Token = "HC_BOB_LORE",
                Value = "For loss, one must have\nFor defeat, one must try\n\nChange means to have an unnacceptable reality\n\nTo abandon, one must have\nTo win, one must try\n\nChange means to have an acceptable reality\n\nBeyond pain lies recovery\nBeyond rain lies the sun\n\nChange means to be wrong\n\nBefore disaster lies hope\nBefore death lies life\n\nChange means to be right\n\nAbandon then, your flesh.\nAbandon then, your frailty.\nCast your suffering away.\nEmbrace the balance between."
            };
            AssetPath  = HarbCratePlugin.assetPrefix + "Assets/HarbCrate/Tetrahdron/BoB.prefab";
            SpritePath = HarbCratePlugin.assetPrefix + "Assets/HarbCrate/Tetrahdron/bob.png";
            Tier       = ItemTier.Tier3;
            Tags       = new ItemTag[2]
            {
                ItemTag.Utility,
                ItemTag.Healing
            };
            SetupDisplayRules();
        }
Beispiel #30
0
        public ColdSnap() : base()
        {
            Cooldown    = 64;
            Name        = new TokenValue("HC_COLDSNAP", "Coldsnap");
            PickupText  = new TokenValue("HC_COLDSNAP_PICKUP", "<style=cIsUtility>Freeze</style> nearby enemies.");
            Description = new TokenValue("HC_COLDSNAP_DESC",
                                         $"<style=cIsUtility>Freeze</style> nearby enemies for {FreezeDuration} seconds."
                                         + " Frozen enemies can be <style=cIsDamage>executed</style>."
                                         );
            Lore = new TokenValue
            {
                Token = "HC_COLDSNAP_LORE",
                Value = "Order: \"Instant Antiheat Crystal\"\r\nTracking Number: 23******\r\nEstimated Delivery: 02/29/2056\r\nShipping Method:  Standard/Fragile\r\nShipping Address: Tortoise Infrastructure, Salvador, Earth\r\nShipping Details:\r\n\r\nTo safeguard the interests of our clients, we need to up our fire proofing. I have ordered a test run of IACs for you. Install them and find out if they are worth investing into. "
            };
            IsLunar        = false;
            IsEnigmaCompat = true;
            AssetPath      = HarbCratePlugin.assetPrefix + "Assets/HarbCrate/IceShard/ColdSnap.prefab";
            SpritePath     = HarbCratePlugin.assetPrefix + "Assets/HarbCrate/IceShard/coldsnap.png";

            DefaultScale *= 60;
            SetupDisplayRules();
        }
Beispiel #31
0
        public static string tokenstring(TokenValue tok)
        {
            switch (tok)
            {
                case TokenValue.TWOPOINTS:
                    return ":";
                case TokenValue.LPAR:
                    return "(";
                case TokenValue.RPAR:
                    return ")";
                case TokenValue.LBRACKET:
                    return "[";
                case TokenValue.RBRACKET:
                    return "]";
                case TokenValue.LBRACE:
                    return "{";
                case TokenValue.RBRACE:
                    return "}";
                case TokenValue.COMMA:
                    return ",";
                case TokenValue.DOT:
                    return ".";
                case TokenValue.SEMICOLON:
                    return ";";
                case TokenValue.DOLLAR:
                    return "$";
                case TokenValue.SHARP:
                    return "#";

                //[Identificateurs]
                case TokenValue.VALUE_IDENTIFIER:
                    return "value identifier";
                case TokenValue.TYPE_IDENTIFIER:
                    return "type identifier";

                //[Structures de controle]

                case TokenValue.IF:
                    return "if";
                case TokenValue.ELSEIF:
                    return "else if";
                case TokenValue.ELSE:
                    return "else";

                case TokenValue.SWITCH:
                    return "switch";
                case TokenValue.CASE:
                    return "case";
                case TokenValue.DEFAULT:
                    return "default";
                case TokenValue.BREAK:
                    return "break";

                case TokenValue.WHILE:
                    return "while";
                case TokenValue.DO:
                    return "do";

                case TokenValue.FOR:
                    return "for";

                //[Operateurs booleens]      

                case TokenValue.AND:
                    return "&&";
                case TokenValue.OR:
                    return "||";
                case TokenValue.GT:
                    return ">";
                case TokenValue.LT:
                    return "<";
                case TokenValue.GEQ:
                    return ">=";
                case TokenValue.LEQ:
                    return "<=";
                case TokenValue.EQBOOL:
                    return "==";
                case TokenValue.NEG:
                    return "!";

                case TokenValue.EQ:
                    return "=";
                case TokenValue.PLUSEQ:
                    return "+=";
                case TokenValue.MINUSEQ:
                    return "-=";
                case TokenValue.TIMESEQ:
                    return "*=";
                case TokenValue.DIVEQ:
                    return "/=";

                case TokenValue.PLUSPLUS:
                    return "++";
                case TokenValue.MINUSMINUS:
                    return "--";
                case TokenValue.TIMESTIMES:
                    return "**";

                //[Operateurs]
                case TokenValue.PLUS:
                    return "+";
                case TokenValue.MINUS:
                    return "-";
                case TokenValue.TIMES:
                    return "*";
                case TokenValue.DIV:
                    return "/";



                //[Types]
                case TokenValue.STRING:
                    return "string";
                case TokenValue.CHAR:
                    return "char";
                case TokenValue.INT:
                    return "int";
                case TokenValue.BOOLEAN:
                    return "boolean";

                //[Autres]
                case TokenValue.NEW:
                    return "new";

                //[Mots-cles]
                case TokenValue.NPC:
                    return "npc";
                case TokenValue.FUNCTION:
                    return "function";
                case TokenValue.CONSTANT:
                    return "constant";
                case TokenValue.CLASS:
                    return "class";

                //[Special]
                case TokenValue.EOF:
                    return "eof";

                default:
                    return "";
            }
        }
Beispiel #32
0
 public Token(TokenValue typeVal, bool value)
 {
     this.type = typeVal;
     this.booleanValue = value;
 }
Beispiel #33
0
 public Token(TokenValue typeVal, string value)
 {
     this.type = typeVal;
     this.stringValue = value;
 }
Beispiel #34
0
        //-----CONSTRUCTEURS-----

        public Token(TokenValue typeVal)
        {
            this.type = typeVal;
        }
Beispiel #35
0
 public Token(TokenValue typeVal, char value)
 {
     this.type = typeVal;
     this.charValue = value;
 }
Beispiel #36
0
 // Implementation of IEvaluationState
 public void AppendValue( TokenValue value )
 {
     m_postfix_expression.Add( value );
 }
Beispiel #37
0
        public void HandleTokenParam()
        {
            var p1 = new TokenValue("NOK", "http://somewhere.nl/codes");
            Assert.AreEqual("http://somewhere.nl/codes|NOK", p1.ToString());

            var p2 = new TokenValue("y|n", "http://some|where.nl/codes");
            Assert.AreEqual(@"http://some\|where.nl/codes|y\|n", p2.ToString());

            var p3 = new TokenValue("NOK", matchAnyNamespace: true);
            Assert.AreEqual("NOK", p3.ToString());

            var p4 = new TokenValue("NOK", matchAnyNamespace: false);
            Assert.AreEqual("|NOK", p4.ToString());

            var p5 = TokenValue.Parse("http://somewhere.nl/codes|NOK");
            Assert.AreEqual("http://somewhere.nl/codes", p5.Namespace);
            Assert.AreEqual("NOK", p5.Value);
            Assert.IsFalse(p4.AnyNamespace);

            var p6 = TokenValue.Parse(@"http://some\|where.nl/codes|y\|n");
            Assert.AreEqual(@"http://some|where.nl/codes", p6.Namespace);
            Assert.AreEqual("y|n", p6.Value);
            Assert.IsFalse(p6.AnyNamespace);

            var p7 = TokenValue.Parse("|NOK");
            Assert.AreEqual(null, p7.Namespace);
            Assert.AreEqual("NOK", p7.Value);
            Assert.IsFalse(p7.AnyNamespace);

            var p8 = TokenValue.Parse("NOK");
            Assert.AreEqual(null, p8.Namespace);
            Assert.AreEqual("NOK", p8.Value);
            Assert.IsTrue(p8.AnyNamespace);

            var crit = Criterium.Parse("paramX=|NOK");
            var p9 = ((UntypedValue)crit.Operand).AsTokenValue();
            Assert.AreEqual("NOK", p9.Value);
            Assert.IsFalse(p9.AnyNamespace);
        }
Beispiel #38
0
 public Token(TokenValue _tokenVal)
 {
     tokenText = null;
     if (_tokenVal <= TokenValue.Equals)
     {
         tokenVal = _tokenVal;
     }
     else
     {
         tokenVal = TokenValue.Error;
     }
 }
Beispiel #39
0
        public Token(string _tokenText, ScannerState _state, bool quoteFlag)
        {
            state = _state;

            if (_tokenText == null)//|| _tokenText.Length == 0 )
            {
                //tokenVal = TokenValue.Error;
                //errorMessage = "Bad Token String - 0 length";
                _tokenText = "";
            }
            //else
            //{
            switch (state)
            {
                case ScannerState.ParseID:
                    tokenText = _tokenText.ToLower();
                    if (reservedWords.Contains(tokenText))
                    {
                        tokenVal = (TokenValue)reservedWords[tokenText];
                    }
                    else if (tokenText.StartsWith("x-"))
                    {
                        tokenVal = TokenValue.Xtension;
                        tokenText = "x:" + tokenText.Substring(2);
                    }
                    else if (isID(tokenText))  // this check may be unnecessary by virute of the scanner....
                    {
                        tokenVal = TokenValue.ID;
                    }
                    else
                    {
                        tokenVal = TokenValue.Error;
                        errorMessage = "Illegal value for ID";
                    }
                    if (isBeginEndValue())
                    {
                        tokenText = CapsCamelCase(tokenText);
                    }
                    else
                    {
                        tokenText = CamelCase(tokenText);
                    }
                    break;

                case ScannerState.ParseParms:
                    tokenText = HttpUtility.HtmlEncode(_tokenText);
                    if (quoteFlag)
                    {
                        tokenVal = TokenValue.QuotedString;
                    }
                    else
                    {
                        tokenVal = TokenValue.Parm;
                    }
                    break;

                case ScannerState.ParseValue:
                    tokenText = HttpUtility.HtmlEncode(_tokenText);
                    tokenVal = TokenValue.Value;
                    break;

                case ScannerState.ParseSimple:
                    tokenVal = TokenValue.Error;
                    errorMessage = "Bad constructor call - ParseSimple and text...";
                    break;
            }
            //}
        }
Beispiel #40
0
        public void HandleComposites()
        {
            var pX = new CompositeValue(new ValueExpression[] { new StringValue("hello, world!"), new NumberValue(14.8M) });
            var pY = new TokenValue("NOK", "http://somesuch.org");
            var p1 = new ChoiceValue(new ValueExpression[] { pX, pY });
            Assert.AreEqual(@"hello\, world!$14.8,http://somesuch.org|NOK", p1.ToString());

            var crit1 = ChoiceValue.Parse(@"hello\, world$14.8,http://somesuch.org|NOK");
            Assert.AreEqual(2, crit1.Choices.Length);
            Assert.IsTrue(crit1.Choices[0] is CompositeValue);
            var comp1 = crit1.Choices[0] as CompositeValue;
            Assert.AreEqual(2, comp1.Components.Length);
            Assert.AreEqual("hello, world", ((UntypedValue)comp1.Components[0]).AsStringValue().Value);
            Assert.AreEqual(14.8M, ((UntypedValue)comp1.Components[1]).AsNumberValue().Value);
            Assert.AreEqual("http://somesuch.org|NOK", ((UntypedValue)crit1.Choices[1]).AsTokenValue().ToString());
        }
Beispiel #41
0
 public Token(TokenValue typeVal, int value)
 {
     this.type = typeVal;
     this.intValue = value;
 }