saif-ellafi / foundryvtt-mythic-gme

Mythic GM Emulator Macros and Roll Tables
Other
27 stars 15 forks source link

Feature Request "better-rolltables" integration #4

Closed klaas1979 closed 2 years ago

klaas1979 commented 2 years ago

I love what you have done with this module so far. I started with an implementation of the Mythic Adventure Crafter to use in a gamemaster less tabletop game. I am using Mythic Variation 2 and created the tables for the Turning Points as described in Adventure Crafter. A Turning Point is used instead of a random event, if the Variations 2 and Adventure Crafter a mixed.

For the Turning Point I need https://github.com/ultrakorne/better-rolltables because 4 results need to be generated for a single Turning Point. I created a table as replacement for the Event and used the settings to have it used instead of the standard table.

The culprit is, that the module uses the standard tables or the standard way to get the results. This leads to a single result retrieved from my better-rolltable regardless what I do. I tried to figure out how to easily support better-rolltables, but came to the conclusion to ask for help before continuing.

Do you plan to support Mythic Adventure Crafter?

Or is it possible to support better-rolltables and add multiple results from a table roll to the Chat? I tracked it down to the method _mgeGetOracleAnswers. There you use

const focusTable = await _mgeFindTableBySetting('focusTable');
focusRoll = await focusTable.roll();
focusResult = focusRoll.results[0].getChatText();

with https://github.com/ultrakorne/better-rolltables/wiki/API-for-macros-and-modules the results are directly added to the chat and not returned. After checking the source basically the better-rolltables API is not enough, but the results need to be retrieved with code like in betterTableRoll method.

Maybe better-rolltables is useful for this module as well, as it provides some nice features for more complex table design.

saif-ellafi commented 2 years ago

Hey @klaas1979 - Thank you for this. I see many options with various pros and cons:

  1. Having to define what "Support Better Rolltables" means, but in general to me unfortunately it would be tons of over complication to support a module for which all the content relies on another community module, unfortunately. So staying with core-functionality gives me sanity of mind (what happens on updates, what if it is no longer maintained, what if it breaks, what if people don't want to, etc.). So I am a bit little-to-none inclined towards modifying this module's data to one of another community module's format (Though I have to say I haven't checked it out in detail, will do and remain open minded).

  2. An alternative would be to, as you suggest, support Locations Crafter (if you submit your Pull Request I will be forever thankful :-), I love contributions!) ), though that would also mean that for every content we would need support of this module, which in my opinion, it could be better if users like you had the power to do it quite possible (is it still within the bounds of this module?)

  3. Last but not least, I was thinking perhaps a "generic" macro, that can take -n- amount of tables that takes each of the tables results and combines them into a single chat entry, with the bells and whistles of this module. Would this help you in this case? Or would you need special conditions on the outcomes between tables?

PS. This module is a bit of a mess into how it is written :). I did not expect it to grow that much in the first place. So at some point I will be considering a cleanup-redesign, maybe sooner rather than later. Re-utilization is slightly good since most of the macros here share their functions, so it should not be a big deal either, but any ideas on integration are welcome!

klaas1979 commented 2 years ago

great ideas, what could be done:

  1. have the support to better-rolltables added as you have added the support to the 3D roll module. If installed it is used. Alternatively adding a setting to use the better-rolltables if present, then the support problems what be a smaller issue, because the fallback to the FoundryVTT base tables is present. In my mind it would be a single additional method where all the logic is added to, that uses the standard tables or the betterroll tables.
  2. I meant Adventure Crafter, but maybe Location Crafter could be added as well. I was a dev years ago and just started playing again with kids, so I am not really sure, if I can pull this off. At least I have installed a JavaScript environment yesterday, maybe I try it, but I guess it is 10% that I make it :)
  3. I guess this addresses most stuff in the best possible way. Users could switch out most tables easy and add functionality via a Macro that is called, great stuff. I do not know Foundry API and inner workings at all, could you provide an example for the interface API of the Macro? In my opinion it would be some general processing with the result given back to a method in your module? Javascript was never my prime language so I am at a loss here.

Yeah I read the module and others and thought, it could be cleaned up and sorted a bit. Maybe with some more intuitive structure it would be easier to add to it for outsiders.

TLDR:

  1. I would love a generic interface that is called and gives result back that is then included.
  2. I would envision to use the settings to select the Macro or Table. I.e. extending the selection you already have.
  3. It would be great to have some formatting options: My example is a long result, it is underlined and bold, would be great to have only the Name underlined and bold and the explanation text without any formatting. Maybe you just take the text with formatting already applied?
  4. This could then be used to switch out other tables as well. I use the short name and the description a lot. I could provide german translations. Could help to stitch something together.

Last thought: You would need to support Adventure Crafter a bit. The rules how Mythic is changed and Random Events are replaced by Turning Point result in one Table rolled 4-times. Mythic roles 3 different tables, this will never match.

Any thoughts with that you can work?

saif-ellafi commented 2 years ago

heh, tons of good info! My original plans for the moment were:

  1. Sit back and play with the module a bit myself (That is why it was created, right :D)
  2. Freeze the feature set a bit, and take any programming time into re-structuring the module for flexibility and modularity, so it can grow further. Not only the structure, but also take the HTML code out and use templates and handlebars.

My suggestion would be to wait until the reorganization of the module, before expanding it. However I am open for either better-rolltables support as you suggested (opt-in) and/or an extra, final generic macro that can take both tables and macros (I loved your idea of being able to choose macros! Haven't thought of that).

For Adventure Crafter I recommend to wait, at least until the refactor is done. In the refactor we can also replace strings with translations code for translation support! German translations are welcome, I can help with Spanish aber mein Deutsch ist noch nicht da :D - Finally, I have not read the Adventure Crafter so if you have thoughts in mind, all welcome.

If you are planning on hacking-coding-stuff do let me know so we don't work twice on that, it is really appreciated if you come up with ideas. My only advice is to NOT learn from my javascript. I am a very ugly-pragmatic programmer!

saif-ellafi commented 2 years ago

For better-rolltables support I can patch something up quick so you can at least play that setup you are playing! :)

saif-ellafi commented 2 years ago

Ok, I have took some time to investigate Better Rolltables - @klaas1979 Unfortunately, I cannot support it :( (I promise I went with an open mind). It is mostly for technical reasons, but the biggest one is that it is too far away from Foundry's API for Random Table. It has its own set of classes and API functions and the returned properties of the tables are very specific to what the author wants to achieve with the library, which is not very standardized.

Some more details:

  1. game.betterTables is utilized to roll, and not from the tables themselves. This is fine, although it means we are outside of Foundry's territory when it comes to the API.
  2. Mostly three functions from the API I could find of use that we could use for Mythic Tools logic, none of them return or comply to Foundry's standard API for random tables. For example, getBetterTableResults() returns an object with no properties, for which data only includes the range of the result and the text of the result. No elements of the Roll object by Foundry is included, so from which in Mythic I am unable to utilize as I need the outcome details of the dice rolled. roll() on the other hand seems transient and does not include roll data at all. I guess this is not meant to be used. betterTableRoll() is the one I hoped for but is actually void so it does not give any return info value at all, but directly dumping into the chat.
  3. The standard API in Foundry supports multiple drawing, with draw() and drawMany() these are the ones that we should be using and return detail properties of the outcome. I was hoping Better Random Tables used this, but it is unfortunately not the case.
  4. With such a specific API, we would lose control over my module's "Flavor" (Control over the chat output, control over 3D dice, control of timing, control over the HTML output of random table draws, and parsing modifiers, etc), so we would lose more than winning.

With these 3 points, I cannot implement "generic" random table logic, since Better RandomTables is way too unique for its own purpose. And its purpose is not entirely a generic approach, but rather a design centered around the concept of loot. Foundry on its own has enough capabilities to achieve what you are looking for (drawing multiple times by using drawMany(n)) and we could solve that on Mythic GME Tools itself. My two cents!

klaas1979 commented 2 years ago

I see your point and changed the tables to work without better roll table. Thank you for checking it out. In the end I tried better rolltables for all features besides loot, so it is not useful to build on it. Change is working well, just needed to have a second table rolling 4x on the Turning Point Table (if using a table). Then the roll is not helpful with a 1d1 and 4x range 1-1, but it is working great. With a macro I can just roll 4 times and be fine.

I did not find a drawMany() in the UI, but if it works programatically this is great.

So as you suggested it would be great to have a way to overwrite the "event stuff" to not roll on the three default tables as of now but to replace this with a the 4x rolls on the Turning Point Table.

A turning point result as example: CONCLUSION: If this Turning Point is currently a Plotline Development, then it becomes a Plotline Conclusion. Incorporate anything necessary into this Turning Point to end this Plotline and remove it from the Plotlines List. If this Turning Point is a New Plotline or already a Conclusion, then consider this Plot Point a None.

I thought about having a verbose option with the explanation and having a short option (everything till the ":"). I would have parsed the text result split at first ":" and have everything before as heading and anything after as description. It would be great to have a setting with vebose and non verbose results. Then I could fix my own tables to be verbose, so that I do not need the PDF along with Foundry.

Could you provide this integration point somehow?

saif-ellafi commented 2 years ago

Indeed, I am planning something that will be ready in a while tonight! stay tuned. However for the long text flavors, I love the idea! You gave me great ideas, so will be writing them down! Maybe in the future we can enter flavor content where the result of our macros rather fill in the gaps.

One big point to consider, is that since this module is approved for redistribution, we cannot include descriptions or content, so for that the players owner of the book can fill the descriptions themselves. But at least for the tables we got permission.

saif-ellafi commented 2 years ago

Hey @klaas1979 ! I have released 2.2.0 with an Oracle Builder if you may test it and let me know your thoughts :) image

klaas1979 commented 2 years ago

I guess I am stupid, but I do not find the button/place to start it. In Settings I cannot choose it. Did you add this to a compendium as Macro or where do I start it?

Looks great and presumeable fix the whole request :)

saif-ellafi commented 2 years ago

Yes, as a Macro along the core Macros! Is it not? Will check in a moment. It is called Oracle Builder

saif-ellafi commented 2 years ago

@klaas1979 any luck?

klaas1979 commented 2 years ago

Yeah now the update worked, it is working like a charm :) Now it would be needed to switch the Random Event to a Marcro and then it would be integrated completely with Adventure Crafter

saif-ellafi commented 2 years ago

Yes I thought about that it would be very easy to add other macros in between but I am not sure because each of them has its own output and inputs...

klaas1979 commented 2 years ago

If you have the configurator. You could (easily?!) store the tables as a configuration in json. Then you could add these configurations as selection in the Settings for the table selection. It would need some rework to select because you would need to have more configuration. I.e. for the standard random event three tables configured. For the other roles with two tables, both tables configured etc.

But then, you would have free configureabeability and all input/output would be in the hand of the module. Would this work?

Then the settings would probably fire up a configuration dialog to select the correct tables. With a reset button the standard json-config could be restored.

saif-ellafi commented 2 years ago

Are you sure it is not over complicated? Because if you import the tables from the macros you can already select them in the oracle builder.

klaas1979 commented 2 years ago

I played a bit with it and changed some code. It could be very easy to use the oracle builder and add the created tables to the configuration for the world:

const tables = Object.fromEntries((await _mgeGetAllPacks())
.concat(game.tables.contents)
.concat(game.macros.contents) // adds all macros including the one from the oracle
.filter(e => e.name.startsWith('Mythic'))
.map(e => [e.name, e.name]));

Naming the macros with "Mythic" includes them in the selection. Then the settings can select the newly created Macro. Now the "problem" is that the random event has multiple tables rolled upon (eventFocus and the two descriptions for it). This would be needed to change to replace the random event with the Adventure Crafter Turning Point. It is called here, but the change would be somewhere else:

async function _mgeSubmitOracleQuestion(eventTitle, useSpeaker, eventFocus, tableSetting1, tableSetting2, baseChat) { const randomAnswers = await _mgeGetOracleAnswers(eventFocus, tableSetting1, tableSetting2);

To change this I envisioned to not create macros but configure random events etc. in the settings via the Oracle Builder. But in the end I am not really deep into foundry API and module development, so it was my first idea.

saif-ellafi commented 2 years ago

Hmm I am a bit confused now. What is exactly not possible to achieve with just the Oracle Builder, and placing Turning Points content as tables, instead of macros?

saif-ellafi commented 2 years ago

For the sake of posterity, let's close this issue here. We can continue either in a new issue for changes that allow the Adventure Crafter, and or continue in Discord (Either FoundryVTT, Die Gießerei or Mythic Game Master Emulator) servers for a more open discussion!

klaas1979 commented 2 years ago

Thank you. I try to build an example to make it clear. Will take some time.

saif-ellafi commented 2 years ago

@klaas1979 - if it helps, I have read the adventure crafter (it is fantastic btw) and found out that it needs way too many tables and has weird exceptions haha. I have used it however in gameplay, and to keep it simple, what I did is:

Theme 1: [[#Theme Table]] - Plotline [[1d100]]
Theme 2: [[#Theme Table]] - Plotline [[1d100]]
Theme 3: [[#Theme Table]] - Plotline [[1d100]]
Theme 2: [[#Theme Table]] - Plotline [[1d100]]
Theme 2: [[#Theme Table]] - Plotline [[1d100]]

And then simply loading a journal with PDFoundry where I can quickly check the tables visually :)

klaas1979 commented 2 years ago

I have all the adventure crafter tables finished as standard Foundry Tables (dumped better-rolltables). All logic to have a Turning Point or create a Character if a new Character should be introduced are build and working. Maybe 12 tables take or less build.

My Oracle Builder macro basically does 5x rolls on the same Turning Point table. So I would now want to exchange the Random Event stuff (3 tables rolled in Mythic) by the Turning Point stuff (5 roles on one table) and have these results integrated in the process. I will try to patch something up, some time in the future to show it.

saif-ellafi commented 2 years ago

oh wow you loaded all tables!! cool. My next plans would be to slow down the development a bit until I can refactor the whole module for better modularity and flexibility.