fix dmg stuff
This commit is contained in:
parent
783af8652c
commit
b862028524
|
@ -8,6 +8,7 @@ import chalk from 'chalk';
|
|||
import prettyBytes from 'pretty-bytes';
|
||||
import { Command } from './types/index';
|
||||
import { startServer } from './web/web';
|
||||
import { init as initPVP } from './lib/rpg/pvp';
|
||||
|
||||
const bot = new Client({
|
||||
intents: [
|
||||
|
@ -40,6 +41,8 @@ async function init() {
|
|||
log.error(`${chalk.bold('emergency mode could not be established.')} shutting down.`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
initPVP(bot);
|
||||
}
|
||||
|
||||
bot.on(Events.ClientReady, async () => {
|
||||
|
|
|
@ -324,7 +324,7 @@ export async function giveItem(user: string, item: Item, quantity = 1): Promise<
|
|||
|
||||
let inv;
|
||||
if (storedItem) {
|
||||
if (storedItem.quantity + quantity === 0) {
|
||||
if (storedItem.quantity + quantity === 0 && item.id !== DefaultItems.BLOOD) { // let blood show as 0x
|
||||
await db<ItemInventory>('itemInventories')
|
||||
.delete()
|
||||
.where('user', user)
|
||||
|
|
|
@ -2,7 +2,7 @@ import { InitHealth, ItemInventory, db } from '../db';
|
|||
import { DefaultItems, getDefaultItem, giveItem, getItemQuantity, formatItems } from './items';
|
||||
import { Client } from 'discord.js';
|
||||
|
||||
export const BLOOD_ID = DefaultItems.BLOOD;
|
||||
export const BLOOD_ID = -DefaultItems.BLOOD;
|
||||
export const BLOOD_ITEM = getDefaultItem(BLOOD_ID);
|
||||
export const MAX_HEALTH = BLOOD_ITEM.maxStack;
|
||||
const BLOOD_GAIN_PER_HOUR = 5;
|
||||
|
@ -19,10 +19,12 @@ export async function initHealth(user: string) {
|
|||
}
|
||||
|
||||
export async function getHealth(user: string) {
|
||||
await initHealth(user);
|
||||
return await getItemQuantity(user, BLOOD_ID);
|
||||
}
|
||||
|
||||
export async function dealDamage(user: string, dmg: number) {
|
||||
await initHealth(user);
|
||||
return await giveItem(user, BLOOD_ITEM, -dmg);
|
||||
}
|
||||
|
||||
|
@ -45,5 +47,6 @@ async function healthCron(bot: Client) {
|
|||
}
|
||||
|
||||
export function init(bot: Client) {
|
||||
healthCron(bot);
|
||||
setInterval(() => healthCron(bot), 1_000 * 60 * 60);
|
||||
}
|
Loading…
Reference in New Issue