Fix reset deck in Foundry v9 #9

This commit is contained in:
sladecraven 2022-03-18 19:30:18 +01:00
parent ae2d926324
commit 633525a9e5
3 changed files with 14 additions and 13 deletions

View File

@ -378,7 +378,7 @@ export class SoSActor extends Actor {
async addObjectToContainer( itemId, containerId ) { async addObjectToContainer( itemId, containerId ) {
let container = this.data.items.find( item => item.id == containerId && item.type == 'container') let container = this.data.items.find( item => item.id == containerId && item.type == 'container')
let object = this.data.items.find( item => item.id == itemId ) let object = this.data.items.find( item => item.id == itemId )
//console.log("Found", container, object) console.log("Found", container, object)
if ( container ) { if ( container ) {
if ( object.type == 'container') { if ( object.type == 'container') {
ui.notifications.warn("Only 1 level of container... sorry"); ui.notifications.warn("Only 1 level of container... sorry");

View File

@ -58,21 +58,22 @@ export class SoSCardDeck {
/* -------------------------------------------- */ /* -------------------------------------------- */
resetDeck() { resetDeck() {
let newdeck = duplicate(this.data.deck).concat( duplicate (this.data.discard)); let newdeck = duplicate(this.data.deck).concat( duplicate (this.data.discard) )
this.data.discard = []; // Reinit discard pile this.data.discard = [] // Reinit discard pile
this.data.deck = []; this.data.deck = []
let decklen = newdeck.length; let decklen = newdeck.length
let cardState = []; let cardState = []
for (let i = 0; i <decklen; i++) { for (let i = 0; i <decklen; i++) {
cardState[i] = false; cardState[i] = false
} }
// Randomize deck // Randomize deck
while (this.data.deck.length != decklen) { while (this.data.deck.length != decklen) {
let idx = new Roll("1d"+decklen).roll().total; let idx = new Roll("1d"+decklen).roll({async : false}).total
if (!cardState[idx - 1]) { //console.log("Deck stuff", this.data.deck.length, decklen, idx)
this.data.deck.push( newdeck[idx-1] ); if (!cardState[idx-1]) {
} this.data.deck.push( newdeck[idx-1] )
cardState[idx - 1] = true; }
cardState[idx-1] = true
} }
} }

View File

@ -7,7 +7,7 @@
"url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-shadows-over-sol/", "url": "https://gitlab.com/LeRatierBretonnien/foundryvtt-shadows-over-sol/",
"license": "LICENSE.txt", "license": "LICENSE.txt",
"flags": {}, "flags": {},
"version": "2.0.4", "version": "2.0.5",
"minimumCoreVersion": "0.8.0", "minimumCoreVersion": "0.8.0",
"compatibleCoreVersion": "9", "compatibleCoreVersion": "9",
"scripts": [], "scripts": [],