diff --git a/index.js b/index.js index 3b51e35..0958491 100644 --- a/index.js +++ b/index.js @@ -244,6 +244,8 @@ app.command('/profile', async (ctx) => { }) app.view("chooseopponent", async (ctx) => { + const user = await initializeUser(ctx.context.userId); + const { selected_option } = Object.values(ctx.view.state.values)[0]['rank-selection']; const rank = selected_option.value; @@ -254,6 +256,16 @@ app.view("chooseopponent", async (ctx) => { "CASUAL": `*Battle Casual*: Alright <@${ctx.body.user.id}>, things are about to get a little bit tougher from here... Who do you feel like taking on today?` } + const canRankUp = (() => { + if (user.rank == 'Beginner') { + return (user.health + user.mindmg + user.maxdmg) >= 50 && user.cshards >= 50 + } else if (user.rank == 'Casual') { + return (user.health + user.mindmg + user.maxdmg) >= 200 && user.cshards >= 250 + } else { + return false + } + })(); + await ctx.ack({ response_action: 'update', view: { @@ -307,7 +319,29 @@ app.view("chooseopponent", async (ctx) => { "text": "Choose an opponent:", "emoji": true } - } + }, + ...( canRankUp ? [ + { + type: 'divider', + }, + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": `You can also now participate in a rank up battle against *Battle ${user.rank}*. Click the button below to initiate the battle.` + }, + "accessory": { + "type": "button", + "text": { + "type": "plain_text", + "text": "Click Me", + "emoji": true + }, + "value": ctx.context.userId, + "action_id": "start-rankup-battle" + } + } + ] : []) ] } }) @@ -326,7 +360,7 @@ app.view("chooseopponent-BEGINNER", async (ctx) => { const player = await initializeUser(userId); await sql`UPDATE users - SET playerhealth = ${player.health}, + SET playerhealth = ${player.health}, playermin = ${player.mindmg}, playermax = ${player.maxdmg}, @@ -821,7 +855,7 @@ app.action('viewaction-opponent', checkButton, async (ctx) => { break; case 'item': const increase = Math.floor(Math.random() * 5) + 1; - switch (['health', 'min', 'max', 'nothing'][Math.floor(Math.random() * 4)]) { + switch (['health', 'health', 'min', 'min', 'max', 'nothing', 'nothing', 'nothing'][Math.floor(Math.random() * 8)]) { case 'health': await sql`UPDATE users SET opponenthealth = ${user.opponenthealth + increase} WHERE slack_id = ${ctx.context.userId};` response = `*_${AllOpponents.find(x => x.rawId == user.currentopponent).name} drinks some squash. U N D I L U T E D._*\n\n\`\`\`+ ${increase} HEALTH\`\`\`` @@ -932,10 +966,10 @@ app.command('/viewopponents', async (ctx) => { }, { type: 'section', - text: { + fields: mappedBeginner.map(opponent => ({ type: 'mrkdwn', - text: mappedBeginner.map(opponent => `*${opponent.name}:*\n\n${opponent.battlePower} Battle Power`).join('\n\n\n') - } + text: `*${opponent.name}* // ${opponent.battlePower} Battle Power` + })) } ] }) @@ -949,7 +983,6 @@ app.command('/viewopponents', async (ctx) => { }); ; (async () => { - // Start your app await app.start(process.env.PORT); console.log('⚡️ Bolt app is running!'); diff --git a/opponents/beginner.js b/opponents/beginner.js index d211fea..87264ff 100644 --- a/opponents/beginner.js +++ b/opponents/beginner.js @@ -24,5 +24,138 @@ module.exports = [ "defend": 0.75, "item": 0.125 } + }, + { + rawId: "artMaster", + name: "Art Master", + stats: { + health: 28, + min: 2, + max: 10 + }, + image: "https://media.discordapp.net/attachments/1108683335347212389/1118119440991662220/BM_-_Art_Master_1.png?ex=6676a260&is=667550e0&hm=410450b374166b4709df42789cfb1d5980c6ff448c873926784405787db9cacb&", + intro: `*_{player} walks into Vibe Central_* + +*Art Master*: Sup! Welcome to Vibe Central! +*{player}*: Hello hello, is this an art gallery or something? +*Art Master*: Yup! Here you can find the best art from all of Vibe City! Some of these amazing artworks are actually made by myself and- + +*_{player} wanders over to a large canvas painting of Art Master. It says in large letters "ART MASTER >:)" at the bottom of the canvas_* + +*{player}*: If I beat you in battle can I keep this art? +*Art Master*: OH, IT'S ON!`, + chances: { + attack: (1/3), + defend: (1/3), + item: (1/3) + } + }, + { + rawId: "guitarHero", + name: "Guitar Hero", + stats: { + health: 30, + min: 6, + max: 12 + }, + image: "https://media.discordapp.net/attachments/1108683335347212389/1118184167700705300/BM_-_Guitar_Hero.png?ex=6676dea8&is=66758d28&hm=fd18a62d49917a80a1c8f6761aea36750f04032b15449bd6bae53796716ba0f3&", + intro: `*_Guitar Hero is sat peacefully at the Vibe City park playing his bass guitar_* + +*{player}*: Woah! Nice music! +*Guitar Hero*: Oh! Thanks, I appreciate that! +*{player}*: Hey, do you want to battle? +*Guitar Hero*: Do I wanna what- +*{player}*: Battle... You know, me vs you? +*Guitar Hero*: Oh I know, it was just very sudden... Erm, sure! I'll gladly battle you! +*{player}*: Epic!`, + chances: { + attack: 0.25, + defend: 0.375, + item: 0.375 + } + }, + { + rawId: "delta", + name: "Delta", + stats: { + health: 40, + min: 2, + max: 8 + }, + image: "https://media.discordapp.net/attachments/1108683335347212389/1118184167910428773/BM_-_Delta.png?ex=6676dea8&is=66758d28&hm=21ae6fbaf25e4b63a9ba5607a35802950e806aa7d6a9d38206116a34e1a69a23&", + intro: `*_{player} is wandering around X Town looking for potential battlers. {player} eventually bumps into Delta and they both fall over_* + +*Delta*: I'm so sorry! Erm, who are you? I haven't seen you around before... +*{player}*: Hey! I'm {player}! Can we battle please? +*Delta*: Battle? I'm horrible at those I really don't think we- + +*_Jessica walks around the corner and towers over both {player} and Delta_* + +*Jessica*: What's good. Why are you on the floor with... +*Delta*: Oh, I was just about to battle {player} over here hahaha... +*Jessica*: Hm, sounds cool. I'll stick around to watch you lose. I need a good laugh anyways +*Delta*: WOW OKAY THEN-`, + chances: { + attack: (1/3), + defend: (1/3), + item: (1/3) + } + }, + { + rawId: "smallKey", + name: "Small KeyMaster", + stats: { + health: 35, + min: 5, + max: 15 + }, + image: "https://media.discordapp.net/attachments/1108683335347212389/1118187424464523315/BM_-_Small_KeyMaster_1.png?ex=6676e1b0&is=66759030&hm=d489f46b7764f542751c763a37c659c0f42ed690c84f6c2bb7e8cb1a80de9378&", + intro: `*_{player} enters the CR Building of Capsule HQ_* + +*Small KeyMaster*: Oh hey! Welcome to Capsule HQ! Would you- +*{player}*: Small KeyMaster!? Woah! You look the same in real life and on TV! +*Small KeyMaster*: Yup, that's me! So are you here for capsules or fragment relate- +*{player}*: Can we battle? +*Small KeyMaster*: Erm, that's not really what I'm supposed to do b- + +*_Medium KeyMaster walks in_* + +*Medium KeyMaster*: Heya! That sounds like fun, why don't you battle em' SK? +*{player}*: MEDIUM KEYMASTER TOO!? +*Small KeyMaster*: Well, I guess it wouldn't hurt. However, I'm not going easy on ya! +*{player}*: Oh, it's on!`, + chances: { + attack: 0.525, + defend: 0.1875, + item: 0.2875 + } + }, + { + rawId: "common", + name: "Common Overseer", + stats: { + health: 45, + min: 8, + max: 12 + }, + image: "https://cdn.discordapp.com/attachments/1108683335347212389/1118184168430514217/BM_-_Common_Overseer.png?ex=6676dea8&is=66758d28&hm=99c611218581db7c248e8d37a37ca7860072319446cc0cd5d464ad5476b608d5&", + intro: `*_{player} walks up the stairs of the CR Building in Capsule HQ. They approach the Common Overseer's office and knock on the door_* + +*Common Overseer*: Hello! How can I- +*{player}*: Battle +*Common Overseer*: Erm, I haven't heard of any "Battle Overseer" before but I'm sure if you look for them they'll be more than happy to- +*{player}*: I'll battle them later. For now, us two should battle. +*Common Overseer*: Well, I'm not entirely sure if I can right now, you see- + +*_The Rare Overseer walks out of the Common Overseer's office_* + +*Rare Overseer*: Nope! All the paperwork is done! We're now free to relax! +*Common Overseer*: Fantastic! Alright then, I'll happily accept your battle request! +*{player}*: LET'S GO!`, + chances: { + attack: 0.725, + defend: 0.0875, + item: 0.2875 + } } ] \ No newline at end of file