Merge branch '0.6.0-release' of https://github.com/Futil/foundry-mothership into 0.6.0-release

This commit is contained in:
Chris Schmalz
2025-08-31 11:26:39 -07:00
5 changed files with 59 additions and 7 deletions
+5 -1
View File
@@ -1136,6 +1136,10 @@
"Hull": "Hull",
"Modules": "Modules",
"DeckPlan": "Deck Plan",
"Stock": "Stock"
"Stock": "Stock",
"Errors":{
"SkillAlreadyInList":"This skill is already in the list.",
"NoDropTarget":"Something went wrong with the drop, please try again."
}
}
}
+5 -1
View File
@@ -1136,6 +1136,10 @@
"Hull": "Casco",
"Modules": "módulos",
"DeckPlan": "Planta do Convés",
"Stock": "Stock"
"Stock": "Stock",
"Errors":{
"SkillAlreadyInList":"Essa habilidade já está na lista.",
"NoDropTarget":"Algo deu errado com o drop, tente novamente"
}
}
}
+3 -3
View File
@@ -919,7 +919,7 @@ export class MothershipActor extends Actor {
}, {
keepId: true
});
if (game.modules.get("dice-so-nice").active) {
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
//log what was done
console.log(`Rolled on table ID: ${tableId}, with: rollString:${rollString}, aimFor:${aimFor}, zeroBased:${zeroBased}, checkCrit:${checkCrit}, rollAgainst:${rollAgainst}, comparison:${comparison}`);
//return messageData
@@ -1899,7 +1899,7 @@ export class MothershipActor extends Actor {
keepId: true
});
//is DSN active?
if (game.modules.get("dice-so-nice").active) {
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
//log what was done
console.log(`Rolled a check on: ${attribute}, with: rollString:${rollString}, aimFor:${aimFor}, skill:${skill}, skillValue:${skillValue}.`);
//return messageData
@@ -2239,7 +2239,7 @@ export class MothershipActor extends Actor {
}, {
keepId: true
});
if (game.modules.get("dice-so-nice").active) {
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
//log what was done
console.log(`Modified actor: ${this.name}, with: fieldAddress:${fieldAddress}, modValue:${modValue}, modRollString:${modRollString}, outputChatMsg:${outputChatMsg}`);
//return modification values
+20 -2
View File
@@ -72,7 +72,10 @@ export class MothershipClassSheet extends MothershipItemSheet {
const droppedObject = await fromUuid(droppedUuid.uuid);
if (droppedObject.type == "skill"){
//todo: add a check if the skill already exist in the list and dont add it, (by id or by name?)
if(event.currentTarget == null) {
ui.notifications.error(game.i18n.localize("Mosh.Errors.NoDropTarget"));
return this.render(false);
}
console.log(event.currentTarget.id);
if(event.currentTarget.id == "skills.fixed"){
let parent_fixed_or = event.target.closest('div[id="skills.fixed.or"]');
@@ -80,12 +83,20 @@ export class MothershipClassSheet extends MothershipItemSheet {
if(parent_fixed_or){
let array_index = parent_fixed_or.getAttribute("index");
let skills = this.object.system.base_adjustment.skills_granted;
if(skills[array_index].includes(droppedObject.uuid)){
ui.notifications.warn(game.i18n.localize("Mosh.Errors.SkillAlreadyInList"));
return this.render(false);
}
skills[array_index].push(droppedObject.uuid);
this.object.update({"system.base_adjustment.skills_granted":skills});
return this.render(false);
}else{
let skills = this.object.system.base_adjustment.skills_granted;
if (skills.includes(droppedObject.uuid)){
ui.notifications.warn(game.i18n.localize("Mosh.Errors.SkillAlreadyInList"));
return this.render(false);
}
skills.push(droppedObject.uuid);
this.object.update({"system.base_adjustment.skills_granted":skills});
return this.render(false);
@@ -93,6 +104,10 @@ export class MothershipClassSheet extends MothershipItemSheet {
}
else if(event.currentTarget.id =="skills.common"){
let skills = this.object.system.common_skills;
if (skills.includes(droppedObject.uuid)){
ui.notifications.warn(game.i18n.localize("Mosh.Errors.SkillAlreadyInList"));
return this.render(false);
}
skills.push(droppedObject.uuid);
this.object.update({"system.common_skills":skills});
return this.render(false);
@@ -104,7 +119,10 @@ export class MothershipClassSheet extends MothershipItemSheet {
let parent_index = parent.data("itemId");
let options = this.object.system.selected_adjustment.choose_skill_or;
if(options[parent_index][index].from_list.includes(droppedObject.uuid)){
ui.notifications.warn(game.i18n.localize("Mosh.Errors.SkillAlreadyInList"));
return this.render(false);
}
options[parent_index][index].from_list.push(droppedObject.uuid);
this.object.update({"system.selected_adjustment.choose_skill_or":options});
+26
View File
@@ -654,4 +654,30 @@ export async function fromIdUuid(id_uuid, options={}){
return game.macros.filter(i=> i.id == macroId)[0];
}
}
/**
* This function will format a number into a more readable string with appropriate suffixes.
* For example, 1500 becomes "1.5K", 2000000 becomes "2M", etc.
* It handles numbers in the trillions (t), billions (b), millions (m), and thousands (k).
* It also handles negative numbers and zero.
* At the end it appends 'cr' to denote credits.
* @namespace formatCreditsNumber
* @param {int} num Credits number to format.
* @returns {string} Credits , formatted string with appropriate suffix.
*/
export function formatCreditsNumber(num) {
const absNum = Math.abs(num);
if (absNum >= 1_000_000_000_000) {
return (num / 1_000_000_000_000).toFixed(1).replace(/\.0$/, '') + 'tcr';
} else if (absNum >= 1_000_000_000) {
return (num / 1_000_000_000).toFixed(1).replace(/\.0$/, '') + 'bcr';
} else if (absNum >= 1_000_000) {
return (num / 1_000_000).toFixed(1).replace(/\.0$/, '') + 'mcr';
} else if (absNum >= 1_000) {
return (num / 1_000).toFixed(1).replace(/\.0$/, '') + 'kcr';
} else {
return num.toString() + 'cr';
}
}