@@ -74,8 +74,12 @@ class ExpPlugin: OPlugin {
7474 if inputCheck. hasPrefix ( " /tracker report " ) {
7575 let trimmed = inputCheck [ 15 ... ]
7676 let sorting = trimmed. toOrderBy ( ) ?? tracker. sortingBy
77+ let rexp = host? . get ( variable: " rexp " ) ?? " "
78+ let favor = host? . get ( variable: " favor " ) ?? " "
79+ let sleep = host? . get ( variable: " sleep " ) ?? " "
80+ let tdps = host? . get ( variable: " tdp " ) ?? " "
7781
78- let report = tracker. buildReport ( sorting: sorting, foreColor: foreColor, learnedColor: learnedColor)
82+ let report = tracker. buildReport ( sorting: sorting, foreColor: foreColor, learnedColor: learnedColor, favors : favor , rexp : rexp , sleep : sleep , tdps : tdps )
7983
8084 for cmd in report {
8185 host? . send ( text: cmd)
@@ -180,6 +184,11 @@ class ExpPlugin: OPlugin {
180184 // cleared
181185 // <component id='exp Sorcery'></component>
182186
187+ // <component id='exp rexp'>Rested EXP Stored: 5:59 hours Usable This Cycle: 5:53 hours Cycle Refreshes: 22:32 hours</component>
188+ // <component id='exp tdp'> TDPs: 926</component>
189+ // <component id='exp favor'> Favors: 12</component>
190+ // <component id='exp sleep'></component>
191+
183192 func parse( xml: String ) -> String {
184193 if updateWindow, xml. contains ( " <prompt " ) {
185194 updateExpWindow ( )
@@ -215,16 +224,14 @@ class ExpPlugin: OPlugin {
215224 let start = trimmed. index ( trimmed. startIndex, offsetBy: 24 )
216225 if let favorsIdx = trimmed. index ( of: " Favors " ) {
217226 let number = String ( trimmed [ start ..< favorsIdx] ) . trimmingCharacters ( in: . whitespacesAndNewlines)
218- tracker. tdps = Int ( number) ?? 0
219- host? . send ( text: " #var tdp \( tracker. tdps) " )
227+ host? . send ( text: " #var tdp \( number) " )
220228 }
221229 }
222230
223231 if trimmed. hasPrefix ( " TDPs : " ) {
224232 let start = trimmed. index ( trimmed. startIndex, offsetBy: 6 )
225233 let number = String ( trimmed [ start... ] ) . trimmingCharacters ( in: . whitespacesAndNewlines)
226- tracker. tdps = Int ( number) ?? 0
227- host? . send ( text: " #var tdp \( tracker. tdps) " )
234+ host? . send ( text: " #var tdp \( number) " )
228235 }
229236
230237 if !parsing, trimmed. hasPrefix ( ExpPlugin . start_check) {
@@ -276,17 +283,55 @@ class ExpPlugin: OPlugin {
276283
277284 updateWindow = true
278285 } else {
279- // handle empty tag
286+ // handle additional tags
280287 let regex = RegexFactory . get ( " id='exp \\ s([ \\ w \\ s]+)' " )
281288 if let match = regex? . firstMatch ( & copy) {
282289 let name = match. valueAt ( index: 1 ) ? . replacingOccurrences ( of: " " , with: " _ " ) ?? " "
283- let learningRate = LearningRate . clear
284-
285- tracker. update ( SkillExp ( name: name, mindState: learningRate, ranks: 0 , isNew: false ) , trackLearned: displayLearnedWithPrompt)
286290
287- host? . set ( variable: " \( name) .Ranks " , value: " 0.0 " )
288- host? . set ( variable: " \( name) .LearningRate " , value: " \( learningRate. rawValue) " )
289- host? . set ( variable: " \( name) .LearningRateName " , value: " \( learningRate. description) " )
291+ switch name {
292+ case " favor " :
293+ let valReg = RegexFactory . get ( " .+> \\ s*(.+)<.* " )
294+ if let match = valReg? . firstMatch ( & copy) {
295+ let txt = match. valueAt ( index: 1 ) ?? " "
296+ let value = Int ( txt. replacingOccurrences ( of: " Favors: " , with: " " ) . trimLeadingWhitespace ( ) ) ?? 0
297+ host? . set ( variable: name, value: " \( value) " )
298+ }
299+ break
300+ case " rexp " :
301+ let valReg = RegexFactory . get ( " .+> \\ s*(.+)<.* " )
302+ if let match = valReg? . firstMatch ( & copy) {
303+ let txt = match. valueAt ( index: 1 ) ?? " "
304+ host? . set ( variable: name, value: txt)
305+ } else {
306+ host? . set ( variable: name, value: " " )
307+ }
308+ break
309+ case " sleep " :
310+ let valReg = RegexFactory . get ( " .+> \\ s*(.+)<.* " )
311+ if let match = valReg? . firstMatch ( & copy) {
312+ let txt = ( match. valueAt ( index: 1 ) ?? " " ) . replacingOccurrences ( of: " </b> " , with: " " )
313+ host? . set ( variable: name, value: txt)
314+ } else {
315+ host? . set ( variable: name, value: " " )
316+ }
317+ break
318+ case " tdp " :
319+ let valReg = RegexFactory . get ( " .+> \\ s*(.+)<.* " )
320+ if let match = valReg? . firstMatch ( & copy) {
321+ let txt = match. valueAt ( index: 1 ) ?? " "
322+ let value = Int ( txt. replacingOccurrences ( of: " TDPs: " , with: " " ) . trimLeadingWhitespace ( ) ) ?? 0
323+ host? . set ( variable: name, value: " \( value) " )
324+ }
325+ break
326+ default :
327+ let learningRate = LearningRate . clear
328+
329+ tracker. update ( SkillExp ( name: name, mindState: learningRate, ranks: 0 , isNew: false ) , trackLearned: displayLearnedWithPrompt)
330+
331+ host? . set ( variable: " \( name) .Ranks " , value: " 0.0 " )
332+ host? . set ( variable: " \( name) .LearningRate " , value: " \( learningRate. rawValue) " )
333+ host? . set ( variable: " \( name) .LearningRateName " , value: " \( learningRate. description) " )
334+ }
290335
291336 updateWindow = true
292337 }
@@ -313,17 +358,55 @@ class ExpPlugin: OPlugin {
313358
314359 updateWindow = true
315360 } else {
316- // handle empty tag
361+ // handle additional tags
317362 let regex = RegexFactory . get ( " id='exp \\ s([ \\ w \\ s]+)' " )
318363 if let match = regex? . firstMatch ( & copy) {
319364 let name = match. valueAt ( index: 1 ) ? . replacingOccurrences ( of: " " , with: " _ " ) ?? " "
320- let learningRate = LearningRate . clear
321-
322- tracker. update ( SkillExp ( name: name, mindState: learningRate, ranks: 0 , isNew: false ) , trackLearned: displayLearnedWithPrompt)
323-
324- host? . set ( variable: " \( name) .Ranks " , value: " 0.0 " )
325- host? . set ( variable: " \( name) .LearningRate " , value: " \( learningRate. rawValue) " )
326- host? . set ( variable: " \( name) .LearningRateName " , value: " \( learningRate. description) " )
365+
366+ switch name {
367+ case " favor " :
368+ let valReg = RegexFactory . get ( " .+> \\ s*(.+)<.* " )
369+ if let match = valReg? . firstMatch ( & copy) {
370+ let txt = match. valueAt ( index: 1 ) ?? " "
371+ let value = Int ( txt. replacingOccurrences ( of: " Favors: " , with: " " ) . trimLeadingWhitespace ( ) ) ?? 0
372+ host? . set ( variable: name, value: " \( value) " )
373+ }
374+ break
375+ case " rexp " :
376+ let valReg = RegexFactory . get ( " .+> \\ s*(.+)<.* " )
377+ if let match = valReg? . firstMatch ( & copy) {
378+ let txt = match. valueAt ( index: 1 ) ?? " "
379+ host? . set ( variable: name, value: txt)
380+ } else {
381+ host? . set ( variable: name, value: " " )
382+ }
383+ break
384+ case " sleep " :
385+ let valReg = RegexFactory . get ( " .+> \\ s*(.+)<.* " )
386+ if let match = valReg? . firstMatch ( & copy) {
387+ let txt = ( match. valueAt ( index: 1 ) ?? " " ) . replacingOccurrences ( of: " </b> " , with: " " )
388+ host? . set ( variable: name, value: txt)
389+ } else {
390+ host? . set ( variable: name, value: " " )
391+ }
392+ break
393+ case " tdp " :
394+ let valReg = RegexFactory . get ( " .+> \\ s*(.+)<.* " )
395+ if let match = valReg? . firstMatch ( & copy) {
396+ let txt = match. valueAt ( index: 1 ) ?? " "
397+ let value = Int ( txt. replacingOccurrences ( of: " TDPs: " , with: " " ) . trimLeadingWhitespace ( ) ) ?? 0
398+ host? . set ( variable: name, value: " \( value) " )
399+ }
400+ break
401+ default :
402+ let learningRate = LearningRate . clear
403+
404+ tracker. update ( SkillExp ( name: name, mindState: learningRate, ranks: 0 , isNew: false ) , trackLearned: displayLearnedWithPrompt)
405+
406+ host? . set ( variable: " \( name) .Ranks " , value: " 0.0 " )
407+ host? . set ( variable: " \( name) .LearningRate " , value: " \( learningRate. rawValue) " )
408+ host? . set ( variable: " \( name) .LearningRateName " , value: " \( learningRate. description) " )
409+ }
327410
328411 updateWindow = true
329412 }
@@ -333,8 +416,12 @@ class ExpPlugin: OPlugin {
333416 private func updateExpWindow( ) {
334417 let foreColor = host? . get ( preset: " exptracker:text " ) ?? " "
335418 let learnedColor = host? . get ( preset: " exptracker:learned " ) ?? " "
419+ let rexp = host? . get ( variable: " rexp " ) ?? " "
420+ let favor = host? . get ( variable: " favor " ) ?? " "
421+ let sleep = host? . get ( variable: " sleep " ) ?? " "
422+ let tdps = host? . get ( variable: " tdp " ) ?? " "
336423
337- let commands = tracker. buildDisplayCommands ( foreColor: foreColor, learnedColor: learnedColor)
424+ let commands = tracker. buildDisplayCommands ( foreColor: foreColor, learnedColor: learnedColor, favors : favor , rexp : rexp , sleep : sleep , tdps : tdps )
338425 for cmd in commands {
339426 host? . send ( text: cmd)
340427 }
0 commit comments