Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac23afac5d | ||
|
|
a411fb2b43 | ||
|
|
35b6fe20ae |
@@ -4,7 +4,7 @@ Characters = new Mongo.Collection("characters");
|
|||||||
Schemas.Character = new SimpleSchema({
|
Schemas.Character = new SimpleSchema({
|
||||||
//strings
|
//strings
|
||||||
name: {type: String, defaultValue: "", trim: false, optional: true},
|
name: {type: String, defaultValue: "", trim: false, optional: true},
|
||||||
urlName: {type: String, defaultValue: "", trim: false, optional: true},
|
urlName: {type: String, defaultValue: "-", trim: false, optional: true},
|
||||||
alignment: {type: String, defaultValue: "", trim: false, optional: true},
|
alignment: {type: String, defaultValue: "", trim: false, optional: true},
|
||||||
gender: {type: String, defaultValue: "", trim: false, optional: true},
|
gender: {type: String, defaultValue: "", trim: false, optional: true},
|
||||||
race: {type: String, defaultValue: "", trim: false, optional: true},
|
race: {type: String, defaultValue: "", trim: false, optional: true},
|
||||||
@@ -543,10 +543,13 @@ if (Meteor.isServer){
|
|||||||
});
|
});
|
||||||
Characters.after.update(function(userId, doc, fieldNames, modifier, options) {
|
Characters.after.update(function(userId, doc, fieldNames, modifier, options) {
|
||||||
if (_.contains(fieldNames, "name")){
|
if (_.contains(fieldNames, "name")){
|
||||||
var urlName = getSlug(doc.name, {maintainCase: true});
|
var urlName = getSlug(doc.name, {maintainCase: true}) || "-";
|
||||||
Characters.update(doc._id, {$set: {urlName}});
|
Characters.update(doc._id, {$set: {urlName}});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Characters.before.insert(function(userId, doc) {
|
||||||
|
doc.urlName = getSlug(doc.name, {maintainCase: true}) || "-";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Characters.allow({
|
Characters.allow({
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ Router.map(function() {
|
|||||||
var _id = this.params._id
|
var _id = this.params._id
|
||||||
var character = Characters.findOne(_id);
|
var character = Characters.findOne(_id);
|
||||||
var urlName = character && character.urlName;
|
var urlName = character && character.urlName;
|
||||||
var path = `\/character\/${_id}\/${urlName}`;
|
var path = `\/character\/${_id}\/${urlName || "-"}`;
|
||||||
Router.go(path,{},{replaceState:true});
|
Router.go(path,{},{replaceState:true});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
3
rpg-docs/client/globalHelpers/characterPath.js
Normal file
3
rpg-docs/client/globalHelpers/characterPath.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
Template.registerHelper("characterPath", function(char) {
|
||||||
|
return `\/character\/${char._id}\/${char.urlName || "-"}`;
|
||||||
|
});
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
{{#if characters.count}}
|
{{#if characters.count}}
|
||||||
<div class="character-list layout horizontal wrap">
|
<div class="character-list layout horizontal wrap">
|
||||||
{{# each characters}}
|
{{# each characters}}
|
||||||
<a class="character-card flex layout vertical end-justified" href="{{pathFor route="characterSheet" data=this}}">
|
<a class="character-card flex layout vertical end-justified" href="{{characterPath this}}">
|
||||||
<iron-image class="fit {{colorClass}}"
|
<iron-image class="fit {{colorClass}}"
|
||||||
sizing="cover" preload fade src={{picture}}>
|
sizing="cover" preload fade src={{picture}}>
|
||||||
</iron-image>
|
</iron-image>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{{#if characters.count}}
|
{{#if characters.count}}
|
||||||
<div class="side-list">
|
<div class="side-list">
|
||||||
{{#each characters}}
|
{{#each characters}}
|
||||||
<a href={{pathFor route="characterSheet" data=this}} tabindex="-1" class="side-list-character characterRepresentative">
|
<a href={{characterPath this}} tabindex="-1" class="side-list-character characterRepresentative">
|
||||||
<paper-item class="short">
|
<paper-item class="short">
|
||||||
<div class="character-name">
|
<div class="character-name">
|
||||||
{{name}}
|
{{name}}
|
||||||
|
|||||||
@@ -23,142 +23,12 @@ Meteor.methods({
|
|||||||
|
|
||||||
Migrations.add({
|
Migrations.add({
|
||||||
version: 1,
|
version: 1,
|
||||||
name: "converts effect proficiencies to proficiency objects, removes types from assets",
|
|
||||||
up: function() {
|
|
||||||
//convert proficiency effects to proficiency objects
|
|
||||||
Effects.find({operation: "proficiency"}).forEach(function(effect){
|
|
||||||
var type = "skill";
|
|
||||||
if (_.contains(SAVES, effect.stat)) type = "save";
|
|
||||||
Proficiencies.insert({
|
|
||||||
charId: effect.charId,
|
|
||||||
name: effect.stat,
|
|
||||||
value: effect.value,
|
|
||||||
parent: _.clone(effect.parent),
|
|
||||||
type: type,
|
|
||||||
enabled: effect.enabled,
|
|
||||||
}, function(err){
|
|
||||||
if (!err) Effects.remove(effect._id);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//store type as a parent group if it's needed
|
|
||||||
Effects.find({"parent.collection": "Characters"}).forEach(function(e){
|
|
||||||
Effects.update(e._id, {$set: {"parent.group": e.type}});
|
|
||||||
});
|
|
||||||
Attacks.find({"parent.collection": "Characters"}).forEach(function(a){
|
|
||||||
Attacks.update(a._id, {$set: {"parent.group": a.type}});
|
|
||||||
});
|
|
||||||
//remove type
|
|
||||||
Effects.update({}, {$unset: {type: ""}}, {validate: false, multi: true});
|
|
||||||
Attacks.update({}, {$unset: {type: ""}}, {validate: false, multi: true});
|
|
||||||
//remove languages and proficiencies
|
|
||||||
Characters.update(
|
|
||||||
{},
|
|
||||||
{$unset: {languages: "", proficiencies: ""}},
|
|
||||||
{validate: false, multi: true}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Migrations.add({
|
|
||||||
version: 2,
|
|
||||||
name: "Converts attacks from damage dice and damage bonus to a string with curly bracket calculations, adds settings.showIncrement to items",
|
|
||||||
up: function() {
|
|
||||||
//update attacks
|
|
||||||
Attacks.find({}).forEach(function(attack) {
|
|
||||||
if (!attack.damage && attack.damageDice && attack.damageBonus){
|
|
||||||
var newDamage = attack.damageDice +
|
|
||||||
" + {" + attack.damageBonus + "}";
|
|
||||||
Attacks.update(
|
|
||||||
attack._id,
|
|
||||||
{
|
|
||||||
$unset: {
|
|
||||||
damageBonus: "",
|
|
||||||
damageDice: "",
|
|
||||||
},
|
|
||||||
$set: {
|
|
||||||
damage: newDamage
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{validate: false});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
//update Items
|
|
||||||
Items.update(
|
|
||||||
{settings: undefined},
|
|
||||||
{$set: {"settings.showIncrement" : false}},
|
|
||||||
{validate: false, multi: true}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Migrations.add({
|
|
||||||
version: 3,
|
|
||||||
name: "Converts attacks from damage dice and damage bonus to a string with curly bracket calculations, adds settings.showIncrement to items",
|
|
||||||
up: function() {
|
|
||||||
//update characters
|
|
||||||
Characters.update(
|
|
||||||
{"settings.useVariantEncumbrance": undefined},
|
|
||||||
{$set: {"settings.useVariantEncumbrance" : false}},
|
|
||||||
{validate: false, multi: true}
|
|
||||||
);
|
|
||||||
Characters.update(
|
|
||||||
{"settings.useStandardEncumbrance": undefined},
|
|
||||||
{$set: {"settings.useStandardEncumbrance" : true}},
|
|
||||||
{validate: false, multi: true}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Migrations.add({
|
|
||||||
version: 4,
|
|
||||||
name: "Adds an effect to give characters a base carry capacity",
|
|
||||||
up: function() {
|
|
||||||
//update characters
|
|
||||||
|
|
||||||
Characters.find({}).forEach(function(char){
|
|
||||||
Characters.update(char._id, {
|
|
||||||
$set: {
|
|
||||||
carryMultiplier: {
|
|
||||||
adjustment: 0,
|
|
||||||
reset: "longRest",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
var effect = Effects.findOne({
|
|
||||||
charId: char._id, name: "Natural Carrying Capacity",
|
|
||||||
});
|
|
||||||
if (effect) return;
|
|
||||||
Effects.insert({
|
|
||||||
charId: char._id,
|
|
||||||
name: "Natural Carrying Capacity",
|
|
||||||
stat: "carryMultiplier",
|
|
||||||
operation: "base",
|
|
||||||
value: "1",
|
|
||||||
parent: {
|
|
||||||
id: char._id,
|
|
||||||
collection: "Characters",
|
|
||||||
group: "Inate",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
effect = Effects.findOne({
|
|
||||||
charId: char._id, name: "Natural Carrying Capacity",
|
|
||||||
});
|
|
||||||
if (!effect) throw "Carry capacity effect should be set by now."
|
|
||||||
});
|
|
||||||
},
|
|
||||||
down: function(){
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Migrations.add({
|
|
||||||
version: 5,
|
|
||||||
name: "Gives all characters a URL name",
|
name: "Gives all characters a URL name",
|
||||||
up: function() {
|
up: function() {
|
||||||
//update characters
|
//update characters
|
||||||
Characters.find({}).forEach(function(char){
|
Characters.find({}).forEach(function(char){
|
||||||
if (char.urlName) return;
|
if (char.urlName) return;
|
||||||
var urlName = getSlug(char.name, {maintainCase: true});
|
var urlName = getSlug(char.name, {maintainCase: true}) || "-";
|
||||||
Characters.update(char._id, {$set: {urlName}});
|
Characters.update(char._id, {$set: {urlName}});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user