@@ -5172,7 +5172,7 @@ glift.displays.statusbar._StatusBar.prototype = {
51725172 *
51735173 * Note: Key bindings are set in the base_widget.
51745174 */
5175- gameInfo : function ( gameInfoArr ) {
5175+ gameInfo : function ( gameInfoArr , captureCount ) {
51765176 var wrapperDivId = this . widget . wrapperDiv ,
51775177 suffix = '_gameinfo' ,
51785178 newDivId = wrapperDivId + suffix + '_wrapper' ,
@@ -5214,13 +5214,19 @@ glift.displays.statusbar._StatusBar.prototype = {
52145214 textDiv . on ( 'click' , function ( ) { newDiv . remove ( ) ; } ) ;
52155215 }
52165216
5217+ // This is a hack until a better solution for captures can be crafted.
5218+ var captureArr = [
5219+ { displayName : 'Captured White Stones' , value : captureCount . WHITE } ,
5220+ { displayName : 'Captured Black Stones' , value : captureCount . BLACK }
5221+ ] ;
5222+ gameInfoArr = captureArr . concat ( gameInfoArr ) ;
5223+
52175224 var textArray = [ ] ;
52185225 for ( var i = 0 ; i < gameInfoArr . length ; i ++ ) {
52195226 var obj = gameInfoArr [ i ] ;
52205227 textArray . push ( '<strong>' + obj . displayName + ': </strong>' + obj . value ) ;
52215228 }
52225229
5223-
52245230 textDiv
52255231 . append ( glift . dom . newElem ( 'h3' )
52265232 . appendText ( 'Game Info' )
@@ -7287,18 +7293,18 @@ Properties.prototype = {
72877293 var gameInfoArr = [ ] ;
72887294 // Probably should live in a more canonical place (properties.js).
72897295 var propNameMap = {
7290- GN : 'Game Name' ,
72917296 PW : 'White Player' ,
72927297 PB : 'Black Player' ,
72937298 RE : 'Result' ,
72947299 AN : 'Commenter' ,
72957300 SO : 'Source' ,
72967301 RU : 'Ruleset' ,
72977302 KM : 'Komi' ,
7298- PC : 'Place Name' ,
7299- DT : 'Date' ,
7303+ GN : 'Game Name' ,
73007304 EV : 'Event' ,
7301- RO : 'Round'
7305+ RO : 'Round' ,
7306+ PC : 'Place Name' ,
7307+ DT : 'Date'
73027308 } ;
73037309 for ( var key in propNameMap ) {
73047310 if ( this . contains ( key ) ) {
@@ -8092,25 +8098,41 @@ BaseController.prototype = {
80928098 this . movetree , this . goban , this . problemConditions ) ;
80938099 } ,
80948100
8095- /**
8096- * Return only the necessary information to update the board
8097- */
8101+ /** Return only the necessary information to update the board. */
80988102 // TODO(kashomon): Rename to getCurrentBoardState
80998103 getNextBoardState : function ( ) {
81008104 return glift . bridge . intersections . nextBoardData (
81018105 this . movetree , this . getCaptures ( ) , this . problemConditions ) ;
81028106 } ,
81038107
8104- /**
8105- * Get the captures that occured for the current move.
8106- */
8108+ /** Get the captures that occured for the current move. */
81078109 getCaptures : function ( ) {
81088110 if ( this . captureHistory . length === 0 ) {
81098111 return { BLACK : [ ] , WHITE : [ ] } ;
81108112 }
81118113 return this . captureHistory [ this . currentMoveNumber ( ) - 1 ] ;
81128114 } ,
81138115
8116+ /**
8117+ * Get the captures count. Returns an object of the form
8118+ * {
8119+ * BLACK: <number>
8120+ * WHITE: <number>
8121+ * }
8122+ */
8123+ // TODO(kashomon): Add tests
8124+ getCaptureCount : function ( ) {
8125+ var countObj = { BLACK : 0 , WHITE : 0 } ;
8126+ for ( var i = 0 ; i < this . captureHistory . length ; i ++ ) {
8127+ var obj = this . captureHistory [ i ] ;
8128+ console . log ( obj ) ;
8129+ for ( var color in obj ) {
8130+ countObj [ color ] += obj [ color ] . length ;
8131+ }
8132+ }
8133+ return countObj ;
8134+ } ,
8135+
81148136 /**
81158137 * Return true if a Stone can (probably) be added to the board and false
81168138 * otherwise.
@@ -10697,8 +10719,9 @@ glift.widgets.options.baseOptions = {
1069710719 * requests.
1069810720 *
1069910721 * Examples:
10700- * 'images/kaya.jpg'
10701- * 'http://www.mywebbie.com/images/kaya.jpg'
10722+ * 'images/kaya.jpg'
10723+ * 'http://www.mywebbie.com/images/kaya.jpg'
10724+ *
1070210725 * @api (1.0)
1070310726 */
1070410727 goBoardBackground : '' ,
@@ -10767,6 +10790,7 @@ glift.widgets.options.baseOptions = {
1076710790 /**
1076810791 * Actions for stones. If the user specifies his own actions, then the
1076910792 * actions specified by the user will take precedence.
10793+ * @api (1.0)
1077010794 */
1077110795 stoneActions : {
1077210796 /**
@@ -10975,7 +10999,9 @@ glift.widgets.options.baseOptions = {
1097510999 'game-info' : {
1097611000 click : function ( event , widget , icon , iconBar ) {
1097711001 widget . statusBar &&
10978- widget . statusBar . gameInfo ( widget . controller . getGameInfo ( ) ) ;
11002+ widget . statusBar . gameInfo (
11003+ widget . controller . getGameInfo ( ) ,
11004+ widget . controller . getCaptureCount ( ) ) ;
1097911005 } ,
1098011006 tooltip : 'Show the game info'
1098111007 } ,
0 commit comments