Skip to content

Commit

Permalink
Merge pull request #70 from HavlockV/develop
Browse files Browse the repository at this point in the history
0.2.6
  • Loading branch information
HavlockV authored Aug 15, 2020
2 parents 693a53b + 49f73c1 commit b8183c0
Show file tree
Hide file tree
Showing 11 changed files with 159 additions and 81 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ Compendium 'Weapons' contains a single test weapon.

## What is working

version 0.2.6 :

* Modification of rolls and dice to be compatible with 0.7.x.
* 0.7.x bring a lot of changes. __This needs more testing. I *strongly* recommend not to upgrade to 0.7.x yet__

version 0.2.5 :

* Bug correction on creature sheets.
Expand Down
11 changes: 9 additions & 2 deletions module/chat/damagecards.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ export class CoC7DamageRoll{

if( this.weapon.data.data.properties.addb) this.rollString = this.rollString + '+' + this.actor.db;
if( this.weapon.data.data.properties.ahdb) this.rollString = this.rollString + '+' + this.actor.db + '/2';
// const max =
this.maxDamage = Roll.maximize( this.rollString);

const is7 = Object.prototype.hasOwnProperty.call(Roll, 'cleanTerms');

this.maxDamage = is7? Roll.maximize( this.rollString)._total: Roll.maximize( this.rollString);
this.roll = null;
if( this.critical){
if( this.weapon.impale) {
Expand All @@ -63,6 +65,11 @@ export class CoC7DamageRoll{
this.result = Math.floor( this.roll.total);
}

if( is7) this.roll._dice = this.roll.dice;
else{
this.roll._dice.forEach( d => d.rolls.forEach( r => {r.result = r.roll;}));
}

if( game.dice3d && this.roll){
game.dice3d.showForRoll(this.roll);
}
Expand Down
14 changes: 10 additions & 4 deletions module/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,21 @@ export class CoC7Check {

let max = (this.dice.unit.total == 0)? 100 : 90;
let min = (this.dice.unit.total == 0)? 10 : 0;
let highest = this.dice.total - this.dice.unit.total;
let selected = this.dice.total - this.dice.unit.total;

for( let i = 0; i < this.dice.tens.results.length; i++)
{
let die = {};
die.value = this.dice.tens.results[i];
if( die.value == max) die.isMax = true; else die.isMax = false;
if( die.value == min) die.isMin = true; else die.isMin = false;
if( die.value == highest){ highest = 101; die.selected = true;}
if( die.value == selected) {
selected = 101;
die.selected = true;
if( this.dices.hasBonus) { die.isMax = true; die.isMin = false;}
else {die.isMin = true; die.isMax = false;}
} else {
if( die.value == max) die.isMax = true; else die.isMax = false;
if( die.value == min) die.isMin = true; else die.isMin = false;
}
// if( die.value == 100) die.value = "00";
this.dices.tens.push( die);
}
Expand Down
112 changes: 80 additions & 32 deletions module/dice.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,41 +82,89 @@ export class CoC7Dice {
// return true;
// }

static test(){
const roll = new Roll('2d10');
roll.roll();
const die = new Die(10);
die.faces = 10;
die.roll(50);
}

static roll( modif=0)
{
const normalSides = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90];
const zeroSides = [100, 10, 20, 30, 40, 50, 60, 70, 80, 90];
const unitDie = new Die(10);
unitDie.sides = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
const tenDie = new Die(10);
modif = parseInt( modif);
unitDie.roll(1);
if( unitDie.total == 0)
{
tenDie.sides = zeroSides;
}
else
{
tenDie.sides = normalSides;
}

if( modif == 0 )
{
tenDie.roll(1);
}
else
{
tenDie.roll( 1 + Math.abs(modif));
}

let unitDie;
let tenDie;
let total;
if( modif < 0)
{
total = Math.max( ...tenDie.results);
}
else
{
total = Math.min( ...tenDie.results);
const is7 = Object.prototype.hasOwnProperty.call(Roll, 'cleanTerms');
if( is7){
unitDie = {
total: 0,
results: []
};
tenDie = {
total: 0,
results: []
};
const unit = new DiceTerm({faces:10});
unit.evaluate();
const tens = new DiceTerm({number: Math.abs(modif)+1, faces:10});
unit.results.forEach( r => {
if( 10 === r.result){
r.result = 0;
}
unitDie.results.push( r.result);
});
unitDie.total = unit.total;
tens.evaluate();
tens.results.forEach( r => {
if( 0 != unit.total && 10 === r.result){
r.result = 0;
}
r.result = r.result * 10;
tenDie.results.push( r.result);
});

if( modif < 0){
total = Math.max( ...tens.values);
} else
{
total = Math.min( ...tens.values);
}
tenDie.total = total;
} else {
const normalSides = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90];
const zeroSides = [100, 10, 20, 30, 40, 50, 60, 70, 80, 90];
unitDie = new Die(10);
unitDie.sides = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
tenDie = new Die(10);
modif = parseInt( modif);
unitDie.roll(1);
if( unitDie.total == 0)
{
tenDie.sides = zeroSides;
}
else
{
tenDie.sides = normalSides;
}

if( modif == 0 )
{
tenDie.roll(1);
}
else
{
tenDie.roll( 1 + Math.abs(modif));
}

if( modif < 0)
{
total = Math.max( ...tenDie.results);
}
else
{
total = Math.min( ...tenDie.results);
}
}


Expand Down
4 changes: 2 additions & 2 deletions system.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "CoC7",
"title": "The Call of Cthulhu 7th edition",
"description": "The Call of Cthulhu 7th edition simple game system",
"version": "0.2.5",
"version": "0.2.6",
"author": "HavelockV",
"minimumCoreVersion": "0.5.2",
"compatibleCoreVersion": "0.6.5",
Expand Down Expand Up @@ -69,6 +69,6 @@
"secondaryTokenAttribute": "power",
"url": "https://github.com/HavlockV/CoC7-FoundryVTT/",
"manifest": "https://github.com/HavlockV/CoC7-FoundryVTT/raw/master/system.json",
"download": "https://github.com/HavlockV/CoC7-FoundryVTT/archive/0.2.5.zip"
"download": "https://github.com/HavlockV/CoC7-FoundryVTT/archive/0.2.6.zip"
}

9 changes: 5 additions & 4 deletions templates/chat/combat/damage-result.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ <h3 style="text-align: center;font-weight: bolder;"class="item-name card-title">
{{#each roll._dice as |die key| }}
<section class="tooltip-part">
<div class="dice">
<p class="part-formula">
<span class="part-formula part-header flexrow">
{{die.formula}}
<span class="part-total">{{die.total}}</span>
</p>
<div class="flex1"></div>
<span class="part-total flex0">{{die.total}}</span>
</span>
<ol class="dice-rolls">
{{#each die.rolls as |roll key|}}
<li class="roll die d{{die.faces}}">{{roll.roll}}</li>
<li class="roll die d{{die.faces}}">{{roll.result}}</li>
{{/each}}
</ol>
</div>
Expand Down
18 changes: 10 additions & 8 deletions templates/chat/combat/melee-initiator.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,15 @@ <h3 style="text-align: center;font-weight: bolder;"class="item-name card-title">
<div class="dice-tooltip" style="display: none;">
<section class="tooltip-part">
<div class="dice">
<p class="part-formula">
<span class="part-formula part-header flexrow">
{{#if check.dices.tenOnlyOneDie}}
{{localize 'CoC7.TensDie'}}
{{else}}
{{check.dices.tens.length}} {{localize 'CoC7.TensDice'}}
{{/if}}
<span class="part-total">{{check.dices.tenResult}}</span>
</p>
{{/if}}
<div class="flex1"></div>
<span class="part-total flex0">{{check.dices.tenResult}}</span>
</span>
<ol class="dice-rolls">
{{#each check.dices.tens as |die key|}}
<li class="roll die d10 {{#unless die.selected}}discarded{{/unless}} {{#if die.isMax}}min{{/if}} {{#if die.isMin}}max{{/if}}">{{die.value}}</li>
Expand All @@ -129,10 +130,11 @@ <h3 style="text-align: center;font-weight: bolder;"class="item-name card-title">
</section>
<section class="tooltip-part">
<div class="dice">
<p class="part-formula">
{{localize 'CoC7.UnitsDie'}}
<span class="part-total">{{check.dices.unit.value}}</span>
</p>
<span class="part-formula part-header flexrow">
{{localize 'CoC7.UnitsDie'}}
<div class="flex1"></div>
<span class="part-total flex0">{{check.dices.unit.value}}</span>
</span>
<ol class="dice-rolls">
<li class="roll die d10">{{check.dices.unit.value}}</li>
</ol>
Expand Down
18 changes: 10 additions & 8 deletions templates/chat/combat/melee-target.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,15 @@ <h3 style="text-align: center;font-weight: bolder;"class="item-name card-title">
<div class="dice-tooltip" style="display: none;">
<section class="tooltip-part">
<div class="dice">
<p class="part-formula">
<span class="part-formula part-header flexrow">
{{#if check.dices.tenOnlyOneDie}}
{{localize 'CoC7.TensDie'}}
{{else}}
{{check.dices.tens.length}} {{localize 'CoC7.TensDice'}}
{{/if}}
<span class="part-total">{{check.dices.tenResult}}</span>
</p>
{{/if}}
<div class="flex1"></div>
<span class="part-total flex0">{{check.dices.tenResult}}</span>
</span>
<ol class="dice-rolls">
{{#each check.dices.tens as |die key|}}
<li class="roll die d10 {{#unless die.selected}}discarded{{/unless}} {{#if die.isMax}}min{{/if}} {{#if die.isMin}}max{{/if}}">{{die.value}}</li>
Expand All @@ -146,10 +147,11 @@ <h3 style="text-align: center;font-weight: bolder;"class="item-name card-title">
</section>
<section class="tooltip-part">
<div class="dice">
<p class="part-formula">
{{localize 'CoC7.UnitsDie'}}
<span class="part-total">{{check.dices.unit.value}}</span>
</p>
<span class="part-formula part-header flexrow">
{{localize 'CoC7.UnitsDie'}}
<div class="flex1"></div>
<span class="part-total flex0">{{check.dices.unit.value}}</span>
</span>
<ol class="dice-rolls">
<li class="roll die d10">{{check.dices.unit.value}}</li>
</ol>
Expand Down
21 changes: 12 additions & 9 deletions templates/chat/combat/range-initiator.html
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,15 @@ <h3 style="text-align: center;font-weight: bolder;"class="item-name card-title">
<div class="dice-tooltip" style="display: none;">
<section class="tooltip-part">
<div class="dice ten-dice">
<p class="part-formula">
<span class="part-formula part-header flexrow">
{{#if roll.tenOnlyOneDie}}
{{localize 'CoC7.TensDie'}}
{{else}}
{{roll.dices.tens.length}} {{localize 'CoC7.TensDice'}}
{{/if}}
<span class="part-total">{{roll.dices.tenResult}}</span>
</p>
<div class="flex1"></div>
<span class="part-total flex0">{{roll.dices.tenResult}}</span>
</span>
<ol class="dice-rolls">
{{#each roll.dices.tens as |die key|}}
<li
Expand All @@ -416,10 +417,11 @@ <h3 style="text-align: center;font-weight: bolder;"class="item-name card-title">
</section>
<section class="tooltip-part">
<div class="dice unit-die">
<p class="part-formula">
<span class="part-formula part-header flexrow">
{{localize 'CoC7.UnitsDie'}}
<span class="part-total">{{roll.dices.unit.value}}</span>
</p>
<div class="flex1"></div>
<span class="part-total flex0">{{roll.dices.unit.value}}</span>
</span>
<ol class="dice-rolls">
<li data-value="{{roll.dices.unit.value}}" class="roll die d10">{{roll.dices.unit.value}}</li>
</ol>
Expand Down Expand Up @@ -492,12 +494,13 @@ <h4 class="result-details">{{roll.details}}</h4>
<div class="dice-tooltip" style="display: none;">
<section class="tooltip-part">
<div class="dice ten-dice">
<p class="part-formula">
<span class="part-formula part-header flexrow">
{{#each d.rolls as |roll|}}
<span class="part">{{roll.formula}}</span>
{{/each}}
<span class="part-total">{{d.total}}</span>
</p>
<div class="flex1"></div>
<span class="part-total flex0">{{d.total}}</span>
</span>
<ol class="dice-rolls">
{{#each d.rolls as |roll|}}
<li
Expand Down
14 changes: 8 additions & 6 deletions templates/chat/roll-result.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
<div class="dice-tooltip" style="display: none;">
<section class="tooltip-part">
<div class="dice">
<p class="part-formula">
<span class="part-formula part-header flexrow">
{{#if dices.tenOnlyOneDie}}
{{localize 'CoC7.TensDie'}}
{{else}}
{{dices.tens.length}} {{localize 'CoC7.TensDice'}}
{{/if}}
<span class="part-total">{{dices.tenResult}}</span>
</p>
<div class="flex1"></div>
<span class="part-total flex0">{{dices.tenResult}}</span>
</span>
<ol class="dice-rolls">
{{#each dices.tens as |die key|}}
<li class="roll die d10 {{#unless die.selected}}discarded{{/unless}} {{#if die.isMax}}min{{/if}} {{#if die.isMin}}max{{/if}}">{{die.value}}</li>
Expand All @@ -38,10 +39,11 @@
</section>
<section class="tooltip-part">
<div class="dice">
<p class="part-formula">
<span class="part-formula part-header flexrow">
{{localize 'CoC7.UnitsDie'}}
<span class="part-total">{{dices.unit.value}}</span>
</p>
<div class="flex1"></div>
<span class="part-total flex0">{{dices.unit.value}}</span>
</span>
<ol class="dice-rolls">
<li class="roll die d10">{{dices.unit.value}}</li>
</ol>
Expand Down
Loading

0 comments on commit b8183c0

Please sign in to comment.