feat: Allow switching to specially named backdrops

The `switch costume` block accepts special values like "next costume" and
"previous costume". If you create a costume with these names, these take
priority over the special values. However, the `switch backdrop` block
keeps these special values for values like "next backdrop", "previous
backdrop", "random backdrop". It is impossible to navigate to such a
backdrop by name via block. This commit also modifies tests to allow for
this.

BREAKING CHANGE: specially-named backdrops can now be navigated
This commit is contained in:
jokebookservice1 2018-10-10 20:06:54 +01:00
parent 0c18b4952d
commit 341bd8f3d3
No known key found for this signature in database
GPG key ID: A872407E9C478467
2 changed files with 11 additions and 8 deletions

View file

@ -129,9 +129,11 @@ test('switch backdrop block runs correctly', t => {
t.strictEqual(testBackdrop(['a', 'b', 'c', 'd'], 'previous backdrop', 3), 2);
t.strictEqual(testBackdrop(['a', 'b', 'c', 'd'], 'next backdrop', 2), 3);
// 'previous backdrop' and 'next backdrop' can't be overriden
t.strictEqual(testBackdrop(['a', 'previous backdrop', 'c', 'd'], 'previous backdrop', 4), 3);
t.strictEqual(testBackdrop(['next backdrop', 'b', 'c', 'd'], 'next backdrop'), 2);
// 'previous backdrop', 'previous backdrop', 'random backdrop' can be overriden
// Test is deterministic since 'random backdrop' will not pick the same backdrop as currently selected
t.strictEqual(testBackdrop(['a', 'previous backdrop', 'c', 'd'], 'previous backdrop', 4), 2);
t.strictEqual(testBackdrop(['next backdrop', 'b', 'c', 'd'], 'next backdrop', 3), 1);
t.strictEqual(testBackdrop(['random backdrop', 'b', 'c', 'd'], 'random backdrop'), 1);
// NaN, Infinity, and true are the first costume
t.strictEqual(testBackdrop(['a', 'b', 'c', 'd'], NaN, 2), 1);