Skip to content

Commit 08d03dc

Browse files
share text now shows extra stuff if you match or beat the bot
1 parent c732616 commit 08d03dc

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

assets/js/app/lib/helpers.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ Deckdle.__addStateObjSession = (mode = Deckdle.__getGameMode()) => {
237237
}
238238
}
239239

240-
Deckdle.__getShareText = (mode = Deckdle.__getGameMode(), type = Deckdle.__getGameType()) => {
240+
Deckdle.__getShareText = (mode, type, botCompScore) => {
241241
let html = ''
242242

243243
if (mode == 'daily') {
@@ -262,6 +262,17 @@ Deckdle.__getShareText = (mode = Deckdle.__getGameMode(), type = Deckdle.__getGa
262262
gameScore = `GOLF: +${tableauCount + stockCount}`
263263
}
264264

265+
switch (botCompScore) {
266+
case 0:
267+
gameScore += ` == 🤖`
268+
break
269+
case 1:
270+
gameScore += ` > 🤖`
271+
break
272+
default:
273+
break
274+
}
275+
265276
html += `${gameScore}, x${Deckdle.__getState()['comboCurrentMax']}\n`
266277
break
267278
}

assets/js/app/main.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,12 @@ Deckdle._loadQueryString = (param) => {
255255
}
256256

257257
// copy results to clipboard for sharing
258-
Deckdle._shareResults = async () => {
259-
let shareText = Deckdle.__getShareText()
258+
Deckdle._shareResults = async (botCompScore) => {
259+
let shareText = Deckdle.__getShareText(
260+
Deckdle.__getGameMode(),
261+
Deckdle.__getGameType(),
262+
botCompScore
263+
)
260264

261265
// if (navigator.canShare({ text: shareText })) {
262266
// navigator.share({ text: shareText }).then(() => {

assets/js/app/modals.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ Deckdle.modalOpen = async (type) => {
351351
🤖 You <strong>matched</strong> the bot! <strong>Holy cowabunga!</strong> 🤖
352352
</div>
353353
`
354+
let botCompScore = -1
354355

355356
if (Deckdle.myModal) {
356357
Deckdle.myModal._destroyModal()
@@ -420,8 +421,10 @@ Deckdle.modalOpen = async (type) => {
420421
// flip stockCount so it's negative (bot score will be negative, too)
421422
if (-stockCount < botScore) {
422423
modalText += botBeatHTML
424+
botCompScore = 1
423425
} else if (-stockCount == botScore) {
424426
modalText += botMatchHTML
427+
botCompScore = 0
425428
}
426429
}
427430
// loss
@@ -430,8 +433,10 @@ Deckdle.modalOpen = async (type) => {
430433
// (which will be a positive number for their tableau count)
431434
if (tableauCount < botScore) {
432435
modalText += botBeatHTML
436+
botCompScore = 1
433437
} else if (tableauCount == botScore) {
434438
modalText += botMatchHTML
439+
botCompScore = 0
435440
}
436441
}
437442
}
@@ -483,7 +488,7 @@ Deckdle.modalOpen = async (type) => {
483488
if (gameState == 'GAME_OVER') {
484489
modalText += `
485490
<div class="share">
486-
<button class="game-over share" onclick="Deckdle._shareResults()">Share <i class="fa-solid fa-share-nodes"></i></button>
491+
<button class="game-over share" onclick="Deckdle._shareResults(${botCompScore})">Share <i class="fa-solid fa-share-nodes"></i></button>
487492
</div>
488493
<div class="bot-score">
489494
<button class="fa-solid fa-robot icon tiny solo" title="${botScoreDaily}" onclick="Deckdle.modalOpen('bot-score')"></button>

0 commit comments

Comments
 (0)