This commit is contained in:
CDeenen
2021-07-27 21:56:50 +02:00
committed by kyamsil
parent ce28b2da97
commit 6c840cbf59
13 changed files with 565 additions and 39 deletions

View File

@@ -1,4 +1,5 @@
import {compatibleCore} from "../misc.js";
import {otherControls} from "../../MaterialDeck.js";
export class pf2e{
constructor(){
@@ -102,6 +103,27 @@ export class pf2e{
return this.getCondition(token,condition) != undefined;
}
getValuedCondition(token,condition) {
const effect = this.getCondition(token, condition);
if (effect != undefined && effect?.data.value != null) return effect;
}
async modifyValuedCondition(token,condition,delta) {
const effect = this.getValuedCondition(token,condition);
if (effect == undefined) {
if (delta > 0) {
const Condition = condition.charAt(0).toUpperCase() + condition.slice(1);
const newCondition = game.pf2e.ConditionManager.getCondition(Condition);
// newCondition.data.sources.hud = !0,
await game.pf2e.ConditionManager.addConditionToToken(newCondition, token);
}
} else {
const currentValue = effect.value;
console.log(`Current Value: ${currentValue}`);
await game.pf2e.ConditionManager.updateConditionValue(effect, token, currentValue+delta);
}
}
async toggleCondition(token,condition) {
if (condition == undefined) condition = 'removeAll';
if (condition == 'removeAll'){
@@ -113,7 +135,7 @@ export class pf2e{
if (effect == undefined) {
const Condition = condition.charAt(0).toUpperCase() + condition.slice(1);
const newCondition = game.pf2e.ConditionManager.getCondition(Condition);
newCondition.data.sources.hud = !0,
// newCondition.data.sources.hud = !0,
await game.pf2e.ConditionManager.addConditionToToken(newCondition, token);
}
else {
@@ -162,6 +184,7 @@ export class pf2e{
*/
getFeatures(token,featureType) {
if (featureType == undefined) featureType = 'any';
if (featureType == 'action') return this.getActions(token);
const allItems = token.actor.items;
if (featureType == 'any') return allItems.filter(i => i.type == 'class' || i.type == 'feat')
else return allItems.filter(i => i.type == featureType)
@@ -193,7 +216,20 @@ export class pf2e{
}
}
/**
* Actions
*/
getActions(token) {
const allActions = token.actor.data.data.actions;
return allActions.filter(a=>a.type==='strike');
}
rollItem(item) {
let variant = 0;
if (otherControls.rollOption == 'map1') variant = 1;
if (otherControls.rollOption == 'map2') variant = 2;
if(item.type==='strike') return item.variants[variant].roll({event});
if(item.type==='weapon') return item.parent.data.data.actions.find(a=>a.name===item.name).variants[variant].roll({event});
return item.roll()
}
}

View File

@@ -221,6 +221,11 @@ export class TokenHelper{
return this.system.getResilience(token)
}
// /* PF2E */
// getStrikes(token) {
// return this.system.getStrikes(token);
// }
/**
* Conditions
*/
@@ -236,6 +241,16 @@ export class TokenHelper{
return this.system.toggleCondition(token,condition);
}
/* PF2E */
getValuedCondition(token,condition) {
return this.system.getValuedCondition(token,condition);
}
/* PF2E */
modifyValuedCondition(token,condition,delta) {
return this.system.modifyValuedCondition(token,condition,delta);
}
/**
* Roll
*/