Compare commits
No commits in common. "main" and "feature/long-poll-status" have entirely different histories.
main
...
feature/lo
|
@ -6,7 +6,7 @@ from .models import Game, Player
|
||||||
class PlayerForm(forms.Form):
|
class PlayerForm(forms.Form):
|
||||||
name = forms.CharField(max_length=80, label="Name", required=False)
|
name = forms.CharField(max_length=80, label="Name", required=False)
|
||||||
spirit = forms.TypedChoiceField(label="Spirit",
|
spirit = forms.TypedChoiceField(label="Spirit",
|
||||||
choices=Player.enumerate_spirit_names(),
|
choices=enumerate(Player.SPIRIT_NAMES),
|
||||||
empty_value=None, coerce=int)
|
empty_value=None, coerce=int)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -247,42 +247,18 @@ class Player(models.Model):
|
||||||
game = models.ForeignKey(Game, on_delete=models.CASCADE, db_index=True)
|
game = models.ForeignKey(Game, on_delete=models.CASCADE, db_index=True)
|
||||||
name = models.CharField(max_length=80)
|
name = models.CharField(max_length=80)
|
||||||
SPIRIT_NAMES = [
|
SPIRIT_NAMES = [
|
||||||
# From https://spiritislandwiki.com/index.php?title=List_of_Spirits
|
"Lightning's Swift Strike",
|
||||||
# Base game
|
"River Surges in Sunlight",
|
||||||
("Lightning's Swift Strike", "SI", "L"),
|
"Vital Strength of the Earth",
|
||||||
("River Surges in Sunlight", "SI", "L"),
|
"Shadows Flicker Like Flame",
|
||||||
("Vital Strength of the Earth", "SI", "L"),
|
"Thunderspeaker",
|
||||||
("Shadows Flicker Like Flame", "SI", "L"),
|
"A Spread of Rampant Green",
|
||||||
("Thunderspeaker", "SI", "M"),
|
"Ocean's Hungry Grasp",
|
||||||
("A Spread of Rampant Green", "SI", "M"),
|
"Bringer of Dreams and Nightmares",
|
||||||
("Ocean's Hungry Grasp", "SI", "H"),
|
"Keeper of the Forbidden Wilds",
|
||||||
("Bringer of Dreams and Nightmares", "SI", "H"),
|
"Sharp Fangs Behind the Leaves",
|
||||||
# Branch and Claw
|
"Serpent Slumbering Beneath the Island",
|
||||||
("Keeper of the Forbidden Wilds", "BC", "M"),
|
"Heart of the Wildfire",
|
||||||
("Sharp Fangs Behind the Leaves", "BC", "M"),
|
|
||||||
# Promo Pack 1
|
|
||||||
("Serpent Slumbering Beneath the Island", "P1", "H"),
|
|
||||||
("Heart of the Wildfire", "P1", "H"),
|
|
||||||
# Jagged Earth
|
|
||||||
("Stone's Unyielding Defiance", "JE", "M"),
|
|
||||||
("Shifting Memory of Ages", "JE", "M"),
|
|
||||||
("Grinning Trickster Stirs Up Trouble", "JE", "M"),
|
|
||||||
("Lure of the Deep Wilderness", "JE", "M"),
|
|
||||||
("Many Minds Move as One", "JE", "M"),
|
|
||||||
("Volcano Looming High", "JE", "M"),
|
|
||||||
("Shroud of Silent Mist", "JE", "H"),
|
|
||||||
("Vengeance as a Burning Plague", "JE", "H"),
|
|
||||||
("Starlight Seeks Its Form", "JE", "V"),
|
|
||||||
("Fractured Days Split the Sky", "JE", "V"),
|
|
||||||
# Promo Pack 2
|
|
||||||
("Downpour Drenches the World", "P2", "H"),
|
|
||||||
("Finder of Paths Unseen", "P2", "V"),
|
|
||||||
# Horizons of Spirit Island
|
|
||||||
("Devouring Teeth Lurk Underfoot", "HS", "L"),
|
|
||||||
("Eyes Watch From the Trees", "HS", "L"),
|
|
||||||
("Fathomless Mud of the Swamp", "HS", "L"),
|
|
||||||
("Rising Heat of Stone and Sand", "HS", "L"),
|
|
||||||
("Sun-Bright Whirlwind", "HS", "L"),
|
|
||||||
]
|
]
|
||||||
spirit = models.IntegerField()
|
spirit = models.IntegerField()
|
||||||
order = models.IntegerField()
|
order = models.IntegerField()
|
||||||
|
@ -291,12 +267,7 @@ class Player(models.Model):
|
||||||
unique_together = (("game", "name"), ("game", "order"))
|
unique_together = (("game", "name"), ("game", "order"))
|
||||||
|
|
||||||
def get_spirit_name(self):
|
def get_spirit_name(self):
|
||||||
return Player.SPIRIT_NAMES[self.spirit][0]
|
return Player.SPIRIT_NAMES[self.spirit]
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def enumerate_spirit_names():
|
|
||||||
return [(i, f"[{spirit[1]},{spirit[2]}] {spirit[0]}") for (i, spirit)
|
|
||||||
in enumerate(Player.SPIRIT_NAMES)]
|
|
||||||
|
|
||||||
|
|
||||||
class Phase(models.Model):
|
class Phase(models.Model):
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
|
from channels.http import AsgiHandler
|
||||||
from channels.routing import ProtocolTypeRouter, URLRouter
|
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||||
|
|
||||||
import django
|
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from django.core.asgi import get_asgi_application
|
|
||||||
|
|
||||||
# TODO Importing views breaks if django.setup() isn't called first...
|
|
||||||
# ... but this isn't the way this is supposed to work.
|
|
||||||
django.setup()
|
|
||||||
|
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
@ -14,8 +9,8 @@ application = ProtocolTypeRouter({
|
||||||
"http": URLRouter([
|
"http": URLRouter([
|
||||||
url(r'^(?P<access_code>[a-zA-Z]{6})/', URLRouter([
|
url(r'^(?P<access_code>[a-zA-Z]{6})/', URLRouter([
|
||||||
url(r"status/(?P<hashcode>[a-z0-9]{64})/",
|
url(r"status/(?P<hashcode>[a-z0-9]{64})/",
|
||||||
views.StatusLongPollConsumer.as_asgi(), name='status'),
|
views.StatusLongPollConsumer, name='status'),
|
||||||
])),
|
])),
|
||||||
url(r"", get_asgi_application()),
|
url(r"", AsgiHandler),
|
||||||
]),
|
]),
|
||||||
})
|
})
|
||||||
|
|
|
@ -81,7 +81,7 @@ def new_game(request):
|
||||||
form = NewGameForm()
|
form = NewGameForm()
|
||||||
|
|
||||||
initial_player_data = [{'spirit': i}
|
initial_player_data = [{'spirit': i}
|
||||||
for (i, _) in Player.enumerate_spirit_names()]
|
for i in enumerate(Player.SPIRIT_NAMES)]
|
||||||
formset = PlayerFormSet(initial=initial_player_data)
|
formset = PlayerFormSet(initial=initial_player_data)
|
||||||
for player_form in formset:
|
for player_form in formset:
|
||||||
player_form.player_id = int(player_form.prefix[5:]) + 1
|
player_form.player_id = int(player_form.prefix[5:]) + 1
|
||||||
|
@ -262,7 +262,7 @@ def handle_game_request(request, game, update):
|
||||||
f"#{effect_num} {effect_kind} " +
|
f"#{effect_num} {effect_kind} " +
|
||||||
"was changed by another user to " +
|
"was changed by another user to " +
|
||||||
f"{current_value}, so " +
|
f"{current_value}, so " +
|
||||||
"your attempt to change it from " +
|
f"your attempt to change it from " +
|
||||||
f"{orig} to {amount} " +
|
f"{orig} to {amount} " +
|
||||||
"was not processed.")
|
"was not processed.")
|
||||||
else:
|
else:
|
||||||
|
@ -377,7 +377,7 @@ class StatusLongPollConsumer(AsyncHttpConsumer):
|
||||||
|
|
||||||
async def fear_tracker_hashcode_seen(self, event):
|
async def fear_tracker_hashcode_seen(self, event):
|
||||||
if self.hashcode != event["hashcode"]:
|
if self.hashcode != event["hashcode"]:
|
||||||
if "status_string" in event and event["status_string"]:
|
if event["status_string"]:
|
||||||
body = event["status_string"].encode('utf-8')
|
body = event["status_string"].encode('utf-8')
|
||||||
await self.send_response(200, body)
|
await self.send_response(200, body)
|
||||||
await self.disconnect()
|
await self.disconnect()
|
||||||
|
|
|
@ -3,9 +3,10 @@ ASGI entrypoint. Configures Django and then runs the application
|
||||||
defined in the ASGI_APPLICATION setting.
|
defined in the ASGI_APPLICATION setting.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
import django
|
import django
|
||||||
|
from channels.routing import get_default_application
|
||||||
|
|
||||||
import fear_tracker.routing
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fear_tracker_site.settings")
|
||||||
|
|
||||||
django.setup()
|
django.setup()
|
||||||
application = fear_tracker.routing.application
|
application = get_default_application()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user