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

View File

@ -5,7 +5,7 @@ export class CrucibleRollDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
static async create(actor, rollData) { 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); let html = await renderTemplate('systems/fvtt-crucible-rpg/templates/roll-dialog-generic.html', rollData);
return new CrucibleRollDialog(actor, rollData, html, options); return new CrucibleRollDialog(actor, rollData, html, options);
@ -58,21 +58,11 @@ export class CrucibleRollDialog extends Dialog {
} }
$(function () { onLoad(); }); $(function () { onLoad(); });
html.find('#none-clicked').change((event) => { html.find('#advantage').change((event) => {
this.rollData.advantage = "none" this.rollData.advantage = event.currentTarget.value
this.refreshDialog()
}) })
html.find('#advantage-clicked').change((event) => { html.find('#rollAdvantage').change((event) => {
this.rollData.advantage = "advantage" this.rollData.rollAdvantage = event.currentTarget.value
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('#featDieName').change((event) => { html.find('#featDieName').change((event) => {
this.rollData.featDieName = event.currentTarget.value this.rollData.featDieName = event.currentTarget.value

View File

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

View File

@ -208,11 +208,11 @@
"styles": [ "styles": [
"styles/simple.css" "styles/simple.css"
], ],
"templateVersion": 9, "templateVersion": 10,
"title": "Crucible RPG", "title": "Crucible RPG",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-crucible-rpg/raw/master/system.json", "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", "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" "background" : "./images/ui/crucible_welcome_page.webp"
} }

View File

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

View File

@ -28,12 +28,26 @@
{{/if}} {{/if}}
</li> </li>
{{/if}} {{/if}}
{{#if (eq advantage "advantage")}}
<li>Advantage !</li> {{#if (eq advantage "advantage1")}}
<li>1 Advantage Die !</li>
{{/if}} {{/if}}
{{#if (eq advantage "disadvantage")}} {{#if (eq advantage "advantage2")}}
<li>Disdvantage !</li> <li>2 Advantage Dice !</li>
{{/if}} {{/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")}} {{#if (ne featDieName "none")}}
<li>Feature Die : d10 ({{featDieName}})</li> <li>Feature Die : d10 ({{featDieName}})</li>
{{/if}} {{/if}}

View File

@ -31,6 +31,15 @@
<label class="attribute-value checkbox"><input type="checkbox" name="data.isproficient" {{checked data.isproficient}}/></label> <label class="attribute-value checkbox"><input type="checkbox" name="data.isproficient" {{checked data.isproficient}}/></label>
</li> </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> <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 class="competence-base flexrow" type="text" name="data.level" value="{{data.level}}" data-dtype="Number">
{{#select data.level}} {{#select data.level}}
@ -50,6 +59,10 @@
<li class="flexrow"><label class="generic-label">Is Innate ?</label> <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> <label class="attribute-value checkbox"><input type="checkbox" name="data.isinnate" {{checked data.isinnate}}/></label>
</li> </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> <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> <label class="attribute-value checkbox"><input type="checkbox" name="data.isweaponskill" {{checked data.isweaponskill}}/></label>

View File

@ -1,24 +1,4 @@
<ul> <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> </ul>

View File

@ -6,8 +6,6 @@
<h1 class="dialog-roll-title roll-dialog-header">{{title}}</h1> <h1 class="dialog-roll-title roll-dialog-header">{{title}}</h1>
</header> </header>
<div class="grid grid-2col">
<div class="flexcol"> <div class="flexcol">
<div class="flexrow"> <div class="flexrow">
@ -18,10 +16,34 @@
{{#if skill}} {{#if skill}}
<div class="flexrow"> <div class="flexrow">
<span class="roll-dialog-label">Skill : </span> <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> </div>
{{/if}} {{/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"> <div class="flexrow">
<span class="roll-dialog-label">Feature Die : </span> <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" > <select class="status-small-label color-class-common" type="text" id="featDieName" value="{{featDieName}}" data-dtype="String" >
@ -46,12 +68,6 @@
</select> </select>
</div> </div>
</div>
<div>
{{> systems/fvtt-crucible-rpg/templates/partial-roll-select.html}}
</div>
</div> </div>
</form> </form>