Example #1
0
        public static GameParams GetGameParameters(int indx)
        {
            if (indx < 0)
            {
                return(null);
            }
            GameParams   gameParams = new GameParams();
            string       gameid     = GetGameRow(indx, 0);
            const string pattern    = @"^\[([^[]*)\]\s*=((X)?([0-9]*)?[xX*]([0-9]*))?\s*([#]([0-9]*))?\s*;(.*)?\s*$";
            //	1 name
            //	2 diagonal
            //	3 x
            //	4 y
            //	5 level
            //	6 comment
            Match m = Regex.Match(gameid, pattern, RegexOptions.IgnoreCase);

            //if(!m.Success)
            //	return null;
            gameParams.name    = m.Groups[1].Value;             //	Extract "[...]" from string
            gameParams.diag    = (string.IsNullOrWhiteSpace(m.Groups[3].Value)?(int)GameType.NODIAGGAME:(int)GameType.DIAGGAME);
            gameParams.tx      = m.Groups[4].Value;             //	Extract "=X*y" from string
            gameParams.ty      = m.Groups[5].Value;             //	Extract "=n*Y" from string
            gameParams.tlevel  = m.Groups[7].Value;             //	Extract "=N" from string
            gameParams.comment = m.Groups[8].Value;             //	Extract "; XXXX" from string
            return(gameParams);
        }
Example #2
0
        public static GameParams GetGameID(string gameid)
        {
            GameParams   gameParams = new GameParams();
            const string pattern    = @"^\[([^[]*)\]\s*(=((X)?([0-9]*)?[xX*]([0-9]*)))?\s*([#]([0-9]*))?\s*(;\s*(.*))?\s*$";
            //	1 name
            //		2 =dx*y
            //		3 dx*y
            //	4 diagonal
            //	5 x
            //	6 y
            //		7 #n
            //	8 level
            //		9 ;comment
            // 10 comment
            Match m = Regex.Match(gameid, pattern, RegexOptions.IgnoreCase);

            gameParams.pIdline  = gameid;
            gameParams.pName    = m.Groups[1].Value;                                                    //	Extract "[...]" from string
            gameParams.pDiag    = (string.IsNullOrWhiteSpace(m.Groups[4].Value)?(int)GameType.NODIAGGAME:(int)GameType.DIAGGAME);
            gameParams.ptX      = (string.IsNullOrWhiteSpace(m.Groups[5].Value)?"3":m.Groups[5].Value); //	Extract "=X*y" from string
            gameParams.ptY      = (string.IsNullOrWhiteSpace(m.Groups[6].Value)?"3":m.Groups[6].Value); //	Extract "=n*Y" from string
            gameParams.tlevel   = (string.IsNullOrWhiteSpace(m.Groups[8].Value)?"1":m.Groups[8].Value); //	Extract "=N" from string
            gameParams.pComment = m.Groups[10].Value;                                                   //	Extract "; XXXX" from string
            return(gameParams);
        }
Example #3
0
        private void comboGameName_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboGameName.SelectedIndex < 0)
            {
                return;
            }
            int gameIndex = GameFile.GetGameIndexFull((string)comboGameName.Items[comboGameName.SelectedIndex]);

            if (gameIndex < 0)
            {
                return;
            }
            GameParams pars = GameFile.GetGameParameters(gameIndex);

            if (pars == null)
            {
                return;
            }
            textGameName.Text    = pars.pName;
            comboGameType.Text   = string.Format("={0}{1}*{2}\t({3}*{3})", (pars.pDiag != 0)?"X":"", pars.pX, pars.pY, pars.pSize);
            numericLevel.Value   = pars.pLevel;
            textGameComment.Text = pars.pComment;
            if ((actGameDef.gxCells != pars.pX) || (actGameDef.gyCells != pars.pY) || (actGameDef.gxCross != pars.pDiag))
            {
                actGameDef = new GameDef(pars.pX, pars.pY, pars.pDiag, comboGameType.Text);
                gameTable.InitTable(pars.pX, pars.pY, pars.pDiag);
            }
            for (int yy = 0; yy < pars.pSize; yy++)
            {
                string rowLine = GameFile.GetGameRow(gameIndex, yy);
                gameTable.FillTableRow(yy, ((rowLine.Length > 0) && (rowLine[0] != '*'))?rowLine:"");
            }
            int nErr = gameTable.CheckTable(true);

            pictureTable_Resize(null, null);
            //int errnum=gameTable.CheckTable(true);
        }
Example #4
0
        static public string SetGameIdLine(GameParams par)
        {
            string line = string.Format("[{0}]\t={1}{2}x{3}\t ({4}x{4})\t#{5}\t; {6}", par.pName, par.ptX, par.ptY, par.pSize, par.pLevel, par.pComment);

            return(line);
        }
Example #5
0
 static public GameParams SetGameId(GameParams par)
 {
     par.pIdline = SetGameIdLine(par);
     return(par);
 }