Example #1
0
 public Development(uint level, uint prestige, TokenColor discounts, IReadOnlyTokenCollection cost)
 {
     Level         = level;
     Prestige      = prestige;
     _costInternal = cost;
     Discounts     = discounts;
 }
Example #2
0
        public static Player NewPlayer(string name, Board board, TokenColor tokenColor) // Create a new player and add the tokens to the player
        {
            var player = new Player {
                Name = name
            };

            player.Tokens = CreateTokens(tokenColor, player); // Add tokens yo the player

            switch (tokenColor)                               // Set starting position
            {
            case TokenColor.Blue:
                board.Squares[42].Occupants.Add(player.Tokens[0]);
                break;

            case TokenColor.Yellow:
                board.Squares[28].Occupants.Add(player.Tokens[0]);
                break;

            case TokenColor.Green:
                board.Squares[14].Occupants.Add(player.Tokens[0]);
                break;

            case TokenColor.Red:
                board.Squares[0].Occupants.Add(player.Tokens[0]);
                break;
            }

            return(player);
        }
Example #3
0
        private void addSquare(TokenColor tokenColor, double width, double height, Thickness margin, int squareIndex)
        {
            Rectangle square = new Rectangle();

            square.Fill           = getColorByTokenColor(tokenColor, false);
            square.Width          = width;
            square.Height         = height;
            square.Margin         = margin;
            square.Name           = "Square" + squareIndex.ToString();
            square.MouseDown     += Square_MouseDown;
            _squares[squareIndex] = square;
            mainCanvas.Children.Add(square);

            if (_engine.Squares[squareIndex].Occupied)
            {
                Ellipse token = new Ellipse();
                token.Width      = _tokenDiameter;
                token.Height     = _tokenDiameter;
                token.Margin     = margin;
                token.Fill       = getColorByTokenColor(_engine.Squares[squareIndex].Token.TokenColor, true);
                token.Name       = "Token" + squareIndex.ToString();
                token.MouseDown += Square_MouseDown;
                mainCanvas.Children.Add(token);
            }
        }
Example #4
0
        private void updateCurrentPlayer()
        {
            TokenColor playerColor = (TokenColor)_engine.CurrentPlayer;

            _lblCurrentPlayer = new Label();

            TextBlock txtBlockDesc = new TextBlock();

            txtBlockDesc.Text = "Current Player: ";

            TextBlock txtBlockClr = new TextBlock();

            txtBlockClr.Background = getColorByTokenColor(playerColor, false);
            txtBlockClr.Text       = playerColor.ToString();

            StackPanel panel = new StackPanel();

            panel.Orientation = Orientation.Horizontal;
            panel.Children.Add(txtBlockDesc);
            panel.Children.Add(txtBlockClr);

            _lblCurrentPlayer.FontSize = 24;
            _lblCurrentPlayer.Content  = panel;
            _lblCurrentPlayer.Margin   = new Thickness(_gameboardX + _homeYardLength, _gameboardY - 50, 0, 0);
            mainCanvas.Children.Add(_lblCurrentPlayer);

            Rectangle marker = new Rectangle();

            marker.Fill   = Brushes.Black;
            marker.Width  = _homeYards[_engine.CurrentPlayer - 1].Width + _squareMargin;
            marker.Height = _homeYards[_engine.CurrentPlayer - 1].Height + _squareMargin;
            marker.Margin = _homeYards[_engine.CurrentPlayer - 1].Margin;
            Panel.SetZIndex(marker, -1);
            mainCanvas.Children.Add(marker);
        }
Example #5
0
        public bool ScanTokenAndProvideInfoAboutIt(TokenInfo tokenInfo, ref int state)
        {
            if (_lexer == null)
                return false;

            ScanTokenInfo info = _lexer.GetToken((ScanState)state);

            if (info == null)
                return false;

            state		= (int)info.State;

            _lastColor   = (TokenColor)info.Color;
            _colorizeEnd = info.ColorizeEnd;

            tokenInfo.Color	     = _lastColor;
            tokenInfo.Type	     = (TokenType)	info.Type;
            tokenInfo.Trigger	   = (TokenTriggers)info.Triggers;

            if (info.Token == null)
                return false;

            tokenInfo.StartIndex = info.Token.Location.Column	- 1;
            tokenInfo.EndIndex   = info.Token.Location.EndColumn - 2;

            return !info.IsEndOfLine;
        }
Example #6
0
 public Token(int idx)
 {
     this.index = idx;
     if (idx < 13)
     {
         this.color = TokenColor.YELLOW;
         this.val   = idx + 1;
     }
     else if (idx < 26)
     {
         this.color = TokenColor.BLUE;
         this.val   = (idx % 12) + 1;
     }
     else if (idx < 39)
     {
         this.color = TokenColor.BLACK;
         this.val   = (idx % 12) + 1;
     }
     else if (idx < 52)
     {
         this.color = TokenColor.RED;
         this.val   = (idx % 12) + 1;
     }
     else
     {
         this.color = TokenColor.NONE;
     }
 }
Example #7
0
        /// <summary>
        /// This method is used to parse next language token from the current line and return information about it.
        /// </summary>
        /// <param name="tokenInfo"> The TokenInfo structure to be filled in.</param>
        /// <param name="state"> The scanner's current state value.</param>
        /// <returns>Returns true if a token was parsed from the current line and information returned;
        /// otherwise, returns false indicating no more tokens are on the current line.</returns>
        public bool ScanTokenAndProvideInfoAboutIt(TokenInfo tokenInfo, ref int state)
        {
            // If input string is empty - there is nothing to parse - so, return false
            if (sourceString.Length == 0)
            {
                return(false);
            }

            TokenColor color        = TokenColor.Text;
            int        charsMatched = 0;

            // Compare input string with patterns from correspondence table
            MatchRegEx(sourceString, ref charsMatched, ref color);

            // Fill in TokenInfo structure on the basis of examination
            if (tokenInfo != null)
            {
                tokenInfo.Color      = color;
                tokenInfo.Type       = TokenType.Text;
                tokenInfo.StartIndex = currentPos;
                tokenInfo.EndIndex   = Math.Max(currentPos, currentPos + charsMatched - 1);
            }

            // Move current position
            currentPos += charsMatched;

            // Set an unprocessed part of string as a source
            sourceString = sourceString.Substring(charsMatched);

            return(true);
        }
Example #8
0
        public override void Init(GrammarData grammarData)
        {
            base.Init(grammarData);
            if (this.EditorInfo != null)
            {
                return;
            }
            TokenType tknType = TokenType.Identifier;

            if (IsSet(TermOptions.IsOperator))
            {
                tknType |= TokenType.Operator;
            }
            else if (IsSet(TermOptions.IsDelimiter | TermOptions.IsPunctuation))
            {
                tknType |= TokenType.Delimiter;
            }
            TokenTriggers triggers = TokenTriggers.None;

            if (this.IsSet(TermOptions.IsBrace))
            {
                triggers |= TokenTriggers.MatchBraces;
            }
            if (this.IsSet(TermOptions.IsMemberSelect))
            {
                triggers |= TokenTriggers.MemberSelect;
            }
            TokenColor color = TokenColor.Text;

            if (IsSet(TermOptions.IsKeyword))
            {
                color = TokenColor.Keyword;
            }
            this.EditorInfo = new TokenEditorInfo(tknType, color, triggers);
        }
Example #9
0
        public bool ScanTokenAndProvideInfoAboutIt(TokenInfo tokenInfo, ref int state)
        {
            if (_lexer == null)
            {
                return(false);
            }

            ScanTokenInfo info = _lexer.GetToken((ScanState)state);

            if (info == null)
            {
                return(false);
            }

            state = (int)info.State;

            _lastColor   = (TokenColor)info.Color;
            _colorizeEnd = info.ColorizeEnd;

            tokenInfo.Color   = _lastColor;
            tokenInfo.Type    = (TokenType)info.Type;
            tokenInfo.Trigger = (TokenTriggers)info.Triggers;

            if (info.Token == null)
            {
                return(false);
            }

            tokenInfo.StartIndex = info.Token.Location.Column - 1;
            tokenInfo.EndIndex   = info.Token.Location.EndColumn - 2;

            return(!info.IsEndOfLine);
        }
Example #10
0
 public TokenTableEntry(ScanContext inputContext, ScanContext outputContext, string pattern, TokenColor color, TokenTriggers triggers)
 {
     this.inputContext  = inputContext;
     this.outputContext = outputContext;
     this.regExpression = new Regex(/*"\\G" + */ pattern);             // \G = "anchor to the current position"
     this.tokenColor    = color;
     this.tokenTriggers = triggers;
 }
Example #11
0
 public Player(TokenColor tokenColor)
 {
     if (tokenColor == TokenColor.None)
     {
         throw new InvalidTokenColorException("A player needs a color");
     }
     TokenColor = tokenColor;
 }
 public bool WillPush(Square[] gameBoard, int targetPosition, TokenColor playerTokenColor)
 {
     if (!gameBoard[targetPosition].Occupied)
     {
         return(false);
     }
     //Don't push your own token
     return(gameBoard[targetPosition].Token.TokenColor != playerTokenColor);
 }
Example #13
0
 public Player(TokenColor tokenColor)
 {
     if (tokenColor == TokenColor.None)
     {
         throw new InvalidOperationException("A player needs a color");
     }
     TokenColor = tokenColor;
     _tokens    = new Token[HomeYard.TokenCount];
 }
Example #14
0
 private static void removefromTokensList(List <Token> tokens, TokenColor color, int value)
 {
     for (int i = tokens.Count - 1; i >= 0; --i)
     {
         if (tokens[i].GetColor() == color && tokens[i].GetValue() == value)
         {
             tokens.RemoveAt(i);
         }
     }
 }
            private int getStartPositionByColor(TokenColor tokenColor)
            {
                if (tokenColor == TokenColor.None)
                {
                    throw new InvalidTokenColorException("Can't get start position when color is none");
                }

                //Color - 1 times a quarter lap in the square
                return((((int)tokenColor) - 1) * (cycleCount / 4));
            }
Example #16
0
        public HomeYard(TokenColor tokenColor)
        {
            if (tokenColor == TokenColor.None)
            {
                throw new InvalidTokenColorException("A homeyard needs a color");
            }

            TokenColor = tokenColor;
            _tokens    = new Stack <Token>();
        }
        static Configuration()
        {
            ccsCommentInfo.BlockEnd        = "\n";
            ccsCommentInfo.BlockStart      = "#";
            ccsCommentInfo.LineStart       = "??";
            ccsCommentInfo.UseLineComments = true;

            // default colors - currently, these need to be declared
            CreateColor("Keyword", COLORINDEX.CI_BLUE, COLORINDEX.CI_USERTEXT_BK);
            CreateColor("Comment", COLORINDEX.CI_DARKGREEN, COLORINDEX.CI_USERTEXT_BK);
            CreateColor("Identifier", COLORINDEX.CI_SYSPLAINTEXT_FG, COLORINDEX.CI_USERTEXT_BK);
            CreateColor("String", COLORINDEX.CI_RED, COLORINDEX.CI_USERTEXT_BK);
            CreateColor("Number", COLORINDEX.CI_SYSPLAINTEXT_FG, COLORINDEX.CI_USERTEXT_BK);
            CreateColor("Text", COLORINDEX.CI_SYSPLAINTEXT_FG, COLORINDEX.CI_USERTEXT_BK);

            TokenColor error       = CreateColor("Error", COLORINDEX.CI_RED, COLORINDEX.CI_USERTEXT_BK, false, false);
            TokenColor proc        = CreateColor("Proc", COLORINDEX.CI_AQUAMARINE, COLORINDEX.CI_USERTEXT_BK, true, false);
            TokenColor outaction   = CreateColor("OutAction", COLORINDEX.CI_DARKGRAY, COLORINDEX.CI_USERTEXT_BK, true, false);
            TokenColor inaction    = CreateColor("InAction", COLORINDEX.CI_BLACK, COLORINDEX.CI_USERTEXT_BK);
            TokenColor method      = CreateColor("Method", COLORINDEX.CI_MAGENTA, COLORINDEX.CI_USERTEXT_BK);
            TokenColor fullclass   = CreateColor("FullClass", COLORINDEX.CI_MAROON, COLORINDEX.CI_USERTEXT_BK);
            TokenColor stringColor = CreateColor("String", COLORINDEX.CI_MAROON, COLORINDEX.CI_USERTEXT_BK);
            TokenColor fatParens   = CreateColor("FatParens", COLORINDEX.CI_BLACK, COLORINDEX.CI_USERTEXT_BK, true, false);

            //
            // map tokens to color classes
            //
            ColorToken((int)Tokens.LCASEIDENT, TokenType.Keyword, inaction, TokenTriggers.None);
            ColorToken((int)Tokens.OUTACTION, TokenType.Keyword, outaction, TokenTriggers.None);
            ColorToken((int)Tokens.PROC, TokenType.Keyword, proc, TokenTriggers.None);
            ColorToken((int)Tokens.NUMBER, TokenType.Literal, TokenColor.String, TokenTriggers.None);
            ColorToken((int)Tokens.KWUSE, TokenType.Keyword, TokenColor.Keyword, TokenTriggers.None);
            ColorToken((int)Tokens.KWIF, TokenType.Keyword, TokenColor.Keyword, TokenTriggers.None);
            ColorToken((int)Tokens.KWELSE, TokenType.Keyword, TokenColor.Keyword, TokenTriggers.None);
            ColorToken((int)Tokens.KWTHEN, TokenType.Keyword, TokenColor.Keyword, TokenTriggers.None);
            ColorToken((int)Tokens.KWAND, TokenType.Keyword, TokenColor.Keyword, TokenTriggers.None);
            ColorToken((int)Tokens.KWOR, TokenType.Keyword, TokenColor.Keyword, TokenTriggers.None);
            ColorToken((int)Tokens.KWXOR, TokenType.Keyword, TokenColor.Keyword, TokenTriggers.None);
            ColorToken((int)Tokens.KWTRUE, TokenType.Keyword, TokenColor.Keyword, TokenTriggers.None);
            ColorToken((int)Tokens.KWFALSE, TokenType.Keyword, TokenColor.Keyword, TokenTriggers.None);
            ColorToken((int)Tokens.METHOD, TokenType.Keyword, method, TokenTriggers.None);
            ColorToken((int)Tokens.FULLCLASS, TokenType.Keyword, fullclass, TokenTriggers.None);
            ColorToken((int)Tokens.STRING, TokenType.Keyword, stringColor, TokenTriggers.None);

            ColorToken((int)'(', TokenType.Delimiter, TokenColor.Text, TokenTriggers.MatchBraces);
            ColorToken((int)')', TokenType.Delimiter, TokenColor.Text, TokenTriggers.MatchBraces);
            ColorToken((int)'{', TokenType.Delimiter, fatParens, TokenTriggers.MatchBraces);
            ColorToken((int)'}', TokenType.Delimiter, fatParens, TokenTriggers.MatchBraces);
            ColorToken((int)'[', TokenType.Delimiter, fatParens, TokenTriggers.MatchBraces);
            ColorToken((int)']', TokenType.Delimiter, fatParens, TokenTriggers.MatchBraces);

            //// Extra token values internal to the scanner
            ColorToken((int)Tokens.LEX_ERROR, TokenType.Text, error, TokenTriggers.None);
            ColorToken((int)Tokens.LEX_COMMENT, TokenType.Text, TokenColor.Comment, TokenTriggers.None);
        }
Example #18
0
        public bool TryTake(TokenColor tokenType, uint count)
        {
            if (GetCount(tokenType) < count)
            {
                return(false);
            }

            _tokensInternal[tokenType] -= count;

            return(true);
        }
Example #19
0
 public virtual void SetColor(TokenColor color)
 {
     m_color = color;
     if (m_color == TokenColor.Black)
     {
         image = "tokenblack.png";
     }
     else
     {
         image = "tokenwhite.png";
     }
 }
Example #20
0
        public void SameValueDevelopmentsAreEqual(uint level, uint prestige, TokenColor discounts, uint diamondPrice, uint rubyPrice, uint emeraldPrice, uint onyxPrice, uint sapphirePrice)
        {
            //arrange
            Development d1, d2 = null;
            //act
            var price = new TokenCollection(diamondPrice, onyxPrice, sapphirePrice, emeraldPrice, rubyPrice, 0);

            d1 = new Development(level, prestige, discounts, price);
            d2 = new Development(level, prestige, discounts, price);
            //assert
            Assert.AreEqual(d1, d2);
        }
Example #21
0
        public override void Init(GrammarData grammarData)
        {
            base.Init(grammarData);
            this.Symbol = SymbolTable.Symbols.TextToSymbol(Text);

            #region comments about keyterms priority
            // Priority - determines the order in which multiple terminals try to match input for a given current char in the input.
            // For a given input char the scanner looks up the collection of terminals that may match this input symbol. It is the order
            // in this collection that is determined by Priority value - the higher the priority, the earlier the terminal gets a chance
            // to check the input.
            // Keywords found in grammar by default have lowest priority to allow other terminals (like identifiers)to check the input first.
            // Additionally, longer symbols have higher priority, so symbols like "+=" should have higher priority value than "+" symbol.
            // As a result, Scanner would first try to match "+=", longer symbol, and if it fails, it will try "+".
            // Reserved words are the opposite - they have the highest priority
            #endregion
            if (FlagIsSet(TermFlags.IsReservedWord))
            {
                base.Priority = ReservedWordsPriority + Text.Length;
            }
            else
            {
                base.Priority = LowestPriority + Text.Length;
            }
            //Setup editor info
            if (this.EditorInfo != null)
            {
                return;
            }
            TokenType tknType = TokenType.Identifier;
            if (FlagIsSet(TermFlags.IsOperator))
            {
                tknType |= TokenType.Operator;
            }
            else if (FlagIsSet(TermFlags.IsDelimiter | TermFlags.IsPunctuation))
            {
                tknType |= TokenType.Delimiter;
            }
            TokenTriggers triggers = TokenTriggers.None;
            if (this.FlagIsSet(TermFlags.IsBrace))
            {
                triggers |= TokenTriggers.MatchBraces;
            }
            if (this.FlagIsSet(TermFlags.IsMemberSelect))
            {
                triggers |= TokenTriggers.MemberSelect;
            }
            TokenColor color = TokenColor.Text;
            if (FlagIsSet(TermFlags.IsKeyword))
            {
                color = TokenColor.Keyword;
            }
            this.EditorInfo = new TokenEditorInfo(tknType, color, triggers);
        }
Example #22
0
 public override void SetColor(TokenColor color)
 {
     m_color = color;
     if (m_color == TokenColor.Black)
     {
         image = "queenblack.png";
     }
     else
     {
         image = "queenwhite.png";
     }
 }
Example #23
0
        private void createToken(TokenColor tokenColor, double width, double height, Thickness margin)
        {
            Ellipse token = new Ellipse();

            token.Fill       = getColorByTokenColor(tokenColor, true);
            token.Width      = width;
            token.Height     = height;
            token.Margin     = margin;
            token.Name       = tokenColor.ToString();
            token.MouseDown += HomeYard_MouseDown;
            mainCanvas.Children.Add(token);
        }
Example #24
0
        private void createHomeYard(TokenColor tokenColor, double width, double height, Thickness margin)
        {
            Rectangle homeYard = new Rectangle();

            homeYard.Fill       = getColorByTokenColor(tokenColor, false);
            homeYard.Width      = width;
            homeYard.Height     = height;
            homeYard.Margin     = margin;
            homeYard.Name       = tokenColor.ToString();
            homeYard.MouseDown += HomeYard_MouseDown;
            _homeYards[((int)tokenColor) - 1] = homeYard;
        }
Example #25
0
 /// <summary>
 /// change grid's status by placing a token in a specific column
 /// </summary>
 public void PlaceTokenInColumn(TokenColor playerColor, int column)
 {
     for (int y = 0; y < _rows; y++)
     {
         if (grid[y, column] == TokenColor.Blank)
         {
             grid[y, column] = playerColor;
             break;
         }
     }
     //update dropped tokens
     tokensCount++;
 }
Example #26
0
        private static Player AddOnePlayer(int playerNumber, List <string> colors, Board board) // Get name of one player and color of tokens from user
        {
            Console.Clear();
            Console.Write($"Enter name of {playerNumber} player: ");
            string name = Console.ReadLine();

            var        selectedOption      = Menu.ShowMenu("Choose color of the tokens:", colors);
            string     selectedColorString = colors[selectedOption];
            TokenColor selectedColorEnum   = Utility.ColorFromStringToEnum(selectedColorString);

            var player = GameFactory.NewPlayer(name, board, selectedColorEnum);

            return(player);
        }
 private void initHomeYards()
 {
     _homeYards = new HomeYard[homeYardSize];
     for (int i = 0; i < homeYardSize; i++)
     {
         TokenColor homeYardColor = (TokenColor)(i + 1);
         _homeYards[i] = new HomeYard(homeYardColor);
         for (int j = 0; j < HomeYard.StartingTokenCount; j++)
         {
             int id = j + (i * HomeYard.StartingTokenCount + 1);
             _homeYards[i].Push(new Token(homeYardColor, id));
         }
     }
 }
Example #28
0
 /// <summary>
 /// game is over if there are no blank spots or someone has won
 /// </summary>
 public GameStatus CheckIfGameIsOver(TokenColor color)
 {
     if (CheckForWin(color))
     {
         return(GameStatus.Win);
     }
     else if (gridIsFull())
     {
         return(GameStatus.Finished);
     }
     else
     {
         return(GameStatus.NotCompleted);
     }
 }
Example #29
0
        private Development BuildDevelopmentCard(string[] parameters)
        {
            var        level         = uint.Parse(parameters[0]);
            var        prestige      = uint.Parse(parameters[1]);
            TokenColor tokenColor    = (TokenColor)Enum.Parse(typeof(TokenColor), parameters[2], true);
            var        diamondPrice  = uint.Parse(parameters[3]);
            var        sapphirePrice = uint.Parse(parameters[4]);
            var        emeraldPrice  = uint.Parse(parameters[5]);
            var        rubyPrice     = uint.Parse(parameters[6]);
            var        onyxPrice     = uint.Parse(parameters[7]);

            var price = new TokenCollection(diamondPrice, onyxPrice, sapphirePrice, emeraldPrice, rubyPrice, 0);

            return(new Development(level, prestige, tokenColor, price));
        }
Example #30
0
        public Token(TokenColor tokenColor, int tokenID)
        {
            if (tokenColor == TokenColor.None)
            {
                throw new InvalidOperationException("A token needs a color");
            }

            if (tokenID < 1 || tokenID > HomeYard.TokenCount * LudoEngine.MaximumPlayers)
            {
                throw new InvalidOperationException("Token id can't be higher than total amount of tokens or less than 1");
            }

            TokenColor = tokenColor;
            TokenID    = tokenID;
        }
Example #31
0
        private static List <Token> CreateTokens(TokenColor color, Player player) // Create 4 tokens and routes, and make the first token in the list active.
        {
            int[] route    = GetRoute(color);
            var   tempList = new List <Token>();

            for (int i = 0; i < 4; i++) // Add tokens, first one is set to be active, rest is inactive.
            {
                tempList.Add(i == 0 ? new Token {
                    Color = color, IsActive = true, PlayerId = player.Id, Route = route
                }
                : new Token {
                    Color = color, PlayerId = player.Id, Route = route
                });
            }
            return(tempList);
        }
Example #32
0
        /// <summary>
        /// This method is used to compare initial string with regular expression patterns from 
        /// correspondence table
        /// </summary>
        /// <param name="source">Initial string to parse</param>
        /// <param name="charsMatched">This parameter is used to get the size of matched block</param>
        /// <param name="color">Color of matched block</param>
        private void MatchRegEx(string source, ref int charsMatched, ref TokenColor color)
        {
            foreach (Regex expr in patternTable)
            {
                Match m = expr.Match(source);
                if (m.Success && m.Length != 0)
                {
                    charsMatched = m.Length;
                    color = TokenColor.Keyword;
                    return;
                }
            }

            // No matches found. So we return color scheme of usual text
            charsMatched = 1;
            color = TokenColor.Text;
        }
Example #33
0
        public TokenEditor(string text, int amount, TokenColor color)
        {
            InitializeComponent();

              txtText.Text = text;
              numAmount.Value = amount;
              rbRed.Checked = color == TokenColor.Red;
              rbBlue.Checked = color == TokenColor.Blue;
              rbAzure.Checked = color == TokenColor.Azure;
              rbGreen.Checked = color == TokenColor.Green;
              rbYellow.Checked = color == TokenColor.Yellow;
              rbPurple.Checked = color == TokenColor.Purple;

              this.DialogResult = DialogResult.Cancel;

              this.btnCancel.Click += new EventHandler(btnCancel_Click);
              this.btnOk.Click += new EventHandler(btnOk_Click);

              Localize();

              this.Load += new EventHandler(TokenDialog_Load);
        }
        public override void Execute()
        {
            TokenModel token = Receiver.GetTokenByKey(Arguments.Key);
              if(token != null)
              {
            oldColor = token.Color.Value;
            token.Color.Value = Arguments.Color;

            Log(Arguments.Color);
              }
        }
 void Log(TokenColor color)
 {
     string playerName = Receiver.GetPlayerByKey(Invoker).Info.NickName;
       string commandName = Receiver.GetCommandByKey(COMMANDCODE).Data.Name;
       Receiver.Console.WriteLog(string.Concat(
     "[", playerName, "] ",
     commandName, " (", color, ")"
     ));
 }
Example #36
0
 public void SetTokenColor(string key, TokenColor color)
 {
     if(InvokeRequired)
     Invoke(new Action<string, TokenColor>(SetTokenColor), key, color);
       else
       {
     try
     {
       foreach(TokenView token in Controls.Find(key, true))
     GameViewHelper.FindParentCardView(token).SetTokenColor(key, color);
     }
     catch(Exception ex)
     {
       HandleException(ex);
     }
       }
 }
Example #37
0
 public void AddToken(string cardKey, string tokenKey, string text, int amount, TokenColor color)
 {
     AddTokenArgs args = new AddTokenArgs() { CardKey = cardKey, TokenKey = tokenKey, Amount = amount, Text = text, Color = color };
       if(InvokeRequired)
     Invoke(new Action<AddTokenArgs>(AddToken), args);
       else
       {
     try
     {
       AddToken(args);
     }
     catch(Exception ex)
     {
       HandleException(ex);
     }
       }
 }
        public ManualTokenTestFixture()
            : base()
        {
            //             0         1         2         3
              //             012345678901234567890123456789012345678
              line = string.Empty;
              offset = 0;

              expectedTokenType = TokenType.Unknown;
              expectedTokenColor = TokenColor.Text;
              expectedStartIndex = 0;
              expectedEndIndex = 0;
              state = 0;

              lexer = new BooTokenLexer();
              scanner = new BooScanner(lexer);
              token = new TokenInfo();
        }
Example #39
0
 public TokenEditorInfo(TokenType type, TokenColor color, TokenTriggers triggers)
 {
     Type = type;
       Color = color;
       Triggers = triggers;
 }
Example #40
0
 public static void ColorToken(string tokenName, TokenType type, TokenColor color, TokenTriggers trigger)
 {
     definitions[tokenName] = new TokenDefinition(type, color, trigger);
 }
 public static void ColorToken(int token, TokenType type, TokenColor color, TokenTriggers trigger)
 {
     definitions[token] = new TokenDefinition(type, color, trigger);
 }
        //set configurations
        static Configuration()
        {
            myCInfo.BlockEnd = "*/";
            myCInfo.BlockStart = "/*";
            myCInfo.LineStart = "//";
            myCInfo.UseLineComments = true;

            // default colors - currently, these need to be declared
            CreateColor("Keyword", COLORINDEX.CI_BLUE, COLORINDEX.CI_USERTEXT_BK);
            CreateColor("Comment", COLORINDEX.CI_DARKGREEN, COLORINDEX.CI_USERTEXT_BK);
            CreateColor("Identifier", COLORINDEX.CI_SYSPLAINTEXT_FG, COLORINDEX.CI_USERTEXT_BK);
            CreateColor("String", COLORINDEX.CI_RED, COLORINDEX.CI_USERTEXT_BK);
            //CreateColor("Number", COLORINDEX.CI_SYSPLAINTEXT_FG, COLORINDEX.CI_USERTEXT_BK);
            CreateColor("Number", COLORINDEX.CI_MAGENTA, COLORINDEX.CI_USERTEXT_BK);
            CreateColor("Text", COLORINDEX.CI_SYSPLAINTEXT_FG, COLORINDEX.CI_USERTEXT_BK);

            opsColor = CreateColor("Operator", COLORINDEX.CI_DARKGRAY, COLORINDEX.CI_USERTEXT_BK, false, false);
            singleQuoteColor = CreateColor("SingleQuote", COLORINDEX.CI_RED, COLORINDEX.CI_SYSTEXT_BK, true, false);
            errorColor = CreateColor("Error", COLORINDEX.CI_RED, COLORINDEX.CI_USERTEXT_BK, false, true);
            intrinColor = CreateColor("Intrinsic", COLORINDEX.CI_MAROON, COLORINDEX.CI_USERTEXT_BK, false, false);
            ppColor = CreateColor("Preprocessor", COLORINDEX.CI_BLUE, COLORINDEX.CI_USERTEXT_BK, false, false);
            structIdentColor = CreateColor("StructIdent", COLORINDEX.CI_AQUAMARINE, COLORINDEX.CI_USERTEXT_BK, false, false);

            //
            // map tokens to color classes
            //
            ColorToken((int)Tokens.NUMBER, TokenType.Text, TokenColor.Number, TokenTriggers.None);

            ColorToken((int)Tokens.STRING, TokenType.String, TokenColor.String, TokenTriggers.None);
            ColorToken((int)'"', TokenType.Operator, singleQuoteColor, TokenTriggers.None);

            ColorToken((int)Tokens.INTRINSIC, TokenType.Text, intrinColor, TokenTriggers.MethodTip);
            for (int i = (int)Tokens.PPDEFINE; i <= (int)Tokens.PPUNDEF; i++)
            {
                ColorToken(i, TokenType.Text, ppColor, TokenTriggers.None);
            }

            ColorToken((int)Tokens.STRUCTIDENTIFIER, TokenType.String, structIdentColor, TokenTriggers.None);

            ColorToken((int)Tokens.PPINCLFILE, TokenType.Text, TokenColor.String, TokenTriggers.None);
            //
            //  Our ShaderSense tokens
            // KEYWORDS
            for (int i = (int)Tokens.KWBLENDSTATE; i <= (int)Tokens.RWVIRTUAL; i++)
            {
                ColorToken(i, TokenType.Keyword, TokenColor.Keyword, TokenTriggers.None);
            }

            //characters
            ColorToken((int)'(', TokenType.Delimiter, TokenColor.Text, TokenTriggers.MatchBraces);
            ColorToken((int)')', TokenType.Delimiter, TokenColor.Text, TokenTriggers.MatchBraces);
            ColorToken((int)'{', TokenType.Delimiter, TokenColor.Text, TokenTriggers.MatchBraces);
            ColorToken((int)'}', TokenType.Delimiter, TokenColor.Text, TokenTriggers.MatchBraces);

            //
            //  Our ShaderSense tokens
            // OPERATORS
            for (int i = (int)Tokens.EQ; i <= (int)Tokens.ARROW; i++)
            {
                ColorOperatorToken(i);
            }
            //more characters and operators
            ColorOperatorToken((int)';');
            ColorOperatorToken((int)',');
            ColorOperatorToken((int)'=');
            ColorOperatorToken((int)'^');
            ColorOperatorToken((int)'+');
            ColorOperatorToken((int)'-');
            ColorOperatorToken((int)'*');
            ColorOperatorToken((int)'/');
            ColorOperatorToken((int)'!');
            ColorOperatorToken((int)':');
            ColorOperatorToken((int)'[');
            ColorOperatorToken((int)']');
            ColorOperatorToken((int)'&');
            ColorOperatorToken((int)'|');
            ColorOperatorToken((int)'.');
            ColorOperatorToken((int)'%');
            ColorOperatorToken((int)'?');

            //// Extra token values internal to the scanner
            ColorToken((int)Tokens.LEX_ERROR, TokenType.Text, errorColor, TokenTriggers.None);
            ColorToken((int)Tokens.LEX_COMMENT, TokenType.Text, TokenColor.Comment, TokenTriggers.None);
        }
 internal void UpdateToken(Context token)
 {
     this._token = token.Clone();
     this._color = ColorFromToken(this._token);
 }
 internal TokenColorInfo(Context token)
 {
     this._token = token.Clone();
     this._color = ColorFromToken(this._token);
     this._next = this;
 }
Example #45
0
 public void AddToken(string key, string text, int amount, TokenColor color)
 {
     TokenView tokenView = new TokenView();
       tokenView.Name = key;
       tokenView.ContextMenuStrip = menu;
       tokenView.TokenText = text;
       tokenView.TokenColor = color;
       tokenView.TokenAmount = amount;
       tokenView.DoubleClick += new EventHandler(tokenView_DoubleClick);
       pnlTokens.Controls.Add(tokenView);
       tokensKeys.Add(key);
 }
Example #46
0
 private static void SetColor(TokenInfo info, TokenColor color)
 {
     info.Color = color;
 }
Example #47
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            this.TokenText = txtText.Text;
              this.TokenAmount = (int)numAmount.Value;

              if(rbRed.Checked)
            this.TokenColor = TokenColor.Red;
              if(rbBlue.Checked)
            this.TokenColor = TokenColor.Blue;
              if(rbAzure.Checked)
            this.TokenColor = TokenColor.Azure;
              if(rbGreen.Checked)
            this.TokenColor = TokenColor.Green;
              if(rbPurple.Checked)
            this.TokenColor = TokenColor.Purple;
              if(rbYellow.Checked)
            this.TokenColor = TokenColor.Yellow;

              this.DialogResult = DialogResult.OK;
              this.Close();
        }
Example #48
0
 public void SetTokenColor(string key, TokenColor color)
 {
     TokenView token = (TokenView)this.Controls.Find(key, true).First();
       token.TokenColor = color;
 }
Example #49
0
 public TokenDefinition(TokenType type, TokenColor color, TokenTriggers triggers)
 {
     this.TokenType = type;
     this.TokenColor = color;
     this.TokenTriggers = triggers;
 }