feat: short impl of battler gen
This commit is contained in:
parent
6e17f7175e
commit
edd59cac86
159
index.js
159
index.js
|
@ -16,6 +16,8 @@ const AllOpponents = [
|
|||
...(BeginnerOpponents.map(x => ({ ...x, rank: 'BEGINNER' }))),
|
||||
]
|
||||
|
||||
const shop = require('./shopItems');
|
||||
|
||||
const app = new App({
|
||||
token: process.env.SLACK_BOT_TOKEN,
|
||||
signingSecret: process.env.SLACK_SIGNING_SECRET
|
||||
|
@ -34,7 +36,7 @@ async function initializeUser(slackUserId) {
|
|||
}
|
||||
|
||||
async function getBattlerUrl(slackUserId, endpoint = "battler.png") {
|
||||
const [ user ] = await sql`SELECT * FROM customization WHERE slack_id = ${slackUserId};`
|
||||
const [user] = await sql`SELECT * FROM customization WHERE slack_id = ${slackUserId};`
|
||||
|
||||
const url = new URL(endpoint, "https://generator.battlemaster.obl.ong/");
|
||||
|
||||
|
@ -416,7 +418,7 @@ app.view("chooseopponent1", async (ctx) => {
|
|||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const opponentStats = ((opponent) => {
|
||||
|
@ -477,7 +479,7 @@ app.view("chooseopponent1", async (ctx) => {
|
|||
type: 'plain_text',
|
||||
text: `${slackUser.display_name_normalized} vs ${opponent.name}`
|
||||
},
|
||||
image_url: await getBattlerUrl(userId, "battlesquadfight.png") + `&username=${encodeURIComponent(slackUser.display_name_normalized)}&opponent=${opponent.rawId}`
|
||||
image_url: await getBattlerUrl(userId, "battlesquadfight.png") + `&username=${encodeURIComponent(slackUser.display_name_normalized)}&opponent=${opponent.rawId}`
|
||||
},
|
||||
...(opponent.battleAwareness ? [{
|
||||
type: 'section',
|
||||
|
@ -1596,10 +1598,153 @@ app.view('downgrade', async (ctx) => {
|
|||
]
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
app.command('/battlershop', async (ctx) => {
|
||||
await ctx.ack();
|
||||
|
||||
await ctx.client.views.open({
|
||||
trigger_id: ctx.payload.trigger_id,
|
||||
view: {
|
||||
"type": "modal",
|
||||
"callback_id": "battlershop",
|
||||
"title": {
|
||||
"type": "plain_text",
|
||||
"text": "Battler Shop",
|
||||
"emoji": true
|
||||
},
|
||||
"submit": {
|
||||
"type": "plain_text",
|
||||
"text": "Select",
|
||||
"emoji": true
|
||||
},
|
||||
"close": {
|
||||
"type": "plain_text",
|
||||
"text": "Never mind",
|
||||
"emoji": true
|
||||
},
|
||||
"blocks": [
|
||||
{
|
||||
"type": "actions",
|
||||
"elements": Object.entries(shop).map(x => {
|
||||
return {
|
||||
"type": "button",
|
||||
"text": {
|
||||
"type": "plain_text",
|
||||
"text": x[0],
|
||||
"emoji": true
|
||||
},
|
||||
"value": x[0],
|
||||
"action_id": "battlershop-"+x[0]
|
||||
}
|
||||
})
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const selectedOption = new Map();
|
||||
|
||||
app.action(/battlershop-(.+)/, async (ctx) => {
|
||||
await ctx.ack();
|
||||
|
||||
selectedOption.set(ctx.context.userId, ctx.payload.action_id.slice(12));
|
||||
})
|
||||
|
||||
; (async () => {
|
||||
await app.start(process.env.PORT);
|
||||
app.view("battlershop", async (ctx) => {
|
||||
const sel = `${selectedOption.get(ctx.context.userId)}`
|
||||
|
||||
console.log('⚡️ Bolt app is running!');
|
||||
})();
|
||||
await ctx.ack({ response_action: 'push', view: {
|
||||
"type": "modal",
|
||||
"title": {
|
||||
"type": "plain_text",
|
||||
"text": `${sel} Accessories`,
|
||||
"emoji": true
|
||||
},
|
||||
"submit": {
|
||||
"type": "plain_text",
|
||||
"text": "Select",
|
||||
"emoji": true
|
||||
},
|
||||
"close": {
|
||||
"type": "plain_text",
|
||||
"text": "Back"
|
||||
},
|
||||
"blocks": [
|
||||
{
|
||||
"type": "actions",
|
||||
"elements": [
|
||||
{
|
||||
"type": "static_select",
|
||||
"placeholder": {
|
||||
"type": "plain_text",
|
||||
"text": "Select an accessory",
|
||||
"emoji": true
|
||||
},
|
||||
"options": [
|
||||
{
|
||||
"text": {
|
||||
"type": "plain_text",
|
||||
"text": "*plain_text option 0*",
|
||||
"emoji": true
|
||||
},
|
||||
"value": "value-0"
|
||||
},
|
||||
],
|
||||
"action_id": "accessory-type"
|
||||
},
|
||||
{
|
||||
"type": "static_select",
|
||||
"placeholder": {
|
||||
"type": "plain_text",
|
||||
"text": "Select a colour",
|
||||
"emoji": true
|
||||
},
|
||||
"options": [
|
||||
{
|
||||
"text": {
|
||||
"type": "plain_text",
|
||||
"text": "*plain_text option 0*",
|
||||
"emoji": true
|
||||
},
|
||||
"value": "value-0"
|
||||
},
|
||||
{
|
||||
"text": {
|
||||
"type": "plain_text",
|
||||
"text": "*plain_text option 1*",
|
||||
"emoji": true
|
||||
},
|
||||
"value": "value-1"
|
||||
},
|
||||
{
|
||||
"text": {
|
||||
"type": "plain_text",
|
||||
"text": "*plain_text option 2*",
|
||||
"emoji": true
|
||||
},
|
||||
"value": "value-2"
|
||||
}
|
||||
],
|
||||
"action_id": "actionId-1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "image",
|
||||
"image_url": "https://assets3.thrillist.com/v1/image/1682388/size/tl-horizontal_main.jpg",
|
||||
"alt_text": "Battler preview"
|
||||
}
|
||||
]
|
||||
} });
|
||||
});
|
||||
|
||||
|
||||
app.action
|
||||
|
||||
; (async () => {
|
||||
await app.start(process.env.PORT);
|
||||
|
||||
console.log('⚡️ Bolt app is running!');
|
||||
})();
|
398
shopItems.js
Normal file
398
shopItems.js
Normal file
|
@ -0,0 +1,398 @@
|
|||
module.exports = {
|
||||
Base: [
|
||||
{
|
||||
name: "Skin",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
],
|
||||
Top: [
|
||||
{
|
||||
name: "Sash",
|
||||
creationShards: 350,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Side Cloak",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return user.questscount >= 50
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Bizznizz Tie",
|
||||
creationShards: 500,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "House Vibe Hoo",
|
||||
display: "House Vibe Hoodie",
|
||||
creationShards: 696,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
],
|
||||
Bottom: [
|
||||
{
|
||||
name: "Knee Pads",
|
||||
creationShards: 0,
|
||||
destructionShards: 200,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Skirt",
|
||||
creationShards: 200,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Battler Drip",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return false
|
||||
},
|
||||
},
|
||||
],
|
||||
Face: [
|
||||
{
|
||||
name: "Deal with it",
|
||||
creationShards: 1000,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Eye Mask",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable() {
|
||||
return false
|
||||
},
|
||||
},
|
||||
],
|
||||
Eyes: [
|
||||
{
|
||||
name: "Serious",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 2,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Angry",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 2,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Confused",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 2,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Cheerful",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 2,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Tired",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 2,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Excited",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 2,
|
||||
unlockableHint: null,
|
||||
},
|
||||
],
|
||||
Neck: [
|
||||
{
|
||||
name: "Neck Chain",
|
||||
creationShards: 0,
|
||||
destructionShards: 50,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "1K Chain",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return false
|
||||
},
|
||||
},
|
||||
],
|
||||
Hat: [
|
||||
{
|
||||
name: "Beginner Headtie",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return false
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Commander Hat",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return user.dailycount >= 25
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Top Hat",
|
||||
creationShards: 0,
|
||||
destructionShards: 1000,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Back Cap",
|
||||
creationShards: 300,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "The Item",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return false
|
||||
},
|
||||
},
|
||||
],
|
||||
Back: [
|
||||
{
|
||||
name: "Battle Sword",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return user.dailycount >= 30
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Tail",
|
||||
creationShards: 0,
|
||||
destructionShards: 500,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Generic Pole",
|
||||
creationShards: 0,
|
||||
destructionShards: 100,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Battle Hammer",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return user.dailycount >= 60
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Battle Scythe",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return user.dailycount >= 90
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Battle Spear",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return user.dailycount >= 10
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "THE FIRE",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return false
|
||||
},
|
||||
},
|
||||
],
|
||||
Buddy: [
|
||||
{
|
||||
name: "Battler",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return false
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "House Vibe",
|
||||
creationShards: 800,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Lock Block",
|
||||
creationShards: 500,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Battle Special",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable() {
|
||||
return false
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Battle Support",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable() {
|
||||
return true
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "Houseannor",
|
||||
creationShards: 0,
|
||||
destructionShards: 800,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Ranger",
|
||||
creationShards: 0,
|
||||
destructionShards: 500,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "PCSB",
|
||||
display: "Pesky Closed Square Bracket",
|
||||
creationShards: 100,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "PLR",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 5,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Basketiballu",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return false
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Starting Mountain",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 10,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Olivia",
|
||||
creationShards: 1000,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Prototype Ranger",
|
||||
creationShards: 0,
|
||||
destructionShards: 250,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "DEMUL",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return false
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Incoming Sword",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return false
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "MARZ Ball",
|
||||
creationShards: 0,
|
||||
destructionShards: 100,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
{
|
||||
name: "Noodle the Kitten",
|
||||
creationShards: 250,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockableHint: null,
|
||||
},
|
||||
],
|
||||
Glow: [
|
||||
{
|
||||
name: "Glow",
|
||||
creationShards: 0,
|
||||
destructionShards: 0,
|
||||
velocityShards: 0,
|
||||
unlockable(user) {
|
||||
return user.victories >= 1000
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
Loading…
Reference in a new issue