diff --git a/src/games/chessbase/index.js b/src/games/chessbase/index.js index 0a2bc74..9afde63 100644 --- a/src/games/chessbase/index.js +++ b/src/games/chessbase/index.js @@ -1240,6 +1240,17 @@ exports.games = (function () { "fairy-set-view.js", "knightmate-view.js" ] + var modelScripts_koth = [ + "base-model.js", + "grid-geo-model.js", + "koth-model.js" + ] + var config_view_js_koth = [ + "base-view.js", + "grid-board-view.js", + "fairy-set-view.js", + "koth-view.js" + ] return [ { "name": "classic-chess", @@ -6500,7 +6511,129 @@ exports.games = (function () { } }, "viewScripts": config_view_js_ml - } + }, + { + "name": "koth-chess", + "modelScripts": modelScripts_koth, + "config": { + "status": true, + "model": { + "title-en": "King of the Hill", + "summary": "Go to the middle", + "rules": { + "en": "koth-rules.html" + }, + "module": "chessbase", + "plazza": "true", + "thumbnail": "koth-thumb.png", + "released": 1402412178, + "credits": { + "en": "koth-credits.html" + }, + "gameOptions": config_model_gameOptions, + "obsolete": false, + "js": modelScripts_koth, + "description": { + "en": "koth-description.html" + }, + "levels": config_model_levels_10 + }, + "view": { + "title-en": "Chessbase view", + "visuals": { + "600x600": [ + "res/visuals/koth-600x600-3d.jpg", + "res/visuals/koth-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_koth, + "useAutoComplete": true + } + }, + "viewScripts": config_view_js_koth + } diff --git a/src/games/chessbase/koth-model.js b/src/games/chessbase/koth-model.js new file mode 100644 index 0000000..4fd5afc --- /dev/null +++ b/src/games/chessbase/koth-model.js @@ -0,0 +1,188 @@ +/* + * 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(8,8); + + Model.Game.cbDefine = function() { + + return { + + geometry: geometry, + + pieceTypes: { + + 0: { + name: 'pawn-w', + aspect: 'fr-pawn', + graph: this.cbPawnGraph(geometry,1), + value: 1, + abbrev: '', + fenAbbrev: 'P', + epCatch: false, + }, + + 1: { + name: 'ipawn-w', + aspect: 'fr-pawn', + graph: this.cbInitialPawnGraph(geometry,1), + value: 1, + abbrev: '', + fenAbbrev: 'P', + initial: [{s:1,p:8},{s:1,p:9},{s:1,p:10},{s:1,p:11},{s:1,p:12},{s:1,p:13},{s:1,p:14},{s:1,p:15}], + epTarget: false, + }, + + 2: { + name: 'pawn-b', + aspect: 'fr-pawn', + graph: this.cbPawnGraph(geometry,-1), + value: 1, + abbrev: '', + fenAbbrev: 'P', + epCatch: false, + }, + + 3: { + name: 'ipawn-b', + aspect: 'fr-pawn', + graph: this.cbInitialPawnGraph(geometry,-1), + value: 1, + abbrev: '', + fenAbbrev: 'P', + initial: [{s:-1,p:48},{s:-1,p:49},{s:-1,p:50},{s:-1,p:51},{s:-1,p:52},{s:-1,p:53},{s:-1,p:54},{s:-1,p:55}], + epTarget: false, + }, + + 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:57},{s:-1,p:62}], + }, + + 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:58},{s:-1,p:61}], + }, + + 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:56},{s:-1,p:63}], + castle: true, + }, + + 7: { + name: 'queen', + aspect: 'fr-queen', + graph: this.cbQueenGraph(geometry), + value: 8, + abbrev: 'A', + initial: [{s:1,p:3},{s:-1,p:59}], + }, + + 8: { + name: 'kingw', + aspect: 'fr-king', + isKing: true, + graph: this.cbKingGraph(geometry), + abbrev: 'K', + initial: [{s:1,p:4}], + }, + + 9: { + name: 'kingb', + aspect: 'fr-king', + isKing: true, + graph: this.cbKingGraph(geometry), + abbrev: 'K', + initial: [{s:-1,p:60}], + }, + + }, + + promote: function(aGame,piece,move) { + if(piece.t==1) + return [0]; + else if(piece.t==3) + return [2]; + else if(piece.t==0 && geometry.R(move.t)==7) + return [4,5,6,7]; + else if(piece.t==2 && geometry.R(move.t)==0) + return [9,10,11,12]; + return []; + }, + + castle: { + "4/0": {k:[3,2],r:[1,2,3],n:"O-O-O"}, + "4/7": {k:[5,6],r:[6,5],n:"O-O"}, + "60/56": {k:[59,58],r:[57,58,59],n:"O-O-O"}, + "60/63": {k:[61,62],r:[62,61],n:"O-O"}, + }, + + }; + } + Model.Board.Evaluate = function(aGame,piece,move) { + if(piece.t==8 && geometry.R(move.t)==3 && geometry.C(3)) { + this.mFinished=true; + this.mWinner=1; + return; + }, + if(piece.t==8 && geometry.R(move.t)==3 && geometry.C(4)) { + this.mFinished=true; + this.mWinner=1; + return; + }, + if(piece.t==8 && geometry.R(move.t)==4 && geometry.C(3)) { + this.mFinished=true; + this.mWinner=1; + return; + }, + if(piece.t==8 && geometry.R(move.t)==4 && geometry.C(4)) { + this.mFinished=true; + this.mWinner=1; + return; + }, + if(piece.t==9 && geometry.R(move.t)==3 && geometry.C(3)) { + this.mFinished=true; + this.mWinner=1; + return; + }, + if(piece.t==9 && geometry.R(move.t)==3 && geometry.C(4)) { + this.mFinished=true; + this.mWinner=1; + return; + }, + if(piece.t==9 && geometry.R(move.t)==4 && geometry.C(3)) { + this.mFinished=true; + this.mWinner=1; + return; + }, + if(piece.t==9 && geometry.R(move.t)==4 && geometry.C(4)) { + this.mFinished=true; + this.mWinner=1; + return; + } + } + +})(); diff --git a/src/games/chessbase/koth-view.js b/src/games/chessbase/koth-view.js new file mode 100644 index 0000000..4e011f0 --- /dev/null +++ b/src/games/chessbase/koth-view.js @@ -0,0 +1,92 @@ +/* + * 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: 1500, + height: 1500, + }, + "3d": { + scale: [.75,.75,.75], + }, + }, + pieces: this.cbFairyPieceStyle({ + "default": { + "3d": { + scale: [.5,.5,.5], + }, + "2d": { + width: 1300, + height: 1300, + }, + }, + "fr-amazon": { + "3d": { + scale: [.5,.5,.6], + }, + }, + }), + }; + } + + /* 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