diff --git a/src/games/chessbase/4board-credits.html b/src/games/chessbase/4board-credits.html new file mode 100644 index 00000000..e4939648 --- /dev/null +++ b/src/games/chessbase/4board-credits.html @@ -0,0 +1,9 @@ +

Credits

+
+Inventor: tilera
+Developer: tilera
+Developer of Jocly: Michel Gutierrez
+Piece Graphic Designer:
+Michel Gutierrez
+jcfrog
+
\ No newline at end of file diff --git a/src/games/chessbase/4board-description.html b/src/games/chessbase/4board-description.html new file mode 100644 index 00000000..6c4f1596 --- /dev/null +++ b/src/games/chessbase/4board-description.html @@ -0,0 +1 @@ +

4Board Chess is a Chess Variants, where 4 Classic chess Boards stuckt together and 3 of the Kings be replaced by Fairy Pieces.

\ No newline at end of file diff --git a/src/games/chessbase/4board-model.js b/src/games/chessbase/4board-model.js new file mode 100644 index 00000000..e97a6e9f --- /dev/null +++ b/src/games/chessbase/4board-model.js @@ -0,0 +1,264 @@ +/* + * 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. + * + * Original authors: Jocly team + * + */ + + +(function() { + + var geometry = Model.Game.cbBoardGeometryGrid(16,16); + + Model.Game.cbDefine = function() { + + return { + + geometry: geometry, + + pieceTypes: { + + 0: { + name: 'pawn-w', + aspect: 'fr-pawn', + graph: this.cbInitialPawnGraph(geometry,1), + value: 1, + abbrev: '', + fenAbbrev: 'P', + epCatch: true, + epTarget: true, + initial: [{s:1,p:16},{s:1,p:17},{s:1,p:18},{s:1,p:19},{s:1,p:20},{s:1,p:21},{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}], + }, + + 1: { + name: 'pawn-b', + aspect: 'fr-pawn', + graph: this.cbInitialPawnGraph(geometry,-1), + value: 1, + abbrev: '', + fenAbbrev: 'P', + epCatch: true, + epTarget: true, + initial: [{s:-1,p:96},{s:-1,p:97},{s:-1,p:98},{s:-1,p:99},{s:-1,p:100},{s:-1,p:101},{s:-1,p:102},{s:-1,p:103},{s:-1,p:104},{s:-1,p:105},{s:-1,p:106},{s:-1,p:107},{s:-1,p:108},{s:-1,p:109},{s:-1,p:110},{s:-1,p:111}], + }, + + 2: { + name: 'pawn-w2', + aspect: 'fr-pawn', + graph: this.cbInitialPawnGraph(geometry,-1), + value: 1, + abbrev: '', + fenAbbrev: 'P', + epCatch: true, + epTarget: true, + initial: [{s:1,p:224},{s:1,p:225},{s:1,p:226},{s:1,p:227},{s:1,p:228},{s:1,p:229},{s:1,p:230},{s:1,p:231},{s:1,p:232},{s:1,p:233},{s:1,p:234},{s:1,p:235},{s:1,p:236},{s:1,p:237},{s:1,p:238},{s:1,p:239}], + }, + + 3: { + name: 'pawn-b2', + aspect: 'fr-pawn', + graph: this.cbInitialPawnGraph(geometry,1), + value: 1, + abbrev: '', + fenAbbrev: 'P', + epCatch: true, + epTarget: true, + initial: [{s:-1,p:144},{s:-1,p:145},{s:-1,p:146},{s:-1,p:147},{s:-1,p:148},{s:-1,p:149},{s:-1,p:150},{s:-1,p:151},{s:-1,p:152},{s:-1,p:153},{s:-1,p:154},{s:-1,p:155},{s:-1,p:156},{s:-1,p:157},{s:-1,p:158},{s:-1,p:159}], + }, + + 4: { + name: 'knight', + aspect: 'fr-knight', + graph: this.cbKnightGraph(geometry), + value: 2.9, + abbrev: 'N', + initial: [{s:1,p:1},{s:1,p:6},{s:1,p:9},{s:1,p:14},{s:1,p:241},{s:1,p:246},{s:1,p:249},{s:1,p:254},{s:-1,p:113},{s:-1,p:118},{s:-1,p:121},{s:-1,p:126},{s:-1,p:129},{s:-1,p:134},{s:-1,p:137},{s:-1,p:142}], + }, + + 5: { + name: 'bishop', + aspect: 'fr-bishop', + graph: this.cbBishopGraph(geometry), + value: 3.1, + abbrev: 'B', + initial: [{s:1,p:2},{s:1,p:5},{s:1,p:10},{s:1,p:13},{s:1,p:242},{s:1,p:245},{s:1,p:250},{s:1,p:253},{s:-1,p:114},{s:-1,p:117},{s:-1,p:122},{s:-1,p:125},{s:-1,p:130},{s:-1,p:133},{s:-1,p:138},{s:-1,p:141}], + }, + + 6: { + name: 'rook', + aspect: 'fr-rook', + graph: this.cbRookGraph(geometry), + value: 5, + abbrev: 'R', + initial: [{s:1,p:0},{s:1,p:7},{s:1,p:8},{s:1,p:15},{s:1,p:240},{s:1,p:247},{s:1,p:248},{s:1,p:255},{s:-1,p:112},{s:-1,p:119},{s:-1,p:120},{s:-1,p:127},{s:-1,p:128},{s:-1,p:135},{s:-1,p:136},{s:-1,p:143}], + castle: true, + }, + + 7: { + name: 'queen', + aspect: 'fr-queen', + graph: this.cbQueenGraph(geometry), + value: 9, + abbrev: 'Q', + initial: [{s:1,p:3},{s:1,p:11},{s:1,p:244},{s:1,p:252},{s:-1,p:115},{s:-1,p:123},{s:-1,p:132},{s:-1,p:140}], + }, + + 8: { + name: 'king', + aspect: 'fr-king', + isKing: true, + graph: this.cbKingGraph(geometry), + abbrev: 'K', + initial: [{s:1,p:12},{s:-1,p:124}], + }, + + 9: { + name: 'commander', + aspect: 'fr-amazon', + graph: this.cbMergeGraphs(geometry, + this.cbQueenGraph(geometry), + this.cbKnightGraph(geometry)), + value: 13, + abbrev: 'Co', + initial: [{s:1,p:4},{s:-1,p:116}], + }, + + 10: { + name: 'cardinal', + aspect: 'fr-cardinal', + graph: this.cbMergeGraphs(geometry, + this.cbBishopGraph(geometry), + this.cbKnightGraph(geometry)), + value: 6, + abbrev: 'Ca', + initial: [{s:1,p:251},{s:-1,p:139}], + }, + + 11: { + name: 'chancellor', + aspect: 'fr-marshall', + graph: this.cbMergeGraphs(geometry, + this.cbRookGraph(geometry), + this.cbKnightGraph(geometry)), + value: 9, + abbrev: 'Ch', + initial: [{s:1,p:243},{s:-1,p:131}], + castle: true, + }, + + }, + + promote: function(aGame,piece,move) { + if(piece.t==0 && geometry.R(move.t)==7) + return [4,5,6,7,9,10,11]; + else if(piece.t==1 && geometry.R(move.t)==0) + return [4,5,6,7,9,10,11]; + else if(piece.t==2 && geometry.R(move.t)==8) + return [4,5,6,7,9,10,11]; + else if(piece.t==3 && geometry.R(move.t)==15) + return [4,5,6,7,9,10,11]; + return []; + }, + + castle: { + "12/8": {k:[11,10],r:[9,10,11],n:"O-O-O"}, + "12/15": {k:[13,14],r:[14,13],n:"O-O"}, + "124/120": {k:[123,122],r:[121,122,123],n:"O-O-O"}, + "124/127": {k:[125,126],r:[126,125],n:"O-O"}, + }, + + evaluate: function(aGame,evalValues,material) { + // check lack of material to checkmate + var white=material[1].count; + var black=material[-1].count; + if(!white[0] && !white[1] && !white[4] && !white[5] && !white[6] && !white[7]) { // white king single + if(!black[2] && !black[3] && !black[6] && !black[7] && (black[4]+black[5]<2 || black[5]<2)) { + this.mFinished=true; + this.mWinner=JocGame.DRAW; + } + } + if(!black[2] && !black[3] && !black[4] && !black[5] && !black[6] && !black[7]) { // black king single + if(!white[0] && !white[1] && !white[6] && !white[7] && (white[4]+white[5]<2 || white[5]<2)) { + this.mFinished=true; + this.mWinner=JocGame.DRAW; + } + } + + // check 50 moves without capture + if(this.noCaptCount>=100) { + this.mFinished=true; + this.mWinner=JocGame.DRAW; + } + + // motivate pawns to reach the promotion line + var distPromo=aGame.cbUseTypedArrays?new Int8Array(3):[0,0,0]; + var height=geometry.height; + var pawns=material[1].byType[0],pawnsLength; + if(pawns) { + pawnsLength=pawns.length; + for(var i=0;i=-1;s-=2) { + var pieces=material[s].byType[t]; + if(pieces) + for(var i=0;iRules +

Setup

+ +

Pieces

+
+King
+Like in Classic Chess.
+
+
+Queen
+Like in Classic Chess.
+
+
+Rook
+Like in Classic Chess.
+
+
+Bishop
+Like in Classic Chess.
+
+
+Knight
+Like in Classic Chess.
+
+
+Pawn
+Like in Classic Chess.
+
+
+Commander
+Classic Queen + Classic Knight.
+
+
+Chancellor
+Classic Rook + Classic Knight.
+
+
+Cardinal
+Classic Bishop + Classic Knight
+
+
+
\ No newline at end of file diff --git a/src/games/chessbase/4board-thumb.png b/src/games/chessbase/4board-thumb.png new file mode 100644 index 00000000..264c631e Binary files /dev/null and b/src/games/chessbase/4board-thumb.png differ diff --git a/src/games/chessbase/4board-view.js b/src/games/chessbase/4board-view.js new file mode 100644 index 00000000..9e48ac88 --- /dev/null +++ b/src/games/chessbase/4board-view.js @@ -0,0 +1,100 @@ +/* + * 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. + * + * Original authors: Jocly team + * + */ + + + + + + +(function() { + + View.Game.cbDefineView = function() { + + var orthoBoardDelta = { +// notationMode: 'in', +// notationDebug: true, + }; + var orthoBoard3d = $.extend(true,{},this.cbGridBoardClassic3DMargin,orthoBoardDelta); + var orthoBoard2d = $.extend(true,{},this.cbGridBoardClassic2DNoMargin,orthoBoardDelta); + + return { + coords: { + "2d": this.cbGridBoard.coordsFn.call(this,orthoBoard2d), + "3d": this.cbGridBoard.coordsFn.call(this,orthoBoard3d), + }, + boardLayout: [ + ".#.#.#.#.#.#.#.#", + "#.#.#.#.#.#.#.#.", + ".#.#.#.#.#.#.#.#", + "#.#.#.#.#.#.#.#.", + ".#.#.#.#.#.#.#.#", + "#.#.#.#.#.#.#.#.", + ".#.#.#.#.#.#.#.#", + "#.#.#.#.#.#.#.#.", + ".#.#.#.#.#.#.#.#", + "#.#.#.#.#.#.#.#.", + ".#.#.#.#.#.#.#.#", + "#.#.#.#.#.#.#.#.", + ".#.#.#.#.#.#.#.#", + "#.#.#.#.#.#.#.#.", + ".#.#.#.#.#.#.#.#", + "#.#.#.#.#.#.#.#.", + ], + + board: { + "2d": { + draw: this.cbDrawBoardFn(orthoBoard2d), + }, + "3d": { + display: this.cbDisplayBoardFn(orthoBoard3d), + }, + }, + clicker: { + "2d": { + width: 700, + height: 700, + }, + "3d": { + scale: [0.45,0.45,0.45], + }, + }, + pieces: this.cbFairyPieceStyle({ + "default": { + "3d": { + scale: [0.3,0.3,0.3], + }, + "2d": { + width: 650, + height: 650, + }, + }, + "fr-amazon": { + "3d": { + scale: [0.3,0.3,0.3], + }, + }, + }), + }; + } + + /* Make the knight and amazon jump when leaping */ + View.Board.cbMoveMidZ = function(aGame,aMove,zFrom,zTo) { + var geometry = aGame.cbVar.geometry; + var x0 = geometry.C(aMove.f); + var x1 = geometry.C(aMove.t); + var y0 = geometry.R(aMove.f); + var y1 = geometry.R(aMove.t); + if(x1-x0==0 || y1-y0==0 || Math.abs(x1-x0)==Math.abs(y1-y0)) + return (zFrom+zTo)/2; + else + return Math.max(zFrom,zTo)+1500; + } + + +})(); \ No newline at end of file diff --git a/src/games/chessbase/index.js b/src/games/chessbase/index.js index 7669f8e0..db3d8c8d 100644 --- a/src/games/chessbase/index.js +++ b/src/games/chessbase/index.js @@ -1141,6 +1141,17 @@ exports.games = (function () { "fairy-set-view.js", "wild-tamerlane-view.js" ] + var modelScripts_4b = [ + "base-model.js", + "grid-geo-model.js", + "4board-model.js" + ] + var config_view_js_4b = [ + "base-view.js", + "grid-board-view.js", + "fairy-set-view.js", + "4board-view.js" + ] return [ { "name": "classic-chess", @@ -5272,7 +5283,129 @@ exports.games = (function () { } }, "viewScripts": config_view_js_wtamerlane - } + }, + { + "name": "4board-chess", + "modelScripts": modelScripts_4b, + "config": { + "status": true, + "model": { + "title-en": "4Board Chess", + "summary": "4 Chess Boards together.", + "rules": { + "en": "4board-rules.html" + }, + "module": "chessbase", + "plazza": "true", + "thumbnail": "knight-thumbnail.png", + "released": 1402412178, + "credits": { + "en": "4board-credits.html" + }, + "gameOptions": config_model_gameOptions, + "obsolete": false, + "js": modelScripts_4b, + "description": { + "en": "4board-description.html" + }, + "levels": config_model_levels_15 + }, + "view": { + "title-en": "Chessbase view", + "visuals": { + "600x600": [ + "res/visuals/4board-600x600-3d.jpg", + "res/visuals/4board-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/knight/knight.js", + "image|/res/fairy/knight/knight-diffusemap.jpg", + "image|/res/fairy/knight/knight-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/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/rook/rook.js", + "image|/res/fairy/rook/rook-diffusemap.jpg", + "image|/res/fairy/rook/rook-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/elephant/elephant.js", + "image|/res/fairy/elephant/elephant-diffusemap.jpg", + "image|/res/fairy/elephant/elephant-normalmap.jpg", + "smoothedfilegeo|0|/res/fairy/admiral/admiral.js", + "image|/res/fairy/admiral/admiral-diffusemap.jpg", + "image|/res/fairy/admiral/admiral-normalmap.jpg", + "smoothedfilegeo|0|/res/fairy/camel/camel.js", + "image|/res/fairy/camel/camel-diffusemap.jpg", + "image|/res/fairy/camel/camel-normalmap.jpg", + "smoothedfilegeo|0|/res/fairy/lion/lion.js", + "image|/res/fairy/lion/lion-diffusemap.jpg", + "image|/res/fairy/lion/lion-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/unicorn/unicorn.js", + "image|/res/fairy/unicorn/unicorn-diffusemap.jpg", + "image|/res/fairy/unicorn/unicorn-normalmap.jpg", + "smoothedfilegeo|0|/res/fairy/lighthouse/lighthouse.js", + "image|/res/fairy/lighthouse/lighthouse-diffusemap.jpg", + "image|/res/fairy/lighthouse/lighthouse-normalmap.jpg", + "smoothedfilegeo|0|/res/fairy/amazon/amazon.js", + "image|/res/fairy/amazon/amazon-diffusemap.jpg", + "image|/res/fairy/amazon/amazon-normalmap.jpg", + "smoothedfilegeo|0|/res/fairy/cardinal/cardinal.js", + "image|/res/fairy/cardinal/cardinal-diffusemap.jpg", + "image|/res/fairy/cardinal/cardinal-normalmap.jpg", + "smoothedfilegeo|0|/res/fairy/marshall/marshall.js", + "image|/res/fairy/marshall/marshall-diffusemap.jpg", + "image|/res/fairy/marshall/marshall-normalmap.jpg", + "smoothedfilegeo|0|/res/fairy/dragon/dragon.js", + "image|/res/fairy/dragon/dragon-diffusemap.jpg", + "image|/res/fairy/dragon/dragon-normalmap.jpg", + "smoothedfilegeo|0|/res/fairy/crowned-rook/crowned-rook.js", + "image|/res/fairy/crowned-rook/crowned-rook-diffusemap.jpg", + "image|/res/fairy/crowned-rook/crowned-rook-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_4b, + "useAutoComplete": true + } + }, + "viewScripts": config_view_js_4b + } diff --git a/src/games/chessbase/res/visuals/4board-600x600-2d.jpg b/src/games/chessbase/res/visuals/4board-600x600-2d.jpg new file mode 100644 index 00000000..7c21d8ae Binary files /dev/null and b/src/games/chessbase/res/visuals/4board-600x600-2d.jpg differ diff --git a/src/games/chessbase/res/visuals/4board-600x600-3d.jpg b/src/games/chessbase/res/visuals/4board-600x600-3d.jpg new file mode 100644 index 00000000..86eb52da Binary files /dev/null and b/src/games/chessbase/res/visuals/4board-600x600-3d.jpg differ