// create new initial board internal static BoardModel CreateSetup(GameModel game, BoardDef def) { return(new BoardModel { _game = game, Def = def, }.SetupPieces().GenerateNewState()); }
static BoardModel Create(GameModel game, BoardDef def) { return(new BoardModel { _game = game, Def = def, }); }
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); }
// 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); } }
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); } } } }
GameDef Init() { Board = BoardDef.Create(null); // FIX:??? SetProperty("title", TextValue.Create("Unknown")); return(this); }
// 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); } } }
internal BoardDef Exec() { _boarddef = BoardDef.Create(this); EvalExec(); return(_boarddef); }