Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ultrakorne committed Jun 10, 2020
2 parents edca7e4 + 91637ba commit ee9d778
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 27 deletions.
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "better-rolltables",
"title": "Better Roll Tables",
"description": "Adding functionality to roll tables, especially to roll treasure and magic items",
"version": "1.0.0",
"version": "1.1.0",
"author": "Ultrakorne#6240",
"esmodules": [
"./scripts/brt-main.js"
Expand Down Expand Up @@ -40,5 +40,5 @@
],
"url": "https://github.com/ultrakorne/better-rolltables",
"manifest": "https://raw.githubusercontent.com/ultrakorne/better-rolltables/master/module.json",
"download": "https://github.com/ultrakorne/better-rolltables/releases/download/v1.0.0/better-rolltables.zip"
"download": "https://github.com/ultrakorne/better-rolltables/releases/download/v1.1.0/better-rolltables.zip"
}
30 changes: 7 additions & 23 deletions scripts/better-table-view.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { i18n } from './utils.js';
import { LootBuilder } from './loot-builder.js'
import { BRTCONFIG } from './config.js';
import { LootCreator } from './loot-creator.js';
import { LootChatCard } from './loot-chat-card.js';
import { StoryBuilder } from './story/story-builder.js';
import { StoryChatCard } from './story/story-chat-card.js';
import { BetterTables } from './better-tables.js';

export class BetterRT {
static async enhanceRollTableView(rollTableConfig, html, rollTable) {
Expand Down Expand Up @@ -197,33 +193,21 @@ export class BetterRT {
}

static async generateLoot(tableEntity) {
const lootBuilder = new LootBuilder(tableEntity);
const generatedLoot = await lootBuilder.generateLoot();
const lootCreator = new LootCreator(generatedLoot);
await lootCreator.createActor();
await lootCreator.addCurrenciesToActor();
await lootCreator.addItemsToActor();
const betterTables = new BetterTables();
await betterTables.generateLoot(tableEntity);
}

static async onOptionTypeChanged(value, tableEntity) {
await tableEntity.setFlag(BRTCONFIG.NAMESPACE, BRTCONFIG.TABLE_TYPE_KEY, value);
}

static async onLootRollClicked(tableEntity) {
const lootBuilder = new LootBuilder(tableEntity);
const generatedLoot = await lootBuilder.generateLoot();
const lootChatCard = new LootChatCard(generatedLoot);
await lootChatCard.createChatCard(tableEntity);
const betterTables = new BetterTables();
await betterTables.generateChatLoot(tableEntity);
}

static async onStoryRollClicked(tableEntity) {
const storyBuilder = new StoryBuilder(tableEntity);
await storyBuilder.drawStory();
const storyHtml = storyBuilder.generatedStory();
const storyGMHtml = storyBuilder.generatedStoryGM();

const storyChat = new StoryChatCard(tableEntity);
storyChat.createChatCard(storyHtml);
storyChat.createChatCard(storyGMHtml, {gmOnly: true});
const betterTables = new BetterTables();
await betterTables.generateChatStory(tableEntity);
}
}
33 changes: 33 additions & 0 deletions scripts/better-tables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { LootCreator } from './loot-creator.js';
import { LootBuilder } from './loot-builder.js'
import { LootChatCard } from './loot-chat-card.js';
import { StoryBuilder } from './story/story-builder.js';
import { StoryChatCard } from './story/story-chat-card.js';

export class BetterTables {
async generateLoot(tableEntity) {
const lootBuilder = new LootBuilder(tableEntity);
const generatedLoot = await lootBuilder.generateLoot();
const lootCreator = new LootCreator(generatedLoot);
await lootCreator.createActor();
await lootCreator.addCurrenciesToActor();
await lootCreator.addItemsToActor();
}

async generateChatLoot(tableEntity) {
const lootBuilder = new LootBuilder(tableEntity);
const generatedLoot = await lootBuilder.generateLoot();
const lootChatCard = new LootChatCard(generatedLoot);
await lootChatCard.createChatCard(tableEntity);
}

async generateChatStory(tableEntity) {
const storyBuilder = new StoryBuilder(tableEntity);
await storyBuilder.drawStory();
const storyHtml = storyBuilder.generatedStory();
const storyGMHtml = storyBuilder.generatedStoryGM();
const storyChat = new StoryChatCard(tableEntity);
storyChat.createChatCard(storyHtml);
storyChat.createChatCard(storyGMHtml, { gmOnly: true });
}
}
6 changes: 6 additions & 0 deletions scripts/brt-main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { BetterRT } from './better-table-view.js';
import { BRTCONFIG } from './config.js';
import { i18n } from './utils.js';
import { BetterTables } from './better-tables.js';

// CONFIG.debug.hooks = true;

Expand All @@ -11,6 +12,8 @@ Hooks.on("init", function () {
});

registerSettings();

game.betterTables = new BetterTables();
});

Hooks.on("renderRollTableConfig", BetterRT.enhanceRollTableView);
Expand Down Expand Up @@ -48,3 +51,6 @@ function registerSettings() {
type: String
});
}



2 changes: 0 additions & 2 deletions scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ export async function findInCompendiumByName(compendiumName, entityName){
}

export async function findInCompendiumById(compendiumName, entityId){
console.log("findInCompendiumById compendiumName ", compendiumName);
console.log("findInCompendiumById entityId ", entityId);
const compendium = game.packs.find(t => t.collection === compendiumName);
if(compendium) {
const compendiumIndex = await compendium.getIndex();
Expand Down

0 comments on commit ee9d778

Please sign in to comment.