drewg13 / foundryvtt-scum-and-villainy

Scum and Villainy game system for FoundryVTT
Other
12 stars 15 forks source link

Universe and Faction Status should use standard items #76

Closed gortiz closed 10 months ago

gortiz commented 10 months ago

When a element is added to Universe or Faction Status, a new internal item is created. Instead it should use the original item or create a new standard item if the element was added from the compendium.

For example, let's say I'm tracking the Ashtari Cult faction. First I import the faction from the compendium and do my own modifications. For example, I advance the clock. Later I drag and drop the faction from the item list to Universe (or Faction Status, it is the same). Everything seems fine, the clock shown in Universe is the same as the one shown in the Ashtari Cult faction listed in icon. But then I tick the clock again and in Universe it didn't change. What happened is that when I dragged and dropped the faction to Universe, a new item was created, stored in game.actors.getName("MyUniverse").items.getName("Ashtari Cult").

I guess one can either use Universe or Faction Status and do not create the items in the item list, but that makes it very difficult to add use these elements as tokens, for example.

Could it be possible to change the implementation to do not copy the items but use reference to them?

drewg13 commented 10 months ago

This is fundamental to the design of Foundry and would be extremely challenging to work around. World-level Items are considered templates, not instances. To illustrate why, imagine you create two Actors, Alice and Bob, and an Item, a Sword. When you drag that Sword into Alice's inventory, Foundry creates a copy and embeds it in the Alice Actor Document. When you do the same for Bob, it creates another copy. If your story results in an enhancement to Alice's Sword, maybe a +1 to hit, when you modify her copy, Bob's copy is separate and remains unmodified. If you want to modify both, you can either modify them each separately or modify the world's Sword Item and use it to replace the Sword Item on each Actor.

Working around this behavior is quite complex and not something I'm interested in undertaking. If you're interested in coding a PR, we can get further into the details, but most people making these type of requests are not.

Additionally, to clarify, core Foundry behavior for Items is that they cannot be represented on the canvas as tokens, so any difficulty using Items as tokens is core to Foundry and out of my control. It's not clear to me what you intend to do with a world-level Item, beyond making homebrew modifications before adding it to one of the faction trackers, which is already fully supported by the current behaviors. You can fully control player access to the trackers via permissions and even control fine-grained visibility of individual factions within a singular tracker via the eye icons. Alternately, set up multiple trackers with varying permissions, although this method would be complicated by the inability to transfer factions between trackers while maintaining current data.

If you're using modules that modify the core Item-canvas behavior, you're on your own with that. I built the system with the default behaviors in mind and can't possibly account for all possible modules and use cases. I strongly recommend picking one canonical tracking method and strongly discourage attempting to have multiple ways to access and track the same information.

gortiz commented 10 months ago

Thanks for the context. I didn't know that. With that information I infer that Actors are not templates. Therefore we could create instances of planets and factions as actors and directly reference them from Universe and Faction Status. Am I right? I think that is what Wicked Ones system does.

I don't want to do anything superfancy. But I would like to be able to have tiles that open the planet sheet once clicked and I wouldn't mind to be able to have either 2 universe actors or 1 universe and 1 faction status so players in one we have the picture of what is important right now and the other can be used by the DM to track the progress of all factions.

I can do the tile thing with game.actors.getName("MyUniverse").items.getName("Nightfall").sheet.render(true), but seems a bit hacky

drewg13 commented 10 months ago

It's also not possible in Foundry to embed Actors in other Actors by default. I did a little hacky workaround to make the Ship association work with characters, but it's not pretty and requires a lot of really ugly code. There's no way I'm reworking the whole system to extend that to everything else, that would not only be a lot of work to do, I'd also have to catch and migrate everyone else's code to the new paradigm or support both indefinitely. You're asking for a lot of effort to support what seems to me like the aesthetic preference of one GM. I'm not trying to be dismissive and I'm not averse to major overhauls or new functionality if the benefit clearly outweighs the cost or if someone else does the bulk of the coding, but this doesn't reach that level to me.

If your code works for the tile thing you want to do, that seems like your best way forward to me. My entire system is hacky because I'm a hack coder. If you find something that works, I say use that.

You don't need two different trackers to accomplish your intended goal, just make one and disable player visibility for factions you don't want them to see or aren't currently relevant. That's the intended functionality to cover that use case.

gortiz commented 10 months ago

Understood. Anyway, thanks for the effort. In general the plugin is fantastic! I don't think I may have time to do major updates, but I may try to improve the spanish translation is possible and/or fix any small bug I may find.