Open devgianlu opened 4 years ago
Four commands are now available (could be changed to buttons):
/addcustomdeck_json
: Adds a deck from the JSON provided (must change to file upload)/addcustomdeck_url
: Adds a deck from an URL/removecustomdeck
: Remove a deck with the given ID/listcustomdecks
: List available decksI've intentionally kept the Cardcast JSON format to allow for some kind of retro-compatibility if someone had downloaded his decks.
The main two problems are:
We could easy cache the URLs, but not the JSON. I was thinking to use some digest like MD5 to check if we already have the exact same content, or maybe that's not even that useful. My app would probably benefit from this as I'd allow the user to create custom decks without uploading them.
I've removed the two add commands and added some buttons in the game options. I am going to make a better list of the custom sets so that commands are not needed anymore (this way we don't have to show the user the deck id which is just a number).
The hash method is not working reliably for caching because of newlines and formatting stuff so we need an alternative to identify if two decks are identical. We would need to parse the content and then compute the hash after it has been "normalized" (something like https://github.com/fraunhoferfokus/JSum) which is a bit more expensive in terms of computing, but I don't think it'll be an issue.
I was also thinking that we probably don't need the server to fetch URLs, we could let the user send the JSON (fetching on the client). The only downside is that of the hash mentioned above.
@ajanata Let me know what you think.
Daily update...
I've fixed the caching issue with bencode. I've added some UI elements to list the custom decks and allow to remove them with a button press.
I'd say this is almost complete.
@ajanata Have you been able to take a look at this?
Don't know how it looks for you, but here the 'Custom Card Sets' prevents the use of the buttons regardless of browser or monitor resolution. Tested on pyx.gianlu.xyz
.
@Tibladar It's fine on 1600x900 and 1920x1080, but I suppose I can address in some way.
Should be good now.
Should be good now.
Yep, working fine.
a converter from xyzzy metrics csv format to this json format:
import os
import json
import html
rootdir = "csv"
def process_file(path, filename):
filename_parts = filename.split('.')
name = filename_parts[0]
json_filename = '.'.join(filename_parts[:-1]) + '.json'
doc = dict()
doc['name'] = name
doc['description'] = 'no description'
doc['watermark'] = name
with open(path, 'r', encoding='utf-8') as infile:
with open('json/' + json_filename, 'w', encoding='utf-8') as outfile:
calls = []
responses = []
for line in infile:
line = html.unescape(line)
parts = line.split(',')
wb = parts[0]
text = ','.join(parts[1:-2])
if wb == 'white':
responses.append(text)
else:
calls.append(text)
doc['calls'] = []
doc['responses'] = []
for call in calls:
parts = call.split('____')
if len(parts) > 1:
doc['calls'].append({ 'text' : parts })
for response in responses:
doc['responses'].append({ 'text' : [response] })
outfile.write(json.dumps(doc, sort_keys=True, indent=4))
for subdir, dirs, files in os.walk(rootdir):
for file in files:
filepath = subdir + os.sep + file
if filepath.endswith(".csv"):
process_file(filepath, file)
script in .convert.py
, csvs in csv/*.csv
, produces json files in json/*.json
Getting this error whenever I'm trying to upload a JSON deck. Error: Cannot find custom deck with the given ID or URL or invalid JSON was provided.
Getting this error whenever I'm trying to upload a JSON deck. Error: Cannot find custom deck with the given ID or URL or invalid JSON was provided.
@silverkey5 Can you post the URL or JSON you tried to use?
{
{ "calls": [ { "text": [ "Ashido's secret passion is ", "." ] }, { "text": [ "Dear Midoriya, I'm having issues with ", " and would like some advice." ] }, { "text": [ "For Mr. Compress's next trick, he will pull ", " out of ", "!" ] }, { "text": [ "In his farewell speech, All Might warned young heroes about the dangers of ", "." ] }, { "text": [ "Bakugou masturbates to ", "." ] }, { "text": [ "Dabi ate ", " for dinner." ] } ], "description": "no description", "name": "test", "responses": [], "watermark": "test" } }<
I've also tried uploading this to a URL, but when I used the /addurl command it said it was an invalid command https://api.jsonbin.io/b/60b3d22692af611956f6a26c/1
@silverkey5 The watermark must be all uppercase.
{ "name": "testDeck", "description": "bnha stuff", "watermark": "BNHA", "calls": [ { "text": [ "Ashido's secret passion is ", "." ] }, { "text": [ "Dear Midoriya, I'm having issues with ", " and would like some advice." ] }, { "text": [ "For Mr. Compress's next trick, he will pull ", " out of ", "!" ] }, { "text": [ "In his farewell speech, All Might warned young heroes about the dangers of ", "." ] }, { "text": [ "Bakugou masturbates to ", "." ] }, { "text": [ "Dabi ate ", " for dinner." ] } ]
}
It still returns the same error message
It must also be 5 characters long.
...im just dumb lol thank you so much!
Any update on this?
This PR aims to replace the functionality provided by the dead CardCast website. See #240
Play with custom decks at https://pyx.gianlu.xyz/ZY/.
TODO:
JSON template: