Guest User

Untitled

a guest
Oct 6th, 2025
5
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 193.00 KB | None | 0 0
  1. /*
  2. Current Version: 6.4.3
  3. Last updated: 03.15.2018
  4. Character Sheet and Script Maintained by: Samuel T.
  5. Older Verions: https://github.com/dayst/StarWarsEdgeOfTheEmpire_Dice
  6. Credits:
  7. Original creator: Konrad J.
  8. Helped with Dice specs: Alicia G. and Blake the Lake
  9. Dice graphics hosted by Alicia G. at galacticcampaigns.com
  10. Dice graphics borrowed from the awesome google+ hangouts EotE Dice App
  11. Basic Character Sheet and Advanced Dice Roller: Steve Day
  12. GM Sheet Campaign Details design inspiration: www.reddit.com/user/JohnSquiggleton
  13. Sheet Autocreator: www.reddit.com/user/lowdownfool
  14. New Tab Labels: Steve D., GM Knowledge Rhino, and Loki
  15. Skill Description by: Gribble - https://dl.dropboxusercontent.com/u/9077657/SW-EotE-Reference-Sheets.pdf
  16. Critical Descriptions by: Gribble - https://dl.dropboxusercontent.com/u/9077657/SW-EotE-Reference-Sheets.pdf
  17. Debugger: Arron
  18. Basic Roll Templates for basic rolls: Josh A.
  19. Initiative Roller: Andrew H.
  20. Opposed Roller: Tom F.
  21. Method to hide depreciated Vehicle Tabs: Phil B.
  22. Work done by GM Knowledge Rhino:
  23. Group Tab
  24. Companion Tab
  25. GM Resources
  26. Redesign of Vehicle Tab
  27. Riding Beast Display
  28. Roll Template Code Fixes
  29. Roll Templates integrated with all Rolls
  30. Overencumbrance roll notification
  31. Work done by Samuel T.:
  32. Versions 4.0.10.0 - 6.3.0 b5
  33. SuggestionEngine
  34. NPC Sheet
  35. Initiative fix
  36. Label generation fix
  37. Semantic Versioning
  38. Consolidated the Dice Pool and Destiny Sections
  39. Collapsing sections
  40. Optgroups for dropdowns
  41. API Chat Commands
  42. Dice Downgrade fix by Bast L.
  43. Settings:
  44. Log
  45. * default: 'on' and 'single'
  46. * Description: Sets the visual output in the chat window for the dice rolls
  47. * Command: !eed log on|off|multi|single
  48. Graphics
  49. * default: 'on' and 'm'
  50. * Description: Sets chat window dice output as graphic, small, medium, or large if "on" or as text if "off"
  51. * Command: !eed graphics on|off|s|m|l
  52. Test
  53. * Description: Output every side of every die to the chat window
  54. * !eed test
  55. Debug
  56. * default: 'off'
  57. * DescriptionL Sets the logging level of the script in the API console. If you are having issues with the
  58. * script rolling incorrect dice, turn on debug logging and post the result in the forums. No need to restart the
  59. * script with this command.
  60. * Command: !eed debug on|off
  61. GM Sheet Settings:
  62. SuggestionDisplay
  63. * Description: Sets the state of the skill_suggestion_setting_display status on the DicePool
  64. * Command: !eed suggestionDisplay none|whisper|always
  65. Fear
  66. * Description: Sets the state of the Fear check status on the DicePool
  67. * Command: !eed fear on|off
  68. Roll:
  69. Label
  70. * default: null
  71. * Description: set the skill name of the roll
  72. * Command: !eed label(Name of Skill)
  73. Initiative
  74. * default: false
  75. * Description: Set NPC/PC initiative true
  76. * Command: !eed npcinit or pcinit and #b #g #y #blk #p #r #w
  77. Skill
  78. * default:
  79. * Description: create the ability and proficiency dice for a skill check
  80. * Command: !eed skill(char_value|skill_value)
  81. Opposed
  82. * default:
  83. * Description: create the difficulty and challenge dice for an opposed skill check
  84. * Command: !eed opposed(char_value|skill_value|[NPC minion group size]|[Is skill a minion skill])
  85. Dice
  86. * default:
  87. * Description: Loop thru the dice and adds or subtracts them from the dice object
  88. * Command: !eed #g #y #b #blk #r #p #w #s #a
  89. Upgrade
  90. * default:
  91. * Description: upgrades ability and difficulty dice
  92. * Command: !eed upgrade(ability|#) or upgrade(difficulty|#)
  93. Downgrade
  94. * default:
  95. * Description: downgrades proficiency and challenge dice
  96. * Command: !eed downgrade(proficiency|#) or downgrade(challenge|#)
  97. Destiny
  98. * default:
  99. * Description: Rolls 1w die and adds the result to the destiny pool
  100. * Command: !eed #w destiny doRoll
  101. Other:
  102. Charsheet
  103. * default:
  104. * Description: Generates a blank character sheet and automatically makes it viewable and editable by the person calling the script.
  105. * Command: !charsheet
  106. */
  107.  
  108. /* Define functions that may not always exist */
  109. if(!log) {
  110. log = function(input) {
  111. console.log(input);
  112. }
  113. }
  114.  
  115. if (!sendChat) {
  116. sendChat = function (sender, msg) {
  117. log(sender + " says " + msg);
  118. }
  119. }
  120. /* End special function definitions*/
  121.  
  122.  
  123. /* Begin Sheet Character Sheet Auto Creator */
  124. var Charsheet = Charsheet || {};
  125.  
  126. on('chat:message', function (msg) {
  127. // Exit if not an api command
  128. if (msg.type != "api") {
  129. return;
  130. }
  131. if (msg.content.indexOf('!charsheet') != -1) {
  132. Charsheet.Generate(msg);
  133. }
  134. });
  135.  
  136. Charsheet.Generate = function (msg) {
  137. var player = msg.who;
  138. var character_name = msg.who + Date.now();
  139.  
  140. var character = createObj('character', {
  141. name: character_name,
  142. inplayerjournals: msg.playerid,
  143. controlledby: msg.playerid
  144. });
  145. /* Create attributes */
  146. createObj('attribute', {
  147. name: 'player_name',
  148. current: player,
  149. _characterid: character.id
  150. });
  151. createObj('attribute', {
  152. name: 'name',
  153. current: character_name,
  154. _characterid: character.id
  155. });
  156. sendChat("Dice System", "/w " + msg.who + " a blank character sheet was created for you named \"" + character_name);
  157. sendChat("GM", "/w " + "gm " + "A blank character sheet was created for " + msg.who)
  158. };
  159.  
  160. if (!Date.now) {
  161. Date.now = function now() {
  162. return new Date().getTime();
  163. };
  164. }
  165. /* End Sheet Character Sheet Auto Creator */
  166.  
  167. function SuggestionEngine () {
  168. var that = this;
  169.  
  170. var flags = {
  171. displayOption: null,
  172. generalSuggesting: true,
  173. combatSuggesting: true,
  174. combatType: null,
  175. isFearCheck: false
  176. };
  177.  
  178. function convertToBoolean (value) {
  179. // will trap the following properly: false, true, "false", "true", 0, 1, "", and undefined
  180. //noinspection RedundantConditionalExpressionJS
  181. return !value || value == 1 || value === 'true'
  182. }
  183.  
  184. this.suggestions = {
  185. special: {
  186. fear: {
  187. allowedSkills: [
  188. "Cool",
  189. "Discipline"
  190. ],
  191. success: [
  192. {
  193. text: "The character avoids any fear effects, except those triggered by threats",
  194. required: 1
  195. }
  196. ],
  197. advantage: [
  198. {text: "Gain $BOOST$ on the character's first check.", required: 1},
  199. {
  200. text: "If spending multiple $ADVANTAGE$, grant $BOOST$ to an additional player's first check.",
  201. required: 2
  202. }
  203. ],
  204. triumph: [
  205. {
  206. text: "Can be spent to cancel all previous penalties from fear checks, or",
  207. required: 1
  208. },
  209. {
  210. text: "Spent to ensure the character need not make any additional fear checks during the encounter, no matter the source.",
  211. required: 1
  212. }
  213. ],
  214. failure: [
  215. {
  216. text: "The character adds $SETBACK$ to each action he takes during the encounter.",
  217. required: 1
  218. }
  219. ],
  220. threat: [
  221. {
  222. text: "The character suffers a number of strain equal to the number of $FAILURE$.",
  223. required: 1
  224. },
  225. {
  226. text: "If the check generates $THREAT$$THREAT$$THREAT$+, the character can be staggered for his first turn, instead.",
  227. required: 3
  228. }
  229. ],
  230. despair: [
  231. {
  232. text: "The character is incredibly frightened and increases the difficulty of all checks until the end of the encounter by one.",
  233. required: 1
  234. }
  235. ]
  236. }
  237. },
  238. general: {
  239. Astrogation: {
  240. success: [
  241. {
  242. text: "Better target for the destination, e.g.: place vessel directly into orbit around target planet.",
  243. required: 1
  244. },
  245. {text: "Reduce time spent calculating.", required: 1}
  246. ],
  247. advantage: [
  248. {text: "Reduce travel time.", required: 1},
  249. {text: "Identify convenient stopovers to resupply or conduct additional business.", required: 1}
  250. ],
  251. triumph: [
  252. {text: "Complete calculations in minimum time.", required: 1},
  253. {text: "Greatly reduce travel time.", required: 1},
  254. {text: "Reveal highly valuable but previously unknown information.", required: 1}
  255. ],
  256. threat: [
  257. {text: "Decrease accuracy of hyperspace jump.", required: 1},
  258. {text: "Increase travel time.", required: 1},
  259. {text: "Miss relevant details when analyzing hyperspace routes or galactic maps.", required: 1}
  260. ],
  261. despair: [
  262. {text: "Greatly decrease accuracy of hyperspace jump.", required: 1},
  263. {text: "Greatly increase travel time.", required: 1},
  264. {
  265. text: "Miss large amounts of relevant details when analyzing hyperspace routes or galactic maps.",
  266. required: 1
  267. },
  268. {
  269. text: "Trigger something truly awful happening, such as jumping out of hyperspace in the path of an asteroid.",
  270. required: 1
  271. }
  272. ]
  273. },
  274. Athletics: {
  275. success: [
  276. {text: "Reduce time required.", required: 1},
  277. {text: "Increase distance travelled.", required: 1}
  278. ],
  279. advantage: [
  280. {
  281. text: "Generate bonus on other physical checks performed later or by allies that turn.",
  282. required: 1
  283. },
  284. {
  285. text: "Spend $ADVANTAGE$$ADVANTAGE$ to grant additional maneuver during turn to move or perform physical activity.",
  286. required: 2
  287. }
  288. ],
  289. triumph: [
  290. {text: "Perform the check with truly impressive results.", required: 1}
  291. ],
  292. threat: [
  293. {text: "Small amounts cause strain.", required: 1},
  294. {
  295. text: "Larger amounts may cause character to fall prone, or even suffer a wound from sprains and bruises.",
  296. required: 1
  297. }
  298. ],
  299. despair: [
  300. {
  301. text: "Inflict a Critical Injury, which the GM can choose to be thematic or roll randomly.",
  302. required: 1
  303. }
  304. ]
  305. },
  306. Charm: {
  307. success: [
  308. {
  309. text: "Gain an extra scene in which target is willing to support you for each additional success.",
  310. required: 1
  311. }
  312. ],
  313. advantage: [
  314. {text: "Affect unexpected subjects beyond the original target.", required: 1}
  315. ],
  316. triumph: [
  317. {text: "Have target NPC become recurring character who remains predisposed to assist.", required: 1}
  318. ],
  319. threat: [
  320. {text: "Reduce the number of people able to influence", required: 1},
  321. {text: "Turn those affected negatively against character.", required: 1}
  322. ],
  323. despair: [
  324. {text: "Turn NPC against character and make into a minor recurring adversary.", required: 1}
  325. ]
  326. },
  327. Coercion: {
  328. success: [
  329. {text: "Spend 2 extra successes to inflict one strain on target. ", required: 2}
  330. ],
  331. advantage: [
  332. {text: "Affect unexpected subjects beyond the original target.", required: 1}
  333. ],
  334. triumph: [
  335. {text: "Shift allegiance of target.", required: 1}
  336. ],
  337. threat: [
  338. {text: "Target has building resentment towards character.", required: 1}
  339. ],
  340. despair: [
  341. {text: "Reveal something about goals and motivations to target.", required: 1}
  342. ]
  343. },
  344. Computers: {
  345. success: [
  346. {text: "Reduce time required.", required: 1}
  347. ],
  348. advantage: [
  349. {text: "Uncover additional information about the system.", required: 1}
  350. ],
  351. triumph: [
  352. {
  353. text: "Obfuscate actions taken, add a $CHALLENGE$ to any check to detect or identify the characters actions.",
  354. required: 1
  355. }
  356. ],
  357. threat: [
  358. {
  359. text: "The character does a poor job of concealing his presence in the system. Security systems are alerted, and add $BOOST$ to the check of any NPC attempting to discover evidence of his actions.",
  360. required: 1
  361. }
  362. ],
  363. despair: [
  364. {
  365. text: "Leave behind trace information of your own system in the system being sliced. Add $BOOST$ to the check of any NPC using the target system to slice the character's system.",
  366. required: 1
  367. }
  368. ]
  369. },
  370. Cool: {
  371. advantage: [
  372. {text: "Gain an additional insight into the situation at hand.", required: 1}
  373. ],
  374. triumph: [
  375. {text: "Heal 3 strain.", required: 1}
  376. ],
  377. threat: [
  378. {text: "Miss a vital detail or event.", required: 1}
  379. ],
  380. despair: [
  381. {text: "The character is overwhelmed by the chaos and is stunned for one round.", required: 1}
  382. ]
  383. },
  384. Coordination: {
  385. success: [
  386. {text: "Reduce time required.", required: 1},
  387. {text: "Increase distance travelled by 25%, (maximum 100% increase).", required: 1}
  388. ],
  389. advantage: [
  390. {text: "Spend $ADVANTAGE$$ADVANTAGE$ to grant additional maneuver during turn.", required: 2}
  391. ],
  392. triumph: [
  393. {text: "Perform the check with truly impressive results.", required: 1}
  394. ],
  395. threat: [
  396. {text: "Lose free maneuver for one round.", required: 1}
  397. ],
  398. despair: [
  399. {text: "Suffer a wound", required: 1},
  400. {text: "Lose a vital piece of equipment.", required: 1}
  401. ]
  402. },
  403. Deception: {
  404. success: [
  405. {text: "Extend duration of Deceit action.", required: 1}
  406. ],
  407. advantage: [
  408. {text: "Increase the value of any goods or services gained through the action.", required: 1}
  409. ],
  410. triumph: [
  411. {
  412. text: "Fool the target into believing the character is trustworthy - future Deceit checks against target do not require an opposed check.",
  413. required: 1
  414. }
  415. ],
  416. threat: [
  417. {text: "Give away a portion of the lie, making target suspicious.", required: 1}
  418. ],
  419. despair: [
  420. {
  421. text: "Target realises he has been lied to and spreads word of his deceit to harm his reputation or uses the situation to his advantage.",
  422. required: 1
  423. }
  424. ]
  425. },
  426. Discipline: {
  427. success: [
  428. {text: "Downgrade difficulty of the dice pool for next action (max. 1).", required: 1}
  429. ],
  430. advantage: [
  431. {text: "Gain an additional insight into the situation at hand.", required: 1}
  432. ],
  433. triumph: [
  434. {
  435. text: "Add $BOOST$ to any Discipline checks made by allies during the following round.",
  436. required: 1
  437. }
  438. ],
  439. threat: [
  440. {
  441. text: "Undermine the characters resolve, perhaps inflicting a penalty on further actions in distressing circumstances.",
  442. required: 1
  443. }
  444. ],
  445. despair: [
  446. {
  447. text: "The character is overwhelmed entirely and is unable to perform more than one maneuver next round.",
  448. required: 1
  449. }
  450. ]
  451. },
  452. Leadership: {
  453. success: [
  454. {text: "Extend target's support for additional scenes.", required: 1},
  455. {text: "Increase efficiency or effectiveness of target during ordered actions.", required: 1}
  456. ],
  457. advantage: [
  458. {text: "Affect bystanders in addition to target.", required: 1}
  459. ],
  460. triumph: [
  461. {
  462. text: "Have target NPC become recurring character who decides to faithfully follow the acting character.",
  463. required: 1
  464. }
  465. ],
  466. threat: [
  467. {
  468. text: "Decrease the efficiency of ordered actions, causing them to take longer or be done poorly.",
  469. required: 1
  470. }
  471. ],
  472. despair: [
  473. {
  474. text: "Undermine the character's authority, damaging the characters ability to command target or those who witnessed the attempt.",
  475. required: 1
  476. },
  477. {
  478. text: "With multiple $DESPAIR$ the target may become a recurring thorn in the character's side,refusing future orders or turning others against the character.",
  479. required: 2
  480. }
  481. ]
  482. },
  483. Mechanics: {
  484. success: [
  485. {text: "Reduce time required by 10-20%", required: 1}
  486. ],
  487. advantage: [
  488. {
  489. text: "Grant $BOOST$ on checks when using repaired item, or even the Superior quality, for a session.",
  490. required: 1
  491. }
  492. ],
  493. triumph: [
  494. {text: "Give device additional single use function.", required: 1}
  495. ],
  496. threat: [
  497. {
  498. text: "Particularly shoddy repairs or temporary measures, the GM may spend $THREAT$ to cause the target object or system to malfunction shortly after check completed.",
  499. required: 1
  500. }
  501. ],
  502. despair: [
  503. {text: "Cause further harm to target object or system.", required: 1},
  504. {text: "Cause other components of target to malfunction.", required: 1}
  505. ]
  506. },
  507. Medicine: {
  508. success: [
  509. {text: "Target recovers one additional wound.", required: 1},
  510. {text: "Reduce healing time by one hour.", required: 1}
  511. ],
  512. advantage: [
  513. {text: "Eliminate one strain from target.", required: 1}
  514. ],
  515. triumph: [
  516. {
  517. text: "Heal additional wounds while attempting to heal Critical Injury, or vice versa.",
  518. required: 1
  519. }
  520. ],
  521. threat: [
  522. {text: "Inflict strain on the target due to shock of procedure.", required: 1},
  523. {text: "Increase time procedure takes.", required: 1}
  524. ],
  525. despair: [
  526. {text: "A truly terrible accident, perhaps inflicting further wounds on target.", required: 1}
  527. ]
  528. },
  529. Negotiation: {
  530. success: [
  531. {text: "Increase acting character's profit by 5%.", required: 1},
  532. {text: "Modify scope of agreement.", required: 1}
  533. ],
  534. advantage: [
  535. {
  536. text: "Earn unrelated boons from target, concessions if failed or extra perks if passed.",
  537. required: 1
  538. }
  539. ],
  540. triumph: [
  541. {text: "Have target NPC become regular client or specialist vendor.", required: 1}
  542. ],
  543.  
  544. threat: [
  545. {text: "Increase cost of goods purchased.", required: 1},
  546. {text: "Decrease value of goods sold.", required: 1},
  547. {text: "Shorten contracts negotiated.", required: 1}
  548. ],
  549. despair: [
  550. {
  551. text: "Seriously sabotage goals during the interaction, perhaps receive counterfeit goods or payment, or agree to terms entirely beyond scope of negotiation.",
  552. required: 1
  553. }
  554. ]
  555. },
  556. Perception: {
  557. success: [
  558. {text: "Reveal additional details.", required: 1}
  559. ],
  560. advantage: [
  561. {text: "Recall additional information associated with object noticed.", required: 1}
  562. ],
  563. triumph: [
  564. {
  565. text: "Notice details that can be useful later to gain $BOOST$ on future interactions with noticed object.",
  566. required: 1
  567. }
  568. ],
  569. threat: [
  570. {text: "Conceal a vital detail about situation or environment.", required: 1}
  571. ],
  572. despair: [
  573. {text: "Obtain false information about surroundings or target.", required: 1}
  574. ]
  575. },
  576. PilotingPlanetary: {
  577. success: [
  578. {text: "Gain insights into situation.", required: 1},
  579. {text: "Deduce way to modify vehicle to make it more effective in future.", required: 1}
  580. ],
  581. advantage: [
  582. {
  583. text: "Reveal vulnerability in opponent's piloting style or vehicle, giving benefit in later rounds.",
  584. required: 1
  585. }
  586. ],
  587. triumph: [
  588. {text: "Grant additional maneuver while continuing to pilot vehicle.", required: 1}
  589. ],
  590. threat: [
  591. {
  592. text: "Spend $THREAT$$THREAT$ to give opponents $BOOST$ on checks against character and vehicle due to momentary malfunction in system.",
  593. required: 2
  594. }
  595. ],
  596. despair: [
  597. {
  598. text: "Deal damage to vehicle as character strains systems throughout vehicle during check.",
  599. required: 1
  600. }
  601. ]
  602. },
  603. PilotingSpace: {
  604. success: [
  605. {text: "Gain insights into situation.", required: 1},
  606. {text: "Deduce way to modify vehicle to make it more effective in future.", required: 1}
  607. ],
  608. advantage: [
  609. {
  610. text: "Reveal vulnerability in opponent's piloting style or vehicle, giving benefit in later rounds.",
  611. required: 1
  612. }
  613. ],
  614. triumph: [
  615. {text: "Grant additional maneuver while continuing to pilot vehicle.", required: 1}
  616. ],
  617. threat: [
  618. {
  619. text: "Spend $THREAT$$THREAT$ to give opponents $BOOST$ on checks against character and vehicle due to momentary malfunction in system.",
  620. required: 2
  621. }
  622. ],
  623. despair: [
  624. {
  625. text: "Deal damage to vehicle as character strains systems throughout vehicle during check.",
  626. required: 1
  627. }
  628. ]
  629. },
  630. Resilience: {
  631. success: [
  632. {text: "Extend effects of the success to increase time between checks.", required: 1}
  633. ],
  634. advantage: [
  635. {text: "Identify way to reduce difficulty of future checks against same threat.", required: 1}
  636. ],
  637. triumph: [
  638. {text: "Recover 3 strain.", required: 1}
  639. ],
  640. threat: [
  641. {text: "Overburden the character, inflicting penalties on subsequent checks.", required: 1}
  642. ],
  643. despair: [
  644. {
  645. text: "Inflict a wound or minor Critical Injury on character, as they succumb to harsh conditions.",
  646. required: 1
  647. }
  648. ]
  649. },
  650. Skulduggery: {
  651. success: [
  652. {text: "Gain additional insights about nature of opposition.", required: 1}
  653. ],
  654. advantage: [
  655. {text: "Identify additional potential target.", required: 1}
  656. ],
  657. triumph: [
  658. {text: "Earn an unexpected boon.", required: 1}
  659. ],
  660. threat: [
  661. {
  662. text: "Opportunity to catch character immediately after act, number of $THREAT$ determine immediacy of discovery and ensuing danger.",
  663. required: 1
  664. }
  665. ],
  666. despair: [
  667. {text: "Leave behind evidence of larceny.", required: 1}
  668. ]
  669. },
  670. Stealth: {
  671. success: [
  672. {text: "Assist allied character infiltrating at same time.", required: 1}
  673. ],
  674. advantage: [
  675. {text: "Decrease time taken to perform action while hidden.", required: 1}
  676. ],
  677. triumph: [
  678. {text: "Identify way to completely distract opponent for duration of scene.", required: 1}
  679. ],
  680. threat: [
  681. {text: "Increase time taken to perform action while hidden by 20%.", required: 1}
  682. ],
  683. despair: [
  684. {text: "Leave behind evidence of passing, concerning identity and possibly motive.", required: 1}
  685. ]
  686. },
  687. Streetwise: {
  688. success: [
  689. {text: "Reduce time or funds required to obtain item, information or service.", required: 1}
  690. ],
  691. advantage: [
  692. {text: "Reveal additional rumours or alternative sources.", required: 1}
  693. ],
  694. triumph: [
  695. {text: "Gain semi-permanent contact on street.", required: 1}
  696. ],
  697. threat: [
  698. {text: "Seed gathered information with minor falsehoods.", required: 1}
  699. ],
  700. despair: [
  701. {text: "Character lets slip details about self or information sought.", required: 1}
  702. ]
  703. },
  704. Survival: {
  705. success: [
  706. {text: "Assist other character in surviving.", required: 1},
  707. {text: "Stockpile goods to increase time between checks.", required: 1}
  708. ],
  709. advantage: [
  710. {text: "Gain insight into environment to make future checks simpler.", required: 1},
  711. {
  712. text: "When tracking, learn significant detail about target, such as number, species or how recently tracks were made.",
  713. required: 1
  714. }
  715. ],
  716. triumph: [
  717. {
  718. text: "When handling domesticated animal, predispose animal towards character earning loyal companion.",
  719. required: 1
  720. },
  721. {text: "When tracking, learn vital clue about target.", required: 1}
  722. ],
  723. threat: [
  724. {text: "Spend vital resources (food, fuel, etc.) during check.", required: 1}
  725. ],
  726. despair: [
  727. {text: "Inflict wounds, Critical Injuries or large amounts of strain on character.", required: 1}
  728. ]
  729. },
  730. Vigilance: {
  731. success: [
  732. {text: "Character is particularly well prepared.", required: 1}
  733. ],
  734. advantage: [
  735. {text: "Notice key environmental factor.", required: 1}
  736. ],
  737. triumph: [
  738. {text: "Gain extra maneuver during first round of combat.", required: 1}
  739. ],
  740. threat: [
  741. {text: "Miss key piece of information about situation or environment.", required: 1}
  742. ],
  743. despair: [
  744. {
  745. text: "The character is unable to perform more than one maneuver during first round of combat.",
  746. required: 1
  747. }
  748. ]
  749. }
  750. },
  751. combat: {
  752. /*TODO continue working on the combat skill suggestions*/
  753. personal: {
  754. AllowedSkills: [
  755. "RangedLight",
  756. "RangedHeavy",
  757. "Melee",
  758. "Brawl",
  759. "Lightsaber",
  760. "Gunnery"
  761. ],
  762. '1advantage1triumph': [
  763. {text: "Recover 1 strain", advantage: 1, triumph: 1},
  764. {text: "Add $BOOST$ to the next allied active character's next check.", advantage: 1, triumph: 1},
  765. {text: "Notice a single important point in the ongoing conflict.", advantage: 1, triumph: 1},
  766. {
  767. text: "Inflict a Critical Injury with a successful attack that deals damage past soak. ($ADVANTAGE$ cost may vary)",
  768. advantage: 1,
  769. triumph: 1,
  770. crit: true
  771. }
  772. ],
  773. '2advantage1triumph': [
  774. {text: "Activate a weapon quality ($ADVANTAGE$ cost may vary)", advantage: 2, triumph: 1},
  775. {
  776. text: "Perform an immediate free maneuver that does not exceed the two maneuver per turn limit",
  777. advantage: 2,
  778. triumph: 1
  779. },
  780. {text: "Add $SETBACK$ to the targeted character's next check.", advantage: 2, triumph: 1},
  781. {
  782. text: "Add $BOOST$ to any allied character's next check, including that of the active character.",
  783. advantage: 2,
  784. triumph: 1
  785. }
  786. ],
  787. '3advantage1triumph': [
  788. {
  789. text: "Negate the targeted enemy's defensive bonuses until the end of turn",
  790. advantage: 3,
  791. triumph: 1
  792. },
  793. {
  794. text: "Ignore penalizing environmental effects until the end of the active character's next turn.",
  795. advantage: 3,
  796. triumph: 1
  797. },
  798. {
  799. text: "When dealing damage to a target, have the attack disable the opponent or one piece of gear rather than dealing wounds or strain.",
  800. advantage: 3,
  801. triumph: 1
  802. },
  803. {
  804. text: "Gain +1 melee or ranged defense until the end of the active character's next turn",
  805. advantage: 3,
  806. triumph: 1
  807. },
  808. {
  809. text: "Force the target to drop a melee or ranged weapon they are wielding.",
  810. advantage: 3,
  811. triumph: 1
  812. }
  813. ],
  814. '1triumph': [
  815. {text: "Upgrade the difficulty of the targeted character's next check.", triumph: 1},
  816. {
  817. text: "Upgrade any allied character's next check, including that of the current active character.",
  818. triumph: 1
  819. },
  820. {text: "Do something vital, such as shooting the controls to the nearby blast doors.", triumph: 1}
  821. ],
  822. '2triumph': [
  823. {
  824. text: "When dealing damage to a target, had the attack destroyed a piece of equipment the target is using.",
  825. triumph: 2
  826. }
  827. ],
  828. '1threat1despair': [
  829. {text: "The active character suffers 1 strain", threat: 1, despair: 1},
  830. {text: "The active character looses the benefits of a prior maneuver", threat: 1, despair: 1}
  831. ],
  832. '2threat1despair': [
  833. {text: "An opponent may immediately perform one free maneuver.", threat: 2, despair: 1},
  834. {text: "Add $BOOST$ to the targeted character's next check", threat: 2, despair: 1},
  835. {
  836. text: "The active character or an allied character suffers a $SETBACK$ on their next action.",
  837. threat: 2,
  838. despair: 1
  839. }
  840. ],
  841. '3threat1despair': [
  842. {text: "The active character falls prone.", threat: 3, despair: 1},
  843. {
  844. text: "The active character grants the enemy a significant advantage in the ongoing encounter.",
  845. threat: 3,
  846. despair: 1
  847. }
  848. ],
  849. '1despair': [
  850. {text: "The character's ranged weapon immediately runs out of ammunition.", despair: 1},
  851. {
  852. text: "Upgrade the difficulty of an allied character's next check, including the active character.",
  853. despair: 1
  854. },
  855. {text: "The tool or melee weapon the character is using becomes damaged.", despair: 1}
  856. ]
  857. },
  858. vehicle: {
  859. AllowedSkills: [
  860. "RangedHeavy",
  861. "Gunnery",
  862. "PilotingSpace",
  863. "PilotingPlanetary"
  864.  
  865. ],
  866. '1advantage1triumph': [
  867. {
  868. text: "Add $BOOST$ to the next allied active character's Piloting, Gunnery, Computers, or Mechanics check.",
  869. advantage: 1,
  870. triumph: 1
  871. },
  872. {text: "Notice a single important point in the ongoing conflict.", advantage: 1, triumph: 1},
  873. {
  874. text: "Inflict a Critical Hit with successful attack that deals damage past armor ($ADVANTAGE$ cost may vary)",
  875. advantage: 1,
  876. triumph: 1,
  877. crit: true
  878. }
  879. ],
  880. '2advantage1triumph': [
  881. {text: "Activate a weapon quality ($ADVANTAGE$ cost may vary", advantage: 2, triumph: 1},
  882. {
  883. text: "Perform an immediate free maneuver, provided the active character has not already performed two maneuvers in that turn.",
  884. advantage: 2,
  885. triumph: 1
  886. },
  887. {
  888. text: "Add $SETBACK$ to the targeted character's next Piloting or Gunnery check.",
  889. advantage: 2,
  890. triumph: 1
  891. },
  892. {
  893. text: "Add $BOOST$ to any allied character's next Piloting, Gunnery, Computers or Mechanics check, including the active character,",
  894. advantage: 2,
  895. triumph: 1
  896. }
  897. ],
  898. '3advantage1triumph': [
  899. {
  900. text: "When dealing damage to an opposing vehicle or ship, have the shot temporarily damage a component of the attacker's choice rather than deal hull damage or system strain.",
  901. advantage: 3,
  902. triumph: 1
  903. },
  904. {
  905. text: "Ignore penalizing terrain or stellar phenomena until the end of the active character's next turn.",
  906. advantage: 3,
  907. triumph: 1
  908. },
  909. {
  910. text: "If piloting the ship, perform one free Pilot Only maneuver (provided it does not break the limit of maximum number of Pilot Only maneuvers in a turn).",
  911. advantage: 3,
  912. triumph: 1
  913. },
  914. {
  915. text: "Force the target ship or vehicle to veer off, breaking any Aim or Stay on Target maneuvers.",
  916. advantage: 3,
  917. triumph: 1
  918. }
  919. ],
  920. '1triumph': [
  921. {
  922. text: "Upgrade the difficulty of the targeted character's next Piloting or Gunnery check.",
  923. triumph: 1
  924. },
  925. {
  926. text: "Upgrade any allied character's next Piloting, Gunnery, Computers or Mechanics check.",
  927. triumph: 1
  928. }
  929. ],
  930. '2triumph': [
  931. {text: "Destroy an important component when dealing damage.", triumph: 2}
  932. ],
  933. '1threat1despair': [
  934. {
  935. text: "If piloting a ship, sudden maneuvers force the ship to slow down by 1 point of speed.",
  936. threat: 1,
  937. despair: 1
  938. },
  939. {text: "The active character looses the benefits of a prior maneuver.", threat: 1, despair: 1},
  940. {
  941. text: "The character's active ship suffers 1 system strain. (This option may be selected multiple times)",
  942. threat: 1,
  943. despair: 1
  944. }
  945. ],
  946. '2threat1despair': [
  947. {text: "An opponent may immediately perform one free maneuver.", threat: 2, despair: 1},
  948. {
  949. text: "Add $BOOST$ to the targeted character's next Piloting or Gunnery Check",
  950. threat: 2,
  951. despair: 1
  952. },
  953. {
  954. text: "The active character or allied character suffers $SETBACK$ on their next action.",
  955. threat: 2,
  956. despair: 1
  957. }
  958. ],
  959. '3threat1despair': [
  960. {
  961. text: "The initiative currently being used drops below the last slot in the round.",
  962. threat: 3,
  963. despair: 1
  964. },
  965. {text: "The enemy gains a significant advantage in the ongoing encounter.", threat: 3, despair: 1},
  966. {
  967. text: "The primary weapon system of the active character's ship (or weapon the character is manning if acting as a gunner) suffers a Component Critical Hit.",
  968. despair: 1
  969. }
  970. ],
  971. '1despair': [
  972. {
  973. text: "Upgrade the difficulty of an allied character's next Gunnery, Piloting, computers or Mechanics check.",
  974. despair: 1
  975. },
  976. {
  977. text: "The active character's ship suffers a minor collision either with one of their opponents within close range or with the terrain around them.",
  978. despair: 1
  979. },
  980. {
  981. text: "The active character's ship suffers a major collision either with one of their opponents within close range or with the terrain around them.",
  982. despair: 1,
  983. failed: true
  984. }
  985. ]
  986. }
  987. }
  988. };
  989.  
  990. this.enum = {
  991. types: {
  992. general: {number:0, text:"general"},
  993. combat: {number:1, text:"combat"}
  994. },
  995. displayOptions: {
  996. none: {number:0, text:"none"}, // Suggestions are not displayed
  997. whisper: {number:1, text:"whisper"}, // Suggestions are whispered to the GM
  998. always: {number:2, text:"always"} // Suggestions are included in the dice roll result
  999. },
  1000. combatType: {
  1001. personal: {number:0, text:"personal"},
  1002. vehicle: {number:1, text:"vehicle"}
  1003. }
  1004. };
  1005.  
  1006. this.setDisplayOption = function (input) {
  1007. if (input == null || input === "")
  1008. return;
  1009.  
  1010. var flag = null;
  1011. if (flag = that.enum.isValidInput(input, that.enum.displayOptions))
  1012. flags.displayOption = flag;
  1013. };
  1014.  
  1015. this.getDisplayOption = function () {
  1016. return flags.displayOption;
  1017. };
  1018.  
  1019. this.setGeneralSuggestions = function (input) {
  1020. if (input == null || input === "")
  1021. return;
  1022. log("input="+input);
  1023.  
  1024. flags.generalSuggesting = convertToBoolean(input);
  1025. log("flags.generalSuggesting="+flags.generalSuggesting);
  1026. };
  1027.  
  1028. this.getGeneralSuggesting = function () {
  1029. return flags.generalSuggesting;
  1030. };
  1031.  
  1032. this.setCombatSuggestions = function (input) {
  1033. if (input == null || input === "")
  1034. return;
  1035. log("input="+input);
  1036. flags.combatSuggesting = convertToBoolean(input);
  1037. log("flags.combatSuggesting="+flags.combatSuggesting);
  1038. };
  1039.  
  1040. this.getCombatSuggesting = function () {
  1041. return flags.combatSuggesting;
  1042. };
  1043.  
  1044. this.setIsFearCheck = function (input) {
  1045. if (input == null || input === "")
  1046. return;
  1047.  
  1048. flags.isFearCheck = convertToBoolean(input);
  1049. };
  1050.  
  1051. this.getIsFearCheck = function () {
  1052. return flags.isFearCheck;
  1053. };
  1054.  
  1055. this.setCombatType = function (input) {
  1056. if (input == null || input === "") {
  1057. flags.combatType = null;
  1058. return;
  1059. }
  1060.  
  1061. var flag = null;
  1062. if (flag = that.enum.isValidInput(input, that.enum.combatType))
  1063. flags.combatType = flag;
  1064. };
  1065.  
  1066. this.getCombatType = function () {
  1067. return flags.combatType;
  1068. };
  1069.  
  1070. this.enum.isValidInput = function (input, enumToUse) {
  1071. if (input == null || input === "" || !enumToUse)
  1072. return;
  1073.  
  1074. var retVal = null;
  1075.  
  1076. Object.keys(enumToUse).some(function(key) {
  1077. var object = enumToUse[key];
  1078.  
  1079. if (input == object || input === object.text || input === object.number) {
  1080. return retVal = object;
  1081. }
  1082. });
  1083.  
  1084. return retVal;
  1085. };
  1086.  
  1087. this.enum.mapTextToNumber = function (input, enumToUse) {
  1088. if (input == null || input === "")
  1089. return;
  1090.  
  1091. var flag = null;
  1092. if (flag = that.enum.isValidInput(input, enumToUse))
  1093. return flag.number;
  1094. };
  1095.  
  1096. this.enum.mapNumberToText = function (input, enumToUse) {
  1097. if (input == null || input === "")
  1098. return;
  1099.  
  1100. var flag = null;
  1101. if (flag = that.enum.isValidInput(input, enumToUse))
  1102. return flag.text;
  1103. };
  1104.  
  1105.  
  1106. /* Suggestion Handling */
  1107. function addSkillSuggestionsFromArray (diceObj, array, key, rollResultForSymbol, suggestionsType) {
  1108. for (var i = 0; i < array.length; i++) {
  1109. if (array[i].required <= rollResultForSymbol) {
  1110. suggestionsType[key] += "<li>" + array[i].text + "</li>";
  1111. diceObj.vars.suggestions.suggestionsExist = true;
  1112. }
  1113. }
  1114. return diceObj;
  1115. }
  1116.  
  1117. function buildSuggestionSet (suggestionSet, symbol, rollResultForSymbol, suggestionJSON) {
  1118. if (suggestionSet == null)
  1119. suggestionSet = new Set();
  1120.  
  1121. var item = {};
  1122. for (var i = 0; i < suggestionJSON.length; i++) {
  1123. item = suggestionJSON[i];
  1124. if (item.hasOwnProperty(symbol) && item[symbol] <= rollResultForSymbol) {
  1125. suggestionSet.add(item.text);
  1126. }
  1127. }
  1128.  
  1129. return suggestionSet;
  1130. }
  1131.  
  1132. function buildCombatSuggestions (diceObj, symbol, rollResultForSymbol, suggestionJSON) {
  1133. var suggestionSet = null;
  1134. var spendingSuggestions = diceObj.vars.suggestions;
  1135. Object.keys(suggestionJSON).forEach(function(property) {
  1136. if (property === "AllowedSkills")
  1137. return;
  1138.  
  1139. suggestionSet = spendingSuggestions.combat[property];
  1140. suggestionSet = buildSuggestionSet(suggestionSet, symbol, rollResultForSymbol, suggestionJSON[property]);
  1141.  
  1142. if (suggestionSet.size > 0) {
  1143. spendingSuggestions.suggestionsExist = true;
  1144. spendingSuggestions.combat[property] = suggestionSet;
  1145. }
  1146. });
  1147.  
  1148. return diceObj;
  1149. }
  1150.  
  1151. function buildRollTemplateItem (key, value) {
  1152. return "{{" + key + "=<ul>" + value + "</ul>}}";
  1153. }
  1154.  
  1155. function generateSuggestions (diceObj, symbol, rollResultForSymbol) {
  1156. var skillName = diceObj.vars.skillName;
  1157.  
  1158. var combatType = flags.combatType;
  1159. if (flags.combatSuggesting && combatType) {
  1160. var combatSkills = that.suggestions.combat;
  1161. var personal = that.enum.combatType.personal;
  1162. var vehicle = that.enum.combatType.vehicle;
  1163. if (combatType == personal)
  1164. {
  1165. diceObj = buildCombatSuggestions(diceObj, symbol, rollResultForSymbol, combatSkills.personal);
  1166. }
  1167. else if (combatType == vehicle)
  1168. {
  1169. diceObj = buildCombatSuggestions(diceObj, symbol, rollResultForSymbol, combatSkills.vehicle);
  1170. }
  1171. } else if (flags.generalSuggesting) {
  1172. var generalSkills = that.suggestions.general;
  1173. if (generalSkills.hasOwnProperty(skillName)) {
  1174. var skill = generalSkills[skillName];
  1175. var fearJSON = (diceObj.vars.isFearCheck ? that.suggestions.special.fear : null);
  1176.  
  1177. if (skill.hasOwnProperty(symbol)) {
  1178. diceObj = addSkillSuggestionsFromArray(diceObj, skill[symbol], symbol, rollResultForSymbol, diceObj.vars.suggestions.general);
  1179. }
  1180.  
  1181. if (fearJSON && fearJSON.allowedSkills.indexOf(skillName)) {
  1182. diceObj = addSkillSuggestionsFromArray(diceObj, fearJSON[symbol], symbol, rollResultForSymbol, diceObj.vars.suggestions.general);
  1183. }
  1184. }
  1185. }
  1186. return diceObj;
  1187. }
  1188.  
  1189. this.processSuggestions = function(diceObj) {
  1190. if (flags.displayOption === that.enum.displayOptions.none)
  1191. return diceObj;
  1192.  
  1193. diceObj.vars.suggestions = {
  1194. general: {
  1195. success: "",
  1196. advantage: "",
  1197. triumph: "",
  1198. failure: "",
  1199. threat: "",
  1200. despair: ""
  1201. },
  1202. combat: {
  1203. '1advantage1triumph': null,
  1204. '2advantage1triumph': null,
  1205. '3advantage1triumph': null,
  1206. '1triumph': null,
  1207. '2triumph': null,
  1208. '1threat1despair': null,
  1209. '2threat1despair': null,
  1210. '3threat1despair': null,
  1211. '1despair': null,
  1212. '2despair': null
  1213. },
  1214. suggestionsExist: false
  1215. };
  1216.  
  1217.  
  1218. var failedCheck = !diceObj.totals.success > 0;
  1219. Object.keys(diceObj.totals).forEach(function(key) {
  1220. var rollResultForSymbol = diceObj.totals[key];
  1221. if (rollResultForSymbol > 0) {
  1222. diceObj = generateSuggestions(diceObj, key, rollResultForSymbol, failedCheck);
  1223. }
  1224. });
  1225.  
  1226. return diceObj;
  1227. };
  1228.  
  1229. this.buildSuggestionsRollTemplate = function (diceObj) {
  1230. var suggestions = diceObj.vars.suggestions;
  1231. var suggestionsRollTemplate = "";
  1232.  
  1233. // display results shown to character owners and GM
  1234. Object.keys(suggestions).forEach(function (property) {
  1235. if (property === "suggestionsExist")
  1236. return;
  1237.  
  1238. var propertyObject = suggestions[property];
  1239. Object.keys(propertyObject).forEach(function(symbol) {
  1240. var object = propertyObject[symbol];
  1241.  
  1242. if (!object)
  1243. return;
  1244.  
  1245. if (typeof object === "string")
  1246. suggestionsRollTemplate += buildRollTemplateItem(symbol, object);
  1247. else if (object.size > 0) {
  1248. var suggestionList = "";
  1249. object.forEach(function (value) {
  1250. suggestionList += "<li>" + value + "</li>";
  1251. });
  1252. suggestionsRollTemplate += buildRollTemplateItem(symbol, suggestionList);
  1253. }
  1254. });
  1255. });
  1256. return suggestionsRollTemplate;
  1257. }
  1258. }
  1259.  
  1260. /*TODO refactor eote to be swrpg*/
  1261. var eote = {};
  1262.  
  1263. eote.init = function () {
  1264. eote.setCharacterDefaults();
  1265. eote.createGMDicePool();
  1266. eote.events();
  1267. convertTokensToTags(suggestionEngine.suggestions, eote.defaults.graphics.SymbolicReplacement);
  1268. attemptRegisterGMObj();
  1269. };
  1270.  
  1271.  
  1272. eote.defaults = {
  1273. globalVars: {
  1274. diceLogChat: true,
  1275. diceGraphicsChat: true,
  1276. diceGraphicsChatSize: 30,//medium size
  1277. diceTextResult: "",
  1278. diceTextResultLog: "",
  1279. diceGraphicResult: "",
  1280. diceGraphicResultLog: "",
  1281. diceTestEnabled: false,
  1282. diceLogRolledOnOneLine: true,
  1283. scriptDebug: false
  1284. },
  1285. '-DicePoolID': '',
  1286. GMSheet: {
  1287. obj: null,
  1288. name: "-DicePool"
  1289. },
  1290. character: {
  1291. attributes: [
  1292. /* Don't need to update characterID
  1293. *
  1294. *{
  1295. name : "characterID",
  1296. current : "UPDATES TO CURRENT ID",
  1297. max : "",
  1298. update : false
  1299. }*/
  1300. ],
  1301. abilities: []
  1302. },
  1303. graphics: {
  1304. SIZE: {
  1305. SMALL: 20,
  1306. MEDIUM: 30,
  1307. LARGE: 40
  1308. },
  1309. ABILITY: {
  1310. BLANK: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/g3hoJRG.png",
  1311. A: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/VG7HnFE.png",
  1312. AA: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/ynn0deR.png",
  1313. S: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/HnweiQT.png",
  1314. SA: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/iVXuNKP.png",
  1315. SS: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/IVDgDKo.png"
  1316. },
  1317. BOOST: {
  1318. BLANK: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/nlIAfJx.png",
  1319. A: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/d6X6QEs.png",
  1320. AA: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/EqMcrlF.png",
  1321. S: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/vrt51oP.png",
  1322. SA: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/r9xl3CP.png"
  1323. },
  1324. CHALLENGE: {
  1325. BLANK: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/GInMHEN.png",
  1326. F: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/zKdsTV9.png",
  1327. FF: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/QcZXdpS.png",
  1328. FT: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/wxV072J.png",
  1329. T: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/n2rgehM.png",
  1330. TT: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/SaWvZMV.png",
  1331. DESPAIR: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/5EppLES.png"
  1332. },
  1333. DIFFICULTY: {
  1334. BLANK: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/oxbKghK.png",
  1335. F: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/rujbVt9.png",
  1336. FF: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/VUj86X2.png",
  1337. FT: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/l8rUPCX.png",
  1338. T: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/2gLDiqq.png",
  1339. TT: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/4wqEJsa.png"
  1340. },
  1341. FORCE: {
  1342. D: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/8kBnDI1.png",
  1343. DD: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/eki6Bnc.png",
  1344. L: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/JCI7Mgm.png",
  1345. LL: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/Z58SAHI.png"
  1346. },
  1347. PROFICIENCY: {
  1348. BLANK: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/4bQ0dY8.png",
  1349. A: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/PU7pp3w.png",
  1350. S: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/jXGG6L1.png",
  1351. SA: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/oQMDNdm.png",
  1352. SS: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/UDW3jYZ.png",
  1353. AA: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/jUA6PVw.png",
  1354. TRIUMPH: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/7zrDoEN.png"
  1355. },
  1356. SETBACK: {
  1357. BLANK: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/n9W07Lp.png",
  1358. F: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/jMV5VOB.png",
  1359. T: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/TYgM9LP.png"
  1360. },
  1361. SYMBOLS: {
  1362. A: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/Gav94H2.png",
  1363. S: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/z79ieDp.png",
  1364. T: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/o8EQ4z6.png",
  1365. F: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/y2qABhW.png",
  1366. TRIUMPH: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/1lJCfnB.png",
  1367. DESPAIR: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/rOEJlCc.png",
  1368. L: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/j5bV12H.png",
  1369. D: "https://imgsrv.roll20.net/?src=http%3A//i.imgur.com/AZ3lzVj.png"
  1370. },
  1371. SymbolicReplacement: {}
  1372. },
  1373. regex: {
  1374. cmd: /!eed/,
  1375. log: /log (on|multi|single|off)/,
  1376. debug: /debug (on|off)/,
  1377. graphics: /graphics (on|off|s|m|l)/,
  1378. test: /test/,
  1379. resetdice: /(resetgmdice|resetdice)/,
  1380. initiative: /\bnpcinit|\bpcinit/,
  1381. characterID: /characterID\((.*?)\)/,
  1382. rollPlayer: /rollPlayer(\(.*?\))/,
  1383. label: /label\((.*?)\)/,
  1384. skill: /skill\((.*?)\)/g,
  1385. fear: /fear (on|off)/,
  1386. suggestionDisplay: /suggestionDisplay (none|whisper|always)/,
  1387. opposed: /opposed\((.*?)\)/g,
  1388. upgrade: /upgrade\((.*?)\)/g,
  1389. downgrade: /downgrade\((.*?)\)/g,
  1390. gmdice: /\(gmdice\)/,
  1391. encum: /encum\((.*?)\)/g,
  1392. dice: /(-?\d{1,2}blk)\b|(-?\d{1,2}b)\b|(-?\d{1,2}g)\b|(-?\d{1,2}y)\b|(-?\d{1,2}p)\b|(-?\d{1,2}r)\b|(-?\d{1,2}w)\b|(-?\d{1,2}a)\b|(-?\d{1,2}s)|(-?\d{1,2}t)\b|(-?\d{1,2}f)/g,
  1393. crit: /crit\((.*?)\)/,
  1394. critShip: /critship\((.*?)\)/,
  1395. unusable: /unusableWeapon/,
  1396. destiny: /destiny (useDark|useLight|registerPlayer|sendUpdate|doRoll|clearPool)/,
  1397. combat: /combat\(personal|vehicle\)/
  1398. },
  1399. destinyListeners: []
  1400. };
  1401.  
  1402. var GMSheet = eote.defaults.GMSheet;
  1403. var suggestionEngine = new SuggestionEngine();
  1404.  
  1405. function buildReplacementObject (title, src, size) {
  1406. return {matcher: new RegExp("\\$" + title.toUpperCase() + "\\$","g"), replacer: '<img src="' + src + '" title="' + title + '" height="' + size + '" width="' + size + '"/>'};
  1407. }
  1408.  
  1409. // dice symbols
  1410. eote.defaults.graphics.SymbolicReplacement.success = buildReplacementObject("success", eote.defaults.graphics.SYMBOLS.S, eote.defaults.graphics.SIZE.SMALL);
  1411. eote.defaults.graphics.SymbolicReplacement.advantage = buildReplacementObject("advantage", eote.defaults.graphics.SYMBOLS.A, eote.defaults.graphics.SIZE.SMALL);
  1412. eote.defaults.graphics.SymbolicReplacement.triumph = buildReplacementObject("triumph", eote.defaults.graphics.SYMBOLS.TRIUMPH, eote.defaults.graphics.SIZE.SMALL);
  1413. eote.defaults.graphics.SymbolicReplacement.failure = buildReplacementObject("failure", eote.defaults.graphics.SYMBOLS.F, eote.defaults.graphics.SIZE.SMALL);
  1414. eote.defaults.graphics.SymbolicReplacement.threat = buildReplacementObject("threat", eote.defaults.graphics.SYMBOLS.T, eote.defaults.graphics.SIZE.SMALL);
  1415. eote.defaults.graphics.SymbolicReplacement.despair = buildReplacementObject("despair", eote.defaults.graphics.SYMBOLS.DESPAIR, eote.defaults.graphics.SIZE.SMALL);
  1416.  
  1417. // dice icons
  1418. eote.defaults.graphics.SymbolicReplacement.ability = buildReplacementObject("ability", eote.defaults.graphics.ABILITY.BLANK, eote.defaults.graphics.SIZE.SMALL);
  1419. eote.defaults.graphics.SymbolicReplacement.boost = buildReplacementObject("boost", eote.defaults.graphics.BOOST.BLANK, eote.defaults.graphics.SIZE.SMALL);
  1420. eote.defaults.graphics.SymbolicReplacement.proficiency = buildReplacementObject("proficiency", eote.defaults.graphics.PROFICIENCY.BLANK, eote.defaults.graphics.SIZE.SMALL);
  1421. eote.defaults.graphics.SymbolicReplacement.difficulty = buildReplacementObject("difficulty", eote.defaults.graphics.DIFFICULTY.BLANK, eote.defaults.graphics.SIZE.SMALL);
  1422. eote.defaults.graphics.SymbolicReplacement.setback = buildReplacementObject("setback", eote.defaults.graphics.SETBACK.BLANK, eote.defaults.graphics.SIZE.SMALL);
  1423. eote.defaults.graphics.SymbolicReplacement.challenge = buildReplacementObject("challenge", eote.defaults.graphics.CHALLENGE.BLANK, eote.defaults.graphics.SIZE.SMALL);
  1424.  
  1425. function attemptRegisterGMObj() {
  1426. var GMObj = GMSheet.obj;
  1427.  
  1428. // if the GMObj is null then it means that this is the first time this version of the script is being run on this campaign.
  1429. if (!GMObj) {
  1430. GMObj = findObjs({
  1431. _type: "character",
  1432. name: GMSheet.name
  1433. });
  1434. if (GMObj.length > 0) {
  1435. GMSheet.obj = GMObj[0];
  1436. eote.process.logger("attemptRegisterGMObj", "Registering of GMObj successful");
  1437. }
  1438. else {
  1439. var msg = "The character sheet called " + GMSheet.name + " was not found in your campaign.";
  1440. eote.process.logger("attemptRegisterGMObj", msg);
  1441. sendChat("System", "/w gm " + msg);
  1442. }
  1443. } else {
  1444. eote.process.logger("attemptRegisterGMObj", "GMObj previously registered.");
  1445. }
  1446. }
  1447.  
  1448. eote.createGMDicePool = function () {
  1449.  
  1450. var charObj_DicePool = findObjs({ _type: "character", name: "-DicePool" })[0];
  1451. var attrObj_DicePool = [
  1452. {
  1453. name: 'pcgm',
  1454. current: 3,
  1455. max: '',
  1456. update: true
  1457. },
  1458. {
  1459. name: 'gmdicepool',
  1460. current: 2,
  1461. max: '',
  1462. update: true
  1463. }
  1464. ];
  1465. //create character -DicePool
  1466. if (!charObj_DicePool) {
  1467. charObj_DicePool = createObj("character", {
  1468. name: GMSheet.name,
  1469. bio: "GM Dice Pool"
  1470. });
  1471. }
  1472. eote.defaults['-DicePoolID'] = charObj_DicePool.id;
  1473. GMSheet.obj = charObj_DicePool;
  1474. eote.updateAddAttribute(charObj_DicePool, attrObj_DicePool);
  1475. };
  1476.  
  1477. eote.createObj = function () {//Create Object Fix - Firebase.set failed
  1478. var obj = createObj.apply(this, arguments);
  1479. var id = obj.id;
  1480. var characterID = obj.get('characterid');
  1481. var type = obj.get('type');
  1482. if (obj && !obj.fbpath && obj.changed) {
  1483. obj.fbpath = obj.changed._fbpath.replace(/([^\/]*\/){4}/, "/");
  1484. } else if (obj && !obj.changed && type == 'attribute') { //fix for dynamic attribute after in character created in game
  1485. obj.fbpath = '/char-attribs/char/' + characterID + '/' + id;
  1486. // /char-attribs/char/characterID/attributeID
  1487. }
  1488. return obj;
  1489. };
  1490.  
  1491. eote.setCharacterDefaults = function (characterObj) {
  1492.  
  1493. var charObj = [characterObj];
  1494.  
  1495. if (!characterObj) {
  1496. charObj = findObjs({ _type: "character" });
  1497. }
  1498. //add/update characterID field
  1499. _.each(charObj, function (charObj) {
  1500. //updates default attr:CharacterID to current character id
  1501. //_.findWhere(eote.defaults.character.attributes, {'name':'characterID'}).current = charObj.id;
  1502.  
  1503. //Attributes
  1504. eote.updateAddAttribute(charObj, eote.defaults.character.attributes);//Update Add Attribute defaults
  1505. //Abilities
  1506. });
  1507. };
  1508.  
  1509. eote.updateListeners = function (attributes) {
  1510.  
  1511. _.each(eote.defaults.destinyListeners, function (charID) {
  1512.  
  1513. var charObj = findObjs({
  1514. _type: "character",
  1515. _id: charID
  1516. });
  1517. //add/update characterID field
  1518. _.each(charObj, function (charObj) {
  1519. //Attributes
  1520. eote.updateAddAttribute(charObj, attributes); //Update Add Attribute defaults
  1521. });
  1522. });
  1523. //Update GM
  1524. var GMObj = findObjs({
  1525. _type: "character",
  1526. name: GMSheet.name
  1527. });
  1528. GMSheet.obj = GMSheet.obj || GMObj;
  1529. eote.updateAddAttribute(GMObj, attributes);
  1530. };
  1531.  
  1532. eote.updateAddAttribute = function (charactersObj, updateAddAttributesObj) { // charactersObj = object or array objects, updateAddAttributesObj = object or array objects
  1533. if (!charactersObj) {
  1534. log("error: charactersObj passed into eote.updateAddAttribute is not set");
  1535. return;
  1536. }
  1537.  
  1538. //check if object or array
  1539. if (!_.isArray(charactersObj)) {
  1540. charactersObj = [charactersObj];
  1541. }
  1542. if (!_.isArray(updateAddAttributesObj)) {
  1543. updateAddAttributesObj = [updateAddAttributesObj];
  1544. }
  1545. _.each(charactersObj, function (characterObj) {//loop characters
  1546.  
  1547. var characterName = '';
  1548.  
  1549. if (characterObj.name) {
  1550. characterName = characterObj.name;
  1551. } else {
  1552. characterName = characterObj.get('name');
  1553. }
  1554. //find attribute via character ID
  1555. var characterAttributesObj = findObjs({ _type: "attribute", characterid: characterObj.id });
  1556.  
  1557. if (updateAddAttributesObj.length != 0) {
  1558.  
  1559. log('UPDATE/ADD ATTRIBUTES FOR:----------------------->' + characterName);
  1560.  
  1561. _.each(updateAddAttributesObj, function (updateAddAttrObj) { //loop attributes to update / add
  1562.  
  1563. attr = _.find(characterAttributesObj, function (a) {
  1564. return (a.get('name') === updateAddAttrObj.name);
  1565. });
  1566. if (attr) {
  1567. if (updateAddAttrObj.update) {
  1568. log('Update Attr: ' + updateAddAttrObj.name);
  1569. attr.set({ current: updateAddAttrObj.current });
  1570. attr.set({ max: updateAddAttrObj.max ? updateAddAttrObj.max : '' });
  1571. }
  1572. } else {
  1573. // log('Add Attr: '+ updateAddAttrObj.name);
  1574. eote.createObj('attribute', {
  1575. characterid: characterObj.id,
  1576. name: updateAddAttrObj.name,
  1577. current: updateAddAttrObj.current,
  1578. max: updateAddAttrObj.max ? updateAddAttrObj.max : ''
  1579. });
  1580. }
  1581. });
  1582. }
  1583. });
  1584. };
  1585.  
  1586. /* DICE PROCESS
  1587. *
  1588. * Matches the different regex commands and runs that dice processing step
  1589. * The order of step should not be change or dice could be incorrectly rolled.
  1590. * example: All dice needs to be 'upgraded" before it can be 'downgraded'
  1591. * ---------------------------------------------------------------- */
  1592.  
  1593. eote.defaults.dice = function () {
  1594. this.vars = {
  1595. characterName: '',
  1596. characterID: '',
  1597. playerName: '',
  1598. playerID: '',
  1599. label: '',
  1600. suggestions: {},
  1601. skillName: '',
  1602. isFearCheck: false,
  1603. combatCheck: false
  1604. };
  1605. this.totals = {
  1606. success: 0,
  1607. failure: 0,
  1608. advantage: 0,
  1609. threat: 0,
  1610. triumph: 0,
  1611. despair: 0,
  1612. light: 0,
  1613. dark: 0
  1614. };
  1615. this.graphicsLog = {
  1616. Boost: '',
  1617. Ability: '',
  1618. Proficiency: '',
  1619. SetBack: '',
  1620. Difficulty: '',
  1621. Challenge: '',
  1622. Force: '',
  1623. Success: '',
  1624. Advantage: '',
  1625. Threat: '',
  1626. Failure: ''
  1627. };
  1628. this.textLog = {
  1629. Boost: '',
  1630. Ability: '',
  1631. Proficiency: '',
  1632. SetBack: '',
  1633. Difficulty: '',
  1634. Challenge: '',
  1635. Force: '',
  1636. Success: '',
  1637. Advantage: '',
  1638. Threat: '',
  1639. Failure: ''
  1640. };
  1641. this.count = {
  1642. boost: 0,
  1643. ability: 0,
  1644. proficiency: 0,
  1645. setback: 0,
  1646. difficulty: 0,
  1647. challenge: 0,
  1648. force: 0,
  1649. success: 0,
  1650. advantage: 0,
  1651. threat: 0,
  1652. failure: 0
  1653. }
  1654. };
  1655.  
  1656. eote.process = {};
  1657.  
  1658. eote.process.logger = function (functionName, cmd) {
  1659. if (eote.defaults.globalVars.debugScript) {
  1660. log(functionName + ' : ' + cmd);
  1661. }
  1662. };
  1663.  
  1664. eote.process.setup = function (cmd, playerName, playerID) {
  1665.  
  1666. if (!cmd.match(eote.defaults.regex.cmd)) { //check for api cmd !eed
  1667. return false;
  1668. }
  1669. var debugMatch = cmd.match(eote.defaults.regex.debug);
  1670. if (debugMatch) {
  1671. eote.process.debug(debugMatch);
  1672. return false;
  1673. }
  1674. var fearMatch = cmd.match(eote.defaults.regex.fear);
  1675. if (fearMatch) {
  1676. eote.process.fear(fearMatch);
  1677. return false;
  1678. }
  1679.  
  1680. var suggestionDisplayMatch = cmd.match(eote.defaults.regex.suggestionDisplay);
  1681. if (suggestionDisplayMatch) {
  1682. eote.process.suggestionDisplay(suggestionDisplayMatch);
  1683. return false;
  1684. }
  1685.  
  1686. eote.process.logger("eote.process.setup", "NEW ROLL");
  1687. eote.process.logger("eote.process.setup", "Original Command: " + cmd);
  1688.  
  1689. /* reset dice - test, might not need this */
  1690. var diceObj = new eote.defaults.dice();
  1691. diceObj.vars.playerName = playerName;
  1692. diceObj.vars.playerID = playerID;
  1693.  
  1694. /* Dice config
  1695. * Description: Change dice roller default config
  1696. * --------------------------------------------------------------*/
  1697. var logMatch = cmd.match(eote.defaults.regex.log);
  1698.  
  1699. if (logMatch) {
  1700. eote.process.log(logMatch);
  1701. return false; //Stop current roll and run test
  1702. }
  1703. var graphicsMatch = cmd.match(eote.defaults.regex.graphics);
  1704.  
  1705. if (graphicsMatch) {
  1706. eote.process.graphics(graphicsMatch);
  1707. return false; //Stop current roll and run test
  1708. }
  1709. var testMatch = cmd.match(eote.defaults.regex.test);
  1710.  
  1711. if (testMatch) {
  1712. eote.process.test(testMatch);
  1713. return false; //Stop current roll and run test
  1714. }
  1715. /* Roll information
  1716. * Description: Set default dice roll information Character Name and Skill Label
  1717. * --------------------------------------------------------------*/
  1718.  
  1719. var rollPlayerMatch = cmd.match(eote.defaults.regex.rollPlayer);
  1720.  
  1721. if (rollPlayerMatch) {
  1722. diceObj = eote.process.rollPlayer(rollPlayerMatch, diceObj);
  1723.  
  1724. if (!diceObj) {
  1725. return false;
  1726. }
  1727. }
  1728. var characterIDMatch = cmd.match(eote.defaults.regex.characterID);
  1729.  
  1730. if (characterIDMatch) {
  1731. diceObj = eote.process.characterID(characterIDMatch, diceObj);
  1732. //Once Character ID is parsed, remove it from the cmd.
  1733. //it is possible that the character ID could contain dice values
  1734. //for ex. characterID(-JMBFmYX1i0L259bjb-X) will add 59 blue dice to the pool
  1735. cmd = cmd.replace(characterIDMatch[0], '');
  1736. eote.process.logger("eote.process.setup.characterIDMatch", "New command: " + cmd);
  1737. }
  1738. var unusableMatch = cmd.match(eote.defaults.regex.unusable);
  1739.  
  1740. if (unusableMatch) {
  1741. eote.process.logger("eote.process.setup.unusableMatch", "Roll ended because of unusable weapon");
  1742. sendChat(diceObj.vars.characterName, "&{template:base} {{title=" + diceObj.vars.characterName + "}} {{wide=Weapon is too damaged to be used. Try repairing it.}}");
  1743. return false;
  1744. }
  1745. var labelMatch = cmd.match(eote.defaults.regex.label);
  1746.  
  1747. if (labelMatch) {
  1748. diceObj = eote.process.label(labelMatch, diceObj);
  1749. }
  1750. /* Dice rolls
  1751. * Description: Create dice pool before running any custom roll
  1752. * script commands that may need dice evaluated.
  1753. * --------------------------------------------------------------*/
  1754. var gmdiceMatch = cmd.match(eote.defaults.regex.gmdice);
  1755.  
  1756. if (gmdiceMatch) {
  1757. cmd = eote.process.gmdice(cmd); // update the cmd string to contain the gmdice
  1758. eote.process.logger("eote.process.setup.gmDice", "New command: " + cmd);
  1759. }
  1760. var encumMatch = cmd.match(eote.defaults.regex.encum);
  1761.  
  1762. if (encumMatch) {
  1763. diceObj = eote.process.encum(encumMatch, diceObj);
  1764. //eote.process.logger("eote.process.setup.encumMatch","New dice:" + diceObj);
  1765. }
  1766.  
  1767. var combatMatch = cmd.match(eote.defaults.regex.combat);
  1768. if (combatMatch) {
  1769. suggestionEngine.setCombatType(cmd[1]);
  1770. } else {
  1771. suggestionEngine.setCombatType(null);
  1772. }
  1773.  
  1774. var skillMatch = cmd.match(eote.defaults.regex.skill);
  1775. if (skillMatch) {
  1776. suggestionEngine.setIsFearCheck(getAttrByName(GMSheet.obj.id, "skill_suggestion_setting_fear"));
  1777. var CombatSuggestions = getAttrByName(GMSheet.obj.id, "skill_suggestion_setting_combat");
  1778. log("CombatSuggestions="+CombatSuggestions);
  1779. suggestionEngine.setCombatSuggestions(getAttrByName(GMSheet.obj.id, "skill_suggestion_setting_combat"));
  1780. var generalSuggestions = getAttrByName(GMSheet.obj.id, "skill_suggestion_setting_general");
  1781. log("generalSuggestions="+generalSuggestions);
  1782. suggestionEngine.setGeneralSuggestions(generalSuggestions);
  1783. suggestionEngine.setIsFearCheck(getAttrByName(GMSheet.obj.id, "skill_suggestion_setting_fear"));
  1784.  
  1785. suggestionEngine.setDisplayOption(getAttrByName(GMSheet.obj.id, "skill_suggestion_setting_display"));
  1786. diceObj = eote.process.skill(skillMatch, diceObj);
  1787. }
  1788.  
  1789. var opposedMatch = cmd.match(eote.defaults.regex.opposed);
  1790. if (opposedMatch) {
  1791. diceObj = eote.process.opposed(opposedMatch, diceObj);
  1792. }
  1793.  
  1794. var diceMatch = cmd.match(eote.defaults.regex.dice);
  1795. if (diceMatch) {
  1796. diceObj = eote.process.setDice(diceMatch, diceObj);
  1797. }
  1798.  
  1799. var upgradeMatch = cmd.match(eote.defaults.regex.upgrade);
  1800. if (upgradeMatch) {
  1801. diceObj = eote.process.upgrade(upgradeMatch, diceObj);
  1802. }
  1803.  
  1804. var downgradeMatch = cmd.match(eote.defaults.regex.downgrade);
  1805. if (downgradeMatch) {
  1806. diceObj = eote.process.downgrade(downgradeMatch, diceObj);
  1807. }
  1808.  
  1809. /* Roll dice and update success / fail
  1810. * ------------------------------------------------------------- */
  1811. diceObj = eote.process.rollDice(diceObj);
  1812.  
  1813. // process and display skill suggestions
  1814. if (diceObj.vars.skillName != null || suggestionEngine.getCombatType() != null) {
  1815. diceObj = suggestionEngine.processSuggestions(diceObj);
  1816. }
  1817.  
  1818. /* Custom rolls
  1819. * Description: Custom dice components have their own message, results and
  1820. * often will return false to not allow proceeding scripts to fire
  1821. * --------------------------------------------------------------*/
  1822. var resetdiceMatch = cmd.match(eote.defaults.regex.resetdice);
  1823.  
  1824. if (resetdiceMatch) {
  1825. eote.process.resetdice(resetdiceMatch, diceObj);
  1826. return false;
  1827. }
  1828. var initiativeMatch = cmd.match(eote.defaults.regex.initiative);
  1829.  
  1830. if (initiativeMatch) {
  1831. eote.process.initiative(initiativeMatch, diceObj);
  1832. //return false;
  1833. }
  1834. var destinyMatch = cmd.match(eote.defaults.regex.destiny);
  1835.  
  1836. if (destinyMatch) {
  1837. eote.process.logger("eote.process.setup.destiny", "Destiny Point Command");
  1838. var doRoll = eote.process.destiny(destinyMatch, diceObj);
  1839. if (!doRoll) {
  1840. return false;
  1841. }
  1842. }
  1843. var critMatch = cmd.match(eote.defaults.regex.crit);
  1844.  
  1845. if (critMatch) {
  1846. eote.process.crit(critMatch, diceObj);
  1847. return false;
  1848. }
  1849. var critShipMatch = cmd.match(eote.defaults.regex.critShip);
  1850.  
  1851. if (critShipMatch) {
  1852. eote.process.crit(critShipMatch, diceObj);
  1853. return false;
  1854. }
  1855.  
  1856. /* Display dice output in chat window
  1857. * ------------------------------------------------------------- */
  1858. eote.process.diceOutput(diceObj, playerName, playerID);
  1859. };
  1860.  
  1861. /* DICE PROCESS FUNCTION
  1862. *
  1863. * ---------------------------------------------------------------- */
  1864.  
  1865.  
  1866.  
  1867. eote.process.log = function (cmd) {
  1868.  
  1869. /* Log
  1870. * default: 'on' and 'single'
  1871. * Description: Sets the visual output in the chat window for the dice rolls
  1872. * Command: !eed log on|off|multi|single
  1873. * ---------------------------------------------------------------- */
  1874.  
  1875. switch (cmd[1]) {
  1876. case "on": //if 'on' outputs dice to chat window
  1877. eote.defaults.globalVars.diceLogChat = true;
  1878. sendChat("Dice System", 'Output rolled dice to chat window "On"');
  1879. break;
  1880. case "off": //if 'off' outputs only results to chat window
  1881. eote.defaults.globalVars.diceLogChat = false;
  1882. sendChat("Dice System", 'Output rolled dice to chat window "Off"');
  1883. break;
  1884. case "multi": //if 'multi' multiple sets dice per line
  1885. eote.defaults.globalVars.diceLogRolledOnOneLine = false;
  1886. sendChat("Dice System", 'Multiple line output "Off". NOTE: This setting can cause issues with the Roll Templates. Recommended setting is !eed log single');
  1887. break;
  1888. case "single": //if 'single' single set of dice per line
  1889. eote.defaults.globalVars.diceLogRolledOnOneLine = true;
  1890. sendChat("Dice System", 'Multiple line output "On"');
  1891. break;
  1892. }
  1893. };
  1894.  
  1895. eote.process.debug = function (cmd) {
  1896. switch (cmd[1]) {
  1897. case "on":
  1898. eote.defaults.globalVars.debugScript = true;
  1899. sendChat("Dice System", 'Debug Script "On"');
  1900. break;
  1901. case "off":
  1902. eote.defaults.globalVars.debugScript = false;
  1903. sendChat("Dice System", 'Debug Script "Off"');
  1904. break;
  1905. }
  1906. };
  1907.  
  1908. eote.process.fear = function (cmd) {
  1909.  
  1910. /* Fear
  1911. * Description: Sets the state of the Fear check status on the DicePool
  1912. * Command: !eed fear on|off
  1913. * ---------------------------------------------------------------- */
  1914.  
  1915. var value = null;
  1916. switch (cmd[1]) {
  1917. case "off":
  1918. value = 0;
  1919. break;
  1920. case "on":
  1921. value = 1;
  1922. break;
  1923. }
  1924.  
  1925. if (value != null) {
  1926. eote.updateAddAttribute(GMSheet.obj, {
  1927. name: "skill_suggestion_setting_fear",
  1928. current: value,
  1929. update: true
  1930. });
  1931. }
  1932. };
  1933.  
  1934. eote.process.suggestionDisplay = function (cmd) {
  1935.  
  1936. /* SuggestionDisplay
  1937. * Description: Sets the state of the skill_suggestion_setting_display check status on the DicePool
  1938. * Command: !eed suggestionDisplay none|whisper|always
  1939. * ---------------------------------------------------------------- */
  1940.  
  1941. /*TODO fix why suggestionDisplay is no longer working*/
  1942. var value = (suggestionEngine.enum.displayOptions.hasOwnProperty(cmd[1]) ? cmd[1] : null);
  1943.  
  1944. if (value != null) {
  1945. eote.updateAddAttribute(GMSheet.obj, {
  1946. name: "skill_suggestion_setting_display",
  1947. current: value,
  1948. update: true
  1949. });
  1950. } else {
  1951. sendChat("Error", "/w gm " + cmd[1] + " is not a valid argument for suggestionDisplay.");
  1952. }
  1953. };
  1954.  
  1955. eote.process.graphics = function (cmd) {
  1956.  
  1957. /* Graphics
  1958. * default: 'on' and 'm'
  1959. * Description: Sets chat window dice output as graphic, small, medium, or large if "on" or as text if "off"
  1960. * Command: !eed graphics on|off|s|m|l
  1961. * ---------------------------------------------------------------- */
  1962.  
  1963. //log(cmd[1]);
  1964. switch (cmd[1]) {
  1965. case "on":
  1966. eote.defaults.globalVars.diceGraphicsChat = true;
  1967. sendChat("Dice System", 'Chat graphics "On"');
  1968. break;
  1969. case "off":
  1970. eote.defaults.globalVars.diceGraphicsChat = false;
  1971. sendChat("Dice System", 'Chat graphics "Off"');
  1972. break;
  1973. case "s":
  1974. eote.defaults.globalVars.diceGraphicsChatSize = eote.defaults.graphics.SIZE.SMALL;
  1975. sendChat("Dice System", 'Chat graphics size "Small"');
  1976. break;
  1977. case "m":
  1978. eote.defaults.globalVars.diceGraphicsChatSize = eote.defaults.graphics.SIZE.MEDIUM;
  1979. sendChat("Dice System", 'Chat graphics size "Medium"');
  1980. break;
  1981. case "l":
  1982. eote.defaults.globalVars.diceGraphicsChatSize = eote.defaults.graphics.SIZE.LARGE;
  1983. sendChat("Dice System", 'Chat graphics size "Large"');
  1984. break;
  1985. }
  1986. };
  1987.  
  1988. eote.process.test = function (cmd) {
  1989.  
  1990. eote.process.logger("eote.process.test", cmd);
  1991.  
  1992. //Set test vars to true
  1993. eote.defaults.globalVars.diceTestEnabled = true;
  1994. tmpLogChat = eote.defaults.globalVars.diceLogChat;
  1995. tmpGraphicsChat = eote.defaults.globalVars.diceGraphicsChat;
  1996. eote.defaults.globalVars.diceLogChat = true;
  1997. eote.defaults.globalVars.diceGraphicsChat = true;
  1998.  
  1999. //Roll dice
  2000. eote.process.setup('!eed 1b 1g 1y 1blk 1p 1r 1w', 'GM', 'Dice Test');
  2001.  
  2002. //After test reset vars back
  2003. eote.defaults.globalVars.diceTestEnabled = false;
  2004. eote.defaults.globalVars.diceLogChat = tmpLogChat;
  2005. eote.defaults.globalVars.diceGraphicsChat = tmpGraphicsChat;
  2006. };
  2007.  
  2008. eote.process.rollPlayer = function (cmd, diceObj) {
  2009. //Build cmd string
  2010. //get characterID
  2011. //get skills
  2012. //get encum
  2013. //remove rollPlayer(xxxx) from string
  2014. var match = {
  2015. skill: /skill:(.*?)[\|\)]/,
  2016. encum: /encum/,
  2017. character: /character:(.*?)[\|\)]/
  2018. };
  2019. var characterMatch = cmd[1].match(match.character);
  2020.  
  2021. var companion = null;
  2022. var character = null;
  2023. if (characterMatch) {
  2024. var charObj = findObjs({ _type: "character", name: characterMatch[1] });
  2025.  
  2026. if (charObj.length > 0) {
  2027. diceObj.vars.characterName = charObj[0].get('name');
  2028. diceObj.vars.characterID = charObj[0].id;
  2029. }
  2030. else {
  2031. sendChat("Alert", "Can't find character. Please update character, or npc, name field to match sheet character name and try again.");
  2032. return false;
  2033. }
  2034. }
  2035. else {
  2036. sendChat("Alert", "Please update character, or npc, name field.");
  2037. return false;
  2038. }
  2039. var encumMatch = cmd[1].match(match.encum);
  2040. var attr_1 = null;
  2041. var attr_2 = null;
  2042. if (encumMatch) {
  2043. //encumbrance
  2044. attr_1 = getAttrByName(diceObj.vars.characterID, 'encumbrance', 'max');
  2045. attr_2 = getAttrByName(diceObj.vars.characterID, 'encumbrance');
  2046. var cmdEncum = ['encum(' + attr_1 + '|' + attr_2 + ')']; //["encum(3|5)"]
  2047.  
  2048. diceObj = eote.process.encum(cmdEncum, diceObj);
  2049. }
  2050. var skillMatch = cmd[1].match(match.skill);
  2051. if (eote.defaults.globalVars.debugScript) sendChat("Alert", "skillmatch=" + skillMatch.toString());
  2052.  
  2053. if (skillMatch) {
  2054.  
  2055. var attrArray = skillMatch[1].split(',');
  2056. attr_1 = getAttrByName(diceObj.vars.characterID, attrArray[0]);
  2057. attr_2 = getAttrByName(diceObj.vars.characterID, attrArray[1]);
  2058.  
  2059. if (eote.defaults.globalVars.debugScript) {
  2060. sendChat("Alert", "attr_1 = " + attr_1);
  2061. sendChat("Alert", "attr_2 = " + attr_2);
  2062. }
  2063.  
  2064. var cmdSkill;
  2065. if(!isNaN((parseFloat(attr_1)) && isFinite(attr_1))) { // is numeric
  2066. cmdSkill = ['skill(' + attr_1 + '|' + attr_2 + ')']; //['skill(0|2)']
  2067. } else {
  2068. var attr_3 = getAttrByName(diceObj.vars.characterID, attr_1.substr(2,attr_1.length-3));
  2069. cmdSkill = ['skill(' + attr_3 + '|' + attr_2 + ')']; //['skill(0|2)']
  2070. }
  2071.  
  2072. diceObj = eote.process.skill(cmdSkill, diceObj);
  2073. }
  2074. return diceObj;
  2075. };
  2076.  
  2077. eote.process.destiny = function (cmd, diceObj) {
  2078.  
  2079. var charObj_DicePool = findObjs({ _type: "character", name: "-DicePool" })[0];
  2080. var doRoll = false;
  2081.  
  2082. if (!charObj_DicePool) {
  2083. sendChat("GM", "/w " + "gm The DicePool character sheet could not be found! Re-save this script and it should be recreated. In the future do not rename the -DicePool Character Sheet.");
  2084. return doRoll;
  2085. }
  2086. //GM's Destiny Point Pool
  2087. var currentLightSidePoints = findObjs({
  2088. _characterid: charObj_DicePool.get("_id"),
  2089. _type: "attribute",
  2090. _name: "lightSidePoints"
  2091. });
  2092. var currentDarkSidePoints = findObjs({
  2093. _characterid: charObj_DicePool.get("_id"),
  2094. _type: "attribute",
  2095. _name: "darkSidePoints"
  2096. });
  2097. if (!currentDarkSidePoints[0] || !currentLightSidePoints[0]) {
  2098. sendChat("Dice System", "No Destiny Points Defined. The GM has been whispered with instructions to reset the Destiny Pool.");
  2099. sendChat("GM", "/w " + "gm The Destiny Pool system needs to be (or has been) reset. To fix this functionality, go to the -DicePool Character Sheet and add 1 dark side and 1 light side destiny point, then click the Force Player Update button. This should clear up the issue.");
  2100. return doRoll;
  2101. }
  2102. var darkSide = parseInt(currentDarkSidePoints[0].get("current"));
  2103. var lightSide = parseInt(currentLightSidePoints[0].get("current"));
  2104.  
  2105. var displayPool = '';
  2106. //noinspection FallThroughInSwitchStatementJS
  2107. switch (cmd[1]) {
  2108. case "useDark":
  2109. if (darkSide > 0) {
  2110. darkSide = darkSide - 1;
  2111. lightSide = lightSide + 1;
  2112.  
  2113. displayPool = '/direct &{template:base} {{title=' + 'The GM flips a Dark Side Destiny Point' + '}}';
  2114. displayPool = displayPool + '{{Dark Side points remaining=' + darkSide + '}}';
  2115. displayPool = displayPool + '{{New Light Side total=' + lightSide + '}}';
  2116.  
  2117. sendChat('Dice System', displayPool);
  2118. }
  2119. else {
  2120. sendChat("GM", "/w " + "gm There are no Dark Side points left in the Destiny Pool. Encourage your Players to use a Light Side Point." );
  2121. return doRoll;
  2122. }
  2123. break;
  2124. case "useLight":
  2125. if (lightSide > 0) {
  2126. lightSide = lightSide - 1;
  2127. darkSide = darkSide + 1;
  2128.  
  2129. displayPool = '/direct &{template:base} {{title=' + diceObj.vars.characterName + ' flips a Light Side Destiny Point' + '}}';
  2130. displayPool = displayPool + '{{New Dark Side total=' + darkSide + '}}';
  2131. displayPool = displayPool + '{{Light Side points remaining=' + lightSide + '}}';
  2132.  
  2133. sendChat('Dice System', displayPool);
  2134. }
  2135. else {
  2136. sendChat("Dice System", "/w " + diceObj.vars.characterName + " There are no Light Side points left in the Destiny Pool. Suggest to your GM to use a Dark Side point to make one available.");
  2137. return doRoll;
  2138. }
  2139. break;
  2140. case "doRoll":
  2141. sendChat(diceObj.vars.characterName, '/direct Rolling a Destiny Point.');
  2142. doRoll = true;
  2143. // falls through on purpose (I think) to sync automatically when destiny point is rolled
  2144. case "registerPlayer":
  2145. if (!doRoll) {
  2146. sendChat("Dice System", "/w " + diceObj.vars.characterName + '&{template:base} {{title=Syncing your Destiny Pool to the GM\'s}}')
  2147. }
  2148. darkSide = darkSide + diceObj.totals.dark;
  2149. lightSide = lightSide + diceObj.totals.light;
  2150.  
  2151. //Register
  2152. if (eote.defaults.destinyListeners.indexOf(diceObj.vars.characterID) == -1) {
  2153. eote.defaults.destinyListeners.push(diceObj.vars.characterID);
  2154. }
  2155. break;
  2156. case "sendUpdate":
  2157. sendChat("Dice System", "Updating Players Destiny Pools");
  2158. break;
  2159. case "clearPool":
  2160. sendChat("Dice System", '&{template:base} {{title=The GM cleared the Destiny Pool}}');
  2161. lightSide = 0;
  2162. darkSide = 0;
  2163. break;
  2164. }
  2165. var newDestPool = [
  2166. {
  2167. name: 'lightSidePoints',
  2168. current: lightSide,
  2169. max: '',
  2170. update: true
  2171. },
  2172. {
  2173. name: 'darkSidePoints',
  2174. current: darkSide,
  2175. max: '',
  2176. update: true
  2177. }
  2178. ];
  2179. eote.updateListeners(newDestPool);
  2180. return doRoll;
  2181. };
  2182.  
  2183. eote.process.characterID = function (cmd, diceObj) {
  2184.  
  2185. /* CharacterId
  2186. * default: null
  2187. * Description: looks up the characters name based on character ID
  2188. * Command: !eed characterID(##########)
  2189. * ---------------------------------------------------------------- */
  2190.  
  2191. eote.process.logger("eote.process.characterID", cmd);
  2192.  
  2193. var characterID = cmd[1];
  2194.  
  2195. if (characterID) {
  2196.  
  2197. diceObj.vars.characterName = getObj("character", characterID).get('name');
  2198. diceObj.vars.characterID = characterID;
  2199. }
  2200. return diceObj;
  2201. };
  2202.  
  2203. eote.process.label = function (cmd, diceObj) {
  2204.  
  2205. /* Label
  2206. * default: null
  2207. * Description: set the skill name of the roll
  2208. * Command: !eed label(Name of Skill)
  2209. * ---------------------------------------------------------------- */
  2210. //log(cmd);
  2211.  
  2212. var label = cmd[1];
  2213.  
  2214. if (label) {
  2215.  
  2216. var labelStr = '';
  2217. var labelArray = label.split('|');
  2218.  
  2219. _.each(labelArray, function (labelVal) {
  2220. var labelArray = labelVal.split(':');
  2221. var label = labelArray[0];
  2222. var message = labelArray[1];
  2223. var labelTest = label.toLowerCase();
  2224.  
  2225. switch (labelTest) {
  2226. case 'skill':
  2227. labelStr = '{{title='+labelStr + message + '}}';
  2228. break;
  2229. case 'dice':
  2230. labelStr = '{{title='+labelStr + message + '}}';
  2231. break;
  2232. case 'weapon':
  2233. labelStr = '{{title='+labelStr + message + '}}';
  2234. break;
  2235. default:
  2236. labelStr = labelStr + '{{' + label + '=' + message + '}}';
  2237. }
  2238.  
  2239. });
  2240. diceObj.vars.label = labelStr;
  2241. }
  2242. return diceObj;
  2243. };
  2244.  
  2245. eote.process.resetdice = function (cmd, diceObj) {
  2246.  
  2247. var characterObj = [{ name: diceObj.vars.characterName, id: diceObj.vars.characterID }];
  2248. eote.process.logger("eote.process.resetdice", cmd);
  2249. var resetdice = [];
  2250.  
  2251. if (cmd[1] == 'resetdice') {
  2252. resetdice = [
  2253. {
  2254. name: "b",
  2255. current: 0,
  2256. update: true
  2257. },
  2258. {
  2259. name: "g",
  2260. current: 0,
  2261. update: true
  2262. },
  2263. {
  2264. name: "y",
  2265. current: 0,
  2266. update: true
  2267. },
  2268. {
  2269. name: "blk",
  2270. current: 0,
  2271. update: true
  2272. },
  2273. {
  2274. name: "r",
  2275. current: 0,
  2276. update: true
  2277. },
  2278. {
  2279. name: "p",
  2280. current: 0,
  2281. update: true
  2282. },
  2283. {
  2284. name: "w",
  2285. current: 0,
  2286. update: true
  2287. },
  2288. {
  2289. name: "upgradeAbility",
  2290. current: 0,
  2291. update: true
  2292. },
  2293. {
  2294. name: "downgradeProficiency",
  2295. current: 0,
  2296. update: true
  2297. },
  2298. {
  2299. name: "upgradeDifficulty",
  2300. current: 0,
  2301. update: true
  2302. },
  2303. {
  2304. name: "downgradeChallenge",
  2305. current: 0,
  2306. update: true
  2307. }
  2308. ]
  2309. }
  2310.  
  2311. if (cmd[1] == 'resetgmdice') {
  2312. resetdice = [
  2313. {
  2314. name: "bgm",
  2315. current: 0,
  2316. update: true
  2317. },
  2318. {
  2319. name: "ggm",
  2320. current: 0,
  2321. update: true
  2322. },
  2323. {
  2324. name: "ygm",
  2325. current: 0,
  2326. update: true
  2327. },
  2328. {
  2329. name: "blkgm",
  2330. current: 0,
  2331. update: true
  2332. },
  2333. {
  2334. name: "rgm",
  2335. current: 0,
  2336. update: true
  2337. },
  2338. {
  2339. name: "pgm",
  2340. current: 0,
  2341. update: true
  2342. },
  2343. {
  2344. name: "wgm",
  2345. current: 0,
  2346. update: true
  2347. },
  2348. {
  2349. name: "upgradeAbilitygm",
  2350. current: 0,
  2351. update: true
  2352. },
  2353. {
  2354. name: "downgradeProficiencygm",
  2355. current: 0,
  2356. update: true
  2357. },
  2358. {
  2359. name: "upgradeDifficultygm",
  2360. current: 0,
  2361. update: true
  2362. },
  2363. {
  2364. name: "downgradeChallengegm",
  2365. current: 0,
  2366. update: true
  2367. }
  2368. ]
  2369. }
  2370. eote.updateAddAttribute(characterObj, resetdice);
  2371. };
  2372.  
  2373. eote.process.initiative = function (cmd, diceObj) {
  2374.  
  2375. /* initiative
  2376. * default: false
  2377. * Description: Set NPC/PC initiative true
  2378. * Command: !eed npcinit or pcinit
  2379. * ---------------------------------------------------------------- */
  2380.  
  2381. var type = '';
  2382. var NumSuccess = diceObj.totals.success;
  2383. var NumAdvantage = diceObj.totals.advantage;
  2384. var turnorder;
  2385.  
  2386. eote.process.logger("eote.process.initiative.diceObj", diceObj);
  2387. eote.process.logger("eote.process.initiative.NumSuccess", NumSuccess);
  2388. eote.process.logger("eote.process.initiativeNumAdvantage", NumAdvantage);
  2389.  
  2390. if (Campaign().get("turnorder") == "") turnorder = []; //NOTE: We check to make sure that the turnorder isn't just an empty string first. If it is treat it like an empty array.
  2391. else turnorder = JSON.parse(Campaign().get("turnorder"));
  2392.  
  2393. if (cmd[0] == 'pcinit') {
  2394. type = 'PC';
  2395. }
  2396.  
  2397. if (cmd[0] == 'npcinit') {
  2398. type = 'NPC';
  2399. }
  2400. //Add a new custom entry to the end of the turn order.
  2401. turnorder.push({
  2402. id: "-1",
  2403. pr: NumSuccess + ":" + NumAdvantage,
  2404. custom: type
  2405. });
  2406. turnorder.sort(function (x, y) {
  2407. // verify that x or y contains a colon, if it doesn't put it below
  2408. if (x.toString().indexOf(":") < 1 || y.toString().indexOf(":") < 1) {
  2409. return 1;
  2410. } else {
  2411. var a = x.pr.split(":");
  2412. var b = y.pr.split(":");
  2413.  
  2414. if (b[0] - a[0] != 0) {//First rank on successes
  2415. return b[0] - a[0];
  2416. } else if (b[1] - a[1] != 0) {//Then rank on Advantage
  2417. return b[1] - a[1];
  2418. } else { //If they are still tied, PC goes first
  2419.  
  2420. if (x.custom == y.custom) {
  2421. return 0;
  2422. } else if (x.custom == "NPC") {
  2423. return 1;
  2424. } else {
  2425. return -1;
  2426. }
  2427. }
  2428. }
  2429. });
  2430. Campaign().set("turnorder", JSON.stringify(turnorder));
  2431. };
  2432.  
  2433. eote.process.crit = function (cmd, diceObj) {
  2434.  
  2435. /* Crit
  2436. * default:
  2437. * Description: Rolls critical injury table
  2438. * Command: !eed crit(roll) crit(roll|#) crit(heal|#)
  2439. * ---------------------------------------------------------------- */
  2440.  
  2441. eote.process.logger("eote.process.crit", "");
  2442.  
  2443. var characterObj = [{ name: diceObj.vars.characterName, id: diceObj.vars.characterID }];
  2444. var critTableLifeform = [
  2445. {
  2446. percent: '1 to 5',
  2447. severity: 1,
  2448. name: 'Minor Nick',
  2449. Result: 'Suffer 1 strain.'
  2450. },
  2451. {
  2452. percent: '6 to 10',
  2453. severity: 1,
  2454. name: 'Slowed Down',
  2455. Result: 'May only act during last allied Initiative slot on next turn.'
  2456. },
  2457. {
  2458. percent: '11 to 15',
  2459. severity: 1,
  2460. name: 'Sudden Jolt',
  2461. Result: 'May only act during last hero Initiative slot on next turn.'
  2462. },
  2463. {
  2464. percent: '16 to 20',
  2465. severity: 1,
  2466. name: 'Distracted',
  2467. Result: 'Cannot perform free maneuver on next turn.'
  2468. },
  2469. {
  2470. percent: '21 to 25',
  2471. severity: 1,
  2472. name: 'Off-Balance',
  2473. Result: 'Add 1 Setback die to next skill check.'
  2474. },
  2475. {
  2476. percent: '26 to 30',
  2477. severity: 1,
  2478. name: 'Discouraging Wound',
  2479. Result: 'Flip one light destiny to dark.'
  2480. },
  2481. {
  2482. percent: '31 to 35',
  2483. severity: 1,
  2484. name: 'Stunned',
  2485. Result: 'Staggered, cannot perform action on next turn.'
  2486. },
  2487. {
  2488. percent: '36 to 40',
  2489. severity: 1,
  2490. name: 'Stinger',
  2491. Result: 'Increase difficulty of next check by 1 Difficulty die.'
  2492. },
  2493. //----------------------------- Severity 2
  2494. {
  2495. percent: '41 to 45',
  2496. severity: 2,
  2497. name: 'Bowled Over',
  2498. Result: 'Knocked prone and suffer 1 strain.'
  2499. },
  2500. {
  2501. percent: '46 to 50',
  2502. severity: 2,
  2503. name: 'Head Ringer',
  2504. Result: 'Increase difficulty of all Intellect and Cunning checks by 1 Difficulty die until end of encounter.'
  2505. },
  2506. {
  2507. percent: '51 to 55',
  2508. severity: 2,
  2509. name: 'Fearsome Wound',
  2510. Result: 'Increase difficulty of all Presence and Willpower checks by 1 Difficulty die until end of encounter.'
  2511. },
  2512. {
  2513. percent: '56 to 60',
  2514. severity: 2,
  2515. name: 'Agonizing Wound',
  2516. Result: 'Increase difficulty of all Brawn and Agility checks by 1 Difficulty die until end of encounter.'
  2517. },
  2518. {
  2519. percent: '61 to 65',
  2520. severity: 2,
  2521. name: 'Slightly Dazed',
  2522. Result: 'Add 1 Setback die to all skill checks until end of encounter.'
  2523. },
  2524. {
  2525. percent: '66 to 70',
  2526. severity: 2,
  2527. name: 'Scattered Senses',
  2528. Result: 'Remove all Boost dice from all skill checks until end of encounter.'
  2529. },
  2530. {
  2531. percent: '71 to 75',
  2532. severity: 2,
  2533. name: 'Hamstrung',
  2534. Result: 'Lose free maneuver until end of encounter.'
  2535. },
  2536. {
  2537. percent: '76 to 80',
  2538. severity: 2,
  2539. name: 'Staggered',
  2540. Result: 'Attacker may immediately attempt another free attack against you using same dice pool as original attack.'
  2541. },
  2542. {
  2543. percent: '81 to 85',
  2544. severity: 2,
  2545. name: 'Winded',
  2546. Result: 'Cannot voluntarily suffer strain to activate abilities or gain additional maneuvers until end of encounter.'
  2547. },
  2548. {
  2549. percent: '86 to 90',
  2550. severity: 2,
  2551. name: 'Compromised',
  2552. Result: 'Increase difficulty of all skill checks by 1 Difficulty die until end of encounter.'
  2553. },
  2554. //---------------------------------------- Severity 3
  2555. {
  2556. percent: '91 to 95',
  2557. severity: 3,
  2558. name: 'At the Brink',
  2559. Result: 'Suffer 1 strain each time you perform an action.'
  2560. },
  2561. {
  2562. percent: '96 to 100',
  2563. severity: 3,
  2564. name: 'Crippled',
  2565. Result: 'Limb crippled until healed or replaced. Increase difficulty of all checks that use that limb by 1 Difficulty die.'
  2566. },
  2567. {
  2568. percent: '101 to 105',
  2569. severity: 3,
  2570. name: 'Maimed',
  2571. Result: 'Limb permanently lost. Unless you have a cybernetic replacement, cannot perform actions that use that limb. Add 1 Setback to all other actions.'
  2572. },
  2573. {
  2574. percent: '106 to 110',
  2575. severity: 3,
  2576. name: 'Horrific Injury',
  2577. Result: 'Roll 1d10 to determine one wounded characteristic -- roll results(1-3 = Brawn, 4-6 = Agility, 7 = Intellect, 8 = Cunning, 9 = Presence, 10 = Willpower. Until Healed, treat characteristic as one point lower.'
  2578. },
  2579. {
  2580. percent: '111 to 115',
  2581. severity: 3,
  2582. name: 'Temporarily Lame',
  2583. Result: 'Until healed, may not perform more than one maneuver each turn.'
  2584. },
  2585. {
  2586. percent: '116 to 120',
  2587. severity: 3,
  2588. name: 'Blinded',
  2589. Result: 'Can no longer see. Upgrade the difficulty of Perception and Vigilance checks three times, and all other checks twice.'
  2590. },
  2591. {
  2592. percent: '121 to 125',
  2593. severity: 3,
  2594. name: 'Knocked Senseless',
  2595. Result: 'You can no longer upgrade dice for checks.'
  2596. },
  2597. //---------------------------------------- Severity 4
  2598. {
  2599. percent: '126 to 130',
  2600. severity: 4,
  2601. name: 'Gruesome Injury',
  2602. Result: 'Roll 1d10 to determine one wounded characteristic -- roll results(1-3 = Brawn, 4-6 = Agility, 7 = Intellect, 8 = Cunning, 9 = Presence, 10 = Willpower. Characteristic is permanently one point lower.'
  2603. },
  2604. {
  2605. percent: '131 to 140',
  2606. severity: 4,
  2607. name: 'Bleeding Out',
  2608. Result: 'Suffer 1 wound and 1 strain every round at the beginning of turn. For every 5 wounds suffered beyond wound threshold, suffer one additional Critical Injury (ignore the details for any result below this result).'
  2609. },
  2610. {
  2611. percent: '141 to 150',
  2612. severity: 4,
  2613. name: 'The End is Nigh',
  2614. Result: 'Die after the last Initiative slot during the next round.'
  2615. },
  2616. {
  2617. percent: '151',
  2618. severity: 4,
  2619. name: 'Dead',
  2620. Result: 'Complete, absolute death.'
  2621. }
  2622. ];
  2623. var critTableMachine = [
  2624. {
  2625. percent: '1 to 9',
  2626. severity: 1,
  2627. name: 'Mechanical Stress',
  2628. Result: 'Ship or vehicle suffers 1 system strain.'
  2629. },
  2630. {
  2631. percent: '10 to 18',
  2632. severity: 1,
  2633. name: 'Jostled',
  2634. Result: 'All crew members suffer 1 strain.'
  2635. },
  2636. {
  2637. percent: '19 to 27',
  2638. severity: 1,
  2639. name: 'Losing Power to Shields',
  2640. Result: 'Decrease defense in affected defense zone by 1 until repaired. If ship or vehicle has no defense, suffer 1 system strain.'
  2641. },
  2642. {
  2643. percent: '28 to 36',
  2644. severity: 1,
  2645. name: 'Knocked Off Course',
  2646. Result: 'On next turn, pilot cannot execute any maneuvers. Instead, must make a Piloting check to regain bearings and resume course. Difficulty depends on current speed.'
  2647. },
  2648. {
  2649. percent: '37 to 45',
  2650. severity: 1,
  2651. name: 'Tailspin',
  2652. Result: 'All firing from ship or vehicle suffers 2 setback dice until end of pilot\'s next turn.'
  2653. },
  2654. {
  2655. percent: '46 to 54',
  2656. severity: 1,
  2657. name: 'Component Hit',
  2658. Result: 'One component of the attacker\'s choice is knocked offline, and is rendered inoperable until the end of the following round. See page 245 CRB for Small/Large Vehicle and Ship Component tables. '
  2659. },
  2660. // --------------- severity : 2
  2661. {
  2662. percent: '55 to 63',
  2663. severity: 2,
  2664. name: 'Shields Failing',
  2665. Result: 'Decrease defense in all defense zones by 1 until repaired. If ship or vehicle has no defense, suffer 2 system strain.'
  2666. },
  2667. {
  2668. percent: '64 to 72',
  2669. severity: 2,
  2670. name: 'Hyperdrive or Navicomputer Failure',
  2671. Result: 'Cannot make any jump to hyperspace until repaired. If ship or vehicle has no hyperdrive, navigation systems fail leaving it unable to tell where it is or is going.'
  2672. },
  2673. {
  2674. percent: '73 to 81',
  2675. severity: 2,
  2676. name: 'Power Fluctuations',
  2677. Result: 'Pilot cannot voluntarily inflict system strain on the ship until repaired.'
  2678. },
  2679. // --------------- severity : 3
  2680. {
  2681. percent: '82 to 90',
  2682. severity: 3,
  2683. name: 'Shields Down',
  2684. Result: 'Decrease defense in affected defense zone to 0 and all other defense zones by 1 point until repaired. If ship or vehicle has no defense, suffer 4 system strain.'
  2685. },
  2686. {
  2687. percent: '91 to 99',
  2688. severity: 3,
  2689. name: 'Engine Damaged',
  2690. Result: 'Ship or vehicle\'s maximum speed reduced by 1, to a minimum of 1, until repaired.'
  2691. },
  2692. {
  2693. percent: '100 to 108',
  2694. severity: 3,
  2695. name: 'Shield Overload',
  2696. Result: 'Decrease defense in all defense zones to 0 until repaired. In addition, suffer 2 system strain. Cannot be repaired until end of encounter. If ship or vehicle has no defense, reduce armor by 1 until repaired.'
  2697. },
  2698. {
  2699. percent: '109 to 117',
  2700. severity: 3,
  2701. name: 'Engines Down',
  2702. Result: 'Ship or vehicle\'s maximum speed reduced to 0. In addition, ship or vehicle cannot execute maneuvers until repaired. Ship continues on course at current speed and cannot be stopped or course changed until repaired.'
  2703. },
  2704. {
  2705. percent: '118 to 126',
  2706. severity: 3,
  2707. name: 'Major System Failure',
  2708. Result: 'One component of the attacker\'s choice is heavily damages, and is inoperable until the critical hit is repaired. See page 245 CRB for Small/Large Vehicle and Ship Component tables. '
  2709. },
  2710. // --------------- severity : 4
  2711. {
  2712. percent: '127 to 133',
  2713. severity: 4,
  2714. name: 'Major Hull Breach',
  2715. Result: 'Ships and vehicles of silhouette 4 and smaller depressurize in a number of rounds equal to silhouette. Ships of silhouette 5 and larger don\'t completely depressurize, but parts do (specifics at GM discretion). Ships and vehicles operating in atmosphere instead suffer a Destabilized Critical.'
  2716. },
  2717. {
  2718. percent: '134 to 138',
  2719. severity: 4,
  2720. name: 'Destabilised',
  2721. Result: 'Reduce ship or vehicle\'s hull integrity threshold and system strain threshold to half original values until repaired.'
  2722. },
  2723. {
  2724. percent: '139 to 144',
  2725. severity: 4,
  2726. name: 'Fire!',
  2727. Result: 'Fire rages through ship or vehicle and it immediately takes 2 system strain. Fire can be extinguished with appropriate skill, Vigilance or Cool checks at GM\'s discretion. Takes one round per two silhouette to put out.'
  2728. },
  2729. {
  2730. percent: '145 to 153',
  2731. severity: 4,
  2732. name: 'Breaking Up',
  2733. Result: 'At the end of next round, ship is completely destroyed. Anyone aboard has one round to reach escape pod or bail out before they are lost.'
  2734. },
  2735. {
  2736. percent: '154+',
  2737. severity: 4,
  2738. name: 'Vaporized',
  2739. Result: 'The ship or Vehicle is completely destroyed.'
  2740. }
  2741. ];
  2742. var critRoll = function (addCritNum, type) {
  2743. var openSlot = false;
  2744. var diceRoll = '';
  2745. var critMod = '';
  2746. var rollTotal = '';
  2747. var rollOffset = parseInt(getAttrByName(diceObj.vars.characterID, type + '-critAddOffset'));
  2748. rollOffset = rollOffset ? rollOffset : 0;
  2749. var totalcrits = parseInt(getAttrByName(diceObj.vars.characterID, type + '-critTotal'));
  2750. if(!totalcrits){
  2751. totalcrits = 0;
  2752. }
  2753.  
  2754. //roll random
  2755. if (!addCritNum) {
  2756. diceRoll = randomInteger(100);
  2757. critMod = (totalcrits * 10);
  2758. rollTotal = diceRoll + critMod + rollOffset;
  2759. rollTotal = rollTotal < 1 ? 1 : rollTotal;
  2760. eote.process.logger("critRoll", "diceRoll: " + diceRoll);
  2761. eote.process.logger("critRoll", "critMod: " + critMod);
  2762. eote.process.logger("critRoll", "rollTotal " + rollTotal);
  2763. } else {
  2764. rollTotal = parseInt(addCritNum);
  2765. }
  2766. //find crit in critical table
  2767. if(type=="character" || type=="npc" || type == "companion" || type=="beast"){
  2768. critTable = critTableLifeform;
  2769. }
  2770. if(type=="starship" || type=="vehicle"){
  2771. critTable = critTableMachine;
  2772. }
  2773. for (var key in critTable) {
  2774. var percent = critTable[key].percent.split(' to ');
  2775. var low = parseInt(percent[0]);
  2776. var high = percent[1] ? parseInt(percent[1]) : 1000;
  2777.  
  2778. if ((rollTotal >= low) && (rollTotal <= high)) {
  2779.  
  2780. critAttrs = [
  2781. {
  2782. name: type + '-critTotal',
  2783. current: totalcrits+1,
  2784. max: '',
  2785. update: true
  2786. },
  2787. ];
  2788. critAttrs2 = [
  2789. {
  2790. name: type + '-critName',
  2791. current: critTable[key].name,
  2792. max: '',
  2793. update: true
  2794. },
  2795. {
  2796. name: type + '-critSeverity' ,
  2797. current: critTable[key].severity,
  2798. max: '',
  2799. update: true
  2800. },
  2801. {
  2802. name: type + '-critRange',
  2803. current: critTable[key].percent,
  2804. max: '',
  2805. update: true
  2806. },
  2807. {
  2808. name: type + '-critSummary',
  2809. current: critTable[key].Result,
  2810. max: '',
  2811. update: true
  2812. },
  2813. ];
  2814. var chat = '/direct &{template:base} {{title='+type.charAt(0).toUpperCase()+type.slice(1)+' Critical}} ';
  2815. chat = chat + '{{subtitle=' + diceObj.vars.characterName + '}}';
  2816. chat = chat + '{{Previous Criticals=' + totalcrits + ' x 10}}';
  2817. if (rollOffset) {
  2818. chat = chat + '{{Dice Roll Offset=' + rollOffset + '}}';
  2819. }
  2820. chat = chat + '{{Dice Roll=' + diceRoll + '}}';
  2821. chat = chat + '{{Total=' + rollTotal + '}}';
  2822. chat = chat + '{{wide=<b>' + critTable[key].name + '</b><br>';
  2823. chat = chat + critTable[key].Result + '<br>}}';
  2824.  
  2825. sendChat(diceObj.vars.characterName, chat);
  2826. }
  2827. }
  2828. eote.updateAddAttribute(characterObj, critAttrs);
  2829. eote.process.createRepeatingCrit(type,characterObj,critAttrs2);
  2830. };
  2831. var critHeal = function (critID, type) {
  2832. log(critID);
  2833. log(type);
  2834. var rowid = critID;
  2835. var regex = new RegExp('^repeating_.*?_' + rowid + '_.*?$');
  2836. var attrsInRow = filterObjs(function(obj) {
  2837. if (obj.get('type') !== 'attribute' || obj.get('characterid') !== diceObj.vars.characterID) return false;
  2838. return regex.test(obj.get('name'));
  2839. });
  2840. _.each(attrsInRow, function (attribute) {//loop characters
  2841. attribute.remove();
  2842. });
  2843. var totalcrits = parseInt(getAttrByName(diceObj.vars.characterID, type + '-critTotal'));
  2844. critAttrs = [
  2845. {
  2846. name: type + '-critTotal',
  2847. current: totalcrits-1,
  2848. max: '',
  2849. update: true
  2850. },
  2851.  
  2852. ];
  2853. eote.updateAddAttribute(characterObj, critAttrs);
  2854. };
  2855. var critArray = cmd[1].split('|');
  2856. var command = critArray[0];
  2857. var type = critArray[1] ? critArray[1] : null;
  2858. var input = critArray[2] ? critArray[2] : null;
  2859.  
  2860. if (type == null) {
  2861. sendChat("Alert", "Type not supplied. Needs character, companion or beast");
  2862. return;
  2863. }
  2864.  
  2865. if (command == 'heal') {
  2866. critHeal(input, type);
  2867. } else if (command == 'add') {
  2868. critRoll(input, type);
  2869. } else { // crit(roll)
  2870. critRoll(null, type);
  2871. }
  2872. };
  2873. eote.process.createRepeatingCrit = function(type,charactersObj,critAttrs) {
  2874. eote.process.logger("repeating","repeating");
  2875. eote.process.logger("type",type);
  2876. eote.process.logger("critAttrs",critAttrs);
  2877. var newId = eote.process.generateRowID();
  2878. //check if object or array
  2879. if (!_.isArray(charactersObj)) {
  2880. charactersObj = [charactersObj];
  2881. }
  2882. if (!_.isArray(critAttrs)) {
  2883. critAttrs = [critAttrs];
  2884. }
  2885. var characterId = "";
  2886. _.each(charactersObj, function (characterObj) {//loop characters
  2887.  
  2888. var characterName = '';
  2889.  
  2890. if (characterObj.name) {
  2891. characterName = characterObj.name;
  2892. } else {
  2893. characterName = characterObj.get('name');
  2894. }
  2895. characterId = characterObj.id;
  2896. //find attribute via character ID
  2897. var characterAttributesObj = findObjs({ _type: "attribute", characterid: characterObj.id });
  2898.  
  2899. if (critAttrs.length != 0) {
  2900.  
  2901. log('UPDATE/ADD ATTRIBUTES FOR:----------------------->' + characterName);
  2902.  
  2903. _.each(critAttrs, function (critAttr) { //loop attributes to update / add
  2904.  
  2905. attr = _.find(characterAttributesObj, function (a) {
  2906. return (a.get('name') === critAttr.name);
  2907. });
  2908. if (attr) {
  2909. if (critAttr.update) {
  2910. log('Update Attr: ' + critAttr.name);
  2911. attr.set({ current: critAttr.current });
  2912. attr.set({ max: critAttr.max ? critAttr.max : '' });
  2913. }
  2914. } else {
  2915. log('Add Attr: '+ critAttr.name);
  2916. log( 'Value: '+ critAttr.current);
  2917. eote.createObj('attribute', {
  2918. characterid: characterObj.id,
  2919. name: "repeating_crit"+type+"_" + newId + "_" + critAttr.name,
  2920. current: critAttr.current,
  2921. max: critAttr.max ? critAttr.max : ''
  2922. });
  2923. }
  2924. });
  2925. }
  2926. });
  2927. eote.createObj('attribute', {
  2928. characterid: characterId,
  2929. name: "repeating_crit"+type+"_" + newId + "_"+type+"-critId",
  2930. current: newId
  2931. });
  2932.  
  2933. };
  2934.  
  2935.  
  2936.  
  2937. eote.process.generateRowID = function () {
  2938. "use strict";
  2939. var a = 0, b = [];
  2940. var c = (new Date()).getTime() + 0, d = c === a;
  2941. a = c;
  2942. for (var e = new Array(8), f = 7; 0 <= f; f--) {
  2943. e[f] = "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(c % 64);
  2944. c = Math.floor(c / 64);
  2945. }
  2946. c = e.join("");
  2947. if (d) {
  2948. for (f = 11; 0 <= f && 63 === b[f]; f--) {
  2949. b[f] = 0;
  2950. }
  2951. b[f]++;
  2952. } else {
  2953. for (f = 0; 12 > f; f++) {
  2954. b[f] = Math.floor(64 * Math.random());
  2955. }
  2956. }
  2957. for (f = 0; 12 > f; f++){
  2958. c += "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz".charAt(b[f]);
  2959. }
  2960. return c.replace(/_/g, "Z");
  2961. };
  2962.  
  2963.  
  2964. eote.process.gmdice = function (cmd) {
  2965.  
  2966. /* gmdice
  2967. * default:
  2968. * Description: Update CMD string to include -DicePool dice
  2969. * Command: (gmdice)
  2970. * ---------------------------------------------------------------- */
  2971.  
  2972. //var charObj = findObjs({ _type: "character", name: "-DicePool" });
  2973. var charID = eote.defaults['-DicePoolID'];//charObj[0].id;
  2974.  
  2975. var g = getAttrByName(charID, 'ggm');
  2976. var y = getAttrByName(charID, 'ygm');
  2977. var p = getAttrByName(charID, 'pgm');
  2978. var r = getAttrByName(charID, 'rgm');
  2979. var b = getAttrByName(charID, 'bgm');
  2980. var blk = getAttrByName(charID, 'blkgm');
  2981. var w = getAttrByName(charID, 'wgm');
  2982. var upAbility = getAttrByName(charID, 'upgradeAbilitygm');
  2983. var upDifficulty = getAttrByName(charID, 'upgradeDifficultygm');
  2984. var downProficiency = getAttrByName(charID, 'downgradeProficiencygm');
  2985. var downChallenge = getAttrByName(charID, 'downgradeChallengegm');
  2986.  
  2987. var gmdiceCMD = g + 'g ' + y + 'y ' + p + 'p ' + r + 'r ' + b + 'b ' + blk + 'blk ' + w + 'w upgrade(ability|' + upAbility + ') downgrade(proficiency|' + downProficiency + ') upgrade(difficulty|' + upDifficulty + ') downgrade(challenge|' + downChallenge + ')';
  2988.  
  2989. eote.process.logger("eote.process.gmDice.charID", charID);
  2990. cmd = cmd.replace('(gmdice)', gmdiceCMD);
  2991. //log(cmd);
  2992. return cmd;
  2993. };
  2994.  
  2995. eote.process.encum = function (cmd, diceObj) {
  2996.  
  2997. /* Encumberment
  2998. * default:
  2999. * Description: If the current encum is great than threshold add 1 setback per unit over current encum
  3000. * Command: !eed encum(encum_current|encum_threshold)
  3001. * ---------------------------------------------------------------- */
  3002.  
  3003. eote.process.logger("eote.process.encum", cmd);
  3004.  
  3005. _.each(cmd, function (encum) {
  3006.  
  3007. var diceArray = encum.match(/\((.*?)\|(.*?)\)/);
  3008.  
  3009. if (diceArray && diceArray[1] && diceArray[2]) {
  3010.  
  3011. var num1 = eote.process.math(diceArray[1]);
  3012. var num2 = eote.process.math(diceArray[2]);
  3013. var setbackDice = diceObj.count.setback;
  3014.  
  3015. if (num2 > num1) {
  3016. diceObj.count.setback = setbackDice + (num2 - num1);
  3017. eote.process.logger("eote.process.encum.NewSetbackTotal", diceObj.count.setback + "blk");
  3018. //sendChat("Dice System", "/w " + diceObj.vars.characterName + " **Overencumbered** " + diceObj.count.setback + " Setbacks added");
  3019. }
  3020. else {
  3021. eote.process.logger("eote.process.encum", "No New Setback");
  3022. }
  3023. }
  3024. });
  3025. return diceObj;
  3026. };
  3027.  
  3028. eote.process.skill = function (cmd, diceObj) {
  3029.  
  3030. /* Skill
  3031. * default:
  3032. * Description: create the ability and proficiency dice for a skill check
  3033. * Command: !eed skill(char_value|skill_value|[NPC minion group size]|[Is minion skill])
  3034. * ---------------------------------------------------------------- */
  3035.  
  3036. eote.process.logger("eote.process.skill", cmd);
  3037.  
  3038. _.each(cmd, function (skill) {
  3039. var matchers = {
  3040. matchNPCGroupWSkillName: /\((.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\)/,
  3041. matchNPCGroupWOSkillName: /\((.*?)\|(.*?)\|(.*?)\|(.*?)\)/,
  3042. matchRegSkillWSkillName: /\((.*?)\|(.*?)\|(.*?)\)/,
  3043. matchRegSkillWOSkillName: /\((.*?)\|(.*?)\)/
  3044. };
  3045. var diceArray = null;
  3046. Object.keys(matchers).some(function(key) {
  3047. if ((diceArray = skill.match(matchers[key])) != null) {
  3048. return true;
  3049. }
  3050. });
  3051.  
  3052. if (diceArray && diceArray[1] && diceArray[2]) {
  3053. var num1 = eote.process.math(diceArray[1]);
  3054. if (diceArray[3] && diceArray[4] && diceArray[4] === "1") {
  3055. num1 += (eote.process.math(diceArray[3]) - 1);
  3056. }
  3057. var num2 = eote.process.math(diceArray[2]);
  3058. var totalAbil = Math.abs(num1 - num2);
  3059. var totalProf = (num1 < num2 ? num1 : num2);
  3060. var abilityDice = diceObj.count.ability;
  3061. var proficiencyDice = diceObj.count.proficiency;
  3062.  
  3063. diceObj.count.ability = abilityDice + totalAbil;
  3064. diceObj.count.proficiency = proficiencyDice + totalProf;
  3065.  
  3066. // check for skill name
  3067. if (diceArray[5] || diceArray[3] && !diceArray[4]) {
  3068. var name = (diceArray[5] ? diceArray[5] : diceArray[3]);
  3069.  
  3070. /* remove all non-letter characters to bring the name in line with the JSON properties
  3071. * in order to have the closest chance in getting a match.
  3072. *
  3073. * does not guarantee a match.
  3074. */
  3075. name = name.replace(/[^A-Za-z]/g, "");
  3076.  
  3077. diceObj.vars.skillName = name;
  3078. } else {
  3079. diceObj.vars.skillName = null;
  3080. }
  3081.  
  3082. eote.process.logger("eote.process.skill.abilityTotal", diceObj.count.ability + "g");
  3083. eote.process.logger("eote.process.skill.proficiencyTotal", diceObj.count.proficiency + "y");
  3084. }
  3085.  
  3086. });
  3087. return diceObj;
  3088. };
  3089.  
  3090. eote.process.opposed = function (cmd, diceObj) {
  3091. /*Opposed
  3092. * default:
  3093. * Description: create the difficulty and challenge dice for an opposed skill check
  3094. * Command: !eed opposed(char_value|skill_value)
  3095. * ---------------------------------------------------------------- */
  3096.  
  3097. eote.process.logger("eote.process.opposed", cmd);
  3098.  
  3099. _.each(cmd, function (opposed) {
  3100.  
  3101. var diceArray = opposed.match(/\((.*?)\|(.*?)\)/);
  3102.  
  3103. if (diceArray && diceArray[1] && diceArray[2]) {
  3104. var num1 = eote.process.math(diceArray[1]);
  3105. var num2 = eote.process.math(diceArray[2]);
  3106. var totalOppDiff = Math.abs(num1 - num2);
  3107. var totalOppChal = (num1 < num2 ? num1 : num2);
  3108. var opposeddifficultyDice = diceObj.count.difficulty;
  3109. var opposedchallengeDice = diceObj.count.challenge;
  3110. diceObj.count.difficulty = opposeddifficultyDice + totalOppDiff;
  3111. diceObj.count.challenge = opposedchallengeDice + totalOppChal;
  3112. }
  3113. });
  3114. return diceObj;
  3115. };
  3116.  
  3117. eote.process.setDice = function (cmd, diceObj) {
  3118.  
  3119. /* setDice
  3120. * default:
  3121. * Description: Loop thru the dice and adds or subtracts them from the dice object
  3122. * Command: !eed g# y# b# blk# r# p# w# or g#+# or g#-#
  3123. * ---------------------------------------------------------------- */
  3124.  
  3125. eote.process.logger("eote.process.setDice", cmd);
  3126.  
  3127. _.each(cmd, function (dice) {
  3128.  
  3129. var diceArray = dice.match(/(-?\d{1,2})(\w{1,3})/);
  3130.  
  3131. if (diceArray && diceArray[1] && diceArray[2]) {
  3132.  
  3133. var diceQty = eote.process.math(diceArray[1]);
  3134. diceQty = (isNaN(diceQty) ? 0 : diceQty);
  3135.  
  3136. var abilityDice = diceObj.count.ability;
  3137. var proficiencyDice = diceObj.count.proficiency;
  3138. var difficultyDice = diceObj.count.difficulty;
  3139. var challengeDice = diceObj.count.challenge;
  3140. var boostDice = diceObj.count.boost;
  3141. var setbackDice = diceObj.count.setback;
  3142. var forceDice = diceObj.count.force;
  3143. var success = diceObj.count.success;
  3144. var advantage = diceObj.count.advantage;
  3145. var threat = diceObj.count.threat;
  3146. var failure = diceObj.count.failure;
  3147.  
  3148. switch (diceArray[2]) {
  3149. case 'b':
  3150. diceObj.count.boost = boostDice + diceQty;
  3151. break;
  3152. case 'g':
  3153. diceObj.count.ability = abilityDice + diceQty;
  3154. break;
  3155. case 'y':
  3156. diceObj.count.proficiency = proficiencyDice + diceQty;
  3157. break;
  3158. case 'blk':
  3159. diceObj.count.setback = setbackDice + diceQty;
  3160. break;
  3161. case 'p':
  3162. diceObj.count.difficulty = difficultyDice + diceQty;
  3163. break;
  3164. case 'r':
  3165. diceObj.count.challenge = challengeDice + diceQty;
  3166. break;
  3167. case 'w':
  3168. diceObj.count.force = forceDice + diceQty;
  3169. break;
  3170. case 's':
  3171. diceObj.count.success = success + diceQty;
  3172. break;
  3173. case 'a':
  3174. diceObj.count.advantage = advantage + diceQty;
  3175. break;
  3176. case 't':
  3177. diceObj.count.threat = threat + diceQty;
  3178. break;
  3179. case 'f':
  3180. diceObj.count.failure = failure + diceQty;
  3181. break;
  3182. }
  3183. }
  3184. });
  3185. diceObj = eote.process.checkNegative(diceObj);
  3186.  
  3187. eote.process.logger("eote.process.setDice.DiceToRoll", diceObj.count.boost + "b," + diceObj.count.ability + "g," + diceObj.count.proficiency + "y," + diceObj.count.setback + "blk," + diceObj.count.difficulty + "p," + diceObj.count.challenge + "r," + diceObj.count.force + "w," + diceObj.count.advantage + "a," + diceObj.count.threat + "t," + diceObj.count.failure + "f");
  3188.  
  3189. return diceObj;
  3190. };
  3191.  
  3192. eote.process.checkNegative = function (diceObj) {
  3193. if (diceObj.count.boost < 0) {
  3194. eote.process.logger("eote.process.checkNegative.boost", "Setting count to 0 for being negative.");
  3195. diceObj.count.boost = 0;
  3196. }
  3197. if (diceObj.count.ability < 0) {
  3198. eote.process.logger("eote.process.checkNegative.ability", "Setting count to 0 for being negative.");
  3199. diceObj.count.ability = 0;
  3200. }
  3201. if (diceObj.count.proficiency < 0) {
  3202. eote.process.logger("eote.process.checkNegative.proficiency", "Setting count to 0 for being negative.");
  3203. diceObj.count.proficiency = 0;
  3204. }
  3205. if (diceObj.count.setback < 0) {
  3206. eote.process.logger("eote.process.checkNegative.setback", "Setting count to 0 for being negative.");
  3207. diceObj.count.setback = 0;
  3208. }
  3209. if (diceObj.count.difficulty < 0) {
  3210. eote.process.logger("eote.process.checkNegative.difficulty", "Setting count to 0 for being negative.");
  3211. diceObj.count.difficulty = 0;
  3212. }
  3213. if (diceObj.count.challenge < 0) {
  3214. eote.process.logger("eote.process.checkNegative.challenge", "Setting count to 0 for being negative.");
  3215. diceObj.count.challenge = 0;
  3216. }
  3217. if (diceObj.count.force < 0) {
  3218. eote.process.logger("eote.process.checkNegative.force", "Setting count to 0 for being negative.");
  3219. diceObj.count.force = 0;
  3220. }
  3221. if (diceObj.count.success < 0) {
  3222. eote.process.logger("eote.process.checkNegative.success", "Setting count to 0 for being negative.");
  3223. diceObj.count.success = 0;
  3224. }
  3225. if (diceObj.count.advantage < 0) {
  3226. eote.process.logger("eote.process.checkNegative.advantage", "Setting count to 0 for being negative.");
  3227. diceObj.count.advantage = 0;
  3228. }
  3229. if (diceObj.count.threat < 0) {
  3230. eote.process.logger("eote.process.checkNegative.threat", "Setting count to 0 for being negative.");
  3231. diceObj.count.threat = 0;
  3232. }
  3233. if (diceObj.count.failure < 0) {
  3234. eote.process.logger("eote.process.checkNegative.failure", "Setting count to 0 for being negative.");
  3235. diceObj.count.failure = 0;
  3236. }
  3237. return diceObj;
  3238. };
  3239.  
  3240. eote.process.upgrade = function (cmd, diceObj) {
  3241.  
  3242. /* Upgrade
  3243. * default:
  3244. * Description: upgrades ability and difficulty dice
  3245. * Command: !eed upgrade(ability|#) or upgrade(difficulty|#)
  3246. * ---------------------------------------------------------------- */
  3247.  
  3248. eote.process.logger("eote.process.upgrade", cmd);
  3249.  
  3250. _.each(cmd, function (dice) {
  3251.  
  3252. var diceArray = dice.match(/\((.*?)\|(.*?)\)/);
  3253.  
  3254. if (diceArray && diceArray[1] && diceArray[2]) {
  3255.  
  3256. var type = diceArray[1];
  3257. var upgradeVal = eote.process.math(diceArray[2]);
  3258. var abilityDice = diceObj.count.ability;
  3259. var proficiencyDice = diceObj.count.proficiency;
  3260. var difficultyDice = diceObj.count.difficulty;
  3261. var challengeDice = diceObj.count.challenge;
  3262.  
  3263. switch (type) {
  3264. case 'ability':
  3265.  
  3266. var totalProf = (upgradeVal < abilityDice ? upgradeVal : abilityDice);
  3267. var totalAbil = Math.abs(upgradeVal - abilityDice);
  3268.  
  3269. if (upgradeVal > abilityDice) {
  3270. totalProf = totalProf + Math.floor(totalAbil / 2);
  3271. totalAbil = totalAbil % 2;
  3272. }
  3273. diceObj.count.ability = totalAbil;
  3274. diceObj.count.proficiency = proficiencyDice + totalProf;
  3275.  
  3276. eote.process.logger("eote.process.upgrade.abilityTotal", diceObj.count.ability + "g");
  3277. eote.process.logger("eote.process.upgrade.proficiencyTotal", diceObj.count.proficiency + "y");
  3278.  
  3279. break;
  3280. case 'difficulty':
  3281.  
  3282. var totalChall = (upgradeVal < difficultyDice ? upgradeVal : difficultyDice);
  3283. var totalDiff = Math.abs(upgradeVal - difficultyDice);
  3284.  
  3285. if (upgradeVal > difficultyDice) {
  3286. totalChall = totalChall + Math.floor(totalDiff / 2);
  3287. totalDiff = totalDiff % 2;
  3288. }
  3289. diceObj.count.difficulty = totalDiff;
  3290. diceObj.count.challenge = challengeDice + totalChall;
  3291.  
  3292. eote.process.logger("eote.process.upgrade.difficultyTotal", diceObj.count.difficulty + "p");
  3293. eote.process.logger("eote.process.upgrade.challengeTotal", diceObj.count.challenge + "r");
  3294.  
  3295. break;
  3296. }
  3297. }
  3298. });
  3299. return diceObj;
  3300. };
  3301.  
  3302. eote.process.downgrade = function (cmd, diceObj) {
  3303.  
  3304. /* Downgrade
  3305. * default:
  3306. * Description: downgrades proficiency and challenge dice
  3307. * Command: !eed downgrade(proficiency|#) or downgrade(challenge|#)
  3308. * ---------------------------------------------------------------- */
  3309.  
  3310. eote.process.logger("eote.process.downgrade", cmd);
  3311.  
  3312. _.each(cmd, function (dice) {
  3313.  
  3314. var diceArray = dice.match(/\((.*?)\|(.*?)\)/);
  3315.  
  3316. if (diceArray && diceArray[1] && diceArray[2]) {
  3317.  
  3318. var type = diceArray[1];
  3319. var downgradeVal = eote.process.math(diceArray[2]);
  3320. var abilityDice = diceObj.count.ability;
  3321. var proficiencyDice = diceObj.count.proficiency;
  3322. var difficultyDice = diceObj.count.difficulty;
  3323. var challengeDice = diceObj.count.challenge;
  3324.  
  3325. switch (type) {
  3326. case 'proficiency':
  3327. abilityDice += Math.min(proficiencyDice, downgradeVal);
  3328. proficiencyDice = Math.max(0, proficiencyDice - downgradeVal);
  3329. diceObj.count.ability = abilityDice;
  3330. diceObj.count.proficiency = proficiencyDice;
  3331. break;
  3332. case 'challenge':
  3333. difficultyDice += Math.min(challengeDice, downgradeVal);
  3334. challengeDice = Math.max(0, challengeDice - downgradeVal);
  3335. diceObj.count.difficulty = difficultyDice;
  3336. diceObj.count.challenge = challengeDice;
  3337. break;
  3338. }
  3339. }
  3340. });
  3341. return diceObj;
  3342. };
  3343.  
  3344. eote.process.math = function (expr) {
  3345.  
  3346. /* Math
  3347. * Returns: Number
  3348. * Description: Evaluates a mathematical expression (as a string) and return the result
  3349. * ---------------------------------------------------------------- */
  3350.  
  3351. var chars = expr.split("");
  3352. var n = [], op = [], index = 0, oplast = true;
  3353.  
  3354. n[index] = "";
  3355.  
  3356. // Parse the expression
  3357. for (var c = 0; c < chars.length; c++) {
  3358.  
  3359. if (isNaN(parseInt(chars[c])) && chars[c] !== "." && !oplast) {
  3360. op[index] = chars[c];
  3361. index++;
  3362. n[index] = "";
  3363. oplast = true;
  3364. } else {
  3365. n[index] += chars[c];
  3366. oplast = false;
  3367. }
  3368. }
  3369. // Calculate the expression
  3370. expr = parseFloat(n[0]);
  3371. for (var o = 0; o < op.length; o++) {
  3372. var num = parseFloat(n[o + 1]);
  3373. switch (op[o]) {
  3374. case "+":
  3375. expr = expr + num;
  3376. break;
  3377. case "-":
  3378. expr = expr - num;
  3379. break;
  3380. case "*":
  3381. expr = expr * num;
  3382. break;
  3383. case "/":
  3384. expr = expr / num;
  3385. break;
  3386. }
  3387. }
  3388. return expr;
  3389. };
  3390.  
  3391. eote.process.addDiceValues = function (diceTotalObj, diceResult) {
  3392.  
  3393. diceTotalObj.success = diceTotalObj.success + diceResult.success;
  3394. diceTotalObj.failure = diceTotalObj.failure + diceResult.failure;
  3395. diceTotalObj.advantage = diceTotalObj.advantage + diceResult.advantage;
  3396. diceTotalObj.threat = diceTotalObj.threat + diceResult.threat;
  3397. diceTotalObj.triumph = diceTotalObj.triumph + diceResult.triumph;
  3398. diceTotalObj.despair = diceTotalObj.despair + diceResult.despair;
  3399. diceTotalObj.light = diceTotalObj.light + diceResult.light;
  3400. diceTotalObj.dark = diceTotalObj.dark + diceResult.dark;
  3401.  
  3402. return diceTotalObj;
  3403. };
  3404.  
  3405. eote.process.totalDiceValues = function (diceTotalObj) {
  3406.  
  3407. var diceTS = {
  3408. success: 0,
  3409. failure: 0,
  3410. advantage: 0,
  3411. threat: 0,
  3412. triumph: 0,
  3413. despair: 0,
  3414. light: 0,
  3415. dark: 0,
  3416. diceGraphicsLog: "",
  3417. diceTextLog: ""
  3418. };
  3419. var i = 0;
  3420.  
  3421. i = diceTotalObj.success - diceTotalObj.failure;
  3422.  
  3423. if (i >= 0) {
  3424. diceTS.success = i;
  3425. } else {
  3426. diceTS.failure = Math.abs(i);
  3427. }
  3428. i = diceTotalObj.advantage - diceTotalObj.threat;
  3429.  
  3430. if (i >= 0) {
  3431. diceTS.advantage = i;
  3432. } else {
  3433. diceTS.threat = Math.abs(i);
  3434. }
  3435. diceTS.triumph = diceTotalObj.triumph;
  3436. diceTS.despair = diceTotalObj.despair;
  3437. diceTS.light = diceTotalObj.light;
  3438. diceTS.dark = diceTotalObj.dark;
  3439.  
  3440. return diceTS;
  3441. };
  3442.  
  3443. eote.process.rollDice = function (diceObj) {
  3444.  
  3445. results = {
  3446. success: 0,
  3447. failure: 0,
  3448. advantage: 0,
  3449. threat: 0,
  3450. triumph: 0,
  3451. despair: 0,
  3452. light: 0,
  3453. dark: 0,
  3454. diceGraphicsLog: '',
  3455. diceTextLog: ''
  3456. };
  3457. eote.process.logger("eote.process.rollDice.FinalDiceToRoll", diceObj.count.boost + "b," + diceObj.count.ability + "g," + diceObj.count.proficiency + "y," + diceObj.count.setback + "blk," + diceObj.count.difficulty + "p," + diceObj.count.challenge + "r," + diceObj.count.force + "w," + diceObj.count.advantage + "a," + diceObj.count.threat + "t," + diceObj.count.failure + "f");
  3458.  
  3459. //Blue "Boost" die (d6)
  3460. if (diceObj.count.boost > 0) {
  3461. results = eote.roll.boost(diceObj.count.boost);
  3462. diceObj.graphicsLog.Boost = results.diceGraphicsLog;
  3463. diceObj.textLog.Boost = results.diceTextLog;
  3464. diceObj.totals = eote.process.addDiceValues(diceObj.totals, results);
  3465. }
  3466. //Green "Ability" die (d8)
  3467. if (diceObj.count.ability > 0) {
  3468. results = eote.roll.ability(diceObj.count.ability);
  3469. diceObj.graphicsLog.Ability = results.diceGraphicsLog;
  3470. diceObj.textLog.Ability = results.diceTextLog;
  3471. diceObj.totals = eote.process.addDiceValues(diceObj.totals, results);
  3472. }
  3473. //Yellow "Proficiency" die (d12)
  3474. if (diceObj.count.proficiency > 0) {
  3475. results = eote.roll.proficiency(diceObj.count.proficiency);
  3476. diceObj.graphicsLog.Proficiency = results.diceGraphicsLog;
  3477. diceObj.textLog.Proficiency = results.diceTextLog;
  3478. diceObj.totals = eote.process.addDiceValues(diceObj.totals, results);
  3479. }
  3480. //Black "SetBack" die (d6)
  3481. if (diceObj.count.setback > 0) {
  3482. results = eote.roll.setback(diceObj.count.setback);
  3483. diceObj.graphicsLog.SetBack = results.diceGraphicsLog;
  3484. diceObj.textLog.SetBack = results.diceTextLog;
  3485. diceObj.totals = eote.process.addDiceValues(diceObj.totals, results);
  3486. }
  3487. //Purple "Difficulty" die (d8)
  3488. if (diceObj.count.difficulty > 0) {
  3489. results = eote.roll.difficulty(diceObj.count.difficulty);
  3490. diceObj.graphicsLog.Difficulty = results.diceGraphicsLog;
  3491. diceObj.textLog.Difficulty = results.diceTextLog;
  3492. diceObj.totals = eote.process.addDiceValues(diceObj.totals, results);
  3493. }
  3494. //Red "Challenge" die (d12)
  3495. if (diceObj.count.challenge > 0) {
  3496. results = eote.roll.challenge(diceObj.count.challenge);
  3497. diceObj.graphicsLog.Challenge = results.diceGraphicsLog;
  3498. diceObj.textLog.Challenge = results.diceTextLog;
  3499. diceObj.totals = eote.process.addDiceValues(diceObj.totals, results);
  3500. }
  3501. //White "Force" die (d12)
  3502. if (diceObj.count.force > 0) {
  3503. results = eote.roll.force(diceObj.count.force);
  3504. diceObj.graphicsLog.Force = results.diceGraphicsLog;
  3505. diceObj.textLog.Force = results.diceTextLog;
  3506. diceObj.totals = eote.process.addDiceValues(diceObj.totals, results);
  3507. }
  3508. // Free Successes (from skills)
  3509. if (diceObj.count.success > 0) {
  3510. results = eote.roll.success(diceObj.count.success);
  3511. diceObj.graphicsLog.Success = results.diceGraphicsLog;
  3512. diceObj.textLog.Success = results.diceTextLog;
  3513. diceObj.totals = eote.process.addDiceValues(diceObj.totals, results);
  3514. }
  3515. // Free Advantage (from skills)
  3516. if (diceObj.count.advantage > 0) {
  3517. results = eote.roll.advantage(diceObj.count.advantage);
  3518. diceObj.graphicsLog.Advantage = results.diceGraphicsLog;
  3519. diceObj.textLog.Advantage = results.diceTextLog;
  3520. diceObj.totals = eote.process.addDiceValues(diceObj.totals, results);
  3521. }
  3522. //Free Threat (from skills)
  3523. if (diceObj.count.threat > 0) {
  3524. results = eote.roll.threat(diceObj.count.threat);
  3525. diceObj.graphicsLog.Threat = results.diceGraphicsLog;
  3526. diceObj.textLog.Threat = results.diceTextLog;
  3527. diceObj.totals = eote.process.addDiceValues(diceObj.totals, results);
  3528. }
  3529. // Free Failure (from skills)
  3530. if (diceObj.count.failure > 0) {
  3531. results = eote.roll.failure(diceObj.count.failure);
  3532. diceObj.graphicsLog.Failure = results.diceGraphicsLog;
  3533. diceObj.textLog.Failure = results.diceTextLog;
  3534. diceObj.totals = eote.process.addDiceValues(diceObj.totals, results);
  3535. }
  3536. //finds the sum of each dice attribute
  3537. diceObj.totals = eote.process.totalDiceValues(diceObj.totals);
  3538. return diceObj;
  3539. };
  3540.  
  3541. eote.process.diceOutput = function (diceObj, playerName, playerID) {
  3542.  
  3543. //log(diceObj);
  3544. var s1 = '<img src="';
  3545. var s2 = '" title="';
  3546. var s3 = '" height="';
  3547. var s4 = '" width="';
  3548. var s5 = '"/>';
  3549. var chatGlobal = '';
  3550. var diceGraphicsResults = "";
  3551. var diceGraphicsRolled = "";
  3552. var diceTextRolled = "";
  3553. var diceTextResults = "";
  3554.  
  3555. diceTextResults = "[";
  3556. if (diceObj.totals.success > 0) {
  3557. diceTextResults = diceTextResults + " Success:" + diceObj.totals.success;
  3558. for (i = 1; i <= diceObj.totals.success; i++) {
  3559. diceGraphicsResults = diceGraphicsResults + s1 + eote.defaults.graphics.SYMBOLS.S + s2 + "Success" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3560. }
  3561. }
  3562. if (diceObj.totals.failure > 0) {
  3563. diceTextResults = diceTextResults + " Fail:" + diceObj.totals.failure;
  3564. for (i = 1; i <= diceObj.totals.failure; i++) {
  3565. diceGraphicsResults = diceGraphicsResults + s1 + eote.defaults.graphics.SYMBOLS.F + s2 + "Failure" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3566. }
  3567. }
  3568. if (diceObj.totals.advantage > 0) {
  3569. diceTextResults = diceTextResults + " Advant:" + diceObj.totals.advantage;
  3570. for (i = 1; i <= diceObj.totals.advantage; i++) {
  3571. diceGraphicsResults = diceGraphicsResults + s1 + eote.defaults.graphics.SYMBOLS.A + s2 + "Advantage" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3572. }
  3573. }
  3574. if (diceObj.totals.threat > 0) {
  3575. diceTextResults = diceTextResults + " Threat:" + diceObj.totals.threat;
  3576. for (i = 1; i <= diceObj.totals.threat; i++) {
  3577. diceGraphicsResults = diceGraphicsResults + s1 + eote.defaults.graphics.SYMBOLS.T + s2 + "Threat" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3578. }
  3579. }
  3580. if (diceObj.totals.triumph > 0) {
  3581. diceTextResults = diceTextResults + " Triumph:" + diceObj.totals.triumph;
  3582. for (i = 1; i <= diceObj.totals.triumph; i++) {
  3583. diceGraphicsResults = diceGraphicsResults + s1 + eote.defaults.graphics.SYMBOLS.TRIUMPH + s2 + "Triumph" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3584. }
  3585. }
  3586. if (diceObj.totals.despair > 0) {
  3587. diceTextResults = diceTextResults + " Despair:" + diceObj.totals.despair;
  3588. for (i = 1; i <= diceObj.totals.despair; i++) {
  3589. diceGraphicsResults = diceGraphicsResults + s1 + eote.defaults.graphics.SYMBOLS.DESPAIR + s2 + "Despair" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3590. }
  3591. }
  3592. if (diceObj.totals.light > 0) {
  3593. diceTextResults = diceTextResults + " Light:" + diceObj.totals.light;
  3594.  
  3595. for (i = 1; i <= diceObj.totals.light; i++) {
  3596. diceGraphicsResults = diceGraphicsResults + s1 + eote.defaults.graphics.SYMBOLS.L + s2 + "Light" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3597. }
  3598. }
  3599. if (diceObj.totals.dark > 0) {
  3600. diceTextResults = diceTextResults + " Dark:" + diceObj.totals.dark;
  3601. for (i = 1; i <= diceObj.totals.dark; i++) {
  3602. diceGraphicsResults = diceGraphicsResults + s1 + eote.defaults.graphics.SYMBOLS.D + s2 + "Dark" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3603. }
  3604. }
  3605. diceTextResults = diceTextResults + "]";
  3606. //------------------------------------>
  3607. if (eote.defaults.globalVars.diceTestEnabled === true) {
  3608. characterPlayer = 'TEST';
  3609. } else if (diceObj.vars.characterName) {
  3610. characterPlayer = diceObj.vars.characterName;
  3611. } else {
  3612. characterPlayer = playerName;
  3613. }
  3614.  
  3615. var templateName = (diceObj.vars.suggestions.suggestionsExist
  3616. && suggestionEngine.getDisplayOption() == suggestionEngine.enum.displayOptions.always ? "suggestion" : "base");
  3617.  
  3618. /*Dice roll images work just fine when whispered*/
  3619. var label = diceObj.vars.label;
  3620. if (eote.defaults.globalVars.diceTestEnabled === true) {
  3621. chatGlobal = "/direct <br>6b 8g 12y 6blk 8p 12r 12w <br>";
  3622. } else if (label) {
  3623. chatGlobal = "/direct &{template:" + templateName +"} " + diceObj.vars.label + "{{subtitle=" + characterPlayer + "}}";
  3624. } else {
  3625. chatGlobal = "/direct &{template:" + templateName +"} {{title=" + characterPlayer + "}}";
  3626. }
  3627. //------------------------------------>
  3628. if (eote.defaults.globalVars.diceLogChat === true) {
  3629. if (eote.defaults.globalVars.diceLogRolledOnOneLine === true) {
  3630.  
  3631. diceGraphicsRolled = diceObj.graphicsLog.Boost + diceObj.graphicsLog.Ability + diceObj.graphicsLog.Proficiency + diceObj.graphicsLog.SetBack + diceObj.graphicsLog.Difficulty + diceObj.graphicsLog.Challenge + diceObj.graphicsLog.Force + diceObj.graphicsLog.Success + diceObj.graphicsLog.Advantage + diceObj.graphicsLog.Failure + diceObj.graphicsLog.Threat;
  3632.  
  3633. if (diceObj.textLog.Boost != "") diceTextRolled = diceTextRolled + "Boost:" + diceObj.textLog.Boost;
  3634. if (diceObj.textLog.Ability != "") diceTextRolled = diceTextRolled + "Ability:" + diceObj.textLog.Ability;
  3635. if (diceObj.textLog.Proficiency != "") diceTextRolled = diceTextRolled + "Proficiency:" + diceObj.textLog.Proficiency;
  3636. if (diceObj.textLog.SetBack != "") diceTextRolled = diceTextRolled + "SetBack:" + diceObj.textLog.SetBack;
  3637. if (diceObj.textLog.Difficulty != "") diceTextRolled = diceTextRolled + "Difficulty:" + diceObj.textLog.Difficulty;
  3638. if (diceObj.textLog.Challenge != "") diceTextRolled = diceTextRolled + "Challenge:" + diceObj.textLog.Challenge;
  3639. if (diceObj.textLog.Force != "") diceTextRolled = diceTextRolled + "Force:" + diceObj.textLog.Force;
  3640. if (diceObj.textLog.Success != "") diceTextRolled = diceTextRolled + "Success:" + diceObj.textLog.Success;
  3641. if (diceObj.textLog.Advantage != "") diceTextRolled = diceTextRolled + "Advantage:" + diceObj.textLog.Advantage;
  3642. if (diceObj.textLog.Failure != "") diceTextRolled = diceGraphicsRolled + "Failure:" + diceObj.textLog.Failure;
  3643. if (diceObj.textLog.Threat != "") diceTextRolled = diceGraphicsRolled + "Threat:" + diceObj.textLog.Threat;
  3644.  
  3645. if (eote.defaults.globalVars.diceGraphicsChat === true) {
  3646. chatGlobal = chatGlobal + '{{roll=' + diceGraphicsRolled + '}}';
  3647. } else {
  3648. sendChat("", diceTextRolled);
  3649. }
  3650. } else {
  3651.  
  3652. if (eote.defaults.globalVars.diceGraphicsChat === true) {
  3653.  
  3654. if (diceObj.vars.label) {
  3655. sendChat(characterPlayer, "/direct " + diceObj.vars.label + '<br>');
  3656. }
  3657. if (diceObj.graphicsLog.Boost != "") sendChat("", "/direct " + diceObj.graphicsLog.Boost);
  3658. if (diceObj.graphicsLog.Ability != "") sendChat("", "/direct " + diceObj.graphicsLog.Ability);
  3659. if (diceObj.graphicsLog.Proficiency != "") sendChat("", "/direct " + diceObj.graphicsLog.Proficiency);
  3660. if (diceObj.graphicsLog.SetBack != "") sendChat("", "/direct " + diceObj.graphicsLog.SetBack);
  3661. if (diceObj.graphicsLog.Difficulty != "") sendChat("", "/direct " + diceObj.graphicsLog.Difficulty);
  3662. if (diceObj.graphicsLog.Challenge != "") sendChat("", "/direct " + diceObj.graphicsLog.Challenge);
  3663. if (diceObj.graphicsLog.Force != "") sendChat("", "/direct " + diceObj.graphicsLog.Force);
  3664. if (diceObj.graphicsLog.Success != "") sendChat("", "/direct " + diceObj.graphicsLog.Success);
  3665. if (diceObj.graphicsLog.Advantage != "") sendChat("", "/direct " + diceObj.graphicsLog.Advantage);
  3666. if (diceObj.graphicsLog.Failure != "") sendChat("", "/direct " + diceObj.graphicsLog.Failure);
  3667. if (diceObj.graphicsLog.Threat != "") sendChat("", "/direct " + diceObj.graphicsLog.Threat);
  3668. } else {
  3669. if (diceObj.vars.label) {
  3670. sendChat(characterPlayer, "/direct " + diceObj.vars.label + '<br>');
  3671. }
  3672. if (diceObj.textLog.Boost != "") sendChat("", "Boost:" + diceObj.textLog.Boost);
  3673. if (diceObj.textLog.Ability != "") sendChat("", "Ability:" + diceObj.textLog.Ability);
  3674. if (diceObj.textLog.Proficiency != "") sendChat("", "Proficiency:" + diceObj.textLog.Proficiency);
  3675. if (diceObj.textLog.SetBack != "") sendChat("", "SetBack:" + diceObj.textLog.SetBack);
  3676. if (diceObj.textLog.Difficulty != "") sendChat("", "Difficulty:" + diceObj.textLog.Difficulty);
  3677. if (diceObj.textLog.Challenge != "") sendChat("", "Challenge:" + diceObj.textLog.Challenge);
  3678. if (diceObj.textLog.Force != "") sendChat("", "Force:" + diceObj.textLog.Force);
  3679. if (diceObj.textLog.Success != "") sendChat("", "Success:" + diceObj.textLog.Success);
  3680. if (diceObj.textLog.Advantage != "") sendChat("", "Advantage:" + diceObj.textLog.Advantage);
  3681. if (diceObj.textLog.Failure != "") sendChat("", "Failure:" + diceObj.textLog.Failure);
  3682. if (diceObj.textLog.Threat != "") sendChat("", "Threat:" + diceObj.textLog.Threat);
  3683. }
  3684. }
  3685. }
  3686.  
  3687. var suggestions = suggestionEngine.buildSuggestionsRollTemplate(diceObj);
  3688. var suggestionStatus = suggestionEngine.enum.displayOptions;
  3689. var suggestionsFlag = suggestionEngine.getDisplayOption();
  3690. var suggestionsExist = diceObj.vars.suggestions.suggestionsExist;
  3691.  
  3692. if (suggestionsExist) {
  3693. switch (suggestionsFlag) {
  3694. case suggestionStatus.none:
  3695. // not really needed since the other checks won't allow a status of none to do anything
  3696. // but this prevents the default from yelling at you.
  3697. suggestions = null;
  3698. break;
  3699. case suggestionStatus.whisper:
  3700. suggestions = "&{template:base} {{title=Skill Suggestions}} " + suggestions;
  3701. break;
  3702. case suggestionStatus.always:
  3703. suggestions = " {{suggestionsExist=true}} " + suggestions;
  3704. break;
  3705. case null:
  3706. var msg = "No display option determined! Please set the display option on the " + eote.defaults.GMSheet.name;
  3707. log(msg);
  3708. sendChat("System", "/w gm " + msg);
  3709. break;
  3710. default:
  3711. // this should never be entered
  3712. log("Report Me! A suggestionFlag of '"+ suggestionsFlag +"' is not handled properly!");
  3713. }
  3714. }
  3715.  
  3716. if (eote.defaults.globalVars.diceGraphicsChat === true) {
  3717. chatGlobal = chatGlobal + '{{results=' + diceGraphicsResults + '}}';
  3718. if (suggestions && suggestionsFlag == suggestionStatus.always)
  3719. chatGlobal += " " + suggestions;
  3720. sendChat(characterPlayer, chatGlobal);
  3721. } else {
  3722. sendChat("Roll", diceTextResults);
  3723. }
  3724.  
  3725. if (suggestions && suggestionsFlag == suggestionStatus.whisper) {
  3726. sendChat("System", "/w gm " + suggestions);
  3727. }
  3728. eote.process.logger("eote.process.rollResult", diceTextResults);
  3729. };
  3730.  
  3731. eote.roll = {
  3732.  
  3733. boost: function (diceQty) {
  3734. //Blue "Boost" die (d6)
  3735. //1 Blank
  3736. //2 Blank
  3737. //3 Success
  3738. //4 Advantage
  3739. //5 Advantage + Advantage
  3740. //6 Success + Advantage
  3741. var roll = 0;
  3742. var diceResult = {
  3743. success: 0,
  3744. failure: 0,
  3745. advantage: 0,
  3746. threat: 0,
  3747. triumph: 0,
  3748. despair: 0,
  3749. light: 0,
  3750. dark: 0,
  3751. diceGraphicsLog: "",
  3752. diceTextLog: ""
  3753. };
  3754. var i = 0;
  3755. var s1 = '<img src="';
  3756. var s2 = '" title="';
  3757. var s3 = '" height="';
  3758. var s4 = '" width="';
  3759. var s5 = '"/>';
  3760.  
  3761. if (eote.defaults.globalVars.diceTestEnabled === true) {
  3762. diceQty = 6;
  3763. }
  3764. for (i = 1; i <= diceQty; i++) {
  3765. if (eote.defaults.globalVars.diceTestEnabled === true) {
  3766. roll = roll + 1;
  3767. } else {
  3768. roll = randomInteger(6);
  3769. }
  3770. switch (roll) {
  3771. case 1:
  3772. diceResult.diceTextLog = diceResult.diceTextLog + "(Blank)";
  3773. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.BOOST.BLANK + s2 + "Boost Blank" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3774. break;
  3775. case 2:
  3776. diceResult.diceTextLog = diceResult.diceTextLog + "(Blank)";
  3777. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.BOOST.BLANK + s2 + "Boost Blank" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3778. break;
  3779. case 3:
  3780. diceResult.diceTextLog = diceResult.diceTextLog + "(Success)";
  3781. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.BOOST.S + s2 + "Boost Success" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3782. diceResult.success = diceResult.success + 1;
  3783. break;
  3784. case 4:
  3785. diceResult.diceTextLog = diceResult.diceTextLog + "(Advantage)";
  3786. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.BOOST.A + s2 + "Boost Advantage" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3787. diceResult.advantage = diceResult.advantage + 1;
  3788. break;
  3789. case 5:
  3790. diceResult.diceTextLog = diceResult.diceTextLog + "(Advantage x2)";
  3791. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.BOOST.AA + s2 + "Boost Advantage x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3792. diceResult.advantage = diceResult.advantage + 2;
  3793. break;
  3794. case 6:
  3795. diceResult.diceTextLog = diceResult.diceTextLog + "(Success + Advantage)";
  3796. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.BOOST.SA + s2 + "Boost Success + Advantage" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3797. diceResult.success = diceResult.success + 1;
  3798. diceResult.advantage = diceResult.advantage + 1;
  3799. break;
  3800. }
  3801. }
  3802. return diceResult;
  3803. },
  3804. ability: function (diceQty) {
  3805. //Green "Ability" die (d8)
  3806. //1 Blank
  3807. //2 Success
  3808. //3 Success
  3809. //4 Advantage
  3810. //5 Advantage
  3811. //6 Success + Advantage
  3812. //7 Advantage + Advantage
  3813. //8 Success + Success
  3814. var roll = 0;
  3815. var diceTextLog = "";
  3816. var diceGraphicsLog = "";
  3817. var diceResult = {
  3818. success: 0,
  3819. failure: 0,
  3820. advantage: 0,
  3821. threat: 0,
  3822. triumph: 0,
  3823. despair: 0,
  3824. light: 0,
  3825. dark: 0,
  3826. diceGraphicsLog: "",
  3827. diceTextLog: ""
  3828. };
  3829. var i = 0;
  3830. var s1 = '<img src="';
  3831. var s2 = '" title="';
  3832. var s3 = '" height="';
  3833. var s4 = '" width="';
  3834. var s5 = '"/>';
  3835.  
  3836. if (eote.defaults.globalVars.diceTestEnabled === true) {
  3837. diceQty = 8;
  3838. }
  3839. for (i = 1; i <= diceQty; i++) {
  3840. if (eote.defaults.globalVars.diceTestEnabled === true) {
  3841. roll = roll + 1;
  3842. }
  3843. else {
  3844. roll = randomInteger(8);
  3845. }
  3846. switch (roll) {
  3847. case 1:
  3848. diceResult.diceTextLog = diceResult.diceTextLog + "(Blank)";
  3849. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.ABILITY.BLANK + s2 + "Ability Blank" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3850. break;
  3851. case 2:
  3852. diceResult.diceTextLog = diceResult.diceTextLog + "(Success)";
  3853. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.ABILITY.S + s2 + "Ability Success" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3854. diceResult.success = diceResult.success + 1;
  3855. break;
  3856. case 3:
  3857. diceResult.diceTextLog = diceResult.diceTextLog + "(Success)";
  3858. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.ABILITY.S + s2 + "Ability Success" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3859. diceResult.success = diceResult.success + 1;
  3860. break;
  3861. case 4:
  3862. diceResult.diceTextLog = diceResult.diceTextLog + "(Advantage)";
  3863. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.ABILITY.A + s2 + "Ability Advantage" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3864. diceResult.advantage = diceResult.advantage + 1;
  3865. break;
  3866. case 5:
  3867. diceResult.diceTextLog = diceResult.diceTextLog + "(Advantage)";
  3868. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.ABILITY.A + s2 + "Ability Advantage" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3869. diceResult.advantage = diceResult.advantage + 1;
  3870. break;
  3871. case 6:
  3872. diceResult.diceTextLog = diceResult.diceTextLog + "(Success + Advantage)";
  3873. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.ABILITY.SA + s2 + "Ability Success + Advantage" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3874. diceResult.success = diceResult.success + 1;
  3875. diceResult.advantage = diceResult.advantage + 1;
  3876. break;
  3877. case 7:
  3878. diceResult.diceTextLog = diceResult.diceTextLog + "(Advantage x2)";
  3879. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.ABILITY.AA + s2 + "Ability Advantage x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3880. diceResult.advantage = diceResult.advantage + 2;
  3881. break;
  3882. case 8:
  3883. diceResult.diceTextLog = diceResult.diceTextLog + "(Success x2)";
  3884. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.ABILITY.SS + s2 + "Ability Success x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3885. diceResult.success = diceResult.success + 2;
  3886. break;
  3887. }
  3888. }
  3889. return diceResult;
  3890. },
  3891. proficiency: function (diceQty) {
  3892. //Yellow "Proficiency" die (d12)
  3893. //1 Blank
  3894. //2 Triumph
  3895. //3 Success
  3896. //4 Success
  3897. //5 Advantage
  3898. //6 Success + Advantage
  3899. //7 Success + Advantage
  3900. //8 Success + Advantage
  3901. //9 Success + Success
  3902. //10 Success + Success
  3903. //11 Advantage + Advantage
  3904. //12 Advantage + Advantage
  3905. var roll = 0;
  3906. var diceTextLog = "";
  3907. var diceGraphicsLog = "";
  3908. var diceResult = {
  3909. success: 0,
  3910. failure: 0,
  3911. advantage: 0,
  3912. threat: 0,
  3913. triumph: 0,
  3914. despair: 0,
  3915. light: 0,
  3916. dark: 0,
  3917. diceGraphicsLog: "",
  3918. diceTextLog: ""
  3919. };
  3920. var i = 0;
  3921. var s1 = '<img src="';
  3922. var s2 = '" title="';
  3923. var s3 = '" height="';
  3924. var s4 = '" width="';
  3925. var s5 = '"/>';
  3926.  
  3927. if (eote.defaults.globalVars.diceTestEnabled === true) {
  3928. diceQty = 12;
  3929. }
  3930. for (i = 1; i <= diceQty; i++) {
  3931. if (eote.defaults.globalVars.diceTestEnabled === true) {
  3932. roll = roll + 1;
  3933. }
  3934. else {
  3935. roll = randomInteger(12);
  3936. }
  3937. switch (roll) {
  3938. case 1:
  3939. diceResult.diceTextLog = diceResult.diceTextLog + "(Blank)";
  3940. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.PROFICIENCY.BLANK + s2 + "Proficiency Blank" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3941. break;
  3942. case 2:
  3943. diceResult.diceTextLog = diceResult.diceTextLog + "(Triumph(+Success))";
  3944. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.PROFICIENCY.TRIUMPH + s2 + "Proficiency Triumph(+Success)" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3945. diceResult.triumph = diceResult.triumph + 1;
  3946. diceResult.success = diceResult.success + 1;
  3947. break;
  3948. case 3:
  3949. diceResult.diceTextLog = diceResult.diceTextLog + "(Success)";
  3950. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.PROFICIENCY.S + s2 + "Proficiency Success" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3951. diceResult.success = diceResult.success + 1;
  3952. break;
  3953. case 4:
  3954. diceResult.diceTextLog = diceResult.diceTextLog + "(Success)";
  3955. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.PROFICIENCY.S + s2 + "Proficiency Success" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3956. diceResult.success = diceResult.success + 1;
  3957. break;
  3958. case 5:
  3959. diceResult.diceTextLog = diceResult.diceTextLog + "(Advantage)";
  3960. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.PROFICIENCY.A + s2 + "Proficiency Advantage" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3961. diceResult.advantage = diceResult.advantage + 1;
  3962. break;
  3963. case 6:
  3964. diceResult.diceTextLog = diceResult.diceTextLog + "(Success + Advantage)";
  3965. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.PROFICIENCY.SA + s2 + "Proficiency Success + Advantage" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3966. diceResult.success = diceResult.success + 1;
  3967. diceResult.advantage = diceResult.advantage + 1;
  3968. break;
  3969. case 7:
  3970. diceResult.diceTextLog = diceResult.diceTextLog + "(Success + Advantage)";
  3971. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.PROFICIENCY.SA + s2 + "Proficiency Success + Advantage" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3972. diceResult.success = diceResult.success + 1;
  3973. diceResult.advantage = diceResult.advantage + 1;
  3974. break;
  3975. case 8:
  3976. diceResult.diceTextLog = diceResult.diceTextLog + "(Success + Advantage)";
  3977. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.PROFICIENCY.SA + s2 + "Proficiency Success + Advantage" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3978. diceResult.success = diceResult.success + 1;
  3979. diceResult.advantage = diceResult.advantage + 1;
  3980. break;
  3981. case 9:
  3982. diceResult.diceTextLog = diceResult.diceTextLog + "(Success x2)";
  3983. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.PROFICIENCY.SS + s2 + "Proficiency Success x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3984. diceResult.success = diceResult.success + 2;
  3985. break;
  3986. case 10:
  3987. diceResult.diceTextLog = diceResult.diceTextLog + "(Success x2)";
  3988. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.PROFICIENCY.SS + s2 + "Proficiency Success x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3989. diceResult.success = diceResult.success + 2;
  3990. break;
  3991. case 11:
  3992. diceResult.diceTextLog = diceResult.diceTextLog + "(Advantage x2)";
  3993. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.PROFICIENCY.AA + s2 + "Proficiency Advantage x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3994. diceResult.advantage = diceResult.advantage + 2;
  3995. break;
  3996. case 12:
  3997. diceResult.diceTextLog = diceResult.diceTextLog + "(Advantage x2)";
  3998. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.PROFICIENCY.AA + s2 + "Proficiency Advantage x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  3999. diceResult.advantage = diceResult.advantage + 2;
  4000. break;
  4001. }
  4002. }
  4003. return diceResult;
  4004. },
  4005. setback: function (diceQty) {
  4006. //Black "Setback" die (d6)
  4007. //1 Blank
  4008. //2 Blank
  4009. //3 Failure
  4010. //4 Failure
  4011. //5 Threat
  4012. //6 Threat
  4013. var roll = 0;
  4014. var diceTextLog = "";
  4015. var diceGraphicsLog = "";
  4016. var diceResult = {
  4017. success: 0,
  4018. failure: 0,
  4019. advantage: 0,
  4020. threat: 0,
  4021. triumph: 0,
  4022. despair: 0,
  4023. light: 0,
  4024. dark: 0,
  4025. diceGraphicsLog: "",
  4026. diceTextLog: ""
  4027. };
  4028. var i = 0;
  4029. var s1 = '<img src="';
  4030. var s2 = '" title="';
  4031. var s3 = '" height="';
  4032. var s4 = '" width="';
  4033. var s5 = '"/>';
  4034.  
  4035. if (eote.defaults.globalVars.diceTestEnabled === true) {
  4036. diceQty = 6;
  4037. }
  4038. for (i = 1; i <= diceQty; i++) {
  4039. if (eote.defaults.globalVars.diceTestEnabled === true) {
  4040. roll = roll + 1;
  4041. }
  4042. else {
  4043. roll = randomInteger(6);
  4044. }
  4045. switch (roll) {
  4046. case 1:
  4047. diceResult.diceTextLog = diceResult.diceTextLog + "(Blank)";
  4048. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.SETBACK.BLANK + s2 + "Setback Blank" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4049. break;
  4050. case 2:
  4051. diceResult.diceTextLog = diceResult.diceTextLog + "(Blank)";
  4052. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.SETBACK.BLANK + s2 + "Setback Blank" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4053. break;
  4054. case 3:
  4055. diceResult.diceTextLog = diceResult.diceTextLog + "(Failure)";
  4056. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.SETBACK.F + s2 + "Setback Failure" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4057. diceResult.failure = diceResult.failure + 1;
  4058. break;
  4059. case 4:
  4060. diceResult.diceTextLog = diceResult.diceTextLog + "(Failure)";
  4061. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.SETBACK.F + s2 + "Setback Failure" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4062. diceResult.failure = diceResult.failure + 1;
  4063. break;
  4064. case 5:
  4065. diceResult.diceTextLog = diceResult.diceTextLog + "(Threat)";
  4066. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.SETBACK.T + s2 + "Setback Threat" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4067. diceResult.threat = diceResult.threat + 1;
  4068. break;
  4069. case 6:
  4070. diceResult.diceTextLog = diceResult.diceTextLog + "(Threat)";
  4071. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.SETBACK.T + s2 + "Setback Threat" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4072. diceResult.threat = diceResult.threat + 1;
  4073. break;
  4074. }
  4075. }
  4076. return diceResult;
  4077. },
  4078. difficulty: function (diceQty) {
  4079. //Purple "Difficulty" die (d8)
  4080. //1 Blank
  4081. //2 Failure
  4082. //3 Threat
  4083. //4 Threat
  4084. //5 Threat
  4085. //6 Failure + Failure
  4086. //7 Failure + Threat
  4087. //8 Threat + Threat
  4088. var roll = 0;
  4089. var diceTextLog = "";
  4090. var diceGraphicsLog = "";
  4091. var diceResult = {
  4092. success: 0,
  4093. failure: 0,
  4094. advantage: 0,
  4095. threat: 0,
  4096. triumph: 0,
  4097. despair: 0,
  4098. light: 0,
  4099. dark: 0,
  4100. diceGraphicsLog: "",
  4101. diceTextLog: ""
  4102. };
  4103. var i = 0;
  4104. var s1 = '<img src="';
  4105. var s2 = '" title="';
  4106. var s3 = '" height="';
  4107. var s4 = '" width="';
  4108. var s5 = '"/>';
  4109.  
  4110. if (eote.defaults.globalVars.diceTestEnabled === true) {
  4111. diceQty = 8;
  4112. }
  4113. for (i = 1; i <= diceQty; i++) {
  4114. if (eote.defaults.globalVars.diceTestEnabled === true) {
  4115. roll = roll + 1;
  4116. }
  4117. else {
  4118. roll = randomInteger(8);
  4119. }
  4120. switch (roll) {
  4121. case 1:
  4122. diceResult.diceTextLog = diceResult.diceTextLog + "(Blank)";
  4123. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.DIFFICULTY.BLANK + s2 + "Difficulty Blank" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4124. break;
  4125. case 2:
  4126. diceResult.diceTextLog = diceResult.diceTextLog + "(Failure)";
  4127. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.DIFFICULTY.F + s2 + "Difficulty Failure" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4128. diceResult.failure = diceResult.failure + 1;
  4129. break;
  4130. case 3:
  4131. diceResult.diceTextLog = diceResult.diceTextLog + "(Threat)";
  4132. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.DIFFICULTY.T + s2 + "Difficulty Threat" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4133. diceResult.threat = diceResult.threat + 1;
  4134. break;
  4135. case 4:
  4136. diceResult.diceTextLog = diceResult.diceTextLog + "(Threat)";
  4137. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.DIFFICULTY.T + s2 + "Difficulty Threat" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4138. diceResult.threat = diceResult.threat + 1;
  4139. break;
  4140. case 5:
  4141. diceResult.diceTextLog = diceResult.diceTextLog + "(Threat)";
  4142. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.DIFFICULTY.T + s2 + "Difficulty Threat" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4143. diceResult.threat = diceResult.threat + 1;
  4144. break;
  4145. case 6:
  4146. diceResult.diceTextLog = diceResult.diceTextLog + "(Failure x2)";
  4147. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.DIFFICULTY.FF + s2 + "Difficulty Failure x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4148. diceResult.failure = diceResult.failure + 2;
  4149. break;
  4150. case 7:
  4151. diceResult.diceTextLog = diceResult.diceTextLog + "(Failure + Threat)";
  4152. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.DIFFICULTY.FT + s2 + "Difficulty Failure + Threat" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4153. diceResult.failure = diceResult.failure + 1;
  4154. diceResult.threat = diceResult.threat + 1;
  4155. break;
  4156. case 8:
  4157. diceResult.diceTextLog = diceResult.diceTextLog + "(Threat x2)";
  4158. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.DIFFICULTY.TT + s2 + "Difficulty Threat x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4159. diceResult.threat = diceResult.threat + 2;
  4160. break;
  4161. }
  4162. }
  4163. return diceResult;
  4164. },
  4165. challenge: function (diceQty) {
  4166. //Red "Challenge" die (d12)
  4167. //1 Blank
  4168. //2 Despair
  4169. //3 Failure
  4170. //4 Failure
  4171. //5 Threat
  4172. //6 Threat
  4173. //7 Failure + Failure
  4174. //8 Failure + Failure
  4175. //9 Threat + Threat
  4176. //10 Threat + Threat
  4177. //11 Failure + Threat
  4178. //12 Failure + Threat
  4179. var roll = 0;
  4180. var diceTextLog = "";
  4181. var diceGraphicsLog = "";
  4182. var diceResult = {
  4183. success: 0,
  4184. failure: 0,
  4185. advantage: 0,
  4186. threat: 0,
  4187. triumph: 0,
  4188. despair: 0,
  4189. light: 0,
  4190. dark: 0,
  4191. diceGraphicsLog: "",
  4192. diceTextLog: ""
  4193. };
  4194. var i = 0;
  4195. var s1 = '<img src="';
  4196. var s2 = '" title="';
  4197. var s3 = '" height="';
  4198. var s4 = '" width="';
  4199. var s5 = '"/>';
  4200.  
  4201. if (eote.defaults.globalVars.diceTestEnabled === true) {
  4202. diceQty = 12;
  4203. }
  4204. for (i = 1; i <= diceQty; i++) {
  4205. if (eote.defaults.globalVars.diceTestEnabled === true) {
  4206. roll = roll + 1;
  4207. }
  4208. else {
  4209. roll = randomInteger(12);
  4210. }
  4211. switch (roll) {
  4212. case 1:
  4213. diceResult.diceTextLog = diceResult.diceTextLog + "(Blank)";
  4214. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.CHALLENGE.BLANK + s2 + "Challenge Blank" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4215. break;
  4216. case 2:
  4217. diceResult.diceTextLog = diceResult.diceTextLog + "(Despair)";
  4218. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.CHALLENGE.DESPAIR + s2 + "Challenge Despair" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4219. diceResult.despair = diceResult.despair + 1;
  4220. diceResult.failure = diceResult.failure + 1;
  4221. break;
  4222. case 3:
  4223. diceResult.diceTextLog = diceResult.diceTextLog + "(Failure)";
  4224. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.CHALLENGE.F + s2 + "Challenge Failure" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4225. diceResult.failure = diceResult.failure + 1;
  4226. break;
  4227. case 4:
  4228. diceResult.diceTextLog = diceResult.diceTextLog + "(Failure)";
  4229. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.CHALLENGE.F + s2 + "Challenge Failure" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4230. diceResult.failure = diceResult.failure + 1;
  4231. break;
  4232. case 5:
  4233. diceResult.diceTextLog = diceResult.diceTextLog + "(Threat)";
  4234. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.CHALLENGE.T + s2 + "Challenge Threat" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4235. diceResult.threat = diceResult.threat + 1;
  4236. break;
  4237. case 6:
  4238. diceResult.diceTextLog = diceResult.diceTextLog + "(Threat)";
  4239. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.CHALLENGE.T + s2 + "Challenge Threat" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4240. diceResult.threat = diceResult.threat + 1;
  4241. break;
  4242. case 7:
  4243. diceResult.diceTextLog = diceResult.diceTextLog + "(Failure x2)";
  4244. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.CHALLENGE.FF + s2 + "Challenge Failure x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4245. diceResult.failure = diceResult.failure + 2;
  4246. break;
  4247. case 8:
  4248. diceResult.diceTextLog = diceResult.diceTextLog + "(Failure x2)";
  4249. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.CHALLENGE.FF + s2 + "Challenge Failure x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4250. diceResult.failure = diceResult.failure + 2;
  4251. break;
  4252. case 9:
  4253. diceResult.diceTextLog = diceResult.diceTextLog + "(Threat x2)";
  4254. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.CHALLENGE.TT + s2 + "Challenge Threat x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4255. diceResult.threat = diceResult.threat + 2;
  4256. break;
  4257. case 10:
  4258. diceResult.diceTextLog = diceResult.diceTextLog + "(Threat x2)";
  4259. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.CHALLENGE.TT + s2 + "Challenge Threat x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4260. diceResult.threat = diceResult.threat + 2;
  4261. break;
  4262. case 11:
  4263. diceResult.diceTextLog = diceResult.diceTextLog + "(Failure + Threat)";
  4264. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.CHALLENGE.FT + s2 + "Challenge Failure + Threat" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4265. diceResult.failure = diceResult.failure + 1;
  4266. diceResult.threat = diceResult.threat + 1;
  4267. break;
  4268. case 12:
  4269. diceResult.diceTextLog = diceResult.diceTextLog + "(Failure + Threat)";
  4270. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.CHALLENGE.FT + s2 + "Challenge Failure + Threat" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4271. diceResult.failure = diceResult.failure + 1;
  4272. diceResult.threat = diceResult.threat + 1;
  4273. break;
  4274. }
  4275. }
  4276. return diceResult;
  4277. },
  4278. force: function (diceQty) {
  4279. //White "Force" die (d12)
  4280. //1 Light
  4281. //2 Light
  4282. //3 Light + Light
  4283. //4 Light + Light
  4284. //5 Light + Light
  4285. //6 Dark
  4286. //7 Dark
  4287. //8 Dark
  4288. //9 Dark
  4289. //10 Dark
  4290. //11 Dark
  4291. //12 Dark + Dark
  4292. var roll = 0;
  4293. var diceTextLog = "";
  4294. var diceGraphicsLog = "";
  4295. var diceResult = {
  4296. success: 0,
  4297. failure: 0,
  4298. advantage: 0,
  4299. threat: 0,
  4300. triumph: 0,
  4301. despair: 0,
  4302. light: 0,
  4303. dark: 0,
  4304. diceGraphicsLog: "",
  4305. diceTextLog: ""
  4306. };
  4307. var i = 0;
  4308. var s1 = '<img src="';
  4309. var s2 = '" title="';
  4310. var s3 = '" height="';
  4311. var s4 = '" width="';
  4312. var s5 = '"/>';
  4313.  
  4314. if (eote.defaults.globalVars.diceTestEnabled === true) {
  4315. diceQty = 12;
  4316. }
  4317. for (i = 1; i <= diceQty; i++) {
  4318. if (eote.defaults.globalVars.diceTestEnabled === true) {
  4319. roll = roll + 1;
  4320. }
  4321. else {
  4322. roll = randomInteger(12);
  4323. }
  4324. switch (roll) {
  4325. case 1:
  4326. diceResult.diceTextLog = diceResult.diceTextLog + "(Light)";
  4327. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.FORCE.L + s2 + "Force Light" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4328. diceResult.light = diceResult.light + 1;
  4329. break;
  4330. case 2:
  4331. diceResult.diceTextLog = diceResult.diceTextLog + "(Light)";
  4332. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.FORCE.L + s2 + "Force Light" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4333. diceResult.light = diceResult.light + 1;
  4334. break;
  4335. case 3:
  4336. diceResult.diceTextLog = diceResult.diceTextLog + "(Light x2)";
  4337. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.FORCE.LL + s2 + "Force Light x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4338. diceResult.light = diceResult.light + 2;
  4339. break;
  4340. case 4:
  4341. diceResult.diceTextLog = diceResult.diceTextLog + "(Light x2)";
  4342. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.FORCE.LL + s2 + "Force Light x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4343. diceResult.light = diceResult.light + 2;
  4344. break;
  4345. case 5:
  4346. diceResult.diceTextLog = diceResult.diceTextLog + "(Light x2)";
  4347. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.FORCE.LL + s2 + "Force Light x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4348. diceResult.light = diceResult.light + 2;
  4349. break;
  4350. case 6:
  4351. diceResult.diceTextLog = diceResult.diceTextLog + "(Dark)";
  4352. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.FORCE.D + s2 + "Force Dark" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4353. diceResult.dark = diceResult.dark + 1;
  4354. break;
  4355. case 7:
  4356. diceResult.diceTextLog = diceResult.diceTextLog + "(Dark)";
  4357. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.FORCE.D + s2 + "Force Dark" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4358. diceResult.dark = diceResult.dark + 1;
  4359. break;
  4360. case 8:
  4361. diceResult.diceTextLog = diceResult.diceTextLog + "(Dark)";
  4362. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.FORCE.D + s2 + "Force Dark" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4363. diceResult.dark = diceResult.dark + 1;
  4364. break;
  4365. case 9:
  4366. diceResult.diceTextLog = diceResult.diceTextLog + "(Dark)";
  4367. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.FORCE.D + s2 + "Force Dark" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4368. diceResult.dark = diceResult.dark + 1;
  4369. break;
  4370. case 10:
  4371. diceResult.diceTextLog = diceResult.diceTextLog + "(Dark)";
  4372. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.FORCE.D + s2 + "Force Dark" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4373. diceResult.dark = diceResult.dark + 1;
  4374. break;
  4375. case 11:
  4376. diceResult.diceTextLog = diceResult.diceTextLog + "(Dark)";
  4377. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.FORCE.D + s2 + "Force Dark" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4378. diceResult.dark = diceResult.dark + 1;
  4379. break;
  4380. case 12:
  4381. diceResult.diceTextLog = diceResult.diceTextLog + "(Dark x2)";
  4382. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.FORCE.DD + s2 + "Force Dark x2" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4383. diceResult.dark = diceResult.dark + 2;
  4384. break;
  4385. }
  4386. }
  4387. return diceResult;
  4388. },
  4389. success: function (diceQty) {
  4390. //Free Success
  4391. var i = 0;
  4392. var s1 = '<img src="';
  4393. var s2 = '" title="';
  4394. var s3 = '" height="';
  4395. var s4 = '" width="';
  4396. var s5 = '"/>';
  4397.  
  4398. var roll = 0;
  4399. var diceTextLog = "";
  4400. var diceGraphicsLog = "";
  4401.  
  4402. var diceResult = {
  4403. success: 0,
  4404. failure: 0,
  4405. advantage: 0,
  4406. threat: 0,
  4407. triumph: 0,
  4408. despair: 0,
  4409. light: 0,
  4410. dark: 0,
  4411. diceGraphicsLog: "",
  4412. diceTextLog: ""
  4413. };
  4414. diceResult.diceTextLog = diceTextLog + "(Success x" + diceQty + ")";
  4415. diceResult.success = diceResult.success + diceQty;
  4416. for (i = 0; i < diceQty; i++) {
  4417. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.SYMBOLS.S + s2 + "Success" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4418. }
  4419. return diceResult;
  4420. },
  4421. advantage: function (diceQty) {
  4422. //Free Advantage
  4423. var i = 0;
  4424. var s1 = '<img src="';
  4425. var s2 = '" title="';
  4426. var s3 = '" height="';
  4427. var s4 = '" width="';
  4428. var s5 = '"/>';
  4429.  
  4430. var roll = 0;
  4431. var diceTextLog = "";
  4432. var diceGraphicsLog = "";
  4433.  
  4434. var diceResult = {
  4435. success: 0,
  4436. failure: 0,
  4437. advantage: 0,
  4438. threat: 0,
  4439. triumph: 0,
  4440. despair: 0,
  4441. light: 0,
  4442. dark: 0,
  4443. diceGraphicsLog: "",
  4444. diceTextLog: ""
  4445. };
  4446. diceResult.diceTextLog = diceTextLog + "(Advantage x" + diceQty + ")";
  4447. diceResult.advantage = diceResult.advantage + diceQty;
  4448. for (i = 0; i < diceQty; i++) {
  4449. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.SYMBOLS.A + s2 + "Advantage" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4450. }
  4451. return diceResult;
  4452. },
  4453. threat: function (diceQty) {
  4454. //Free threat
  4455. var i = 0;
  4456. var s1 = '<img src="';
  4457. var s2 = '" title="';
  4458. var s3 = '" height="';
  4459. var s4 = '" width="';
  4460. var s5 = '"/>';
  4461.  
  4462. var roll = 0;
  4463. var diceTextLog = "";
  4464. var diceGraphicsLog = "";
  4465.  
  4466. var diceResult = {
  4467. success: 0,
  4468. failure: 0,
  4469. advantage: 0,
  4470. threat: 0,
  4471. triumph: 0,
  4472. despair: 0,
  4473. light: 0,
  4474. dark: 0,
  4475. diceGraphicsLog: "",
  4476. diceTextLog: ""
  4477. };
  4478. diceResult.diceTextLog = diceTextLog + "(Threat x" + diceQty + ")";
  4479. diceResult.threat = diceResult.threat + diceQty;
  4480. for (i = 0; i < diceQty; i++) {
  4481. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.SYMBOLS.T + s2 + "Threat" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4482. }
  4483. return diceResult;
  4484. },
  4485. failure: function (diceQty) {
  4486. //Free Failure
  4487. var i = 0;
  4488. var s1 = '<img src="';
  4489. var s2 = '" title="';
  4490. var s3 = '" height="';
  4491. var s4 = '" width="';
  4492. var s5 = '"/>';
  4493.  
  4494. var roll = 0;
  4495. var diceTextLog = "";
  4496. var diceGraphicsLog = "";
  4497.  
  4498. var diceResult = {
  4499. success: 0,
  4500. failure: 0,
  4501. advantage: 0,
  4502. threat: 0,
  4503. triumph: 0,
  4504. despair: 0,
  4505. light: 0,
  4506. dark: 0,
  4507. diceGraphicsLog: "",
  4508. diceTextLog: ""
  4509. };
  4510. diceResult.diceTextLog = diceTextLog + "(Failure x" + diceQty + ")";
  4511. diceResult.failure = diceResult.failure + diceQty;
  4512. for (i = 0; i < diceQty; i++) {
  4513. diceResult.diceGraphicsLog = diceResult.diceGraphicsLog + s1 + eote.defaults.graphics.SYMBOLS.F + s2 + "Success" + s3 + eote.defaults.globalVars.diceGraphicsChatSize + s4 + eote.defaults.globalVars.diceGraphicsChatSize + s5;
  4514. }
  4515. return diceResult;
  4516. }
  4517. };
  4518.  
  4519. eote.events = function () {
  4520.  
  4521. //event listener Add character defaults to new characters
  4522. on("add:character", function (characterObj) {
  4523. eote.setCharacterDefaults(characterObj);
  4524. });
  4525. on("chat:message", function (msg) {
  4526.  
  4527. if (msg.type != 'api') {
  4528. return;
  4529. }
  4530. eote.process.setup(msg.content, msg.who, msg.playerid);
  4531. });
  4532. };
  4533.  
  4534. // this only runs once per initialization of the script in order to prevent this process from running too frequently
  4535. // this converts any $\w$ token that matches a defined list of tokens into a html image tag.
  4536. function convertTokensToTags(skillSuggestions, symReplace) {
  4537. Object.keys(skillSuggestions).forEach(function(categoryKey) {
  4538. var category = skillSuggestions[categoryKey];
  4539. Object.keys(category).forEach(function(categoryElemKey) {
  4540. var categoryElem = category[categoryElemKey];
  4541. Object.keys(categoryElem).forEach(function(symbolKey) {
  4542. var item = categoryElem[symbolKey];
  4543. for (var i = 0; i < item.length; i++)
  4544. {
  4545. var itemElem = item[i];
  4546. if (typeof itemElem == "object") {
  4547. if (itemElem.text.indexOf("$") > 0) {
  4548. Object.keys(symReplace).forEach(function (symReplaceKey) {
  4549. itemElem.text = itemElem.text.replace(symReplace[symReplaceKey].matcher, symReplace[symReplaceKey].replacer);
  4550. });
  4551. }
  4552. }
  4553. }
  4554. });
  4555. });
  4556. });
  4557. log("Finished converting tokens to tags");
  4558. }
  4559.  
  4560. on('ready', function() {
  4561. eote.init();
  4562. });
Add Comment
Please, Sign In to add comment