Conversation
|
|
|
||
| const { HTMLField, SchemaField, TypedObjectField } = foundry.data.fields; | ||
|
|
||
| export default class PartyModel extends foundry.abstract.TypeDataModel { |
There was a problem hiding this comment.
Should probably be DrawSteelSystemModel? I don't think it's super likely we end up with any pseudo collections but it does seem expected.
| const update = {}; | ||
| if (!foundry.utils.hasProperty(data, "prototypeToken.actorLink")) | ||
| foundry.utils.setProperty(update, "prototypeToken.actorLink", true); | ||
|
|
||
| if (!foundry.utils.hasProperty(data, "prototypeToken.sight.enabled")) | ||
| foundry.utils.setProperty(update, "prototypeToken.sight.enabled", false); | ||
|
|
||
| if (!foundry.utils.hasProperty(data, "prototypeToken.disposition")) | ||
| foundry.utils.setProperty(update, "prototypeToken.disposition", CONST.TOKEN_DISPOSITIONS.FRIENDLY); | ||
|
|
||
| if (!foundry.utils.isEmpty(update)) this.parent.updateSource(update); |
There was a problem hiding this comment.
I think foundry.utils.mergeObject(defaultData, data, { insertKeys: false, insertValues: false }) gets us equivalent results while being more maintainable?
| Object.defineProperty(this, "members", { | ||
| enumerable: true, | ||
| get() { | ||
| return Object.entries(this._source.members).reduce((acc, [id, data]) => { | ||
| const actor = game.actors.get(id); | ||
| if (this.validMember(actor)) acc.set(actor.id, { ...data, actor }); | ||
| return acc; | ||
| }, new foundry.utils.Collection()); | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Do we want an a new field for this instead of overwriting the initialized TOF?
| * @returns {boolean} | ||
| */ | ||
| validMember(actor) { | ||
| return (actor instanceof foundry.documents.Actor) && ["hero"].includes(actor.type) |
There was a problem hiding this comment.
I wonder if the array should be some static property on the constructor
| async removeMembers(actors = []) { | ||
| const update = {}; | ||
| actors.forEach(actor => { | ||
| if (this.validMember(actor) && this.members.has(actor.id)) update[`-=${actor.id}`] = null; |
There was a problem hiding this comment.
Why do we check if it's a valid member first? e.g. if I do a forced type update to turn a hero into an NPC I can no longer use this method to remove them.
partyactor.canvas.tokens.performTokenPlacementin favor ofcanvas.tokens.placeTokento be in line withcanvas.regions.placeRegion.canvas.tokens.#getTokenDatawhich threw errors when items or effect were empty.Notes
canvas.tokens.#getTokenDataand don't think it's relevant for this anyhow. We are also not using it anywhere in the system at present.TODO
game.actors.partyas an easy access getter.To test:
Create party actor and hero actor.