Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Moerill committed Jan 3, 2021
1 parent 0963db1 commit 0eb0b57
Show file tree
Hide file tree
Showing 25 changed files with 1,331 additions and 741 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# v0.4

- *New Feature* Autoroll attack and dmg rolls!
- Setting user based in the settings menu!
- *New Feature* Support for Calegos Confetti module!
- throws confetti on crits/fumbles
- Use at your own risk in combination with auto rolls!
- *New Feature* Apply damage to all targets buttons!
- *New Feature* Statistics!
- track a few of your players statistics, like damage done, damage taken, nat20s/1s, ...
- Statistics are tracked over the whole worlds time and a session (session stats are reset if >= 6 hours are between updates)
- Including a small overview window!
- Future plans:
- provide awards and/or achievements
- maybe add a few more statistics
- *New Setting* Added setting on whether to automatically hide gm rolls or not.
- Improved the AbilityTemplate code to copy less from the original DnD system.
- *Fix* apply damage buttons for area damage showing "NaN", when saving throw was rolled already
- Area dmg div now removed after it is rolled and applied to the targets
- Advantage is now reset after each throw
- *Fix* toggling successfull saves not modifying the applied resistance of damage rolls
- *Fix* some more bugfixes, that i noticed on the way

# v0.3.3

- Advantage selection now gets shown for hotbar items as well.
Expand Down
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ Its not difficult to put at least some effort into something that you want someo
- [Hit/Miss and Success/Fail (GM only)](#hitmiss-and-successfail-gm-only)
- [Crit](#crit)
- [Resistance multiplier (GM only)](#resistance-multiplier-gm-only)
- [Automatic Hit/Dmg rolls](#automatic-hitdmg-rolls)
- [Statistics](#statistics)
- [Miscellaneous features](#miscellaneous-features)
- [Whetstone Integration](#whetstone-integration)
- [Dice tooltips](#dice-tooltips)
- [Apply damage buttons (GM only)](#apply-damage-buttons-gm-only)
- [Fudge rolls (GM only)](#fudge-rolls-gm-only)
- [Dice So Nice support](#dice-so-nice-support)
- [Confeftti Support!](#confeftti-support)
- [Automatic template targetting](#automatic-template-targetting)
- [Known Module incompatibilities](#known-module-incompatibilities)
- [Planned ToDo's](#planned-todos)
Expand Down Expand Up @@ -113,6 +116,17 @@ Before you rolled damage you can toggle whether the dmg roll was a crit or not!

You can toggle through the resistance multiplier applied, when using the apply to target buttons.

### Automatic Hit/Dmg rolls

Check the settings to enable automatic Hit/Dmg rolls

## Statistics

![](doc/statistics-overview.w

Want to finally end the dispute of who tanks the most or deals the most damage?
Mars 5e tracks a few basic stats for your players!

## Miscellaneous features

### Whetstone Integration
Expand Down Expand Up @@ -143,28 +157,32 @@ Double clicking on a dice result allows the GM to modify the displayed result. O

### Dice So Nice support

### Confeftti Support!

Throw confetti on fumbles/crits! yay!

### Automatic template targetting

(needs DnD 1.2.1)
(needs DnD 1.2.1+)
When using the automatically created spell templates the module will autotarget everyone in it.

## Known Module incompatibilities

- BetterRolls for 5e
- completly incompatible, since both tackle a similar thing in completly different ways
- MidiQoL
- [Everything related to automatic rolling](https://github.com/Moerill/fvtt-mars-5e/issues/10#issuecomment-749528287)
- [More Information](https://github.com/Moerill/fvtt-mars-5e/issues/33)
- Dynamic Active Effects (DAE)
- [Setting: Use ability save field when rolling ability saves](https://github.com/Moerill/fvtt-mars-5e/issues/11)

## Planned ToDo's

These are just ideas, they may or may not happen.

- [ ] template auto targetting
- [ ] Basic roll statistics
- [ ] Chat Filter (filtering on player, action and whisper basis)
- [ ] Automatic rolling of attack/dmg rolls
- [x] template auto targetting (incoming with DnD 1.2.1++)
- [x] Basic roll statistics
- [ ] ~~Chat Filter (filtering on player, action and whisper basis)~~
- [x] Automatic rolling of attack/dmg rolls
- [ ] Clean-up SCSS (and code)
- [ ] Manifest+
- [ ] (look into Sadness Chan support, only a maybe)
Expand Down
Binary file added doc/statistics-overview.webp
Binary file not shown.
8 changes: 7 additions & 1 deletion html/chat/targets.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="mars5e-target {{#unless target.visible}}mars5e-hidden-target{{/unless}} {{#if data.isGM}}mars5e-gm-target mars5e-invisible-target{{/if}}" {{#if target.id}}data-target-id="{{target.id}}"{{/if}}>
<div class="mars5e-target {{#unless target.visible}}mars5e-hidden-target{{/unless}} {{#if data.isGM}}mars5e-gm-target {{#if @root.invisibleTarget}}mars5e-invisible-target{{/if}}{{/if}}" {{#if target.id}}data-target-id="{{target.id}}"{{/if}}>
<div class="target-header">
{{#if target.img}}<img src="{{target.img}}" />{{/if}}
<h3>{{target.name}}</h3>
Expand All @@ -25,6 +25,12 @@
{{/unless}}
{{/unless}}
{{/if}}
{{else}}
{{#unless data.hasAttack}}
{{#unless data.isHealing}}
{{> 'modules/mars-5e/html/chat/dmg.hbs' data.damage}}
{{/unless}}
{{/unless}}
{{/if}}

{{#if data.isHealing}}
Expand Down
2 changes: 2 additions & 0 deletions html/definitions.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
--mars5e-apply-label: '{{localize "MARS5E.label.apply"}}';
--mars5e-versatile-label: '{{localize "DND5E.Versatile"}}';
--mars5e-apply-all-label: '{{localize "MARS5E.label.applyAll"}}';
--mars5e-apply-all-versatile-label: '{{localize "MARS5E.label.applyAllVersatile"}}';
{{!-- {{ localize "MARS5E.label.hit"}} --}}
{{!-- {{ localize "MARS5E.label.miss" }} --}}
Expand Down
8 changes: 8 additions & 0 deletions html/item-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
</blockquote>
{{/if}}
<div class="mars5e-targets">
{{#if targets}}
<div class="mars5e-apply-dmg-menu mars5e-apply-all" style="height: 19px;">
<button class="mars5e-apply" data-amount="0"><i class="fas fa-fist-raised"></i></button>
{{#if damage.versatile}}
<button class="mars5e-apply-versatile" data-amount="0"><i class="fas fa-sign-language"></i></button>
{{/if}}
</div>
{{/if}}
{{#if toolCheck}}
<div class='mars5e-target'>
<div class='mars5e-action tool mars5e-toggleable'>
Expand Down
2 changes: 1 addition & 1 deletion html/roll.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
{{#if label}}
<label>{{label}}</label>
{{/if}}
<a class='mars5e-roll mars5e-result' title='{{flavorFormula}}' data-roll='{{json}}' data-advantage='{{advantage}}'><span class='result-total'>{{total}}</span>{{{tooltip}}}</a>
<a class='mars5e-roll mars5e-result' data-advantage='{{advantage}}'><span class='result-total'>{{total}}</span>{{{tooltip}}}</a>
</div>
</div>
93 changes: 93 additions & 0 deletions html/statistics.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

<section class='content'>
<nav class="tabs" data-group='sections'>
<a class='item' data-tab='session' title='{{localize "MARS5E.statistics.tooltips.session"}}'>{{ localize "MARS5E.statistics.session" }}</a>
<a class="item" data-tab="world" >{{ localize "MARS5E.statistics.world" }}</a>
</nav>
<table>
<thead></thead> <!-- Tables are weird! this, at least for chrome, does what i want.. -->
<tr>
<th></th>
<th colspan=2>{{localize 'DND5E.Damage'}}</th>
<th>{{localize 'DND5E.Healing'}}</th>
<th colspan=2>{{localize 'DND5E.AttackPl'}}</th>
<th></th>
<th></th>
<th colspan=2>{{localize 'MARS5E.statistics.natural'}}</th>

</tr>
<th data-type="name">{{localize 'Name'}}</th>
<th data-type="dmgDone" title="{{localize 'MARS5E.statistics.tooltips.dmgDone'}}">{{localize 'MARS5E.statistics.done'}}</th>
<th data-type="dmgTaken" title="{{localize 'MARS5E.statistics.tooltips.dmgTaken'}}">{{localize 'MARS5E.statistics.taken'}}</th>
<th data-type="healingDone" title="{{localize 'MARS5E.statistics.tooltips.healingDone'}}">{{localize 'MARS5E.statistics.done'}}</th>
<th data-type="hit" title="{{localize 'MARS5E.statistics.tooltips.hit'}}">{{localize 'MARS5E.statistics.hit'}}</th>
<th data-type="attacks" title="{{localize 'MARS5E.statistics.tooltips.attacks'}}">{{localize 'MARS5E.statistics.made'}}</th>
<th data-type="kills" title="{{localize 'MARS5E.statistics.tooltips.kills'}}">{{localize 'MARS5E.statistics.kills'}}</th>
<th data-type="unconscious" title="{{localize 'MARS5E.statistics.tooltips.unconscious'}}">{{localize 'MARS5E.statistics.unconscious'}}</th>
<th data-type="nat1s" title="{{localize 'MARS5E.statistics.tooltips.nat1s'}}">{{localize 'MARS5E.statistics.1s'}}</th>
<th data-type="nat20s" title="{{localize 'MARS5E.statistics.tooltips.nat20s'}}">{{localize 'MARS5E.statistics.20s'}}</th>
</tr>
{{#each user}}
<tr class='tab' data-tab='world' data-group='sections'>
<td>{{this.name}}</td>
<td>
{{this.world.dmgDone}}
</td>
<td>
{{this.world.dmgTaken}}
</td>
<td>
{{this.world.healingDone}}
</td>
<td>
{{this.world.hits}}
</td>
<td>
{{this.world.attacks}}
</td>
<td>
{{this.world.kills}}
</td>
<td>
{{this.world.unconscious}}
</td>
<td>
{{this.world.nat1}}
</td>
<td>
{{this.world.nat20}}
</td>
</tr>
<tr class='tab' data-tab='session' data-group='sections'>
<td>{{this.name}}</td>
<td>
{{this.session.dmgDone}}
</td>
<td>
{{this.session.dmgTaken}}
</td>
<td>
{{this.session.healingDone}}
</td>
<td>
{{this.session.hits}}
</td>
<td>
{{this.session.attacks}}
</td>
<td>
{{this.session.kills}}
</td>
<td>
{{this.session.unconscious}}
</td>
<td>
{{this.session.nat1}}
</td>
<td>
{{this.session.nat20}}
</td>
</tr>
{{/each}}
</table>
</section>
55 changes: 51 additions & 4 deletions js/actor/entity.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Mars5eUserStatistics from "../statistics.js";
import { markSuccess, markFail } from "../util.js";

export default function initActorClass() {
return class Mars5eActor extends CONFIG.Actor.entityClass {
rollAbilitySave(
Expand Down Expand Up @@ -81,10 +84,31 @@ export default function initActorClass() {
tooltip: await roll.getTooltip(),
};

const template = await renderTemplate(
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
Expand All @@ -98,12 +122,13 @@ export default function initActorClass() {
await game.dice3d.showForRoll(
roll,
game.user,
chatData.whisper,
chatData.blind
true,
chatData.whisper || null,
chatData.blind || null
);
}

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

rollAbilityTest(abilityId, options = {}) {
Expand All @@ -130,5 +155,27 @@ export default function initActorClass() {
})}`
);
}

async update(data, options = {}) {
const oldHp = expandObject(data).data?.attributes?.hp
? duplicate(getProperty(this.data, "data.attributes.hp"))
: null;
return super.update(data, options).then((entity) => {
if (!oldHp) return;
const user = game.users.find(
(user) => user.character?.id === entity.id
);

if (!user) return;
const newHp = duplicate(getProperty(this.data, "data.attributes.hp"));
const dHp = oldHp.value + oldHp.temp - newHp.value - newHp.temp;
const statistics = {
dmgTaken: dHp > 0 ? dHp : 0,
unconscious: oldHp.value > 0 && newHp.value === 0 ? 1 : 0,
};

Mars5eUserStatistics.update(user, statistics);
});
}
};
}
Loading

0 comments on commit 0eb0b57

Please sign in to comment.