Skip to content

Commit

Permalink
debuff logic rewrite (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
morozoffnor authored Feb 1, 2024
2 parents aa41a7d + ddda797 commit 56d7a69
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
6 changes: 6 additions & 0 deletions app/tools/items/bolt.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export class Bolt {
}
this.icon = "boltRare.png"
this.effectInfo = {
instant: true,
option1: 5,
v: 2
}
Expand All @@ -79,13 +80,18 @@ export class Bolt {
}
this.icon = "boltLegendary.png"
this.effectInfo = {
instant: true,
option1: 5,
v: 2
}

return this
}

/**
* @param {{type: Number | NumberConstructor}} size
* @returns Number
*/
useItem(size) {
if (this.subtype === 'addition') {
return size + this.effectInfo.option1
Expand Down
27 changes: 8 additions & 19 deletions app/tools/items/tools/useItem.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {getUserById, IncUserStats} from "../../../database/database.mjs";
import {bot} from "../../../main.mjs";
import {config} from "../../../config.mjs";
import {Bolt} from "../bolt.mjs";
import {handleItem} from "./itemsHandler.mjs";

export async function useItem(usedItem) {
let user = await getUserById(parseInt(usedItem['userId']))
Expand Down Expand Up @@ -33,26 +35,13 @@ export async function useDebuffItem(usedItem) {
if (user.items[i]._id == usedItem['itemId']) {
// console.log('found item in user ' + user.id)
console.log('debuffing other user')
// TODO rewrite this custom thing for Bolt


if (user.items[i].effectInfo.v === 2) {
switch (user.items[i].rarity) {
case 'Rare':
target.cockStats.currentSize = (target.cockStats.currentSize + user.items[i].effectInfo.option1).toFixed(3)
const message = `@${user.userName} использовал ${user.items[i].name} [${user.items[i].rarity}] на @${target.userName}!\nТеперь его хуй равен ${target.cockStats.currentSize}`
await bot.telegram.sendMessage(config.chatId, message, {parse_mode: "HTML"})
break
case 'Legendary':
target.cockStats.currentSize = (target.cockStats.currentSize * user.items[i].effectInfo.option1).toFixed(3)
const message1 = `@${user.userName} использовал ${user.items[i].name} [${user.items[i].rarity}] на @${target.userName}!\nТеперь его хуй равен ${target.cockStats.currentSize}`
await bot.telegram.sendMessage(config.chatId, message1, {parse_mode: "HTML"})
break
}




if (user.items[i].effectInfo.instant) {
const targetSize = target.cockStats.currentSize
const newTargetSize = await handleItem(user.items[i], targetSize)
target.cockStats.currentSize = await newTargetSize
const message = `@${user.userName} использовал ${user.items[i].name} [${user.items[i].rarity}] на @${target.userName}!\nТеперь его хуй равен ${target.cockStats.currentSize}`
await bot.telegram.sendMessage(config.chatId, message, {parse_mode: "HTML"})
} else {
target.activatedItem = user.items[i]
const message = `@${user.userName} использовал ${user.items[i].name} [${user.items[i].rarity}] на @${target.userName}`
Expand Down

0 comments on commit 56d7a69

Please sign in to comment.