Files
roll20-character-sheets/ButterflyAspect/ButterflyAspect.html
T
Tealk d42c9b86cc add button to minimize
text fields of stunts and inventory can be hidden
2020-07-18 23:00:01 +02:00

1066 lines
39 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<div class="sheet-container">
<div class="sheet-float sheet-head">
<div class="sheet-float sheet-head-logo">
<img class="sheet-logo" src="https://img.anzahcraft.de/logo-roll20.png" alt="AnzahCraft" />
<div class="sheet-gmroll">
<select name="attr_gmroll">
<option value="nogm" selected="selected">Für alle sichtbar w&uuml;rfeln</option>
<option value="gm">Für GM w&uuml;rfeln</option>
</select>
<input type="hidden" name="attr_abilityroll" />
</div>
</div>
<div class="sheet-float sheet-head-info">
<div class="sheet-header">
<span>Allgemeines</span>
</div>
<div class="sheet-float sheet-head-info-boxes">
<div class="sheet-formular">
<label for="attr_character_name">Charaktername</label>
<input class="sheet-bottomspace" type="text" name="attr_character_name" />
</div>
<div class="sheet-formular">
<label for="attr_character_description">Beschreibung</label>
<textarea name="attr_character_description" style="height: 102px;"></textarea>
</div>
</div>
<div class="sheet-float sheet-head-info-sideboxes">
<div class="sheet-formular">
<button type="roll" class="sheet-small-button" name="roll_schicksalRoll"
value="Die Gruppe hat jetzt noch [[@{schicksal} ?{Modifier?|+/-}]] Schicksalspunkte">Schicksal</button>
<input type="number" name="attr_schicksal" value="4" class="sheet-number-20" />
</div>
<div class="sheet-formular">
<label for="attr_exp">EXP</label>
<input type="number" name="attr_exp" value="0" class="sheet-number-20" />
</div>
<div class="sheet-formular">
<button type="roll" class="sheet-small-button" name="roll_schicksalRoll"
value="/w gm @{character_name} stellt sich dem Karma: [[1d10cf<@{karma}]]">Karma</button>
<input type="number" name="attr_karma" value="0" class="sheet-number-20" />
</div>
</div>
<div class="sheet-head-stats">
<div class="sheet-formular">
<label for="attr_leben">Leben</label>
<div class="sheet-head-stats-health">
<input type="number" class="sheet-number-20" name="attr_leben" placeholder="Aktuell" /> / <input
type="number" class="sheet-number-20" name="attr_leben_max" readonly />
</div>
</div>
<div class="sheet-formular">
<label for="attr_verteidigung">Verteidigung</label>
<input type="number" id="attr_verteidigung" name="attr_verteidigung" class="sheet-number-20"
readonly />
</div>
<div class="sheet-formular">
<label for="attr_bewegung">Mana</label>
<div class="sheet-head-stats-mana">
<input type="number" class="sheet-number-20" name="attr_mana" placeholder="Aktuell" /> / <input
type="number" class="sheet-number-20" name="attr_mana_max" readonly />
</div>
</div>
</div>
</div>
</div>
<div class="sheet-break"></div>
<div class="sheet-float sheet-half sheet-attribut">
<div class="sheet-header">
<span>Attribute</span>
</div>
<div class="sheet-float sheet-attribut-stats">
<div class="sheet-float sheet-formular">
<button type="roll" class="sheet-small-button" name="roll_NaRoll"
value="@{abilityroll} versucht sich in Nahkampf [[floor(@{Na}d10 / 2) + ?{Modifier?|0}]]">Nahkampf</button>
<input type="number" name="attr_Na" value="1" min="1" class="sheet-number-20" />
</div>
<div class="sheet-float sheet-formular">
<button type="roll" class="sheet-small-button" name="roll_FeRoll"
value="@{abilityroll} versucht sich in Fernkampf [[floor(@{Fe}d10 / 2) + ?{Modifier?|0}]]">Fernkampf</button>
<input type="number" name="attr_Fe" value="1" min="1" class="sheet-number-20" />
</div>
<div class="sheet-float sheet-formular">
<button type="roll" class="sheet-small-button" name="roll_GeRoll"
value="@{abilityroll} versucht sich in Geschick [[floor(@{Ge}d10 / 2) + ?{Modifier?|0}]]">Geschick</button>
<input type="number" name="attr_Ge" value="1" min="1" class="sheet-number-20" />
</div>
<div class="sheet-float sheet-formular">
<button type="roll" class="sheet-small-button" name="roll_WaRoll"
value="@{abilityroll} versucht sich in Wahrnehmung [[floor(@{Wa}d10 / 2) + ?{Modifier?|0}]]">Wahrnehmung</button>
<input type="number" name="attr_Wa" value="1" min="1" class="sheet-number-20" />
</div>
<div class="sheet-float sheet-formular">
<button type="roll" class="sheet-small-button" name="roll_KoRoll"
value="@{abilityroll} versucht sich in Konstitution [[floor(@{Ko}d10 / 2) + ?{Modifier?|0}]]">Konstitution</button>
<input type="number" name="attr_Ko" value="1" min="1" class="sheet-number-20" />
</div>
<div class="sheet-float sheet-formular">
<button type="roll" class="sheet-small-button" name="roll_InRoll"
value="@{abilityroll} versucht sich in Intelligenz [[floor(@{In}d10 / 2) + ?{Modifier?|0}]]">Intelligenz</button>
<input type="number" name="attr_In" value="1" min="1" class="sheet-number-20" />
</div>
<div class="sheet-float sheet-formular">
<button type="roll" class="sheet-small-button" name="roll_WiRoll"
value="@{abilityroll} versucht sich in Wissen [[floor(@{Wi}d10 / 2) + ?{Modifier?|0}]]">Wissen</button>
<input type="number" name="attr_Wi" value="1" min="1" class="sheet-number-20" />
</div>
<div class="sheet-float sheet-formular">
<button type="roll" class="sheet-small-button" name="roll_CaRoll"
value="@{abilityroll} versucht sich in Charisma [[floor(@{Ca}d10 / 2) + ?{Modifier?|0}]]">Charisma</button>
<input type="number" name="attr_Ca" value="1" min="1" class="sheet-number-20" />
</div>
</div>
</div>
<div class="sheet-float sheet-half sheet-aspects">
<div class="sheet-header">
<span>Aspekte</span>
</div>
<input type="text" name="attr_aspekt1" />
<input type="text" name="attr_aspekt2" />
<input type="text" name="attr_aspekt3" />
<input type="text" name="attr_aspekt4" />
<fieldset class="repeating_aspekte">
<input type="text" name="attr_aspekt" />
</fieldset>
</div>
<div class="sheet-break"></div>
<div class="sheet-float sheet-full sheet-skills">
<div class="sheet-header">
<span>Fertigkeiten</span>
</div>
<div class="sheet-grid">
<div>Fertigkeit</div>
<div>Attr.</div>
<div>Wert</div>
<div>MOD</div>
<div>PP</div>
<div>Roll</div>
</div>
<div class="sheet-gridplace">
<div class="repcontainer" data-groupname="repeating_basicskills">
<div class="repitem" data-reprowid="-LqmJZp6DZSuTu37ytv5">
<div><input class="sheet-textcenter" type="text" name="attr_ansehen_name" value="Ansehen" />
</div>
<div>-</div>
<div><input type="number" name="attr_ansehen" value="0"></div>
<div><input type="number" name="attr_ansehen_mod" value="0"></div>
<div>-</div>
<div><button type="roll" name="roll_statikskill1"
value="@{abilityroll} würfelt auf @{ansehen_name} mit dem Ergebnis [[{1d10! + @{ansehen} + @{ansehen_mod} + ?{Modifier?|0},{(@{ansehen} + 1) * 10}}kl1]]"
class="btn ui-draggable"></button></div>
</div>
</div>
<div class="repcontainer" data-groupname="repeating_basicskills">
<div class="repitem" data-reprowid="-LqmJZp6DZSuTu37ytv5">
<div><input class="sheet-textcenter" type="text" name="attr_vermoegen_name" value="Vermögen" />
</div>
<div>-</div>
<div><input type="number" name="attr_vermoegen" value="0"></div>
<div><input type="number" name="attr_vermoegen_mod" value="0"></div>
<div>-</div>
<div><button type="roll" name="roll_vermoegen"
value="@{abilityroll} würfelt auf @{vermoegen_name} mit dem Ergebnis [[{1d10! + @{vermoegen} + @{vermoegen_mod} + ?{Modifier?|0},{(@{vermoegen} + 1) * 10}}kl1]]"
class="btn ui-draggable"></button></div>
</div>
</div>
<fieldset class="repeating_basicskills">
<div><input class="sheet-textcenter" type="text" name="attr_skillname" /></div>
<div>
<select name="attr_attribut">
<option value="@{Na}">Nahkampf</option>
<option value="@{Fe}">Fernkampf</option>
<option value="@{Ge}">Geschick</option>
<option value="@{Wa}">Wahrnehmung</option>
<option value="@{Ko}">Konstitution</option>
<option value="@{in}">Intelligenz</option>
<option value="@{Wi}">Wissen</option>
<option value="@{Ca}">Charisma</option>
</select>
</div>
<div><input type="number" name="attr_skill" value="0" /></div>
<div><input type="number" name="attr_skill_mod" value="0" /></div>
<div><input type="number" name="attr_pp" value="0" /></div>
<div><button type="roll" name="roll_skill"
value="@{abilityroll} würfelt auf @{skillname} mit dem Ergebnis [[{@{attribut}d10! + @{skill} + @{skill_mod} + ?{Modifier?|0},{(@{skill} + 1) * 10}}kl1]]"></button>
</div>
</fieldset>
</div>
</div>
<div class="sheet-break"></div>
<div class="sheet-float sheet-full sheet-skills">
<div class="sheet-header">
<span>Waffen</span>
</div>
<div class="sheet-grid">
<div>Waffe</div>
<div>Attr.</div>
<div>Wert</div>
<div>MOD</div>
<div>Dmg</div>
<div>Roll</div>
</div>
<div class="sheet-gridplace">
<fieldset class="repeating_waponskills">
<div><input class="sheet-textcenter" type="text" name="attr_weaponname"></div>
<div>
<select name="attr_attribut">
<option value="@{Na}">Nahkampf</option>
<option value="@{Fe}">Fernkampf</option>
</select>
</div>
<div><input type="number" name="attr_weaponskill" value="0"></div>
<div><input type="number" name="attr_weaponskill_mod" value="0"></div>
<div><input type="number" name="attr_weapondmg" value="0"></div>
<div><button type="roll" name="roll_skill"
value="@{abilityroll} benutzt @{weaponname} mit dem Ergebnis [[{@{attribut}d10! + @{weaponskill} + @{weaponskill_mod} + ?{Modifier?|0},{(@{weaponskill} + 1) * 10}}kl1]] und einem Waffenschaden von [[@{weapondmg}]]"
class="btn ui-draggable"></button>
</div>
</fieldset>
</div>
</div>
<div class="sheet-break"></div>
<div class="sheet-float sheet-half sheet-stunts">
<div class="sheet-header">
<span>Stunts</span>
</div>
<fieldset class="repeating_stunts">
<div class="sheet-repeat-stunt">
<input class="sheet-options-flag" name="attr_options-flag" type="checkbox"
title="Show/hide options"><span>y</span>
<input type="text" name="attr_stunt" placeholder="Name" />
<textarea name="attr_description" placeholder="Beschriebung"></textarea>
</div>
</fieldset>
</div>
<div class="sheet-float sheet-half sheet-inventar">
<div class="sheet-header">
<span>Inventar</span>
</div>
<div class="sheet-ruestung">
<input type="text" name="attr_ruestungName" placeholder="Rüstungsart" />
<input type="number" name="attr_ruestungGeschick" placeholder="Max. Geschickbonus" />
<input type="number" name="attr_ruestung" placeholder="Rüstungsbonus" />
</div>
<fieldset class="repeating_extras">
<div class="sheet-repeat-inv sheet-extras-row">
<input class="sheet-options-flag" name="attr_options-flag" type="checkbox"
title="Show/hide options"><span>y</span>
<input type="text" name="attr_name" placeholder="Gegenstand" />
<input type="text" name="attr_wight" placeholder="Gewicht" />
<input type="text" name="attr_costs" placeholder="Anzahl" />
<textarea name="attr_description" placeholder="Beschreibung"></textarea>
</div>
</fieldset>
</div>
<div class="sheet-break"></div>
<div class="sheet-float sheet-full sheet-xp">
<div class="sheet-header">
<span>Erfahrungspunkte und Steigerung</span>
</div>
<div class="sheet-totalxp">
<div class="sheet-formular">
<label for="attr_XPtoSpend">Verfügbare EP</label>
<input type="number" class="sheet-number-20" name="attr_XPtoSpend" value="@{XPTotal} - @{XPSpent}"
disabled />
</div>
<div class="sheet-formular">
<label for="attr_XPSpent">Ausgegebene EP</label>
<input type="number" class="sheet-number-20" name="attr_XPSpent" readonly />
</div>
<div class="sheet-formular">
<label for="attr_XPTotal">Gesamte EP</label>
<input type="number" class="sheet-number-20" name="attr_XPTotal" />
</div>
</div>
<fieldset class="repeating_advancements">
<div class="sheet-item">
<input type="text" name="attr_advancement1">
</div>
<div class="sheet-brackets">
<input type="number" name="attr_advancement1xp">
</div>
<div class="sheet-placeholder"></div>
<div class="sheet-item">
<input type="text" name="attr_advancement2">
</div>
<div class="sheet-brackets">
<input type="number" name="attr_advancement2xp">
</div>
<div class="sheet-placeholder"></div>
<div class="sheet-item">
<input type="text" name="attr_advancement3">
</div>
<div class="sheet-brackets">
<input type="number" name="attr_advancement3xp">
</div>
</fieldset>
</div>
<div class="sheet-break"></div>
<div class="sheet-float sheet-full sheet-notes">
<div class="sheet-header">
<span>Notizen</span>
</div>
<fieldset class="repeating_notes">
<div class="sheet-options sheet-notes-row">
<input type="text" name="attr_title" placeholder="Titel" />
<textarea name="attr_body" placeholder="Inhalt"></textarea>
</div>
</fieldset>
</div>
</div>
<!-- worker scripts -->
<script type="text/worker">
/* ---- BEGIN: TheAaronSheet.js ---- */
// Github: https://github.com/shdwjk/TheAaronSheet/blob/master/TheAaronSheet.js
// By: The Aaron, Arcane Scriptomancer
// Contact: https://app.roll20.net/users/104025/the-aaron
var TAS = TAS || (function(){
'use strict';
var version = '0.2.5',
lastUpdate = 1504710542,
loggingSettings = {
debug: {
key: 'debug',
title: 'DEBUG',
color: {
bgLabel: '#7732A2',
label: '#F2EF40',
bgText: '#FFFEB7',
text: '#7732A2'
}
},
error: {
key: 'error',
title: 'Error',
color: {
bgLabel: '#C11713',
label: 'white',
bgText: '#C11713',
text: 'white'
}
},
warn: {
key: 'warn',
title: 'Warning',
color: {
bgLabel: '#F29140',
label: 'white',
bgText: '#FFD8B7',
text: 'black'
}
},
info: {
key: 'info',
title: 'Info',
color: {
bgLabel: '#413FA9',
label: 'white',
bgText: '#B3B2EB',
text: 'black'
}
},
notice: {
key: 'notice',
title: 'Notice',
color: {
bgLabel: '#33C133',
label: 'white',
bgText: '#ADF1AD',
text: 'black'
}
},
log: {
key: 'log',
title: 'Log',
color: {
bgLabel: '#f2f240',
label: 'black',
bgText: '#ffff90',
text: 'black'
}
},
callstack: {
key: 'TAS',
title: 'function',
color: {
bgLabel: '#413FA9',
label: 'white',
bgText: '#B3B2EB',
text: 'black'
}
},
callstack_async: {
key: 'TAS',
title: 'ASYNC CALL',
color: {
bgLabel: '#413FA9',
label: 'white',
bgText: '#413FA9',
text: 'white'
}
},
TAS: {
key: 'TAS',
title: 'TAS',
color: {
bgLabel: 'grey',
label: 'black;background:linear-gradient(#304352,#d7d2cc,#d7d2cc,#d7d2cc,#304352)',
bgText: 'grey',
text: 'black;background:linear-gradient(#304352,#d7d2cc,#d7d2cc,#d7d2cc,#304352)'
}
}
},
config = {
debugMode: false,
logging: {
log: true,
notice: true,
info: true,
warn: true,
error: true,
debug: false
}
},
callstackRegistry = [],
queuedUpdates = {}, //< Used for delaying saves till the last moment.
complexType = function(o){
switch(typeof o){
case 'string':
return 'string';
case 'boolean':
return 'boolean';
case 'number':
return (_.isNaN(o) ? 'NaN' : (o.toString().match(/\./) ? 'decimal' : 'integer'));
case 'function':
return 'function: '+(o.name ? o.name+'()' : '(anonymous)');
case 'object':
return (_.isArray(o) ? 'array' : (_.isArguments(o) ? 'arguments' : ( _.isNull(o) ? 'null' : 'object')));
default:
return typeof o;
}
},
dataLogger = function(primaryLogger,secondaryLogger,data){
_.each(data,function(m){
var type = complexType(m);
switch(type){
case 'string':
primaryLogger(m);
break;
case 'undefined':
case 'null':
case 'NaN':
primaryLogger('['+type+']');
break;
case 'number':
case 'not a number':
case 'integer':
case 'decimal':
case 'boolean':
primaryLogger('['+type+']: '+m);
break;
default:
primaryLogger('['+type+']:=========================================');
secondaryLogger(m);
primaryLogger('=========================================================');
break;
}
});
},
colorLog = function(options){
var coloredLoggerFunction,
key = options.key,
label = options.title || 'TAS',
lBGColor = (options.color && options.color.bgLabel) || 'blue',
lTxtColor = (options.color && options.color.label) || 'white',
mBGColor = (options.color && options.color.bgText) || 'blue',
mTxtColor = (options.color && options.color.text) || 'white';
coloredLoggerFunction = function(message){
/* eslint-disable no-console */
console.log(
'%c '+label+': %c '+message + ' ',
'background-color: '+lBGColor+';color: '+lTxtColor+'; font-weight:bold;',
'background-color: '+mBGColor+';color: '+mTxtColor+';'
);
/* eslint-enable no-console */
};
return function(){
if('TAS'===key || config.logging[key]){
/* eslint-disable no-console */
dataLogger(coloredLoggerFunction,function(m){console.log(m);},_.toArray(arguments));
/* eslint-enable no-console */
}
};
},
logDebug = colorLog(loggingSettings.debug),
logError = colorLog(loggingSettings.error),
logWarn = colorLog(loggingSettings.warn),
logInfo = colorLog(loggingSettings.info),
logNotice = colorLog(loggingSettings.notice),
logLog = colorLog(loggingSettings.log),
log = colorLog(loggingSettings.TAS),
logCS = colorLog(loggingSettings.callstack),
logCSA = colorLog(loggingSettings.callstack_async),
registerCallstack = function(callstack,label){
var idx=_.findIndex(callstackRegistry,function(o){
return (_.difference(o.stack,callstack).length === _.difference(callstack,o.stack).length) &&
_.difference(o.stack,callstack).length === 0 &&
o.label === label;
});
if(-1 === idx){
idx=callstackRegistry.length;
callstackRegistry.push({
stack: callstack,
label: label
});
}
return idx;
},
setConfigOption = function(options){
var newconf =_.defaults(options,config);
newconf.logging=_.defaults(
(options && options.logging)||{},
config.logging
);
config=newconf;
},
isDebugMode = function(){
return config.debugMode;
},
debugMode = function(){
config.logging.debug=true;
config.debugMode = true;
},
getCallstack = function(){
var e = new Error('dummy'),
stack = _.map(_.rest(e.stack.replace(/^[^(]+?[\n$]/gm, '')
.replace(/^\s+at\s+/gm, '')
.replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@')
.split('\n')),function(l){
return l.replace(/\s+.*$/,'');
});
return stack;
},
logCallstackSub = function(cs){
var matches, csa;
_.find(cs,function(line){
matches = line.match(/TAS_CALLSTACK_(\d+)/);
if(matches){
csa=callstackRegistry[matches[1]];
logCSA( '===================='+(csa.label ? '> '+csa.label+' <' : '')+'====================');
logCallstackSub(csa.stack);
return true;
}
logCS(line);
return false;
});
},
logCallstack = function(){
var cs;
if(config.debugMode){
cs = getCallstack();
cs.shift();
log('==============================> CALLSTACK <==============================');
logCallstackSub(cs);
log('=========================================================================');
}
},
wrapCallback = function (label, callback, context){
var callstack;
if('function' === typeof label){
context=callback;
callback=label;
label=undefined;
}
if(!config.debugMode){
return (function(cb,ctx){
return function(){
cb.apply(ctx||{},arguments);
};
}(callback,context));
}
callstack = getCallstack();
callstack.shift();
return (function(cb,ctx,cs,lbl){
var ctxref=registerCallstack(cs,lbl);
/*jshint -W054 */
return new Function('cb','ctx','TASlog',
"return function TAS_CALLSTACK_"+ctxref+"(){"+
"var start,end;"+
"TASlog('Entering: '+(cb.name||'(anonymous function)'));"+
"start=_.now();"+
"cb.apply(ctx||{},arguments);"+
"end=_.now();"+
"TASlog('Exiting: '+(cb.name||'(anonymous function)')+' :: '+(end-start)+'ms elapsed');"+
"};")(cb,ctx,log);
/*jshint +W054 */
}(callback,context,callstack,label));
},
prepareUpdate = function( attribute, value ){
queuedUpdates[attribute]=value;
},
applyQueuedUpdates = function() {
setAttrs(queuedUpdates);
queuedUpdates = {};
},
namesFromArgs = function(args,base){
return _.chain(args)
.reduce(function(memo,attr){
if('string' === typeof attr) {
memo.push(attr);
} else if(_.isArray(args) || _.isArguments(args)){
memo = namesFromArgs(attr,memo);
}
return memo;
},(_.isArray(base) && base) || [])
.uniq()
.value();
},
addId = function(obj,value){
Object.defineProperty(obj,'id',{
value: value,
writable: false,
enumerable: false
});
},
addProp = function(obj,prop,value,fullname){
(function(){
var pname=(_.contains(['S','F','I','D'],prop) ? '_'+prop : prop),
full_pname = fullname || prop,
pvalue=value;
_.each(['S','I','F'],function(p){
if( !_.has(obj,p)){
Object.defineProperty(obj, p, {
value: {},
enumerable: false,
readonly: true
});
}
});
if( !_.has(obj,'D')){
Object.defineProperty(obj, 'D', {
value: _.reduce(_.range(10),function(m,d){
Object.defineProperty(m, d, {
value: {},
enumerable: true,
readonly: true
});
return m;
},{}),
enumerable: false,
readonly: true
});
}
// Raw value
Object.defineProperty(obj, pname, {
enumerable: true,
set: function(v){
if(v!==pvalue) {
pvalue=v;
prepareUpdate(full_pname,v);
}
},
get: function(){
return pvalue;
}
});
// string value
Object.defineProperty(obj.S, pname, {
enumerable: true,
set: function(v){
var val=v.toString();
if(val !== pvalue) {
pvalue=val;
prepareUpdate(full_pname,val);
}
},
get: function(){
return pvalue.toString();
}
});
// int value
Object.defineProperty(obj.I, pname, {
enumerable: true,
set: function(v){
var val=parseInt(v,10) || 0;
if(val !== pvalue){
pvalue=val;
prepareUpdate(full_pname,val);
}
},
get: function(){
return parseInt(pvalue,10) || 0;
}
});
// float value
Object.defineProperty(obj.F, pname, {
enumerable: true,
set: function(v){
var val=parseFloat(v) || 0;
if(val !== pvalue) {
pvalue=val;
prepareUpdate(full_pname,val);
}
},
get: function(){
return parseFloat(pvalue) || 0;
}
});
_.each(_.range(10),function(d){
Object.defineProperty(obj.D[d], pname, {
enumerable: true,
set: function(v){
var val=(parseFloat(v) || 0).toFixed(d);
if(val !== pvalue){
pvalue=val;
prepareUpdate(full_pname,val);
}
},
get: function(){
return (parseFloat(pvalue) || 0).toFixed(d);
}
});
});
}());
},
repeating = function( section ) {
return (function(s){
var sectionName = s,
attrNames = [],
fieldNames = [],
operations = [],
after = [],
repAttrs = function TAS_Repeating_Attrs(){
attrNames = namesFromArgs(arguments,attrNames);
return this;
},
repFields = function TAS_Repeating_Fields(){
fieldNames = namesFromArgs(arguments,fieldNames);
return this;
},
repReduce = function TAS_Repeating_Reduce(func, initial, final, context) {
operations.push({
type: 'reduce',
func: (func && _.isFunction(func) && func) || _.noop,
memo: (_.isUndefined(initial) && 0) || initial,
final: (final && _.isFunction(final) && final) || _.noop,
context: context || {}
});
return this;
},
repMap = function TAS_Repeating_Map(func, final, context) {
operations.push({
type: 'map',
func: (func && _.isFunction(func) && func) || _.noop,
final: (final && _.isFunction(final) && final) || _.noop,
context: context || {}
});
return this;
},
repEach = function TAS_Repeating_Each(func, final, context) {
operations.push({
type: 'each',
func: (func && _.isFunction(func) && func) || _.noop,
final: (final && _.isFunction(final) && final) || _.noop,
context: context || {}
});
return this;
},
repTap = function TAS_Repeating_Tap(final, context) {
operations.push({
type: 'tap',
final: (final && _.isFunction(final) && final) || _.noop,
context: context || {}
});
return this;
},
repAfter = function TAS_Repeating_After(callback,context) {
after.push({
callback: (callback && _.isFunction(callback) && callback) || _.noop,
context: context || {}
});
return this;
},
repExecute = function TAS_Repeating_Execute(callback,context){
var rowSet = {},
attrSet = {},
fieldIds = [],
fullFieldNames = [];
repAfter(callback,context);
// call each operation per row.
// call each operation's final
getSectionIDs("repeating_"+sectionName,function(ids){
fieldIds = ids;
fullFieldNames = _.reduce(fieldIds,function(memo,id){
return memo.concat(_.map(fieldNames,function(name){
return 'repeating_'+sectionName+'_'+id+'_'+name;
}));
},[]);
getAttrs( _.uniq(attrNames.concat(fullFieldNames)), function(values){
_.each(attrNames,function(aname){
if(values.hasOwnProperty(aname)){
addProp(attrSet,aname,values[aname]);
}
});
rowSet = _.reduce(fieldIds,function(memo,id){
var r={};
addId(r,id);
_.each(fieldNames,function(name){
var fn = 'repeating_'+sectionName+'_'+id+'_'+name;
addProp(r,name,values[fn],fn);
});
memo[id]=r;
return memo;
},{});
_.each(operations,function(op){
var res;
switch(op.type){
case 'tap':
_.bind(op.final,op.context,rowSet,attrSet)();
break;
case 'each':
_.each(rowSet,function(r){
_.bind(op.func,op.context,r,attrSet,r.id,rowSet)();
});
_.bind(op.final,op.context,rowSet,attrSet)();
break;
case 'map':
res = _.map(rowSet,function(r){
return _.bind(op.func,op.context,r,attrSet,r.id,rowSet)();
});
_.bind(op.final,op.context,res,rowSet,attrSet)();
break;
case 'reduce':
res = op.memo;
_.each(rowSet,function(r){
res = _.bind(op.func,op.context,res,r,attrSet,r.id,rowSet)();
});
_.bind(op.final,op.context,res,rowSet,attrSet)();
break;
}
});
// finalize attrs
applyQueuedUpdates();
_.each(after,function(op){
_.bind(op.callback,op.context)();
});
});
});
};
return {
attrs: repAttrs,
attr: repAttrs,
column: repFields,
columns: repFields,
field: repFields,
fields: repFields,
reduce: repReduce,
inject: repReduce,
foldl: repReduce,
map: repMap,
collect: repMap,
each: repEach,
forEach: repEach,
tap: repTap,
'do': repTap,
after: repAfter,
last: repAfter,
done: repAfter,
execute: repExecute,
go: repExecute,
run: repExecute
};
}(section));
},
repeatingSimpleSum = function(section, field, destination){
repeating(section)
.attr(destination)
.field(field)
.reduce(function(m,r){
return m + (r.F[field]);
},0,function(t,r,a){
a.S[destination]=t;
})
.execute();
};
/* eslint-disable no-console */
console.log('%c•.¸¸.•*´¨`*•.¸¸.•*´¨`*•.¸ The Aaron Sheet v'+version+' ¸.•*´¨`*•.¸¸.•*´¨`*•.¸¸.•','background: linear-gradient(to right,green,white,white,green); color:black;text-shadow: 0 0 8px white;');
console.log('%c•.¸¸.•*´¨`*•.¸¸.•*´¨`*•.¸ Last update: '+(new Date(lastUpdate*1000))+' ¸.•*´¨`*•.¸¸.•*´¨`*•.¸¸.•','background: linear-gradient(to right,green,white,white,green); color:black;text-shadow: 0 0 8px white;');
/* eslint-enable no-console */
return {
/* Repeating Sections */
repeatingSimpleSum: repeatingSimpleSum,
repeating: repeating,
/* Configuration */
config: setConfigOption,
/* Debugging */
callback: wrapCallback,
callstack: logCallstack,
debugMode: debugMode,
isDebugMode: isDebugMode,
_fn: wrapCallback,
/* Logging */
debug: logDebug,
error: logError,
warn: logWarn,
info: logInfo,
notice: logNotice,
log: logLog
};
}());
/* ---- END: TheAaronSheet.js ---- */
//https://wiki.roll20.net/Sheet_Worker_Scripts#change:.3Cattribute_name.3E
on("change:gmroll", function(f) {
getAttrs(["gmroll"], function(v) {
let rollstring = "/me";
if (v.gmroll == "nogm") {
rollstring = "/me";
} else if (v.gmroll == "gm") {
rollstring = "/w GM **@{character_name}**";
}
setAttrs({
abilityroll: rollstring
});
});
});
on("change:ko", function() {
getAttrs(["ko"], function(values) {
setAttrs({
leben: Math.floor(10 + parseInt(values.ko) * 5)
});
setAttrs({
leben_max: Math.floor(10 + parseInt(values.ko) * 5)
});
});
});
on("change:in", function() {
getAttrs(["in"], function(values) {
setAttrs({
mana: Math.floor(10 + parseInt(values.in) * 10)
});
setAttrs({
mana_max: Math.floor(10 + parseInt(values.in) * 10)
});
});
});
on("change:ge change:ruestung change:ruestungGeschick", function() {
getAttrs(["ge", "ruestung", "ruestungGeschick"], function(values) {
if (values.ge < values.ruestungGeschick) {
setAttrs({
verteidigung: Math.floor(parseInt(values.ge) * 3 + parseInt(values.ruestung))
});
} else {
setAttrs({
verteidigung: Math.floor(parseInt(values.ruestungGeschick) * 3 + parseInt(values.ruestung))
});
}
});
});
on('change:repeating_advancements', function () {
TAS.repeating('advancements')
.attrs('XPSpent')
.fields('advancement1xp', 'advancement2xp', 'advancement3xp')
.reduce(function (memo, row, attrSet, id, rowSet) {
memo.total += row.I.advancement1xp;
memo.total += row.I.advancement2xp;
memo.total += row.I.advancement3xp;
return memo;
}, { total: 0 }, function (memo, rowSet, attrSet) {
attrSet.I.XPSpent = memo.total;
})
.execute();
});
</script>