roll dice

This commit is contained in:
François-Xavier Guillois
2023-05-18 23:19:05 +02:00
parent 03d71ecd3c
commit 2dacf17369
21 changed files with 544 additions and 864 deletions
+434
View File
File diff suppressed because one or more lines are too long
+25 -429
View File
File diff suppressed because one or more lines are too long
+7 -1
View File
@@ -2,6 +2,9 @@
"TOTEM.WorldSettings.GameMode.Name":"Choix du mode de jeu",
"TOTEM.WorldSettings.GameMode.Hint":"À limage de certains jeux vidéo proposant différents, Vermine 2047 permet aux joueurs de choisir leur Mode de jeu et de fixer eux-mêmes le degré de réalisme, de surnaturel et de dangerosité de lunivers.",
"TOTEM.roll_tool": "Lanceur de dés",
"TOTEM.roll_dice": "Jeter les dés",
"TOTEM.level": "Niveau",
"TOTEM.pool": "Réserve",
"TOTEM.pools": "Réserves",
@@ -12,11 +15,14 @@
"TOTEM.ability":"Caractéristique",
"TOTEM.skills_title":"Compétences",
"TOTEM.skill_title":"Compétence",
"TOTEM.skill_mastery":"Maîtrise",
"TOTEM.bonus":"Bonus",
"TOTEM.penalty":"Malus",
"TOTEM.reroll":"Relance",
"TOTEM.specialty":"Spécialité",
"TOTEM.difficulty":"Difficulty",
"TOTEM.difficulty":"Difficulté",
"TOTEM.help":"Entraide",
"TOTEM.tooling":"Matériel",
"TOTEM.vigor_ability":"Vigueur",
+4 -1
View File
@@ -222,7 +222,10 @@ export class TotemCharacterSheet extends TotemActorSheet {
console.log($(element).attr('for'));
const NoD = this.actor.system.skills[$(element).attr('for').split('.')[2]]?.value || 0
return game.totem.TotemRoll.roll(this.actor.id, label, NoD, 0, {});*/
let data = {};
let data = {
actorId: this.actor.id,
label: game.i18n.localize(dataset.label)
};
getRollBox(data);
return true;
}
-1
View File
@@ -5,7 +5,6 @@ export const TOTEM = {};
* @type {Object}
*/
TOTEM.SkillLevels = {
1:{ "label":"TOTEM.skill_level.beginner", "dicePool":1, "reroll":0},
2:{ "label":"TOTEM.skill_level.proficient", "dicePool":1, "reroll":1},
+40 -32
View File
@@ -38,47 +38,55 @@
export const getRollBox = async function(data) {
let html = await renderTemplate('systems/totem/templates/roll.hbs', data);
let ui = new Dialog({
title: game.i18n.localize("TOTEM.RollTool"),
title: game.i18n.localize("TOTEM.roll_tool"),
content: html,
buttons: {
roll: {
label: game.i18n.localize('TOTEM.RollDice'),
label: game.i18n.localize('TOTEM.roll_dice'),
callback: (html) => {
let form = html.find('#dice-pool-form');
if (!form[0].checkValidity()) {
throw "Invalid Data";
}
let target = 0, trait, usingSpecialization, difficulty, skill = 0, params = {};
form.serializeArray().forEach(e => {
switch (e.name) {
case "difficulty":
if (e.value != "")
difficulty = -e.value;
break;
case "skillLabel":
params.skill = e.value;
break;
case "usure":
params.usure = +e.value;
break;
case "skill":
skill = +e.value;
break;
case "trait":
trait = +e.value;
break;
case "usingSpecialization":
if (e.value && +e.value > 1)
usingSpecialization = +e.value;
break;
}
// prise en compte de l'usure sur la feuille de perso
if (params.usure != undefined){
updateActorSkillScore(actor, data.skill, 'spent', data.skillSpent + parseInt(params.usure,10));
}
let formData = {};
form.serializeArray().map(item => {
formData[item.name] = item.value;
});
return EcrymeRoll.get().performTest(data.dicePool, target, trait, usingSpecialization, difficulty, skill, params, actor);
console.log("roll form data", formData);
let NoD = parseInt(formData.ability,10);
let Reroll = 0;
// maîtrise bonus
if (formData.skill > 0 && formData.skill < 3){
NoD += 1;
} else if (formData.skill > 2 && formData.skill < 5){
NoD += 2;
} else if (formData.skill > 4){
NoD += 3;
}
// maîtrise relance
if (formData.skill > 1 && formData.skill < 4){
Reroll += 1;
} else if (formData.skill > 3){
Reroll += 2;
}
// réserves
if (formData.self_control > 0){
NoD += parseInt(formData.self_control,10);
}
if (formData.group > 0){
NoD += parseInt(formData.group,10);
}
// checks
if (formData.usingSpecialization !== undefined && formData.usingSpecialization == 1){
NoD += 1;
}
if (formData.usingTools !== undefined && formData.usingTools == 1){
NoD += 1;
}
if (formData.helped !== undefined && formData.helped == 1){
NoD += 1;
}
return game.totem.TotemRoll.roll(data.actorId, data.label, NoD, Reroll, data);
}
},
close: {
+7 -3
View File
@@ -1,9 +1,13 @@
export class TotemRoll {
static roll(actorId, label, NoD, Mod, params = {}){
static roll(actorId, label, NoD, Reroll = 0, params = {}){
const actor = game.actors.get(actorId);
let roll = new Roll(NoD + "d10+"+ Mod, actor.getRollData());
let formula = '{' + NoD + "d10";
if (Reroll > 0){
formula += 'r' + Reroll;
}
formula += (params.difficulty != undefined) ? "}cs>" + params.difficulty : "}cs>7";
let roll = new Roll(formula, actor.getRollData());
roll.toMessage({
speaker: ChatMessage.getSpeaker({ actor: actor }),
flavor: label,
-21
View File
@@ -1,21 +0,0 @@
// Add custom fonts by visiting and search https://fonts.google.com
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
// Import utilities.
@import 'utils/typography';
@import 'utils/colors';
@import 'utils/mixins';
@import 'utils/variables';
/* Global styles */
@import 'global/window';
@import 'global/grid';
@import 'global/flex';
/* Styles limited to totem sheets */
.totem {
@import 'components/forms';
@import 'components/resource';
@import 'components/items';
@import 'components/effects';
}
-14
View File
@@ -1,14 +0,0 @@
.effects .item {
.effect-source,
.effect-duration,
.effect-controls {
text-align: center;
border-left: 1px solid #c9c7b8;
border-right: 1px solid #c9c7b8;
font-size: 12px;
}
.effect-controls {
border: none;
}
}
-55
View File
@@ -1,55 +0,0 @@
.item-form {
font-family: $font-primary;
}
.sheet-header {
flex: 0 auto;
overflow: hidden;
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
margin-bottom: 10px;
.profile-img {
flex: 0 0 100px;
height: 100px;
margin-right: 10px;
}
.header-fields {
flex: 1;
}
h1.charname {
height: 50px;
padding: 0px;
margin: 5px 0;
border-bottom: 0;
input {
width: 100%;
height: 100%;
margin: 0;
}
}
}
.sheet-tabs {
flex: 0;
}
.sheet-body,
.sheet-body .tab,
.sheet-body .tab .editor {
height: 100%;
}
.tox {
.tox-editor-container {
background: $c-white;
}
.tox-edit-area {
padding: 0 8px;
}
}
-120
View File
@@ -1,120 +0,0 @@
// Section Header
.items-header {
height: 28px;
margin: 2px 0;
padding: 0;
align-items: center;
background: rgba(0, 0, 0, 0.05);
border: $border-groove;
font-weight: bold;
> * {
font-size: 14px;
text-align: center;
}
.item-name {
font-weight: bold;
padding-left: 5px;
text-align: left;
display: flex;
// font-size: 16px;
}
}
/* ----------------------------------------- */
/* Items Lists */
/* ----------------------------------------- */
.items-list {
list-style: none;
margin: 0;
padding: 0;
overflow-y: auto;
scrollbar-width: thin;
color: $c-tan;
// Child lists
.item-list {
list-style: none;
margin: 0;
padding: 0;
}
// Item Name
.item-name {
flex: 2;
margin: 0;
overflow: hidden;
font-size: 13px;
text-align: left;
align-items: center;
display: flex;
h3, h4 {
margin: 0;
white-space: nowrap;
overflow-x: hidden;
}
}
// Control Buttons
.item-controls {
display: flex;
flex: 0 0 100px;
justify-content: flex-end;
a {
font-size: 12px;
text-align: center;
margin: 0 6px;
}
}
// Individual Item
.item {
align-items: center;
padding: 0 2px; // to align with the header border
border-bottom: 1px solid $c-faint;
&:last-child { border-bottom: none; }
.item-name {
color: $c-dark;
.item-image {
flex: 0 0 30px;
height: 30px;
background-size: 30px;
border: none;
margin-right: 5px;
}
}
}
.item-prop {
text-align: center;
border-left: 1px solid #c9c7b8;
border-right: 1px solid #c9c7b8;
font-size: 12px;
}
// Section Header
.items-header {
height: 28px;
margin: 2px 0;
padding: 0;
align-items: center;
background: rgba(0, 0, 0, 0.05);
border: $border-groove;
font-weight: bold;
> * {
font-size: 12px;
text-align: center;
}
.item-name {
padding-left: 5px;
text-align: left;
// font-size: 16px;
}
}
}
/* Example style for Totem (can be removed if not needed) */
.item-formula {
flex: 0 0 200px;
padding: 0 8px;
}
-3
View File
@@ -1,3 +0,0 @@
.resource-label {
font-weight: bold;
}
-46
View File
@@ -1,46 +0,0 @@
// Flexbox.
.flex-group-center,
.flex-group-left,
.flex-group-right {
justify-content: center;
align-items: center;
text-align: center;
}
.flex-group-left {
justify-content: flex-start;
text-align: left;
}
.flex-group-right {
justify-content: flex-end;
text-align: right;
}
.flexshrink {
flex: 0;
}
.flex-between {
justify-content: space-between;
}
.flexlarge {
flex: 2;
}
// Alignment styles.
.align-left {
justify-content: flex-start;
text-align: left;
}
.align-right {
justify-content: flex-end;
text-align: right;
}
.align-center {
justify-content: center;
text-align: center;
}
-85
View File
@@ -1,85 +0,0 @@
// Grid.
.grid,
.grid-2col {
display: grid;
grid-column: span 2 / span 2;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
margin: 10px 0;
padding: 0;
}
.grid-3col {
grid-column: span 3 / span 3;
grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-4col {
grid-column: span 4 / span 4;
grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid-5col {
grid-column: span 5 / span 5;
grid-template-columns: repeat(5, minmax(0, 1fr));
}
.grid-6col {
grid-column: span 6 / span 6;
grid-template-columns: repeat(6, minmax(0, 1fr));
}
.grid-7col {
grid-column: span 7 / span 7;
grid-template-columns: repeat(7, minmax(0, 1fr));
}
.grid-8col {
grid-column: span 8 / span 8;
grid-template-columns: repeat(8, minmax(0, 1fr));
}
.grid-9col {
grid-column: span 9 / span 9;
grid-template-columns: repeat(9, minmax(0, 1fr));
}
.grid-10col {
grid-column: span 10 / span 10;
grid-template-columns: repeat(10, minmax(0, 1fr));
}
.grid-11col {
grid-column: span 11 / span 11;
grid-template-columns: repeat(11, minmax(0, 1fr));
}
.grid-12col {
grid-column: span 12 / span 12;
grid-template-columns: repeat(12, minmax(0, 1fr));
}
// Grid offset.
.grid-start-2 { grid-column-start: 2 }
.grid-start-3 { grid-column-start: 3 }
.grid-start-4 { grid-column-start: 4 }
.grid-start-5 { grid-column-start: 5 }
.grid-start-6 { grid-column-start: 6 }
.grid-start-7 { grid-column-start: 7 }
.grid-start-8 { grid-column-start: 8 }
.grid-start-9 { grid-column-start: 9 }
.grid-start-10 { grid-column-start: 10 }
.grid-start-11 { grid-column-start: 11 }
.grid-start-12 { grid-column-start: 12 }
.grid-span-2 { grid-column-end: span 2 }
.grid-span-3 { grid-column-end: span 3 }
.grid-span-4 { grid-column-end: span 4 }
.grid-span-5 { grid-column-end: span 5 }
.grid-span-6 { grid-column-end: span 6 }
.grid-span-7 { grid-column-end: span 7 }
.grid-span-8 { grid-column-end: span 8 }
.grid-span-9 { grid-column-end: span 9 }
.grid-span-10 { grid-column-end: span 10 }
.grid-span-11 { grid-column-end: span 11 }
.grid-span-12 { grid-column-end: span 12 }
-12
View File
@@ -1,12 +0,0 @@
.window-app {
font-family: $font-primary;
}
.rollable {
&:hover,
&:focus {
color: #000;
text-shadow: 0 0 10px red;
cursor: pointer;
}
}
-7
View File
@@ -1,7 +0,0 @@
$c-white: #fff;
$c-black: #000;
$c-dark: #191813;
$c-faint: #c9c7b8;
$c-beige: #b5b3a4;
$c-tan: #444;
-16
View File
@@ -1,16 +0,0 @@
@mixin element-invisible {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
border: 0;
padding: 0;
clip: rect(0 0 0 0);
overflow: hidden;
}
@mixin hide {
display: none;
}
-2
View File
@@ -1,2 +0,0 @@
$font-primary: 'Roboto', sans-serif;
$font-secondary: 'Roboto', sans-serif;
-5
View File
@@ -1,5 +0,0 @@
$padding-sm: 5px;
$padding-md: 10px;
$padding-lg: 20px;
$border-groove: 2px groove #eeede0;
+1 -1
View File
@@ -12,7 +12,7 @@
"name": "Asacolips"
}],
"esmodules": ["module/totem.mjs"],
"styles": ["css/totem.css"],
"styles": ["css/style.css", "css/totem.css"],
"scripts": [],
"packs": [],
"languages": [
+26 -10
View File
@@ -1,25 +1,41 @@
<form id="dice-pool-form" class="ecryme-dv-form" data-actor-id="{{ speakerId }}">
<div class="dice-pool flexcol">
<div class="flexrow row">
<label class="label" style="flex: 80%;">{{localize 'TOTEM.skills_title'}}</label>
<input type="number" class="numeric-entry" style="text-align: center;" name="skill" id="skill" required min="0" max="10" {{#if skillScore}}value="{{ skillScore }}"{{/if}}>
</div>
<label class="label" style="flex: 80%;">{{localize 'TOTEM.difficulty'}}</label>
<input style="text-align: center;" class="numeric-entry" type="number" name="difficulty" value="7" id="difficulty" min="3" max="10">
</div>
<div class="flexrow row">
<label class="label" style="flex: 80%;">{{localize 'TOTEM.ability'}}</label>
<input type="number" class="numeric-entry" style="text-align: center;" name="trait" id="trait" min="-5" max="5" value="0">
<input type="number" class="numeric-entry" style="text-align: center;" name="ability" id="ability" min="1" max="5" value="2">
</div>
<div class="flexrow row">
<label class="label" style="flex: 80%;">{{localize 'TOTEM.skill_title'}}</label>
<input type="number" class="numeric-entry" style="text-align: center;" name="skill" id="skill" required min="0" max="5" {{#if skillScore}}value="{{ skillScore }}"{{else}}value="0"{{/if}}>
</div>
<div class="flexrow row">
<label class="label">{{localize 'TOTEM.skill_mastery'}}</label>
<span style="flex: 80%;">{{localize 'TOTEM.bonus'}} : / {{localize 'TOTEM.reroll'}} : </span>
</div>
<div class="flexrow row">
<label class="label">{{localize 'TOTEM.specialty'}}</label>
<input type="checkbox" name="usingSpecialization" id="usingSpecialization" value="2" {{#if specialization}}checked{{/if}}>
<input type="checkbox" name="usingSpecialization" id="usingSpecialization" value="1" {{#if specialty}}checked{{/if}}>
</div>
<div class="flexrow row">
<label class="label" style="flex: 80%;">{{localize 'TOTEM.reroll'}}</label>
<input type="number" class="numeric-entry" style="text-align: center;" name="usure" id="usure" required min="0" max="{{#if skillScore}}{{ skillScore }}{{ else }}10{{/if}}" value="0">
<label class="label">{{localize 'TOTEM.help'}}</label>
<input type="checkbox" name="helped" id="helped" value="1" {{#if help}}checked{{/if}}>
</div>
<div class="flexrow row">
<label class="label" style="flex: 80%;">{{localize 'TOTEM.difficulty'}}</label>
<input style="text-align: center;" class="numeric-entry" type="number" name="difficulty" value="8" id="difficulty" min="6" max="18">
</div>
<label class="label">{{localize 'TOTEM.tooling'}}</label>
<input type="checkbox" name="usingTools" id="usingTools" value="1" {{#if help}}checked{{/if}}>
</div>
<div class="flexrow row">
<label class="label" style="flex: 80%;">{{localize 'TOTEM.self_control'}}</label>
<input type="number" class="numeric-entry" style="text-align: center;" name="self_control" id="self_control" min="0" max="5" value="0">
</div>
<div class="flexrow row">
<label class="label" style="flex: 80%;">{{localize 'TOTEM.group'}}</label>
<input type="number" class="numeric-entry" style="text-align: center;" name="group" id="group" min="0" max="5" value="0">
</div>
</div>
<p><input type="hidden" name="speakerId" value="{{ speakerId }}" />
<input type="hidden" name="skillLabel" value="{{ skill }}" /></p>