Skip to content
This repository was archived by the owner on Mar 10, 2019. It is now read-only.

Commit edea939

Browse files
committed
Merge branch 'develop'
2 parents 5ad4afa + df06381 commit edea939

File tree

89 files changed

+519
-383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+519
-383
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ target
22
.idea/
33
WebContent/node_modules/
44
WebContent/.backup/
5-
*.iml
65
.old/
76
preferences.json
7+
server.sqlite

WebContent/css/cards.css

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@
1616
overflow-wrap: break-word;
1717
}
1818

19-
#whiteCards {
20-
width: 100%;
21-
}
22-
23-
#hand > .list > .mdc-card.pyx-card {
24-
flex-shrink: 0;
25-
}
26-
2719
.mdc-card.pyx-card .card-details {
2820
min-height: 0;
2921
}

WebContent/css/game.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
#gameLayout {
22
width: 100%;
3+
display: flex;
34
}
45

56
#gameLayout > .message {
67
margin-top: 48px;
78
}
89

10+
#whiteCards {
11+
flex-grow: 1;
12+
}
13+
14+
#hand > .list > .mdc-card.pyx-card {
15+
flex-shrink: 0;
16+
}
17+
918
#drawer > .mdc-drawer__drawer {
1019
padding: 16px;
1120
display: flex;

WebContent/game.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ <h1 class="message mdc-typography--headline">No suggested game options.</h1>
108108
</main>
109109
</div>
110110

111-
<aside class="bottom-sheet" id="hand">
111+
<aside class="bottom-sheet" id="hand" style="display: none">
112112
<div class="_toggleHand_mask" style="flex-grow: 1"></div>
113-
<div class="mdc-elevation--z16 mdc-toolbar" style="display: none">
113+
<div class="mdc-elevation--z16 mdc-toolbar">
114114
<div class="mdc-toolbar__row">
115115
<section class="mdc-toolbar__section mdc-toolbar__section--align-start">
116116
<div class="mdc-toolbar__title">

WebContent/js/game.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ class GameManager {
66
this.drawer = new mdc.drawer.MDCPersistentDrawer($('#drawer')[0]);
77
$('.mdc-toolbar__menu-icon').on('click', () => this.toggleDrawer());
88

9+
this._lobbyMessage = this.root.find('#gameLayout .message');
10+
911
this._leaveGame = this.root.find('#leaveGame');
1012
this._leaveGame.on('click', () => this.leave());
1113

@@ -470,23 +472,26 @@ class GameManager {
470472
this.blackCard = null;
471473
this.addHandCards([], true);
472474
this.addTableCards([], true);
473-
474475
this.toggleStartButton(this.amHost);
475476
this.toggleHandVisibility(false);
477+
this._lobbyMessage.show();
476478
break;
477479
case "p":
478480
this.blackCard = data.bc;
479481
this.updateHandInfo(this.bc.PK - this.bc.D, this.bc.D);
480482
this.toggleStartButton(false);
481483
this.addTableCards([], true);
482484
this.toggleHandVisibility(this.getPlayerStatus(this.user.n) === "sp");
485+
this._lobbyMessage.hide();
483486
break;
484487
case "j":
485488
this.addTableCards(data.wc, true);
486489
this.toggleStartButton(false);
487490
this.toggleHandVisibility(false);
491+
this._lobbyMessage.hide();
488492
break;
489493
case "ro":
494+
this._lobbyMessage.hide();
490495
this._highlightWinningCards(data.WC);
491496
if (data.wl) {
492497
// Someone won the game
@@ -523,8 +528,8 @@ class GameManager {
523528
}
524529

525530
toggleHandVisibility(visible) {
526-
if (visible) this._hand_toolbar.show();
527-
else this._hand_toolbar.hide();
531+
if (visible) this._hand.show();
532+
else this._hand.hide();
528533
this._reloadDrawerPadding();
529534
}
530535

@@ -542,6 +547,9 @@ class GameManager {
542547
this._title.text(this.info.gi.H + " - PYX Reloaded");
543548
document.title = this.info.gi.H + " - PYX Reloaded";
544549

550+
if (this.info.gi.gs === "l") this._lobbyMessage.show();
551+
else this._lobbyMessage.hide();
552+
545553
this.toggleStartButton(this.amHost && this.info.gi.gs === "l");
546554
this.toggleHandVisibility(this.getPlayerStatus(this.user.n) === "sp");
547555

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.gianlu.pyxreloaded</groupId>
77
<artifactId>server</artifactId>
8-
<version>0.2.0</version>
8+
<version>0.2.1</version>
99
<packaging>jar</packaging>
1010

1111
<name>pyx-reloaded</name>

preferences.json.default

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"maxUsers": 100,
1212
"cacheEnabled": true,
1313
"webContent": "./WebContent",
14-
"pyxDb": "pyx.sqlite",
14+
"pyxDbUrl": "jdbc:sqlite:pyx.sqlite",
15+
"serverDbUrl": "jdbc:sqlite:server.sqlite",
1516
"maxSkipsBeforeKick": 2,
1617
"roundIntermission": 8,
1718
"minBlackCards": 50,

src/main/java/com/gianlu/pyxreloaded/Consts.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,13 @@ public enum ErrorCode {
306306
/**
307307
* The user has already suggested a modification.
308308
*/
309-
ALREADY_SUGGESTED("AS");
309+
ALREADY_SUGGESTED("AS"),
310+
/**
311+
* SQL error, fatal.
312+
* <p>
313+
* FIXME: Remove this error
314+
*/
315+
SQL_ERROR("sqle");
310316

311317
private final String code;
312318

@@ -1068,7 +1074,7 @@ public String toString() {
10681074
/**
10691075
* Can be used in responses as key
10701076
*/
1071-
interface ReturnableKey {
1077+
public interface ReturnableKey {
10721078
}
10731079

10741080
/**

src/main/java/com/gianlu/pyxreloaded/Server.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package com.gianlu.pyxreloaded;
22

33
import com.gianlu.pyxreloaded.cardcast.CardcastService;
4-
import com.gianlu.pyxreloaded.data.ConnectedUsers;
5-
import com.gianlu.pyxreloaded.data.Game;
6-
import com.gianlu.pyxreloaded.data.GameManager;
7-
import com.gianlu.pyxreloaded.db.LoadedCards;
8-
import com.gianlu.pyxreloaded.servlets.*;
9-
import com.gianlu.pyxreloaded.servlets.Provider;
4+
import com.gianlu.pyxreloaded.game.Game;
5+
import com.gianlu.pyxreloaded.game.GameManager;
6+
import com.gianlu.pyxreloaded.paths.AjaxPath;
7+
import com.gianlu.pyxreloaded.paths.EventsPath;
8+
import com.gianlu.pyxreloaded.server.Annotations;
9+
import com.gianlu.pyxreloaded.server.CustomResourceHandler;
10+
import com.gianlu.pyxreloaded.server.HttpsRedirect;
11+
import com.gianlu.pyxreloaded.server.Provider;
12+
import com.gianlu.pyxreloaded.singletons.*;
1013
import com.gianlu.pyxreloaded.task.BroadcastGameListUpdateTask;
1114
import com.gianlu.pyxreloaded.task.RefreshAdminTokenTask;
1215
import com.gianlu.pyxreloaded.task.UserPingTask;
@@ -45,11 +48,17 @@ public static void main(String[] args) throws IOException, SQLException, Unrecov
4548

4649
Providers.add(Annotations.Preferences.class, (Provider<Preferences>) () -> preferences);
4750

48-
LoadedCards.load(preferences.getString("pyxDb", "pyx.sqlite"));
51+
LoadedCards loadedCards = new LoadedCards(preferences.getString("pyxDbUrl", "jdbc:sqlite:pyx.sqlite"));
52+
Providers.add(Annotations.LoadedCards.class, (Provider<LoadedCards>) () -> loadedCards);
4953

5054
ConnectedUsers connectedUsers = new ConnectedUsers(false, maxUsers);
5155
Providers.add(Annotations.ConnectedUsers.class, (Provider<ConnectedUsers>) () -> connectedUsers);
5256

57+
ServerDatabase serverDatabase = new ServerDatabase(preferences.getString("serverDbUrl", "jdbc:sqlite:server.sqlite"));
58+
59+
BanList banList = new BanList(serverDatabase);
60+
Providers.add(Annotations.BanList.class, (Provider<BanList>) () -> banList);
61+
5362
BroadcastGameListUpdateTask updateGameListTask = new BroadcastGameListUpdateTask(connectedUsers);
5463
globalTimer.scheduleAtFixedRate(updateGameListTask, BROADCAST_UPDATE_START_DELAY, BROADCAST_UPDATE_DELAY, TimeUnit.MILLISECONDS);
5564

@@ -61,13 +70,13 @@ public static void main(String[] args) throws IOException, SQLException, Unrecov
6170
CardcastService cardcastService = new CardcastService();
6271
Providers.add(Annotations.CardcastService.class, (Provider<CardcastService>) () -> cardcastService);
6372

64-
GameManager gameManager = new GameManager((manager, options) -> new Game(GameManager.generateGameId(), options, connectedUsers, manager, globalTimer, preferences, cardcastService), 100, updateGameListTask);
73+
GameManager gameManager = new GameManager((manager, options) -> new Game(GameManager.generateGameId(), options, connectedUsers, manager, loadedCards, globalTimer, preferences, cardcastService), 100, updateGameListTask);
6574
Providers.add(Annotations.GameManager.class, (Provider<GameManager>) () -> gameManager);
6675

6776
ResourceHandler resourceHandler = new CustomResourceHandler(preferences);
6877
PathHandler pathHandler = new PathHandler(resourceHandler);
69-
pathHandler.addExactPath("/AjaxServlet", new BaseAjaxHandler())
70-
.addExactPath("/Events", Handlers.websocket(new EventsHandler()));
78+
pathHandler.addExactPath("/AjaxServlet", new AjaxPath())
79+
.addExactPath("/Events", Handlers.websocket(new EventsPath()));
7180

7281
RoutingHandler router = new RoutingHandler();
7382
router.setFallbackHandler(pathHandler)

src/main/java/com/gianlu/pyxreloaded/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.gianlu.pyxreloaded;
22

3-
import com.gianlu.pyxreloaded.data.WhiteCard;
3+
import com.gianlu.pyxreloaded.cards.WhiteCard;
44
import com.google.gson.JsonArray;
55
import org.jetbrains.annotations.NotNull;
66

0 commit comments

Comments
 (0)