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

Adding more Card-Sets from CrCast #342

Open
basti79 opened this issue Mar 18, 2022 · 6 comments
Open

Adding more Card-Sets from CrCast #342

basti79 opened this issue Mar 18, 2022 · 6 comments
Labels
deck-sources Suggestions for new places to get decks to play with. enhancement A suggestion for a new feature or expansion of an existing feature. good-first-issue This issue would be a good one to pick if you want to contribute but are not sure where to start.

Comments

@basti79
Copy link

basti79 commented Mar 18, 2022

Describe the feature

Hi, it would be nice if you could add CrCast (https://cast.clrtd.com/) to the list of deck sources. They also feature a JSON API (see https://cast.clrtd.com/api) with seems not so different from Many Decks, so i hope it would be not so complicated.

Greets,
Sebastian.

@basti79 basti79 added the enhancement A suggestion for a new feature or expansion of an existing feature. label Mar 18, 2022
@Lattyware
Copy link
Owner

Sounds like a good source, and the API is set up to mimic CardCast's, so it should be pretty simple to port across the old CardCast code to their site.

I jumped onto their Discord and checked this would be OK with them, they gave the green light, only point of note being:

use crcast.cc instead of cast.clrtd.com

I don't know when I'd get a chance to implement this, but it should be pretty simple to do, so if someone wants to pick it up, please feel free.

@Lattyware Lattyware added good-first-issue This issue would be a good one to pick if you want to contribute but are not sure where to start. deck-sources Suggestions for new places to get decks to play with. labels Mar 18, 2022
@lhvy
Copy link
Contributor

lhvy commented Mar 20, 2022

Working on it in f012004. Making good progress, just need to do some code clean-up etc. Problems so far:

  • CrCast seems to be less strict on formatting and also doesn't support new lines, so some cards don't look awesome and depending on the decks, capitalisation and punctuation is wrong.
  • CrCast has cards that are in the format [img]https://example.com/picture.jpg[/img], which are supposed to display as images, but Massive Decks just displays the text.

@yannibo
Copy link

yannibo commented Mar 22, 2022

We've changed domains to crcast.cc domains. The old ones still work for everything that is still using them.
The new domain of the API is https://api.crcast.cc.

And i * think * we don't really format the text of cards, but i've noticed the issue with newlines. When requesting a deck from the API the text is fine, but the frontend doesn't show the newlines for some reason.

@lhvy
Copy link
Contributor

lhvy commented Apr 6, 2022

When requesting a deck from the API the text is fine

As far as I can tell, none of the decks on CrCast actually have newlines? My memory is a bit foggy now as to whether or not the json format had support for multiple lines. I couldn't find any example decks that had them.

This is the CrCast example API deck's cards in json: https://api.crcast.cc/cc/decks/VD5MM/cards

Would you be able to explain the format?

{
  "error": 0,
  "calls": [
    {
      "text": [
        "Black Card",
        "with",
        "multiple underscores",
        ""
      ]
    },
    {
      "text": [
        "Black Card without underscore",
        ""
      ]
    },
    {
      "text": [
        "Black Card with underscore",
        ""
      ]
    }
  ],
  "responses": [
    {
      "text": [
        "White Card 1"
      ]
    },
    . . .
  ]
}

I'm assuming that each text element in the calls text arrays should have an underscore after it, and the empty string is there to show an underscore is needed? So how is a new line signified? Also should I make any assumptions about formatting (punctuation, capitals etc), or just trust the json and only put a space and then an underline after each element in the calls text array?

For the responses, there's a text array that I don't think I saw utilised. Is the array for multiple lines? I've only really seen single element arrays when looking at decks.

@yannibo
Copy link

yannibo commented Apr 6, 2022

The endpoints starting with /cc are there to imitate the old cardcast api.
Originally those consisted of two endpoints for the deck information and the cards of a deck:
https://api.crcast.cc/v1/cc/decks/VD5MM
https://api.crcast.cc/v1/cc/decks/VD5MM/cards

We then added another endpoint, which just combines the output of the 2 above in one single endpoint:

https://api.crcast.cc/v1/cc/decks/VD5MM/all

Would you be able to explain the format?

The array "calls" contains all black cards. Every black card is an object with a text array. Underscores should be between every string in the text array and empty strings are just there to indicate an underscore at the end of a text.

In the end the text of a black card can be merged by this example javascript code:

var card = { text: ["Black Card", "with", "multiple underscores", ""] };
var bcText = card.text.join(" ___ ");
console.log(bcText);
// Black Card ___ with ___ multiple underscores ___

The "responses" array contains all white cards. White cards only have one element in the text array because they don't have "spaces for cards". So the array always contains only one string.

So how is a new line signified?

Newlines are just "\n" in the strings. I have updated the test deck to include cards with multiple lines.

Also should I make any assumptions about formatting (punctuation, capitals etc), or just trust the json and only put a space and then an underline after each element in the calls text array?

We generally don't format texts. So they should be like a user has put them in.

We also have another endpoint next to the cardcast endpoints, which uses a different json format:

https://api.crcast.cc/v1/VD5MM

This endpoint returns information about a deck and the cards it contains in one endpoint but formatted differently. Instead of splitting it and returning it as an array it just returns it as a single string. Underscores are just single underscores in the string and newlines are indicated by "\n".

Example response from https://api.crcast.cc/v1/VD5MM
{
"error": 0,
"deck": {
  "deckcode": "VD5MM",
  "name": "Test Deck",
  "description": "This is a Deck to test the API Endpoints",
  "language": "en",
  "nsfw": 0,
  "blacks": [
    {
      "text": "Black Cards _ with underscores _ and newlines:\nsecond line\nthird line with underscore _"
    },
    {
      "text": "Black Card _ with _ multiple underscores _"
    },
    {
      "text": "Black Card without underscore"
    },
    {
      "text": "Black Card with underscore _"
    }
  ],
  "whites": [
    {
      "text": "White Card with multiple lines:\nsecond line\nthird line"
    },
    {
      "text": "White Card 1"
    },
    {
      "text": "White Card 2"
    },
    {
      "text": "White Card 3"
    }
  ]
}
}

I know that our documentation is "not good", but we are working on it to include more details about possible responses and so on.

@Lattyware
Copy link
Owner

Also worth looking at the old code from when CardCast was up, as it was working with that format so a lot of it should be reusable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deck-sources Suggestions for new places to get decks to play with. enhancement A suggestion for a new feature or expansion of an existing feature. good-first-issue This issue would be a good one to pick if you want to contribute but are not sure where to start.
Projects
None yet
Development

No branches or pull requests

4 participants