feat: battle awareness

This commit is contained in:
DaInfLoop 2024-06-25 22:30:51 +01:00
parent 3c77e88a4d
commit 78dd59d686
2 changed files with 169 additions and 13 deletions

View file

@ -440,7 +440,6 @@ app.view("chooseopponent1", async (ctx) => {
"elements": [ "elements": [
{ {
"type": "button", "type": "button",
"text": { "text": {
"type": "plain_text", "type": "plain_text",
"text": "Continue", "text": "Continue",
@ -450,7 +449,19 @@ app.view("chooseopponent1", async (ctx) => {
"action_id": "continue" "action_id": "continue"
} }
] ]
},
...(opponent.battleAwareness ? [{
type: 'section',
text: {
type: 'mrkdwn',
text: `Watch out, ${slackUser.display_name_normalized}! ${opponent.name} has ${opponent.battleAwareness.type} Battle Awareness! This means they will react to some or ALL of your actions. Be careful!`
},
"accessory": {
"type": "image",
"image_url": "",
"alt_text": `${opponent.battleAwareness.type} Battle Awareness`
} }
}] : [])
] ]
}); });
@ -522,6 +533,15 @@ async function playerLoss(ctx) {
await takeOutOfBattle(ctx.context.userId); await takeOutOfBattle(ctx.context.userId);
const special = !!SpecialOpponents.find(x => x.rawId == user.currentopponent);
if (special) {
await sql`
UPDATE users
losses = ${user.losses + 1}
WHERE slack_id = ${ctx.context.userId};
`
} else {
await sql` await sql`
UPDATE users UPDATE users
SET spoints = ${user.spoints - 1}, SET spoints = ${user.spoints - 1},
@ -529,6 +549,7 @@ async function playerLoss(ctx) {
losses = ${user.losses + 1} losses = ${user.losses + 1}
WHERE slack_id = ${ctx.context.userId}; WHERE slack_id = ${ctx.context.userId};
` `
}
ctx.respond({ ctx.respond({
replace_original: true, replace_original: true,
@ -547,7 +568,7 @@ async function playerLoss(ctx) {
"type": "section", "type": "section",
"text": { "text": {
"type": "mrkdwn", "type": "mrkdwn",
"text": `Oh no ${slackUser.display_name_normalized}... You've been defeated by ${AllOpponents.find(x => x.rawId == user.currentopponent).name}... Don't give up! There's always room for improvement!\n\n\n*Losses:*\n> -1 Skill Point\n>-5 Creation Shards\n> 1 Defeat` "text": `Oh no ${slackUser.display_name_normalized}... You've been defeated by ${AllOpponents.find(x => x.rawId == user.currentopponent).name}... Don't give up! There's always room for improvement!\n\n\n*Losses:*\n> ${special ? 0 : -1} Skill Point(s)\n>${special ? 0 : -5} Creation Shards\n> 1 Defeat`
}, },
"accessory": { "accessory": {
"type": "image", "type": "image",
@ -704,6 +725,8 @@ app.action(/attack|defend|item/, checkButton, async (ctx) => {
const user = await initializeUser(ctx.context.userId); const user = await initializeUser(ctx.context.userId);
const slackUser = (await ctx.client.users.info({ user: ctx.context.userId })).user.profile; const slackUser = (await ctx.client.users.info({ user: ctx.context.userId })).user.profile;
await sql`UPDATE users SET lastaction = ${ctx.payload.action_id} WHERE slack_id = ${ctx.context.userId};`;
switch (ctx.payload.action_id) { switch (ctx.payload.action_id) {
case 'attack': case 'attack':
if (user.opponentdefense == 'Strong') { if (user.opponentdefense == 'Strong') {
@ -859,9 +882,15 @@ app.action('viewaction-opponent', checkButton, async (ctx) => {
const user = await initializeUser(ctx.context.userId); const user = await initializeUser(ctx.context.userId);
const slackUser = (await ctx.client.users.info({ user: ctx.context.userId })).user.profile; const slackUser = (await ctx.client.users.info({ user: ctx.context.userId })).user.profile;
const chances = AllOpponents.find(x => x.rawId == user.currentopponent).chances; const opponent = AllOpponents.find(x => x.rawId == user.currentopponent);
const action = chooseAction(chances); const action = (() => {
if (opponent.battleAwareness && opponent.battleAwareness.chances[user.lastaction]) {
return chooseAction(opponent.battleAwareness.chances[user.lastaction](user));
}
return chooseAction(opponent.chances);
})();
switch (action) { switch (action) {
case 'attack': case 'attack':

View file

@ -73,6 +73,63 @@ module.exports = [
item: 0.3 item: 0.3
} }
}, },
{
rawId: "incomingSword",
name: "Incoming Sword",
stats: {
health: (user) => user.maxdmg * 5,
min: (user) => user.health - 1,
max: (user) => user.health * 5
},
image: "https://cdn.discordapp.com/attachments/1108683335347212389/1215652090807058432/BM_-_Incoming_Sword.png?ex=667c173c&is=667ac5bc&hm=9a72fb8decaf8c7f2089ee0c03f6f6ed79d8aace72f02429d9cc4456a751f818&",
intro: `*_{player} is on the floor. They can't see a thing... A fall like that really took them out... After slowly opening their eyes, 4 figures can be seen towering over {player}... More specifically, Mercha holding Lock Block, Dicey, and Master Block, curiously floating next to her..._*
*Mercha*: Hey! Heyyyyy! Ay! You okay!?
*_{player} quickly flips themselves up into a standing position_*
*{player}*: Woah! Erm... Yeah? I think so?...
*Mercha*: Look, there isn't usually any visitors here in the Sandbox so I'm actually wondering how you even got here in the first place...
*{player}*: Oh well actually there was an opening in the void so I-
*_Suddenly, intense music (Zone Incoming - House Vibe OST) starts playing as a large red glare can be seen in the sky. Master Block quickly cowers behind Dicey..._*
*Mercha*: Oh god... That sword again!? ALRIGHT, EVERYBODY UP!
*_Mercha and Dicey quickly soar into the air at dramatic speed, however, the glare continues its direct path. It is headed straight for {player}..._*
*{player}*: Wait wait wait! How did you guys do that!?
*Mercha*: What are you doing down there!? START FLYING NOW!
*{player}*: No thanks! I'm gonna battle whatever that thing is! I'm sure I can defeat it!
*_Mercha, Dicey, Lock Block and Master Block exchange concerned looks_*
*Mercha*: Well, I'm not gonna argue with you... Just be careful there buddy...
*{player}*: No problem! Let's go!`,
chances: {},
battleAwareness: {
type: "Extreme",
chances: {
attack: () => ({
attack: (2/3),
defend: (1/3),
item: 0
}),
defend: (user) => {
if (user.playerdefense == "Weak") {
return { attack: 1, defend: 0, item: 0 }
} else {
return { attack: 0, defend: (2/3), item: (1/3) }
}
},
item: () => ({
attack: 0.5,
defend: 0.25,
item: 0.25
}),
}
}
},
{ {
rawId: "TheFirewall", rawId: "TheFirewall",
name: "The Firewall", name: "The Firewall",
@ -156,5 +213,75 @@ module.exports = [
defend: 0.375, defend: 0.375,
item: 0.375 item: 0.375
} }
},
{
rawId: "masterOG",
name: "Master OG",
stats: {
health: (user) => user.maxdmg * 30,
min: (user) => user.health,
max: (user) => user.health * 10
},
image: "https://cdn.discordapp.com/attachments/1108683335347212389/1248625695374970942/Master_OG_20240607135837.png?ex=667c13cc&is=667ac24c&hm=2c9b1e323dd061d3da4a0cf0bf0c1cbe649a733e7a68977d287d0920e008450e&",
intro: `*_After the events of Cake Day and Velvet Night, they took the Sacred Cake back to their universe and left... For now... Anyways, as the Battle Squad and {player} are about to wrap up Battle Master's birthday party, a glowing white portal appears..._*
*Battle Builder*: ERM... Guyssss... I think we've got a little bit of company again...
*Battle Special*: Oh goodness I REALLY hope it isn't Battler again-
*_The entire Battle Squad watch the portal with concern as Battle Master and Battle Support dash out of the portal... Wait WHAT!?_*
*Battle Casual*: Okay... So when could Master and Support do all of THAT!?
*Battle Support*: Do all of what?
*_Battle Master and Battle Support can be seen coming back inside Moonbase HQ..._*
*Battle Beginner*: But wait... Didn't they just come out of the portal??? What's going on here!?
*Battle Pro*: Shockingly, I am also wondering the same thing.
*Battle Master*: I see. This must be his doing...
*Battle Support*: Wait, he wasn't joking about our past selves paying us a visit!?
*_Everyone once again turns to Battle Support in shock_*
*Battle Special*: That makes a LITTLE more sense...
*Battle Master*: Pleasure to meet you. Master OG.
*Master OG*: Likewise... How fascinating. The universe has changed dramatically here-
*{player}*: Can I battle Master OG?
*Battle Pro*: ABSOLUTELY N-
*Master OG*: Very well.
*_Master OG equips his shard and slowly points it in {player}'s direction_*
*Support OG*: That was actually the main goal of our visit!
*Battle Master*: I see. Giving {player} a chance to battle me, or at the very least a version of myself early. Ingenious as always from him.
*Battle Support*: Oh how exciting! Good luck though {player}! Master OG is still very strong!
*{player}*: AYY! LET'S GO THEN!`,
deniedIntro: `You should not be able to see this. If you do, ping Haroon.`,
secretCondition() {
const now = new Date();
return [5, 6].includes(now.getUTCMonth())
},
chances: {},
battleAwareness: {
type: "Extreme",
chances: {
attack() {
return {
attack: 0.1,
defend: 0.52,
item: 0.38
}
},
defend(user) {
if (user.playerdefense == "Strong") return { attack: 0, defend: 0.75, item: 0.25 }
else if (user.playerdefense == "Moderate") return { attack: 0.15, defend: 0.52, item: 0.33 }
else return { attack: 0.3, defend: 0.52, item: 0.18 }
},
item() {
// Why are you using Item around Battle Master
return { attack: 1, defend: 0, item: 0 }
}
}
}
} }
] ]