Skip to content

Commit

Permalink
items gallery
Browse files Browse the repository at this point in the history
  • Loading branch information
morozoffnor committed Jan 24, 2024
1 parent 0e09589 commit 8e6640c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/api/items.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {tokenChecker} from "./tools/APItokenChecker.mjs";
import {logger} from "../tools/logger.mjs";
import {useDebuffItem, useItem} from "../tools/items/tools/useItem.mjs";
import {getActiveUsers} from "../database/database.mjs";
import {getAllItemObjects} from "../tools/items/tools/itemsHandler.mjs";

let ItemsRouter = express.Router()

Expand Down Expand Up @@ -37,4 +38,10 @@ ItemsRouter.get('/activeUsers', express.json({type: 'application/json'}), async
res.status(200).send({users: users})
})

ItemsRouter.get('/list', express.json({type: 'application/json'}), async (req, res) => {
const items = await getAllItemObjects()
res.setHeader('Content-Type', 'application/json');
res.status(200).send({items: items})
})

export default ItemsRouter
23 changes: 23 additions & 0 deletions app/tools/items/tools/itemsHandler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export async function handleItem(item, size, user) {
}




export async function getRandomItem(place) {
const items = getItemsByPlace(place)
return items[Math.floor(Math.random() * items.length)]
Expand Down Expand Up @@ -108,4 +110,25 @@ export async function getLvlUpItem(){
items.push(bolt.rare())
items.push(bolt.legendary())
return items[Math.floor(Math.random() * items.length)]
}

export async function getAllItemObjects() {
let items = []
items.push(minimizer.common())
items.push(minimizer.uncommon())
items.push(minimizer.rare())
items.push(minimizer.legendary())
items.push(condom.common())
items.push(condom.uncommon())
items.push(condom.rare())
items.push(condom.legendary())
items.push(pump.common())
items.push(pump.uncommon())
items.push(pump.rare())
items.push(pump.legendary())
items.push(bolt.common())
items.push(bolt.uncommon())
items.push(bolt.rare())
items.push(bolt.legendary())
return items
}

0 comments on commit 8e6640c

Please sign in to comment.