Skip to content

Commit

Permalink
v1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Moerill committed May 21, 2021
1 parent 42e719c commit fce26e6
Show file tree
Hide file tree
Showing 16 changed files with 7,660 additions and 4,329 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# v1.6

- Sendername in chat messages now gets underlined by the user color
- FVTT 0.8.4 and DnD 1.3.2 compatibility update

# v1.5.1

- **Fix** for automated animation compatibility where the target tokens where sometimes misplaced.
Expand Down
81 changes: 81 additions & 0 deletions build/config.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Do not edit. File was generated by node-gyp's "configure" step
{
"target_defaults": {
"cflags": [],
"default_configuration": "Release",
"defines": [],
"include_dirs": [],
"libraries": []
},
"variables": {
"asan": 0,
"coverage": "false",
"dcheck_always_on": 0,
"debug_nghttp2": "false",
"debug_node": "false",
"enable_lto": "false",
"enable_pgo_generate": "false",
"enable_pgo_use": "false",
"error_on_warn": "false",
"force_dynamic_crt": 0,
"host_arch": "x64",
"icu_gyp_path": "tools/icu/icu-system.gyp",
"icu_small": "false",
"icu_ver_major": "69",
"is_debug": 0,
"llvm_version": "0.0",
"napi_build_version": "8",
"node_byteorder": "little",
"node_debug_lib": "false",
"node_enable_d8": "false",
"node_install_npm": "false",
"node_module_version": 93,
"node_no_browser_globals": "false",
"node_prefix": "/usr",
"node_release_urlbase": "",
"node_section_ordering_info": "",
"node_shared": "false",
"node_shared_brotli": "false",
"node_shared_cares": "false",
"node_shared_http_parser": "false",
"node_shared_libuv": "true",
"node_shared_nghttp2": "true",
"node_shared_nghttp3": "false",
"node_shared_ngtcp2": "false",
"node_shared_openssl": "true",
"node_shared_zlib": "true",
"node_tag": "",
"node_target_type": "executable",
"node_use_bundled_v8": "true",
"node_use_dtrace": "false",
"node_use_etw": "false",
"node_use_node_code_cache": "true",
"node_use_node_snapshot": "true",
"node_use_openssl": "true",
"node_use_v8_platform": "true",
"node_with_ltcg": "false",
"node_without_node_options": "false",
"openssl_fips": "",
"openssl_is_fips": "false",
"openssl_quic": "false",
"ossfuzz": "false",
"shlib_suffix": "so.93",
"target_arch": "x64",
"v8_enable_31bit_smis_on_64bit_arch": 0,
"v8_enable_gdbjit": 0,
"v8_enable_i18n_support": 1,
"v8_enable_inspector": 1,
"v8_enable_lite_mode": 0,
"v8_enable_object_print": 1,
"v8_enable_pointer_compression": 0,
"v8_no_strict_aliasing": 1,
"v8_optimized_debug": 1,
"v8_promise_internal_field_count": 1,
"v8_random_seed": 0,
"v8_trace_maps": 0,
"v8_use_siphash": 1,
"want_separate_host_toolset": 0,
"nodedir": "/home/vali/.cache/node-gyp/16.0.0",
"standalone_static_library": 1
}
}
10 changes: 6 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ const gulp = require("gulp");
const fs = require("fs-extra");
const path = require("path");
const stringify = require("json-stringify-pretty-compact");
const less = require("gulp-less");
const git = require("gulp-git");
const concat = require("gulp-concat");

const chalk = require("chalk");

const argv = require("yargs").argv;

const sass = require("gulp-sass");
sass.compiler = require("node-sass");
const sass = require("gulp-dart-sass");
//sass.compiler = require("node-sass");

const browserSync = require("browser-sync").create();

Expand Down Expand Up @@ -85,6 +84,9 @@ function buildWatch() {
proxy: {
target: "localhost:30000",
ws: true,
proxyOptions: {
changeOrigin: false,
},
},
browser: "google-chrome",
open: false,
Expand Down Expand Up @@ -246,7 +248,7 @@ function gitTag() {

const execGit = gulp.series(gitAdd, gitCommit, gitTag);

const execBuild = gulp.parallel(buildLess);
const execBuild = gulp.parallel(buildSass);

exports.build = gulp.series(execBuild);
exports.watch = buildWatch;
Expand Down
3 changes: 2 additions & 1 deletion html/chat/dmg.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="mars5e-action damage mars5e-toggleable {{#if critical}}critical{{/if}}">
{{log @root}}
<label>{{localize 'DND5E.Damage'}}</label>
<div class="mars5e-apply-dmg-menu" style="height: 19px;">
<button class="mars5e-apply" data-amount="0"><i class="fas fa-fist-raised"></i></button>
Expand All @@ -8,7 +9,7 @@
</div>
{{#each rolls}}
<a class="rollable
{{#if @first}}non-versatile{{/if}}" data-dmg-type="{{this.dmgType}}" data-flavor-formula="{{this.flavorFormula}}" data-resistance="{{this.resistance}}" data-dmg-type-label="{{this.dmgTypeLabel}}">{{this.shortenedFormula}}</a>
{{#if @first}}non-versatile{{/if}}" data-dmg-type="{{this.dmgType}}" data-flavor-formula="{{this.formula}}" data-resistance="{{this.resistance}}" data-dmg-type-label="{{this.dmgTypeLabel}}">{{this.shortenedFormula}}</a>
{{!-- {{#if this.dmgTypeLabel}}<span class="dmg-type
{{!-- {{#if @root.versatile}}versatile{{/if}} --}}
{{!-- ">{{this.dmgTypeLabel}}</span>{{/if}} --}}
Expand Down
3 changes: 1 addition & 2 deletions html/item-card.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<div class="dnd5e chat-card item-card mars5e-card {{#if isGM}}mars5e-gm-card{{/if}}" data-actor-id="{{actor._id}}" data-item-id="{{item._id}}"
<div class="dnd5e chat-card item-card mars5e-card {{#if isGM}}mars5e-gm-card{{/if}}" data-actor-id="{{actorId}}" data-item-id="{{itemId}}"
{{#if tokenId}}data-token-id="{{tokenId}}"{{/if}} {{#if sceneId}}data-scene-id="{{sceneId}}"{{/if}} {{#if isSpell}}data-spell-level="{{item.data.level}}"{{/if}}>


<header class="card-header flexrow">
<img src="{{item.img}}" title="{{item.name}}"/>
<h3 class="item-name">{{item.name}}</h3>
Expand Down
80 changes: 0 additions & 80 deletions js/actor/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,86 +39,6 @@ export default function initActorClass() {
}
}

async _renderRoll(roll, label) {
roll = await roll;
const chatData = {
user: game.user._id,
type: CONST.CHAT_MESSAGE_TYPES.OTHER,
speaker: ChatMessage.getSpeaker({
actor: this.actor,
token: this.token,
}),
flags: {
"core.canPopout": false,
},
};

let advantage = 1;
if (/^2d20kh/.exec(roll.formula)) advantage = 2;
else if (/^2d20kl/.exec(roll.formula)) advantage = 0;

// Define chat data
const templateData = {
formula: roll.formula,
// flavor: ,
user: chatData.user,
total: roll.total,
json: JSON.stringify(roll.toJSON()),
flavorFormula: roll.flavorFormula,
isGM: game.user.isGM,
label: label,
advantage: advantage,
tooltip: await roll.getTooltip(),
};

let template = await renderTemplate(
"modules/mars-5e/html/roll.hbs",
templateData
);

if (roll.terms[0].faces === 20) {
const dice = roll.terms[0];
const div = document.createElement("div");
div.insertAdjacentHTML("afterbegin", template);
const resultDiv = div.querySelector(".mars5e-result");
if (resultDiv) {
if (dice.total >= dice.options.critical) {
markSuccess(resultDiv);
} else if (dice.total <= dice.options.fumble) {
markFail(resultDiv);
}
template = div.innerHTML;
}

Mars5eUserStatistics.update(
game.user,
await Mars5eUserStatistics.getD20Statistics(dice)
);
}

chatData.content = template;

// Toggle default roll mode
const rollMode = game.settings.get("core", "rollMode");
if (["gmroll", "blindroll"].includes(rollMode))
chatData["whisper"] = ChatMessage.getWhisperRecipients("GM");
if (rollMode === "blindroll") chatData["blind"] = true;

// result.dataset.flavorFormula = roll.flavorFormula;
await rollDsN(
[
roll,
game.user,
true,
chatData.whisper || null,
chatData.blind || null,
],
this
);

return CONFIG.ChatMessage.entityClass.create(chatData);
}

rollAbilityTest(abilityId, options = {}) {
return this.processRoll(super.rollAbilityTest, abilityId, options);
}
Expand Down
29 changes: 15 additions & 14 deletions js/chat/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ export default class Mars5eMessage extends ChatMessage {

message.mars5eStatistics = statistics;
const card = message.card;
card.querySelector(
`.mars5e-target[data-target-id="${target}"]`
).innerHTML = content;
card.querySelector(`.mars5e-target[data-target-id="${target}"]`).innerHTML =
content;
message.mars5eUpdate();
return true;
}
Expand Down Expand Up @@ -267,16 +266,16 @@ export default class Mars5eMessage extends ChatMessage {
const formula = el.dataset.flavorFormula;
let r = new Roll(formula);
r.alter(2, 0);
el.dataset.flavorFormula = r.flavorFormula;
el.dataset.flavorFormula = r.formula;
el.innerText = r.formula;
});
} else {
dmgDiv.querySelectorAll(".rollable").forEach((el) => {
const formula = el.dataset.flavorFormula;
let r = new Roll(formula);
// TODO: Switch to proper alter method usage in FVTT 0.7.8
for (const term of r.terms) if (term instanceof Die) term.number *= 0.5;
el.dataset.flavorFormula = r.flavorFormula;
r.alter(0.5, 0);
log(r);
el.dataset.flavorFormula = r.formula;
el.innerText = r.formula;
});
}
Expand Down Expand Up @@ -907,9 +906,9 @@ export default class Mars5eMessage extends ChatMessage {
return canvas.tokens.get(targetId);
}
const scene = game.scenes.get(sceneId);
const data = scene.getEmbeddedEntity("Token", targetId);
const data = scene.getEmbeddedDocument("Token", targetId);
// const data = await fromUuid(`Scene.${sceneId}.Token.${targetId}`);
if (data) return new Token(data);
if (data) return new Config.Token.objectClass(data);
return null;
}

Expand Down Expand Up @@ -949,13 +948,15 @@ export default class Mars5eMessage extends ChatMessage {
const scene =
sceneId === canvas.scene.id ? canvas.scene : game.scenes.get(sceneId);
if (!scene) return null;
let tokenData = scene?.data.tokens.find((e) => e._id === tokenId);
let tokenData = scene.getEmbeddedDocument("Token", tokenId); //tokens.find((e) => e.id === tokenId);
if (!tokenData) {
const actorId = card.dataset.actorId;
tokenData = scene.data.tokens.find((e) => e.actorId === actorId);
tokenData = scene.tokens.find((e) => e.data.actorId === actorId);
}
if (scene instanceof Scene) return canvas.tokens.get(tokenData._id);
this._token = new Token(tokenData);
if (!tokenData) return;
this._token = canvas.tokens.get(tokenData.id);

if (!this._token) this._token = new CONFIG.Token.objectClass(tokenData);
return this._token;
}

Expand All @@ -966,7 +967,7 @@ export default class Mars5eMessage extends ChatMessage {
if (!itemId) return null;
const token = this.token;
const actor = token?.actor ?? game.actors.get(card.dataset.actorId);
this._item = actor.getOwnedItem(itemId);
this._item = actor.items.get(itemId);
return this._item;
}

Expand Down
11 changes: 8 additions & 3 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Hooks.once("devModeReady", ({ registerPackageDebugFlag }) => {
Hooks.on("init", () => {
window["mars5e"] = {};
const MarsItem5e = initItemClass();
CONFIG.Item.entityClass = MarsItem5e;
CONFIG.Item.documentClass = MarsItem5e;
const MarsActor5e = initActorClass();
CONFIG.Actor.entityClass = MarsActor5e;
CONFIG.Actor.documentClass = MarsActor5e;

Mars5eMessage.init();

Expand Down Expand Up @@ -181,8 +181,13 @@ Hooks.on("renderChatMessage", async (app, html, options) => {
if (html[0].style.borderColor) {
html[0].style.borderColor = null;
// html[0].style.borderRightColor = app.user.color;
html[0].style.borderTopColor = app.user.color;
html[0].style.borderLeftColor = app.user.color;
} else html[0].style.borderLeftColor = app.user.color;

// Experimental, maybe keep this?
const sender = html[0].querySelector(".message-sender");
sender.style.textDecoration = `underline ${app.user.color} 2px`;
sender.title = app.user.name;
});

Hooks.once("init", () => {
Expand Down
Loading

0 comments on commit fce26e6

Please sign in to comment.