import { LitElement, html, css } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import { Spell } from './Spell'; @customElement('dd-spell') export class SpellCard extends LitElement { name: string = ''; cost: number = 0; color: string = ''; category: string = ''; description: string = ''; cantripMagic: boolean = false; reserveMagic: boolean = false; @property() spellRemover: any = null; @property() selectSpell: any = null; showDesc: string = 'none'; static get properties() { return { name: { type: String }, cost: { type: Number }, color: { type: String }, category: { type: String }, description: { type: String }, cantripMagic: { type: Boolean }, reserveMagic: { type: Boolean }, } }; openSpellDescription() { if (this.showDesc === 'none') { this.showDesc = 'block'; } else { this.showDesc = 'none'; } this.requestUpdate(); } removeSpell(event: any) { if (this.spellRemover && typeof this.spellRemover === 'function') { this.spellRemover(this.name); event.preventDefault(); } } selectASpell(event: any) { if (this.selectSpell && typeof this.selectSpell === 'function') { this.selectSpell({ name: this.name, cost: this.cost, color: this.color, category: this.category, description: this.description, cantripMagic: this.cantripMagic, reserveMagic: this.reserveMagic, }); event.preventDefault(); } } getColor() { switch (this.color) { case 'Black': return 'black'; case 'Blue': return 'blue'; case 'Green': return 'green'; case 'Red': return 'red'; case 'Yellow': return '#FFDB58'; case 'Gold': return '#FFD700'; case 'Bronze': return '#CD7F32'; case 'Silver': return '#BCC6CC'; default: return 'grey'; } } static styles = [ css` .spell-card { border: .1em solid black; border-radius: .25em; padding: .25em; } ` ]; override render() { return html`
${this.name} - ${this.color} (${this.cost})
Category: ${this.category}
${this.cantripMagic ? html`
Cantrip Castable
` : ''} ${this.reserveMagic ? html`
Reserve Castable
` : ''}
${this.description}
`; } } declare global { interface HTMLElementTagNameMap { 'dd-spell': SpellCard; } }