2020-10-23 13:32:23 -04:00
import TraitSelector from "../apps/trait-selector.js" ;
2021-02-10 18:39:36 -06:00
import { onManageActiveEffect , prepareActiveEffectCategories } from "../effects.js" ;
2020-06-24 14:23:26 -04:00
/ * *
2020-10-23 13:32:23 -04:00
* Override and extend the core ItemSheet implementation to handle specific item types
* @ extends { ItemSheet }
2020-06-24 14:23:26 -04:00
* /
2020-10-23 13:32:23 -04:00
export default class ItemSheet5e extends ItemSheet {
constructor ( ... args ) {
super ( ... args ) ;
2020-11-12 17:30:07 -05:00
// Expand the default size of the class sheet
2021-02-10 18:39:36 -06:00
if ( this . object . data . type === "class" ) {
this . options . width = this . position . width = 600 ;
2020-11-12 17:30:07 -05:00
this . options . height = this . position . height = 680 ;
2020-10-23 13:32:23 -04:00
}
}
/* -------------------------------------------- */
2020-06-24 14:23:26 -04:00
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
/** @inheritdoc */
2021-02-10 18:39:36 -06:00
static get defaultOptions ( ) {
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
return foundry . utils . mergeObject ( super . defaultOptions , {
2020-06-24 14:23:26 -04:00
width : 560 ,
2020-11-12 17:30:07 -05:00
height : 400 ,
2020-06-24 14:23:26 -04:00
classes : [ "sw5e" , "sheet" , "item" ] ,
2020-10-23 13:32:23 -04:00
resizable : true ,
2020-06-24 14:23:26 -04:00
scrollY : [ ".tab.details" ] ,
2021-02-10 18:39:36 -06:00
tabs : [ { navSelector : ".tabs" , contentSelector : ".sheet-body" , initial : "description" } ]
2020-06-24 14:23:26 -04:00
} ) ;
}
/* -------------------------------------------- */
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
/** @inheritdoc */
2020-06-24 14:23:26 -04:00
get template ( ) {
const path = "systems/sw5e/templates/items/" ;
return ` ${ path } / ${ this . item . data . type } .html ` ;
}
/* -------------------------------------------- */
/** @override */
2020-11-12 17:30:07 -05:00
async getData ( options ) {
const data = super . getData ( options ) ;
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
const itemData = data . data ;
2020-06-24 14:23:26 -04:00
data . labels = this . item . labels ;
data . config = CONFIG . SW5E ;
// Item Type, Status, and Details
2020-11-12 17:30:07 -05:00
data . itemType = game . i18n . localize ( ` ITEM.Type ${ data . item . type . titleCase ( ) } ` ) ;
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
data . itemStatus = this . _getItemStatus ( itemData ) ;
data . itemProperties = this . _getItemProperties ( itemData ) ;
data . isPhysical = itemData . data . hasOwnProperty ( "quantity" ) ;
2020-11-12 17:30:07 -05:00
2020-10-23 13:32:23 -04:00
// Potential consumption targets
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
data . abilityConsumptionTargets = this . _getItemConsumptionTargets ( itemData ) ;
2020-06-24 14:23:26 -04:00
2021-06-23 02:53:39 -04:00
// Action Details
2020-06-24 14:23:26 -04:00
data . hasAttackRoll = this . item . hasAttack ;
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
data . isHealing = itemData . data . actionType === "heal" ;
data . isFlatDC = getProperty ( itemData , "data.save.scaling" ) === "flat" ;
data . isLine = [ "line" , "wall" ] . includes ( itemData . data . target ? . type ) ;
2020-10-23 13:32:23 -04:00
2021-01-18 23:49:04 -05:00
// Original maximum uses formula
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
const sourceMax = foundry . utils . getProperty ( this . item . data . _source , "data.uses.max" ) ;
if ( sourceMax ) itemData . data . uses . max = sourceMax ;
2021-01-18 23:49:04 -05:00
2020-10-23 13:32:23 -04:00
// Vehicles
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
data . isCrewed = itemData . data . activation ? . type === "crew" ;
data . isMountable = this . _isItemMountable ( itemData ) ;
2020-11-12 17:30:07 -05:00
// Prepare Active Effects
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
data . effects = prepareActiveEffectCategories ( this . item . effects ) ;
// Re-define the template data references (backwards compatible)
data . item = itemData ;
data . data = itemData . data ;
2020-06-24 14:23:26 -04:00
return data ;
}
2020-10-23 13:32:23 -04:00
/* -------------------------------------------- */
2020-11-12 17:30:07 -05:00
/ * *
2020-10-23 13:32:23 -04:00
* Get the valid item consumption targets which exist on the actor
* @ param { Object } item Item data for the item being displayed
* @ return { { string : string } } An object of potential consumption targets
* @ private
* /
_getItemConsumptionTargets ( item ) {
const consume = item . data . consume || { } ;
2021-02-10 18:39:36 -06:00
if ( ! consume . type ) return [ ] ;
2020-10-23 13:32:23 -04:00
const actor = this . item . actor ;
2021-02-10 18:39:36 -06:00
if ( ! actor ) return { } ;
2020-10-23 13:32:23 -04:00
// Ammunition
2021-02-10 18:39:36 -06:00
if ( consume . type === "ammo" ) {
return actor . itemTypes . consumable . reduce (
( ammo , i ) => {
if ( i . data . data . consumableType === "ammo" ) {
ammo [ i . id ] = ` ${ i . name } ( ${ i . data . data . quantity } ) ` ;
}
return ammo ;
} ,
{ [ item . _id ] : ` ${ item . name } ( ${ item . data . quantity } ) ` }
) ;
2020-10-23 13:32:23 -04:00
}
// Attributes
2021-02-10 18:39:36 -06:00
else if ( consume . type === "attribute" ) {
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
const attributes = TokenDocument . getTrackedAttributes ( actor . data . data ) ;
attributes . bar . forEach ( a => a . push ( "value" ) ) ;
return attributes . bar . concat ( attributes . value ) . reduce ( ( obj , a ) => {
let k = a . join ( "." ) ;
obj [ k ] = k ;
2020-10-23 13:32:23 -04:00
return obj ;
} , { } ) ;
}
// Materials
2021-02-10 18:39:36 -06:00
else if ( consume . type === "material" ) {
2020-10-23 13:32:23 -04:00
return actor . items . reduce ( ( obj , i ) => {
2021-02-10 18:39:36 -06:00
if ( [ "consumable" , "loot" ] . includes ( i . data . type ) && ! i . data . data . activation ) {
2020-10-23 13:32:23 -04:00
obj [ i . id ] = ` ${ i . name } ( ${ i . data . data . quantity } ) ` ;
}
return obj ;
} , { } ) ;
}
// Charges
2021-02-10 18:39:36 -06:00
else if ( consume . type === "charges" ) {
2020-10-23 13:32:23 -04:00
return actor . items . reduce ( ( obj , i ) => {
2020-11-12 17:30:07 -05:00
// Limited-use items
2020-10-23 13:32:23 -04:00
const uses = i . data . data . uses || { } ;
2021-02-10 18:39:36 -06:00
if ( uses . per && uses . max ) {
const label =
uses . per === "charges"
? ` ( ${ game . i18n . format ( "SW5E.AbilityUseChargesLabel" , { value : uses . value } )}) `
: ` ( ${ game . i18n . format ( "SW5E.AbilityUseConsumableLabel" , { max : uses . max , per : uses . per } )}) ` ;
2020-10-23 13:32:23 -04:00
obj [ i . id ] = i . name + label ;
}
2020-11-12 17:30:07 -05:00
// Recharging items
const recharge = i . data . data . recharge || { } ;
2021-02-10 18:39:36 -06:00
if ( recharge . value ) obj [ i . id ] = ` ${ i . name } ( ${ game . i18n . format ( "SW5E.Recharge" ) } ) ` ;
2020-10-23 13:32:23 -04:00
return obj ;
2021-02-10 18:39:36 -06:00
} , { } ) ;
} else return { } ;
2020-10-23 13:32:23 -04:00
}
2020-06-24 14:23:26 -04:00
/* -------------------------------------------- */
/ * *
* Get the text item status which is shown beneath the Item type in the top - right corner of the sheet
* @ return { string }
* @ private
* /
_getItemStatus ( item ) {
2021-02-10 18:39:36 -06:00
if ( item . type === "power" ) {
2020-06-24 14:23:26 -04:00
return CONFIG . SW5E . powerPreparationModes [ item . data . preparation ] ;
2021-02-10 18:39:36 -06:00
} else if ( [ "weapon" , "equipment" ] . includes ( item . type ) ) {
2020-10-23 13:32:23 -04:00
return game . i18n . localize ( item . data . equipped ? "SW5E.Equipped" : "SW5E.Unequipped" ) ;
2021-02-10 18:39:36 -06:00
} else if ( item . type === "tool" ) {
2020-10-23 13:32:23 -04:00
return game . i18n . localize ( item . data . proficient ? "SW5E.Proficient" : "SW5E.NotProficient" ) ;
2020-06-24 14:23:26 -04:00
}
}
/* -------------------------------------------- */
/ * *
* Get the Array of item properties which are used in the small sidebar of the description tab
* @ return { Array }
* @ private
* /
_getItemProperties ( item ) {
const props = [ ] ;
const labels = this . item . labels ;
2021-02-10 18:39:36 -06:00
if ( item . type === "weapon" ) {
props . push (
... Object . entries ( item . data . properties )
. filter ( ( e ) => e [ 1 ] === true )
. map ( ( e ) => CONFIG . SW5E . weaponProperties [ e [ 0 ] ] )
) ;
} else if ( item . type === "power" ) {
2020-06-24 14:23:26 -04:00
props . push (
labels . components ,
labels . materials ,
2020-10-23 13:32:23 -04:00
item . data . components . concentration ? game . i18n . localize ( "SW5E.Concentration" ) : null ,
item . data . components . ritual ? game . i18n . localize ( "SW5E.Ritual" ) : null
2021-02-10 18:39:36 -06:00
) ;
} else if ( item . type === "equipment" ) {
2020-06-24 14:23:26 -04:00
props . push ( CONFIG . SW5E . equipmentTypes [ item . data . armor . type ] ) ;
props . push ( labels . armor ) ;
2021-02-10 18:39:36 -06:00
} else if ( item . type === "feat" ) {
2020-06-24 14:23:26 -04:00
props . push ( labels . featType ) ;
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
//TODO: Work out these
2021-02-10 18:39:36 -06:00
} else if ( item . type === "species" ) {
2020-11-12 17:30:07 -05:00
//props.push(labels.species);
2021-02-10 18:39:36 -06:00
} else if ( item . type === "archetype" ) {
//props.push(labels.archetype);
} else if ( item . type === "background" ) {
//props.push(labels.background);
} else if ( item . type === "classfeature" ) {
//props.push(labels.classfeature);
2021-04-06 16:03:48 -04:00
} else if ( item . type === "deployment" ) {
//props.push(labels.deployment);
} else if ( item . type === "venture" ) {
//props.push(labels.venture);
2021-02-10 18:39:36 -06:00
} else if ( item . type === "fightingmastery" ) {
//props.push(labels.fightingmastery);
} else if ( item . type === "fightingstyle" ) {
//props.push(labels.fightingstyle);
} else if ( item . type === "lightsaberform" ) {
//props.push(labels.lightsaberform);
2020-07-30 16:04:59 -04:00
}
2021-02-10 18:39:36 -06:00
2020-06-24 14:23:26 -04:00
// Action type
2021-02-10 18:39:36 -06:00
if ( item . data . actionType ) {
2020-06-24 14:23:26 -04:00
props . push ( CONFIG . SW5E . itemActionTypes [ item . data . actionType ] ) ;
}
// Action usage
2021-02-10 18:39:36 -06:00
if ( item . type !== "weapon" && item . data . activation && ! isObjectEmpty ( item . data . activation ) ) {
props . push ( labels . activation , labels . range , labels . target , labels . duration ) ;
2020-06-24 14:23:26 -04:00
}
2021-02-10 18:39:36 -06:00
return props . filter ( ( p ) => ! ! p ) ;
2020-06-24 14:23:26 -04:00
}
/* -------------------------------------------- */
2020-10-23 13:32:23 -04:00
/ * *
* Is this item a separate large object like a siege engine or vehicle
* component that is usually mounted on fixtures rather than equipped , and
* has its own AC and HP .
* @ param item
* @ returns { boolean }
* @ private
* /
_isItemMountable ( item ) {
const data = item . data ;
2021-02-10 18:39:36 -06:00
return (
( item . type === "weapon" && data . weaponType === "siege" ) ||
( item . type === "equipment" && data . armor . type === "vehicle" )
) ;
2020-10-23 13:32:23 -04:00
}
/* -------------------------------------------- */
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
/** @inheritdoc */
2021-02-10 18:39:36 -06:00
setPosition ( position = { } ) {
if ( ! ( this . _minimized || position . height ) ) {
position . height = this . _tabs [ 0 ] . active === "details" ? "auto" : this . options . height ;
2020-10-23 13:32:23 -04:00
}
2020-06-24 14:23:26 -04:00
return super . setPosition ( position ) ;
}
/* -------------------------------------------- */
/* Form Submission */
2021-02-10 18:39:36 -06:00
/* -------------------------------------------- */
2020-06-24 14:23:26 -04:00
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
/** @inheritdoc */
2021-02-10 18:39:36 -06:00
_getSubmitData ( updateData = { } ) {
2020-11-12 17:30:07 -05:00
// Create the expanded update data object
2021-02-10 18:39:36 -06:00
const fd = new FormDataExtended ( this . form , { editors : this . editors } ) ;
2020-11-12 17:30:07 -05:00
let data = fd . toObject ( ) ;
2021-02-10 18:39:36 -06:00
if ( updateData ) data = mergeObject ( data , updateData ) ;
2020-11-12 17:30:07 -05:00
else data = expandObject ( data ) ;
2020-07-13 19:51:27 -03:00
2020-11-12 17:30:07 -05:00
// Handle Damage array
const damage = data . data ? . damage ;
2021-02-10 18:39:36 -06:00
if ( damage ) damage . parts = Object . values ( damage ? . parts || { } ) . map ( ( d ) => [ d [ 0 ] || "" , d [ 1 ] || "" ] ) ;
2020-07-13 19:51:27 -03:00
2020-11-12 17:30:07 -05:00
// Return the flattened submission data
return flattenObject ( data ) ;
2020-06-24 14:23:26 -04:00
}
/* -------------------------------------------- */
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
/** @inheritdoc */
2020-06-24 14:23:26 -04:00
activateListeners ( html ) {
super . activateListeners ( html ) ;
2021-02-10 18:39:36 -06:00
if ( this . isEditable ) {
2020-11-12 17:30:07 -05:00
html . find ( ".damage-control" ) . click ( this . _onDamageControl . bind ( this ) ) ;
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
html . find ( ".trait-selector.class-skills" ) . click ( this . _onConfigureTraits . bind ( this ) ) ;
2021-02-10 18:39:36 -06:00
html . find ( ".effect-control" ) . click ( ( ev ) => {
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
if ( this . item . isOwned ) return ui . notifications . warn ( "Managing Active Effects within an Owned Item is not currently supported and will be added in a subsequent update." ) ;
2021-02-10 18:39:36 -06:00
onManageActiveEffect ( ev , this . item ) ;
2020-11-12 17:30:07 -05:00
} ) ;
}
2020-06-24 14:23:26 -04:00
}
/* -------------------------------------------- */
/ * *
* Add or remove a damage part from the damage formula
* @ param { Event } event The original click event
* @ return { Promise }
* @ private
* /
async _onDamageControl ( event ) {
event . preventDefault ( ) ;
const a = event . currentTarget ;
// Add new damage component
2021-02-10 18:39:36 -06:00
if ( a . classList . contains ( "add-damage" ) ) {
await this . _onSubmit ( event ) ; // Submit any unsaved changes
2020-06-24 14:23:26 -04:00
const damage = this . item . data . data . damage ;
2021-02-10 18:39:36 -06:00
return this . item . update ( { "data.damage.parts" : damage . parts . concat ( [ [ "" , "" ] ] ) } ) ;
2020-06-24 14:23:26 -04:00
}
// Remove a damage component
2021-02-10 18:39:36 -06:00
if ( a . classList . contains ( "delete-damage" ) ) {
await this . _onSubmit ( event ) ; // Submit any unsaved changes
2020-06-24 14:23:26 -04:00
const li = a . closest ( ".damage-part" ) ;
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
const damage = foundry . utils . deepClone ( this . item . data . data . damage ) ;
2020-06-24 14:23:26 -04:00
damage . parts . splice ( Number ( li . dataset . damagePart ) , 1 ) ;
2021-02-10 18:39:36 -06:00
return this . item . update ( { "data.damage.parts" : damage . parts } ) ;
2020-06-24 14:23:26 -04:00
}
}
/* -------------------------------------------- */
/ * *
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
* Handle spawning the TraitSelector application for selection various options .
2020-06-24 14:23:26 -04:00
* @ param { Event } event The click event which originated the selection
* @ private
* /
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
_onConfigureTraits ( event ) {
2020-06-24 14:23:26 -04:00
event . preventDefault ( ) ;
const a = event . currentTarget ;
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
const options = {
2021-01-18 23:49:04 -05:00
name : a . dataset . target ,
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
title : a . parentElement . innerText ,
choices : [ ] ,
allowCustom : false
} ;
switch ( a . dataset . options ) {
case 'saves' :
options . choices = CONFIG . SW5E . abilities ;
options . valueKey = null ;
break ;
case 'skills' :
const skills = this . item . data . data . skills ;
const choiceSet = skills . choices && skills . choices . length ? skills . choices : Object . keys ( CONFIG . SW5E . skills ) ;
options . choices = Object . fromEntries ( Object . entries ( CONFIG . SW5E . skills ) . filter ( skill => choiceSet . includes ( skill [ 0 ] ) ) ) ;
options . maximum = skills . number ;
break ;
}
new TraitSelector ( this . item , options ) . render ( true ) ;
2020-06-24 14:23:26 -04:00
}
2020-11-12 17:30:07 -05:00
/* -------------------------------------------- */
Updated to DND5e 1.3.2
Things unfinished:
- Migration
- The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more
- The French
- The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points
- I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking
- I only did a little testing
- There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented
Things changed from base 5e:
- Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message
Extra Comments:
- Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers
- Weapon proficiencies probably need revising
- Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e
- SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented
- SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented
- Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
2021-06-01 01:55:14 +01:00
/** @inheritdoc */
2020-11-12 17:30:07 -05:00
async _onSubmit ( ... args ) {
2021-02-10 18:39:36 -06:00
if ( this . _tabs [ 0 ] . active === "details" ) this . position . height = "auto" ;
2020-11-12 17:30:07 -05:00
await super . _onSubmit ( ... args ) ;
}
2020-06-24 14:23:26 -04:00
}