Repository navigation
Feature/UI ux enhancements - #20
Conversation
…ools. Login and registration show labels, password rules, and one generic credential error. The match foreign key is fools again so admin ordering matches the app, while the database column stays game_id.
New accounts stay inactive until the confirmation link is opened, and that switch cannot be turned off when DEBUG is false. Password reset does not reveal whether an address exists, new usernames are short and case-insensitive, and registration, resend, and reset share a five-per-hour cap per IP and per address.
The nickname is shown once, with a link to the current match, the lobby, or the lobby list. Finished games, wins, losses, and win rate are on the page, and a player with no games is not shown a zero win rate. Changing an email still requires the current password. Changing a password emails the same reset link as the sign-in form.
Each public lobby shows its size, deck, and whether it is full, and the list updates as soon as one changes. Creating a lobby starts closed, asks for a password only when the room is private, and asks before leaving a lobby the player is already in. Joining another lobby asks the same way.
Bots sit in when the owner starts, cannot sign in, and choose moves through a replaceable strategy. The built-in one attacks, defends, throws in, takes, or passes the attack when transfer is allowed, always with the cheapest card the rule permits.
… still throw has had a say.
…p the hand, actions, and result together.
… and keep the hand in place when the table updates.
…the right player, and keep the seats, history, and a new deal with whoever is still at the table.
…s they are dealt, light only a legal drop, and refuse a take after the table is already beaten.
…deck cannot deal six cards to every seat, and free bot chairs when the match ends.
…hen two players pass the attack, let a bot throw on a beaten rank, and keep the phone menu and table usable.
…hen every person is ready, and pass the room to whoever sat down first.
Allow hosts to update gameplay rules while a lobby is waiting, with seat and deck validation and readiness reset on changes. Record updates as system chat notices and expose the settings editor in the lobby UI.
Keep dragged cards selected during drag operations and show visual error feedback when a play or defense is invalid. Handle drops consistently so invalid actions can display a clear message.
Keep extra attack rows within the felt without vertical scrolling, and adjust pile and card sizing and positioning for medium-width screens.
… table on a phone. Surrender ends the match and returns the lobby to waiting without removing that player. Direct, lobby, and table chat share one paged history with a read mark, username search, and a public player page. On the table, the log and chat sit on the felt, and the phone controls, opponents, and hand sit closer together.
…ward the center, and keep side seats level with the felt. On a phone, tighten the lobby list and the space under that summary, and drop the empty-deck label.
Make chat screens fit the viewport, improve mobile layouts and controls, and add client-side inbox filtering that preserves the query across navigation. Update template tests and include scripts and captured footage for a product demo.
| # Static and media | ||
| staticfiles/ | ||
| static/ | ||
| /static/ # only root-level static/, if you ever add one |
There was a problem hiding this comment.
| /static/ # only root-level static/, if you ever add one | |
| /static/ # only root-level static/ |
| /** | ||
| * Login and registration forms: field checks, password rules, show/hide, submit state. | ||
| * Server-side validation remains the source of truth. This script only | ||
| * explains failures earlier and does not block paste or password managers. | ||
| */ |
There was a problem hiding this comment.
| /** | |
| * Login and registration forms: field checks, password rules, show/hide, submit state. | |
| * Server-side validation remains the source of truth. This script only | |
| * explains failures earlier and does not block paste or password managers. | |
| */ | |
| /** | |
| * Login and registration forms: field checks, password rules, submit state. | |
| * This script only adds local checks in addition to server validation. | |
| */ |
| setRule("length", value.length >= minLength ? "met" : (showFailures ? "unmet" : "idle")); | ||
| setRule("numeric", /^[0-9]+$/.test(value) ? (showFailures ? "unmet" : "idle") : "met"); | ||
| if (tooSimilar(value)) setRule("similar", showFailures ? "unmet" : "idle"); | ||
| else if (identityParts().length) setRule("similar", "met"); | ||
| else setRule("similar", "idle"); | ||
| } | ||
| var sameAsServer = password && password.value === initial[passwordKey] && serverMessages[passwordKey]; | ||
| if (sameAsServer) applyServerRules(); | ||
| else setRule("common", "pending"); | ||
| } | ||
|
|
||
| function applyServerRules() { | ||
| var messages = [] | ||
| .concat(serverMessages[passwordKey] || []) | ||
| .concat(serverMessages[confirmKey] || []); | ||
| var text = messages.join(" ").toLowerCase(); | ||
| if (!text) return; | ||
| if (text.indexOf("too short") !== -1 || text.indexOf("at least") !== -1) setRule("length", "unmet"); | ||
| if (text.indexOf("entirely numeric") !== -1 || text.indexOf("only numbers") !== -1) setRule("numeric", "unmet"); | ||
| if (text.indexOf("too similar") !== -1 || text.indexOf("less similar") !== -1) setRule("similar", "unmet"); | ||
| if (text.indexOf("too common") !== -1 || text.indexOf("common password") !== -1) setRule("common", "unmet"); | ||
| } | ||
|
|
||
| function passwordMessage(value, showFailures) { | ||
| if (!value) return "Enter a password."; | ||
| if (value.length > maxLength) return "Use " + maxLength + " characters or fewer."; |
There was a problem hiding this comment.
value.length counts UTF-16 code units, while the server-side len(password) in Python counts Unicode code points. As a result, a valid password—for example, one containing 65 emoji—will be incorrectly rejected in the browser as exceeding the 128-character limit. The minimum-length indicator can also be inaccurate. Use a code-point count, such as Array.from(value).length, for both length checks.
| """Business logic for multiplayer Durak (podkidnoy). | ||
|
|
||
| This module owns lobby lifecycle, dealing from the shared card pool, table | ||
| phases (build / defend / between), and persistence updates on existing Django | ||
| models. It also triggers WebSocket broadcasts via :mod:`fools.realtime`. | ||
|
|
||
| Typical flow: | ||
| #. Players create or join a lobby, toggle ready, owner calls ``start_game``. | ||
| #. Attacker opens from ``between`` into ``build``. While the wave is on the table, | ||
| the defender may ``defend`` or ``take_table`` at any time; the attacker and | ||
| other players may still ``play_attack`` (throw-ins) in parallel—no separate | ||
| ``defend`` phase gate. ``take_table`` only declares the take: the cards move | ||
| after every player who can still throw in confirms with ``pass_throw``. | ||
| #. After the table is fully beaten, attacker ``bito`` discards and rotates roles. | ||
| """ |
There was a problem hiding this comment.
| """Business logic for multiplayer Durak (podkidnoy). | |
| This module owns lobby lifecycle, dealing from the shared card pool, table | |
| phases (build / defend / between), and persistence updates on existing Django | |
| models. It also triggers WebSocket broadcasts via :mod:`fools.realtime`. | |
| Typical flow: | |
| #. Players create or join a lobby, toggle ready, owner calls ``start_game``. | |
| #. Attacker opens from ``between`` into ``build``. While the wave is on the table, | |
| the defender may ``defend`` or ``take_table`` at any time; the attacker and | |
| other players may still ``play_attack`` (throw-ins) in parallel—no separate | |
| ``defend`` phase gate. ``take_table`` only declares the take: the cards move | |
| after every player who can still throw in confirms with ``pass_throw``. | |
| #. After the table is fully beaten, attacker ``bito`` discards and rotates roles. | |
| """ | |
| """Business logic for Fool's Arena. | |
| This module owns lobby lifecycle, dealing from the shared card pool, table | |
| phases (build, defend, between), and persistence updates on existing Django | |
| models. It also triggers WebSocket broadcasts via fools.realtime. | |
| Typical flow: | |
| #. Players create or join a lobby, toggle ready, owner calls ``start_game``. | |
| #. Attacker opens from ``between`` into ``build``. While the wave is on the table, | |
| the defender may ``defend`` or ``take_table`` at any time; the attacker and | |
| other players may still ``play_attack`` (throw-ins) in parallel—no separate | |
| ``defend`` phase gate. ``take_table`` only declares the take: the cards move | |
| after every player who can still throw in confirms with ``pass_throw``. | |
| #. After the table is fully beaten, attacker ``bito`` discards and rotates roles. | |
| """ |
| from chat.services import ( | ||
| broadcast_chat_message, | ||
| get_lobby_chat, | ||
| message_payload, | ||
| record_lobby_notice, | ||
| remove_user_from_lobby_chat, | ||
| ) | ||
| from fools.card_catalog import ensure_playing_cards_for_deck_size | ||
| from fools.realtime import broadcast_game, broadcast_lobby, broadcast_lobby_list |
There was a problem hiding this comment.
| from chat.services import ( | |
| broadcast_chat_message, | |
| get_lobby_chat, | |
| message_payload, | |
| record_lobby_notice, | |
| remove_user_from_lobby_chat, | |
| ) | |
| from fools.card_catalog import ensure_playing_cards_for_deck_size | |
| from fools.realtime import broadcast_game, broadcast_lobby, broadcast_lobby_list | |
| from fools.card_catalog import ensure_playing_cards_for_deck_size | |
| from fools.realtime import broadcast_game, broadcast_lobby, broadcast_lobby_list | |
| from chat.services import ( | |
| broadcast_chat_message, | |
| get_lobby_chat, | |
| message_payload, | |
| record_lobby_notice, | |
| remove_user_from_lobby_chat, | |
| ) |
|
|
||
| def compatibility_display(self, obj): | ||
| """Display game compatibility information. | ||
| """Display fools compatibility information. |
There was a problem hiding this comment.
| """Display fools compatibility information. | |
| """Display game compatibility information. |
| """Admin interface for the GameDeck model. | ||
|
|
||
| Basic management interface for game deck cards with position tracking. | ||
| Basic management interface for fools deck cards with position tracking. |
There was a problem hiding this comment.
| Basic management interface for fools deck cards with position tracking. | |
| Basic management interface for game deck cards with position tracking. |
| """Admin interface for the Turn model. | ||
|
|
||
| Management interface for game turns with move tracking. | ||
| Management interface for fools turns with move tracking. |
There was a problem hiding this comment.
| Management interface for fools turns with move tracking. | |
| Management interface for game turns with move tracking. |
| @@ -0,0 +1,368 @@ | |||
| /** | |||
| * Shared chat history: grouping, stick-to-bottom, older pages, and read marks. | |||
| * Direct chats, the lobby, and the table all use this so those parts match. | |||
There was a problem hiding this comment.
| * Direct chats, the lobby, and the table all use this so those parts match. | |
| * Direct messages, the lobby chat, and the game chat all use this so those parts match. |
| var grouped = previous | ||
| && kind !== "system" | ||
| && previous.kind !== "system" | ||
| && sender | ||
| && sender === previous.sender | ||
| && !isNaN(sent.getTime()) | ||
| && !isNaN(previous.sent.getTime()) | ||
| && sent.getTime() - previous.sent.getTime() < GROUP_MS | ||
| && sent.getTime() >= previous.sent.getTime(); |
There was a problem hiding this comment.
| var grouped = previous | |
| && kind !== "system" | |
| && previous.kind !== "system" | |
| && sender | |
| && sender === previous.sender | |
| && !isNaN(sent.getTime()) | |
| && !isNaN(previous.sent.getTime()) | |
| && sent.getTime() - previous.sent.getTime() < GROUP_MS | |
| && sent.getTime() >= previous.sent.getTime(); | |
| var hasPrevious = !!previous; | |
| var notSystem = hasPrevious | |
| && kind !== "system" && previous.kind !== "system"; | |
| var sameUser = hasPrevious | |
| && sender && sender === previous.sender; | |
| var sameTimeGroup = hasPrevious | |
| && !isNaN(sent.getTime()) | |
| && !isNaN(previous.sent.getTime()) | |
| && sent.getTime() - previous.sent.getTime() < GROUP_MS | |
| && sent.getTime() >= previous.sent.getTime(); | |
| var grouped = notSystem | |
| && sameUser && sameTimeGroup; |
Give messages distinct sent_at values so ordering tests do not depend on identical timestamps.
The workflow was forcing production settings, so pytest ignored the in-memory cache and channel layer and tried to resolve the Docker host redis.
No description provided.