Skip to content

Instantly share code, notes, and snippets.

View Eng-Bunnys's full-sized avatar

.Bunnys Eng-Bunnys

View GitHub Profile
#include "AssistantLib.h"
#include <iostream>
using namespace std;
AssistantLib::AssistantLib(string name, int status, int noBooksHandled)
: Librarian(name, status, noBooksHandled, AssistantLibrarian) {}
void AssistantLib::AssignBook(Librarian* otherLibrarian) {
if (otherLibrarian->GetType() == AssistantLibrarian && otherLibrarian->GetStatus() < Status) otherLibrarian->IncreaseBooksHandled();
else cout << "Assistant librarians cannot assign books to other assistant librarians" << std::endl;
@Eng-Bunnys
Eng-Bunnys / chatXP.js
Created November 1, 2022 19:37
Chat XP with cooldown to avoid spam
// This code is a general use case, meaning that it's auto enabled for all guilds, to make it per guild you'll have to moidfy it yourself
// This is done in the messageCreate event
// The channel that the level up message will be sent to, by default this should be the current channel unless you have a feature that has a custom level up channel
const levelUpChannel = message.channel;
// Accessing the data base and checking if the message author has an existing account/schema
let userData = await pointSchema.findOne({
@Eng-Bunnys
Eng-Bunnys / LevelSystem.js
Created September 28, 2022 17:31
Level System with carry over XP and extra levels
/**
What this does:
It checks if the users RP [XP] is larger than or equal to the required XP to level up, if larger than we have extra XP, we check if that extra XP can level the user up again and if it can't we set it as carryOverXp
*/
//This is the function that calculates the amount of XP required to level up once, you can of course change this to your own equation
//If you'd like to learn more about the mathmatics behind level systems go here: https://pavcreations.com/level-systems-and-character-growth-in-rpg-games/
function RPRequiredToLevelUp(rank) {
return rank * 800 + (rank - 1) * 400;
}
//This function takes in the user's current rank (before it's updated), currentRP : the user's current XP before any addition, addedRP (the user's XP after addition)