From b78a9d60c80ad31136f9daca6abbda58fcea400b Mon Sep 17 00:00:00 2001 From: Andrew Guibert <andy.guibert@gmail.com> Date: Mon, 15 Oct 2018 21:01:05 -0500 Subject: [PATCH] Enforce single party on frontend in single party mode --- auth-service/.classpath | 2 +- .../prebuild/src/app/login/login.component.ts | 31 +++++++++++-------- game-service/.classpath | 2 +- .../game/round/service/PartyService.java | 1 + player-service/.classpath | 2 +- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/auth-service/.classpath b/auth-service/.classpath index 5880dcc..039dcda 100644 --- a/auth-service/.classpath +++ b/auth-service/.classpath @@ -5,7 +5,7 @@ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"> <attributes> - <attribute name="org.eclipse.jst.component.nondependency" value=""/> + <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> </attributes> </classpathentry> <classpathentry kind="output" path="build/classes/java/main"/> diff --git a/frontend/prebuild/src/app/login/login.component.ts b/frontend/prebuild/src/app/login/login.component.ts index cc08616..22f183e 100644 --- a/frontend/prebuild/src/app/login/login.component.ts +++ b/frontend/prebuild/src/app/login/login.component.ts @@ -24,6 +24,7 @@ export class LoginComponent implements OnInit, OnDestroy { player = new Player(); isFullDevice: boolean = !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); isQuickPlayAllowed: boolean = this.isFullDevice; + isSingleParty: boolean = false; isGoogleConfigured: boolean = false; isGithubConfigured: boolean = false; isTwitterConfigured: boolean = false; @@ -71,7 +72,7 @@ export class LoginComponent implements OnInit, OnDestroy { this.showQueue(queuePosition); } - this.checkForQuickPlay(); + this.checkForSingleParty(); this.checkSsoOptions(); } @@ -109,32 +110,36 @@ export class LoginComponent implements OnInit, OnDestroy { if (data.indexOf('GitHubAuth') > -1) { this.isGithubConfigured = true; } - } + }); } - async checkForQuickPlay() { - if (this.isQuickPlayAllowed) { - console.log('Quick play is supported -- skipping party service check'); - return; + async checkForSingleParty() { + if (this.isSingleParty) { + return; } let data: any = await this.http.get(`${environment.API_URL_PARTY}/describe`).toPromise(); if (data == null) { - console.log('WARNING: Unable to contact party service to determine if quick play is allowed'); - return; + console.log('WARNING: Unable to contact party service to determine if single party mode is enabled'); + return; } if (data.isSingleParty === true) { - console.log('Quick play is supported'); - this.ngZone.run(() => { - this.isQuickPlayAllowed = true; - }); + console.log('Single party mode enabled'); + this.party = data.partyId; + this.ngZone.run(() => { + this.isSingleParty = true; + }); } else { - console.log('Quick play is NOT supported'); + console.log('Single party mode disabled'); } } async quickJoin() { + if (this.isSingleParty) { + this.joinParty(); + return; + } // First get an unstarted round ID let roundID = await this.http.get(`${environment.API_URL_GAME_ROUND}/available`, { responseType: 'text' }).toPromise(); // Then join the round diff --git a/game-service/.classpath b/game-service/.classpath index c1e7fa4..ae9e739 100644 --- a/game-service/.classpath +++ b/game-service/.classpath @@ -6,7 +6,7 @@ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"> <attributes> - <attribute name="org.eclipse.jst.component.nondependency" value=""/> + <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> </attributes> </classpathentry> <classpathentry kind="output" path="build/classes/java/main"/> diff --git a/game-service/src/main/java/org/libertybikes/game/round/service/PartyService.java b/game-service/src/main/java/org/libertybikes/game/round/service/PartyService.java index 3523b5a..69050a0 100644 --- a/game-service/src/main/java/org/libertybikes/game/round/service/PartyService.java +++ b/game-service/src/main/java/org/libertybikes/game/round/service/PartyService.java @@ -64,6 +64,7 @@ public class PartyService { public Map<String, Object> describe() { Map<String, Object> config = new HashMap<>(); config.put("isSingleParty", this.isSingleParty); + config.put("partyId", allParties.values().iterator().next().id); return config; } diff --git a/player-service/.classpath b/player-service/.classpath index c1e7fa4..ae9e739 100644 --- a/player-service/.classpath +++ b/player-service/.classpath @@ -6,7 +6,7 @@ <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> <classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"> <attributes> - <attribute name="org.eclipse.jst.component.nondependency" value=""/> + <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> </attributes> </classpathentry> <classpathentry kind="output" path="build/classes/java/main"/>