Esempio n. 1
0
 // create new initial board
 internal static BoardModel CreateSetup(GameModel game, BoardDef def)
 {
     return(new BoardModel {
         _game = game,
         Def = def,
     }.SetupPieces().GenerateNewState());
 }
Esempio n. 2
0
 static BoardModel Create(GameModel game, BoardDef def)
 {
     return(new BoardModel {
         _game = game,
         Def = def,
     });
 }
Esempio n. 3
0
 internal void Exec(BoardDef board)
 {
     // TODO: do we need to init data items?
     EvalExec();
     board.Dimensions = _names.Count;
     AddPositions("", _startrect, new List <int>(), 0, board);
     AddLinks(board);
 }
Esempio n. 4
0
 // Recursive walk to add links
 void AddLinks(BoardDef board)
 {
     for (int i = 0; i < _directions.Count; i++)
     {
         if (_diroffs[i].Count != _names.Count)
         {
             throw Error.Evaluation("grid: direction size mismatch");
         }
         AddLinks(i, "", "", 0, board);
     }
 }
Esempio n. 5
0
 void AddLinks(int dirindex, string fromname, string toname, int level, BoardDef board)
 {
     for (int i = 0; i < _names[level].Count; i++)
     {
         var j = i + _diroffs[dirindex][level];
         if (j >= 0 && j < _names[level].Count)
         {
             var fname = fromname + _names[level][i];
             var tname = toname + _names[level][j];
             if (level == _names.Count - 1)
             {
                 board.AddLink(_directions[dirindex], board.GetPosition(fname), board.GetPosition(tname));
             }
             else
             {
                 AddLinks(dirindex, fname, tname, level + 1, board);
             }
         }
     }
 }
Esempio n. 6
0
 GameDef Init()
 {
     Board = BoardDef.Create(null); // FIX:???
     SetProperty("title", TextValue.Create("Unknown"));
     return(this);
 }
Esempio n. 7
0
 // Recursive walk to add positions
 void AddPositions(string basename, Rect baserect, List <int> basecoords, int level, BoardDef board)
 {
     for (int i = 0; i < _names[level].Count; i++)
     {
         var name   = basename + _names[level][i];
         var rect   = baserect.Offset(_coords[level].Times(i));
         var coords = new List <int>(basecoords);
         coords.Add(i);
         //var coords_ = coords.AsEnumerable().Concat(new int[] { i }).ToList();
         if (level == _names.Count - 1)
         {
             board.SetPosition(board.GetPosition(name), rect, coords);
         }
         else
         {
             AddPositions(name, rect, coords, level + 1, board);
         }
     }
 }
Esempio n. 8
0
 internal BoardDef Exec()
 {
     _boarddef = BoardDef.Create(this);
     EvalExec();
     return(_boarddef);
 }