Merge branch 'dev' into gold-rush
This commit is contained in:
commit
62174ee74e
25
.github/dependabot.yml
vendored
Normal file
25
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
target-branch: "dev"
|
||||||
|
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/frontend"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
target-branch: "dev"
|
||||||
|
|
||||||
|
- package-ecosystem: "pip"
|
||||||
|
directory: "/backend"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
target-branch: "dev"
|
@ -15,6 +15,8 @@ sio = socketio.Server(cors_allowed_origins="*")
|
|||||||
static_files={
|
static_files={
|
||||||
'/': {'content_type': 'text/html', 'filename': 'index.html'},
|
'/': {'content_type': 'text/html', 'filename': 'index.html'},
|
||||||
'/game': {'content_type': 'text/html', 'filename': 'index.html'},
|
'/game': {'content_type': 'text/html', 'filename': 'index.html'},
|
||||||
|
'/help': {'content_type': 'text/html', 'filename': 'index.html'},
|
||||||
|
'/status': {'content_type': 'text/html', 'filename': 'index.html'},
|
||||||
# '/robots.txt': {'content_type': 'text/html', 'filename': 'robots.txt'},
|
# '/robots.txt': {'content_type': 'text/html', 'filename': 'robots.txt'},
|
||||||
'/favicon.ico': {'filename': 'favicon.ico'},
|
'/favicon.ico': {'filename': 'favicon.ico'},
|
||||||
'/img/icons': './img/icons',
|
'/img/icons': './img/icons',
|
||||||
@ -29,9 +31,10 @@ for file in [f for f in os.listdir('.') if '.js' in f or '.map' in f or '.html'
|
|||||||
app = socketio.WSGIApp(sio, static_files=static_files)
|
app = socketio.WSGIApp(sio, static_files=static_files)
|
||||||
games: List[Game] = []
|
games: List[Game] = []
|
||||||
online_players = 0
|
online_players = 0
|
||||||
|
blacklist: List[str] = []
|
||||||
|
|
||||||
def advertise_lobbies():
|
def advertise_lobbies():
|
||||||
sio.emit('lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'locked': g.password != ''} for g in games if not g.started and len(g.players) < 10])
|
sio.emit('lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'password': g.password} for g in games if not g.started and len(g.players) < 10 and not g.is_hidden])
|
||||||
sio.emit('spectate_lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'locked': g.password != ''} for g in games if g.started])
|
sio.emit('spectate_lobbies', room='lobby', data=[{'name': g.name, 'players': len(g.players), 'locked': g.password != ''} for g in games if g.started])
|
||||||
|
|
||||||
@sio.event
|
@sio.event
|
||||||
@ -138,6 +141,8 @@ def create_room(sid, room_name):
|
|||||||
sio.enter_room(sid, room_name)
|
sio.enter_room(sid, room_name)
|
||||||
g = Game(room_name, sio)
|
g = Game(room_name, sio)
|
||||||
g.add_player(sio.get_session(sid))
|
g.add_player(sio.get_session(sid))
|
||||||
|
if room_name in blacklist:
|
||||||
|
g.is_hidden = True
|
||||||
games.append(g)
|
games.append(g)
|
||||||
print(f'{sid} created a room named {room_name}')
|
print(f'{sid} created a room named {room_name}')
|
||||||
advertise_lobbies()
|
advertise_lobbies()
|
||||||
@ -365,6 +370,40 @@ def chat_message(sid, msg):
|
|||||||
color = sid.encode('utf-8').hex()[-3:]
|
color = sid.encode('utf-8').hex()[-3:]
|
||||||
sio.emit('chat_message', room=ses.game.name, data={'color': f'#{color}','text':f'[{ses.name}]: {msg}'})
|
sio.emit('chat_message', room=ses.game.name, data={'color': f'#{color}','text':f'[{ses.name}]: {msg}'})
|
||||||
|
|
||||||
|
@sio.event
|
||||||
|
def get_all_rooms(sid, deploy_key):
|
||||||
|
if 'DEPLOY_KEY' in os.environ and deploy_key == os.environ['DEPLOY_KEY']:
|
||||||
|
sio.emit('all_rooms', room=sid, data=[{
|
||||||
|
'name': g.name,
|
||||||
|
'hidden': g.is_hidden,
|
||||||
|
'players': [{'name':p.name, 'bot': p.is_bot, 'health': p.lives, 'sid': p.sid} for p in g.players],
|
||||||
|
'password': g.password,
|
||||||
|
'expansions': g.expansions,
|
||||||
|
'started': g.started,
|
||||||
|
'current_turn': g.turn,
|
||||||
|
'incremental_turn': g.incremental_turn,
|
||||||
|
'debug': g.debug,
|
||||||
|
'spectators': len(g.spectators)
|
||||||
|
} for g in games])
|
||||||
|
|
||||||
|
@sio.event
|
||||||
|
def kick(sid, data):
|
||||||
|
if 'DEPLOY_KEY' in os.environ and data['key'] == os.environ['DEPLOY_KEY']:
|
||||||
|
sio.emit('kicked', room=data['sid'])
|
||||||
|
|
||||||
|
@sio.event
|
||||||
|
def hide_toogle(sid, data):
|
||||||
|
if 'DEPLOY_KEY' in os.environ and data['key'] == os.environ['DEPLOY_KEY']:
|
||||||
|
game = [g for g in games if g.name==data['room']]
|
||||||
|
if len(games) > 0:
|
||||||
|
game[0].is_hidden = not game[0].is_hidden
|
||||||
|
if game[0].is_hidden:
|
||||||
|
if not data['room'] in blacklist:
|
||||||
|
blacklist.append(data['room'])
|
||||||
|
elif data['room'] in blacklist:
|
||||||
|
blacklist.remove(data['room'])
|
||||||
|
advertise_lobbies()
|
||||||
|
|
||||||
@sio.event
|
@sio.event
|
||||||
def start_game(sid):
|
def start_game(sid):
|
||||||
ses: Player = sio.get_session(sid)
|
ses: Player = sio.get_session(sid)
|
||||||
|
@ -45,6 +45,8 @@ class Game:
|
|||||||
self.attack_in_progress = False
|
self.attack_in_progress = False
|
||||||
self.characters_to_distribute = 2 # personaggi da dare a inizio partita
|
self.characters_to_distribute = 2 # personaggi da dare a inizio partita
|
||||||
self.debug = self.name == 'debug'
|
self.debug = self.name == 'debug'
|
||||||
|
self.is_changing_pwd = False
|
||||||
|
self.is_hidden = False
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
print('resetting lobby')
|
print('resetting lobby')
|
||||||
@ -118,12 +120,16 @@ class Game:
|
|||||||
self.sio.emit('chat_message', room=self.name, data=f'_joined|{player.name}')
|
self.sio.emit('chat_message', room=self.name, data=f'_joined|{player.name}')
|
||||||
|
|
||||||
def set_private(self):
|
def set_private(self):
|
||||||
if self.password == '':
|
if not self.is_changing_pwd:
|
||||||
self.password = ''.join(random.choice("AEIOUJKZT123456789") for x in range(6))
|
self.is_changing_pwd = True
|
||||||
print(self.name, 'is now private pwd', self.password)
|
if self.password == '':
|
||||||
else:
|
self.password = ''.join(random.choice("AEIOUJKZT123456789") for x in range(6))
|
||||||
self.password = ''
|
print(self.name, 'is now private pwd', self.password)
|
||||||
self.notify_room()
|
else:
|
||||||
|
self.password = ''
|
||||||
|
self.notify_room()
|
||||||
|
eventlet.sleep(0.2)
|
||||||
|
self.is_changing_pwd = False
|
||||||
|
|
||||||
def notify_character_selection(self):
|
def notify_character_selection(self):
|
||||||
self.notify_room()
|
self.notify_room()
|
||||||
|
@ -1031,7 +1031,8 @@ class Player:
|
|||||||
self.attacker.molly_discarded_cards = 0
|
self.attacker.molly_discarded_cards = 0
|
||||||
self.attacker.notify_self()
|
self.attacker.notify_self()
|
||||||
self.on_failed_response_cb()
|
self.on_failed_response_cb()
|
||||||
self.game.responders_did_respond_resume_turn(did_lose=True)
|
if self.game:
|
||||||
|
self.game.responders_did_respond_resume_turn(did_lose=True)
|
||||||
if self.mancato_needed <= 0:
|
if self.mancato_needed <= 0:
|
||||||
self.attacker = None
|
self.attacker = None
|
||||||
|
|
||||||
@ -1050,7 +1051,7 @@ class Player:
|
|||||||
return max(1, range) + aim + self.character.sight_mod
|
return max(1, range) + aim + self.character.sight_mod
|
||||||
|
|
||||||
def get_visibility(self):
|
def get_visibility(self):
|
||||||
if not self.character:
|
if not self.character or not self.game or not self.game.players[self.game.turn].character:
|
||||||
return 0
|
return 0
|
||||||
covers = 0
|
covers = 0
|
||||||
if self.game.check_event(ce.Lazo) or self.game.players[self.game.turn].character.check(self.game, chd.BelleStar):
|
if self.game.check_event(ce.Lazo) or self.game.players[self.game.turn].character.check(self.game, chd.BelleStar):
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
certifi==2020.11.8
|
certifi==2021.5.30
|
||||||
dnspython==1.16.0
|
dnspython==1.16.0
|
||||||
eventlet==0.29.1
|
eventlet==0.31.0
|
||||||
greenlet==0.4.17
|
greenlet==1.1.0
|
||||||
python-engineio==3.13.2
|
python-engineio==3.14.2
|
||||||
python-socketio==4.6.0
|
python-socketio==4.6.1
|
||||||
six==1.15.0
|
six==1.16.0
|
||||||
|
@ -8,27 +8,27 @@
|
|||||||
"lint": "vue-cli-service lint"
|
"lint": "vue-cli-service lint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"core-js": "^3.6.5",
|
"core-js": "^3.14.0",
|
||||||
"pretty-checkbox-vue": "^1.1.9",
|
"pretty-checkbox-vue": "^1.1.9",
|
||||||
"register-service-worker": "^1.7.1",
|
"register-service-worker": "^1.7.2",
|
||||||
"socket.io-client": "^3.0.3",
|
"socket.io-client": "^4.1.2",
|
||||||
"vue": "^2.6.11",
|
"vue": "^2.6.14",
|
||||||
"vue-clipboard2": "^0.3.1",
|
"vue-clipboard2": "^0.3.1",
|
||||||
"vue-i18n": "^8.22.2",
|
"vue-i18n": "^8.24.4",
|
||||||
"vue-router": "^3.2.0",
|
"vue-router": "^3.5.1",
|
||||||
"vue-socket.io": "^3.0.10"
|
"vue-socket.io": "^3.0.10"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vue/cli-plugin-babel": "~4.5.0",
|
"@vue/cli-plugin-babel": "~4.5.13",
|
||||||
"@vue/cli-plugin-eslint": "~4.5.0",
|
"@vue/cli-plugin-eslint": "~4.5.13",
|
||||||
"@vue/cli-plugin-pwa": "~4.5.0",
|
"@vue/cli-plugin-pwa": "~4.5.13",
|
||||||
"@vue/cli-plugin-router": "~4.5.0",
|
"@vue/cli-plugin-router": "~4.5.0",
|
||||||
"@vue/cli-service": "~4.5.0",
|
"@vue/cli-service": "~4.5.13",
|
||||||
"babel-eslint": "^10.1.0",
|
"babel-eslint": "^10.1.0",
|
||||||
"eslint": "^6.7.2",
|
"eslint": "^6.7.2",
|
||||||
"eslint-plugin-vue": "^6.2.2",
|
"eslint-plugin-vue": "^7.11.1",
|
||||||
"vue-template-compiler": "^2.6.11",
|
"vue-template-compiler": "^2.6.14",
|
||||||
"workbox-webpack-plugin": "^6.0.2"
|
"workbox-webpack-plugin": "^6.1.5"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
|
@ -188,6 +188,10 @@ export default {
|
|||||||
change_username() {
|
change_username() {
|
||||||
this.hasToSetUsername = true
|
this.hasToSetUsername = true
|
||||||
},
|
},
|
||||||
|
kicked() {
|
||||||
|
window.location.replace(window.location.origin)
|
||||||
|
document.title = 'PewPew!'
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
inviteLink() {
|
inviteLink() {
|
||||||
|
73
frontend/src/components/Status.vue
Normal file
73
frontend/src/components/Status.vue
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1 id="status">PewPew! Server Status</h1>
|
||||||
|
<h2>Rooms {{rooms.length}}</h2>
|
||||||
|
<button @click="refresh">reload</button>
|
||||||
|
<ul>
|
||||||
|
<li v-for="r in rooms" :key="r">
|
||||||
|
<p style="margin:0"><b>name:</b> {{r.name}}</p>
|
||||||
|
<p style="margin:0"><b>hidden:</b> {{r.hidden}}</p>
|
||||||
|
<button @click="hide(r.name)">toggle hide</button>
|
||||||
|
<p style="margin:0"><b>password:</b> {{r.password}}</p>
|
||||||
|
<p style="margin:0"><b>mods:</b> {{r.expansions}}</p>
|
||||||
|
<p style="margin:0"><b>started:</b> {{r.started}}</p>
|
||||||
|
<p style="margin:0"><b>turn:</b> {{r.current_turn}}</p>
|
||||||
|
<p style="margin:0"><b>incremental_turn:</b> {{r.incremental_turn}}</p>
|
||||||
|
<p style="margin:0"><b>debug:</b> {{r.debug}}</p>
|
||||||
|
<p style="margin:0"><b>spectators:</b> {{r.spectators}}</p>
|
||||||
|
<p style="margin:0"><b>players:</b></p>
|
||||||
|
<ul style="margin:0">
|
||||||
|
<li v-for="p in r.players" :key="p">
|
||||||
|
<p style="margin:0"><b>name:</b> {{p.name}}</p>
|
||||||
|
<p style="margin:0"><b>is_bot:</b> {{p.is_bot}}</p>
|
||||||
|
<p style="margin:0"><b>health:</b> {{p.health}}</p>
|
||||||
|
<button v-if="!p.is_bot" @click="kick(p.sid)">Kick</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<br>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'Help',
|
||||||
|
components: {
|
||||||
|
},
|
||||||
|
data:()=>({
|
||||||
|
rooms: [],
|
||||||
|
deploy_key: ''
|
||||||
|
}),
|
||||||
|
computed: {
|
||||||
|
},
|
||||||
|
sockets: {
|
||||||
|
all_rooms(data) {
|
||||||
|
this.rooms = data;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (this.deploy_key == "")
|
||||||
|
this.deploy_key = prompt('Write the key');
|
||||||
|
this.refresh();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
refresh(){
|
||||||
|
this.$socket.emit('get_all_rooms', this.deploy_key)
|
||||||
|
},
|
||||||
|
hide(room_name){
|
||||||
|
this.$socket.emit('hide_toogle', {'key':this.deploy_key, 'room':room_name})
|
||||||
|
setTimeout((()=>{
|
||||||
|
this.refresh()
|
||||||
|
}).bind(this), 500)
|
||||||
|
},
|
||||||
|
kick(sid){
|
||||||
|
this.$socket.emit('kick', {'key':this.deploy_key, 'sid':sid})
|
||||||
|
setTimeout((()=>{
|
||||||
|
this.refresh()
|
||||||
|
}).bind(this), 500)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
@ -12,7 +12,12 @@ const routes = [
|
|||||||
{
|
{
|
||||||
path: '/help',
|
path: '/help',
|
||||||
name: 'Help',
|
name: 'Help',
|
||||||
component: () => import(/* webpackChunkName: "helep" */ '../components/Help.vue')
|
component: () => import(/* webpackChunkName: "help" */ '../components/Help.vue')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/status',
|
||||||
|
name: 'Status',
|
||||||
|
component: () => import(/* webpackChunkName: "status" */ '../components/Status.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
|
1001
frontend/yarn.lock
1001
frontend/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user