Skip to content

Commit

Permalink
slot
Browse files Browse the repository at this point in the history
  • Loading branch information
PapiOphidian committed Nov 19, 2023
1 parent cab1d91 commit 91dc286
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 48 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"build": "turbo run build"
},
"devDependencies": {
"@types/node": "^20.9.1",
"@types/node": "^20.9.2",
"@typescript-eslint/eslint-plugin": "^6.11.0",
"@typescript-eslint/parser": "^6.11.0",
"discord-api-types": "0.37.63",
"eslint": "^8.54.0",
"tsup": "^7.3.0",
"tsup": "^8.0.0",
"turbo": "^1.10.16",
"typescript": "^5.2.2"
},
Expand Down
Binary file modified packages/runtime-worker/images/backgrounds/commands/slot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 10 additions & 7 deletions packages/runtime-worker/src/ImageCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ const images = {
"badge-giver3": "badges/GivingHandTier3_50x50.png",
"badge-giver4": "badges/GivingHandTier4_50x50.png",

"apple": "emojis/apple.png",
"cherries": "emojis/cherries.png",
"apple": "emojis/apple-warped.png",
"cherries": "emojis/cherries-warped.png",
"discoin": "emojis/discoin.png",
"heart": "emojis/heart.png",
"heart": "emojis/heart-warped.png",
"heart-broken": "emojis/pixel_heart_broken.png",
"heart-full": "emojis/pixel_heart.png",
"pear": "emojis/pear.png",
"strawberry": "emojis/strawberry.png",
"pear": "emojis/pear-warped.png",
"strawberry": "emojis/strawberry-warped.png",
"triangle": "emojis/triangle.png",
"watermelon": "emojis/watermelon.png",
"watermelon": "emojis/watermelon-warped.png",

"add-circle": "icons/add_circle.png",
"neko": "icons/NEKO.png",
Expand All @@ -42,7 +42,10 @@ const images = {
"profile-light": "overlays/profile_light.png",
"old-profile-light": "overlays/profile_old_light.png",
"old-profile": "overlays/profile_old.png",
"profile": "overlays/profile.png"
"profile": "overlays/profile.png",
"slot-jackpot": "overlays/JACKPOT.png",
"slot-win": "overlays/YOUWIN.png",
"slot-lost": "overlays/YOULOST.png"
}

import type { UnpackArray } from "@amanda/shared-types"
Expand Down
56 changes: 27 additions & 29 deletions packages/runtime-worker/src/commands/money.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,27 +399,14 @@ commands.assign([

const fruits = ["apple" as const, "cherries" as const, "watermelon" as const, "pear" as const, "strawberry" as const] // plus heart, which is chosen seperately
const isPremium = await sql.orm.get("premium", { user_id: cmd.author.id })
let cooldownInfo: { max: number, min: number, step: number, regen: { amount: number, time: number, } }
// avg % assumes 5 fruits + heart, heart payouts [0, 1.25, 4, 20], triple fruit payout 5
if (isPremium?.state) {
cooldownInfo = {
max: 190, // avg +6.2% per roll
min: 172, // avg -4.8% per roll
step: 6, // 4 rolls to hit the bottom
regen: {
amount: 1,
time: 20 * 1000 // 2 minutes to recover by 1 roll
}
}
} else {
cooldownInfo = {
max: 186, // avg +3.6% per roll
min: 164, // avg -9.4% per roll
step: 7, // 4.6 rolls to hit the bottom
regen: {
amount: 1,
time: 30 * 1000 // 3.5 minutes to recover by 1 roll
}
const cooldownInfo = {
max: isPremium?.state ? 190 : 186,
min: isPremium?.state ? 172 : 164,
step: isPremium?.state ? 6 : 7,
regen: {
amount: 1,
time: (isPremium?.state ? 20 : 30) * 1000
}
}

Expand All @@ -433,7 +420,10 @@ commands.assign([
"heart",
"pear",
"strawberry",
"watermelon"
"watermelon",
"slot-jackpot",
"slot-win",
"slot-lost"
])
])

Expand All @@ -443,16 +433,24 @@ commands.assign([
else slots[i] = sharedUtils.arrayRandom(fruits)
}

const canvas = Canvas.createCanvas(600, 800).getContext("2d")
const canvas = Canvas.createCanvas(1200, 1600).getContext("2d")
const bg = images.get("slot-background")!
canvas.drawImage(bg, 0, 0)

const pieces: Array<Canvas.Image> = []
slots.forEach(i => pieces.push(images.get(i)!/* .resize(85, 85)*/))

canvas.drawImage(pieces[0], 100, 560, 85, 85)
canvas.drawImage(pieces[1], 258, 560, 85, 85)
canvas.drawImage(pieces[2], 412, 560, 85, 85)
canvas.drawImage(pieces[0], 200, 814, 100, 100)
canvas.drawImage(pieces[1], 400, 785, 110, 110)
canvas.drawImage(pieces[2], 632, 753, 120, 120)

const text = slots.every(s => s === "heart")
? images.get("slot-jackpot")!
: slots.includes("heart") || slots.slice(1).every(s => s === slots[0])
? images.get("slot-win")!
: images.get("slot-lost")!

canvas.drawImage(text, 283, 1108)

const amount = cmd.data.options.get("amount")?.asNumber()

Expand All @@ -474,16 +472,16 @@ commands.assign([

let result = ""
let winning = BigInt(0)
if (slots.every(s => s == "heart")) {
if (slots.every(s => s === "heart")) {
winning = bet * BigInt(20)
result = lang.GLOBAL.THREE_HEARTS
} else if (slots.filter(s => s == "heart").length == 2) {
} else if (slots.filter(s => s === "heart").length === 2) {
winning = bet * BigInt(4)
result = lang.GLOBAL.TWO_HEARTS
} else if (slots.filter(s => s == "heart").length == 1) {
} else if (slots.filter(s => s === "heart").length === 1) {
winning = bet + (bet / BigInt(3))
result = lang.GLOBAL.ONE_HEART
} else if (slots.slice(1).every(s => s == slots[0])) {
} else if (slots.slice(1).every(s => s === slots[0])) {
winning = bet * BigInt(5)
result = lang.GLOBAL.TRIPLE_PIECES
} else {
Expand Down
23 changes: 13 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -950,12 +950,12 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:^20.9.1":
version: 20.9.1
resolution: "@types/node@npm:20.9.1"
"@types/node@npm:^20.9.2":
version: 20.9.2
resolution: "@types/node@npm:20.9.2"
dependencies:
undici-types: ~5.26.4
checksum: bb893c6790733dac32818c1ca170fa466622dec39a0ade4639463e1358cb811771e242accbd065e7a1bfe59adc989c0ee59be65e462d3a0ab49043426f0b7637
checksum: 5bbb8fb2248fc5c5c4071d9809fb9af85997677c07124d65665202b53283a3b7bdff26fb844e9ee407e3847dfce6399c2b01e3329ea44a4b720647b1b987c678
languageName: node
linkType: hard

Expand Down Expand Up @@ -1244,15 +1244,15 @@ __metadata:
version: 0.0.0-use.local
resolution: "amanda@workspace:."
dependencies:
"@types/node": ^20.9.1
"@types/node": ^20.9.2
"@typescript-eslint/eslint-plugin": ^6.11.0
"@typescript-eslint/parser": ^6.11.0
cloudstorm: ^0.9.5
discord-api-types: 0.37.63
eslint: ^8.54.0
heatsync: ^2.4.2
snowtransfer: ^0.9.0
tsup: ^7.3.0
tsup: ^8.0.0
turbo: ^1.10.16
typescript: ^5.2.2
languageName: unknown
Expand Down Expand Up @@ -5014,9 +5014,9 @@ __metadata:
languageName: node
linkType: hard

"tsup@npm:^7.3.0":
version: 7.3.0
resolution: "tsup@npm:7.3.0"
"tsup@npm:^8.0.0":
version: 8.0.0
resolution: "tsup@npm:8.0.0"
dependencies:
bundle-require: ^4.0.0
cac: ^6.7.12
Expand All @@ -5033,10 +5033,13 @@ __metadata:
sucrase: ^3.20.3
tree-kill: ^1.2.2
peerDependencies:
"@microsoft/api-extractor": ^7.36.0
"@swc/core": ^1
postcss: ^8.4.12
typescript: ">=4.5.0"
peerDependenciesMeta:
"@microsoft/api-extractor":
optional: true
"@swc/core":
optional: true
postcss:
Expand All @@ -5046,7 +5049,7 @@ __metadata:
bin:
tsup: dist/cli-default.js
tsup-node: dist/cli-node.js
checksum: 9d66196cffc1a54bce6002c2a89caad9337a88d9bf01882f8abf5eb28ccbf845a777da558dc625df1bc4844362db14557e1578a06cf7e5d2fe1ff1b06bd1941a
checksum: c39d7f484e1745ab14f38672b925cf1d713bec9f94d50c31aaf8c828a8500efa1f219e6518cdf9e06d74a146872be4591d98ef9aead103909b89d2b07a2f961a
languageName: node
linkType: hard

Expand Down

0 comments on commit 91dc286

Please sign in to comment.