Skip to content

Commit

Permalink
Revert "Attempted fix for #233, #217, #216, #224, socketio version is…
Browse files Browse the repository at this point in the history
…sues (#235)"

This reverts commit c9e7c42.
  • Loading branch information
amritrau committed Apr 8, 2021
1 parent c9e7c42 commit 9b17fa1
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 132 deletions.
12 changes: 5 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ attrs==19.1.0
Click==7.0
coverage==5.3
dnspython==1.16.0
eventlet==0.30.2
gevent==21.1.2
gevent-websocket==0.10.1
Flask==1.1.2
Flask-SocketIO==5.0.1
eventlet==0.24.1
Flask==1.0.2
Flask-SocketIO==3.3.2
git-fame==1.12.2
greenlet==0.4.15
itsdangerous==1.1.0
Expand All @@ -25,8 +23,8 @@ pycodestyle==2.5.0
pytest==4.4.1
pytest-cov==2.6.1
python-dateutil==2.8.1
python-engineio==4.0.1
python-socketio==5.1.0
python-engineio==3.8.2.post1
python-socketio==3.1.2
pytz==2021.1
six==1.12.0
stevedore==1.30.1
Expand Down
12 changes: 1 addition & 11 deletions shadow-hunters/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import secrets
import html

from flask import (
Flask, render_template, url_for, redirect,
request, flash, send_from_directory
)
from flask import Flask, render_template, url_for, redirect, request, flash
from flask_socketio import SocketIO, join_room, leave_room

from game_context import GameContext
Expand Down Expand Up @@ -40,13 +37,6 @@ def after_request(response):
return response


# favicon handler
@app.route('/favicon.ico')
def favicon():
base = os.path.join(os.path.dirname(app.root_path), 'static')
return send_from_directory(base, 'favicon.ico')


# sleep times after socket emissions (to pace frontend)
SOCKET_SLEEP = float(os.getenv('SOCKET_SLEEP', 0.25))
AI_SLEEP = float(os.getenv('AI_SLEEP', 2.0))
Expand Down
9 changes: 9 additions & 0 deletions static/deps/socketio-2.2.0.min.js

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions static/deps/socketio-3.1.3.min.js

This file was deleted.

113 changes: 59 additions & 54 deletions static/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,61 @@ $('document').ready(function() {
});
socket.on('connect', function() {

// User joins the room
socket.emit('join', usrctx );

// Set up message posting with button presses
var chat_form = $('#chat').on('submit', function(e) {
e.preventDefault();
var user_input = $('#message').val();
socket.emit('message', { 'data': user_input });
$('#message').val('').focus();
});

// Start game button
var start_form = $('#start').on('submit', function(e) {
e.preventDefault();
socket.emit('start', { 'n_players': $('#nPlayers').val() });
});

// Reveal button
var reveal_form = $('#reveal').on('submit', function(e) {
e.preventDefault();
$('#reveal').hide();
socket.emit('reveal');
});

// Special ability button
var special_form = $('#special').on('submit', function(e) {
e.preventDefault();
$('#special').hide();
socket.emit('special');
});

// Form type 1
var confirm_form = $('#confirm').on('submit', function(e) {
e.preventDefault();
socket.emit('answer', { 'value': $('#confirm [name="inputs"][clicked=true]').val() });
$('#confirm').hide();
$('#confirm').empty();
});

// Form type 2
var yesno_form = $('#yesno').on('submit', function(e) {
e.preventDefault();
socket.emit('answer', { 'value': $('#yesno [name="inputs"][clicked=true]').val() });
$('#yesno').hide();
$('#yesno').empty();
});

// Form type 3
var select_form = $('#select').on('submit', function(e) {
e.preventDefault();
socket.emit('answer', { 'value': $('#select [name="inputs"][clicked=true]').val() });
$('#select').hide();
$('#select').empty();
});

// Receive a message
socket.on('message', function(msg) {

Expand Down Expand Up @@ -98,60 +153,10 @@ $('document').ready(function() {
window.location = "/";
});

// User joins the room
socket.emit('join', usrctx );

// Set up message posting with button presses
var chat_form = $('#chat').on('submit', function(e) {
e.preventDefault();
var user_input = $('#message').val();
socket.emit('message', { 'data': user_input });
$('#message').val('').focus();
});

// Start game button
var start_form = $('#start').on('submit', function(e) {
e.preventDefault();
socket.emit('start', { 'n_players': $('#nPlayers').val() });
});

// Reveal button
var reveal_form = $('#reveal').on('submit', function(e) {
e.preventDefault();
$('#reveal').hide();
socket.emit('reveal');
});

// Special ability button
var special_form = $('#special').on('submit', function(e) {
e.preventDefault();
$('#special').hide();
socket.emit('special');
});

// Form type 1
var confirm_form = $('#confirm').on('submit', function(e) {
e.preventDefault();
socket.emit('answer', { 'value': $('#confirm [name="inputs"][clicked=true]').val() });
$('#confirm').hide();
$('#confirm').empty();
});

// Form type 2
var yesno_form = $('#yesno').on('submit', function(e) {
e.preventDefault();
socket.emit('answer', { 'value': $('#yesno [name="inputs"][clicked=true]').val() });
$('#yesno').hide();
$('#yesno').empty();
});

// Form type 3
var select_form = $('#select').on('submit', function(e) {
e.preventDefault();
socket.emit('answer', { 'value': $('#select [name="inputs"][clicked=true]').val() });
$('#select').hide();
$('#select').empty();
});
// Close window handler
window.onbeforeunload = function() {
socket.close();
}

// Configure game
var config = {
Expand Down
102 changes: 52 additions & 50 deletions templates/join.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

gtag('config', 'UA-138967428-1');
</script>
<script src="https://cdn.jsdelivr.net/npm/@widgetbot/crate@3" async defer>
<script src="https://cdn.jsdelivr.net/npm/@widgetbot/crate@3" async="" defer="">
new Crate({
server: '774628310822289431', // Shadow Hunters
channel: '774628311267541023', // #find-a-game
Expand Down Expand Up @@ -51,55 +51,57 @@



<body class="bg">
<div class="centered">
<p style="position: absolute; top: 200px; left: -50px">
<a href="/rules" class="pull-left"><img src="https://d2naeox1pchp13.cloudfront.net/rules.png" width="100"></a>
</p>
<body>
<center>
<div style="color: #FFFFFF; background-color: #000000; opacity: .4; position: absolute; top: 300px; left: -195px; font-size: 12px">
<p class=flashes style="width: 390px; height: 0px">
<p>Find a game on our <a href="https://discord.gg/HwnNfaz9zD" style="color:#FFFFFF">Discord</a> by clicking the Crate in the bottom right!</p>
</p>
</div>
</center>
<center>
<div style="color: #FFFFFF; background-color: #000000; opacity: .4; position: absolute; top: 365px; left: -195px; font-size: 12px">
<p class=flashes style="width: 390px; height: 0px">
<p>Disconnected? Re-enter your name and room ID to rejoin your game.</p>
</p>
</div>
</center>
<center>
<div style="width: 350px; border: 5px solid; padding: 10px; box-shadow: 5px 10px #000000; background-color: #DFDFDF;height: 75px; position: fixed; left: -191px">
<form action="/room" method="POST">
<center>
<div><b style="color: #3f2b6d; font-size: 14px">Enter a screen name and a room ID to join a game!</b></div>
<div><br /></div>
<input id="screen-name" style="font-family: Palatino, 'Times New Roman', Times;" type="text" name="username" placeholder="Screen Name" autocomplete="off"/>
<input id="room-id" style="font-family: Palatino, 'Times New Roman', Times;"type="text" name="room_id" placeholder="Room ID" autocomplete="off"/>
<input id="submit-button" style="font-family: Palatino, 'Times New Roman', Times;"type="submit" value="Join"/>
<div><br /></div>
</center>
</form>
</div>
</center>
<div><br /></div>
<center>
<div style="color: #FFFFFF; background-color: #000000; opacity: .3; position: absolute; top: 125px; left: -75px; font-size: 12px">
{% with messages = get_flashed_messages() %}
{% if messages %}
<p class=flashes style="width: 150px; height: 0px">
{% for message in messages %}
<p>{{ message }}</p>
{% endfor %}
</p>
{% endif %}
{% endwith %}
</div>
</center>
</body>
<body>
<div class="bg">
<div class="centered">
<p style="position: absolute; top: 200px; left: -50px">
<a href="/rules" class="pull-left"><img src="https://d2naeox1pchp13.cloudfront.net/rules.png" width="100"></a>
</p>
<body>
<center>
<div style="color: #FFFFFF; background-color: #000000; opacity: .4; position: absolute; top: 300px; left: -195px; font-size: 12px">
<p class=flashes style="width: 390px; height: 0px">
<p>Find a game on our <a href="https://discord.gg/HwnNfaz9zD" style="color:#FFFFFF">Discord</a> by clicking the Crate in the bottom right!</p>
</p>
</div>
</center>
<center>
<div style="color: #FFFFFF; background-color: #000000; opacity: .4; position: absolute; top: 365px; left: -195px; font-size: 12px">
<p class=flashes style="width: 390px; height: 0px">
<p>Disconnected? Re-enter your name and room ID to rejoin your game.</p>
</p>
</div>
</center>
<center>
<div style="width: 350px; border: 5px solid; padding: 10px; box-shadow: 5px 10px #000000; background-color: #DFDFDF;height: 75px; position: fixed; left: -191px">
<form action="/room" method="POST">
<center>
<div><b style="color: #3f2b6d; font-size: 14px">Enter a screen name and a room ID to join a game!</b></div>
<div><br /></div>
<input id="screen-name" style="font-family: Palatino, 'Times New Roman', Times;" type="text" name="username" placeholder="Screen Name" autocomplete="off"/>
<input id="room-id" style="font-family: Palatino, 'Times New Roman', Times;"type="text" name="room_id" placeholder="Room ID" autocomplete="off"/>
<input id="submit-button" style="font-family: Palatino, 'Times New Roman', Times;"type="submit" value="Join"/>
<div><br /></div>
</center>
</form>
</div>
</center>
<div><br /></div>
<center>
<div style="color: #FFFFFF; background-color: #000000; opacity: .3; position: absolute; top: 125px; left: -75px; font-size: 12px">
{% with messages = get_flashed_messages() %}
{% if messages %}
<p class=flashes style="width: 150px; height: 0px">
{% for message in messages %}
<p>{{ message }}</p>
{% endfor %}
</p>
{% endif %}
{% endwith %}
</div>
</center>
</body>
</div>
</div>
</body>
</html>
8 changes: 5 additions & 3 deletions templates/room.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

gtag('config', 'UA-138967428-1');
</script>
<script src="https://cdn.jsdelivr.net/npm/@widgetbot/crate@3" async defer>
<script src="https://cdn.jsdelivr.net/npm/@widgetbot/crate@3" async="" defer="">
new Crate({
server: '774628310822289431', // Shadow Hunters
channel: '774628311267541023', // #find-a-game
Expand Down Expand Up @@ -68,7 +68,7 @@
</style>
<script src={{ url_for("static", filename="deps/phaser-3.15.1.min.js") }}></script>
<script src={{ url_for("static", filename="deps/jquery-1.12.4.min.js") }}></script>
<script src={{ url_for("static", filename="deps/socketio-3.1.3.min.js") }}></script>
<script src={{ url_for("static", filename="deps/socketio-2.2.0.min.js") }}></script>
<script> var usrctx = {{ context|tojson }}; </script>
<script> var socket; var WaitingRoom; var GameBoard; </script>
<script src={{ url_for("static", filename="waitRoom.js") }}></script>
Expand All @@ -88,7 +88,8 @@

</head>

<body class="bg">
<body>
<div class="bg">

<ul class="nav">
<a href="/" class="pull-left"><img src="https://d2naeox1pchp13.cloudfront.net/home.png" width="100"></a>
Expand Down Expand Up @@ -145,5 +146,6 @@ <h5 style="color:white;padding-top:50px;">Like Shadow Hunters? Join our <a href=
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1" />
</form>

</div>
</body>
</html>
3 changes: 2 additions & 1 deletion templates/rules.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

gtag('config', 'UA-138967428-1');
</script>
<script src="https://cdn.jsdelivr.net/npm/@widgetbot/crate@3" async defer>
<script src="https://cdn.jsdelivr.net/npm/@widgetbot/crate@3" async="" defer="">
new Crate({
server: '774628310822289431', // Shadow Hunters
channel: '774628311267541023', // #find-a-game
Expand Down Expand Up @@ -90,6 +90,7 @@

<body>
<div class="bg">

<ul class="nav">
<a href="/" class="pull-left"><img src="https://d2naeox1pchp13.cloudfront.net/home.png" width="100"></a>
<a href="/" class="pull-left"><img src="https://d2naeox1pchp13.cloudfront.net/logo.png"></a>
Expand Down

0 comments on commit 9b17fa1

Please sign in to comment.