card set descriptions

This commit is contained in:
Andy Janata 2013-03-26 17:19:01 -07:00
parent cc954aa0e4
commit a43e087fa2
6 changed files with 42 additions and 7 deletions

View File

@ -91,6 +91,7 @@ try {
} }
if (null != editCardSet) { if (null != editCardSet) {
String nameParam = request.getParameter("cardSetName"); String nameParam = request.getParameter("cardSetName");
String descriptionParam = request.getParameter("cardSetDescription");
String activeParam = request.getParameter("active"); String activeParam = request.getParameter("active");
String baseDeckParam = request.getParameter("baseDeck"); String baseDeckParam = request.getParameter("baseDeck");
String[] selectedBlackCardsParam = request.getParameterValues("selectedBlackCards"); String[] selectedBlackCardsParam = request.getParameterValues("selectedBlackCards");
@ -103,6 +104,7 @@ try {
} }
} else { } else {
editCardSet.setName(nameParam); editCardSet.setName(nameParam);
editCardSet.setDescription(descriptionParam);
editCardSet.setActive("on".equals(activeParam)); editCardSet.setActive("on".equals(activeParam));
editCardSet.setBaseDeck("on".equals(baseDeckParam)); editCardSet.setBaseDeck("on".equals(baseDeckParam));
List<Integer> blackCardIds = new ArrayList<Integer>(selectedBlackCardsParam.length); List<Integer> blackCardIds = new ArrayList<Integer>(selectedBlackCardsParam.length);
@ -256,6 +258,10 @@ select {
<input type="text" name="cardSetName" id="cardSetName" <input type="text" name="cardSetName" id="cardSetName"
value="<%= editCardSet != null ? editCardSet.getName() : "" %>" /> value="<%= editCardSet != null ? editCardSet.getName() : "" %>" />
<br/> <br/>
<label for="cardSetDescription">Description:</label>
<input type="text" name="cardSetDescription" id="cardSetDescription"
value="<%= editCardSet != null ? editCardSet.getDescription() : "" %>" />
<br/>
<label for="active">Active</label> <label for="active">Active</label>
<input type="checkbox" name="active" id="active" <input type="checkbox" name="active" id="active"
<%= editCardSet != null && editCardSet.isActive() ? "checked='checked'" : "" %> /> <%= editCardSet != null && editCardSet.isActive() ? "checked='checked'" : "" %> />

View File

@ -41,6 +41,8 @@ cah.CardSet.list = {};
* id CardSet's database/wire ID. * id CardSet's database/wire ID.
* @param {String} * @param {String}
* name CardSet's name. * name CardSet's name.
* @param {String}
* description CardSet's description.
* @param {Boolean} * @param {Boolean}
* baseDeck Whether this CardSet can be used as a base deck. At least one base deck must be * baseDeck Whether this CardSet can be used as a base deck. At least one base deck must be
* used per game. * used per game.
@ -51,7 +53,7 @@ cah.CardSet.list = {};
* @constructor * @constructor
* @private * @private
*/ */
cah.CardSet = function(id, name, baseDeck, blackCardCount, whiteCardCount) { cah.CardSet = function(id, name, description, baseDeck, blackCardCount, whiteCardCount) {
/** /**
* CardSet's database/wire ID. * CardSet's database/wire ID.
* *
@ -68,6 +70,14 @@ cah.CardSet = function(id, name, baseDeck, blackCardCount, whiteCardCount) {
*/ */
this.name_ = name; 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. * 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_; 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. * @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) { for ( var key in cardSets) {
var cardSetData = cardSets[key]; var cardSetData = cardSets[key];
var cardSet = new cah.CardSet(cardSetData[cah.$.CardSetData.ID], 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.BLACK_CARDS_IN_DECK],
cardSetData[cah.$.CardSetData.WHITE_CARDS_IN_DECK]); cardSetData[cah.$.CardSetData.WHITE_CARDS_IN_DECK]);
cah.CardSet.list[cardSet.getId()] = cardSet; cah.CardSet.list[cardSet.getId()] = cardSet;

View File

@ -16,8 +16,8 @@ cah.$.AjaxOperation.CHANGE_GAME_OPTIONS = "cgo";
cah.$.AjaxOperation.GET_GAME_INFO = "ggi"; cah.$.AjaxOperation.GET_GAME_INFO = "ggi";
cah.$.AjaxOperation.PLAY_CARD = "pc"; cah.$.AjaxOperation.PLAY_CARD = "pc";
cah.$.AjaxOperation.CREATE_GAME = "cg"; cah.$.AjaxOperation.CREATE_GAME = "cg";
cah.$.AjaxOperation.GAME_CHAT = "GC";
cah.$.AjaxOperation.KICK = "K"; cah.$.AjaxOperation.KICK = "K";
cah.$.AjaxOperation.GAME_CHAT = "GC";
cah.$.AjaxOperation.ADMIN_SET_VERBOSE_LOG = "svl"; cah.$.AjaxOperation.ADMIN_SET_VERBOSE_LOG = "svl";
cah.$.AjaxOperation.GET_CARDS = "gc"; cah.$.AjaxOperation.GET_CARDS = "gc";
cah.$.AjaxOperation.JOIN_GAME = "jg"; cah.$.AjaxOperation.JOIN_GAME = "jg";
@ -77,6 +77,7 @@ cah.$.CardSetData = function() {
// Dummy constructor to make Eclipse auto-complete. // Dummy constructor to make Eclipse auto-complete.
}; };
cah.$.CardSetData.prototype.dummyForAutocomplete = undefined; cah.$.CardSetData.prototype.dummyForAutocomplete = undefined;
cah.$.CardSetData.CARD_SET_DESCRIPTION = "csd";
cah.$.CardSetData.CARD_SET_NAME = "csn"; cah.$.CardSetData.CARD_SET_NAME = "csn";
cah.$.CardSetData.ID = "cid"; cah.$.CardSetData.ID = "cid";
cah.$.CardSetData.WHITE_CARDS_IN_DECK = "wcid"; cah.$.CardSetData.WHITE_CARDS_IN_DECK = "wcid";

View File

@ -93,9 +93,9 @@ cah.Game = function(id) {
/** @type {cah.CardSet} */ /** @type {cah.CardSet} */
var cardSet = cah.CardSet.list[key]; var cardSet = cah.CardSet.list[key];
var cardSetElementId = 'card_set_' + this.id_ + '_' + cardSet.getId(); 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() + (cardSet.getBlackCardCount() == 1 ? '' : 's') + ', ' + cardSet.getWhiteCardCount()
+ ' white card' + (cardSet.getWhiteCardCount() == 1 ? '' : 's'); + ' white card' + (cardSet.getWhiteCardCount() == 1 ? '' : 's') + '.';
var html = '<input type="checkbox" id="' + cardSetElementId + '" class="card_set" title="' var html = '<input type="checkbox" id="' + cardSetElementId + '" class="card_set" title="'
+ title + '" value="' + cardSet.getId() + '" name="card_set" /><label for="' + title + '" value="' + cardSet.getId() + '" name="card_set" /><label for="'
+ cardSetElementId + '" title="' + title + '" class="card_set_label">' + cardSet.getName() + cardSetElementId + '" title="' + title + '" class="card_set_label">' + cardSet.getName()

View File

@ -523,6 +523,7 @@ public class Constants {
public enum CardSetData { public enum CardSetData {
BASE_DECK("bd"), BASE_DECK("bd"),
BLACK_CARDS_IN_DECK("bcid"), BLACK_CARDS_IN_DECK("bcid"),
CARD_SET_DESCRIPTION("csd"),
CARD_SET_NAME("csn"), CARD_SET_NAME("csn"),
@DuplicationAllowed @DuplicationAllowed
ID(WhiteCardData.ID), ID(WhiteCardData.ID),

View File

@ -25,9 +25,8 @@ public class CardSet {
private int id; private int id;
private String name; private String name;
private String description;
private boolean active; private boolean active;
private boolean base_deck; private boolean base_deck;
@ManyToMany @ManyToMany
@ -85,6 +84,14 @@ public class CardSet {
this.base_deck = baseDeck; this.base_deck = baseDeck;
} }
public String getDescription() {
return description;
}
public void setDescription(final String description) {
this.description = description;
}
/** /**
* @return Client representation of this card. * @return Client representation of this card.
*/ */
@ -92,6 +99,7 @@ public class CardSet {
final Map<CardSetData, Object> cardSetData = new HashMap<CardSetData, Object>(); final Map<CardSetData, Object> cardSetData = new HashMap<CardSetData, Object>();
cardSetData.put(CardSetData.ID, getId()); cardSetData.put(CardSetData.ID, getId());
cardSetData.put(CardSetData.CARD_SET_NAME, getName()); cardSetData.put(CardSetData.CARD_SET_NAME, getName());
cardSetData.put(CardSetData.CARD_SET_DESCRIPTION, getDescription());
cardSetData.put(CardSetData.BASE_DECK, isBaseDeck()); cardSetData.put(CardSetData.BASE_DECK, isBaseDeck());
cardSetData.put(CardSetData.BLACK_CARDS_IN_DECK, getBlackCards().size()); cardSetData.put(CardSetData.BLACK_CARDS_IN_DECK, getBlackCards().size());
cardSetData.put(CardSetData.WHITE_CARDS_IN_DECK, getWhiteCards().size()); cardSetData.put(CardSetData.WHITE_CARDS_IN_DECK, getWhiteCards().size());