Added new tokens and database upgrade

This commit is contained in:
Mitchell McCaffrey 2020-05-18 16:31:32 +10:00
parent ba17aec263
commit f080b675dd
54 changed files with 124 additions and 39 deletions

View File

@ -23,6 +23,7 @@ function Tokens({ onCreateMapTokenState, tokens }) {
onCreateMapTokenState({
id: shortid.generate(),
tokenId: token.id,
type: token.type,
owner: userId,
size: tokenSize,
label: "",

View File

@ -26,6 +26,68 @@ function loadVersions(db) {
map.file = mapBuffers[map.id];
});
});
// v1.3.0 - Added new default tokens
db.version(3)
.stores({})
.upgrade((tx) => {
return tx
.table("states")
.toCollection()
.modify((state) => {
function mapTokenId(id) {
switch (id) {
case "__default-Axes":
return "__default-barbarian";
case "__default-Bird":
return "__default-druid";
case "__default-Book":
return "__default-wizard";
case "__default-Crown":
return "__default-humanoid";
case "__default-Dragon":
return "__default-dragon";
case "__default-Eye":
return "__default-warlock";
case "__default-Fist":
return "__default-monk";
case "__default-Horse":
return "__default-fey";
case "__default-Leaf":
return "__default-druid";
case "__default-Lion":
return "__default-monstrosity";
case "__default-Money":
return "__default-humanoid";
case "__default-Moon":
return "__default-cleric";
case "__default-Potion":
return "__default-sorcerer";
case "__default-Shield":
return "__default-paladin";
case "__default-Skull":
return "__default-undead";
case "__default-Snake":
return "__default-beast";
case "__default-Sun":
return "__default-cleric";
case "__default-Swords":
return "__default-fighter";
case "__default-Tree":
return "__default-plant";
case "__default-Triangle":
return "__default-sorcerer";
default:
return "__default-fighter";
}
}
for (let stateId in state.tokens) {
state.tokens[stateId].tokenId = mapTokenId(
state.tokens[stateId].tokenId
);
state.tokens[stateId].type = "default";
}
});
});
}
// Get the dexie database used in DatabaseContext

View File

@ -450,7 +450,7 @@ function Game() {
for (let defaultToken of defaultTokens) {
defaultTokensWithIds.push({
...defaultToken,
id: `__default-${defaultToken.name}`,
id: `__default-${defaultToken.key}`,
owner: userId,
});
}

BIN
src/tokens/Aberration.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
src/tokens/Artificer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

BIN
src/tokens/Barbarian.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
src/tokens/Bard.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
src/tokens/Beast.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

BIN
src/tokens/Blood Hunter.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

BIN
src/tokens/Celestial.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

BIN
src/tokens/Cleric.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

BIN
src/tokens/Construct.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 104 KiB

After

Width:  |  Height:  |  Size: 86 KiB

BIN
src/tokens/Druid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

BIN
src/tokens/Elemental.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

BIN
src/tokens/Fey.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

BIN
src/tokens/Fiend.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

BIN
src/tokens/Fighter.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

BIN
src/tokens/Giant.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
src/tokens/Goblinoid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

BIN
src/tokens/Humanoid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

BIN
src/tokens/Monk.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

BIN
src/tokens/Monstrosity.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

BIN
src/tokens/Ooze.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

BIN
src/tokens/Paladin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
src/tokens/Plant.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

BIN
src/tokens/Ranger.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

BIN
src/tokens/Rouge.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

BIN
src/tokens/Shapechanger.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

BIN
src/tokens/Sorcerer.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

BIN
src/tokens/Titan.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

BIN
src/tokens/Undead.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

BIN
src/tokens/Warlock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

BIN
src/tokens/Wizard.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

View File

@ -1,45 +1,67 @@
import axes from "./Axes.png";
import bird from "./Bird.png";
import book from "./Book.png";
import crown from "./Crown.png";
import aberration from "./Aberration.png";
import artificer from "./Artificer.png";
import barbarian from "./Barbarian.png";
import bard from "./Bard.png";
import beast from "./Beast.png";
import bloodHunter from "./Blood Hunter.png";
import celestial from "./Celestial.png";
import cleric from "./Cleric.png";
import construct from "./Construct.png";
import dragon from "./Dragon.png";
import eye from "./Eye.png";
import fist from "./Fist.png";
import horse from "./Horse.png";
import leaf from "./Leaf.png";
import lion from "./Lion.png";
import money from "./Money.png";
import moon from "./Moon.png";
import potion from "./Potion.png";
import shield from "./Shield.png";
import skull from "./Skull.png";
import snake from "./Snake.png";
import sun from "./Sun.png";
import swords from "./Swords.png";
import tree from "./Tree.png";
import triangle from "./Triangle.png";
import druid from "./Druid.png";
import elemental from "./Elemental.png";
import fey from "./Fey.png";
import fiend from "./Fiend.png";
import fighter from "./Fighter.png";
import giant from "./Giant.png";
import goblinoid from "./Goblinoid.png";
import humanoid from "./Humanoid.png";
import monk from "./Monk.png";
import monstrosity from "./Monstrosity.png";
import ooze from "./Ooze.png";
import paladin from "./Paladin.png";
import plant from "./Plant.png";
import ranger from "./Ranger.png";
import rouge from "./Rouge.png";
import shapechanger from "./Shapechanger.png";
import sorcerer from "./Sorcerer.png";
import titan from "./Titan.png";
import undead from "./Undead.png";
import warlock from "./Warlock.png";
import wizard from "./Wizard.png";
export const tokenSources = {
axes,
bird,
book,
crown,
barbarian,
bard,
cleric,
druid,
fighter,
monk,
paladin,
ranger,
rouge,
sorcerer,
warlock,
wizard,
artificer,
bloodHunter,
aberration,
beast,
celestial,
construct,
dragon,
eye,
fist,
horse,
leaf,
lion,
money,
moon,
potion,
shield,
skull,
snake,
sun,
swords,
tree,
triangle,
elemental,
fey,
fiend,
giant,
goblinoid,
humanoid,
monstrosity,
ooze,
plant,
shapechanger,
titan,
undead,
};
export const tokens = Object.keys(tokenSources).map((key) => ({