#Adventure Cards Macro

1 messages · Page 1 of 1 (latest)

formal mirage
#

Isn't there a string in the actor data? I'll need to check.

half junco
#

But, it's a string.

formal mirage
#

It might be language dependent though

half junco
#

The player write it down.

#

One typo.

#

The macro will fail.

formal mirage
#

That's their fault. ;P

half junco
#

That's why I choose the number.

formal mirage
#

No Adventure Cards for them!

half junco
#

It's harder to make a mistake.

formal mirage
#

I get what you mean though

half junco
#

I'll think how to add this then

#

work in 3 stages

#

Aditional stats on? will use it
Aditional stats off? will use rank
Aditional stats off no possible rank? will give 1

formal mirage
#

Great!

#

Nice fallbacks

#

So how does it know which card it has?

#

And where does it pull them from?

half junco
half junco
#

I wipe every single item called "Adventure Card"

#

And add new one

formal mirage
#

They all just say "Adventure Card."

#

I was wondering how the item stores the data of which card it is

#

I also wondered if the item could have the name of the Adventure Card included, like Adventure Card: Love Interest.

half junco
formal mirage
#

I see.

half junco
formal mirage
#

So the user will have to make the table, correct?

half junco
#

Yes.

formal mirage
#

OK, so I would just name each item the table result name.

half junco
#

This would make horrible to wipe the cards.

formal mirage
#

Then if they name it "Adventure Card: Uh-Oh!" it'll use that.

half junco
#

I could add to description without pain

formal mirage
#

Not if you search `item.name.includes('Adventure Card:')

#

Right?

half junco
#
async function wipeAdventureCards(actorID) {
  let character = game.actors.get(actorID);
    
  let cards = character.items.filter(e => e.name===adventureCardName);    
  const ids = cards.map( card => card.id );
  await character.deleteEmbeddedDocuments('Item', ids);        
}
#

I would need to fix this

formal mirage
#

I see.

#

Do whatever you think makes sense. I'm just brainstorming ideas.

half junco
#

I can't predict what will be people tables.

formal mirage
#

Oh, you create the items, right?

half junco
formal mirage
#

You could add a flag on each of them.

half junco
#
async function createCard(actorID, imageLink) { 
  let rules = '';
  
  let character = game.actors.get(actorID);
  let data = [{
    name: adventureCardName,
    type: 'gear',
    img: icon,    
    data: {
      "description": `<img src="${imageLink}"/>`
    }
  }];  
  const createCard = await character.createEmbeddedDocuments('Item', data);
}
formal mirage
#

Yeah, inside of data, add a flags property.

#

Then you can search for those flags instead

half junco
formal mirage
#

No no, you just need to flag it with something like this...

#
flags:{
  'swade-macros': {
    type: 'Adventure Card'
  }
}
#

Then when you want to wipe them, just search for that flag with item.getFlag('swade-macros', 'type')

half junco
#

The flag solution looks better. I'll make some tests.

But, what name the item will have?

formal mirage
#

I would just give it the name of the table result

#

Keep it simple. If users want something more meaningful, they can change the name of the Journal Entry.

half junco
#

I'll try

formal mirage
#

Flags are awesome. I use them a lot for a lot of different things.

#

I even use flags on drawings on a scene I'm bundling with a module. Then I search the flags for the thing I'm looking for.

half junco
#
  let data = [{
    name: adventureCardName,
    type: 'gear',
    img: icon,    
    data: {
      "description": `<img src="${imageLink}"/>`,
      flags:{
        'swademacros': {
          type: 'Adventure Card'
        }
      }
    }
  }];  
#

@formal mirage just that?

formal mirage
#

That should do it. Or after you create the item, use setFlags() on it

#

Either way

half junco
#

this didn't work

formal mirage
#

Oh interesting. I guess add it in the data directly then

formal mirage
#

I like the new macro. The only thing odd I noticed was that it doesn't mark the cards as drawn in the table.

#

@half junco I also noticed an error because you assign the id to actorID but you try to reference it as actorid

#

This should fix it. I also updated the macro to create a variable for the selected table first and then use .drawMany() which then marks the card as drawn on the table.

#

Actually, I have a few other fixes I'm working on.

formal mirage
#

Something to consider is getting rid of wipeAdventureCards(). There are occasions when a player gets another card in the middle of a game such as interludes.

half junco
#

How can I clean old cards to give new ones then?

formal mirage
#

Add another button perhaps? I'm also trying to figure out how to deal only one card.

#

Also, I set resetTableAfterGiveCards to false. Once a card is drawn, it shouldn't be available again.

#

Not until a reset

#

Oh, maybe a reset would cover both wiping the card items and resetting the table

half junco
#

You'll need to add some buttons then

#

Button to reset

#

Button to wipe

formal mirage
#

Wiping cards

#

So we could add a Reset button that wipes the cards and resets the table

formal mirage
#

Let me know what you think of this. Need to head out for the evening. I can make more modifications after tomorrow.

half junco
#

I think a Wipe Cards button should be added.

formal mirage
#

Reset does it

#

It wipes cards and resets the table

half junco
#

cool