polishing skill selector in DP

This commit is contained in:
Vlyan
2022-02-11 18:51:37 +01:00
parent 165c8c81c7
commit 16dbc7939d
6 changed files with 68 additions and 37 deletions

View File

@@ -1,13 +1,39 @@
# Changelog
## 1.7.0 - DiceRoller for Techniques & Npc Generator
- NPC Sheet : Added random generator feature (demeanor, clan and families names courteously authorized by Edge).
- NPC Sheet :
- Added a random generator feature (Demeanor, Clan and Families names courteously authorized by Edge).
- PC/NPC sheet:
- Added the ability to techniques, with a skill set, to open the DicePicker with presets values.
- Some can interact with targets, but do the default difficulty if none.
- Notes : Techniques in sheet need to be re-imported from the compendium or manually updated for this to work.
- Compendiums :
- Techniques : Added difficulty and skill values (not all techniques).
Syntaxe quick explanation :
- Difficulty can be :
- Number : 1-9
- Or specific syntaxe "@`S`:`prop1`" or "@`T`:`prop1`|`max`" or "@`T`:`prop1`|`max`(`prop2`)" :
- `@` fixed, trigger the parser
- `T` or `S` : `T`arget or `S`elf, define the actor to get the value.
- `prop1` / `prop2` : Can be any property in `actor` or `actor.data.data`.
- `|` separator, optional if no min/max.
- `min` or `max` : Between the selected targets search for the min/max of `prop2`. If no `prop2` found, take `prop1` as `prop2` (irrelevant for `@S`).
- `(prop2)` : define the property for the actor selection in multiple target, can be omitted if same as `prop1`.
- Exemples :
- `@S:vigilance` : Difficulty will be my own vigilance
- `@T:vigilance|min` : Difficulty will be the vigilance from the target with the minimum vigilance (implicit) value. it's the same to wrote `@T:vigilance|min(vigilance)`.
- `@T:vigilance|max(statusRank)` : Difficulty will be the vigilance from the target with the maximum statusRank value
- Skill can be :
- Skill id : `melee`, `fitness`...
- Skill category id : `scholar`, `martial`...
- Or both in list, coma separated.
- Ids are english names in lower case, see `config.js / L5R5E.skills` for the list.
- Exemples :
- `theology`
- `melee,ranged,unarmed`
- `martial,fitness,performance`
## 1.6.0 - QoL & SoftLock
- PC/NPC/Armies sheet:
- Added SoftLock functionality.

View File

@@ -197,10 +197,15 @@ export class DicePickerDialog extends FormApplication {
}
this.object.skill.list = this.parseSkillsList(skillsList);
if (this.object.skill.list.length > 0) {
if (this.actorIsPc) {
this.skillId = this.object.skill.list[0].id;
} else {
// Set 1st skill
if (this.useCategory) {
this.skillCatId = this.object.skill.list[0].id;
} else {
this.skillId = this.object.skill.list[0].id;
}
// Remove the list if only one item
if (this.object.skill.list.length === 1) {
this.object.skill.list = null;
}
}
}
@@ -297,11 +302,11 @@ export class DicePickerDialog extends FormApplication {
}
/**
* Return true if an actor is loaded and is a Character
* Return true if an actor is loaded and is a NPC
* @return {boolean}
*/
get actorIsPc() {
return !this._actor || this._actor.data?.type === "character";
get useCategory() {
return !!this._actor && this._actor.data?.type === "npc";
}
/**
@@ -315,7 +320,7 @@ export class DicePickerDialog extends FormApplication {
ringsList: game.l5r5e.HelpersL5r5e.getRingsList(this._actor),
data: this.object,
actor: this._actor,
actorIsPc: this.actorIsPc,
useCategory: this.useCategory,
canUseVoidPoint:
this.object.difficulty.addVoidPoint || !this._actor || this._actor.data.data.void_points.value > 0,
disableSubmit: this.object.skill.value < 1 && this.object.ring.value < 1,
@@ -353,10 +358,10 @@ export class DicePickerDialog extends FormApplication {
html.find("select[name=skill]").on("change", async (event) => {
event.preventDefault();
event.stopPropagation();
if (this.actorIsPc) {
this.skillId = event.target.value;
} else {
if (this.useCategory) {
this.skillCatId = event.target.value;
} else {
this.skillId = event.target.value;
}
this.render(false);
});
@@ -751,12 +756,12 @@ export class DicePickerDialog extends FormApplication {
s = s.trim();
if (CONFIG.l5r5e.skills.has(s)) {
unqSkillList.add(this.actorIsPc ? s : CONFIG.l5r5e.skills.get(s));
unqSkillList.add(this.useCategory ? CONFIG.l5r5e.skills.get(s) : s);
} else if (categories.has(s)) {
if (this.actorIsPc) {
categories.get(s).forEach((e) => unqSkillList.add(e));
} else {
if (this.useCategory) {
unqSkillList.add(s);
} else {
categories.get(s).forEach((e) => unqSkillList.add(e));
}
}
});
@@ -765,9 +770,9 @@ export class DicePickerDialog extends FormApplication {
const array = [...unqSkillList].map((id) => {
return {
id: id,
label: this.actorIsPc
? game.i18n.localize(`l5r5e.skills.${CONFIG.l5r5e.skills.get(id)}.${id}`)
: game.i18n.localize(`l5r5e.skills.${id}.title`),
label: this.useCategory
? game.i18n.localize(`l5r5e.skills.${id}.title`)
: game.i18n.localize(`l5r5e.skills.${CONFIG.l5r5e.skills.get(id)}.${id}`),
};
});
array.sort((a, b) => a.label.localeCompare(b.label));

File diff suppressed because one or more lines are too long

View File

@@ -93,9 +93,15 @@
border: none !important;
text-shadow: none !important;
}
select {
text-align: center;
width: 134px;
direction: rtl;
appearance: none;
}
option {
font-size: 0.8rem;
}
img {

View File

@@ -21,27 +21,21 @@
<td class="skill">
{{#if data.skill.name}}
{{#if data.skill.list}}
{{#if actorIsPc}}
{{^if useCategory}}
<label>{{localizeSkill data.skill.cat 'title'}}</label>
{{/if}}
<select class="attribute-dtype" name="skill">
{{#select data.skill.id}}
{{#each data.skill.list as |item|}}
<option value="{{item.id}}">{{item.label}}</option>
{{/each}}
{{/select}}
</select>
{{else}}
<select class="attribute-dtype" name="skill">
{{#select data.skill.cat}}
{{#each data.skill.list as |item|}}
<option value="{{item.id}}">{{item.label}}</option>
{{/each}}
{{/select}}
{{/select}}
</select>
{{/if}}
{{else}}
<label>{{localizeSkill data.skill.cat 'title'}}</label>
{{#if actorIsPc}}
{{^if useCategory}}
<div>
<label>{{data.skill.name}}</label>
</div>

View File

@@ -11,7 +11,7 @@
<strong>{{localize 'l5r5e.types'}}</strong> : {{localizeTechnique data.data.technique_type}}
</li>
<li>
<strong>{{localize 'l5r5e.skills.title'}}</strong> : {{localizeSkillId data.data.skill}}
<strong>{{localize 'l5r5e.skills.title'}}</strong> : {{data.data.skill}}
</li>
<li>
<strong>{{localize 'l5r5e.dicepicker.difficulty_title'}}</strong> : {{data.data.difficulty}}