Compare commits

..

29 Commits
0.2.0 ... 0.2.6

Author SHA1 Message Date
Stefan Zermatten
43c4122fe3 Fixed stack dragging within the same container 2015-05-11 17:10:58 +02:00
Stefan Zermatten
3f4dcc146a fixed charId's being out of date after re-parenting 2015-05-11 17:10:28 +02:00
Stefan Zermatten
e4600decd0 Added more things to except list for need sign in 2015-05-11 16:51:17 +02:00
Stefan Zermatten
f6df716870 Rewrote how item drag and drop works. Need to update charId's to keep up. 2015-05-11 16:51:02 +02:00
Stefan Zermatten
b99da301cd Updated meteor 2015-05-11 12:16:38 +02:00
Stefan Zermatten
0a01885300 Finished implementing useraccounts 2015-05-11 12:15:00 +02:00
Stefan Zermatten
5cb1515235 Began implementing useraccounts and permissions properly 2015-05-08 12:59:38 +02:00
Stefan Zermatten
7430c2c795 Prevented evaluate crashing when given duff abilityMod strings 2015-05-06 12:12:18 +02:00
Stefan Zermatten
39f7548b8d Fixed singlecharacter publication returning undefined rather than an empty array 2015-05-06 12:11:37 +02:00
Stefan Zermatten
c4a8c4b7ba Fixed typos in the guide, floating action buttons are on the bottom RIGHT not left 2015-05-04 10:01:47 +02:00
Stefan Zermatten
263aba596c Changed Guide styling to be more spacious 2015-05-04 09:53:29 +02:00
Stefan Zermatten
f98ed0b659 Fixed old proficiency dialog showing up after it has been depreciated 2015-04-30 07:42:59 +02:00
Stefan Zermatten
6159ce0e88 Characters menu item now shows up when no characters yet exist 2015-04-30 07:42:30 +02:00
Stefan Zermatten
e9509a3a24 Fixed containers not responding to rename or delete 2015-04-30 07:30:37 +02:00
Stefan Zermatten
aa069fd885 Removed single character subscription vulnerability 2015-04-30 07:18:42 +02:00
Stefan Zermatten
99a64667c6 Removed proficiency from effects 2015-04-29 12:31:51 +02:00
Stefan Zermatten
e05fa064d5 Added basic user guide 2015-04-29 12:25:51 +02:00
Stefan Zermatten
b95636a8a3 Added a side list for characters 2015-04-29 10:16:12 +02:00
Stefan Zermatten
bd6c7cd106 paper sliders no longer jump to points, they need to be dragged 2015-04-29 08:57:09 +02:00
Stefan Zermatten
6b1ff343c2 Persona dialogs now correctly update their input fields 2015-04-29 08:47:55 +02:00
Stefan Zermatten
9e7e027fe9 Share dialog style improvement, can delete shares 2015-04-29 08:38:47 +02:00
Stefan Zermatten
79e0f917df Gave share dialog a done button 2015-04-29 08:16:24 +02:00
Stefan Zermatten
4bddf8d5d3 Racial proficiencies now show up when inserted. 2015-04-29 08:14:01 +02:00
Stefan Zermatten
57159d6cfe Identity dialog now opens as expected 2015-04-29 08:13:09 +02:00
Stefan Zermatten
56957e0ef0 No longer showing ID of users shared to, will show username or nothing 2015-04-29 07:53:00 +02:00
Stefan Zermatten
31e7b8d610 In-progress implementing usernames for share dialog 2015-04-24 12:16:12 +02:00
Stefan Zermatten
e0209df270 Features now always enabled by default 2015-04-24 12:15:50 +02:00
Stefan Zermatten
40500517af Fixed hit dice dialog and arrow positions. 2015-04-24 12:15:32 +02:00
Stefan Zermatten
c1222ad51d Race dialog now animates properly 2015-04-24 11:26:54 +02:00
51 changed files with 860 additions and 399 deletions

View File

@@ -20,3 +20,7 @@ mike:mocha
dburles:mongo-collection-instances
percolate:migrations
ecwyne:mathjs
useraccounts:polymer
accounts-google
splendido:accounts-meld
email

View File

@@ -1,9 +1,11 @@
accounts-base@1.2.0
accounts-google@1.0.4
accounts-oauth@1.1.5
accounts-password@1.1.1
accounts-ui@1.1.5
accounts-ui-unstyled@1.1.7
aldeed:collection2@2.3.3
aldeed:simple-schema@1.3.2
aldeed:simple-schema@1.3.3
amplify@1.0.0
autoupdate@1.2.1
base64@1.0.3
@@ -24,6 +26,7 @@ ejson@1.0.6
email@1.0.6
fastclick@1.0.3
geojson-utils@1.0.3
google@1.1.5
html-tools@1.0.4
htmljs@1.0.4
http@1.1.0
@@ -44,20 +47,22 @@ less@1.0.14
livedata@1.0.13
localstorage@1.0.3
logging@1.0.7
matb33:collection-hooks@0.7.11
matb33:collection-hooks@0.7.13
meteor@1.1.6
meteor-platform@1.2.2
mike:mocha@0.5.3
mike:mocha@0.5.4
minifiers@1.1.5
minimongo@1.0.8
mobile-status-bar@1.0.3
momentjs:moment@2.10.3
mongo@1.1.0
npm-bcrypt@0.7.8_2
oauth@1.1.4
oauth2@1.1.3
observe-sequence@1.0.6
ordered-dict@1.0.3
package-version-parser@3.0.3
percolate:migrations@0.7.3
percolate:migrations@0.7.5
practicalmeteor:chai@1.9.2_3
practicalmeteor:loglevel@1.1.0_3
random@1.0.3
@@ -72,16 +77,21 @@ sanjo:meteor-version@1.0.0
service-configuration@1.0.4
session@1.1.0
sha@1.0.3
softwarerero:accounts-t9n@1.0.9
spacebars@1.0.6
spacebars-compiler@1.0.6
splendido:accounts-emails-field@1.2.0
splendido:accounts-meld@1.3.0
srp@1.0.3
templating@1.1.1
tracker@1.0.7
ui@1.0.6
underscore@1.0.3
url@1.0.4
useraccounts:core@1.9.1
useraccounts:polymer@1.9.1
velocity:chokidar@0.12.6_1
velocity:core@0.6.0
velocity:core@0.6.1
velocity:html-reporter@0.5.3
velocity:meteor-internals@1.1.0_7
velocity:shim@0.1.0

View File

@@ -19,6 +19,156 @@ Schemas.Item = new SimpleSchema({
Items.attachSchema(Schemas.Item);
var checkMovePermission = function(itemId, parent) {
var item = Items.findOne(itemId);
if (!item)
throw new Meteor.Error("No such item",
"An item could not be found to move");
//handle permissions
var permission = Meteor.call("canWriteCharacter", item.charId);
if (!permission){
throw new Meteor.Error("Access denied",
"Not permitted to move items from this character");
}
if (parent.collection === "Characters"){
permission = Meteor.call("canWriteCharacter", parent.id);
if (!permission){
throw new Meteor.Error("Access denied",
"Not permitted to move items to this character");
}
} else {
var parentCollectionObject = global[parent.collection];
var parentObject = null;
if (parentCollectionObject)
parentObject = parentCollectionObject.findOne(
parent.id, {fields: {_id: 1, charId: 1}}
);
if (!parentObject) throw new Meteor.Error(
"Invalid parent",
"The destination parent " + parent.id +
" does not exist in the collection " + parent.collection
);
if (parentObject.charId){
permission = Meteor.call("canWriteCharacter", parentObject.charId);
if (!permission){
throw new Meteor.Error("Access denied",
"Not permitted to move items to this character");
}
}
}
};
var moveItem = function(itemId, enable, parentCollection, parentId) {
var item = Items.findOne(itemId);
if (!item) return;
parentCollection = parentCollection || item.parent.collection;
parentId = parentId || item.parent.id;
if (Meteor.isServer) {
checkMovePermission(itemId, {collection: parentCollection, id: parentId});
}
//update the item provided the update will actually change something
if (
item.parent.collection !== parentCollection ||
item.parent.id !== parentId ||
item.enabled !== enable
){
Items.update(
itemId,
{$set: {
"parent.collection": parentCollection,
"parent.id": parentId,
enabled: enable,
}}
);
}
};
Meteor.methods({
moveItemToParent: function(itemId, parent) {
check(itemId, String);
check(parent, {collection: String, id: String});
moveItem(itemId, false, parent.collection, parent.id);
},
moveItemToCharacter: function(itemId, charId) {
check(itemId, String);
check(charId, String);
moveItem(itemId, false, "Characters", charId);
},
moveItemToContainer: function(itemId, containerId) {
check(itemId, String);
check(containerId, String);
moveItem(itemId, false, "Containers", containerId);
},
equipItem: function(itemId, charId){
check(itemId, String);
check(charId, String);
moveItem(itemId, true, "Characters", charId);
},
unequipItem: function(itemId, charId){
check(itemId, String);
check(charId, String);
moveItem(itemId, false, "Characters", charId);
},
splitItemToParent: function(itemId, moveQuantity, parent){
check(itemId, String);
check(moveQuantity, Number);
check(parent, {id: String, collection: String});
//get the item
var item = Items.findOne(itemId);
if (!item) return;
//don't bother moving nothing
if (moveQuantity <= 0 || item.quantity <= 0){
return;
}
//ensure we are only moving up to the current stack size
if (item.quantity < moveQuantity){
moveQuantity = this.quantity;
}
if (Meteor.isServer) {
checkMovePermission(itemId, parent);
}
//create a new item stack
var newStack = _.omit(EJSON.clone(item), "_id");
newStack.parent = parent;
newStack.quantity = moveQuantity;
//find out if we have an exact replica in the destination
var query = _.omit(newStack, ["parent", "quantity"]);
query["parent.collection"] = newStack.parent.collection;
query["parent.id"] = newStack.parent.id;
query._id = {$ne: itemId}; //make sure we don't join it to itself
var existingStack = Items.findOne(query);
if (existingStack){
//increase the existing stack's size
Items.update(
existingStack._id,
{$inc: {quantity: moveQuantity}}
);
} else {
//insert the new stack
Items.insert(newStack, function(err, id){
if (err) throw err;
//copy the children also
Meteor.call("cloneChildren", item._id, {collection: "Items", id: id});
});
}
//reduce the old stack's size
var oldQuantity = item.quantity - moveQuantity;
if (oldQuantity === 0){
Items.remove(itemId);
} else {
Items.update(itemId, {$set: {quantity: oldQuantity}});
}
},
});
Items.helpers({
totalValue: function(){
return this.value * this.quantity;
@@ -33,103 +183,6 @@ Items.helpers({
return this.name;
}
},
equip: function(characterId){
var charId = characterId || this.charId;
if (!charId || !Characters.findOne(charId)) throw "Invalid character";
if (this.parent.collection === "Characters" &&
this.parent.id === charId &&
this.enabled) {
return;
}
Items.update(
this._id,
{$set: {
"parent.collection": "Characters",
"parent.id": charId,
enabled: true,
}}
);
},
unequip: function(){
if (!this.enabled) return;
Items.update(this._id, {$set: {enabled: false}});
},
moveToContainer: function(containerId){
if (!containerId || !Containers.findOne(containerId)){
throw "Invalid container";
}
if (this.parent.collection === "Containers" &&
this.parent.id === containerId &&
!this.enabled) return;
Items.update(
this._id,
{$set: {
"parent.collection": "Containers",
"parent.id": containerId,
enabled: false,
}}
);
},
moveToCharacter: function(characterId){
if (!characterId || !Characters.findOne(characterId)) {
throw "Invalid character";
}
if (this.parent.collection === "Characters" &&
this.parent.id === characterId &&
!this.enabled) return;
Items.update(
this._id,
{$set: {
"parent.collection": "Characters",
"parent.id": characterId,
charId: characterId,
enabled: false,
}}
);
},
splitToParent: function(parent, moveQuantity){
check(parent, {id: String, collection: String});
check(moveQuantity, Number);
var parentCollection = Meteor.isClient ?
window[parent.collection] : global[parent.collection];
if (!parent.id || !parentCollection.findOne(parent.id)){
throw "Invalid parent";
}
var oldStack = this;
//we can only move as much as we have, leaving 0 behind at worst
if (oldStack.quantity < moveQuantity) moveQuantity = oldStack.quantity;
var oldQuantity = oldStack.quantity - moveQuantity;
var newStack = _.pick(oldStack, Schemas.Item.objectKeys());
newStack.parent = parent;
newStack.quantity = moveQuantity;
var existingStack = Items.findOne(_.omit(newStack, "quantity"));
var updateStackSize = function(){
if (oldQuantity > 0){
Items.update(oldStack._id, {$set: {quantity: oldQuantity}});
} else {
Items.remove(oldStack._id);
}
};
if (existingStack){
Items.update(
existingStack._id,
{$inc: {quantity: moveQuantity}},
{},
function(){
updateStackSize();
}
);
} else {
Items.insert(newStack, function(err, id){
if (err) throw err;
updateStackSize();
//copy the children also
Meteor.call("cloneChildren", oldStack._id, {collection: "Items", id: id});
});
}
},
});
Items.before.update(function(userId, doc, fieldNames, modifier, options){

View File

@@ -1,44 +1,23 @@
Schema = {};
Schema.User = new SimpleSchema({
username: {
type: String,
regEx: /^[a-z0-9A-Z_]{3,15}$/,
optional: true,
},
emails: {
type: [Object],
// this must be optional if you also use other login services like facebook,
// but if you use only accounts-password, then it can be required
optional: true,
},
"emails.$.address": {
type: String,
regEx: SimpleSchema.RegEx.Email,
},
"emails.$.verified": {
type: Boolean
},
createdAt: {
type: Date
},
services: {
type: Object,
optional: true,
blackbox: true,
},
roles: {
type: [String],
optional: true,
},
});
Meteor.users.attachSchema(Schema.User);
Meteor.users.allow({
update: function(userId, doc, fields, modifier) {
return userId === doc._id &&
fields.length === 1 &&
fields[0] === "username";
if (
doc._id === userId &&
_.contains(fields, "username") &&
_.contains(fields, "profile") &&
fields.length === 2 &&
_.keys(modifier).length === 1 &&
modifier.$set &&
modifier.$set["profile.username"] &&
modifier.$set.username &&
_.keys(modifier.$set).length === 2
){
var expectedUsername = modifier.$set["profile.username"];
expectedUsername = expectedUsername.toLowerCase().replace(/\s+/gm, "");
if (modifier.$set.username !== expectedUsername){
return false;
}
var foundUser = Meteor.call("getUserId", expectedUsername);
return !foundUser || foundUser === userId;
}
}
});

View File

@@ -3,22 +3,30 @@ Router.configure({
layoutTemplate: "layout",
});
Router.plugin("ensureSignedIn", {
except: [
"home",
"atSignIn",
"atSignUp",
"atForgotPassword",
"atResetPwd",
"atEnrollAccount",
"atVerifyEmail",
"atresendVerificationEmail",
"loginButtons",
"notFound",
]
});
Router.plugin("dataNotFound", {notFoundTemplate: "notFound"});
Router.map(function() {
/*
this.route("home", {
path: "/",
waitOn: function(){
return Meteor.subscribe("characterList", Meteor.userId());
},
data: {
characters: function(){
return Characters.find({}, {fields: {_id: 1}});
}
}
});*/ //add a home route and change characterList route
this.route("/", {
name: "home",
});
this.route("characterList", {
path: "/",
path: "/characterList",
waitOn: function(){
return Meteor.subscribe("characterList", Meteor.userId());
},
@@ -65,4 +73,8 @@ Router.map(function() {
document.title = appName + " Account";
},
});
this.route("/loginButtons", {
name: "loginButtons",
})
});

View File

@@ -63,6 +63,10 @@ paper-button {
letter-spacing: 0.010;
}
core-item {
cursor: pointer;
}
.listRow {
height: 32px;
}

View File

@@ -1,26 +1,42 @@
<template name="shareDialog">
<div>
<div style="width: 360px;">
<div>
<div class="subhead">
Can View
</div>
{{#each readers}}
{{this}}<br>
{{/each}}
<div class="subhead">
Can Edit
</div>
{{#each writers}}
{{this}}<br>
{{/each}}
{{#if readers.count}}
<div style="font-weight: 500;">
Can View
</div>
{{#each readers}}
<div layout horizontal center>
<div flex>{{username}}</div>
<paper-icon-button class="deleteShare" icon="delete"></paper-icon-button>
</div>
{{/each}}
{{/if}}
{{#if writers.count}}
<div style="font-weight: 500;">
Can Edit
</div>
{{#each writers}}
<div layout horizontal center>
<div flex>{{username}}</div>
<paper-icon-button class="deleteShare" icon="delete"></paper-icon-button>
</div>
{{/each}}
{{/if}}
</div>
<paper-input id="userNameOrEmailInput" label="Username or email" floatinglabel></paper-input><br>
{{#if userFindError}}<p style="color: red;">{{userFindError}}</p>{{/if}}
<div layout horizontal center>
<paper-input flex id="userNameOrEmailInput" label="Username or email" floatinglabel></paper-input>
<paper-button id="shareButton"
class="red-button"
style="width: 80px; height: 37px; margin-top: 16px;"
raised
disabled={{shareButtonDisabled}}>Share</paper-button>
</div>
<p style="color: red;">{{userFindError}}</p>
<paper-radio-group id="accessLevelMenu" selected="read">
<paper-radio-button name="read" label="View Only"></paper-radio-button>
<paper-radio-button name="write" label="Can Edit"></paper-radio-button>
</paper-radio-group>
<br>
<paper-button id="shareButton" class="red-button" raised disabled={{shareButtonDisabled}}>Share</paper-button>
</div>
<paper-button id="doneButton" affirmative> Done </paper-button>
</template>

View File

@@ -5,11 +5,11 @@ Template.shareDialog.onCreated(function(){
Template.shareDialog.helpers({
readers: function(){
var char = Characters.findOne(this._id, {fields: {readers: 1}});
return char && char.readers;
return Meteor.users.find({_id: {$in: char.readers}});
},
writers: function(){
var char = Characters.findOne(this._id, {fields: {writers: 1}});
return char && char.writers;
return Meteor.users.find({_id: {$in: char.writers}});
},
shareButtonDisabled: function(){
return !Template.instance().userId.get();
@@ -18,11 +18,11 @@ Template.shareDialog.helpers({
if (!Template.instance().userId.get()){
return "User not found";
}
}
},
});
Template.shareDialog.events({
"input #userNameOrEmailInput, change #userNameOrEmailInput":
"input #userNameOrEmailInput":
function(event, instance){
var userName = instance.find("#userNameOrEmailInput").value;
instance.userId.set(undefined);
@@ -44,13 +44,18 @@ Template.shareDialog.events({
if (permission === "write"){
Characters.update(self._id, {
$addToSet: {writers: userId},
$pull: {readers: userId}
$pull: {readers: userId},
});
} else {
Characters.update(self._id, {
$addToSet: {readers: userId},
$pull: {writers: userId}
$pull: {writers: userId},
});
}
}
},
"tap .deleteShare": function(event, instance) {
Characters.update(instance.data._id, {
$pull: {writers: this._id, readers: this._id}
});
},
});

View File

@@ -52,15 +52,3 @@
</paper-dropdown>
</paper-dropdown-menu>
</template>
<template name="proficiencyEffectValue">
<paper-dropdown-menu class="proficiencyDropDown" label="Proficiency" flex>
<paper-dropdown layered class="dropdown">
<core-menu class="menu proficiencyMenu" selected={{value}}>
<paper-item name="1">Proficient</paper-item>
<paper-item name="0.5">Half Prof. Bonus</paper-item>
<paper-item name="2">Double Prof. Bonus</paper-item>
</core-menu>
</paper-dropdown>
</paper-dropdown-menu>
</template>

View File

@@ -82,7 +82,6 @@ var attributeOperations = [
{name: "Max", operation: "max"}
];
var skillOperations = [
{name: "Proficiency", operation: "proficiency"},
{name: "Add", operation: "add"},
{name: "Multiply", operation: "mul"},
{name: "Min", operation: "min"},
@@ -128,8 +127,6 @@ Template.effectEdit.helpers({
if (!op) return null;
//operations that don't need templates
if (op === "advantage" || op === "disadvantage" || op === "fail") return null;
//proficiency template
if (op === "proficiency") return "proficiencyEffectValue";
//default template
return "regularEffectValue";
@@ -154,13 +151,7 @@ Template.effectEdit.events({
var oldName = Template.instance().selectedStatGroup.get();
if (oldName != groupName){
instance.selectedStatGroup.set(groupName);
if (groupName === "Skills" || groupName === "Saving Throws"){
Effects.update(this._id, {$set: {
operation: "proficiency",
value: 1,
calculation: ""
}, $unset: {stat: ""}});
} else if (groupName === "Weakness/Resistance"){
if (groupName === "Weakness/Resistance"){
Effects.update(this._id, {$set: {
value: 0.5,
calculation: "",
@@ -197,13 +188,6 @@ Template.effectEdit.events({
operation: "mul"
}});
},
"core-select .proficiencyDropDown": function(event){
var detail = event.originalEvent.detail;
if (!detail.isSelected) return;
var value = +detail.item.getAttribute("name");
if (value == this.value) return;
Effects.update(this._id, {$set: {value: value, calculation: ""}});
},
"change .effectValueInput": function(event){
var value = event.currentTarget.value;
var numValue = +value;

View File

@@ -3,7 +3,7 @@ Template.effectsEditList.helpers({
var selector = {
"parent.id": this.parentId,
"parent.collection": this.parentCollection,
"charId": this.charId
"charId": this.charId,
};
if (this.parentGroup){
selector["parent.group"] = this.parentGroup;
@@ -23,10 +23,11 @@ Template.effectsEditList.events({
charId: this.charId,
parent: {
id: this.parentId,
collection: this.parentCollection
collection: this.parentCollection,
group: this.parentGroup,
},
operation: "add",
enabled: this.enabled
enabled: this.enabled,
});
},
});

View File

@@ -55,9 +55,15 @@ Template.featureEdit.helpers({
return _.isString(this.uses);
},
enabledSelection: function(){
if (!this.enabled) return "disabled";
if (this.alwaysEnabled) return "alwaysEnabled";
return "enabled";
if (this.enabled){
if (this.alwaysEnabled){
return "alwaysEnabled";
} else {
return "enabled";
}
} else if (this.enabled === false){ //make sure it is false, not just falsey
return "disabled";
}
},
});

View File

@@ -39,7 +39,12 @@ Template.features.helpers({
Template.features.events({
"tap #addFeature": function(event){
var featureId = Features.insert({name: "New Feature", charId: this._id});
var featureId = Features.insert({
name: "New Feature",
charId: this._id,
enabled: true,
alwaysEnabled: true,
});
GlobalUI.setDetail({
template: "featureDialog",
data: {featureId: featureId, charId: this._id, startEditing: true},
@@ -80,19 +85,6 @@ Template.features.events({
var featureId = this._id;
Features.update(featureId, {$set: {used: 0}});
},
"tap #proficiencies": function(event){
var charId = this._id;
GlobalUI.setDetail({
template: "textDialog",
data: {
charId: charId,
field: "proficiencies",
title: "Proficiencies",
color: "q",
},
heroId: this._id + "proficiencies",
});
},
"tap .enabledCheckbox": function(event){
event.stopPropagation();
},

View File

@@ -9,7 +9,7 @@
</template>
<template name="containerEdit">
<paper-input id="containerNameInput fullwidth"
<paper-input id="containerNameInput"
label="Name"
floatinglabel
value={{name}}></paper-input>

View File

@@ -4,11 +4,7 @@ Template.containerDialog.helpers({
}
});
Template.containerEdit.onRendered(function(){
updatePolymerInputs(this);
});
Template.containerEdit.events({
Template.containerDialog.events({
"color-change": function(event, instance){
Containers.update(instance.data.containerId, {$set: {color: event.color}});
},
@@ -20,8 +16,15 @@ Template.containerEdit.events({
);
GlobalUI.closeDetail();
},
});
Template.containerEdit.onRendered(function(){
updatePolymerInputs(this);
});
Template.containerEdit.events({
//TODO validate input (integer, non-negative, etc) for these inputs and give validation errors
"change #containerNameInput, input #containerNameInput": function(event){
"change #containerNameInput": function(event){
var name = Template.instance().find("#containerNameInput").value;
Containers.update(this._id, {$set: {name: name}});
},

View File

@@ -174,71 +174,93 @@ Template.inventoryItem.helpers({
Template.layout.events({
"dragstart .inventoryItem": function(event, instance){
event.originalEvent.dataTransfer.setData("dicecloud-id/items", this._id);
Session.set("inventory.dragItemId", this._id);
Session.set("inventory.dragItemOriginalContainer", this.container);
Session.set("inventory.dragItemOriginalCharacter", this.charId);
},
"dragover .itemContainer, dragenter .itemContainer":
function(event, instance){
if (_.contains(event.originalEvent.dataTransfer.types, "dicecloud-id/items")){
event.preventDefault();
}
},
"dragover .equipmentContainer, dragenter .equipmentContainer":
function(event, instance){
if (_.contains(event.originalEvent.dataTransfer.types, "dicecloud-id/items")){
event.preventDefault();
}
},
"dragover .carriedContainer, dragenter .carriedContainer":
function(event, instance){
if (_.contains(event.originalEvent.dataTransfer.types, "dicecloud-id/items")){
event.preventDefault();
}
},
"dragover .characterRepresentative, dragenter .characterRepresentative":
function(event, instance){
if (_.contains(event.originalEvent.dataTransfer.types, "dicecloud-id/items")){
event.preventDefault();
}
},
"dragend .inventoryItem": function(event, instance){
resetInvetorySession(); //this is a valid drop zone
Session.set("inventory.dragItemId", null);
},
"dragover .itemContainer": function(event, instance){
event.preventDefault();
},
"dragover .equipmentContainer": function(event, instance){
event.preventDefault();
},
"dragover .carriedContainer": function(event, instance){
event.preventDefault();
},
"drop .itemContainer": function(event, instacne){
var item = Items.findOne(Session.get("inventory.dragItemId"));
"drop .itemContainer": function(event, instance){
var itemId = event.originalEvent.dataTransfer.getData("dicecloud-id/items");
if (event.ctrlKey){
//split the stack to the container
GlobalUI.showDialog({
template: "splitStackDialog",
data: {
id: item._id,
id: itemId,
parentCollection: "Containers",
parentId: this._id,
},
});
} else {
//move item to the container
item.moveToContainer(this._id);
Meteor.call("moveItemToContainer", itemId, this._id);
}
resetInvetorySession();
Session.set("inventory.dragItemId", null);
},
"drop .equipmentContainer": function(event, instance){
var charId = Session.get("inventory.dragItemOriginalCharacter");
var item = Items.findOne(Session.get("inventory.dragItemId"));
item.equip(charId);
resetInvetorySession();
var itemId = event.originalEvent.dataTransfer.getData("dicecloud-id/items");
Meteor.call("equipItem", itemId, this._id);
Session.set("inventory.dragItemId", null);
},
"drop .carriedContainer": function(event, instance){
var charId = Session.get("inventory.dragItemOriginalCharacter");
var item = Items.findOne(Session.get("inventory.dragItemId"));
var itemId = event.originalEvent.dataTransfer.getData("dicecloud-id/items");
if (event.ctrlKey){
//split the stack to the container
GlobalUI.showDialog({
template: "splitStackDialog",
data: {
id: item._id,
id: itemId,
parentCollection: "Characters",
parentId: this._id,
},
});
} else {
//move item to the character
item.moveToCharacter(this._id);
Meteor.call("moveItemToCharacter", itemId, this._id);
}
resetInvetorySession();
Session.set("inventory.dragItemId", null);
},
"drop .characterRepresentative": function(event, instance) {
var itemId = event.originalEvent.dataTransfer.getData("dicecloud-id/items");
if (event.ctrlKey){
//split the stack to the container
GlobalUI.showDialog({
template: "splitStackDialog",
data: {
id: itemId,
parentCollection: "Characters",
parentId: this._id,
},
});
} else {
//move item to the character
Meteor.call("moveItemToCharacter", itemId, this._id);
}
Session.set("inventory.dragItemId", null);
},
});
var resetInvetorySession = function(){
_.defer(function(){
Session.set("inventory.dragItemId", null);
Session.set("inventory.dragItemOriginalContainer", null);
Session.set("inventory.dragItemOriginalCharacter", null);
});
};

View File

@@ -81,13 +81,10 @@ Template.itemEdit.events({
},
"change #equippedInput": function(event){
var equipped = Template.instance().find("#equippedInput").checked;
var item = Items.findOne(this._id);
if (item){
if (equipped){
item.equip();
} else {
item.unequip();
}
if (equipped){
Meteor.call("equipItem", this._id, this.charId);
} else {
Meteor.call("unequipItem", this._id, this.charId);
}
},
"change #attunementCheckbox": function(event){
@@ -107,7 +104,6 @@ Template.containerDropdown.events({
var detail = event.originalEvent.detail;
if (!detail.isSelected) return;
var containerId = detail.item.getAttribute("name");
var item = Items.findOne(Template.currentData()._id);
item.moveToContainer(containerId);
Meteor.call("moveItemToContainer", Template.currentData()._id, containerId);
}
});

View File

@@ -7,13 +7,12 @@ Template.splitStackDialog.helpers({
Template.splitStackDialog.events({
"tap #moveButton": function(event, instance){
var item = Items.findOne(this.id);
if (item){
item.splitToParent(
{collection: this.parentCollection , id: this.parentId},
+instance.find("#quantityInput").value
);
}
Meteor.call(
"splitItemToParent",
this.id,
+instance.find("#quantityInput").value,
{collection: this.parentCollection , id: this.parentId}
);
},
"tap #oneButton":function(event, instance){
instance.find("#quantityInput").value = 1;

View File

@@ -40,7 +40,7 @@
</div>
<div class="containerMain experiences">
<div class="itemSlot">
<paper-item class="inventoryItem race" hero-id="main" {{detailHero "race"}} layout horizontal>
<paper-item class="inventoryItem race" hero-id="main" {{detailHero "race" _id}} layout horizontal>
{{race}}
</paper-item>
</div>

View File

@@ -2,13 +2,17 @@
{{#baseDialog title=name class="deep-purple white-text" hideColor="true" hideDelete="true" startEditing=startEditing}}
{{alignment}} {{gender}} {{race}}
{{else}}
<!--Name-->
<paper-input id="nameInput" label="Name" floatinglabel value={{name}}></paper-input><br>
<!--Alignment-->
<paper-input id="alignmentInput" label="Alignment" floatinglabel value={{alignment}}></paper-input><br>
<!--Gender-->
<paper-input id="genderInput" label="Gender" floatinglabel value={{gender}}></paper-input><br>
<!--Race-->
<paper-input id="raceInput" label="Race" floatinglabel value={{race}}></paper-input><br>
{{> personaDetailsEdit}}
{{/baseDialog}}
</template>
</template>
<template name="personaDetailsEdit">
<!--Name-->
<paper-input id="nameInput" label="Name" floatinglabel value={{name}}></paper-input><br>
<!--Alignment-->
<paper-input id="alignmentInput" label="Alignment" floatinglabel value={{alignment}}></paper-input><br>
<!--Gender-->
<paper-input id="genderInput" label="Gender" floatinglabel value={{gender}}></paper-input><br>
<!--Race-->
<paper-input id="raceInput" label="Race" floatinglabel value={{race}}></paper-input><br>
</template>

View File

@@ -1,8 +1,8 @@
Template.personaDetailsDialog.onRendered(function(){
Template.personaDetailsEdit.onRendered(function(){
updatePolymerInputs(this);
});
Template.personaDetailsDialog.events({
Template.personaDetailsEdit.events({
"change #nameInput": function(event){
var input = event.currentTarget.value;
Characters.update(this.charId, {$set: {name: input}});

View File

@@ -16,6 +16,7 @@ Template.persona.helpers({
char.field = "details";
char.title = char.name;
char.color = "d";
char.topClass = "characterField";
return char;
},
characterField: function(field, title){
@@ -56,7 +57,7 @@ Template.persona.events({
GlobalUI.setDetail({
template: "personaDetailsDialog",
data: this,
heroId: this._id + "details",
heroId: this._id + this.field,
});
}
}

View File

@@ -2,10 +2,14 @@
{{#baseDialog title=title class=colorClass hideColor="true" hideDelete="true" startEditing=startEditing}}
<div class="prewrap">{{value}}</div>
{{else}}
<paper-input-decorator label={{title}} floatinglabel layout vertical>
<paper-autogrow-textarea>
<textarea id="textInput" placeholder value={{value}}></textarea>
</paper-autogrow-textarea>
</paper-input-decorator>
{{> textDialogEdit}}
{{/baseDialog}}
</template>
</template>
<template name="textDialogEdit">
<paper-input-decorator label={{title}} floatinglabel layout vertical>
<paper-autogrow-textarea>
<textarea id="textInput" placeholder value={{value}}></textarea>
</paper-autogrow-textarea>
</paper-input-decorator>
</template>

View File

@@ -1,7 +1,3 @@
Template.textDialog.onRendered(function(){
updatePolymerInputs(this);
});
Template.textDialog.helpers({
value: function(){
var fieldSelector = {fields: {}};
@@ -11,7 +7,20 @@ Template.textDialog.helpers({
}
});
Template.textDialog.events({
Template.textDialogEdit.onRendered(function(){
updatePolymerInputs(this);
});
Template.textDialogEdit.helpers({
value: function(){
var fieldSelector = {fields: {}};
fieldSelector.fields[this.field] = 1;
var char = Characters.findOne(this.charId, fieldSelector);
return char[this.field];
}
});
Template.textDialogEdit.events({
"change #textInput": function(event){
var input = event.currentTarget.value;
var setter = {$set: {}};

View File

@@ -21,6 +21,7 @@ Template.proficiencyEditList.events({
parent: {
id: this.parentId,
collection: this.parentCollection,
group: this.parentGroup,
},
enabled: this.enabled,
value: 1,

View File

@@ -1,7 +1,11 @@
<template name="hitDice">
{{#if char.attributeBase name}}
<paper-shadow class="card container" hero-id="main" {{detailHero}} layout horizontal>
<div class="containerLeft green">
{{#if ../attributeBase name}}
<paper-shadow class="card container" hero-id="main" {{detailHero name ../_id}} layout horizontal>
<div class="containerLeft green" layout horizontal hero-id="toolbar" {{detailHero name ../_id}}>
<div class="resourceButtons">
<paper-icon-button class="resourceUp" icon="arrow-drop-up" disabled={{cantIncrement}}></paper-icon-button>
<paper-icon-button class="resourceDown" icon="arrow-drop-down" disabled={{cantDecrement}}></paper-icon-button>
</div>
<div class="resourceValue" layout vertical center>
<div>
{{../attributeValue name}}
@@ -10,12 +14,8 @@
d{{diceNum}} {{../abilityMod "constitution"}}
</div>
</div>
<div class="resourceButtons">
<paper-icon-button class="resourceUp" icon="arrow-drop-up" disabled={{cantIncrement}}></paper-icon-button>
<paper-icon-button class="resourceDown" icon="arrow-drop-down" disabled={{cantDecrement}}></paper-icon-button>
</div>
</div>
<div class="containerRight" flex relative horizontal layout center>
<div class="containerRight clickable" flex relative horizontal layout center>
Hit Dice
<paper-ripple fit></paper-ripple>
</div>

View File

@@ -25,4 +25,13 @@ Template.hitDice.events({
Characters.update(this.char._id, modifier, {validate: false});
}
},
"tap .containerRight": function() {
var charId = Template.parentData()._id;
var title = "d" + this.diceNum + " Hit Dice";
GlobalUI.setDetail({
template: "attributeDialog",
data: {name: title, statName: this.name, charId: charId},
heroId: charId + this.name,
});
},
});

View File

@@ -0,0 +1,11 @@
.singleLineItem {
color: black;
color: rgba(0, 0, 0, 0.870588);
cursor: pointer;
font-size: 16px;
height: 40px;
overflow: hidden;
padding: 12px 0 12px 16px;
text-overflow: ellipsis;
white-space: nowrap;
}

View File

@@ -0,0 +1,10 @@
<template name="characterSideList">
<core-item icon="social:people" label="Characters"></core-item>
{{#if characters.count}}
<div>
{{#each characters}}
<div class="singleLineItem characterRepresentative">{{name}}</div>
{{/each}}
</div>
{{/if}}
</template>

View File

@@ -0,0 +1,28 @@
Template.characterSideList.onCreated(function() {
this.subscribe("characterList");
});
Template.characterSideList.helpers({
characters: function() {
var userId = Meteor.userId();
return Characters.find(
{
$or: [
{readers: userId},
{writers: userId},
{owner: userId},
]
},
{fields: {name: 1}}
);
}
});
Template.characterSideList.events({
"tap .singleLineItem": function(event, instance) {
Router.go("characterSheet", {_id: this._id});
},
"tap core-item": function() {
Router.go("characterList");
},
});

View File

@@ -0,0 +1,7 @@
.wallOfText h2{
margin-top: 24px
}
.wallOfText p{
margin-top: 8px;
}

View File

@@ -0,0 +1,92 @@
<template name="guide">
<div class="wallOfText">
<h1>Dicecloud Beta</h1>
<p>Welcome to the Dicecloud beta. Please don't share the link with people you don't actively play with, since the beta is intended to be small, and your experience will probably get laggy if it gets more traffic than I'm expecting.</p>
<p>The beta is going to start with just the character sheet. You can play D&amp;D without minis and maps, without a pre-written adventure, you can play without a lot of things, but the character sheet is necessary. So I'm starting here and working my way outwards.</p>
<p>I will eventually have public bug tracking and feature requests going, but for now I'm going to track comments, feedback and suggestions on <a href="http://reddit.com/r/dicecloud">this subreddit</a>. If you've never used reddit before, all you need is a username and password to sign up. So it should be pretty accessible.</p>
<h2>Character Sheet Philosophy</h2>
<p>Setting up your character on Dicecloud is going to take you a little longer than just filling it in on a paper character sheet would have. The goal of using an online sheet is to make actually playing the game more streamlined, and ultimately more fun. So putting a little extra effort into setting up your character now will pay off over and over again once you're playing.</p>
<p>The idea is to track where each number comes from, and allow you to easily make changes on the fly.</p>
<p>Lets look at a hypothetical example.</p>
<p>You need to swim through a sunken section of dungeon to fetch the quest's Thing.<br>You'll need to take off your magical Plate Armor of +1 Constitution to swim without sinking, of course. Taking it off will change your armor class, your speed and your constitution, which in turn changes your hitpoints and your constitution saving throw. Working out all those changes in the middle of a game will drag the game to a hault. <br> Fortunately you have a digital character sheet, so it's a matter of dragging your Plate Armor +1 Con from your "equipment" box to your "backpack" box and you're done. Your hitpoints change correctly, your saving throws are up to date, your armor class goes back to reflecting the fact that you have natural armor from being a dragonborn. Your character sheet keeps up and you ultimately get more time to play the game. Huzzah!</p>
<h2>Creating a Character</h2>
<ul>
<li>In the <a href={{pathFor route="characterList"}}>character list</a>, click the plus button, floating in the bottom right corner.</li>
<li>Give your character a name, gender and race, these can be changed later if you change your mind. Then click the Add button</li>
<li>Your new character should open, with most of its attributes and abilities at zero.</li>
</ul>
<h2>Adding Racial Effects</h2>
<p>You have already given your character a race, but you haven't yet specified what that race does for your character, so lets do that.</p>
<ul>
<li>Click the Journal tab</li>
<li>In the card that displays your level, click on your race to open the racial dialog box</li>
<li>Click the edit button in the top corner of the racial dialog</li>
</ul>
<p>In the edit mode of the racial dialog you can change your race's name and add effects and proficiencies your race gives you. We will only be adding the base traits our race gives us, specific features can go in the features tab so we can more easily reference them later.</p>
<p>Lets add some of the effects all races will give.</p>
<ul>
<li>Click the Add Effect button, a new effect should appear</li>
<li>In the Stat Group dropdown box, choose "Stats"</li>
<li>The second dropdown lets us choose which stat to effect, choose "Speed"</li>
<li>The third dropdown lets us choose how to effect that stat, choose "Base Value", since our character's base speed comes from their race</li>
<li>Finally, input the value for our characters speed, it'll probably be 30 unless you chose a slower race, such as a dwarf</li>
<li>Close the Race dialog and navigate to the Stats tab</li>
<li>The speed card should now correctly display the character's speed</li>
<li>Click the speed card to see how that value was calculated</li>
<li>Currently there is only one number effecting the total, the speed from our race, but as more effects from different sources start impacting our character's speed, they will show up here.</li>
</ul>
<h2>Adding your ability scores</h2>
<p>Your character currently doesn't have any ability scores, so lets fix that. Whether you roll your abilities or point-buy them, lets add a feature to represent where they came from</p>
<ul>
<li>Navigate to the <emd>Features</emd> tab</li>
<li>Click the plus button in the bottom right to add a new feature</li>
<li>Give the Feature a name, like <em>Point Buy</em></li>
<li>Leave the feature as always enabled, don't limit its uses, and leave the description blank</li>
<li>Click the <em>Add Effect</em> button</li>
<li>For <em>Stat Group</em> choose <em>Ability Scores</em></li>
<li>For <em>Stat</em> choose <em>Strength</em></li>
<li>For the operation choose <em>Base Value</em></li>
<li>Input your character's rolled or point-bought strength, without the racial modfier</li>
<li>Repeat for the rest of your ability scores</li>
</ul>
<p>You can now check that your ability scores appear on your <em>Stats</em> page and that your skills that use them have their values calculated accordingly.</p>
<p>We didn't include your character's racial ability modifiers in the feature, so you should go back to your character's racial dialog and add them in there as effects. Remember to use the add operation, rather than base value, since your race adds to your ability scores.</p>
<p>By separating the source of your character's stats you can easily check how your character got their ability scores and stats, even after 20 levels, without getting confused or making mistakes.</p>
<h2>Adding a Class</h2>
<p>Currently your character is at level 0, because they don't have any class levels. Let's fix that.</p>
<ul>
<li>Click the plus button in the card that currently says "Level 0"</li>
<li>A new class has now been added, name the class in the Class Name input and leave the level as 1</li>
</ul>
<p>We now have a class, lets add the saving throw proficiencies it gives us.</p>
<ul>
<li>Click the Add Proficiency button</li>
<li>Click the dropdown box that currently has "Skill" selected, and choose "Saving Throw" instead</li>
<li>In the second dropdown choose the first saving throw your class gives you</li>
<li>The third dropdown lets us specify if we have half or double our proficiency bonus for this proficiency, leave it at the default "proficient" for now</li>
</ul>
<p>If you navigate back to the stat page, you will see that you now have a proficiency bonus, based on your class level, and the saving throw you are proficienct in will take your proficiency bonus into account.</p>
<p>One of the most important things your class gives you is your hitpoints, so lets go add those now.</p>
<ul>
<li>Navigate to the class dialog box by clicking on your class name in the journal tab and hitting the edit button</li>
<li>Click the Add Effect button</li>
<li>Choose the <em>Stats</em> stat group, and choose the <em>Hitpoints</em> stat</li>
<li>Choose the <em>Base Value</em> operation</li>
</ul>
<p>Now we need to decide how many hitpoints our class gives us. We will assume that we take the constant hitpoints per level, since it's both the rule used for league play and it's statistically advantageous over rolling for hitpoints every level.</p>
<p>We could work out our hit points every level and change the effect each time, but we can do one better, we can input the calculation directly into the value field and have the character sheet figure it out for us</p>
<p>Let's assume we are rolling a fighter, so in the class name you typed in "Fighter" (with the capital F, but without the quote marks). A fighter gets 10 hp at first level and 6 hitpoints every level after that.</p>
<p>Lets rather split that into 4 bonus hitpoints at first level, and 6 hitpoints for every fighter level your character has. We can the write this as <em>4 + 6*FighterLevel</em> where the * represents multiplication.</p>
<p><em>Note, we don't add the constitution modifier here, that's already taken care of by default, since all characters add their constitution modifier to their hit points</em></p>
<ul>
<li>In the value field input <em>4 + 6 * FighterLevel</em>, the spaces aren't needed, but you must spell your class name exactly as it is spelt in the class name input box, capital letters and all, in our case "Fighter"</li>
<li>Create a new effect that effects the base value of <em>d10 Hit Dice</em> with the value of <em>FighterLevel</em>, since we also get our fighters level worth of hit dice</li>
<li>Check how your changes are reflected in the <em>Stats</em> tab</li>
<li>Change your level and check that the <em>Stats</em> tab gets updated accordingly</li>
</ul>
<p>You can try all sorts of calculations in your effects and in certain other places too. For example if you had some feature that is used a number of times equal to your wisdom modifier or 1, whichever is lower, you could limit its uses to <em>min(1, wisdomMod)</em> and the character sheet will figure it out for you, and update itself if you wisdom modifier happens to change later.</p>
</div>
</template>

View File

@@ -1,20 +1,11 @@
<template name="home">
<div class="scroll-y" fit>
<div flex horizontal wrap class="padded">
{{# each characters}}
{{#with characterDetails}}
{{#containerCardHelper this}}{{alignment}} {{gender}} {{race}}{{/containerCardHelper}}
{{/with}}
{{/each}}
<div class="fab-buffer"></div>
<core-toolbar class="blue-grey white-text">
<core-icon-button icon="menu" core-drawer-toggle></core-icon-button>
<div flex>
DiceCloud
</div>
<paper-fab id="addCharacter"
class="floatyButton"
icon="add"
title="Add"
role="button"
tabindex="0"
aria-label="Add"
hero-id="main"></paper-fab>
</core-toolbar>
<div class="padded scroll-y white" fit>
{{> guide}}
</div>
</template>

View File

@@ -1,5 +1,5 @@
#accountSummary {
padding-top: 32px;
padding: 16px;
min-height: 146px;
background-image: url(/png/paper-dice-crown.png);
background-repeat: no-repeat;
@@ -11,3 +11,7 @@
#mainContentSection {
display: initial !important;
}
#navPanel {
padding: 16px;
}

View File

@@ -1,16 +1,19 @@
<template name="layout">
<core-drawer-panel>
<core-header-panel drawer navigation flex mode="seamed" class="white">
<div id="accountSummary">
{{> loginButtons}}
{{#if currentUser}}
<div id="profileLink" style="text-decoration: underline; cursor: pointer;">
My account
{{profileLink}}
</div>
{{else}}
<a href="/sign-in" style="color: white;">Sign in</a>
{{/if}}
</div>
<paper-item id="charactersMenuButton">Characters</paper-item>
<div id="navPanel">
<core-item id="homeNav" icon="home" label="Home"></core-item>
{{> characterSideList}}
</div>
</core-header-panel>
<core-animated-pages main
navigation

View File

@@ -9,11 +9,15 @@ Template.layout.destroyed = function() {
Template.layout.helpers({
notSelected: function(){
return Session.get("global.ui.detailShow") ? "not-selected" : null;
}
},
profileLink: function() {
var user = Meteor.user();
return user.profile && user.profile.username || user.username || "My Account";
},
});
Template.layout.events({
"tap #charactersMenuButton": function(event, instance){
"tap #homeNav": function(event, instance){
Router.go("/");
},
"tap #profileLink": function(event, instance){

View File

@@ -0,0 +1,11 @@
<template name="notFound">
<div layout vertical center center-justified fit>
<h2>The data for the page you requested could not be found.</h2>
{{#if currentUser}}
<h2>It might not exist, or you might not have permission to view it.</h2>
{{else}}
<h2>Perhaps you need to sign in first:</h2>
{{atForm}}
{{/if}}
</div>
</template>

View File

@@ -3,11 +3,7 @@
<core-toolbar class="blue-grey white-text">
<core-icon-button icon="menu" core-drawer-toggle></core-icon-button>
<div id="username" class="clickable" flex>
{{#if username}}
{{username}}
{{else}}
Tap to set username
{{/if}}
{{profileName}}
</div>
</core-toolbar>
<div id="userProfile" class="padded">
@@ -20,5 +16,7 @@
{{/each}}
</div>
</div>
{{> atForm}}
{{> atNavButton }}
{{/with}}
</template>

View File

@@ -1,3 +1,12 @@
Template.profile.helpers({
profileName: function() {
var user = Meteor.user();
return user.profile && user.profile.username ||
user.username ||
"Tap to set username";
}
});
Template.profile.events({
"tap #username": function(){
if (this._id === Meteor.userId()){

View File

@@ -1,9 +1,8 @@
<template name="usernameDialog">
{{#with currentUser}}
<div>
<paper-input id="usernameInput" label="Username" value={{username}}></paper-input>
</div>
{{/with}}
<div>
<paper-input id="usernameInput" label="Username" value={{profileName}}></paper-input>
</div>
<div style="color: red;" class="vertMargin">{{errorMessage}}</div>
<paper-button id="cancelButton" affirmative> Cancel </paper-button>
<paper-button id="changeButton" affirmative> Change Username </paper-button>
<paper-button id="changeButton" disabled={{invalid}} affirmative> Change Username </paper-button>
</template>

View File

@@ -1,8 +1,49 @@
var getUsername = function() {
var user = Meteor.user();
return user.profile && user.profile.username || user.username;
};
Template.usernameDialog.onCreated(function() {
this.errorMessage = new ReactiveVar("");
this.username = new ReactiveVar(getUsername());
});
Template.usernameDialog.helpers({
profileName: function() {
return getUsername();
},
invalid: function() {
return !!Template.instance().errorMessage.get();
},
errorMessage: function() {
return Template.instance().errorMessage.get();
},
});
Template.usernameDialog.events({
"change #usernameInput, input #usernameInput": function(event, instance) {
var username = instance.find("#usernameInput").value;
username = username.trim().toLowerCase().replace(/\s+/gm, "");
if (username.length < 3){
instance.errorMessage.set("Username too short");
} else {
instance.errorMessage.set("Validating...");
Meteor.call("getUserId", username, function(err, userId){
if (userId && userId !== Meteor.userId())
instance.errorMessage.set("This username is taken");
else
instance.errorMessage.set("");
});
}
},
"tap #changeButton": function(event, instance){
var username = instance.find("#usernameInput").value;
username = username.trim().replace(/\s+/gm, " ");
var profileName = username;
username = username.toLowerCase().replace(/\s+/gm, "");
Meteor.users.update(
Meteor.userId(),
{$set: {username: instance.find("#usernameInput").value}}
{$set: {username: username, "profile.username": profileName}}
);
}
},
});

View File

@@ -0,0 +1,13 @@
<template name="titledAtForm">
<core-toolbar class="blue-grey white-text">
<core-icon-button icon="menu" core-drawer-toggle></core-icon-button>
<div flex>
</div>
</core-toolbar>
<div class="scroll-y padded" fit layout vertical center center-justified>
<paper-shadow class="white" style="max-width: 400px;">
{{> atForm}}
</paper-shadow>
</div>
</template>

View File

@@ -1 +1 @@
appName = "Dice Cloud";
appName = "Dicecloud";

View File

@@ -1,3 +1,14 @@
Meteor.methods({
canWriteCharacter: function(charId) {
var userId = this.userId;
var char = Characters.findOne(
charId,
{fields: {owner: 1, writers: 1}}
);
return (userId && char.owner === userId || _.contains(char.writers, userId));
},
});
CHARACTER_SUBSCHEMA_ALLOW = {
// the user must be logged in, and the user must be a writer of the character
insert: function(userId, doc) {

View File

@@ -0,0 +1,71 @@
AccountsTemplates.configure({
//behaviour
confirmPassword: true,
enablePasswordChange: true,
enforceEmailVerification: true,
overrideLoginErrors: false,
sendVerificationEmail: true,
lowercaseUsername: true,
//appearance
continuousValidation: true,
negativeValidation: true,
negativeFeedback: true,
showValidating: true,
showAddRemoveServices: true,
showForgotPasswordLink: true,
showResendVerificationEmailLink: true,
});
AccountsTemplates.configureRoute("changePwd", {
template: "titledAtForm",
});
AccountsTemplates.configureRoute("enrollAccount", {
template: "titledAtForm",
});
AccountsTemplates.configureRoute("forgotPwd", {
template: "titledAtForm",
});
AccountsTemplates.configureRoute("resetPwd", {
template: "titledAtForm",
});
AccountsTemplates.configureRoute("signIn", {
template: "titledAtForm",
});
AccountsTemplates.configureRoute("signUp", {
template: "titledAtForm",
});
AccountsTemplates.configureRoute("verifyEmail", {
template: "titledAtForm",
});
AccountsTemplates.configureRoute("resendVerificationEmail", {
template: "titledAtForm",
});
if (Meteor.isServer){
Meteor.methods({
"userExists": function(username){
return !!Meteor.users.findOne({username: username});
},
});
}
AccountsTemplates.addField({
_id: "username",
type: "text",
required: true,
func: function(value){
if (Meteor.isClient) {
var self = this;
Meteor.call("userExists", value, function(err, userExists){
if (!userExists)
self.setSuccess();
else
self.setError("This username is taken");
self.setValidating(false);
});
return;
}
// Server
return Meteor.call("userExists", value);
},
});

View File

@@ -9,23 +9,27 @@ evaluate = function(charId, string){
}
//ability modifiers
var abilityMods = [
"STRENGTHMOD",
"DEXTERITYMOD",
"CONSTITUTIONMOD",
"INTELLIGENCEMOD",
"WISDOMMOD",
"CHARISMAMOD",
"strengthMod",
"dexterityMod",
"constitutionMod",
"intelligenceMod",
"wisdomMod",
"charismaMod",
];
if (_.contains(abilityMods, sub.toUpperCase())){
if (_.contains(abilityMods, sub)){
var slice = sub.slice(0, -3);
return char.abilityMod(slice);
try {
return char.abilityMod(slice);
} catch (e){
return sub;
}
}
//class levels
if (/\w+levels?\b/gi.test(sub)){
//strip out "level"
var className = sub.replace(/levels?\b/gi, "");
var cls = Classes.findOne({charId: charId, name: className});
return cls && cls.level;
return cls && cls.level || sub;
}
//character level
if (sub.toUpperCase() === "LEVEL"){

View File

@@ -42,6 +42,12 @@ var inheritParentProperties = function(doc, collection){
"Document's parent does not exist"
);
var handMeDowns = _.pick(parent, collection.inheritedKeys);
if (
_.contains(collection.inheritedKeys, "charId") &&
doc.parent.collection === "Characters"
){
handMeDowns.charId = doc.parent.id;
}
if (_.isEmpty(handMeDowns)) return;
collection.update(doc._id, {$set: handMeDowns});
};
@@ -76,14 +82,13 @@ makeChild = function(collection, inheritedKeys){
}
});
if (Meteor.isClient) {
collection.after.update(function(userId, doc, fieldNames, modifier, options) {
if (modifier && modifier.$set && modifier.$set.parent){
//when we change parents, inherit its properties
inheritParentProperties(doc, collection);
}
});
}
collection.after.update(function(userId, doc, fieldNames, modifier, options) {
if (modifier && modifier.$set && modifier.$set["parent.id"]){
//when we change parents, inherit its properties
console.log("re-inheriting")
inheritParentProperties(doc, collection);
}
});
collection.softRemoveNode = collection.softRemoveNode || function(id){
collection.softRemove(id);
@@ -102,14 +107,12 @@ makeParent = function(collection, donatedKeys){
donatedKeys = joinWithDefaultKeys(donatedKeys);
var collectionName = collection._collection.name;
//after changing, push the changes to all children
if (Meteor.isClient) {
collection.after.update(function(userId, doc, fieldNames, modifier, options) {
modifier = limitModifierToKeys(modifier, donatedKeys);
doc = _.pick(doc, ["_id", "charId"]);
if (!modifier) return;
Meteor.call("updateChildren", doc, modifier, true);
});
}
collection.after.update(function(userId, doc, fieldNames, modifier, options) {
modifier = limitModifierToKeys(modifier, donatedKeys);
doc = _.pick(doc, ["_id", "charId"]);
if (!modifier) return;
Meteor.call("updateChildren", doc, modifier, true);
});
collection.softRemoveNode = function(id){
Meteor.call("softRemoveNode", collectionName, id);
};

View File

@@ -79,7 +79,7 @@ To change the slider secondary progress bar color:
<div class="bar-container">
<paper-progress id="sliderBar" aria-hidden="true" min="{{min}}" max="{{max}}" value="{{immediateValue}}" secondaryProgress="{{secondaryProgress}}"
on-down="{{bardown}}" on-up="{{resetKnob}}"
on-down="{{knobdown}}" on-up="{{resetKnob}}"
on-trackstart="{{trackStart}}" on-trackx="{{trackx}}" on-trackend="{{trackEnd}}"></paper-progress>
</div>

View File

@@ -0,0 +1,27 @@
AccountsMeld.configure({
meldDBCallback: function(sourceUserId, destinationUserId){
// Here you can modify every collection you need for the document referencing
// to sourceUserId to be modified in order to point to destinationUserId
Characters.update(
{owner: sourceUserId},
{$set: {owner: destinationUserId}},
{multi: true}
);
Characters.update(
{writers: sourceUserId},
{
$pull: {writers: sourceUserId},
$addToSet: {writers: destinationUserId},
},
{multi: true}
);
Characters.update(
{readers: sourceUserId},
{
$pull: {readers: sourceUserId},
$addToSet: {readers: destinationUserId},
},
{multi: true}
);
},
});

View File

@@ -1,13 +1,28 @@
Meteor.publish("characterList", function(userId){
Meteor.publish("characterList", function(){
var userId = this.userId;
if (!userId) {
this.ready();
return;
}
return Characters.find({
$or: [
{readers: userId},
{writers: userId},
{owner: userId},
]
});
return Characters.find(
{
$or: [
{readers: userId},
{writers: userId},
{owner: userId},
]
},
{
fields: {
name: 1,
race: 1,
alignment: 1,
gender: 1,
readers: 1,
writers:1,
owner: 1,
color: 1,
}
}
);
});

View File

@@ -1,14 +1,15 @@
Meteor.publish("singleCharacter", function(characterId, userId){
if (
Characters.findOne({
_id: characterId,
$or: [
{readers: userId},
{writers: userId},
{owner: userId},
],
})
){
Meteor.publish("singleCharacter", function(characterId){
userId = this.userId;
if (!userId) return [];
var char = Characters.findOne({
_id: characterId,
$or: [
{readers: userId},
{writers: userId},
{owner: userId},
],
});
if (char){
return [
Characters.find({_id: characterId}),
//get all the assets for this character including soft deleted ones
@@ -25,6 +26,12 @@ Meteor.publish("singleCharacter", function(characterId, userId){
SpellLists.find ({charId: characterId}, {removed: true}),
TemporaryHitPoints.find({charId: characterId}, {removed: true}),
Proficiencies.find ({charId: characterId}, {removed: true}),
Meteor.users.find (
{_id: {$in: _.union(char.readers, char.writers)}},
{fields: {username: 1}}
),
];
} else {
return [];
}
});