Esempio n. 1
0
 public void ExcludeValue(TekField field, int value)
 {
     PushMove(field.Row, field.Col, TekMove.tmExclude, value);
     field.ExcludeValue(value, true);
     if (field.Notes.Contains(value))
     {
         PlayNote(field, value);
     }
 }
Esempio n. 2
0
        private bool ParseMultiValues(string input, TekBoard board, MultiValues mvType)
        {
            int      row, col, value;
            TekField field = null;
            Regex    pattern1 = null, pattern2 = null;


            switch (mvType)
            {
            case MultiValues.mvNotes:
                pattern1 = notesPattern1;
                pattern2 = notesPattern2;
                break;

            case MultiValues.mvExcludes:
                pattern1 = excludesPattern1;
                pattern2 = excludesPattern2;
                break;
            }

            Match match = pattern1.Match(input);

            if (match.Success)
            {
                if (field == null && Int32.TryParse(match.Groups["row"].Value, out row) &&
                    Int32.TryParse(match.Groups["col"].Value, out col))
                {
                    if (!board.IsInRange(row, col))
                    {
                        ParseError("Invalid field in {0} line {1}: ({2},{3})", MultiValueString[(int)mvType], input, row, col);
                    }
                    field = board.Fields[row, col];
                }
                if (field != null && Int32.TryParse(match.Groups["value"].Value, out value))
                {
                    switch (mvType)
                    {
                    case MultiValues.mvNotes:
                        field.ToggleNote(value);
                        break;

                    case MultiValues.mvExcludes:
                        field.ExcludeValue(value);
                        break;
                    }
                    match = pattern2.Match(match.Groups["rest"].Value);
                    while (match.Success)
                    {
                        if (Int32.TryParse(match.Groups["value"].Value, out value))
                        {
                            switch (mvType)
                            {
                            case MultiValues.mvNotes:
                                field.ToggleNote(value);
                                break;

                            case MultiValues.mvExcludes:
                                field.ExcludeValue(value);
                                break;
                            }
                            match = match.NextMatch();
                        }
                        else
                        {
                            ParseError("Invalid value in {0} line {1}: ({2})", MultiValueString[(int)mvType], input, match.Groups["value"].Value);
                        }
                    }
                }
            }
            return(field != null);
        }