Merge branch 'mi-g-master'

This commit is contained in:
Timo Ley 2020-07-18 16:39:46 +02:00
commit beb3e37348
10 changed files with 92 additions and 93 deletions

View File

@ -9,13 +9,13 @@ Demos
[Controlled interface](https://mi-g.github.io/jocly/examples/browser/control.html) for playing Chess.
Click _**Other Jocly games**_ to switch to other games.
Simple human vs computer: [Classic chess](https://mi-g.github.com/jocly/examples/browser/simple.html?classic-chess),
[Circular chess](https://mi-g.github.com/jocly/examples/browser/simple.html?circular-chess),
[Multi layers chess](https://mi-g.github.com/jocly/examples/browser/simple.html?raumschach),
[Hexagonal chess](https://mi-g.github.com/jocly/examples/browser/simple.html?glinski-chess),
[Chinese chess](https://mi-g.github.com/jocly/examples/browser/simple.html?xiangqi),
[Middle-age chess](https://mi-g.github.com/jocly/examples/browser/simple.html?courier-chess),
[Scrum](https://mi-g.github.com/jocly/examples/browser/simple.html?scrum)
Simple human vs computer: [Classic chess](https://mi-g.github.com/jocly/examples/browser/simple.html?game=classic-chess),
[Circular chess](https://mi-g.github.com/jocly/examples/browser/simple.html?game=circular-chess),
[Multi layers chess](https://mi-g.github.com/jocly/examples/browser/simple.html?game=raumschach),
[Hexagonal chess](https://mi-g.github.com/jocly/examples/browser/simple.html?game=glinski-chess),
[Chinese chess](https://mi-g.github.com/jocly/examples/browser/simple.html?game=xiangqi),
[Middle-age chess](https://mi-g.github.com/jocly/examples/browser/simple.html?game=courier-chess),
[Scrum](https://mi-g.github.com/jocly/examples/browser/simple.html?game=scrum)
Or see and try [all available games](https://mi-g.github.com/jocly/examples/browser/multiple.html)
@ -62,7 +62,7 @@ Building
Notes:
- using `gulp build watch` instead of `gulp build` makes *gulp* start watching files after the build. Whenever a file is changed, a build is automatically generated
- you can use `--no-default-games` to prevent including the game modules from directory, and `--modules <colon-separated-directories>` to specify additional game modules to include. For instance, `gulp --no-default-games --modules src/games/chessbase:src/games/checkers build` will only generate distribution for Chess and checkers games
- you can specify the games to be built in the distribution with the `--games` option. For instance, `gulp --no-default-games --modules src/games --games xiangqi:classic-chess build` only generates Jocly for Classic Chess and XiangQi
- you can specify the games to be built in the distribution with the `--games` option. For instance, `gulp --no-default-games --modules src/games/chessbase --games xiangqi:classic-chess build` only generates Jocly for Classic Chess and XiangQi
- using the `no-obsolete` option filters out the games marked as obsolete
API Documentation

View File

@ -144,9 +144,9 @@
return [0];
else if(piece.t==3)
return [2];
else if(piece.t==0 && geometry.R(move.t)==7)
else if(piece.t==0 && (move.t in promo[1]))
return [4,5,6,7];
else if(piece.t==2 && geometry.R(move.t)==0)
else if(piece.t==2 && (move.t in promo[-1]))
return [4,5,6,7];
return [];
},
@ -226,4 +226,4 @@
};
}
})();
})();

View File

@ -110,7 +110,7 @@
castle: {
"0/3": {k:[1,2],r:[2,1],n:"O-O"},
"28/31": {k:[30,29],r:[29,30],n:"O-O"},
"28/31": {k:[29,30],r:[30,29],n:"O-O"},
},
evaluate: function(aGame,evalValues,material) {
@ -184,4 +184,4 @@
};
}
})();
})();

View File

@ -148,9 +148,9 @@
return [0];
else if(piece.t==3)
return [2];
else if(piece.t==0 && geometry.R(move.t)==7)
else if(piece.t==0 && (move.t in promo[1]))
return [4,5,6,7];
else if(piece.t==2 && geometry.R(move.t)==0)
else if(piece.t==2 && (move.t in promo[-1]))
return [4,5,6,7];
return [];
},
@ -230,4 +230,4 @@
};
}
})();
})();

View File

@ -8,11 +8,11 @@
5:'a4',16:'b4',26:'c4',37:'d4',47:'e4',58:'f4',69:'g4',81:'h4',92:'i4',104:'k4',115:'l4',
6:'a5',17:'b5',27:'c5',38:'d5',48:'e5',59:'f5',70:'g5',82:'h5',93:'i5',105:'k5',116:'l5',
7:'a6',18:'b6',28:'c6',39:'d6',49:'e6',60:'f6',71:'g6',83:'h6',94:'i6',106:'k6',117:'l6',
19:'b7',29:'c7',40:'d7',50:'e7',61:'f7',72:'g7',84:'h7',95:'i7',107:'k7',
30:'c8',41:'d8',51:'e8',62:'f8',73:'g8',85:'h8',96:'i8',
42:'d9',52:'e9',63:'f9',74:'g9',86:'h9',
53:'e10',64:'f10',75:'g10',
65:'f11',
19:'b7',29:'c7',40:'d7',50:'e7',61:'f7',72:'g7',84:'h7',95:'i7',107:'k7',
30:'c8',41:'d8',51:'e8',62:'f8',73:'g8',85:'h8',96:'i8',
42:'d9',52:'e9',63:'f9',74:'g9',86:'h9',
53:'e10',64:'f10',75:'g10',
65:'f11',
};
var geometry = Model.Game.cbBoardGeometryHex([
@ -35,7 +35,7 @@
}
var promo = {
"1": { 7:1, 19:1, 30:1, 53:1, 65:1, 73:1, 86:1, 96:1, 107:1, 117:1 },
"1": { 7:1, 19:1, 30:1, 42:1, 53:1, 65:1, 75:1, 86:1, 96:1, 107:1, 117:1 },
"-1": { 2:1, 13:1, 23:1, 34:1, 44:1, 55:1, 66:1, 78:1, 89:1, 101:1, 112:1 },
}
@ -229,4 +229,4 @@
};
}
})();
})();

View File

@ -5977,7 +5977,7 @@ exports.games = (function () {
"image|/res/fairy/eagle/eagle-normalmap.jpg",
"smoothedfilegeo|0|/res/fairy/camel/camel.js",
"image|/res/fairy/camel/camel-diffusemap.jpg",
"image|/res/fairy/camel/camel-normalmap.jpg"
"image|/res/fairy/camel/camel-normalmap.jpg"
],
"world": config_view_skins_world,
"camera": config_view_skins_camera
@ -6511,7 +6511,7 @@ exports.games = (function () {
}
},
"viewScripts": config_view_js_ml
},
},
{
"name": "koth-chess",
"modelScripts": modelScripts_koth,

View File

@ -1,23 +1,23 @@
/*
* Copyright(c) 2013-2017 - jocly.com
*
* You are allowed to use and modify this source code as long as it is exclusively for use in the Jocly API.
* You are allowed to use and modify this source code as long as it is exclusively for use in the Jocly API.
*
* Original authors: Jocly team
*
*/
(function() {
var geometry = Model.Game.cbBoardGeometryGrid(12,12);
Model.Game.cbDefine = function() {
var $this = this;
/*
* Movement/capture graph for the prince
*/
@ -40,7 +40,7 @@
graph // forward direction
);
}
/*
* Movement/capture graph for the eagle
*/
@ -68,7 +68,7 @@
if(away.length>0)
graph[pos].push($this.cbTypedArray(away));
}
}
}
});
}
return $this.cbMergeGraphs(geometry,
@ -76,11 +76,11 @@
graph
);
}
return {
geometry: geometry,
pieceTypes: {
0: {
@ -92,7 +92,7 @@
fenAbbrev: 'P',
epCatch: false,
},
1: {
name: 'ipawn-w',
aspect: 'fr-pawn',
@ -104,7 +104,7 @@
epTarget: true,
epCatch: false,
},
2: {
name: 'pawn-b',
aspect: 'fr-pawn',
@ -127,7 +127,7 @@
epTarget: true,
epCatch: false,
},
4: {
name: 'knight',
aspect: 'fr-knight',
@ -136,7 +136,7 @@
abbrev: 'N',
initial: [{s:1,p:14},{s:1,p:21},{s:-1,p:122},{s:-1,p:129}],
},
5: {
name: 'bishop',
aspect: 'fr-bishop',
@ -164,7 +164,7 @@
abbrev: 'Q',
initial: [{s:1,p:18},{s:-1,p:126}],
},
8: {
name: 'king',
aspect: 'fr-king',
@ -173,7 +173,7 @@
abbrev: 'K',
initial: [{s:1,p:17},{s:-1,p:125}],
},
9: {
name: 'cannon',
aspect: 'fr-cannon2',
@ -182,7 +182,7 @@
abbrev: 'C',
initial: [{s:1,p:0},{s:1,p:11},{s:-1,p:132},{s:-1,p:143}],
},
10: {
name: 'elephant',
aspect: 'fr-elephant',
@ -190,8 +190,8 @@
value: 2.5,
abbrev: 'E',
initial: [{s:1,p:12},{s:1,p:23},{s:-1,p:120},{s:-1,p:131}],
},
},
11: {
name: 'prince-w',
aspect: 'fr-admiral',
@ -220,7 +220,7 @@
value: 2,
abbrev: 'M',
initial: [{s:1,p:1},{s:1,p:10},{s:-1,p:133},{s:-1,p:142}],
},
},
14: {
name: 'lion',
@ -233,7 +233,7 @@
value: 7.5,
abbrev: 'L',
initial: [{s:1,p:5},{s:-1,p:137}],
},
},
15: {
name: 'eagle',
aspect: 'fr-eagle',
@ -267,7 +267,7 @@
value: 14,
abbrev: 'D',
initial: [{s:1,p:4},{s:-1,p:136}],
},
},
18: {
name: 'lighthouse',
aspect: 'fr-lighthouse',
@ -306,7 +306,7 @@
abbrev: 'Co',
initial: [{s:1,p:7},{s:-1,p:139}],
},
21: {
name: 'cardinal',
aspect: 'fr-cardinal',
@ -330,7 +330,7 @@
castle: true,
},
},
promote: function(aGame,piece,move) {
if(piece.t==1 && geometry.R(move.t)==11)
return [14,15,20,16,17,18];
@ -348,7 +348,7 @@
/*
* Model.Board.GenerateMoves:
* - handle setup phase
* - handle setup phase
* - handle king special move: a kind of castle involving only the king
*/
var kingLongMoves={
@ -363,7 +363,7 @@
}
var SuperModelBoardGenerateMoves=Model.Board.GenerateMoves;
Model.Board.GenerateMoves = function(aGame) {
// first moves (white and black) are managed specifically to setup K,Q,E,L initial position
// first moves (white and black) are managed specifically to setup K,Q,E,L initial position
if(this.setupState===undefined) {
this.mMoves=[{}];
return;
@ -415,7 +415,7 @@
}
}
}
/*
* Model.Board.CopyFrom overriding to copy setupState property
*/
@ -424,9 +424,9 @@
SuperModelBoardCopyFrom.apply(this,arguments);
this.setupState = aBoard.setupState;
}
/*
* Model.Board.Evaluate overriding: in setup phase, no evaluation
* Model.Board.Evaluate overriding: in setup phase, no evaluation
*/
var SuperModelBoardEvaluate = Model.Board.Evaluate;
Model.Board.Evaluate = function(aGame) {
@ -434,7 +434,7 @@
return;
SuperModelBoardEvaluate.apply(this,arguments);
}
/*
* Model.Board.ApplyMove overriding: setup phase and king special move
*/
@ -502,7 +502,7 @@
this.board[remaining[-1][queen]]=indexes[-1].Q;
piece = this.pieces[indexes[-1].Q];
piece.p=remaining[-1][queen];
$this.zSign=aGame.zobrist.update($this.zSign,"board",piece.t,remaining[-1][queen]);
$this.zSign=aGame.zobrist.update($this.zSign,"board",piece.t,remaining[-1][queen]);
remaining[-1].splice(queen,1);
var eagle,lion;
setup%=2;
@ -511,7 +511,7 @@
lion=1;
} else {
eagle=1;
lion=0;
lion=0;
}
this.board[remaining[1][eagle]]=indexes[1].E;
piece = this.pieces[indexes[1].E];
@ -529,8 +529,8 @@
this.board[remaining[-1][lion]]=indexes[-1].L;
piece = this.pieces[indexes[-1].L];
piece.p=remaining[-1][lion];
$this.zSign=aGame.zobrist.update($this.zSign,"board",piece.t,remaining[1][lion]);
$this.zSign=aGame.zobrist.update($this.zSign,"board",piece.t,remaining[1][lion]);
this.setupState="done";
} else
SuperModelBoardApplyMove.apply(this,arguments);
@ -549,11 +549,11 @@
}
return SuperModelMoveToString.apply(this,arguments);
}
/*
* Model.Board.CompactMoveString overriding to help reading PJN game transcripts
*/
var SuperModelBoardCompactMoveString = Model.Board.CompactMoveString;
var SuperModelBoardCompactMoveString = Model.Board.CompactMoveString;
Model.Board.CompactMoveString = function(aGame,aMove,allMoves) {
if(typeof aMove.ToString!="function") // ensure proper move object, if necessary
aMove=aGame.CreateMove(aMove);
@ -570,5 +570,5 @@
return [aGame.CreateMove({setup:Math.floor(Math.random()*12)})];
return null;
}
})();

View File

@ -1,26 +1,26 @@
/*
* Copyright(c) 2013-2017 - jocly.com
*
* You are allowed to use and modify this source code as long as it is exclusively for use in the Jocly API.
* You are allowed to use and modify this source code as long as it is exclusively for use in the Jocly API.
*
* Original authors: Jocly team
*
*/
(function() {
View.Game.cbDefineView = function() {
var metamachyBoardDelta = {
//notationMode: 'in',
//notationDebug: true,
};
};
var metamachyBoard3d = $.extend(true,{},this.cbGridBoardClassic3DMargin,metamachyBoardDelta);
var metamachyBoard2d = $.extend(true,{},this.cbGridBoardClassic2DNoMargin,metamachyBoardDelta);
return {
coords: {
"2d": this.cbGridBoard.coordsFn.call(this,metamachyBoard2d),
@ -42,10 +42,10 @@
],
board: {
"2d": {
draw: this.cbDrawBoardFn(metamachyBoard2d),
draw: this.cbDrawBoardFn(metamachyBoard2d),
},
"3d": {
display: this.cbDisplayBoardFn(metamachyBoard3d),
display: this.cbDisplayBoardFn(metamachyBoard3d),
},
},
clicker: {
@ -71,8 +71,8 @@
};
}
/*
* Make the knight & the camel jump when moving, the elephant & the lion when moving 2 squares, the cannon when capturing
/*
* Make the knight & the camel jump when moving, the elephant & the lion when moving 2 squares, the cannon when capturing
*/
View.Board.cbMoveMidZ = function(aGame,aMove,zFrom,zTo) {
if(aMove.a=='N' || aMove.a=='M' || (aMove.a=='E' && aGame.g.distGraph[aMove.f][aMove.t]==2) || (aMove.a=='L' && aGame.g.distGraph[aMove.f][aMove.t]==2) || (aMove.a=='K' && aGame.g.distGraph[aMove.f][aMove.t]==2) || (aMove.a=='C' && aMove.c!=null))
@ -82,7 +82,7 @@
}
/*
* View.Game.xdInit overriding to create initial setup gadgets
* View.Game.xdInit overriding to create initial setup gadgets
*/
var SuperViewGameXdInit = View.Game.xdInit;
View.Game.xdInit = function(xdv) {
@ -145,11 +145,11 @@
});
}
},
});
});
})(setup);
}
}
/*
* View.Board.xdInput overriding to handle setup phase
*/
@ -165,7 +165,7 @@
initial: {
setupDone: false,
},
getActions: function(moves,currentInput) {
getActions: function(moves,currentInput) {
var actions={};
if(!currentInput.setupDone) {
moves.forEach(function(move) {
@ -184,7 +184,7 @@
} else
return SuperViewBoardxdInput.apply(this,arguments);
}
/*
* View.Board.cbAnimate overriding to prevent animation on setup
*/
@ -195,7 +195,7 @@
else
SuperViewBoardcbAnimate.apply(this,arguments);
}
/*
* View.Board.xdDisplay overriding to prevent displaying KQEL before setup
*/
@ -211,10 +211,9 @@
});
SuperViewBoardxdDisplay.apply(this,arguments);
for(var pos in hidden)
this.pieces[hidden[pos]].p=parseInt(pos);
this.pieces[hidden[pos]].p=parseInt(pos);
} else
SuperViewBoardxdDisplay.apply(this,arguments);
}
})();
})();

View File

@ -111,8 +111,8 @@
},
castle: {
"2/0": {k:[1],r:[1],n:"O-O"},
"22/20": {k:[21],r:[21],n:"O-O"},
"2/0": {k:[1],r:[1,2],n:"O-O"},
"22/20": {k:[21],r:[21,22],n:"O-O"},
},
evaluate: function(aGame,evalValues,material) {
@ -186,4 +186,4 @@
};
}
})();
})();

View File

@ -8,11 +8,11 @@
5:'a4',16:'b4',26:'c4',37:'d4',47:'e4',58:'f4',69:'g4',81:'h4',92:'i4',104:'k4',115:'l4',
6:'a5',17:'b5',27:'c5',38:'d5',48:'e5',59:'f5',70:'g5',82:'h5',93:'i5',105:'k5',116:'l5',
7:'a6',18:'b6',28:'c6',39:'d6',49:'e6',60:'f6',71:'g6',83:'h6',94:'i6',106:'k6',117:'l6',
19:'b7',29:'c7',40:'d7',50:'e7',61:'f7',72:'g7',84:'h7',95:'i7',107:'k7',
30:'c8',41:'d8',51:'e8',62:'f8',73:'g8',85:'h8',96:'i8',
42:'d9',52:'e9',63:'f9',74:'g9',86:'h9',
53:'e10',64:'f10',75:'g10',
65:'f11',
19:'b7',29:'c7',40:'d7',50:'e7',61:'f7',72:'g7',84:'h7',95:'i7',107:'k7',
30:'c8',41:'d8',51:'e8',62:'f8',73:'g8',85:'h8',96:'i8',
42:'d9',52:'e9',63:'f9',74:'g9',86:'h9',
53:'e10',64:'f10',75:'g10',
65:'f11',
};
var geometry = Model.Game.cbBoardGeometryHex([
@ -30,7 +30,7 @@
],posNames);
var promo = {
"1": { 7:1, 19:1, 30:1, 53:1, 65:1, 73:1, 86:1, 96:1, 107:1, 117:1 },
"1": { 7:1, 19:1, 30:1, 42:1, 53:1, 65:1, 75:1, 86:1, 96:1, 107:1, 117:1 },
"-1": { 2:1, 13:1, 23:1, 34:1, 44:1, 55:1, 66:1, 78:1, 89:1, 101:1, 112:1 },
}
@ -226,4 +226,4 @@
};
}
})();
})();