wild tamerlane files first commit

This commit is contained in:
jcfrog 2017-06-19 18:09:53 +02:00
parent 676c3a8a56
commit 832ee5991c
6 changed files with 569 additions and 0 deletions

View file

@ -1119,6 +1119,17 @@ exports.games = (function () {
"fairy-set-view.js",
"gigachess-view.js"
]
var modelScripts_wtamerlane = [
"base-model.js",
"grid-geo-model.js",
"wild-tamerlane-model.js"
]
var config_view_js_wtamerlane = [
"base-view.js",
"grid-board-view.js",
"fairy-set-view.js",
"wild-tamerlane-view.js"
]
return [
{
"name": "classic-chess",
@ -5033,6 +5044,102 @@ exports.games = (function () {
}
},
"viewScripts": config_view_js_giga
},
{
"name": "wild-tamerlane-chess",
"modelScripts": modelScripts_wtamerlane,
"config": {
"status": true,
"model": {
"title-en": "Wild Tamerlane",
"summary": "Chess on 11x11 with fairy pieces",
"rules": {
"en": "wild-tamerlane-rules.html"
},
"module": "chessbase",
"plazza": "true",
"thumbnail": "wild-tamerlane-thumb.png",
"released": 1497874349,
"credits": {
"en": "wild-tamerlane-credits.html"
},
"gameOptions": config_model_gameOptions,
"obsolete": false,
"js": modelScripts_wtamerlane,
"description": {
"en": "wild-tamerlane-description.html"
},
"levels": config_model_levels_15
},
"view": {
"title-en": "Wild Tamerlane view",
"visuals": {
"600x600": [
"res/visuals/wild-tamerlane-600x600-3d.jpg",
"res/visuals/wild-tamerlane-600x600-2d.jpg"
]
},
"xdView": true,
"css": config_view_css,
"preferredRatio": 1,
"useShowMoves": true,
"useNotation": true,
"module": "chessbase",
"defaultOptions": config_view_defaultOptions,
"skins": [
{
"name": "skin3d",
"title": "3D Classic",
"3d": true,
"preload": [
"smoothedfilegeo|0|/res/ring-target.js",
"image|/res/images/cancel.png",
"image|/res/images/wikipedia.png",
"smoothedfilegeo|0|/res/fairy/pawn/pawn.js",
"image|/res/fairy/pawn/pawn-diffusemap.jpg",
"image|/res/fairy/pawn/pawn-normalmap.jpg",
"smoothedfilegeo|0|/res/fairy/rook/rook.js",
"image|/res/fairy/rook/rook-diffusemap.jpg",
"image|/res/fairy/rook/rook-normalmap.jpg",
"smoothedfilegeo|0|/res/fairy/bishop/bishop.js",
"image|/res/fairy/bishop/bishop-diffusemap.jpg",
"image|/res/fairy/bishop/bishop-normalmap.jpg",
"smoothedfilegeo|0|/res/fairy/knight/knight.js",
"image|/res/fairy/knight/knight-diffusemap.jpg",
"image|/res/fairy/knight/knight-normalmap.jpg",
"smoothedfilegeo|0|/res/fairy/queen/queen.js",
"image|/res/fairy/queen/queen-diffusemap.jpg",
"image|/res/fairy/queen/queen-normalmap.jpg",
"smoothedfilegeo|0|/res/fairy/king/king.js",
"image|/res/fairy/king/king-diffusemap.jpg",
"image|/res/fairy/king/king-normalmap.jpg",
"smoothedfilegeo|0|/res/fairy/elephant/elephant.js",
"image|/res/fairy/elephant/elephant-diffusemap.jpg",
"image|/res/fairy/elephant/elephant-normalmap.jpg",
"smoothedfilegeo|0|/res/fairy/cannon2/cannon2.js",
"image|/res/fairy/cannon2/cannon2-diffusemap.jpg",
"image|/res/fairy/cannon2/cannon2-normalmap.jpg",
"smoothedfilegeo|0|/res/fairy/eagle/eagle.js",
"image|/res/fairy/eagle/eagle-diffusemap.jpg",
"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"
],
"world": config_view_skins_world,
"camera": config_view_skins_camera
},
config_view_skins_9
],
"animateSelfMoves": false,
"switchable": true,
"sounds": config_view_sounds,
"js": config_view_js_wtamerlane,
"useAutoComplete": true
}
},
"viewScripts": config_view_js_wtamerlane
}
]
})()

View file

@ -0,0 +1,6 @@
<h3>Jocly implementation</h3>
<ul>
<li>Development: Jérôme Choain (@<a target="_blank" href="http://twitter.com/jcfrog">jcfrog</a>)</li>
<li>Graphic design: Jérôme Choain (@<a target="_blank" href="http://twitter.com/jcfrog">jcfrog</a>)</li>
<li>Rules and descriptions: <a target="_blank" href="http://history.chess.free.fr/terachess.htm">Jean-Louis Cazaux</a> and Jérôme Choain (@<a target="_blank" href="http://twitter.com/jcfrog">jcfrog</a>)</li>
</ul>

View file

@ -0,0 +1,233 @@
/*
* Copyright(c) 2013-2014 - jocly.com
*
* 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 firstRow=0;
var lastRow=10;
var firstCol=0;
var lastCol=10;
var geometry = Model.Game.cbBoardGeometryGrid(11,11);
// graphs
Model.Game.cbEagleGraph = function(geometry){
var $this=this;
var flags = $this.cbConstants.FLAG_MOVE | $this.cbConstants.FLAG_CAPTURE;
var graph={};
for(var pos=0;pos<geometry.boardSize;pos++) {
graph[pos]=[];
[[-1,-1],[-1,1],[1,-1],[1,1]].forEach(function(delta) { // loop on all 4 diagonals
var pos1=geometry.Graph(pos,delta);
if(pos1!=null) {
for(var dir=0;dir<2;dir++) { // dir=0 for row, dir=1 for column
var nbMax = (dir==0) ? lastRow : lastCol;
var away=[] // hold the sliding line
for(var n=1;n<nbMax;n++) {
var delta2=[];
delta2[dir]=delta[dir]*n;
delta2[1-dir]=0; // delta2 is now only about moving orthogonally, away from the piece
var pos2=geometry.Graph(pos1,delta2);
if(pos2!=null) {
if(n==1) // possible to slide at least 1 cell, make sure the diagonal cell is not occupied, but cannot move to this cell
away.push(pos1 | $this.cbConstants.FLAG_STOP);
away.push(pos2 | flags);
}
}
if(away.length>0)
graph[pos].push($this.cbTypedArray(away));
}
}
});
}
return $this.cbMergeGraphs(geometry,
$this.cbShortRangeGraph(geometry,[[-1,-1],[-1,1],[1,-1],[1,1]]),
graph
);
}
var confine = {};
for(var pos=0;pos<geometry.boardSize;pos++) {
confine[pos]=1;
}
Model.Game.cbDefine = function() {
// classic chess pieces
var piecesTypes = {
0: {
name : 'ipawnw',
abbrev : '',
fenAbbrev : 'P',
aspect : 'fr-pawn',
graph : this.cbInitialPawnGraph(geometry,1,confine),
value : 0.6,
initial: [{s:1,p:22},{s:1,p:23},{s:1,p:24},{s:1,p:25},{s:1,p:26},{s:1,p:27},{s:1,p:28},{s:1,p:29},{s:1,p:30},{s:1,p:31},{s:1,p:32}],
epTarget : true,
},
1: {
name : 'ipawnb',
abbrev : '',
fenAbbrev : 'P',
aspect : 'fr-pawn',
graph : this.cbInitialPawnGraph(geometry,-1,confine),
value : 0.6,
initial: [{s:-1,p:88},{s:-1,p:89},{s:-1,p:90},{s:-1,p:91},{s:-1,p:92},{s:-1,p:93},{s:-1,p:94},{s:-1,p:95},{s:-1,p:96},{s:-1,p:97},{s:-1,p:98}],
epTarget : true,
},
2: {
name : 'pawnw',
abbrev : '',
fenAbbrev : 'P',
aspect : 'fr-pawn',
graph : this.cbPawnGraph(geometry,1,confine),
value : 0.6,
initial: [],
epCatch : true,
},
3: {
name : 'pawnb',
abbrev : '',
fenAbbrev : 'P',
aspect : 'fr-pawn',
graph : this.cbPawnGraph(geometry,-1,confine),
value : 0.6,
initial: [],
epCatch : true,
},
4: {
name : 'rook',
abbrev : 'R',
aspect : 'fr-rook',
graph : this.cbRookGraph(geometry,confine),
value : 5,
initial: [{s:1,p:11},{s:1,p:21},{s:-1,p:99},{s:-1,p:109}],
},
5: {
name : 'bishop',
abbrev : 'B',
aspect : 'fr-bishop',
graph : this.cbBishopGraph(geometry,confine),
value : 3.4,
initial: [{s:1,p:13},{s:1,p:19},{s:-1,p:101},{s:-1,p:107}],
},
6: {
name : 'knight',
abbrev : 'N',
aspect : 'fr-knight',
graph : this.cbKnightGraph(geometry,confine),
value : 2.5,
initial: [{s:1,p:12},{s:1,p:20},{s:-1,p:100},{s:-1,p:108}],
},
7: {
name : 'queen',
abbrev : 'Q',
aspect : 'fr-queen',
graph : this.cbQueenGraph(geometry,confine),
value : 8.2,
initial: [{s:1,p:15},{s:1,p:17},{s:-1,p:103},{s:-1,p:105}],
},
8: {
name : 'king',
abbrev : 'K',
aspect : 'fr-king',
graph : this.cbKingGraph(geometry,confine),
isKing : true,
initial: [{s:1,p:16},{s:-1,p:104}],
},
9: {
name : 'elephant',
abbrev : 'E',
aspect : 'fr-elephant',
graph : this.cbShortRangeGraph(geometry,[[-1,-1],[-1,1],[1,-1],[1,1],[-2,-2],[-2,2],[2,-2],[2,2]],confine),
value : 2.5,
initial: [{s:1,p:0},{s:1,p:10},{s:-1,p:110},{s:-1,p:120}],
},
10: {
name : 'cannon',
abbrev : 'C',
aspect : 'fr-cannon2',
graph : this.cbXQCannonGraph(geometry),
value : 4.9,
initial: [{s:1,p:4},{s:1,p:6},{s:-1,p:114},{s:-1,p:116}],
},
11: {
name : 'gryphon',
abbrev : 'G',
aspect : 'fr-eagle',
graph : this.cbEagleGraph(geometry),
value : 7.7,
initial: [{s:1,p:14},{s:1,p:18},{s:-1,p:102},{s:-1,p:106}],
},
12: {
name : 'camel',
abbrev : 'J',
aspect : 'fr-camel',
graph : this.cbShortRangeGraph(geometry,[[-3,-1],[-3,1],[3,-1],[3,1],[1,3],[1,-3],[-1,3],[-1,-3]]),
value : 2.2,
initial: [{s:1,p:2},{s:1,p:8},{s:-1,p:112},{s:-1,p:118}],
},
}
// defining types for readable promo cases
var T_ipawnw=0
var T_ipawnb=1
var T_pawnw=2
var T_pawnb=3
var T_rook=4
var T_bishop=5
var T_knight=6
var T_queen=7
var T_king=8
var T_elephant=9
var T_cannon=10
var T_gryphon=11
var T_camel=12
return {
geometry: geometry,
pieceTypes: piecesTypes,
promote: function(aGame,piece,move) {
// initial pawns promote to pawn
if (piece.t==T_ipawnw)
return [T_pawnw];
if (piece.t==T_ipawnb)
return [T_pawnb];
// pawns promote to Queen
if( ((piece.t==T_pawnw) && geometry.R(move.t)==lastRow) || ((piece.t==T_pawnb) && geometry.R(move.t)==firstRow))
return [T_gryphon,T_queen];
return [];
},
};
}
})();

View file

@ -0,0 +1,223 @@
/*
*
*
*
* authors: jerome choain
*
*/
(function() {
function createTexturedPatternCanvas(W,H,texture,clipW,clipH,mask,borderFact){
// borderFact is the percentage (/100) of the mask transition overlay border : ex 30% => .3
var cv = document.createElement('canvas');
cv.width=W;
cv.height=H;
var ctx=cv.getContext('2d');
var maskW=mask.width;
var maskH=mask.height;
var textW=texture.width;
var textH=texture.height;
var tmp = document.createElement('canvas');
ctx.globalCompositeOperation='or';
var y=0;
for (var i=0; y<=(H+clipH/2);i++){
var x=0;
for (var j=0; x<=(W+clipW/2);j++){
tmp.width=clipW; tmp.height=clipH;
ctxTmp=tmp.getContext('2d');
ctxTmp.globalCompositeOperation='xor';
ctxTmp.drawImage(texture, Math.random()*(textW-clipW),Math.random()*(textH-clipH),clipW,clipH,0,0,clipW,clipH);
ctxTmp.drawImage(mask,0,0,clipW,clipH);
ctx.drawImage(tmp,x-clipW/2,y-clipH/2,clipW,clipH);
x+=clipW-borderFact*clipW;
}
y+=clipH-borderFact*clipH;
}
return cv;
}
// Reducing the promo frame which was overflowing the board screen
View.Game.cbPromoSize = 1100;
// extending fairy pieces with some musketeer new pieces
View.Game.cbFairyWTamerlanePieceStyle3D = $.extend(true,{},View.Game.cbFairyPieceStyle3D,{
});
View.Game.cbDefineView = function() {
var wtamerlaneBoardDelta = {
notationMode: "out",
//notationDebug: true,
}
wtamerlaneBoardDelta3d = $.extend(true,{},wtamerlaneBoardDelta,
{
/*'colorFill' : {
".": "#575b36", // "rgba(180,213,80,.3)",
"#": "#474b36", // "black" cells
" ": "rgba(0,0,0,0)",
},*/
'colorFill' : {
"#": "rgba(204,40,0,1)",
".": "rgba(180,180,0,1)",
},
'texturesImg' : {
'crackles': '/res/images/crackles.jpg',
'tiler': '/res/images/tileralpha.png',
},
'3D':true,
'margins' : {x:.47,y:.47},
'extraChannels':[
'bump'
],
paintCell: function(spec,ctx,images,channel,cellType,xCenter,yCenter,cx,cy) {
var tW=images['crackles'].width;
var tH=images['crackles'].height;
var tClipCx=200;
var tClipCy=200;
ctx.fillStyle="#000000";
ctx.fillRect(xCenter-cx/2,yCenter-cy/2,cx,cy);
if(channel=="bump"){
return;
}
cx=.98*cx;
cy=.98*cy;
ctx.save();
ctx.strokeStyle = "rgba(0,0,0,1)";
ctx.lineWidth = 50;
if (channel=='diffuse')
ctx.fillStyle=spec.colorFill[cellType];
else
ctx.fillStyle=0xffffff;
ctx.fillRect(xCenter-cx/2,yCenter-cy/2,cx,cy);
ctx.globalCompositeOperation = 'multiply';
ctx.drawImage(images['crackles'],
Math.random()*(tW-tClipCx),Math.random()*(tH-tClipCy),tClipCx,tClipCy,
xCenter-cx/2,yCenter-cy/2,cx,cy);
ctx.restore();
},
paintBackground: function(spec,ctx,images,channel,bWidth,bHeight) {
ctx.save();
ctx.fillStyle="#ffffff";
if (channel=='diffuse')
ctx.fillStyle="#BA784A";
//ctx.fillStyle="#cc6600";
var cSize = this.cbCSize(spec);
ctx.fillRect(-bWidth/2,-bHeight/2,bWidth,bHeight);
var textureCanvas=createTexturedPatternCanvas(1200,800,images['crackles'],200,200,images['tiler'],.3);
ctx.globalCompositeOperation='multiply';
ctx.drawImage(textureCanvas,-bWidth/2,-bHeight/2,bWidth,bHeight);
ctx.restore();
},
}
);
wtamerlaneBoardDelta2d = $.extend(true,{},wtamerlaneBoardDelta,
{
'colorFill' : {
".": "#ffffc0", // "white" cells
"#": "#8F976D", // "black" cells
" ": "rgba(0,0,0,0)",
},
'texturesImg' : {}, // to avoid default wood texture
'margins' : {x:.47,y:.47},
/*'colorFill' : {
".": "rgba(224,50,0,1)",
"#": "rgba(220,220,0,1)",
},*/
}
);
var wtamerlaneBoard3d = $.extend(true,{},this.cbGridBoardClassic3DMargin,wtamerlaneBoardDelta3d);
var wtamerlaneBoard2d = $.extend(true,{},this.cbGridBoardClassic2DMargin,wtamerlaneBoardDelta2d);
return {
coords: {
"2d": this.cbGridBoard.coordsFn.call(this,wtamerlaneBoard2d),
"3d": this.cbGridBoard.coordsFn.call(this,wtamerlaneBoard3d),
},
boardLayout: [
".#.#.#.#.#.",
"#.#.#.#.#.#",
".#.#.#.#.#.",
"#.#.#.#.#.#",
".#.#.#.#.#.",
"#.#.#.#.#.#",
".#.#.#.#.#.",
"#.#.#.#.#.#",
".#.#.#.#.#.",
"#.#.#.#.#.#",
".#.#.#.#.#.",
],
board: {
"2d": {
draw: this.cbDrawBoardFn(wtamerlaneBoard2d),
},
"3d": {
display: this.cbDisplayBoardFn(wtamerlaneBoard3d),
},
},
clicker: {
"2d": {
width: 1018.1818181818,
height: 1018.1818181818,
},
"3d": {
scale: [0.65454545454545,0.65454545454545,0.65454545454545],
},
},
pieces: this.cbFairyPieceStyle({
"default": {
"2d": {
width: 945.45454545455,
height: 945.45454545455,
},
"3d": {
scale: [0.43636363636364,0.43636363636364,0.43636363636364],
display: this.cbDisplayPieceFn(this.cbFairyWTamerlanePieceStyle3D)
},
},
"fr-amazon" :{
"3d": {
scale: [0.52363636363636,0.52363636363636,0.52363636363636],
}
},
}),
};
}
/* Make the knight jump when moving */
View.Board.cbMoveMidZ = function(aGame,aMove,zFrom,zTo) {
var geo=aGame.cbVar.geometry;
var dx=Math.abs(geo.C(aMove.t)-geo.C(aMove.f));
var dy=Math.abs(geo.R(aMove.t)-geo.R(aMove.f));
if(("_N_E_J_".indexOf("_"+aMove.a+"_")>=0) && (aGame.g.distGraph[aMove.f][aMove.t]>1))
return Math.max(zFrom,zTo)+2000;
/*else if(("__".indexOf("_"+aMove.a+"_")>=0) && dx!=dy && dx!=0 && dy!=0)
return Math.max(zFrom,zTo)+2000;*/
else if(("_C_W_".indexOf("_"+aMove.a+"_")>=0) && aMove.c != null)
return Math.max(zFrom,zTo)+2000;
else
return (zFrom+zTo)/2;
}
})();