@@ -1272,16 +1272,18 @@ export class EnhancedJournalSheet extends JournalPageSheet {
1272
1272
let name = item . name ;
1273
1273
let img = item . img ;
1274
1274
1275
+ let identifiedName = name ;
1275
1276
if ( item . system ?. identification ?. status == "unidentified" ) {
1276
1277
name = item . system ?. identification . unidentified . name || name ;
1277
1278
img = item . system ?. identification . unidentified . img || img ;
1278
- } else if ( game . system . id == "pf1" && item . system ?. identified === false ) {
1279
+ } else if ( item . system ?. identified === false ) {
1279
1280
name = item . system ?. unidentified ?. name || name ;
1280
1281
}
1281
1282
1282
1283
let itemData = {
1283
1284
id : item . _id ,
1284
1285
name : name ,
1286
+ identifiedname : game . user . isGM && identifiedName != name ? identifiedName : null ,
1285
1287
type : item . type ,
1286
1288
img : img ,
1287
1289
hide : flags . hide ,
@@ -1721,6 +1723,8 @@ export class EnhancedJournalSheet extends JournalPageSheet {
1721
1723
}
1722
1724
}
1723
1725
1726
+ mergeObject ( sheet . object , formData ) ;
1727
+
1724
1728
let itm = items . find ( i => i . _id == itemData . _id ) ;
1725
1729
if ( itm ) {
1726
1730
itm = mergeObject ( itm , formData ) ;
@@ -1737,9 +1741,11 @@ export class EnhancedJournalSheet extends JournalPageSheet {
1737
1741
} else {
1738
1742
await this . object . setFlag ( 'monks-enhanced-journal' , 'items' , items ) ;
1739
1743
}
1740
- }
1741
1744
1742
- mergeObject ( sheet . object , formData ) ;
1745
+ if ( game . system . id == "dnd5e" ) {
1746
+ sheet . object . name = itm . name ;
1747
+ }
1748
+ }
1743
1749
1744
1750
// Handle the form state prior to submission
1745
1751
let closeForm = sheet . options . closeOnSubmit && ! preventClose ;
@@ -1750,7 +1756,11 @@ export class EnhancedJournalSheet extends JournalPageSheet {
1750
1756
// Restore flags and optionally close the form
1751
1757
sheet . _submitting = false ;
1752
1758
if ( preventRender ) sheet . _state = priorState ;
1753
- if ( closeForm ) await sheet . close ( { submit : false , force : true } ) ;
1759
+ if ( closeForm )
1760
+ await sheet . close ( { submit : false , force : true } ) ;
1761
+ else if ( game . system . id == "dnd5e" && ! preventRender ) {
1762
+ sheet . render ( true ) ;
1763
+ }
1754
1764
1755
1765
if ( ! closeForm )
1756
1766
sheet . bringToTop ( ) ;
@@ -1901,25 +1911,49 @@ export class EnhancedJournalSheet extends JournalPageSheet {
1901
1911
}
1902
1912
1903
1913
let text = tableresult . text ;
1914
+ let textCoins = [ ] ;
1904
1915
if ( text . startsWith ( "{" ) && text . endsWith ( "}" ) && text . length > 2 ) {
1905
- let rolls = text . substring ( 1 , text . length - 1 ) . split ( "," ) ;
1906
- for ( let roll of rolls ) {
1907
- let formula = roll ;
1908
- let coin = roll . match ( / \[ [ a - z ] + \] / ) ;
1909
- if ( coin . length > 0 ) {
1916
+ let splitStr = ( text . indexOf ( "[" ) > - 1 && text . indexOf ( "]" ) > - 1 ) ? "," : " " ;
1917
+ let rolls = text . substring ( 1 , text . length - 1 ) . trim ( ) . split ( splitStr ) ;
1918
+ for ( let part of rolls ) {
1919
+ if ( ! part ) continue ;
1920
+ let formula = part ;
1921
+ let coin = part . match ( / \[ [ a - z ] + \] / ) ;
1922
+ if ( splitStr == " " )
1923
+ [ , formula , coin ] = part . match ( / ^ ( .+ ?) ( \D + ) $ / ) ?? [ ] ;
1924
+ if ( Array . isArray ( coin ) ) {
1910
1925
coin = coin [ 0 ] ;
1911
1926
formula = formula . replace ( `${ coin } ` , '' ) ;
1912
1927
coin = coin . replace ( "[" , "" ) . replace ( "]" , "" ) ;
1913
1928
}
1914
- if ( coin == undefined || coin . length == 0 || MonksEnhancedJournal . currencies . find ( c => c . id == coin ) == undefined )
1915
- coin = MEJHelpers . defaultCurrency ( ) ;
1916
1929
1917
- let value = await tryRoll ( formula ) ;
1918
-
1919
- currency [ coin ] = ( currency [ coin ] || 0 ) + value ;
1920
- currChanged = true ;
1930
+ textCoins . push ( { formula, coin } ) ;
1921
1931
}
1922
1932
}
1933
+
1934
+ // DND5E Award Enricher Parsing
1935
+ if ( text . startsWith ( "[[/award" ) && text . endsWith ( "]]" ) ) {
1936
+ const awards = text . substring ( 8 , text . length - 2 ) . trim ( ) . split ( " " ) ;
1937
+ for ( const part of awards ) {
1938
+ if ( ! part ) continue ;
1939
+ let [ , formula , coin ] = part . match ( / ^ ( .+ ?) ( \D + ) $ / ) ?? [ ] ;
1940
+
1941
+ textCoins . push ( { formula, coin } ) ;
1942
+ }
1943
+ }
1944
+
1945
+ for ( let tc of textCoins ) {
1946
+ if ( tc . coin == undefined )
1947
+ tc . coin = MEJHelpers . defaultCurrency ( ) ;
1948
+ else if ( MonksEnhancedJournal . currencies . find ( c => c . id == tc . coin ) == undefined )
1949
+ continue ;
1950
+
1951
+ tc . coin = tc . coin ?. toLowerCase ( ) ;
1952
+
1953
+ let value = await tryRoll ( tc . formula ) ;
1954
+ currency [ tc . coin ] = ( currency [ tc . coin ] || 0 ) + value ;
1955
+ currChanged = true ;
1956
+ }
1923
1957
}
1924
1958
}
1925
1959
/*
@@ -2443,6 +2477,8 @@ export class EnhancedJournalSheet extends JournalPageSheet {
2443
2477
const description = chatData ?. description ?. value ?? item . description ;
2444
2478
div = $ ( '<div>' ) . addClass ( "item-summary" ) . append ( propertiesElem , levelPriceLabel , `<div class="item-description">${ description } </div>` ) ;
2445
2479
} else {
2480
+ if ( item . system ?. identified === false && ! game . user . isGM && getProperty ( item , "system.unidentified.description" ) )
2481
+ chatData = getProperty ( item , "system.unidentified.description" ) ;
2446
2482
div = $ ( `<div class="item-summary">${ ( typeof chatData == "string" ? chatData : chatData . description . value ?? chatData . description ) } </div>` ) ;
2447
2483
if ( typeof chatData !== "string" ) {
2448
2484
let props = $ ( '<div class="item-properties"></div>' ) ;
0 commit comments