NEETzsche,
@NEETzsche@iddqd.social avatar

So, I wrote the first thing for Balormo's backend tonight. I wanted to do dice rolls, or really RNG (random number generation) broadly, and in this case I wrote the simplest form of it in the TTRPG space: rolling XdY, take the sum.

I did not write an FE for this yet. That's because I want to discuss the way I designed it. Now would be the time to refactor things or change around how it's structured. This is backend proof of concept phase.

For the time being, you can use curl to try it out once you have an account on dev.iddqd.social:

curl -X POST "https://dev.iddqd.social/api/v1/statuses" 
    -H "Authorization: Bearer REDACTED" 
    -H "Content-Type: multipart/form-data" 
    -F "status=Rolling CON for AD&D 2e style" 
    -F "source=Pleroma FE" 
    -F "visibility=public" 
    -F "content_type=text/plain" 
    -F "balormo[rng][system]=dice_sum" 
    -F "balormo[rng][denomination]=6" 
    -F "balormo[rng][quantity]=3"

You can find my commit for it here: https://gitgud.io/thestranjer/balormo/-/commit/483800ea9c2e5f913ecc5f1523625c9ad535917d

Unfortunately, Soapbox and Pleroma seem to drop the balormo object in federation. However, quite fortunately, it delivers the Object URL, which does retain that information:

{
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    "https://dev.iddqd.social/schemas/litepub-0.1.jsonld",
    {"@language": "und"}
  ],
  "actor": "https://dev.iddqd.social/users/NEETzsche",
  "attachment": [],
  "attributedTo": "https://dev.iddqd.social/users/NEETzsche",
  "balormo": {
    "rng": {
      "denomination": 6,
      "quantity": 3,
      "results": [1,1,6],
      "sum": 8,
      "system": "dice_sum"
    }
  },
  "cc": ["https://dev.iddqd.social/users/NEETzsche/followers"],
  "content": "Rolling CON for AD&amp;D 2e style<br/><i>Rolling 3d6, taking the sum.</i><br/><b>Results:</b> 1, 1, 6<br/><b>Sum:</b> 8",
  "context": "https://dev.iddqd.social/contexts/c2ceeca0-5369-41b9-8be7-2d0a647a7907",
  "conversation": "https://dev.iddqd.social/contexts/c2ceeca0-5369-41b9-8be7-2d0a647a7907",
  "id": "https://dev.iddqd.social/objects/48f97fc0-5a63-406f-8822-3ea4493713d9",
  "published": "2024-05-10T09:13:21.883623Z",
  "sensitive": null,
  "source": {
    "content": "Rolling CON for AD&D 2e style",
    "mediaType": "text/plain"
  },
  "summary": "",
  "tag": [],"to": ["https://www.w3.org/ns/activitystreams#Public"],
  "type": "Note"
}

The way I wrote this is you just add more fields to the /api/v1/statuses endpoint and give it extra fields. In this case, the system field can be changed and the pattern matching will pick up on the right one and then generate dice rolls etc in the right fashion. For example, I might write a Shadowrun dice roller that rolls d6s given only a pool value and re-rolls 6s until you don't get anymore.

The reason to bake this into the protocol is so that you can manage the data better and change the way it's displayed in the future. The appended roll text to the status will be put in a <div> with a class on it that's invisible for the FE.

Thoughts on how to improve this before I move on to the FE?

@sun @p @jeffcliff @rees @crunklord420 @caekislove @mint @LukeAlmighty @lain

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • rosin
  • thenastyranch
  • tacticalgear
  • ethstaker
  • InstantRegret
  • DreamBathrooms
  • ngwrru68w68
  • magazineikmin
  • Youngstown
  • mdbf
  • khanakhh
  • slotface
  • GTA5RPClips
  • kavyap
  • JUstTest
  • everett
  • cisconetworking
  • Durango
  • modclub
  • osvaldo12
  • tester
  • Leos
  • cubers
  • normalnudes
  • megavids
  • anitta
  • provamag3
  • lostlight
  • All magazines