Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cardcast replacement #241

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9aa17ff
Updated gitignore for IntelliJ
devgianlu May 17, 2020
ac57455
Rewritten CardcastService.java + renamed all Cardcast stuff + changed…
devgianlu May 17, 2020
e413db0
Get watermark from JSON
devgianlu May 19, 2020
2c56cda
Do caching with url, hash and id
devgianlu May 19, 2020
8bf269c
Removed commands and added buttons in game options + fixed minor NPE
devgianlu May 21, 2020
ee35e70
Modified stream reading to not alter file + fixed content-type + mino…
devgianlu May 21, 2020
b3b5995
Compute JSON hash with bencode
devgianlu May 22, 2020
435421f
Fixed uploading multiple files
devgianlu May 22, 2020
b1a20de
Added list of custom decks + removed old chat code + minor
devgianlu May 22, 2020
e3ab0e5
Added filtering for custom deck url
devgianlu May 23, 2020
31f4b13
Merge remote-tracking branch 'remotes/ajanata/master' into cardcast-r…
devgianlu May 24, 2020
d051817
Fixed build
devgianlu May 24, 2020
fefd902
Reformatted some files
devgianlu May 25, 2020
973133c
Explicitly set Java language level to 1.8 + using diamonds
devgianlu May 25, 2020
6800a65
Show custom card sets from game list
devgianlu May 26, 2020
5810e85
Return watermark in CardSet data
devgianlu May 28, 2020
a092739
Enabled/disable custom decks + added entry in stats.jsp
devgianlu Jun 26, 2020
b53156f
Show/hide custom decks UI + hide buttons independently
devgianlu Jul 4, 2020
7c745cf
Cache JSON decks for longer
devgianlu Jul 10, 2020
576ef51
Merge branch 'master' into cardcast-replacement
devgianlu Jul 26, 2020
710ac6f
Fix game options overlapping with chat
devgianlu Jul 26, 2020
1ed8467
Custom decks enabled flag in cah.config.js too
devgianlu Aug 13, 2020
221a132
Stupid fix
devgianlu Aug 13, 2020
ca781a8
Updated log4j to log4j2
devgianlu Dec 11, 2021
a4629be
Added dependabot
devgianlu Dec 19, 2021
8e4dd77
Updated log4j
devgianlu Dec 19, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: maven
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ build.properties
target
ssl/
src/main/java/net/socialgamer/cah/util/RealShadowBannedStringProvider.java
.idea
*.iml
8 changes: 7 additions & 1 deletion WebContent/cah.css
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,20 @@ span.debug, span.admin {
.game_right_side, .game_options {
position: absolute;
left: 246px;
width: 1000px;
width: 75%;
}

.game_options {
background: #eee;
z-index: 500;
}

.custom_decks_list {
margin-top: 10px;
height: 120px;
width: 100%;
}

.game_right_side_box {
height: 60%;
margin: 10px;
Expand Down
31 changes: 26 additions & 5 deletions WebContent/game.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ RequestWrapper wrapper = new RequestWrapper(request);
ServletContext servletContext = pageContext.getServletContext();
Injector injector = (Injector) servletContext.getAttribute(StartupUtils.INJECTOR);
boolean allowBlankCards = injector.getInstance(Key.get(new TypeLiteral<Boolean>(){}, AllowBlankCards.class));
boolean customDecksEnabled = injector.getInstance(Key.get(new TypeLiteral<Boolean>(){}, CustomDecksEnabled.class));
boolean showAddCustomDeckUrl = injector.getInstance(Key.get(new TypeLiteral<Boolean>(){}, ShowAddCustomDeckUrl.class));
boolean showAddCustomDeckJson = injector.getInstance(Key.get(new TypeLiteral<Boolean>(){}, ShowAddCustomDeckJson.class));
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Expand Down Expand Up @@ -477,11 +480,29 @@ boolean allowBlankCards = injector.getInstance(Key.get(new TypeLiteral<Boolean>(
<option value="Unlimited">Unlimited</option>
</select>
<br/>
<fieldset class="card_sets">
<legend>Card Sets</legend>
<span class="base_card_sets"></span>
<span class="extra_card_sets"></span>
</fieldset>
<div style="display: flex">
<fieldset class="card_sets">
<legend>Card Sets</legend>
<span class="base_card_sets"></span>
<span class="extra_card_sets"></span>
</fieldset>
<% if (customDecksEnabled) { %>
<fieldset>
<legend>Custom Card Sets</legend>
<% if (showAddCustomDeckJson) { %>
<input type="button" class="add_custom_deck_json skip_changed" value="Upload JSON"/>
<% } %>

<% if (showAddCustomDeckUrl) { %>
<input type="button" class="add_custom_deck_url skip_changed" value="Download from URL"/>
<% } %>

<input type="button" class="remove_selected_custom_deck skip_changed" value="Removed selected"/>
<select class="custom_decks_list skip_changed" multiple="multiple">
</select>
</fieldset>
<% } %>
</div>
<% if (allowBlankCards) { %>
<br/>
<label id="blanks_limit_label" title="Blank cards allow a player to type in their own answer.">
Expand Down
27 changes: 23 additions & 4 deletions WebContent/js/cah.ajax.builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,32 @@ cah.ajax.Builder.prototype.withEmote = function(emote) {
};

/**
* @param {string}
* id The Cardcast ID of the deck to add.
* @param {string} json The custom deck JSON
* @returns {cah.ajax.Builder} This object.
*/
cah.ajax.Builder.prototype.withCustomDeckJson = function(json) {
this.assertNotExecuted_();
this.data[cah.$.AjaxRequest.CUSTOM_CARDSET_JSON] = json;
return this;
};

/**
* @param {string} url The custom deck URL
* @returns {cah.ajax.Builder} This object.
*/
cah.ajax.Builder.prototype.withCustomDeckUrl = function(url) {
this.assertNotExecuted_();
this.data[cah.$.AjaxRequest.CUSTOM_CARDSET_URL] = url;
return this;
};

/**
* @param {int} id The custom deck ID
* @returns {cah.ajax.Builder} This object.
*/
cah.ajax.Builder.prototype.withCardcastId = function(id) {
cah.ajax.Builder.prototype.withCustomDeckId = function(id) {
this.assertNotExecuted_();
this.data[cah.$.AjaxRequest.CARDCAST_ID] = id;
this.data[cah.$.AjaxRequest.CUSTOM_CARDSET_ID] = id;
return this;
};

Expand Down
8 changes: 4 additions & 4 deletions WebContent/js/cah.ajax.handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,19 +300,19 @@ cah.ajax.SuccessHandlers[cah.$.AjaxOperation.SCORE] = function(data, req) {
}
};

cah.ajax.SuccessHandlers[cah.$.AjaxOperation.CARDCAST_ADD_CARDSET] = function(data) {
cah.ajax.SuccessHandlers[cah.$.AjaxOperation.ADD_CARDSET] = function(data) {
// pass
};

cah.ajax.SuccessHandlers[cah.$.AjaxOperation.CARDCAST_REMOVE_CARDSET] = function(data) {
cah.ajax.SuccessHandlers[cah.$.AjaxOperation.REMOVE_CARDSET] = function(data) {
// pass
};

cah.ajax.SuccessHandlers[cah.$.AjaxOperation.CARDCAST_LIST_CARDSETS] = function(data, req) {
cah.ajax.SuccessHandlers[cah.$.AjaxOperation.LIST_CARDSETS] = function(data, req) {
var gameId = req[cah.$.AjaxRequest.GAME_ID];
var game = cah.currentGames[gameId];
if (game) {
game.listCardcastDecks(data[cah.$.AjaxResponse.CARD_SETS]);
game.updateCustomDecks(data[cah.$.AjaxResponse.CARD_SETS]);
}
};

Expand Down
23 changes: 0 additions & 23 deletions WebContent/js/cah.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,29 +213,6 @@ function chatsubmit_click(game_id, parent_element) {
case 'names':
ajax = cah.Ajax.build(cah.$.AjaxOperation.NAMES);
break;
case 'addcardcast':
if (game_id !== null) {
ajax = cah.Ajax.build(cah.$.AjaxOperation.CARDCAST_ADD_CARDSET).withCardcastId(
text.split(' ')[0]).withGameId(game_id);
} else {
cah.log.error("This command only works in a game.");
}
break;
case 'removecardcast':
if (game_id !== null) {
ajax = cah.Ajax.build(cah.$.AjaxOperation.CARDCAST_REMOVE_CARDSET).withCardcastId(
text.split(' ')[0]).withGameId(game_id);
} else {
cah.log.error("This command only works in a game.");
}
break;
case 'listcardcast':
if (game_id !== null) {
ajax = cah.Ajax.build(cah.$.AjaxOperation.CARDCAST_LIST_CARDSETS).withGameId(game_id);
} else {
cah.log.error("This command only works in a game.");
}
break;
case 'whois':
ajax = cah.Ajax.build(cah.$.AjaxOperation.WHOIS).withNickname(text.split(' ')[0]);
// so we can show it in the right place; the server ignores this
Expand Down