Skip to content

Commit

Permalink
[FEATURE] Adding on deck marker/player only option
Browse files Browse the repository at this point in the history
  • Loading branch information
kckaiwei committed May 1, 2021
1 parent 3d575d3 commit dbe5082
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# 2.7.4
- Fixed marker sizing for non-square tokens on grid/gridless maps
- Added on deck marker option (off by default)
- - Option for player owned only
- Animation and image options

# 2.7.3
- Fixed deletion permissions in different scenes issue
Expand Down
2 changes: 1 addition & 1 deletion dist/scripts/turnmarker.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/scripts/turnmarker.js.map

Large diffs are not rendered by default.

15 changes: 4 additions & 11 deletions dist/templates/updateWindow.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ <h2>v2.7.4</h2>
<li>Fixed marker sizing issues for non-square tokens on grid/gridless maps</li>
<li>Adding option for on deck marker (off by default), to mark who is next to move</li>
</ul>
<p style="display: flex; flex-flow: row nowrap; align-items: center; justify-content: flex-start;"><input
type="checkbox" class='show-again' id="welcome-screen-show-again" /> <label
for="welcome-screen-show-again">Don't show this screen again until next update.</label>
</p>
<h2>v2.7.3</h2>
<ul>
<li>Fixed tile deletion issue in different scenes</li>
Expand All @@ -47,10 +43,7 @@ <h2>v2.7.1</h2>
<li>Fixing ghosting issues with some start markers</li>
<li>Fixing turn marker showing when out of combat</li>
</ul>
<h2>v2.7.0</h2>
<ul>
<li>Test compatibility with Foundry v0.7.9</li>
<li>You can now select who to announce turns for: all, players, npcs, or all w/ npc names hidden</li>
<li>Options have been added to switch between announcing turns by Token name, or Actor name (for those subterfuge moments)</li>
<li>Fixed a console error when moving a token outside of combat</li>
</ul>
<p style="display: flex; flex-flow: row nowrap; align-items: center; justify-content: flex-start;"><input
type="checkbox" class='show-again' id="welcome-screen-show-again" /> <label
for="welcome-screen-show-again">Don't show this screen again until next update.</label>
</p>
22 changes: 21 additions & 1 deletion src/scripts/turnmarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Hooks.on('updateCombat', async (combat, update) => {
lastTurn = combat.combatant._id;
if (combat && combat.combatant && combat.started) {
await Marker.placeStartMarker(combat.combatant.token._id);
await Marker.placeOnDeckMarker(combat.turns[nextTurn].token._id);
createCombatDeckMarker(combat, nextTurn);
let tile = canvas.tiles.placeables.find(t => t.data.flags.turnMarker == true);
await Marker.placeTurnMarker(combat.combatant.token._id, (tile && tile.id) || undefined);
if (Settings.shouldAnnounceTurns() && !combat.combatant.hidden) {
Expand Down Expand Up @@ -204,6 +204,26 @@ function isVisible(tile) {
return canvas.sight.testVisibility(tile.center, {tolerance, object: tile});
}

async function createCombatDeckMarker(combat, nextTurn) {
if (Settings.getDeckPlayersOnly()) {
if (combat.turns[nextTurn].actor.hasPlayerOwner) {
await Marker.placeOnDeckMarker(combat.turns[nextTurn].token._id).then(function () {
if (Settings.getShouldAnimate("deckmarker")) {
MarkerAnimation.startAnimation("deckmarker");
}
});
} else {
await Marker.deleteOnDeckMarker();
}
} else {
await Marker.placeOnDeckMarker(combat.turns[nextTurn].token._id).then(function () {
if (Settings.getShouldAnimate("deckmarker")) {
MarkerAnimation.startAnimation("deckmarker");
}
});
}
}

Hooks.on('updateTile', (entity, data, options, userId) => {
if (data.flags.turnMarker || data.flags.startMarker || data.flags.deckMarker) {
const tile = canvas.tiles.placeables.find(t => t.id === data._id);
Expand Down
15 changes: 4 additions & 11 deletions src/templates/updateWindow.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ <h2>v2.7.4</h2>
<li>Fixed marker sizing issues for non-square tokens on grid/gridless maps</li>
<li>Adding option for on deck marker (off by default), to mark who is next to move</li>
</ul>
<p style="display: flex; flex-flow: row nowrap; align-items: center; justify-content: flex-start;"><input
type="checkbox" class='show-again' id="welcome-screen-show-again" /> <label
for="welcome-screen-show-again">Don't show this screen again until next update.</label>
</p>
<h2>v2.7.3</h2>
<ul>
<li>Fixed tile deletion issue in different scenes</li>
Expand All @@ -47,10 +43,7 @@ <h2>v2.7.1</h2>
<li>Fixing ghosting issues with some start markers</li>
<li>Fixing turn marker showing when out of combat</li>
</ul>
<h2>v2.7.0</h2>
<ul>
<li>Test compatibility with Foundry v0.7.9</li>
<li>You can now select who to announce turns for: all, players, npcs, or all w/ npc names hidden</li>
<li>Options have been added to switch between announcing turns by Token name, or Actor name (for those subterfuge moments)</li>
<li>Fixed a console error when moving a token outside of combat</li>
</ul>
<p style="display: flex; flex-flow: row nowrap; align-items: center; justify-content: flex-start;"><input
type="checkbox" class='show-again' id="welcome-screen-show-again" /> <label
for="welcome-screen-show-again">Don't show this screen again until next update.</label>
</p>

0 comments on commit dbe5082

Please # to comment.