Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to hide spell casts #1573

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
"CoC7.Initiative": "Initiative",

"CoC7.Cast": "Cast",
"CoC7.CastHidden": "Cast Hidden",
"CoC7.SanityCost": "Sanity Cost",
"CoC7.PowerCost": "Power Cost",
"CoC7.HitPointsCost": "Hit Points Cost",
Expand Down
1 change: 1 addition & 0 deletions lang/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
"CoC7.Initiative": "Inicjatywa",

"CoC7.Cast": "Rzuć",
"CoC7.CastHidden": "Rzuć ukryty",
"CoC7.SanityCost": "Koszt Poczytalności",
"CoC7.PowerCost": "Koszt Mocy",
"CoC7.HitPointsCost": "Koszt PW",
Expand Down
26 changes: 17 additions & 9 deletions module/items/spell/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class CoC7Spell extends CoC7Item {
this.context = context
}

async cast () {
async cast (priv) {
if (!this.isOwned) {
/** This is not owned by any Actor */
return ui.notifications.error(game.i18n.localize('CoC7.NotOwned'))
Expand Down Expand Up @@ -67,20 +67,24 @@ export class CoC7Spell extends CoC7Item {
}
for (const [key, value] of Object.entries(costs)) {
if (!value || Number(value) === 0) continue
losses.push(await this.resolveLosses(key, value))
losses.push(await this.resolveLosses(key, value, priv))
}
const template = 'systems/CoC7/templates/items/spell/chat.html'
const description = this.system.description.value
const html = await renderTemplate(template, { description, losses })
return await ChatMessage.create({
let chatData = {
user: game.user.id,
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
flavor: this.name,
content: html
})
}
if (priv) {
chatData = ChatMessage.applyRollMode(chatData, 'gmroll')
}
return await ChatMessage.create(chatData)
}

async resolveLosses (characteristic, value) {
async resolveLosses (characteristic, value, priv) {
let characteristicName
let loss
if (CoC7Utilities.isFormula(value)) {
Expand All @@ -96,7 +100,7 @@ export class CoC7Spell extends CoC7Item {
break
case 'sanity':
characteristicName = game.i18n.localize('CoC7.SanityPoints')
this.grantSanityLoss(loss)
this.grantSanityLoss(loss, priv)
break
case 'magicPoints':
characteristicName = game.i18n.localize('CoC7.MagicPoints')
Expand All @@ -113,17 +117,21 @@ export class CoC7Spell extends CoC7Item {
}

/** Bypass the Sanity check and just roll the damage */
async grantSanityLoss (value) {
async grantSanityLoss (value, priv) {
const template = SanCheckCard.template
let html = await renderTemplate(template, {})
const message = await ChatMessage.create({
let chatData = {
user: game.user.id,
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
flavor: game.i18n.format('CoC7.CastingSpell', {
spell: this.name
}),
content: html
})
}
if (priv) {
chatData = ChatMessage.applyRollMode(chatData, 'gmroll')
}
const message = await ChatMessage.create(chatData)
const card = await message.getHTML()
if (typeof card.length !== 'undefined' && card.length === 1) {
const sanityLoss = value
Expand Down
6 changes: 5 additions & 1 deletion module/items/spell/sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ export class CoC7SpellSheet extends ItemSheet {
html.find('.option').click(event => this.modifyType(event))
html.find('#cast-spell').click(event => {
event.preventDefault()
this.item.cast()
this.item.cast(false)
})
html.find('#cast-spell-hidden').click(event => {
event.preventDefault()
this.item.cast(true)
})
}

Expand Down
3 changes: 2 additions & 1 deletion styles/sheets/spell.less
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,13 @@
max-width: fit-content;
}

#cast-spell {
.cast-button {
align-items: center;
background: rgba(0, 0, 0, 0.05);
border: 0.065rem solid var(--main-sheet-front-color);
border-radius: 0.25rem;
padding: 0.3rem;
margin-bottom: 0.5rem;

&:focus,
&:hover {
Expand Down
9 changes: 8 additions & 1 deletion templates/items/spell/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@
<div class="aside">
{{#if (and hasOwner (or isKeeper isOwner))}}
<div class="flexrow">
<span id="cast-spell">
<span id="cast-spell" class="cast-button">
<label>
{{localize "CoC7.Cast"}}
</label>
</span>
{{#if isKeeper}}
<span id="cast-spell-hidden" class="cast-button">
<label>
{{localize "CoC7.CastHidden"}}
</label>
</span>
{{/if}}
</div>
{{/if}}
</div>
Expand Down