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

Remove bonus/penalty slider from ranged combat chat message replace with buttons #1641

Merged
merged 1 commit into from
Dec 1, 2024
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
2 changes: 2 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,8 @@
"CoC7.OpenObstacleResolutionCard": "Start obstacle resolution flow card.",
"CoC7.AddBonusDie": "Add bonus die",
"CoC7.RemoveBonusDie": "Remove bonus die",
"CoC7.AdditionalBonusDie": "Additional Bonus Die",
"CoC7.AdditionalPenaltyDie": "Additional Penalty Die",
"CoC7.DecreaseMovementAction": "Decrease movement action",
"CoC7.IncreaseMovementAction": "Increase movement action",
"CoC7.CautiousApproach": "Take cautious approach",
Expand Down
35 changes: 11 additions & 24 deletions module/chat/rangecombat.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export class CoC7RangeInitiator {
this.cover = false
this.surprised = false
this.autoSuccess = false
this.diceModifier = 0
this.messageId = null
this.targetCard = null
this.rolled = false
Expand All @@ -23,6 +22,10 @@ export class CoC7RangeInitiator {
this.fullAuto = false
this.tokenKey = null
this.aimed = false
this.bonusDieA = false
this.bonusDieB = false
this.penaltyDieA = false
this.penaltyDieB = false
this.totalBulletsFired = 0
this._targets = []
for (const t of [...game.user.targets]) {
Expand Down Expand Up @@ -318,7 +321,7 @@ export class CoC7RangeInitiator {
if (t.longRange) damage = this.weapon.system.range.long.damage
if (t.extremeRange) damage = this.weapon.system.range.extreme.damage
}
let modifier = parseInt(this.diceModifier, 10) + parseInt(target.modifier, 10)
let modifier = parseInt(target.modifier, 10)
let difficulty
this.weapon.system.properties.shotgun
? (difficulty = 1)
Expand All @@ -328,6 +331,10 @@ export class CoC7RangeInitiator {
if (this.reload) modifier--
if (this.multipleShots && !this.fullAuto) modifier--
if (this.fullAuto) modifier -= this.currentShotRank - 1
if (this.bonusDieA) modifier++
if (this.bonusDieB) modifier++
if (this.penaltyDieA) modifier--
if (this.penaltyDieB) modifier--
this._calculatedModifier = modifier
if (modifier < -2) {
const excess = Math.abs(modifier + 2)
Expand Down Expand Up @@ -436,10 +443,6 @@ export class CoC7RangeInitiator {
return 'systems/CoC7/templates/chat/combat/range-initiator.html'
}

get diceModifierDisplay () {
return Math.max(-2, Math.min(2, parseInt(this.diceModifier, 10)))
}

async createChatCard () {
this.calcTargetsDifficulty()
const html = await renderTemplate(this.template, this)
Expand Down Expand Up @@ -505,23 +508,7 @@ export class CoC7RangeInitiator {
this.burst = !this.burst
} else {
this[flag] = !this[flag]
}
switch (flag) {
case 'aiming':
if (this.currentShotRank === 1) {
this.diceModifier = parseInt(this.diceModifier, 10) + (this[flag] ? 1 : -1)
}
break
case 'multipleShots':
if (!this.fullAuto) {
this.diceModifier = parseInt(this.diceModifier, 10) + (this[flag] ? -1 : 1)
}
break
case 'fullAuto':
if (!this.fullAuto) {
this.diceModifier = parseInt(this.diceModifier, 10) + (this[flag] ? -(this.currentShotRank - 1) : (this.currentShotRank - 1))
}
break
console.log(flag, this[flag])
}
}

Expand Down Expand Up @@ -1073,7 +1060,7 @@ export class CoC7RangeTarget {
this.big = false
} else this.small = true
} else this[flag] = !this[flag]
if (flag === 'fast' && this.fast && !this.isFast) {
if (this.actor && flag === 'fast' && this.fast && !this.isFast) {
ui.notifications.warn(
game.i18n.format('CoC7.WarnFastTargetWithWrongMOV', {
mov: this.actor.mov
Expand Down
33 changes: 11 additions & 22 deletions templates/chat/combat/range-initiator.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="coc7 chat-card range initiator" data-actor-key="{{actorKey}}" data-item-id="{{item.id}}" data-fast-forward="{{fastForward}}" data-resolved="{{resolved}}" data-rolled="{{rolled}}" data-cover="{{cover}}" data-surprised="{{surprised}}" data-auto-success="{{autoSuccess}}" data-single-shot="{{singleShot}}" data-multiple-shots="{{multipleShots}}" data-burst="{{burst}}" data-full-auto="{{fullAuto}}" data-dice-modifier="{{diceModifier}}" data-aiming={{aiming}} data-is-GM="{{isKeeper}}" data-aimed="{{aimed}}" data-damage-rolled="{{damageRolled}}" data-damage-dealt="{{damageDealt}}" data-total-bullets-fired="{{totalBulletsFired}}" data-roll-mode="{{rollMode}}" data-is-blind="false" data-volley-size="{{volleySize}}">
<div class="coc7 chat-card range initiator" data-actor-key="{{actorKey}}" data-item-id="{{item.id}}" data-fast-forward="{{fastForward}}" data-resolved="{{resolved}}" data-rolled="{{rolled}}" data-cover="{{cover}}" data-surprised="{{surprised}}" data-auto-success="{{autoSuccess}}" data-single-shot="{{singleShot}}" data-multiple-shots="{{multipleShots}}" data-burst="{{burst}}" data-full-auto="{{fullAuto}}" data-bonus-die-a="{{bonusDieA}}" data-bonus-die-b="{{bonusDieB}}" data-penalty-die-a="{{penaltyDieA}}" data-penalty-die-b="{{penaltyDieB}}" data-aiming={{aiming}} data-is-GM="{{isKeeper}}" data-aimed="{{aimed}}" data-damage-rolled="{{damageRolled}}" data-damage-dealt="{{damageDealt}}" data-total-bullets-fired="{{totalBulletsFired}}" data-roll-mode="{{rollMode}}" data-is-blind="false" data-volley-size="{{volleySize}}">
<header class="card-header flexcol">
<div class="flexrow">
{{#if displayActorOnCard}}
Expand Down Expand Up @@ -52,27 +52,7 @@ <h3 style="text-align: center;font-weight: bolder;" class="item-name card-title"
{{/if}}
<span class="flex1 toggle-switch aiming {{#unless rolled}}simple-flag{{/unless}} {{#if aiming}}switched-on{{/if}} gm-select-only" title="{{localize 'CoC7.rangeCombatCard.AimingTitle'}}" style="text-align:center" data-flag="aiming" data-selected={{aiming}}>{{localize 'CoC7.rangeCombatCard.aiming'}}</span>
</div>

<div style="flex: 1;display: flex;flex-direction: column;margin: 0.5rem 1rem 0;opacity:0.6">
<div class="flexrow">
<span style="flex: 4; text-align: left">{{localize 'CoC7.PenaltyDice'}}</span>
<span style="flex: 1">&nbsp;</span>
<span style="flex: 4; text-align: right">{{localize 'CoC7.BonusDice'}}</span>
</div>
<div class="flexrow">
<span style="flex: 1; text-align: left;">-2</span>
<span style="flex: 1; text-align: center;"></span>
<span style="flex: 1; text-align: center;">-1</span>
<span style="flex: 1; text-align: center;"></span>
<span style="flex: 1; text-align: center;">0</span>
<span style="flex: 1; text-align: center;"></span>
<span style="flex: 1; text-align: center;">+1</span>
<span style="flex: 1; text-align: center;"></span>
<span style="flex: 1; text-align: right;">+2</span>
</div>
<input type="range" name="diceModifier" min="-2" max="2" value="{{diceModifierDisplay}}" class="slider gm-range-only">
</div>
{{/if}}
{{/if}}
</header>

<div class="targets">
Expand Down Expand Up @@ -132,6 +112,15 @@ <h3 style="text-align: center;font-weight: bolder;" class="item-name card-title"
<span class="flex1 toggle-switch inMelee target-flag {{#unless ../rolled}}simple-flag{{/unless}} {{#if trgt.inMelee}}switched-on{{/if}} gm-select-only" title="{{localize 'CoC7.rangeCombatCard.InMeleeTitle'}}" style="text-align:center" data-flag="in-melee" data-selected={{trgt.inMelee}}>{{localize 'CoC7.rangeCombatCard.InMelee'}}</span>
<span class="flex1 toggle-switch fast target-flag {{#unless ../rolled}}simple-flag{{/unless}} {{#if trgt.fast}}switched-on{{/if}} gm-select-only" title="{{localize 'CoC7.rangeCombatCard.FastMovingTargetTitle'}}" style="text-align:center" data-flag="fast" data-selected={{trgt.fast}}>{{localize 'CoC7.rangeCombatCard.FastMovingTarget'}}</span>
</div>
{{log ../this}}
<div class="flexrow range-selection" style="border-top: 2px groove #fff; padding-top: 3px">
<span class="flex1 toggle-switch {{#unless ../rolled}}simple-flag{{/unless}} {{#if ../bonusDieA}}switched-on{{/if}} gm-select-only" title="{{localize 'CoC7.AdditionalBonusDie'}}" style="text-align:center" data-flag="bonus-die-a">{{localize 'CoC7.AdditionalBonusDie'}}</span>
<span class="flex1 toggle-switch {{#unless ../rolled}}simple-flag{{/unless}} {{#if ../bonusDieB}}switched-on{{/if}} gm-select-only" title="{{localize 'CoC7.AdditionalBonusDie'}}" style="text-align:center" data-flag="bonus-die-b">{{localize 'CoC7.AdditionalBonusDie'}}</span>
</div>
<div class="flexrow range-selection" style="border-bottom: 2px groove #fff; padding-top: 3px">
<span class="flex1 toggle-switch {{#unless ../rolled}}simple-flag{{/unless}} {{#if ../penaltyDieA}}switched-on{{/if}} gm-select-only" title="{{localize 'CoC7.AdditionalPenaltyDie'}}" style="text-align:center" data-flag="penalty-die-a">{{localize 'CoC7.AdditionalPenaltyDie'}}</span>
<span class="flex1 toggle-switch {{#unless ../rolled}}simple-flag{{/unless}} {{#if ../penaltyDieB}}switched-on{{/if}} gm-select-only" title="{{localize 'CoC7.AdditionalPenaltyDie'}}" style="text-align:center" data-flag="penalty-die-b">{{localize 'CoC7.AdditionalPenaltyDie'}}</span>
</div>

{{#if ../calculatedBonusDice}}
<div class="flexrow" style="margin-top: 5px;">
Expand Down
Loading