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

Add card preview match chat #250

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DanieloV
Copy link
Contributor

@DanieloV DanieloV commented Sep 6, 2024

Code:
The implementation is quite ugly, but at least it can be added to all the places needed step by step. Only changed in a few places for now.
Unsure where to put the formatting method though.

Result:
This should help with making the match chat more informative of what's going on.
Screenshot 2024-09-06 at 20 35 42

@sindreslungaard
Copy link
Owner

I wonder if this could be done on the client-side only so that we don't have to refactor all the existing chat messages. Maybe the json file with card data from #247 can be added to the frontend (or the API response) and used to match against the incoming chat messages? Could also be nice if we want to add some card name autocomplete to admin commands and the lobby chat down the road.

There's surely better ways of doing this but here's one idea for how it could be implemented without being super slow:

// Generated from the json data or API data
const cardNames = {
    "Forbos,": "Forbos, Sanctum Guardian Q", // maybe add the image id to the value as well
    ...
}

function incomingChatMessage(msg) {
    const words = msg.toLowerCase().split(" ");
    const potentialCardsInMessage = [];


    for(const word of words) {
        if(cardNames[word]) {
            potentialCardsInMessage.push(cardNames[word])
        }
    }

    for(card of cardsInMessage) {
        msg.replace(card, "some-formatted-version-of-the-cardname-and-image-id")
    }
}

@DanieloV
Copy link
Contributor Author

I think this is a good idea, but will require to change quite a few things. Will park this until I get to it again, and made sure nothing depends on it anymore.

@DanieloV DanieloV force-pushed the add-card-preview-match-chat branch from 667455f to 537882d Compare September 15, 2024 15:42
@DanieloV DanieloV marked this pull request as draft September 15, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants