Various fixes
This commit is contained in:
@@ -18,6 +18,57 @@ export class VadentisUtility extends Entity {
|
||||
return loadTemplates(templatePaths);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static createOptionList( min, max) {
|
||||
let options = ""
|
||||
for(let i=min; i<=max; i++) {
|
||||
options+= `<option value="${i}">${i}</option>\n`;
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static createDirectOptionList( min, max) {
|
||||
let options = []
|
||||
for(let i=min; i<=max; i++) {
|
||||
options.push( i ) ;
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getTarget() {
|
||||
if (game.user.targets && game.user.targets.size == 1) {
|
||||
for (let target of game.user.targets) {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async performAttack( combatData) {
|
||||
let attacker = game.actors.get(combatData.attackerActorId);
|
||||
let defender = game.actors.get(combatData.targetActorId);
|
||||
if( attacker && defender) {
|
||||
let defense = defender.getDefenseScore();
|
||||
let attaque = attacker.getAttaqueScore();
|
||||
console.log("Attaque : ", attaque);
|
||||
let myRoll = new Roll("1d20"+attaque);
|
||||
myRoll.evaluate()
|
||||
if (game.modules.get("dice-so-nice") && game.modules.get("dice-so-nice").active) {
|
||||
await game.dice3d.showForRoll(myRoll, game.user, true);
|
||||
}
|
||||
if (myRoll.total >= defense) { // Success !
|
||||
ChatMessage.create( { content: `${attacker.name} a réussi son attaque sur ${defender.name} (${myRoll.total} / ${defense}) !<br> Les dégâts sont de : ${combatData.arme.data.damage}`});
|
||||
} else { //Echec
|
||||
ChatMessage.create( { content: `${attacker.name} a raté son attaque sur ${defender.name} (${myRoll.total} / ${defense}) !` });
|
||||
}
|
||||
} else {
|
||||
ui.notifications.warn("Impossible de trouver l'attaquant et le défenseur.")
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static registerChatCallbacks( ) {
|
||||
|
||||
@@ -32,7 +83,8 @@ export class VadentisUtility extends Entity {
|
||||
static onSocketMesssage( msg ) {
|
||||
if( !game.user.isGM ) return; // Only GM
|
||||
|
||||
if (msg.name == 'msg_declare_actions' ) {
|
||||
if (msg.name == 'msg_attack' ) {
|
||||
this.performAttack( msg.data );
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user