Fix criticals roll

This commit is contained in:
LeRatierBretonnien 2025-02-09 18:11:17 +01:00
parent 8168cbfdd9
commit 7bc7570eb4
17 changed files with 99 additions and 74 deletions

View File

@ -147,3 +147,11 @@ rmfrp.armor_values = {
"19": "19",
"20": "20"
}
rmfrp.keyToCriticalTable ={
K: "krush",
P: "puncture",
S: "slash",
U: "unbalance",
G: "grapple"
}

View File

@ -183,19 +183,24 @@ export class RMFRPProcessTable {
}
let roll = new Roll("1d100")
await roll.evaluate()
await RMFRPUtility.showDiceSoNice(roll, game.settings.get("core", "rollMode"))
let score = roll.total
console.log("Critical Roll: ", score)
// Search the result
for (let criticalDef of table.criticals) {
if (Number(criticalDef.score) ) {
if (Number(criticalDef.score) == score) {
return criticalDef.levels[criticalKey.toUpperCase()]
let critDef = foundry.utils.duplicate(criticalDef.levels[criticalKey.toUpperCase()])
critDef.diceResult = score
return critDef
}
} else {
// Score is XX-YY so split it to get the range values
let range = criticalDef.score.split("-")
if (Number(range[0]) <= score && score <= Number(range[1])) {
return criticalDef.levels[criticalKey.toUpperCase()]
let critDef = foundry.utils.duplicate(criticalDef.levels[criticalKey.toUpperCase()])
critDef.diceResult = score
return critDef
}
}
}

View File

@ -6,9 +6,9 @@ export class RMFRPUtility {
static async init() {
}
static capitalizeFirstLetters(str){
static capitalizeFirstLetters(str) {
return str.toLowerCase().replace(/^\w|\s\w/g, function (letter) {
return letter.toUpperCase();
return letter.toUpperCase();
})
}
@ -19,7 +19,7 @@ export class RMFRPUtility {
this.gameSystem = game.settings.get("fvtt-rolemaster-frp", "game_system");
const skillCategories = await RMFRPUtility.loadCompendium("fvtt-rolemaster-frp.skill_categories")
this.skillCategories = skillCategories.map(i => i.toObject()).filter( i => i.system.game_system == "common" || i.system.game_system == this.gameSystem);
this.skillCategories = skillCategories.map(i => i.toObject()).filter(i => i.system.game_system == "common" || i.system.game_system == this.gameSystem);
// Sort skill categories by name
this.skillCategories.sort((a, b) => a.name.localeCompare(b.name));
}
@ -27,7 +27,7 @@ export class RMFRPUtility {
static getGameSystem() {
return this.gameSystem;
}
/* -------------------------------------------- */
static getSkillCategories() {
return this.skillCategories
@ -47,9 +47,35 @@ export class RMFRPUtility {
rmfrp: "Rolemaster Fantasy Role Playing (RMFRP)",
merp: "Middle Earth Role Playing (MERP)"
}
});
});
}
/* -------------------------------------------- */
static async showDiceSoNice(roll, rollMode) {
if (game.modules.get("dice-so-nice")?.active) {
if (game.dice3d) {
let whisper = null;
let blind = false;
rollMode = rollMode ?? game.settings.get("core", "rollMode");
switch (rollMode) {
case "blindroll": //GM only
blind = true;
case "gmroll": //GM + rolling player
whisper = this.getUsers(user => user.isGM);
break;
case "roll": //everybody
whisper = this.getUsers(user => user.active);
break;
case "selfroll":
whisper = [game.user.id];
break;
}
await game.dice3d.showForRoll(roll, game.user, true, whisper, blind);
}
}
}
/* -------------------------------------------- */
static async loadCompendiumData(compendium) {
const pack = game.packs.get(compendium);

View File

@ -1,3 +1,4 @@
import { RMFRPUtility } from "../../rmfrp-utility.js";
export default class RMFRPToolsDiceRoller extends FormApplication {
@ -72,34 +73,14 @@ export default class RMFRPToolsDiceRoller extends FormApplication {
}
/* -------------------------------------------- */
async showDiceSoNice(roll, rollMode) {
if (game.modules.get("dice-so-nice")?.active) {
if (game.dice3d) {
let whisper = null;
let blind = false;
rollMode = rollMode ?? game.settings.get("core", "rollMode");
switch (rollMode) {
case "blindroll": //GM only
blind = true;
case "gmroll": //GM + rolling player
whisper = this.getUsers(user => user.isGM);
break;
case "roll": //everybody
whisper = this.getUsers(user => user.active);
break;
case "selfroll":
whisper = [game.user.id];
break;
}
await game.dice3d.showForRoll(roll, game.user, true, whisper, blind);
}
}
getWeaponCriticalTableName( key) {
return CONFIG.rmfrp.keyToCriticalTable[key.toUpperCase()]
}
/* -------------------------------------------- */
async roll(rollKey, formData) {
let baseRoll = await new Roll("1d100").roll();
await this.showDiceSoNice(baseRoll, game.settings.get("core", "rollMode"))
await RMFRPUtility.showDiceSoNice(baseRoll, game.settings.get("core", "rollMode"))
let rollType = this.rollType.find(r => r.value == rollKey)?.text;
let rollData = {
name: this.itemName,
@ -126,11 +107,11 @@ export default class RMFRPToolsDiceRoller extends FormApplication {
if (baseRoll.result < 6) {
rollData.lowopen = true
let newRoll = await new Roll("-1d100").roll();
await this.showDiceSoNice(newRoll, game.settings.get("core", "rollMode"))
await RMFRPUtility.showDiceSoNice(newRoll, game.settings.get("core", "rollMode"))
rollData.rolls.push(newRoll);
while (newRoll.result > 95) {
newRoll = await new Roll("-1d100").roll();
await this.showDiceSoNice(newRoll, game.settings.get("core", "rollMode"))
await RMFRPUtility.showDiceSoNice(newRoll, game.settings.get("core", "rollMode"))
rollData.rolls.push(newRoll);
}
}
@ -140,11 +121,11 @@ export default class RMFRPToolsDiceRoller extends FormApplication {
if (baseRoll.result > 95) {
rollData.highopen = true
let newRoll = await new Roll("1d100").roll();
await this.showDiceSoNice(newRoll, game.settings.get("core", "rollMode"))
await RMFRPUtility.showDiceSoNice(newRoll, game.settings.get("core", "rollMode"))
rollData.rolls.push(newRoll);
while (newRoll.result > 95) {
newRoll = await new Roll("1d100").roll();
await this.showDiceSoNice(newRoll, game.settings.get("core", "rollMode"))
await RMFRPUtility.showDiceSoNice(newRoll, game.settings.get("core", "rollMode"))
rollData.rolls.push(newRoll);
}
}
@ -181,17 +162,19 @@ export default class RMFRPToolsDiceRoller extends FormApplication {
rollData.attackResult = attackResult;
// Is it a a critical ?
let critical = attackResult.match(/(\d+)(\w)?(\w)?/);
if (critical && critical[2]) {
if (critical && critical[2] && critical[3]) {
if ( critical[2] === "F") {
hasFumble = true
} else {
let criticalTable = this.weapon.system.critical_table
let criticalTable = this.getWeaponCriticalTableName(critical[3])
//let criticalTable = this.weapon.system.critical_table
if ( !criticalTable ) {
ui.notifications.error("Critical table not found for weapon: " + this.weapon.name);
return
}
let criticalResult = await game.rmfrp.attackTables.getCriticalResult(criticalTable, critical[2]);
rollData.criticalResult = criticalResult;
rollData.criticalTable = criticalTable;
console.log("Critical Result: ", criticalResult);
}
}

View File

@ -1 +1 @@
MANIFEST-000208
MANIFEST-000212

View File

@ -1,8 +1,8 @@
2025/01/18-18:15:46.177424 7f3b919fa6c0 Recovering log #206
2025/01/18-18:15:46.187462 7f3b919fa6c0 Delete type=3 #204
2025/01/18-18:15:46.187523 7f3b919fa6c0 Delete type=0 #206
2025/01/18-18:19:43.034876 7f3b8b3ff6c0 Level-0 table #211: started
2025/01/18-18:19:43.034902 7f3b8b3ff6c0 Level-0 table #211: 0 bytes OK
2025/01/18-18:19:43.041054 7f3b8b3ff6c0 Delete type=0 #209
2025/01/18-18:19:43.041200 7f3b8b3ff6c0 Manual compaction at level-0 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end)
2025/01/18-18:19:43.041231 7f3b8b3ff6c0 Manual compaction at level-1 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end)
2025/02/09-17:59:02.058056 7f46ad7fa6c0 Recovering log #210
2025/02/09-17:59:02.108672 7f46ad7fa6c0 Delete type=3 #208
2025/02/09-17:59:02.108745 7f46ad7fa6c0 Delete type=0 #210
2025/02/09-18:10:51.141649 7f46abbff6c0 Level-0 table #215: started
2025/02/09-18:10:51.141686 7f46abbff6c0 Level-0 table #215: 0 bytes OK
2025/02/09-18:10:51.147603 7f46abbff6c0 Delete type=0 #213
2025/02/09-18:10:51.166026 7f46abbff6c0 Manual compaction at level-0 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end)
2025/02/09-18:10:51.166064 7f46abbff6c0 Manual compaction at level-1 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end)

View File

@ -1,8 +1,8 @@
2025/01/18-15:51:04.184298 7f3b911f96c0 Recovering log #202
2025/01/18-15:51:04.200991 7f3b911f96c0 Delete type=3 #200
2025/01/18-15:51:04.201070 7f3b911f96c0 Delete type=0 #202
2025/01/18-18:14:32.987104 7f3b8b3ff6c0 Level-0 table #207: started
2025/01/18-18:14:32.987144 7f3b8b3ff6c0 Level-0 table #207: 0 bytes OK
2025/01/18-18:14:32.993171 7f3b8b3ff6c0 Delete type=0 #205
2025/01/18-18:14:33.006820 7f3b8b3ff6c0 Manual compaction at level-0 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end)
2025/01/18-18:14:33.006858 7f3b8b3ff6c0 Manual compaction at level-1 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end)
2025/01/18-18:15:46.177424 7f3b919fa6c0 Recovering log #206
2025/01/18-18:15:46.187462 7f3b919fa6c0 Delete type=3 #204
2025/01/18-18:15:46.187523 7f3b919fa6c0 Delete type=0 #206
2025/01/18-18:19:43.034876 7f3b8b3ff6c0 Level-0 table #211: started
2025/01/18-18:19:43.034902 7f3b8b3ff6c0 Level-0 table #211: 0 bytes OK
2025/01/18-18:19:43.041054 7f3b8b3ff6c0 Delete type=0 #209
2025/01/18-18:19:43.041200 7f3b8b3ff6c0 Manual compaction at level-0 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end)
2025/01/18-18:19:43.041231 7f3b8b3ff6c0 Manual compaction at level-1 from '!items!1HevhbCbvMonyQXe' @ 72057594037927935 : 1 .. '!items!yRIFroc5VC9Oj3qY' @ 0 : 0; will stop at (end)

View File

@ -1 +1 @@
MANIFEST-000114
MANIFEST-000118

View File

@ -1,8 +1,8 @@
2025/01/18-18:15:46.190110 7f3b909f86c0 Recovering log #112
2025/01/18-18:15:46.200873 7f3b909f86c0 Delete type=3 #110
2025/01/18-18:15:46.200953 7f3b909f86c0 Delete type=0 #112
2025/01/18-18:19:43.027077 7f3b8b3ff6c0 Level-0 table #117: started
2025/01/18-18:19:43.027109 7f3b8b3ff6c0 Level-0 table #117: 0 bytes OK
2025/01/18-18:19:43.034763 7f3b8b3ff6c0 Delete type=0 #115
2025/01/18-18:19:43.041192 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end)
2025/01/18-18:19:43.041225 7f3b8b3ff6c0 Manual compaction at level-1 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end)
2025/02/09-17:59:02.113663 7f46ac7f86c0 Recovering log #116
2025/02/09-17:59:02.167668 7f46ac7f86c0 Delete type=3 #114
2025/02/09-17:59:02.167740 7f46ac7f86c0 Delete type=0 #116
2025/02/09-18:10:51.159538 7f46abbff6c0 Level-0 table #121: started
2025/02/09-18:10:51.159574 7f46abbff6c0 Level-0 table #121: 0 bytes OK
2025/02/09-18:10:51.165836 7f46abbff6c0 Delete type=0 #119
2025/02/09-18:10:51.166053 7f46abbff6c0 Manual compaction at level-0 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end)
2025/02/09-18:10:51.178042 7f46abbff6c0 Manual compaction at level-1 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end)

View File

@ -1,8 +1,8 @@
2025/01/18-15:51:04.203957 7f3b919fa6c0 Recovering log #108
2025/01/18-15:51:04.219103 7f3b919fa6c0 Delete type=3 #106
2025/01/18-15:51:04.219174 7f3b919fa6c0 Delete type=0 #108
2025/01/18-18:14:33.000727 7f3b8b3ff6c0 Level-0 table #113: started
2025/01/18-18:14:33.000756 7f3b8b3ff6c0 Level-0 table #113: 0 bytes OK
2025/01/18-18:14:33.006724 7f3b8b3ff6c0 Delete type=0 #111
2025/01/18-18:14:33.006839 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end)
2025/01/18-18:14:33.006865 7f3b8b3ff6c0 Manual compaction at level-1 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end)
2025/01/18-18:15:46.190110 7f3b909f86c0 Recovering log #112
2025/01/18-18:15:46.200873 7f3b909f86c0 Delete type=3 #110
2025/01/18-18:15:46.200953 7f3b909f86c0 Delete type=0 #112
2025/01/18-18:19:43.027077 7f3b8b3ff6c0 Level-0 table #117: started
2025/01/18-18:19:43.027109 7f3b8b3ff6c0 Level-0 table #117: 0 bytes OK
2025/01/18-18:19:43.034763 7f3b8b3ff6c0 Delete type=0 #115
2025/01/18-18:19:43.041192 7f3b8b3ff6c0 Manual compaction at level-0 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end)
2025/01/18-18:19:43.041225 7f3b8b3ff6c0 Manual compaction at level-1 from '!folders!Lr9SCthdWWHecwEI' @ 72057594037927935 : 1 .. '!items!zvdsAxlRZnL6gqms' @ 0 : 0; will stop at (end)

View File

@ -3,7 +3,7 @@
"title": "Rolemaster FRP System",
"description": "The Rolemaster FRP system for FoundryVTT.",
"manifest": "https://www.uberwald.me/gitea/public/fvtt-rolemaster-frp/raw/branch/develop/system.json",
"download": "https://www.uberwald.me/gitea/public/fvtt-rolemaster-frp/archive/v12.0.18.zip",
"download": "https://www.uberwald.me/gitea/public/fvtt-rolemaster-frp/archive/v12.0.19.zip",
"authors": [
{
"name": "Cynicide",
@ -14,7 +14,7 @@
"email": ""
}
],
"version": "12.0.18",
"version": "12.0.19",
"compatibility": {
"minimum": "12",
"verified": "12"

View File

@ -89,6 +89,9 @@
{{/if}}
{{#if criticalResult}}
<div class="dice-result">
Critical: {{upperFirst criticalTable}} ({{criticalResult.diceResult}})
</div>
<div class="dice-result">
Critical {{criticalResult.key}}: {{criticalResult.description}}
</div>

View File

@ -101,7 +101,7 @@
</td>
</table>
<table>
<!-- <table>
<tr>
<th>{{localize "rmfrp.weapon.critical_table"}}</th>
<th>{{localize "rmfrp.weapon.lsl_crit_column"}}</th>
@ -114,7 +114,7 @@
<td>
<input class="short-input" name="system.lsl_crit_column" type="text" value="{{system.lsl_crit_column}}" data-dtype="Number"/>
</td>
</table>
</table> -->
<table class="short-input">
<th class="short-input">{{localize "rmfrp.weapon.range_modifier"}}</th>