Adds item-sheet CSS class to item sheets.
This commit is contained in:
Michael Stein 2023-04-19 01:33:04 +02:00
parent f91c64f91f
commit ae3381b3d1
13 changed files with 41 additions and 25 deletions

View File

@ -20,6 +20,8 @@
"midgard5.fw": "FW", "midgard5.fw": "FW",
"midgard5.bonus": "Bonus", "midgard5.bonus": "Bonus",
"midgard5.ew": "EW", "midgard5.ew": "EW",
"midgard5.pp-short": "PP",
"midgard5.pp": "Praxispunkte",
"midgard5.item-value": "Wert", "midgard5.item-value": "Wert",
"midgard5.item-quantity": "Menge", "midgard5.item-quantity": "Menge",

View File

@ -3,6 +3,7 @@ import { BooleanField } from "@league-of-foundry-developers/foundry-vtt-types/sr
export interface M5Skill { export interface M5Skill {
fw: number fw: number
attribute: string attribute: string
pp: number
} }
export interface M5SkillUnlearned extends M5Skill { export interface M5SkillUnlearned extends M5Skill {

View File

@ -122,7 +122,7 @@ export class M5Character extends Actor {
ret.stats.brawlEw = ret.stats.brawl.value + ret.stats.attackBonus.value ret.stats.brawlEw = ret.stats.brawl.value + ret.stats.attackBonus.value
ret.stats.poisonResistance = this.modResult(30 + Math.floor(ret.attributes.ko.value / 2)) ret.stats.poisonResistance = this.modResult(30 + Math.floor(ret.attributes.ko.value / 2))
ret.stats.enduranceBonus = Math.floor(ret.attributes.ko.value/10) + Math.floor(ret.attributes.st.value/20) ret.stats.enduranceBonus = Math.floor(ret.attributes.ko.value/10) + Math.floor(ret.attributes.st.value/20)
if (!skip?.mods) { if (!skip?.mods) {
const aggregate = new M5ModAggregate(data, ret) const aggregate = new M5ModAggregate(data, ret)
@ -136,7 +136,6 @@ export class M5Character extends Actor {
}) })
ret.skillMods = aggregate.calculate() ret.skillMods = aggregate.calculate()
// TODO apply attribute and stat calculation to ret.
} }
if (!skip?.items) { if (!skip?.items) {
@ -164,6 +163,7 @@ export class M5Character extends Actor {
label: item.name, label: item.name,
fw: item.system.fw, fw: item.system.fw,
attribute: item.system.attribute, attribute: item.system.attribute,
pp: item.system.pp,
calc: item.system.calc calc: item.system.calc
} as M5SkillCalculated } as M5SkillCalculated
}) })
@ -244,6 +244,7 @@ export class M5Character extends Actor {
} }
prepareDerivedData() { prepareDerivedData() {
console.log("M5Character", "prepareDerivedData")
const data = (this as any).system const data = (this as any).system
data.calc = this.derivedData({}) data.calc = this.derivedData({})
} }
@ -295,9 +296,8 @@ export class M5Character extends Actor {
} }
skillBonus(skill: M5Skill, skillName?: string) { skillBonus(skill: M5Skill, skillName?: string) {
const attribute = this.attribute(skill.attribute) const data = (this as any).system
let ret = attribute ? M5Character.attributeBonus(attribute) : 0 return data.calc?.attributes[skill.attribute]?.bonus ?? 0
return ret
} }
skillEw(skill: M5Skill, skillName?: string) { skillEw(skill: M5Skill, skillName?: string) {

View File

@ -236,17 +236,17 @@ export class M5Item extends Item {
return (this as any).getEmbeddedDocument("Item", itemId) return (this as any).getEmbeddedDocument("Item", itemId)
} }
override migrateSystemData(): any { // migrateSystemData(): any {
const item = (this as any) // const item = (this as any)
const data = item.system // const data = item.system
if (item.type === "spell") { // if (item.type === "spell") {
if (typeof data.ap !== "string") { // if (typeof data.ap !== "string") {
data.ap = Number.isFinite(data.ap) ? "" + data.ap : "" // data.ap = Number.isFinite(data.ap) ? "" + data.ap : ""
} // }
} // }
return super.migrateSystemData() // return super.migrateSystemData()
} // }
} }

View File

@ -5,8 +5,8 @@ export class M5ItemSheet extends ItemSheet {
static get defaultOptions() { static get defaultOptions() {
return mergeObject(super.defaultOptions, { return mergeObject(super.defaultOptions, {
width: 420, width: 640,
height: 240, height: 480,
classes: ["midgard5", "sheet", "item"] classes: ["midgard5", "sheet", "item"]
}) })
} }

View File

@ -5,6 +5,7 @@
<th>{{localize "midgard5.fw"}}</th> <th>{{localize "midgard5.fw"}}</th>
<th>{{localize "midgard5.bonus"}}</th> <th>{{localize "midgard5.bonus"}}</th>
<th>{{localize "midgard5.ew"}}</th> <th>{{localize "midgard5.ew"}}</th>
<th>{{localize "midgard5.pp-short"}}</th>
<th></th> <th></th>
<th></th> <th></th>
</tr> </tr>
@ -16,6 +17,7 @@
<td class="fixed-value">{{skill.fw}}</td> <td class="fixed-value">{{skill.fw}}</td>
<td class="fixed-value">{{skill.calc.bonus}}</td> <td class="fixed-value">{{skill.calc.bonus}}</td>
<td class="fixed-value">{{skill.calc.ew}}</td> <td class="fixed-value">{{skill.calc.ew}}</td>
<td class="fixed-value">{{skill.pp}}</td>
<td class="fixed-value"><button class="roll-button roll-learned-button"></button></td> <td class="fixed-value"><button class="roll-button roll-learned-button"></button></td>
<td class="fixed-value"><a class="item-delete" title="Delete Item"><i class="fas fa-trash"></i></a></td> <td class="fixed-value"><a class="item-delete" title="Delete Item"><i class="fas fa-trash"></i></a></td>
</tr> </tr>
@ -30,6 +32,7 @@
<th>{{localize "midgard5.fw"}}</th> <th>{{localize "midgard5.fw"}}</th>
<th>{{localize "midgard5.bonus"}}</th> <th>{{localize "midgard5.bonus"}}</th>
<th>{{localize "midgard5.ew"}}</th> <th>{{localize "midgard5.ew"}}</th>
<th>{{localize "midgard5.pp-short"}}</th>
<th></th> <th></th>
<th></th> <th></th>
</tr> </tr>
@ -41,6 +44,7 @@
<td class="fixed-value">{{skill.fw}}</td> <td class="fixed-value">{{skill.fw}}</td>
<td class="fixed-value">{{skill.calc.bonus}}</td> <td class="fixed-value">{{skill.calc.bonus}}</td>
<td class="fixed-value">{{skill.calc.ew}}</td> <td class="fixed-value">{{skill.calc.ew}}</td>
<td class="fixed-value">{{skill.pp}}</td>
<td class="fixed-value"><button class="roll-button roll-learned-button"></button></td> <td class="fixed-value"><button class="roll-button roll-learned-button"></button></td>
<td class="fixed-value"><a class="item-delete" title="Delete Item"><i class="fas fa-trash"></i></a></td> <td class="fixed-value"><a class="item-delete" title="Delete Item"><i class="fas fa-trash"></i></a></td>
</tr> </tr>
@ -80,6 +84,7 @@
<th>{{localize "midgard5.fw"}}</th> <th>{{localize "midgard5.fw"}}</th>
<th>{{localize "midgard5.bonus"}}</th> <th>{{localize "midgard5.bonus"}}</th>
<th>{{localize "midgard5.ew"}}</th> <th>{{localize "midgard5.ew"}}</th>
<th>{{localize "midgard5.pp-short"}}</th>
<th></th> <th></th>
<th></th> <th></th>
</tr> </tr>
@ -91,6 +96,7 @@
<td class="fixed-value">{{skill.fw}}</td> <td class="fixed-value">{{skill.fw}}</td>
<td class="fixed-value">{{skill.calc.bonus}}</td> <td class="fixed-value">{{skill.calc.bonus}}</td>
<td class="fixed-value">{{skill.calc.ew}}</td> <td class="fixed-value">{{skill.calc.ew}}</td>
<td class="fixed-value">{{skill.pp}}</td>
<td class="fixed-value"><button class="roll-button roll-learned-button"></button></td> <td class="fixed-value"><button class="roll-button roll-learned-button"></button></td>
<td class="fixed-value"><a class="item-delete" title="Delete Item"><i class="fas fa-trash"></i></a></td> <td class="fixed-value"><a class="item-delete" title="Delete Item"><i class="fas fa-trash"></i></a></td>
</tr> </tr>
@ -106,18 +112,20 @@
<th>{{localize "midgard5.fw"}}</th> <th>{{localize "midgard5.fw"}}</th>
<th>{{localize "midgard5.bonus"}}</th> <th>{{localize "midgard5.bonus"}}</th>
<th>{{localize "midgard5.ew"}}</th> <th>{{localize "midgard5.ew"}}</th>
<th>{{localize "midgard5.pp-short"}}</th>
<th></th> <th></th>
<th></th> <th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{#each actor.system.skills.general as |skill key|}} {{#each data.skills.general as |skill key|}}
<tr data-skill="{{key}}"> <tr data-skill="{{key}}">
<td><button class="learn-button">{{localize "midgard5.learn"}}</button></td> <td><button class="learn-button">{{localize "midgard5.learn"}}</button></td>
<td class="padding">{{localizeMidgard key}}</td> <td class="padding">{{localizeMidgard key}}</td>
<td class="fixed-value">{{skill.fw}}</td> <td class="fixed-value">{{skill.fw}}</td>
<td class="fixed-value">{{skillBonus ../actor._id skill}}</td> <td class="fixed-value">{{skillBonus ../actor._id skill}}</td>
<td class="fixed-value">{{skillEw ../actor._id skill}}</td> <td class="fixed-value">{{skillEw ../actor._id skill}}</td>
<td class="fixed-value"><input name="data.skills.general.{{key}}.pp" type="text" value="{{skill.pp}}" data-dtype="Number" /></td>
<td class="fixed-value"><button class="roll-button roll-general-button"></button></td> <td class="fixed-value"><button class="roll-button roll-general-button"></button></td>
<td class="fixed-value"></td> <td class="fixed-value"></td>
</tr> </tr>

View File

@ -1,4 +1,4 @@
<form class="{{cssClass}}" autocomplete="off"> <form class="item-sheet {{cssClass}}" autocomplete="off">
<header class="sheet-header"> <header class="sheet-header">
<img class="item-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" /> <img class="item-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" />
<h1><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1> <h1><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1>

View File

@ -1,4 +1,4 @@
<form class="{{cssClass}}" autocomplete="off"> <form class="item-sheet {{cssClass}}" autocomplete="off">
<header class="sheet-header"> <header class="sheet-header">
<img class="item-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" /> <img class="item-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" />
<h1><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1> <h1><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1>

View File

@ -1,4 +1,4 @@
<form class="{{cssClass}} m5item-item" autocomplete="off"> <form class="item-sheet {{cssClass}} m5item-item" autocomplete="off">
<header class="sheet-header"> <header class="sheet-header">
<img class="item-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" /> <img class="item-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" />
<h1><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1> <h1><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1>

View File

@ -1,4 +1,4 @@
<form class="{{cssClass}}" autocomplete="off"> <form class="item-sheet {{cssClass}}" autocomplete="off">
<header class="sheet-header"> <header class="sheet-header">
<img class="item-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" /> <img class="item-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" />
<h1><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1> <h1><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1>

View File

@ -1,4 +1,4 @@
<form class="{{cssClass}}" autocomplete="off"> <form class="item-sheet {{cssClass}}" autocomplete="off">
<header class="sheet-header"> <header class="sheet-header">
<img class="item-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" /> <img class="item-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" />
<h1><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1> <h1><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1>
@ -26,6 +26,11 @@
</td> </td>
</tr> </tr>
{{/unless}} {{/unless}}
<tr>
<td>{{localize "midgard5.pp"}}</td>
<td><input name="data.pp" type="text" value="{{data.pp}}" data-dtype="Number" /></td>
</tr>
</tbody> </tbody>
</table> </table>

View File

@ -1,4 +1,4 @@
<form class="{{cssClass}}" autocomplete="off"> <form class="item-sheet {{cssClass}}" autocomplete="off">
<header class="sheet-header"> <header class="sheet-header">
<img class="item-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" /> <img class="item-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" />
<h1><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1> <h1><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1>

View File

@ -1,4 +1,4 @@
<form class="{{cssClass}}" autocomplete="off"> <form class="item-sheet {{cssClass}}" autocomplete="off">
<header class="sheet-header"> <header class="sheet-header">
<img class="item-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" /> <img class="item-img" src="{{item.img}}" data-edit="img" title="{{item.name}}" />
<h1><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1> <h1><input name="name" type="text" value="{{item.name}}" placeholder="Name" /></h1>