Modify Skills again

This commit is contained in:
sladecraven 2022-07-31 19:32:54 +02:00
parent b0d5f441ee
commit 4b0831c427
9 changed files with 117 additions and 62 deletions

View File

@ -86,39 +86,47 @@ export class CrucibleActor extends Actor {
/* -------------------------------------------- */
getMoneys() {
let comp = this.data.items.filter(item => item.type == 'money');
CrucibleUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
getFeats() {
let comp = duplicate(this.data.items.filter(item => item.type == 'feat') || []);
CrucibleUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
getFeatsWithDie() {
let comp = duplicate(this.data.items.filter(item => item.type == 'feat' && item.data.data.isfeatdie) || []);
CrucibleUtility.sortArrayObjectsByName(comp)
return comp;
}
getFeatsWithSL() {
let comp = duplicate(this.data.items.filter(item => item.type == 'feat' && item.data.data.issl) || []);
CrucibleUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
getLore() {
let comp = duplicate(this.data.items.filter(item => item.type == 'spell') || []);
CrucibleUtility.sortArrayObjectsByName(comp)
return comp;
}
getEquippedWeapons() {
let comp = duplicate(this.data.items.filter(item => item.type == 'weapon' && item.data.data.equipped) || []);
CrucibleUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
getArmors() {
let comp = duplicate(this.data.items.filter(item => item.type == 'armor') || []);
CrucibleUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
getShields() {
let comp = duplicate(this.data.items.filter(item => item.type == 'shield') || []);
CrucibleUtility.sortArrayObjectsByName(comp)
return comp;
}
getRace() {
@ -140,6 +148,7 @@ export class CrucibleActor extends Actor {
/* -------------------------------------------- */
getWeapons() {
let comp = duplicate(this.data.items.filter(item => item.type == 'weapon') || []);
CrucibleUtility.sortArrayObjectsByName(comp)
return comp;
}
/* -------------------------------------------- */
@ -156,8 +165,9 @@ export class CrucibleActor extends Actor {
/* -------------------------------------------- */
getSkills() {
let comp = duplicate(this.data.items.filter(item => item.type == 'skill') || []);
return comp;
let comp = duplicate(this.data.items.filter(item => item.type == 'skill') || [])
CrucibleUtility.sortArrayObjectsByName(comp)
return comp
}
/* -------------------------------------------- */
@ -389,7 +399,7 @@ export class CrucibleActor extends Actor {
user: game.user.id,
rollMode: game.settings.get("core", "rollMode"),
whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')),
content: `<div>${this.name} has gained 1 exp in the skill ${skill.name} (exp = ${skill.data.data.exp}}</div`
content: `<div>${this.name} has gained 1 exp in the skill ${skill.name} (exp = ${skill.data.data.exp})</div`
}
ChatMessage.create(chatData)
if (skill.data.data.exp >= 25) {
@ -398,7 +408,7 @@ export class CrucibleActor extends Actor {
user: game.user.id,
rollMode: game.settings.get("core", "rollMode"),
whisper: [game.user.id].concat(ChatMessage.getWhisperRecipients('GM')),
content: `<div>${this.name} has gained 1 SL in the skill ${skill.name} (new SL : ${skill.data.data.level} ) !</div`
content: `<div>${this.name} has gained 1 SL in the skill ${skill.name} (new SL : ${skill.data.data.level}) !</div`
}
ChatMessage.create(chatData)
}
@ -437,7 +447,8 @@ export class CrucibleActor extends Actor {
rollData.featsSL = this.getFeatsWithSL()
rollData.featDieName = "none"
rollData.featSLName = "none"
rollData.rollAdvantage = false
rollData.rollAdvantage = "none"
rollData.advantage = "none"
if (abilityKey) {
rollData.ability = this.getAbility(abilityKey)
@ -466,6 +477,7 @@ export class CrucibleActor extends Actor {
let rollData = this.getCommonRollData(abilityKey)
rollData.mode = "skill"
rollData.skill = skill
rollData.img = skill.img
this.startRoll(rollData)
}

View File

@ -5,7 +5,7 @@ export class CrucibleRollDialog extends Dialog {
/* -------------------------------------------- */
static async create(actor, rollData) {
let options = { classes: ["CrucibleDialog"], width: 420, height: 280, 'z-index': 99999 };
let options = { classes: ["CrucibleDialog"], width: 540, height: 340, 'z-index': 99999 };
let html = await renderTemplate('systems/fvtt-crucible-rpg/templates/roll-dialog-generic.html', rollData);
return new CrucibleRollDialog(actor, rollData, html, options);
@ -58,21 +58,11 @@ export class CrucibleRollDialog extends Dialog {
}
$(function () { onLoad(); });
html.find('#none-clicked').change((event) => {
this.rollData.advantage = "none"
this.refreshDialog()
html.find('#advantage').change((event) => {
this.rollData.advantage = event.currentTarget.value
})
html.find('#advantage-clicked').change((event) => {
this.rollData.advantage = "advantage"
this.refreshDialog()
})
html.find('#disadvantage-clicked').change((event) => {
this.rollData.advantage = "disadvantage"
this.refreshDialog()
})
html.find('#roll-with-advantage-clicked').change((event) => {
this.rollData.rollAdvantage = !this.rollData.rollAdvantage
this.refreshDialog()
html.find('#rollAdvantage').change((event) => {
this.rollData.rollAdvantage = event.currentTarget.value
})
html.find('#featDieName').change((event) => {
this.rollData.featDieName = event.currentTarget.value

View File

@ -274,12 +274,18 @@ export class CrucibleUtility {
}
diceFormula += "+" + String(level) + "d8cs>=5"
}
if(rollData.advantage == "advantage") {
if(rollData.advantage == "advantage1") {
diceFormula += "+ 1d10cs>=5"
}
if(rollData.advantage == "disadvantage") {
if(rollData.advantage == "advantage2") {
diceFormula += "+ 2d10cs>=5"
}
if(rollData.advantage == "disadvantage1") {
diceFormula += "- 1d10cs>=5"
}
if(rollData.advantage == "disadvantage2") {
diceFormula += "- 2d10cs>=5"
}
if (rollData.featDieName != "none") {
diceFormula += "+ 1d10cs>=5"
}
@ -291,12 +297,19 @@ export class CrucibleUtility {
}
rollData.roll = myRoll
rollData.nbSuccess = myRoll.total
if (rollData.rollAdvantage) {
if (rollData.rollAdvantage != "none") {
let myRoll2 = new Roll(diceFormula).roll({ async: false })
await this.showDiceSoNice(myRoll, game.settings.get("core", "rollMode"))
if ( myRoll2.total > rollData.nbSuccess) {
rollData.roll = myRoll2
rollData.nbSuccess = myRoll2.total
if (rollData.rollAdvantage == "roll-advantage") {
if ( myRoll2.total > rollData.nbSuccess) {
rollData.roll = myRoll2
rollData.nbSuccess = myRoll2.total
}
} else {
if ( myRoll2.total < rollData.nbSuccess) {
rollData.roll = myRoll2
rollData.nbSuccess = myRoll2.total
}
}
}
// Manage exp
@ -317,6 +330,21 @@ export class CrucibleUtility {
actor.lastRoll = rollData
}
/* -------------------------------------------- */
static sortArrayObjectsByName( myArray) {
myArray.sort((a, b) => {
let fa = a.name.toLowerCase();
let fb = b.name.toLowerCase();
if (fa < fb) {
return -1;
}
if (fa > fb) {
return 1;
}
return 0;
})
}
/* -------------------------------------------- */
static getUsers(filter) {
return game.users.filter(filter).map(user => user.data._id);

View File

@ -208,11 +208,11 @@
"styles": [
"styles/simple.css"
],
"templateVersion": 9,
"templateVersion": 10,
"title": "Crucible RPG",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/raw/master/system.json",
"download": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/archive/fvtt-crucible-rpg-v0.1.15.zip",
"download": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/archive/fvtt-crucible-rpg-v0.1.16.zip",
"url": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg",
"version": "0.1.15",
"version": "0.1.16",
"background" : "./images/ui/crucible_welcome_page.webp"
}

View File

@ -121,6 +121,8 @@
"armorpenalty": false,
"isproficient": false,
"isweaponskill": false,
"islore": false,
"skilltype": "",
"isinnate": false,
"bonusdice": "",
"level": 0,

View File

@ -28,12 +28,26 @@
{{/if}}
</li>
{{/if}}
{{#if (eq advantage "advantage")}}
<li>Advantage !</li>
{{#if (eq advantage "advantage1")}}
<li>1 Advantage Die !</li>
{{/if}}
{{#if (eq advantage "disadvantage")}}
<li>Disdvantage !</li>
{{#if (eq advantage "advantage2")}}
<li>2 Advantage Dice !</li>
{{/if}}
{{#if (eq advantage "disadvantage1")}}
<li>1 Disadvantage Die !</li>
{{/if}}
{{#if (eq advantage "disadvantage2")}}
<li>2 Disadvantage Dice !</li>
{{/if}}
{{#if (eq rollAdvantage "roll-advantage")}}
<li>Roll with Advantage !</li>
{{/if}}
{{#if (eq rollAdvantage "roll-disadvantage")}}
<li>Roll with Disadvantage !</li>
{{/if}}
{{#if (ne featDieName "none")}}
<li>Feature Die : d10 ({{featDieName}})</li>
{{/if}}

View File

@ -31,6 +31,15 @@
<label class="attribute-value checkbox"><input type="checkbox" name="data.isproficient" {{checked data.isproficient}}/></label>
</li>
<li class="flexrow"><label class="generic-label">Skill Type</label>
<select class="competence-base flexrow" type="text" name="data.skilltype" value="{{data.skilltype}}" data-dtype="string">
{{#select data.skilltype}}
<option value="simple">Simple</option>
<option value="complex">Complex</option>
{{/select}}
</select>
</li>
<li class="flexrow"><label class="generic-label">Skill Dice</label>
<select class="competence-base flexrow" type="text" name="data.level" value="{{data.level}}" data-dtype="Number">
{{#select data.level}}
@ -50,6 +59,10 @@
<li class="flexrow"><label class="generic-label">Is Innate ?</label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.isinnate" {{checked data.isinnate}}/></label>
</li>
<li class="flexrow"><label class="generic-label">Is Lore ?</label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.islore" {{checked data.islore}}/></label>
</li>
<li class="flexrow"><label class="generic-label">Is Weapon Skill ?</label>
<label class="attribute-value checkbox"><input type="checkbox" name="data.isweaponskill" {{checked data.isweaponskill}}/></label>

View File

@ -1,24 +1,4 @@
<ul>
<li class="flex-group-left">
<label class="ability-value checkbox">
<input type="checkbox" id="none-clicked" class="none-clicked" {{#if (eq advantage "none")}} checked {{/if}} /></label>
<label class="generic-label">None</label>
</li>
<li class="flex-group-left">
<label class="ability-value checkbox">
<input type="checkbox" id="advantage-clicked" class="advantage-clicked" {{#if (eq advantage "advantage")}} checked {{/if}} /></label>
<label class="generic-label">Advantage ?</label>
</li>
<li class="flex-group-left">
<label class="ability-value checkbox">
<input type="checkbox" id="disadvantage-clicked" class="disadvantage-clicked" {{#if (eq advantage "disadvantage")}} checked {{/if}} /></label>
<label class="generic-label">Disadvantage ?</label>
</li>
<li class="flex-group-left">
<label class="ability-value checkbox">
<input type="checkbox" id="roll-with-advantage-clicked" class="roll-with-advantage-clicked" {{#if rollAdvantage}} checked {{/if}} /></label>
<label class="generic-label">Roll With Advantage ?</label>
</li>
</ul>

View File

@ -6,8 +6,6 @@
<h1 class="dialog-roll-title roll-dialog-header">{{title}}</h1>
</header>
<div class="grid grid-2col">
<div class="flexcol">
<div class="flexrow">
@ -18,10 +16,34 @@
{{#if skill}}
<div class="flexrow">
<span class="roll-dialog-label">Skill : </span>
<span class="roll-dialog-label">{{skill.name}} - {{skill.data.value}}d8</span>
<span class="roll-dialog-label">{{skill.name}} - {{skill.data.level}}d8</span>
</div>
{{/if}}
<div class="flexrow">
<span class="roll-dialog-label">Advantage/Disadvantage : </span>
<select class="status-small-label color-class-common" type="text" id="advantage" value="{{advantage}}" data-dtype="String" >
{{#select advantage}}
<option value="none">None</option>
<option value="advantage1">1 Advantage</option>
<option value="advantage2">2 Advantages</option>
<option value="disadvantage1">1 Disadvantage</option>
<option value="disadvantage2">2 Disadvantages</option>
{{/select}}
</select>
</div>
<div class="flexrow">
<span class="roll-dialog-label">Roll with Advantage/Disadvantage : </span>
<select class="status-small-label color-class-common" type="text" id="rollAdvantage" value="{{rollAdvantage}}" data-dtype="String" >
{{#select rollAdvantage}}
<option value="none">None</option>
<option value="roll-advantage">Roll with Advantage</option>
<option value="roll-disadvantage">Roll with Disadvantage</option>
{{/select}}
</select>
</div>
<div class="flexrow">
<span class="roll-dialog-label">Feature Die : </span>
<select class="status-small-label color-class-common" type="text" id="featDieName" value="{{featDieName}}" data-dtype="String" >
@ -46,12 +68,6 @@
</select>
</div>
</div>
<div>
{{> systems/fvtt-crucible-rpg/templates/partial-roll-select.html}}
</div>
</div>
</form>