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

Update 248.1 #1241

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,10 +536,11 @@ export default createStore({
commit('setUsername', response.data.username)
commit('setRoles', response.data.roles)
commit('setUserCredits', response.data.credits)
return true;
}
}

return true;
return false;
} catch (err) {
console.error(err);
return false;
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/Announcements.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<view-container :hideTopBar="true">
<view-container :hideTopBar="true" :is-auth-page="true">
<view-title
title="Announcements"
:showSocialLinks="true"
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/MainMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import home5 from '../assets/screenshots/home-5.png'
</script>

<template>
<view-container>
<view-container :is-auth-page="true">
<view-title title="Main Menu" :hideHomeButton="true" :showSocialLinks="true"/>

<warnings v-if="user" :warnings="user.warnings" />
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/account/Settings.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<view-container>
<view-title title="Account" />
<view-title title="Account" :is-auth-page="true" />

<loading-spinner :loading="!info"/>

Expand Down
2 changes: 1 addition & 1 deletion client/src/views/admin/AdministrationPage.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<view-container>
<view-container :is-auth-page="true">
<view-title :title="title" />

<nav>
Expand Down
3 changes: 2 additions & 1 deletion client/src/views/components/ViewContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ import ViewContainerTopBarVue from './ViewContainerTopBar.vue'

export default {
props: {
isAuthPage: Boolean,
hideTopBar: Boolean
},
components: {
'logo': LogoVue,
'view-container-top-bar': ViewContainerTopBarVue
},
async mounted() {
if (!this.$store.state.userId) {
if (this.isAuthPage && !this.$store.state.userId) {
await this.$store.dispatch('verify')
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/game/ActiveGames.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<view-container>
<view-container :is-auth-page="true">
<view-title title="My Games" />

<active-games/>
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/game/Create.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<view-container>
<view-container :is-auth-page="true">
<view-title title="Create Game" />
<loading-spinner :loading="!settings || isCreatingGame"/>

Expand Down
93 changes: 1 addition & 92 deletions client/src/views/game/Detail.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<view-container>
<view-container :is-auth-page="true">
<view-title title="Game Settings" navigation="main-menu"/>

<loading-spinner :loading="isLoading"/>
Expand Down Expand Up @@ -92,97 +92,6 @@ export default {

this.isLoading = false
},
async pauseGame () {
if (await this.$confirm('Pause game', 'Are you sure you want to pause this game?')) {
this.isLoading = true

try {
await gameService.pause(this.game._id)

this.$toast.success(`The game has been paused. Please notify the players.`)

await this.loadGame()
} catch (err) {
this.errors = err.response.data.errors;
console.error(err)
}

this.isLoading = false
}
},
async fastForwardGame () {
if (await this.$confirm('Fast forward game', 'Are you sure you want to fast forward this game?')) {
this.isLoading = true

try {
await gameService.fastForward(this.game._id)

this.$toast.success(`The game has been fast forwarded. Please notify the players.`)

await this.loadGame()
} catch (err) {
this.errors = err.response.data.errors;
console.error(err)
}

this.isLoading = false
}
},
async forceStartGame () {
if (await this.$confirm('Force start game', 'All open slots will be filled with bots. Are you sure you want to force start this game?')) {
this.isLoading = true

try {
await gameService.forceStart(this.game._id)

this.$toast.success(`The game has been force started. Please notify the players.`)

await this.loadGame()
} catch (err) {
this.errors = err.response.data.errors;
console.error(this.error);
console.error(err)
}

this.isLoading = false
}
},
async resumeGame () {
if (await this.$confirm('Resume game', 'Are you sure you want to resume this game?')) {
this.isLoading = true

try {
await gameService.resume(this.game._id)

this.$toast.success(`The game has been resumed. Please notify the players.`)

await this.loadGame()
} catch (err) {
this.errors = err.response.data.errors;
console.error(err)
}

this.isLoading = false
}
},
async deleteGame () {
if (await this.$confirm('Delete game', 'Are you sure you want to delete this game?')) {
this.isLoading = true

try {
let response = await gameService.delete(this.game._id)

if (response.status === 200) {
router.push({name: 'main-menu'})
}
} catch (err) {
this.errors = err.response.data.errors;
console.error(err)
}

this.isLoading = false
}
}
},
computed: {
isNewPlayerGame () {
Expand Down
181 changes: 139 additions & 42 deletions client/src/views/game/GameControl.vue
Original file line number Diff line number Diff line change
@@ -1,61 +1,158 @@
<template>
<div class="row mb-1 bg-dark pt-2 pb-2" v-if="game.settings.general.isGameAdmin">
<div class="col">
<button class="btn btn-danger" v-if="!game.state.startDate"
@click="deleteGame">Delete Game</button>
<button class="btn btn-warning" v-if="canModifyPauseState() && !game.state.paused" @click="pauseGame">Pause
Game</button>
<button class="btn btn-warning" v-if="canModifyPauseState() && game.state.paused" @click="resumeGame">Resume
Game</button>
<button class="btn btn-danger ms-1" v-if="!game.state.startDate"
@click="forceStartGame">Force start Game</button>
<button class="btn btn-warning ms-1"
v-if="game.state.startDate && !game.state.endDate && !game.state.forceTick"
@click="fastForwardGame">Fast Forward Game</button>

<view-collapse-panel @onToggle="togglePlayerControl" title="Player Control">
<game-player-control :game="fullGame" @onGameModified="loadFullGame" />
</view-collapse-panel>
</div>
<div class="row mb-1 bg-dark pt-2 pb-2" v-if="game.settings.general.isGameAdmin">
<div class="col">
<button class="btn btn-danger" v-if="!game.state.startDate"
@click="deleteGame">Delete Game
</button>
<button class="btn btn-warning" v-if="canModifyPauseState() && !game.state.paused" @click="pauseGame">Pause
Game
</button>
<button class="btn btn-warning" v-if="canModifyPauseState() && game.state.paused" @click="resumeGame">Resume
Game
</button>
<button class="btn btn-danger ms-1" v-if="!game.state.startDate"
@click="forceStartGame">Force start Game
</button>
<button class="btn btn-warning ms-1"
v-if="game.state.startDate && !game.state.endDate && !game.state.forceTick"
@click="fastForwardGame">Fast Forward Game
</button>

<view-collapse-panel @onToggle="togglePlayerControl" title="Player Control">
<game-player-control :game="fullGame" @onGameModified="loadFullGame"/>
</view-collapse-panel>
</div>
</div>
</template>
<script>
import GameHelper from '../../services/gameHelper'
import ViewCollapsePanel from '../components/ViewCollapsePanel.vue'
import GamePlayerControl from './GamePlayerControl.vue';
import gameService from '../../services/api/game'
import router from "../../router.js";

export default {
components: {
'view-collapse-panel': ViewCollapsePanel,
'game-player-control': GamePlayerControl,
components: {
'view-collapse-panel': ViewCollapsePanel,
'game-player-control': GamePlayerControl,
},
props: {
game: Object,
},
data() {
return {
fullGame: null,
}
},
methods: {
canModifyPauseState() {
return this.game.settings.general.isGameAdmin
&& GameHelper.isGameStarted(this.game)
&& !GameHelper.isGamePendingStart(this.game)
&& !GameHelper.isGameFinished(this.game);
},
props: {
game: Object,
async togglePlayerControl(collapsed) {
if (!collapsed && !this.fullGame) {
await this.loadFullGame();
}
},
async loadFullGame() {
const resp = await gameService.getGameGalaxy(this.game._id);

this.fullGame = resp.data;
},
data () {
return {
fullGame: null,
async pauseGame() {
if (await this.$confirm('Pause game', 'Are you sure you want to pause this game?')) {
this.isLoading = true

try {
await gameService.pause(this.game._id)

this.$toast.success(`The game has been paused. Please notify the players.`)

await this.loadGame()
} catch (err) {
this.errors = err.response.data.errors;
console.error(err)
}

this.isLoading = false
}
},
methods: {
canModifyPauseState() {
return this.game.settings.general.isGameAdmin
&& GameHelper.isGameStarted(this.game)
&& !GameHelper.isGamePendingStart(this.game)
&& !GameHelper.isGameFinished(this.game);
},
async togglePlayerControl (collapsed) {
if (!collapsed && !this.fullGame) {
await this.loadFullGame();
}
},
async loadFullGame () {
const resp = await gameService.getGameGalaxy(this.game._id);

this.fullGame = resp.data;
async fastForwardGame() {
if (await this.$confirm('Fast forward game', 'Are you sure you want to fast forward this game?')) {
this.isLoading = true

try {
await gameService.fastForward(this.game._id)

this.$toast.success(`The game has been fast forwarded. Please notify the players.`)

await this.loadGame()
} catch (err) {
this.errors = err.response.data.errors;
console.error(err)
}

this.isLoading = false
}
},
async forceStartGame() {
if (await this.$confirm('Force start game', 'All open slots will be filled with bots. Are you sure you want to force start this game?')) {
this.isLoading = true

try {
await gameService.forceStart(this.game._id)

this.$toast.success(`The game has been force started. Please notify the players.`)

await this.loadGame()
} catch (err) {
this.errors = err.response.data.errors;
console.error(this.error);
console.error(err)
}

this.isLoading = false
}
},
async resumeGame() {
if (await this.$confirm('Resume game', 'Are you sure you want to resume this game?')) {
this.isLoading = true

try {
await gameService.resume(this.game._id)

this.$toast.success(`The game has been resumed. Please notify the players.`)

await this.loadGame()
} catch (err) {
this.errors = err.response.data.errors;
console.error(err)
}

this.isLoading = false
}
},
async deleteGame() {
if (await this.$confirm('Delete game', 'Are you sure you want to delete this game?')) {
this.isLoading = true

try {
let response = await gameService.delete(this.game._id)

if (response.status === 200) {
router.push({name: 'main-menu'})
}
} catch (err) {
this.errors = err.response.data.errors;
console.error(err)
}

this.isLoading = false
}
}
}
}
</script>
<style scoped></style>
Loading
Loading