allow to choose between first version cards, second version cards, or all cards at once.

This commit is contained in:
Andy Janata 2012-03-17 20:17:32 -07:00
parent 0923d8f0f3
commit a1c2bbce80
5 changed files with 22 additions and 12 deletions

View File

@ -286,14 +286,12 @@ HttpSession hSession = request.getSession(true);
<option value="10" selected="selected">10</option>
</select>
<br/>
<!--
<label id="card_set_template_label" for="card_set_template">Use cards from version:</label>
<select id="card_set_template" class="card_set">
<option value="1">first</option>
<option value="2">second</option>
<option value="2" selected="selected">second</option>
<option value="3">both</option>
</select>
-->
</div>
</div>

View File

@ -1085,8 +1085,8 @@ cah.Game.prototype.updateOptionsEnabled_ = function() {
cah.Game.prototype.optionChanged_ = function(e) {
cah.Ajax.build(cah.$.AjaxOperation.CHANGE_GAME_OPTIONS).withGameId(this.id_).withScoreLimit(
$(".score_limit", this.optionsElement_).val()).withPlayerLimit(
$(".player_limit", this.optionsElement_).val()).withCardSet(0).run();
// $(".card_set", this.optionsElement_).val()).run();
$(".player_limit", this.optionsElement_).val()).withCardSet(
$(".card_set", this.optionsElement_).val()).run();
};
/**

View File

@ -48,12 +48,18 @@ public class BlackDeck {
* Create a new black card deck, loading the cards from the database and shuffling them.
*/
@SuppressWarnings("unchecked")
public BlackDeck() {
public BlackDeck(final int cardSet) {
final Session session = HibernateUtil.instance.sessionFactory.openSession();
final Transaction transaction = session.beginTransaction();
transaction.begin();
// TODO option to restrict to only stock cards or allow customs
deck = session.createQuery("from BlackCard order by random()").setReadOnly(true).list();
String query = "from BlackCard order by random()";
if (1 == cardSet) {
query = "from BlackCard where in_v1 = true order by random()";
} else if (2 == cardSet) {
query = "from BlackCard where in_v2 = true order by random()";
}
deck = session.createQuery(query).setReadOnly(true).list();
dealt = new ArrayList<BlackCard>();
discard = new ArrayList<BlackCard>();
transaction.commit();

View File

@ -121,7 +121,7 @@ public class Game {
private Timer nextRoundTimer;
private final Object nextRoundTimerLock = new Object();
private int scoreGoal = 8;
private int cardSet = 0;
private int cardSet = 2;
/**
* Create a new game.
@ -484,8 +484,8 @@ public class Game {
if (players.size() >= 3) {
// Pick a random start judge, though the "next" judge will actually go first.
judgeIndex = (int) (Math.random() * players.size());
blackDeck = new BlackDeck();
whiteDeck = new WhiteDeck();
blackDeck = new BlackDeck(cardSet);
whiteDeck = new WhiteDeck(cardSet);
startNextRound();
return true;
} else {

View File

@ -48,12 +48,18 @@ public class WhiteDeck {
* Create a new white card deck, loading the cards from the database and shuffling them.
*/
@SuppressWarnings("unchecked")
public WhiteDeck() {
public WhiteDeck(final int cardSet) {
final Session session = HibernateUtil.instance.sessionFactory.openSession();
final Transaction transaction = session.beginTransaction();
transaction.begin();
// TODO option to restrict to only stock cards or allow customs
deck = session.createQuery("from WhiteCard order by random()").setReadOnly(true).list();
String query = "from WhiteCard order by random()";
if (1 == cardSet) {
query = "from WhiteCard where in_v1 = true order by random()";
} else if (2 == cardSet) {
query = "from WhiteCard where in_v2 = true order by random()";
}
deck = session.createQuery(query).setReadOnly(true).list();
dealt = new ArrayList<WhiteCard>();
discard = new ArrayList<WhiteCard>();
transaction.commit();