import 'dart:convert';
void main() {
MazeOptionHandler().init(x:3, y:3, mapList:map_list);
}
class MazeOptionHandler {
bool isStart = false;
int x = 0;
int y = 0;
List<MapItem> _mapList = [];
List<List<ModelItem>> _dataList = [];
init({int x,int y,List<MapItem> mapList}) {
this.x = x;
this.y = y;
this._mapList = mapList;
_createItems();
}
increment() {}
_createItems(){
int index = 1;
List<ModelItem> items = [];
for(int i = 0; i < x; i++){
List<ModelItem> rows = [];
for(int j = 0; j < y; j++){
ModelItem item = ModelItem(xy: [i+1,j+1], index: index++);
rows.add(item);
items.add(item);
}
_dataList.add(rows);
}
print(json.encode( _dataList ));
}
}
class ModelItem {
List<int> point = [0, 0, 0, 0];
List<int> xy = [0, 0];
int index = 0;
int size = 0;
bool afterLocation = false;
bool currentLocation = false;
bool isStart = false;
bool isEnd = false;
ModelItem topNode;
ModelItem leftNode;
ModelItem rightNode;
ModelItem bottomNode;
ModelItem({this.xy,
this.index,
this.leftNode,
this.rightNode,
this.topNode,
this.bottomNode});
@override
String toString(){
return {
"index": index
}.toString();
}
Map<String, dynamic> toJson() => {
"index": index,
"isStart": isStart,
"isEnd": isEnd,
"topNode":topNode.toString(),
"bottomNode":bottomNode.toString(),
"leftNode":leftNode.toString(),
"rightNode":rightNode.toString(),
};
}
enum MapType{
Left,
Right,
Top,
Bottom,
None,
Start,
End,
Road
}
class MapItem {
int fromIndex;
MapType pathType;
int toIndex;
MapType stateType;
MapItem({this.fromIndex,this.pathType,this.toIndex,this.stateType});
@override
toString(){
return {
"fromIndex": fromIndex,
"pathType": pathType,
"toIndex": toIndex,
"stateType": stateType
}.toString();
}
}