Skip to content

Commit

Permalink
Fix swarms, add ver to modules, handle err on char export
Browse files Browse the repository at this point in the history
  • Loading branch information
rrgeorge committed Oct 3, 2021
1 parent 0f03cfe commit 7f96826
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
11 changes: 10 additions & 1 deletion ddb.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ class DDB {
for (const monster of response.data) {
if (!monster.isReleased&&!monster.isHomebrew) {
prog.value += (!filename)? (15*(1/count)) : 1
console.log(`Skipping ${monster.isReleased} ${monster.isHomebrew}`)
console.log(`Skipping ${monster.name} ${monster.isReleased} ${monster.isHomebrew}`)
continue
}
if (monster.isHomebrew !== homebrew) {
Expand Down Expand Up @@ -862,6 +862,10 @@ class DDB {
} else {
monsterEntry._content.push({type: this.ruledata.monsterTypes.find(s=>s.id===monster.typeId)?.name||monster.typeId})
}
if (monster.swarm) {
let type = monsterEntry._content.find(s=>s.type)
type.type = `swarm of ${this.ruledata.creatureSizes.find(s=>s.id===monster.swarm.sizeId).name} ${this.ruledata.monsterTypes.find(s=>s.id===monster.swarm.typeId)?.pluralizedName}`
}
if (monster.damageAdjustments?.length>0) {
let resist = monster.damageAdjustments
.filter(s=>this.ruledata.damageAdjustments.find(d=>d.id===s&&d.type===1))
Expand Down Expand Up @@ -1047,6 +1051,11 @@ ${(monster.sourceId)?`<i>Source: ${this.ruledata.sources.find((s)=> monster.sour
]
}
var zip = AdmZip(filename)
let ddbVer = zip.readAsText("version.txt").trim()
let modVer = app.getVersion().split(".")
modVer.push(ddbVer)
modVer = modVer.map(Number)
mod._attrs.version = (modVer[0] * (1000**3)) + (modVer[1] * (1000**2)) + (modVer[2] * 1000) + (modVer[3])
zip.extractEntryTo(`${book.name.toLowerCase()}.db3`,temp.name,false,true)
var db = new sqlite3.Database(path.join(temp.name,`${book.name.toLowerCase()}.db3`))
var imageMap = []
Expand Down
20 changes: 16 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,24 @@ function requestCampaignChars(gameId,cobalt) {
defaultPath: `${thisCampaign.label.replaceAll("&&","&")}.compendium`,
}).then((save) => {
if (save.filePath) {
const prog = new ProgressBar({title: "Converting campaign characters...", text: "Converting campaign characters...", detail: "Please wait..."})
download(_win,`https://play5e.online/ddb.php?tokenmap=true&circles=true&campaign=https://ddb.ac/characters/${campaignChars[0].id}`,{
let prog = new ProgressBar({title: "Converting campaign characters...", text: "Converting campaign characters...", detail: "Please wait..."})
let dlProg
download(_win,`https://play5e.online/?api=true&tokenmap=true&circles=true&campaign=https://ddb.ac/characters/${campaignChars[0].id}`,{
filename: path.basename(save.filePath),
directory: path.dirname(save.filePath),
onStarted: () => prog.setCompleted()
})
onCompleted: (f) => {
try {
prog.setCompleted()
new AdmZip(save.filePath)
} catch (e) {
prog.text = "Error"
const err = fs.readFileSync(save.filePath).toString()
prog.detail = err
fs.rm(save.filePath,()=>{})
dialog.showErrorBox("Error",`Could not convert characters:\n${err}`)
}
}
}).catch(e=>console.log(e))
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "encounterlog",
"productName": "EncounterLog",
"version": "2.2.0",
"version": "2.2.1",
"description": "Connect D&D Beyond to EncounterPlus",
"repository": {
"type": "git",
Expand Down

0 comments on commit 7f96826

Please sign in to comment.