Skip to content

Commit

Permalink
Active Effect now can divide, verify Sta, spell Crit/fumble
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyMonette committed Oct 7, 2021
1 parent 656e7f7 commit dfd5e16
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 77 deletions.
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
This Sheet represent a Player character with all of it's stats

### Skill Tab ###
This tabs allows you to roll skills and keep track of your improvement Points
This tabs allows you to roll skills and keep track of your improvement Points.
There is a color code for the skill to easily discernate the trained skills (Red) and those who are not(Brown).


### Race and Profession Tab ###
This tab is used to handle the race and profession.
It allows you to roll the professions skills.
It allows you to roll the professions skills by clicking on the dice of a profession skill.
You can create Items of type Race and/or profession To drag and drop in the caracter sheet.


### Inventory Tab ###
This tab is used to organize different sort of items that the character is carrying.
You can see the total carrying weight
Weapons
Armor
Valuables
Substances and Components
Diagrams
At the top left there is a section for the currency. In the weapon section you have the weapons.
By clicking on the name of a weapon it launches an attack with this specific weapons and will use the specified skill to make the attack.
After you have the armor section, which will help you to easily keep track you your stopping power and resistances. B, S, P, stand for resistance to Blundgeoning damage, Slashing damage and perforring damage. When an armor is equipped, if it contains an encumbrance value it will automaticly subtract it to your REf and DEX.
At the bottom of the sheet you can see the total carrying weight

### Magic Tab ###
This tab is used to organize your Spell, invocations, witcher signs, rituals and hexes.
Expand Down
92 changes: 73 additions & 19 deletions module/sheets/WitcherActorSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ export default class WitcherActorSheet extends ActorSheet {
if (previousActor) {
previousActor.deleteOwnedItem(dragData.item._id)
}
this.actor.createEmbeddedDocuments("Item", [dragData.item]);
if (dragData.item.data.quantity != 0) {
this.actor.createEmbeddedDocuments("Item", [dragData.item]);
}
} else {
super._onDrop(event, data);
}
Expand Down Expand Up @@ -866,23 +868,41 @@ export default class WitcherActorSheet extends ActorSheet {
break;
}
let staCostTotal = spellItem.data.data.stamina;
let customModifier = 0;
let isExtraAttack = false
let content = `<label>${game.i18n.localize("WITCHER.Dialog.attackExtra")}: <input type="checkbox" name="isExtraAttack"></label> <br />`
if (spellItem.data.data.staminaIsVar){
const content = `${game.i18n.localize("WITCHER.Spell.staminaDialog")}<input class="small" name="staCost" value=1>`;
let cancel = true
let dialogData = {
buttons : [[`${game.i18n.localize("WITCHER.Button.Cancel")}`, ()=>{}],
[`${game.i18n.localize("WITCHER.Button.Continue")}`, (html)=>{
let sta = html.find("[name=staCost]")[0].value;
staCostTotal = sta
cancel = false
} ]],
title : game.i18n.localize("WITCHER.Spell.MagicCost"),
content : content
}
await buttonDialog(dialogData)
if (cancel) {
return
content = `${game.i18n.localize("WITCHER.Spell.staminaDialog")}<input class="small" name="staCost" value=1> <br />`
}
content += `<label>${game.i18n.localize("WITCHER.Dialog.attackCustom")}: <input class="small" name="customMod" value=0></label> <br />`;
let cancel = true
let dialogData = {
buttons : [
[`${game.i18n.localize("WITCHER.Button.Continue")}`, (html)=>{

if (spellItem.data.data.staminaIsVar){
staCostTotal = html.find("[name=staCost]")[0].value;
}
customModifier = html.find("[name=customMod]")[0].value;
isExtraAttack = html.find("[name=isExtraAttack]").prop("checked");
cancel = false
} ]],
title : game.i18n.localize("WITCHER.Spell.MagicCost"),
content : content
}
await buttonDialog(dialogData)
if (cancel) {
return
}
let newSta = this.actor.data.data.derivedStats.sta.value
if (isExtraAttack) {
newSta -= 3
if (newSta < 0) {
return ui.notifications.error(game.i18n.localize("WITCHER.Spell.notEnoughSta"));
}
this.actor.update({
'data.derivedStats.sta.value': newSta
});
}
let staCostdisplay = staCostTotal;
let staFocus = 0
Expand All @@ -895,7 +915,7 @@ export default class WitcherActorSheet extends ActorSheet {
staCostTotal = 0
}

let newSta = this.actor.data.data.derivedStats.sta.value - staCostTotal
newSta -= staCostTotal
if (newSta < 0) {
return ui.notifications.error(game.i18n.localize("WITCHER.Spell.notEnoughSta"));
}
Expand All @@ -904,7 +924,9 @@ export default class WitcherActorSheet extends ActorSheet {
'data.derivedStats.sta.value': newSta
});
staCostdisplay += `-${staFocus}[Focus]`


if (customModifier < 0){formula += `${customModifier}`}
if (customModifier > 0){formula += `+${customModifier}`}
let rollResult = new Roll(formula).roll()
let messageData = {flavor:`<h2>${spellItem.name}</h2>
<div><b>${game.i18n.localize("WITCHER.Spell.StaCost")}: </b>${staCostdisplay}</div>
Expand Down Expand Up @@ -933,6 +955,14 @@ export default class WitcherActorSheet extends ActorSheet {
if (spellItem.data.data.liftRequirement) {
messageData.flavor += `<div><b>${game.i18n.localize("WITCHER.Spell.Requirements")}: </b>${spellItem.data.data.liftRequirement}</div>`
}

if (rollResult.dice[0].results[0].result == 10){
messageData.flavor += `<div class="dice-sucess">${game.i18n.localize("WITCHER.Crit")}</div>`
}
else if(rollResult.dice[0].results[0].result == 1) {
messageData.flavor += `<div class="dice-fail">${game.i18n.localize("WITCHER.Fumble")}</div>`
}

rollResult.toMessage(messageData)

let token = this.actor.token;
Expand Down Expand Up @@ -1061,7 +1091,8 @@ export default class WitcherActorSheet extends ActorSheet {
<div class="flex">
<label>${game.i18n.localize("WITCHER.Dialog.DefenseExtra")}: <input type="checkbox" name="isExtraDefense"></label> <br />
</div>
<label>${game.i18n.localize("WITCHER.Dialog.DefenseWith")}: </label><select name="form">${options}</select>`;
<label>${game.i18n.localize("WITCHER.Dialog.DefenseWith")}: </label><select name="form">${options}</select>
<label>${game.i18n.localize("WITCHER.Dialog.attackCustom")}: <input class="small" name="customDef" value=0></label> <br />`;

let messageData = {
speaker: {alias: this.actor.name},
Expand All @@ -1076,8 +1107,12 @@ export default class WitcherActorSheet extends ActorSheet {
label: `${game.i18n.localize("WITCHER.Dialog.ButtonDodge")}`,
callback: (html) => {
let isExtraDefense = html.find("[name=isExtraDefense]").prop("checked");
let customDef = html.find("[name=customDef]")[0].value;
if (isExtraDefense) {
let newSta = this.actor.data.data.derivedStats.sta.value - 1
if (newSta < 0) {
return ui.notifications.error(game.i18n.localize("WITCHER.Spell.notEnoughSta"));
}
this.actor.update({
'data.derivedStats.sta.value': newSta
});
Expand All @@ -1087,6 +1122,9 @@ export default class WitcherActorSheet extends ActorSheet {
let displayFormula = `1d10 + Ref + ${game.i18n.localize("WITCHER.SkRefDodge")}`;
messageData.flavor = `<h1>${game.i18n.localize("WITCHER.Dialog.Defense")}: ${game.i18n.localize("WITCHER.Dialog.ButtonDodge")}</h1><p>${displayFormula}</p>`;
let rollFormula = `1d10+${stat}+${skill}`;
if (customDef != "0") {
rollFormula += "+"+customDef;
}
let roll = new Roll(rollFormula).roll()
if (roll.dice[0].results[0].result == 10){
messageData.flavor += `<div class="dice-sucess">${game.i18n.localize("WITCHER.Crit")}</div> `;
Expand All @@ -1103,6 +1141,9 @@ export default class WitcherActorSheet extends ActorSheet {
let isExtraDefense = html.find("[name=isExtraDefense]").prop("checked");
if (isExtraDefense) {
let newSta = this.actor.data.data.derivedStats.sta.value - 1
if (newSta < 0) {
return ui.notifications.error(game.i18n.localize("WITCHER.Spell.notEnoughSta"));
}
this.actor.update({
'data.derivedStats.sta.value': newSta
});
Expand All @@ -1128,6 +1169,9 @@ export default class WitcherActorSheet extends ActorSheet {
let isExtraDefense = html.find("[name=isExtraDefense]").prop("checked");
if (isExtraDefense) {
let newSta = this.actor.data.data.derivedStats.sta.value - 1
if (newSta < 0) {
return ui.notifications.error(game.i18n.localize("WITCHER.Spell.notEnoughSta"));
}
this.actor.update({
'data.derivedStats.sta.value': newSta
});
Expand Down Expand Up @@ -1195,6 +1239,9 @@ export default class WitcherActorSheet extends ActorSheet {
let isExtraDefense = html.find("[name=isExtraDefense]").prop("checked");
if (isExtraDefense) {
let newSta = this.actor.data.data.derivedStats.sta.value - 1
if (newSta < 0) {
return ui.notifications.error(game.i18n.localize("WITCHER.Spell.notEnoughSta"));
}
this.actor.update({
'data.derivedStats.sta.value': newSta
});
Expand Down Expand Up @@ -1244,6 +1291,9 @@ export default class WitcherActorSheet extends ActorSheet {
let isExtraDefense = html.find("[name=isExtraDefense]").prop("checked");
if (isExtraDefense) {
let newSta = this.actor.data.data.derivedStats.sta.value - 1
if (newSta < 0) {
return ui.notifications.error(game.i18n.localize("WITCHER.Spell.notEnoughSta"));
}
this.actor.update({
'data.derivedStats.sta.value': newSta
});
Expand Down Expand Up @@ -1540,6 +1590,10 @@ export default class WitcherActorSheet extends ActorSheet {

if (isExtraAttack) {
let newSta = this.actor.data.data.derivedStats.sta.value - 3

if (newSta < 0) {
return ui.notifications.error(game.i18n.localize("WITCHER.Spell.notEnoughSta"));
}
this.actor.update({
'data.derivedStats.sta.value': newSta
});
Expand Down
Loading

0 comments on commit dfd5e16

Please sign in to comment.