Merge pull request #8649 from danielsousat/opera-rules-change

[Opera] rules change and string fixes
This commit is contained in:
Miguel Peres
2021-04-05 13:12:58 -03:00
committed by GitHub
3 changed files with 252 additions and 88 deletions
+4
View File
@@ -31,6 +31,10 @@
width: 4.2em;
}
.sheet-bigger-number-input {
width: 6em !important;
}
.sheet-main-container textarea {
box-sizing: border-box;
margin: 0px;
+233 -73
View File
@@ -22,8 +22,8 @@
<span class="column-header secondary-font" data-i18n="max">Max</span>
<span class="column-header secondary-font" data-i18n="used">Usado</span>
<input name="attr_max_attribute_points" type="number" title="@{max_attribute_points}" value="18" />
<input name="attr_used_attribute_points" type="number" disabled="true" title="@{used_attribute_points}"
<input class="bigger-number-input" name="attr_max_attribute_points" type="number" title="@{max_attribute_points}" value="18" />
<input class="bigger-number-input" name="attr_used_attribute_points" type="number" disabled="true" title="@{used_attribute_points}"
value="@{charphysique} + @{chardexterity} + @{charintelligence}" />
</div>
@@ -33,9 +33,9 @@
<span class="column-header secondary-font" data-i18n="max">Max</span>
<span class="column-header secondary-font" data-i18n="used">Usado</span>
<input name="attr_max_creation_points" type="number" title="@{max_creation_points}" value="0" />
<input name="attr_used_creation_points" type="number" disabled="true" title="@{used_creation_points}"
value="@{powers_total_cost} + @{skills_total_cost} + @{features_total_cost} + @{fightcost}" />
<input class="bigger-number-input" name="attr_max_creation_points" type="number" title="@{max_creation_points}" value="0" />
<input class="bigger-number-input" name="attr_used_creation_points" type="number" readonly title="@{used_creation_points}"
value="0" />
</div>
</div>
@@ -359,17 +359,17 @@
<button type="action" class="add-button" name="act_additional_limbs"></button>
<span class="label secondary-font" data-i18n="additional_limbs"
data-i18n-title="additional_limbs-description"
title="Cada dois níveis, atribuí a expressão “x(nível/2+1)” ao atributo Destreza. Adiciona seu (nível/2) ao número de ações físicas ao personagem">Membros
title="Cada dois níveis, atribuí a expressão “x(nível/2+1)” ao atributo Destreza. Adiciona seu (nível/2) ao número de ações físicas do personagem">Membros
Adicionais</span>
<button type="action" class="add-button" name="act_increased_size"></button>
<span class="label secondary-font" data-i18n="increased_size" data-i18n-title="increased_size-description"
title="Comprada a partir do nível 2. Atribuí a expressão “x(nível)” ao atributo Físico">Tamanho
title="Comprada a partir do nível 2. Atribuí a expressão “x(nível)” ao atributo Físico e gera nível-1 de penalidade à Esquiva.">Tamanho
Ampliado</span>
<button type="action" class="add-button" name="act_reduced_size"></button>
<span class="label secondary-font" data-i18n="reduced_size" data-i18n-title="reduced_size-description"
title="Comprada a partir do nível 2. Atribuí a expressão “/(nível)” ao atributo Físico">Tamanho
title="Comprada a partir do nível 2. Atribuí a expressão “/(nível)” ao atributo Físico e gera nível-1 de bônus à Esquiva.">Tamanho
Reduzido</span>
</div>
</div>
@@ -433,7 +433,7 @@
<button type="action" class="add-button" name="act_increased_dexterity"></button>
<span class="label secondary-font" data-i18n="increased_dexterity"
data-i18n-title="increased_dexterity-description"
title="Comprada a partir do nível 2. Atribuí a expressão “x(nível)” ao atributo Destreza. Adiciona seu (nível-1) ao número de ações físicas ao personagem.">Ampliação
title="Comprada a partir do nível 2. Atribuí a expressão “x(nível)” ao atributo Destreza. Adiciona seu (nível-1) ao número de ações físicas do personagem.">Ampliação
de Destreza</span>
<button type="action" class="add-button" name="act_increased_physical"></button>
@@ -445,7 +445,7 @@
<button type="action" class="add-button" name="act_increased_intelligence"></button>
<span class="label secondary-font" data-i18n="increased_intelligence"
data-i18n-title="increased_intelligence-description"
title="Comprada a partir do nível 2. Atribuí a expressão “x(nível)” ao atributo Inteligência. Adiciona seu (nível-1) ao número de ações mentais ao personagem.">Ampliação
title="Comprada a partir do nível 2. Atribuí a expressão “x(nível)” ao atributo Inteligência. Adiciona seu (nível-1) ao número de ações mentais do personagem.">Ampliação
de Inteligência</span>
<button type="action" class="add-button" name="act_reduced_dexterity"></button>
@@ -562,7 +562,7 @@
<input class="row-item-margin" readonly="true" name="attr_fight_name" type="text" title="@{fight_name}"
data-i18n-placeholder="fight" placeholder="Briga" />
<input class="row-item-margin" readonly="true" name="attr_fightlevel" type="text" title="@{fightlevel}" />
<input class="row-item-margin" readonly="true" name="attr_fightlevel" type="text" title="@{fightlevel}" value="0" />
<input class="weapons-damage-total" readonly="true" name="attr_fightdamagetotal" type="text"
title="@{fightdamagetotal}" value="0" />
@@ -660,18 +660,18 @@
<div></div>
<input class="weapons-base" name="attr_weaponblowtotal" type="text" title="@{weaponblowtotal}"
disabled="true"
value="@{weaponlevel} + @{weaponblow} + @{fightblow} + (@{chardexterity} @{weaponeffect})" />
value="@{weaponlevel} + @{weaponblow} + (@{chardexterity} @{weaponeffect})" />
<button type="roll" class="roll-button" name="roll_weaponblow_check" title="@{weaponblow_check}"
value="&{template:main} {{charname=@{character_name}}} {{action=@{weaponname} - @{blow}}} {{value=[[@{weaponlevel} + @{weaponblow} + @{fightblow} + (@{chardexterity} @{weaponeffect})]]}} {{dispute=[[ [[2d6cs>2cf<5]] + @{weaponlevel} + @{weaponblow} + @{fightblow} + (@{chardexterity} @{weaponeffect}) ]] }} {{roll=$[[1]]}} {{damage=[[@{weapondamagetotal}]]}} {{bodyroll=[[2d6cs0cf0]]}}"></button>
value="&{template:main} {{charname=@{character_name}}} {{action=@{weaponname} - @{blow}}} {{value=[[@{weaponblowtotal}]]}} {{dispute=[[ [[2d6cs>2cf<5]] + @{weaponblowtotal} ]] }} {{roll=$[[1]]}} {{damage=[[@{weapondamagetotal}]]}} {{bodyroll=[[2d6cs0cf0]]}}"></button>
</div>
<div class="weapons-subheader-grid">
<div></div>
<input class="weapons-base" name="attr_weaponparrytotal" type="text" title="@{weaponparrytotal}"
disabled="true"
value="@{weaponlevel} + @{weaponparry} + @{fightparry} + (@{chardexterity} @{weaponeffect})" />
value="@{weaponlevel} + @{weaponparry} + (@{chardexterity} @{weaponeffect})" />
<button type="roll" class="roll-button" name="roll_weaponparry_check" title="@{weaponparry_check}"
value="&{template:main} {{charname=@{character_name}}} {{action=@{weaponname} - @{parry}}} {{value=[[@{weaponlevel} + @{weaponparry} + @{fightparry} + (@{chardexterity} @{weaponeffect})]]}} {{dispute=[[ [[2d6cs>2cf<5]] + @{weaponlevel} + @{weaponparry} + @{fightparry} + (@{chardexterity} @{weaponeffect}) ]] }} {{roll=$[[1]]}}"></button>
value="&{template:main} {{charname=@{character_name}}} {{action=@{weaponname} - @{parry}}} {{value=[[@{weaponparrytotal}]]}} {{dispute=[[ [[2d6cs>2cf<5]] + @{weaponparrytotal} ]] }} {{roll=$[[1]]}}"></button>
</div>
<div class="showhidebutton arrowtype">
@@ -721,7 +721,7 @@
value="0" />
<input class="weapons-damage-total" name="attr_weaponblowtotal" type="text"
title="@{weaponblowtotal}" disabled="true"
value="@{weaponlevel} + @{weaponblow} + @{fightblow} + (@{chardexterity} @{weaponeffect})" />
value="@{weaponlevel} + @{weaponblow} + (@{chardexterity} @{weaponeffect})" />
</div>
<div class="weapons-subheader-grid">
@@ -729,7 +729,7 @@
value="0" />
<input class="weapons-damage-total" name="attr_weaponparrytotal" type="text"
title="@{weaponparrytotal}" disabled="true"
value="@{weaponlevel} + @{weaponparry} + @{fightparry} + (@{chardexterity} @{weaponeffect})" />
value="@{weaponlevel} + @{weaponparry} + (@{chardexterity} @{weaponeffect})" />
</div>
</div>
@@ -899,17 +899,11 @@
<input class="row-item-margin" readonly="true" name="attr_fight_name" type="text" title="@{fight_name}"
data-i18n-placeholder="fight" placeholder="Briga" />
<span class="secondary-font" data-i18n="dexterity">Destreza</span>
<input type="hidden" name="attr_fightattribute" value="@{chardexterity}" />
<select class="select row-item-margin" name="attr_fightlevel" title="@{fightlevel}">
<option value="0" selected="selected">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<input class="row-item-margin" name="attr_fightcost" type="text" readonly title="@{fightcost}" value="1" />
<input class="row-item-margin" name="attr_fighttotal" type="number" disabled="true" title="@{fighttotal}"
value="@{fightattribute} + @{fightlevel}" />
<input class="row-item-margin" name="attr_fightlevel" type="text" title="@{fightlevel}" value="0" />
<input class="row-item-margin" name="attr_fightcost" type="text" readonly title="@{fightcost}" value="0" />
<input class="row-item-margin" name="attr_fighttotal" type="number" readonly title="@{fighttotal}"
value="0" />
<div>
</div>
@@ -927,25 +921,20 @@
value="&{template:main} {{charname=@{character_name}}} {{action=@{skill}}} {{value=[[@{skilltotal}]]}} {{dispute=[[ [[2d6cs>2cf<5]] + @{skilltotal}]]}} {{roll=$[[1]]}}"></button>
<input class="row-item-margin" name="attr_skill" type="text" title="@{skill}" />
<select class="select row-item-margin" name="attr_skillattribute" title="@{skillattribute}">
<option value="@{charphysique}" data-i18n="physique" selected="selected">Físico</option>
<option value="@{chardexterity}" data-i18n="dexterity">Destreza</option>
<option value="@{charintelligence}" data-i18n="intelligence">Inteligência</option>
<option value="@{charwill}" data-i18n="will">Vontade</option>
<option value="@{charmind}" data-i18n="mind">Mente</option>
<option value="@{charmagic}" data-i18n="magic">Magia</option>
<option value="@{charperception}" data-i18n="perception">Percepção</option>
<option value="@{charluck}" data-i18n="luck">Sorte</option>
</select>
<select class="select row-item-margin" name="attr_skilllevel" title="@{skilllevel}">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="charphysique" data-i18n="physique" selected="selected">Físico</option>
<option value="chardexterity" data-i18n="dexterity">Destreza</option>
<option value="charintelligence" data-i18n="intelligence">Inteligência</option>
<option value="charwill" data-i18n="will">Vontade</option>
<option value="charmind" data-i18n="mind">Mente</option>
<option value="charmagic" data-i18n="magic">Magia</option>
<option value="charperception" data-i18n="perception">Percepção</option>
<option value="charluck" data-i18n="luck">Sorte</option>
</select>
<input class="row-item-margin" name="attr_skilllevel" type="text" title="@{skilllevel}" value="1" />
<input class="row-item-margin" name="attr_skillcost" type="text" readonly title="@{skillcost}"
value="1" />
<input class="row-item-margin" name="attr_skilltotal" type="number" disabled="true"
title="@{skilltotal}" value="@{skillattribute} + @{skilllevel}" />
<input class="row-item-margin" name="attr_skilltotal" type="number" readonly
title="@{skilltotal}" value="0" />
<div class="showhidebutton arrowtype">
<input type="checkbox" name="attr_showhide_checkbox" value="1" />
@@ -969,7 +958,7 @@
<div class="experience-points">
<span class="label secondary-font" data-i18n="experience_points">Pontos de Experiência</span>
<input name="attr_xp" type="number" title="@{xp}" />
<input class="bigger-number-input" name="attr_xp" type="number" title="@{xp}" />
</div>
</div>
@@ -1183,7 +1172,18 @@
/*Controlling contact weapons damage total*/
on('change:repeating_contactweapons:weapondamage change:physicaldamage', function(eventInfo) {
console.log('weapon damage total');
setRollTotal(['repeating_contactweapons_weapondamage', 'physicaldamage'], 'repeating_contactweapons_weapondamagetotal');
/* recovering all weapons IDs */
getSectionIDs(`repeating_contactweapons`, idArray => {
idArray.forEach(id => {
setRollTotal([`repeating_contactweapons_${id}_weapondamage`, 'physicaldamage'], `repeating_contactweapons_${id}_weapondamagetotal`);
});
});
});
/* calculating physical damage */
@@ -1198,7 +1198,7 @@
factor = Math.floor(eval(parse));
total = Math.floor(factor/8);
console.log(`physical damage total: ${total}`);
setAttrs({
physicaldamage: total
});
@@ -1228,37 +1228,113 @@
repeatingSum("totalpenalty","protection", "protectionpenalty");
});
/* Declaring a Cost Object to be used on creation points calculation */
function Cost(negative, positive) {
this.negative = negative;
this.positive = positive;
}
/* calculates total Cost of a repeating section */
function calculateCost(section, field, total) {
getSectionIDs(section, idArray => {
const fields = idArray.map(id => `${section}_${id}_${field}`);
getAttrs(fields, function(values) {
console.log(`begin calc Cost for ${total} `);
let out = {};
out[total] = new Cost(0,0);
for (let key in values) {
let parsedValue = parseInt(values[key])||0;
if (parsedValue > 0) {
out[total].positive += parsedValue;
} else {
out[total].negative += parsedValue;
}
}
console.log(out);
setAttrs(out);
});
});
}
function getIntValue(value) {
return parseInt(value)||0;
}
/* calculating total creation points */
on('sheet:opened change:fightcost ' +
'change:powers_total_cost ' +
'change:skills_total_cost ' +
'change:features_total_cost'
, function() {
getAttrs(['fightcost', 'powers_total_cost', 'skills_total_cost', 'features_total_cost'], values =>{
let totalNegative = 0;
let totalPositive = 0;
console.log('begin calc creation points');
for (let key in values) {
v = values[key];
console.log(v);
if (v.positive !== undefined) {
totalPositive += getIntValue(v.positive);
totalNegative += getIntValue(v.negative);
} else {
/*if it doesn't have the positive property, than it is the simple fightcost value */
totalPositive += getIntValue(v);
}
}
/* each negative point beyond -10 costs half rounded down.
* Ex: -15 has -5 past -10, so -15 will be (-10) + (-5/2) = -10 -2 = -12.
*/
if (totalNegative < -10) {
totalNegative = -10 + Math.floor((totalNegative+10)/2);
}
/* the max negative cost is -20 */
if (totalNegative < -20) {
totalNegative = -20;
}
console.log(`total negative = ${totalNegative}`);
console.log(`total positive = ${totalPositive}`);
setAttrs({
used_creation_points: totalPositive+totalNegative
});
});
});
/* calculating total powers cost */
on('sheet:opened change:repeating_powers remove:repeating_powers', function() {
repeatingSum("powers_total_cost","powers", "powercost");
calculateCost("repeating_powers", "powercost", "powers_total_cost");
});
/* calculating total skills cost */
on('sheet:opened change:repeating_skills remove:repeating_skills', function() {
repeatingSum("skills_total_cost","skills", "skillcost");
calculateCost("repeating_skills", "skillcost", "skills_total_cost");
});
/* calculating total features cost */
on('sheet:opened change:repeating_features remove:repeating_features', function() {
repeatingSum("features_total_cost","features", "featurecost");
calculateCost("repeating_features", "featurecost", "features_total_cost");
});
function getSkillCost(skillLevel) {
let skillCost = 0;
switch (skillLevel) {
case '1':
skillCost = 1;
break;
case '2':
skillCost = 3;
break;
case '3':
skillCost = 6;
break;
case '4':
skillCost = 10;
break;
/* the skill cost value is equal to the sum of the level plus all levels before */
for(let i=1; i<=skillLevel; i++) {
skillCost += i;
}
return skillCost;
@@ -1276,6 +1352,66 @@
});
});
/*sets a skill total. If the total exceeds 14, sets the maximum 14 */
function setSkillTotal(attributeField, levelField, totalField) {
getAttrs([attributeField, levelField], function(values) {
let total = 0;
let target = {};
total += parseInt(values[attributeField])||0;
total += parseInt(values[levelField])||0;
console.log(total);
target[totalField] = total > 14? 14 : total;
setAttrs(target);
});
}
/* setting the Fight Skill Total */
on('change:chardexterity change:fightlevel', function(eventInfo) {
setSkillTotal('chardexterity', 'fightlevel', 'fighttotal');
});
/* Since the repeating_skills skillattribute has changed from @{attributeName} to
* simply attributeName, this parse is needed to make the skill total calc worker
* with old sheets */
function parseAttributeName(attrName) {
let ret = attrName.replace('@{','').replace('}','');
return ret;
}
/* setting skill total */
on('change:repeating_skills:skillattribute change:repeating_skills:skilllevel ' +
'change:charphysique '+
'change:chardexterity '+
'change:charintelligence '+
'change:charperception '+
'change:charwill '+
'change:charmind '+
'change:charmagic '+
'change:charluck '
, function(eventInfo) {
/* recovering all skills IDs */
getSectionIDs(`repeating_skills`, idArray => {
idArray.forEach(id => {
/*recovering skill attribute name */
getAttrs([`repeating_skills_${id}_skillattribute`], values => {
let attrName = parseAttributeName(values[`repeating_skills_${id}_skillattribute`]);
setSkillTotal(attrName, `repeating_skills_${id}_skilllevel` , `repeating_skills_${id}_skilltotal`)
});
});
});
});
const fightParameters = [
{
fightblow: 0,
@@ -1283,28 +1419,40 @@
fightdodgebonus: 0,
fightdamage: 'd2-1'
},
{
fightblow: 1,
fightparry: 0,
fightdodgebonus: 0,
fightdamage: 'd2-1'
},
{
fightblow: 1,
fightparry: 1,
fightdodgebonus: 1,
fightdamage: '1'
fightdamage: 'd2-1'
},
{
fightblow: 2,
fightparry: 2,
fightdodgebonus: 1,
fightdodgebonus: 2,
fightdamage: 'd2-1'
},
{
fightblow: 2,
fightparry: 2,
fightdodgebonus: 2,
fightdamage: '1'
},
{
fightblow: 3,
fightparry: 3,
fightdodgebonus: 2,
fightdodgebonus: 3,
fightdamage: '1'
},
{
fightblow: 4,
fightparry: 4,
fightdodgebonus: 4,
fightdamage: '1'
},
{
fightblow: 4,
fightparry: 4,
fightdodgebonus: 4,
fightdamage: '1'
}
];
@@ -1316,7 +1464,9 @@
out = {};
let skillCost = getSkillCost(skillLevel);
let fightParams = fightParameters[skillLevel];
/* fight levels beyond 6 give no more bonus, so we have to use the level 6 bonus */
let fightParams = skillLevel>6 ? fightParameters[6]:fightParameters[skillLevel];
out.fightcost = skillCost;
out = Object.assign(out, fightParams);
@@ -1575,6 +1725,11 @@
target: 'charphysicalfeatureeffect',
value: level => level,
operation: OperationEnum.MULT
},
{
target: 'dodgefeatureeffect',
value: level => (-1)*(level-1),
operation: OperationEnum.SUM
}
]
},
@@ -1588,6 +1743,11 @@
target: 'charphysicalfeatureeffect',
value: level => (-1)*level,
operation: OperationEnum.MULT
},
{
target: 'dodgefeatureeffect',
value: level => (level-1),
operation: OperationEnum.SUM
}
]
}
+15 -15
View File
@@ -39,7 +39,7 @@
"fast_reflexes-description": "Cada nível atribuí +1 de Esquiva",
"fast_reflexes": "Reflexos Rápidos",
"increased_senses-description": "Cada nível atribuí +1 de Percepção",
"increased_senses": "Sentidos\n Ampliados",
"increased_senses": "Sentidos Ampliados",
"reduced_senses-description": "Cada nível atribuí -1 de Percepção",
"reduced_senses": "Sentidos Reduzidos",
"increased_mind-description": "Cada nível atribuí +1 de Mente",
@@ -52,28 +52,28 @@
"strong_will": "Vontade Forte",
"weak_will-description": "Cada nível atribuí -1 de Vontade",
"weak_will": "Vontade Fraca",
"additional_limbs-description": "Cada dois níveis, atribuí a expressão “x(nível/2+1)” ao atributo Destreza. Adiciona seu (nível/2) ao número de ações físicas ao personagem",
"additional_limbs": "Membros\n Adicionais",
"increased_size-description": "Comprada a partir do nível 2. Atribuí a expressão “x(nível)” ao atributo Físico",
"increased_size": "Tamanho\n Ampliado",
"reduced_size-description": "Comprada a partir do nível 2. Atribuí a expressão “/(nível)” ao atributo Físico",
"reduced_size": "Tamanho\n Reduzido",
"additional_limbs-description": "Cada dois níveis, atribuí a expressão “x(nível/2+1)” ao atributo Destreza. Adiciona seu (nível/2) ao número de ações físicas do personagem",
"additional_limbs": "Membros Adicionais",
"increased_size-description": "Comprada a partir do nível 2. Atribuí a expressão “x(nível)” ao atributo Físico e gera nível-1 de penalidade à Esquiva.",
"increased_size": "Tamanho Ampliado",
"reduced_size-description": "Comprada a partir do nível 2. Atribuí a expressão “/(nível)” ao atributo Físico e gera nível-1 de bônus à Esquiva.",
"reduced_size": "Tamanho Reduzido",
"feature": "Característica",
"level": "Nível",
"cost": "Custo",
"description": "Descrição",
"powers": "Poderes",
"increased_dexterity-description": "Comprada a partir do nível 2. Atribuí a expressão “x(nível)” ao atributo Destreza. Adiciona seu (nível-1) ao número de ações físicas ao personagem.",
"increased_dexterity": "Ampliação\n de Destreza",
"increased_dexterity-description": "Comprada a partir do nível 2. Atribuí a expressão “x(nível)” ao atributo Destreza. Adiciona seu (nível-1) ao número de ações físicas do personagem.",
"increased_dexterity": "Ampliação de Destreza",
"increased_physical-description": "Comprada a partir do nível 2. Atribuí a expressão “x(nível)” ao atributo Físico",
"increased_physical": "Ampliação de\n Físico",
"increased_intelligence-description": "Comprada a partir do nível 2. Atribuí a expressão “x(nível)” ao atributo Inteligência. Adiciona seu (nível-1) ao número de ações mentais ao personagem.",
"increased_intelligence": "Ampliação\n de Inteligência",
"increased_physical": "Ampliação de Físico",
"increased_intelligence-description": "Comprada a partir do nível 2. Atribuí a expressão “x(nível)” ao atributo Inteligência. Adiciona seu (nível-1) ao número de ações mentais do personagem.",
"increased_intelligence": "Ampliação de Inteligência",
"reduced_dexterity-description": "Comprada a partir do nível 2. Atribuí a expressão “/(nível)” ao atributo Inteligência",
"reduced_dexterity": "Redução de\n Destreza",
"reduced_dexterity": "Redução de Destreza",
"reduced_physical-description": "Comprada a partir do nível 2. Atribuí a expressão “/(nível)” ao atributo Físico",
"reduced_physical": "Redução de\n Físico",
"reduced_intelligence": "Redução de\n Inteligência",
"reduced_physical": "Redução de Físico",
"reduced_intelligence": "Redução de Inteligência",
"skills": "Habilidades",
"skill": "Habilidade",
"attribute": "Atributo",