ENH: Saving throws
							parent
							
								
									44c33d397e
								
							
						
					
					
						commit
						bc9cf50416
					
				|  | @ -39,10 +39,6 @@ export class OseActorSheetCharacter extends OseActorSheet { | |||
|   getData() { | ||||
|     const data = super.getData(); | ||||
| 
 | ||||
|     for (let [a, score] of Object.entries(data.data.scores)) { | ||||
|       data.data.scores[a].label = game.i18n.localize(`OSE.scores.${a}`); | ||||
|     } | ||||
| 
 | ||||
|     // Settings
 | ||||
|     data.config.variableWeaponDamage = game.settings.get( | ||||
|       "ose", | ||||
|  |  | |||
|  | @ -1,17 +1,24 @@ | |||
| export const OSE = { | ||||
|     scores: { | ||||
|         str: "OSE.scores.str.long", | ||||
|         int: "OSE.scores.int.long", | ||||
|         dex: "OSE.scores.dex.long", | ||||
|         wis: "OSE.scores.wis.long", | ||||
|         con: "OSE.scores.con.long", | ||||
|         cha: "OSE.scores.cha.long" | ||||
|     }, | ||||
|     saves: { | ||||
|         death: "OSE.saves.death.short", | ||||
|         wand: "OSE.saves.wand.short", | ||||
|         paralysis: "OSE.saves.paralysis.short", | ||||
|         breath: "OSE.saves.breath.short", | ||||
|         spell: "OSE.saves.spell.short" | ||||
|     } | ||||
| }; | ||||
|   scores: { | ||||
|     str: "OSE.scores.str.long", | ||||
|     int: "OSE.scores.int.long", | ||||
|     dex: "OSE.scores.dex.long", | ||||
|     wis: "OSE.scores.wis.long", | ||||
|     con: "OSE.scores.con.long", | ||||
|     cha: "OSE.scores.cha.long", | ||||
|   }, | ||||
|   saves_short: { | ||||
|     death: "OSE.saves.death.short", | ||||
|     wand: "OSE.saves.wand.short", | ||||
|     paralysis: "OSE.saves.paralysis.short", | ||||
|     breath: "OSE.saves.breath.short", | ||||
|     spell: "OSE.saves.spell.short", | ||||
|   }, | ||||
|   saves_long: { | ||||
|     death: "OSE.saves.death.long", | ||||
|     wand: "OSE.saves.wand.long", | ||||
|     paralysis: "OSE.saves.paralysis.long", | ||||
|     breath: "OSE.saves.breath.long", | ||||
|     spell: "OSE.saves.spell.long", | ||||
|   }, | ||||
| }; | ||||
|  |  | |||
|  | @ -48,6 +48,7 @@ export class OseItem extends Item { | |||
|   } | ||||
| 
 | ||||
|   rollWeapon() { | ||||
|     console.log("WEAPON"); | ||||
|     if (this.data.data.missile) { | ||||
|       this.actor.rollAttack({type: 'missile', label: this.name, dmg: this.data.data.damage}); | ||||
|     } else if (this.data.data.melee) { | ||||
|  | @ -59,6 +60,7 @@ export class OseItem extends Item { | |||
|   } | ||||
| 
 | ||||
|   async rollFormula(options={}) { | ||||
|     console.log("FORMULA"); | ||||
|     if ( !this.data.data.roll ) { | ||||
|       throw new Error("This Item does not have a formula to roll!"); | ||||
|     } | ||||
|  | @ -99,6 +101,7 @@ export class OseItem extends Item { | |||
|       hasDamage: this.hasDamage, | ||||
|       isSpell: this.data.type === "spell", | ||||
|       hasSave: this.hasSave, | ||||
|       config: CONFIG.OSE | ||||
|     }; | ||||
| 
 | ||||
|     // Render the chat card template
 | ||||
|  | @ -137,7 +140,11 @@ export class OseItem extends Item { | |||
|     const header = event.currentTarget; | ||||
|     const card = header.closest(".chat-card"); | ||||
|     const content = card.querySelector(".card-content"); | ||||
|     content.style.display = content.style.display === "none" ? "block" : "none"; | ||||
|     if (content.style.display == "none") { | ||||
|       $(content).slideDown(200); | ||||
|     } else { | ||||
|       $(content).slideUp(200);   | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
| 
 | ||||
|  | @ -170,20 +177,20 @@ export class OseItem extends Item { | |||
|     let targets = []; | ||||
|     if ( isTargetted ) { | ||||
|       targets = this._getChatCardTargets(card); | ||||
|     } | ||||
| 
 | ||||
|     // Attack and Damage Rolls
 | ||||
|     if ( action === "damage" ) await item.rollDamage({event}); | ||||
|     else if ( action === "formula" ) await item.rollFormula({event}); | ||||
| 
 | ||||
|     // Saving Throws for card targets
 | ||||
|     else if ( action == "save" ) { | ||||
|       if ( !targets.length ) { | ||||
|         ui.notifications.warn(`You must have one or more controlled Tokens in order to use this option.`); | ||||
|         return button.disabled = false; | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
|     // Attack and Damage Rolls
 | ||||
|     else if ( action === "damage" ) await item.rollDamage({event}); | ||||
|     else if ( action === "formula" ) await item.rollFormula({event}); | ||||
| 
 | ||||
|     // Saving Throws for card targets
 | ||||
|     else if ( action === "save" ) { | ||||
|       for ( let t of targets ) { | ||||
|         await t.rollAbilitySave(button.dataset.ability, {event}); | ||||
|         await t.rollSave(button.dataset.save, {event}); | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -55,9 +55,9 @@ Hooks.once("init", async function () { | |||
|  */ | ||||
| Hooks.once("setup", function () { | ||||
|   // Localize CONFIG objects once up-front
 | ||||
|   const toLocalize = []; | ||||
|   const toLocalize = ["saves_short", "saves_long", "scores"]; | ||||
|   for (let o of toLocalize) { | ||||
|     CONFIG.MAJI[o] = Object.entries(CONFIG.OSE[o]).reduce((obj, e) => { | ||||
|     CONFIG.OSE[o] = Object.entries(CONFIG.OSE[o]).reduce((obj, e) => { | ||||
|       obj[e[0]] = game.i18n.localize(e[1]); | ||||
|       return obj; | ||||
|     }, {}); | ||||
|  |  | |||
|  | @ -47,7 +47,6 @@ | |||
|       color: $colorOlive; | ||||
|       &:hover { | ||||
|         color: #111; | ||||
|         text-shadow: 0 0 10px red; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  |  | |||
|  | @ -2,7 +2,7 @@ | |||
|     {{#if tokenId}}data-token-id="{{tokenId}}" {{/if}}> | ||||
|     <header class="card-header flexrow"> | ||||
|         <img src="{{item.img}}" title="{{item.name}}" width="36" height="36" /> | ||||
|         <h3 class="item-name">{{item.name}}</h3> | ||||
|         <h3 class="item-name"><a>{{item.name}}</a></h3> | ||||
|     </header> | ||||
| 
 | ||||
|     <div class="card-content" style="display:none;"> | ||||
|  | @ -23,8 +23,8 @@ | |||
|         {{/if}} | ||||
| 
 | ||||
|         {{#if data.save}} | ||||
|         <button data-action="save" data-ability="{{data.save}}" disabled> | ||||
|             {{ localize "OSE.SavingThrow" }} {{data.save}} | ||||
|         <button data-action="save" data-save="{{data.save}}" disabled> | ||||
|             {{lookup config.saves_long data.save}} {{ localize "OSE.SavingThrow" }}  | ||||
|         </button> | ||||
|         {{/if}} | ||||
| 
 | ||||
|  |  | |||
|  | @ -40,8 +40,8 @@ | |||
|             <select name="data.save"> | ||||
|               {{#select data.save}} | ||||
|               <option value=""></option> | ||||
|               {{#each config.saves as |save a|}} | ||||
|               <option value="{{a}}">{{localize save}}</option> | ||||
|               {{#each config.saves_short as |save a|}} | ||||
|               <option value="{{a}}">{{save}}</option> | ||||
|               {{/each}} | ||||
|               {{/select}} | ||||
|             </select> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue