Skip to content

Commit

Permalink
fix: Macro for same item name now creates (#314)
Browse files Browse the repository at this point in the history
* fix: async restores treasure result text (#272)

* fix: async restores treasure result text

* fix: avoid race conditions with flag "async:false"

* fix: Monster Data Model bugfixes (#279)

* fix: On dropping item onto actor, check for existence before checking for anything related to containers

* fix: Remove pre-container-data-model code for handling containers on monsters

* fix: Programmers and linguists agree: Why Plurals?

* fix: don't reroll on round 1 if already rolled (#280)

* Create CNAME

* docs: add Haxxer as a contributor for code (#281)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* fix(temporary): removed caching from the build ci

* fix: AC/AAC display fix + party overview fix (#286)

* fix: Add missing usesAscendingAC key

* fix: Update deprecated code

* fix: use game.system.id instead of OSE.systemName when getting party members

* fix: Additional v1.7.x fixes (#289)

* fix: Character generator now properly sets scores

* fix: Items should once again properly display their descriptions.

* fix: Treasure items should be created under the Treasure inventory heading

* fix: Item and armor descriptions should target the correct fields

* fix: replaced broken chart with "translated" badge

* chore: update README to where people can find the Discord invite

* feat: add Catalan and Chinese support to manifest

* Updates to Item Piles system integration (#292)

* Updates to system integration

* Added unstackable item types

* [enhancement] Added option to revert Ctrl/Meta behavior (#294)

* [enhancement] Added option to revert Ctrl/Meta behavior

* Extracted skipDialogCheck to method

* Removed comment about monster testing.

* Moved skipRollDialogcheck to helper collection

* cleanup

Co-authored-by: bakbakbakbakbak <[email protected]>

* docs: add bakbakbakbakbak as a contributor for code (#302)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* docs: add adn770 as a contributor for translation (#303)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* [enhancement] Container delete confirmation (#299)

* [enhancement] Added confirmation when deleting containers containing items

* [fix] Container now pushes out containing items.

* Changed to Dialog.confirm

* Cleanup

* cleanup

* Allow first item check condition to allow no item

Co-authored-by: bakbakbakbakbak <[email protected]>

* fix: shopping cart now deducts gold

* Remove confusing monster options (#308)

Co-authored-by: bakbakbakbakbak <[email protected]>

* [fix] Correctly creating link anchors in TextEditor & dragging items to hotbar (#304)

* [fix] Use item.getDragData to fix bad link

* [fix] Macro creation when dragging item from actor

* Fixed macro warning for non-actor items

* Tests for item macros

* Cleanup

* Unlinked token macro fix

* Fixed typo in en.json

* Fixed bug on row 67

* Non-destructive macro removal

* Macro logic

* Cleanup

Co-authored-by: bakbakbakbakbak <[email protected]>

* fix: Macro for same item name now creates

Co-authored-by: Anthony Ronda <[email protected]>
Co-authored-by: Tim <[email protected]>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Adam Oresten <[email protected]>
Co-authored-by: bakbakbakbakbak <[email protected]>
  • Loading branch information
6 people authored Jan 23, 2023
1 parent d268006 commit 01c0174
Show file tree
Hide file tree
Showing 27 changed files with 387 additions and 119 deletions.
18 changes: 18 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,24 @@
"contributions": [
"code"
]
},
{
"login": "bakbakbakbakbak",
"name": "bakbakbakbakbak",
"avatar_url": "https://avatars.githubusercontent.com/u/105067023?v=4",
"profile": "https://github.com/bakbakbakbakbak",
"contributions": [
"code"
]
},
{
"login": "adn770",
"name": "Josep Torra",
"avatar_url": "https://avatars.githubusercontent.com/u/113786?v=4",
"profile": "https://github.com/adn770",
"contributions": [
"translation"
]
}
],
"contributorsPerLine": 7,
Expand Down
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
</p>

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-13-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->
[![Forge Installs](https://img.shields.io/badge/dynamic/json?label=Forge%20Installs&query=package.installs&suffix=%25&url=https%3A%2F%2Fforge-vtt.com%2Fapi%2Fbazaar%2Fpackage%2Fose&colorB=4aa94a)](https://forge-vtt.com/bazaar#package=ose)
[![Foundry Hub Endorsements](https://img.shields.io/endpoint?logoColor=white&url=https%3A%2F%2Fwww.foundryvtt-hub.com%2Fwp-json%2Fhubapi%2Fv1%2Fpackage%2Fose%2Fshield%2Fendorsements)](https://www.foundryvtt-hub.com/package/ose/)
[![Foundry Hub Comments](https://img.shields.io/endpoint?logoColor=white&url=https%3A%2F%2Fwww.foundryvtt-hub.com%2Fwp-json%2Fhubapi%2Fv1%2Fpackage%2Fose%2Fshield%2Fcomments)](https://www.foundryvtt-hub.com/package/ose/)
[![Crowdin](https://badges.crowdin.net/ose/localized.svg)](https://crowdin.com/project/ose)

## Installation

Expand Down Expand Up @@ -58,7 +59,7 @@ It's always appreciated when users [submit an issue](https://github.com/vttred/o

- The **#dnd-other** channel in the [official Foundry VTT Discord server](https://discord.gg/foundryvtt)
- The **#ose-virtual-tabletop** channel in the [official Necrotic Gnome Discord server](https://discord.gg/YprM5nq)
- There is a Discord server for Unofficial Old-School Essentials on Foundry VTT. Please ask for the invite link in one of the above places. We are sensitive to the possibility of spam and phishing attacks, so we do not post it on GitHub directly. This space is subject to the [VTT Red Code of Conduct](/CODE_OF_CONDUCT.md).
- There is a Discord server for Unofficial Old-School Essentials on Foundry VTT. You can find it on this repo's [New Issue](https://github.com/vttred/ose/issues/new/choose) page.
- There are [unofficial Foundry VTT user communities for many other languages](https://www.foundryvtt-hub.com/links/#internationaldiscords) if you'd prefer to discuss Foundry VTT in another language. Keep in mind that it's unlikely you'll find answers to your questions about a less popular game system like Old-School Essentials, but they are good for asking questions about Foundry VTT in general.
- The [/r/FoundryVTT community on Reddit](https://reddit.com/r/FoundryVTT) may also have answers to your Foundry VTT questions, but it is another general Foundry VTT user community that may not have many users with specific knowledge about OSE. Be sure to write `[OSE]` in your post subject and select `FVTT Question` from the "Flair" menu.

Expand All @@ -72,12 +73,6 @@ If you're a developer, look for our [CONTRIBUTING.md](/CONTRIBUTING.md) file.

If you speak a non-English language, [Join the ose project on Crowdin](https://crowdin.com/project/ose).

### Language Support Chart

[![Language support chart](https://badges.awesome-crowdin.com/translation-15191204-504892.png)](https://crowdin.com/project/ose)

Above is a list of all languages we need help supporting. The ones with shorter bars need your help by submitting a few more words and phrases for full language support. The ones with green bar segments need your help by proofreading submitted words and phrases.

## Open Game Content Used Under License

See [LICENSE.OGL](/LICENSE.OGL) file.
Expand Down Expand Up @@ -122,15 +117,25 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<table>
<tbody>
<tr>
<td align="center"><a href="https://github.com/Godforsaken84"><img src="https://avatars.githubusercontent.com/u/100036544?v=4?s=100" width="100px;" alt="Godforsaken84"/><br /><sub><b>Godforsaken84</b></sub></a><br /><a href="#design-Godforsaken84" title="Design">🎨</a></td>
<td align="center"><a href="https://github.com/freohr"><img src="https://avatars.githubusercontent.com/u/3462951?v=4?s=100" width="100px;" alt="Stephen FAURE"/><br /><sub><b>Stephen FAURE</b></sub></a><br /><a href="https://github.com/vttred/ose/commits?author=freohr" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/engleback"><img src="https://avatars.githubusercontent.com/u/35422051?v=4?s=100" width="100px;" alt="Ian Engleback"/><br /><sub><b>Ian Engleback</b></sub></a><br /><a href="https://github.com/vttred/ose/commits?author=engleback" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/RabidOwlbear"><img src="https://avatars.githubusercontent.com/u/71675732?v=4?s=100" width="100px;" alt="Grim"/><br /><sub><b>Grim</b></sub></a><br /><a href="https://github.com/vttred/ose/commits?author=RabidOwlbear" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/WallaceMcGregor"><img src="https://avatars.githubusercontent.com/u/17795541?v=4?s=100" width="100px;" alt="WallaceMcGregor"/><br /><sub><b>WallaceMcGregor</b></sub></a><br /><a href="#translation-WallaceMcGregor" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/IGALEGOI"><img src="https://avatars.githubusercontent.com/u/97805442?v=4?s=100" width="100px;" alt="IGALEGOI"/><br /><sub><b>IGALEGOI</b></sub></a><br /><a href="#translation-IGALEGOI" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/sanviler"><img src="https://avatars.githubusercontent.com/u/96877404?v=4?s=100" width="100px;" alt="Lorenzo Castelletta"/><br /><sub><b>Lorenzo Castelletta</b></sub></a><br /><a href="#translation-sanviler" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Godforsaken84"><img src="https://avatars.githubusercontent.com/u/100036544?v=4?s=100" width="100px;" alt="Godforsaken84"/><br /><sub><b>Godforsaken84</b></sub></a><br /><a href="#design-Godforsaken84" title="Design">🎨</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/freohr"><img src="https://avatars.githubusercontent.com/u/3462951?v=4?s=100" width="100px;" alt="Stephen FAURE"/><br /><sub><b>Stephen FAURE</b></sub></a><br /><a href="https://github.com/vttred/ose/commits?author=freohr" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/engleback"><img src="https://avatars.githubusercontent.com/u/35422051?v=4?s=100" width="100px;" alt="Ian Engleback"/><br /><sub><b>Ian Engleback</b></sub></a><br /><a href="https://github.com/vttred/ose/commits?author=engleback" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/RabidOwlbear"><img src="https://avatars.githubusercontent.com/u/71675732?v=4?s=100" width="100px;" alt="Grim"/><br /><sub><b>Grim</b></sub></a><br /><a href="https://github.com/vttred/ose/commits?author=RabidOwlbear" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/WallaceMcGregor"><img src="https://avatars.githubusercontent.com/u/17795541?v=4?s=100" width="100px;" alt="WallaceMcGregor"/><br /><sub><b>WallaceMcGregor</b></sub></a><br /><a href="#translation-WallaceMcGregor" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/IGALEGOI"><img src="https://avatars.githubusercontent.com/u/97805442?v=4?s=100" width="100px;" alt="IGALEGOI"/><br /><sub><b>IGALEGOI</b></sub></a><br /><a href="#translation-IGALEGOI" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sanviler"><img src="https://avatars.githubusercontent.com/u/96877404?v=4?s=100" width="100px;" alt="Lorenzo Castelletta"/><br /><sub><b>Lorenzo Castelletta</b></sub></a><br /><a href="#translation-sanviler" title="Translation">🌍</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/HerrSquash"><img src="https://avatars.githubusercontent.com/u/97633309?v=4?s=100" width="100px;" alt="herrsquash"/><br /><sub><b>herrsquash</b></sub></a><br /><a href="#translation-herrsquash" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://linktr.ee/teuri"><img src="https://avatars.githubusercontent.com/u/64547748?v=4?s=100" width="100px;" alt="Igor Teuri"/><br /><sub><b>Igor Teuri</b></sub></a><br /><a href="#translation-igorteuri" title="Translation">🌍</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/hogwrassler"><img src="https://avatars.githubusercontent.com/u/110945935?v=4?s=100" width="100px;" alt="hogwrassler"/><br /><sub><b>hogwrassler</b></sub></a><br /><a href="https://github.com/vttred/ose/commits?author=hogwrassler" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://timsnyder.codes"><img src="https://avatars.githubusercontent.com/u/1731267?v=4?s=100" width="100px;" alt="Tim"/><br /><sub><b>Tim</b></sub></a><br /><a href="https://github.com/vttred/ose/commits?author=wyrmisis" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/maschill92"><img src="https://avatars.githubusercontent.com/u/4692066?v=4?s=100" width="100px;" alt="Michael Schilling"/><br /><sub><b>Michael Schilling</b></sub></a><br /><a href="https://github.com/vttred/ose/commits?author=maschill92" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://adamoresten.com"><img src="https://avatars.githubusercontent.com/u/12858387?v=4?s=100" width="100px;" alt="Adam Oresten"/><br /><sub><b>Adam Oresten</b></sub></a><br /><a href="https://github.com/vttred/ose/commits?author=Haxxer" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/bakbakbakbakbak"><img src="https://avatars.githubusercontent.com/u/105067023?v=4?s=100" width="100px;" alt="bakbakbakbakbak"/><br /><sub><b>bakbakbakbakbak</b></sub></a><br /><a href="https://github.com/vttred/ose/commits?author=bakbakbakbakbak" title="Code">💻</a></td>
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/adn770"><img src="https://avatars.githubusercontent.com/u/113786?v=4?s=100" width="100px;" alt="Josep Torra"/><br /><sub><b>Josep Torra</b></sub></a><br /><a href="#translation-adn770" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/HerrSquash"><img src="https://avatars.githubusercontent.com/u/97633309?v=4?s=100" width="100px;" alt="herrsquash"/><br /><sub><b>herrsquash</b></sub></a><br /><a href="#translation-herrsquash" title="Translation">🌍</a></td>
<td align="center"><a href="http://linktr.ee/teuri"><img src="https://avatars.githubusercontent.com/u/64547748?v=4?s=100" width="100px;" alt="Igor Teuri"/><br /><sub><b>Igor Teuri</b></sub></a><br /><a href="#translation-igorteuri" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/hogwrassler"><img src="https://avatars.githubusercontent.com/u/110945935?v=4?s=100" width="100px;" alt="hogwrassler"/><br /><sub><b>hogwrassler</b></sub></a><br /><a href="https://github.com/vttred/ose/commits?author=hogwrassler" title="Code">💻</a></td>
Expand Down
101 changes: 100 additions & 1 deletion src/e2e/actor/character.e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ export const options = {
displayName: 'The Character Sheet'
};

export default ({before, beforeEach, after, describe, it, expect, ...context}) => {
/**
* If there are dialogs, close them.
* @returns {Promise} the promise from closing dialogs
*/
export const closeRollDialog = async () => {
const openDialogs = Object.values(ui.windows).filter(o => o.options.classes.indexOf('dialog') > -1);

openDialogs?.forEach(async (o) => {
await o.close();
})
}

export default ({before, beforeEach, after, afterEach, describe, it, expect, ...context}) => {
const testCharacterName = 'Quench Test Character';
const prepareActor = async (data) => {
await trashChat();
Expand All @@ -17,6 +29,7 @@ export default ({before, beforeEach, after, describe, it, expect, ...context}) =
type: 'character'
});
};

const testActor = () => game.actors.getName(testCharacterName);
const trashActor = () => testActor()?.delete();

Expand All @@ -26,6 +39,20 @@ export default ({before, beforeEach, after, describe, it, expect, ...context}) =
expect(game.messages.size).to.equal(1);
}

const rollNoModsSkipDialog = async (key, rollFn) => {
const ctrl_down = new KeyboardEvent('keydown', {ctrlKey: true});
await testActor()[rollFn](key, {event: ctrl_down});
await waitForInput();
expect(game.messages.size).to.equal(1);
}

const rollNoModsSkipDialogMeta = async (key, rollFn) => {
const meta_down = new KeyboardEvent('keydown', {metaKey: true});
await testActor()[rollFn](key, {event: meta_down});
await waitForInput();
expect(game.messages.size).to.equal(1);
}

const rollMods = async (key, rollFn) => {
testActor()[rollFn](key);

Expand All @@ -40,16 +67,88 @@ export default ({before, beforeEach, after, describe, it, expect, ...context}) =
expect(game.messages.size).to.equal(1);
}

const rollInvertCtrlNoDialog = async (key, rollFn) => {
await testActor()[rollFn](key, {fastForward: false});
await waitForInput();

expect(game.messages.size).to.equal(1);
}

const rollInvertCtrlDialog = async (key, rollFn) => {
const ctrl_down = new KeyboardEvent('keydown', {ctrlKey: true});
testActor()[rollFn](key, {event: ctrl_down});

await waitForInput();

const dialog = document.querySelector('.roll-dialog.ose');
expect(dialog).not.equal(null)

dialog.closest('.window-content').querySelector('.dialog-button.ok').click();

await waitForInput();
expect(game.messages.size).to.equal(1);
}

const rollInvertCtrlDialogMeta = async (key, rollFn) => {
const meta_down = new KeyboardEvent('keydown', {metaKey: true});
testActor()[rollFn](key, {event: meta_down});

await waitForInput();

const dialog = document.querySelector('.roll-dialog.ose');
expect(dialog).not.equal(null)

dialog.closest('.window-content').querySelector('.dialog-button.ok').click();

await waitForInput();
expect(game.messages.size).to.equal(1);
}

const canRoll = (key, rollFn) => {
before(async () => {
await game.settings.set(game.system.id, "invertedCtrlBehavior", false);
})

beforeEach(async () => {
await trashChat();
})

afterEach(async () => {
await closeRollDialog();
})
it('With no modifiers', async () => {
await rollNoMods(key, rollFn);
})
it('Skipping dialog, holding ctrl', async () => {
await rollNoModsSkipDialog(key, rollFn);
})
it('Skipping dialog, holding meta', async () => {
await rollNoModsSkipDialogMeta(key, rollFn);
})
it('With modifiers', async () => {
await rollMods(key, rollFn);
})

describe('Inverted Ctrl behavior', () => {
before(async () => {
await game.settings.set(game.system.id, "invertedCtrlBehavior", true);
})

after(async () => {
await game.settings.set(game.system.id, "invertedCtrlBehavior", false);
})

it('Inverted ctrl behavior without dialog', async() => {
await rollInvertCtrlNoDialog(key, rollFn);
})
it('Inverted ctrl behavior with dialog, ctrl key', async() => {
await rollInvertCtrlDialog(key, rollFn);
})
it('Inverted ctrl behavior with dialog, meta key', async() => {
await rollInvertCtrlDialogMeta(key, rollFn);
})
})

}

before(async () => {
Expand Down
70 changes: 70 additions & 0 deletions src/e2e/actor/createItemMacro.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { createOseMacro } from '../../module/macros';
import { trashChat, waitForInput } from '../testUtils';


export const key = 'ose.actor.macro';
export const options = {
displayName: 'The Character Sheet: Item Macros'
};

export default ({ before, beforeEach, after, describe, it, expect, assert, ...context }) => {
const testCharacterName = 'Quench Test Character';
const prepareActor = async (data) => {
await trashChat();
await trashActor();

return Actor.create({
...data,
name: testCharacterName,
type: 'character'
});
};
const testActor = () => game.actors.getName(testCharacterName);
const trashActor = () => testActor()?.delete();
const trashMacro = async () => {
await game.macros.find(o => o.name === "Test Macro Item")?.delete();
await game.user.assignHotbarMacro(null, 1);
}
const createItem = (type) => { return testActor()?.createEmbeddedDocuments("Item", [{ type: type, name: "Test Macro Item" }]) };

const createItemMacroData = (item) => {
const dragData = item.toDragData();
dragData.item = item;
dragData.type = "Item"
return dragData
};

const canCreate = async (type) => {
await createItem(type);
const item = testActor().items.contents[0];
const data = createItemMacroData(item);
const macro = await createOseMacro(data, 1);
await waitForInput();

const createdMacro = game.user.getHotbarMacros()[0];
expect(createdMacro?.macro?.command.indexOf("game.ose.rollItemMacro")).not.equal(-1)
}

before(async () => {
await trashChat();
})

describe('Item Macro', () => {
before(async () => {
await prepareActor();
trashMacro();
})

after(async () => {
await trashChat();
await trashActor();
})

afterEach(() => {
trashMacro();
})

it('Create weapon macro', async () => { await canCreate("weapon") })
it('Create spell macro', async () => { await canCreate("spell") })
})
};
8 changes: 7 additions & 1 deletion src/e2e/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import characterItemMacroTests, {
key as characterItemMacroKey,
options as characterItemMacroOptions
} from './actor/createItemMacro.test';

import characterTests, {
key as characterKey,
options as characterOptions
Expand Down Expand Up @@ -46,7 +51,8 @@ type Quench = {
}

Hooks.on('quenchReady', async (quench: Quench) => {
quench.registerBatch(characterKey, characterTests, characterOptions)
quench.registerBatch(characterItemMacroKey, characterItemMacroTests, characterItemMacroOptions);
quench.registerBatch(characterKey, characterTests, characterOptions);
// Character data model classes
quench.registerBatch(dataModelCharacterACKey, dataModelCharacterACTests, dataModelCharacterACOptions);
quench.registerBatch(dataModelCharacterScoresKey, dataModelCharacterScoresTests, dataModelCharacterScoresOptions);
Expand Down
Loading

0 comments on commit 01c0174

Please sign in to comment.