From a43e087fa211b3418efce024658f4aaebcf84eaa Mon Sep 17 00:00:00 2001 From: Andy Janata Date: Tue, 26 Mar 2013 17:19:01 -0700 Subject: [PATCH] card set descriptions --- WebContent/cardsets.jsp | 6 ++++++ WebContent/js/cah.cardset.js | 23 +++++++++++++++++++++-- WebContent/js/cah.constants.js | 3 ++- WebContent/js/cah.game.js | 4 ++-- src/net/socialgamer/cah/Constants.java | 1 + src/net/socialgamer/cah/db/CardSet.java | 12 ++++++++++-- 6 files changed, 42 insertions(+), 7 deletions(-) diff --git a/WebContent/cardsets.jsp b/WebContent/cardsets.jsp index a773830..b5a9492 100644 --- a/WebContent/cardsets.jsp +++ b/WebContent/cardsets.jsp @@ -91,6 +91,7 @@ try { } if (null != editCardSet) { String nameParam = request.getParameter("cardSetName"); + String descriptionParam = request.getParameter("cardSetDescription"); String activeParam = request.getParameter("active"); String baseDeckParam = request.getParameter("baseDeck"); String[] selectedBlackCardsParam = request.getParameterValues("selectedBlackCards"); @@ -103,6 +104,7 @@ try { } } else { editCardSet.setName(nameParam); + editCardSet.setDescription(descriptionParam); editCardSet.setActive("on".equals(activeParam)); editCardSet.setBaseDeck("on".equals(baseDeckParam)); List blackCardIds = new ArrayList(selectedBlackCardsParam.length); @@ -256,6 +258,10 @@ select { " />
+ + " /> +
/> diff --git a/WebContent/js/cah.cardset.js b/WebContent/js/cah.cardset.js index 06c34b4..0eb3164 100644 --- a/WebContent/js/cah.cardset.js +++ b/WebContent/js/cah.cardset.js @@ -41,6 +41,8 @@ cah.CardSet.list = {}; * id CardSet's database/wire ID. * @param {String} * name CardSet's name. + * @param {String} + * description CardSet's description. * @param {Boolean} * baseDeck Whether this CardSet can be used as a base deck. At least one base deck must be * used per game. @@ -51,7 +53,7 @@ cah.CardSet.list = {}; * @constructor * @private */ -cah.CardSet = function(id, name, baseDeck, blackCardCount, whiteCardCount) { +cah.CardSet = function(id, name, description, baseDeck, blackCardCount, whiteCardCount) { /** * CardSet's database/wire ID. * @@ -68,6 +70,14 @@ cah.CardSet = function(id, name, baseDeck, blackCardCount, whiteCardCount) { */ this.name_ = name; + /** + * CardSet's description. + * + * @type {String} + * @private + */ + this.description_ = description; + /** * Whether this CardSet can be used as a base deck. At least one base deck must be used per game. * @@ -107,6 +117,13 @@ cah.CardSet.prototype.getName = function() { return this.name_; }; +/** + * @returns {String} This CardSet's description. + */ +cah.CardSet.prototype.getDescription = function() { + return this.description_; +}; + /** * @returns {Boolean} Whether this CardSet can be used as the base deck in a game. */ @@ -139,7 +156,9 @@ cah.CardSet.populateCardSets = function(cardSets) { for ( var key in cardSets) { var cardSetData = cardSets[key]; var cardSet = new cah.CardSet(cardSetData[cah.$.CardSetData.ID], - cardSetData[cah.$.CardSetData.CARD_SET_NAME], cardSetData[cah.$.CardSetData.BASE_DECK], + cardSetData[cah.$.CardSetData.CARD_SET_NAME], + cardSetData[cah.$.CardSetData.CARD_SET_DESCRIPTION], + cardSetData[cah.$.CardSetData.BASE_DECK], cardSetData[cah.$.CardSetData.BLACK_CARDS_IN_DECK], cardSetData[cah.$.CardSetData.WHITE_CARDS_IN_DECK]); cah.CardSet.list[cardSet.getId()] = cardSet; diff --git a/WebContent/js/cah.constants.js b/WebContent/js/cah.constants.js index 4bbf46a..670aab8 100644 --- a/WebContent/js/cah.constants.js +++ b/WebContent/js/cah.constants.js @@ -16,8 +16,8 @@ cah.$.AjaxOperation.CHANGE_GAME_OPTIONS = "cgo"; cah.$.AjaxOperation.GET_GAME_INFO = "ggi"; cah.$.AjaxOperation.PLAY_CARD = "pc"; cah.$.AjaxOperation.CREATE_GAME = "cg"; -cah.$.AjaxOperation.GAME_CHAT = "GC"; cah.$.AjaxOperation.KICK = "K"; +cah.$.AjaxOperation.GAME_CHAT = "GC"; cah.$.AjaxOperation.ADMIN_SET_VERBOSE_LOG = "svl"; cah.$.AjaxOperation.GET_CARDS = "gc"; cah.$.AjaxOperation.JOIN_GAME = "jg"; @@ -77,6 +77,7 @@ cah.$.CardSetData = function() { // Dummy constructor to make Eclipse auto-complete. }; cah.$.CardSetData.prototype.dummyForAutocomplete = undefined; +cah.$.CardSetData.CARD_SET_DESCRIPTION = "csd"; cah.$.CardSetData.CARD_SET_NAME = "csn"; cah.$.CardSetData.ID = "cid"; cah.$.CardSetData.WHITE_CARDS_IN_DECK = "wcid"; diff --git a/WebContent/js/cah.game.js b/WebContent/js/cah.game.js index 0041a39..d434234 100644 --- a/WebContent/js/cah.game.js +++ b/WebContent/js/cah.game.js @@ -93,9 +93,9 @@ cah.Game = function(id) { /** @type {cah.CardSet} */ var cardSet = cah.CardSet.list[key]; var cardSetElementId = 'card_set_' + this.id_ + '_' + cardSet.getId(); - var title = cardSet.getBlackCardCount() + ' black card' + var title = cardSet.getDescription() + ' ' + cardSet.getBlackCardCount() + ' black card' + (cardSet.getBlackCardCount() == 1 ? '' : 's') + ', ' + cardSet.getWhiteCardCount() - + ' white card' + (cardSet.getWhiteCardCount() == 1 ? '' : 's'); + + ' white card' + (cardSet.getWhiteCardCount() == 1 ? '' : 's') + '.'; var html = '