Skip to content

Commit

Permalink
Merge branch 'bso' into godFavourPVM
Browse files Browse the repository at this point in the history
  • Loading branch information
gc authored Aug 21, 2024
2 parents 4909955 + 08c2702 commit 083221b
Show file tree
Hide file tree
Showing 77 changed files with 936 additions and 1,029 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Run Integration Tests
run: docker-compose up --build --abort-on-container-exit
run: docker compose up --build --abort-on-container-exit --remove-orphans && docker compose down --volumes --remove-orphans
2 changes: 1 addition & 1 deletion SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This assumes you are using VSCode as your IDE. If you have errors or issues, you
2. Install [Postgres 16](https://www.postgresql.org/download/) and PGAdmin4 for interacting with postgres (optional, but helpful)
3. Install Yarn using: `npm i -g yarn`
4. Clone the repo: `git clone https://github.com/oldschoolgg/oldschoolbot.git`
5. Run `corepack enable` and `yarn` in the root of the repo.
5. Run the following commands in the root of the repo: `corepack enable`, `yarn`, `npx prisma db push` and `npx prisma db push --schema ./prisma/robochimp.prisma`

### Configuration

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"test": "concurrently --raw --kill-others-on-fail \"tsc -p src && yarn test:circular\" \"yarn test:lint\" \"yarn test:unit\" \"tsc -p tests/integration --noEmit\" \"tsc -p tests/unit --noEmit\"",
"test:lint": "biome check --diagnostic-level=error",
"test:unit": "vitest run --coverage --config vitest.unit.config.mts",
"test:docker": "docker-compose up --build --abort-on-container-exit --remove-orphans && docker-compose down --volumes --remove-orphans",
"test:docker": "docker compose up --build --abort-on-container-exit --remove-orphans && docker compose down --volumes --remove-orphans",
"test:watch": "vitest --config vitest.unit.config.mts --coverage",
"buildandrun": "yarn build:esbuild && node --enable-source-maps dist",
"build:esbuild": "concurrently --raw \"yarn build:main\" \"yarn build:workers\"",
Expand All @@ -25,7 +25,7 @@
},
"dependencies": {
"@napi-rs/canvas": "^0.1.53",
"@oldschoolgg/toolkit": "git+https://github.com/oldschoolgg/toolkit.git#2813f25327093fcf2cb12bee7d4c85ce629069a0",
"@oldschoolgg/toolkit": "git+https://github.com/oldschoolgg/toolkit.git#cd7c6865229ca7dc4a66b3816586f2d3f4a4fbed",
"@prisma/client": "^5.17.0",
"@sapphire/ratelimits": "^2.4.9",
"@sapphire/snowflake": "^3.5.3",
Expand All @@ -48,6 +48,7 @@
"p-queue": "^6.6.2",
"piscina": "^4.6.1",
"random-js": "^2.1.0",
"remeda": "^2.7.0",
"simple-statistics": "^7.8.3",
"sonic-boom": "^4.0.1",
"zlib-sync": "^0.1.9",
Expand Down
5 changes: 3 additions & 2 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ model User {
store_bitfield Int[]
// Migrate
farmingPatches_herb Json? @map("farmingPatches.herb") @db.Json
farmingPatches_fruit_tree Json? @map("farmingPatches.fruit tree") @db.Json
farmingPatches_tree Json? @map("farmingPatches.tree") @db.Json
Expand Down Expand Up @@ -535,6 +534,8 @@ model User {
grinchions_caught Int @default(0)
last_giveaway_ticket_given_date DateTime? @db.Timestamp(6)
cl_array Int[] @default([])
@@index([id, last_command_date])
@@map("users")
}
Expand Down Expand Up @@ -993,7 +994,7 @@ model UserStats {
creature_scores Json @default("{}")
monster_scores Json @default("{}")
laps_scores Json @default("{}")
sacrificed_bank Json @default("{}")
sacrificed_bank Json @default("{}") @db.JsonB
openable_scores Json @default("{}")
gp_luckypick BigInt @default(0)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/MUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class MUserClass {
return gearImages.find(i => i.id === this.user.gear_template)!;
}

countSkillsAtleast99() {
countSkillsAtLeast99() {
return Object.values(this.skillsAsLevels).filter(lvl => lvl >= 99).length;
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/bso/divination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,9 @@ export const portents: SourcePortent[] = [
description: 'Consumes stone spirits to grant extra mining XP, instead of extra ore.',
divinationLevelToCreate: 90,
cost: new Bank().add('Incandescent energy', 1200),
chargesPerPortent: 1000,
chargesPerPortent: 60 * 10,
addChargeMessage: portent =>
`You used a Spiritual mining portent, your next ${portent.charges_remaining}x stone spirits will grant XP instead of ore.`
`You used a Spiritual mining portent, it will turn stone spirits into extra mining XP, instead of ore, in your next ${portent.charges_remaining} minutes of mining.`
},
{
id: PortentID.PacifistPortent,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/colosseum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ export async function colosseumCommand(user: MUser, channelID: string) {
cost.add('Dragon arrow', 50);
} else {
messages.push(
'Missed 7% Venator bow boost. If you have one, charge it and keep it in your bank. You also need atleast 50 dragon arrows equipped.'
'Missed 7% Venator bow boost. If you have one, charge it and keep it in your bank. You also need at least 50 dragon arrows equipped.'
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/lib/combat_achievements/combatAchievements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ const indexesWithRng = entries.flatMap(i => i[1].tasks.filter(t => 'rng' in t));
export const combatAchievementTripEffect = async ({ data, messages, user }: Parameters<TripFinishEffect['fn']>[0]) => {
const dataCopy = deepClone(data);
if (dataCopy.type === 'Inferno' && !dataCopy.diedPreZuk && !dataCopy.diedZuk) {
(dataCopy as any).quantity = 1;
(dataCopy as any).q = 1;
}
if (dataCopy.type === 'Colosseum') {
(dataCopy as any).quantity = 1;
(dataCopy as any).q = 1;
}
if (!('quantity' in dataCopy)) return;
let quantity = Number(dataCopy.quantity);
if (!('q' in dataCopy)) return;
let quantity = Number(dataCopy.q);
if (Number.isNaN(quantity)) return;

if (data.type === 'TombsOfAmascut') {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/combat_achievements/hard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ export const hardCombatAchievements: CombatAchievement[] = [
monster: 'Tempoross',
desc: 'Subdue Tempoross, getting rewarded with 10 reward permits from a single Tempoross fight.',
rng: {
chancePerKill: 30,
chancePerKill: 5,
hasChance: data => data.type === 'Tempoross'
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/lib/combat_achievements/medium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ export const mediumCombatAchievements: CombatAchievement[] = [
monster: 'Skotizo',
desc: 'Kill Skotizo with no altars active.',
rng: {
chancePerKill: 15,
chancePerKill: 5,
hasChance: isCertainMonsterTrip(Monsters.Skotizo.id)
}
},
Expand Down
13 changes: 10 additions & 3 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ export const Roles = {
TopSlayer: DISCORD_SETTINGS.Roles?.TopSlayer ?? '867967551819358219',
TopInventor: '992799099801833582',
TopLeagues: '1005417171112972349',
EventOrganizer: '1149907536749801542'
EventOrganizer: '1149907536749801542',
TopTamer: '1054356709222666240',
TopMysterious: '1074592096968785960',
TopGlobalCL: '848966773885763586'
};

export enum DefaultPingableRoles {
Expand Down Expand Up @@ -540,7 +543,9 @@ export const BadgesEnum = {
TopSkiller: 9,
TopCollector: 10,
TopMinigame: 11,
SotWTrophy: 12
SotWTrophy: 12,
Slayer: 13,
TopGiveawayer: 14
} as const;

export const badges: { [key: number]: string } = {
Expand All @@ -556,7 +561,9 @@ export const badges: { [key: number]: string } = {
[BadgesEnum.TopSkiller]: Emoji.Skiller,
[BadgesEnum.TopCollector]: Emoji.CollectionLog,
[BadgesEnum.TopMinigame]: Emoji.MinigameIcon,
[BadgesEnum.SotWTrophy]: Emoji.SOTW
[BadgesEnum.SotWTrophy]: Emoji.SOTWTrophy,
[BadgesEnum.Slayer]: Emoji.Slayer,
[BadgesEnum.TopGiveawayer]: Emoji.SantaHat
};

export const MAX_XP = 5_000_000_000;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/data/buyables/skillCapeBuyables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ for (const skillcape of Skillcapes) {
outputItems: (user: MUser) => {
const output = new Bank().add(skillcape.hood);

if (user.countSkillsAtleast99() > 1) {
if (user.countSkillsAtLeast99() > 1) {
output.add(skillcape.trimmed);
} else {
output.add(skillcape.untrimmed);
Expand Down
4 changes: 2 additions & 2 deletions src/lib/data/cox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ export const minimumCoxSuppliesNeeded = new Bank({
export async function checkCoxTeam(users: MUser[], cm: boolean, quantity = 1): Promise<string | null> {
const hasHerbalist = users.some(u => u.skillLevel(SkillsEnum.Herblore) >= 78);
if (!hasHerbalist) {
return 'nobody with atleast level 78 Herblore';
return 'nobody with at least level 78 Herblore';
}
const hasFarmer = users.some(u => u.skillLevel(SkillsEnum.Farming) >= 55);
if (!hasFarmer) {
return 'nobody with atleast level 55 Farming';
return 'nobody with at least level 55 Farming';
}
const suppliesNeeded = minimumCoxSuppliesNeeded.clone().multiply(quantity);
const userWithoutSupplies = users.find(u => !u.bank.has(suppliesNeeded));
Expand Down
5 changes: 4 additions & 1 deletion src/lib/data/itemAliases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,15 @@ setItemAlias(2993, 'Chompy bird hat (dragon archer)');
setItemAlias(2994, 'Chompy bird hat (expert ogre dragon archer)');
setItemAlias(2995, 'Chompy bird hat (expert dragon archer)');

// Item aliases
// Achievement diary lamps
setItemAlias(11_137, 'Antique lamp 1');
setItemAlias(11_139, 'Antique lamp 2');
setItemAlias(11_141, 'Antique lamp 3');
setItemAlias(11_185, 'Antique lamp 4');

// Defender of varrock quest lamp
setItemAlias(28_820, 'Antique lamp (defender of varrock)');

// Dragonfire shields
setItemAlias(11_284, 'Uncharged dragonfire shield');
setItemAlias(11_283, 'Dragonfire shield');
Expand Down
6 changes: 2 additions & 4 deletions src/lib/degradeableItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,8 @@ export async function degradeItem({
const chargesAfter = user.user[degItem.settingsKey];
assert(typeof chargesAfter === 'number' && chargesAfter > 0);
return {
userMessage: `Your ${
item.name
} degraded by ${chargesToDegrade} charges, and now has ${chargesAfter} remaining.${
pennyReduction > 0 ? ` Your Ghommal's lucky penny saved ${pennyReduction} charges` : ''
userMessage: `Your ${item.name} degraded by ${chargesToDegrade} charges, and now has ${chargesAfter} remaining${
pennyReduction > 0 ? `. Your Ghommal's lucky penny saved ${pennyReduction} charges` : ''
}`
};
}
Expand Down
8 changes: 1 addition & 7 deletions src/lib/diaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,7 @@ export const FaladorDiary: Diary = {
woodcutting: 71
},
qp: 32,
collectionLogReqs: resolveItems([
'Mind rune',
'Prospector jacket',
'Prospector helmet',
'Prospector legs',
'Prospector boots'
]),
collectionLogReqs: resolveItems(['Mind rune', 'Prospector helmet']),
monsterScores: {
'Skeletal Wyvern': 1,
'Blue Dragon': 1
Expand Down
22 changes: 13 additions & 9 deletions src/lib/handleNewCLItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { allCLItems, allCollectionLogsFlat, calcCLDetails } from './data/Collect
import { calculateMastery } from './mastery';
import { calculateOwnCLRanking, roboChimpSyncData } from './roboChimp';

import { RawSQL } from './rawSql';
import { MUserStats } from './structures/MUserStats';
import { fetchCLLeaderboard } from './util/clLeaderboard';
import { insertUserEvent } from './util/userEvents';
Expand Down Expand Up @@ -51,6 +52,10 @@ export async function handleNewCLItems({
await prisma.historicalData.create({ data: await createHistoricalData(user) });
}

if (didGetNewCLItem) {
await prisma.$queryRawUnsafe(RawSQL.updateCLArray(user.id));
}

if (!didGetNewCLItem) return;

const previousCLDetails = calcCLDetails(previousCL);
Expand Down Expand Up @@ -105,15 +110,14 @@ export async function handleNewCLItems({
})}!`
: '';

const nthUser = (
await fetchCLLeaderboard({
ironmenOnly: false,
items: finishedCL.items,
resultLimit: 100_000,
method: 'raw_cl',
userEvents: null
})
).filter(u => u.qty === finishedCL.items.length).length;
const leaderboardUsers = await fetchCLLeaderboard({
ironmenOnly: false,
items: finishedCL.items,
resultLimit: 100_000,
clName: finishedCL.name
});

const nthUser = leaderboardUsers.users.filter(u => u.qty === finishedCL.items.length).length;

const placeStr = nthUser > 100 ? '' : ` They are the ${formatOrdinal(nthUser)} user to finish this CL.`;

Expand Down
1 change: 0 additions & 1 deletion src/lib/minions/data/killableMonsters/vannakaMonsters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ export const vannakaMonsters: KillableMonster[] = [
healAmountNeeded: 12,
attackStyleToUse: GearStat.AttackRanged,
attackStylesUsed: [GearStat.AttackMagic],
canCannon: true,
pkActivityRating: 4,
pkBaseDeathChance: 6,
revsWeaponBoost: true
Expand Down
5 changes: 2 additions & 3 deletions src/lib/minions/data/quests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const quests: Quest[] = [
},
combatLevelReq: 50,
qpReq: 10,
rewards: new Bank().add(28_587).add(28_587).add(28_588).add(28_589).add(28_590).freeze(),
rewards: new Bank().add(28_587).add(28_588).add(28_589).add(28_590).freeze(),
calcTime: (user: MUser) => {
let duration = Time.Minute * 10;
if (user.combatLevel < 90) {
Expand Down Expand Up @@ -112,8 +112,7 @@ export const quests: Quest[] = [
},
combatLevelReq: 65,
qpReq: 20,
// Awaiting item update for the lamp to be added
// rewards: new Bank().add(28_820).freeze(),
rewards: new Bank().add(28_820).freeze(),
skillsRewards: {
smithing: 15_000,
hunter: 15_000
Expand Down
4 changes: 2 additions & 2 deletions src/lib/minions/functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function resolveAttackStyles(
// Automatically use magic if barrage/burst is chosen
if (
params.boostMethod &&
(params.boostMethod === 'barrage' || params.boostMethod === 'burst') &&
(params.boostMethod.includes('barrage') || params.boostMethod.includes('burst')) &&
!attackStyles.includes(SkillsEnum.Magic)
) {
if (attackStyles.includes(SkillsEnum.Defence)) {
Expand All @@ -97,7 +97,7 @@ export function resolveAttackStyles(
}

export async function addMonsterXP(user: MUser, params: AddMonsterXpParams) {
const boostMethod = params.burstOrBarrage ? 'barrage' : 'none';
const boostMethod = params.burstOrBarrage ? ['barrage'] : ['none'];

const [, osjsMon, attackStyles] = resolveAttackStyles(user, {
monsterID: params.monsterID,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/minions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export interface AddMonsterXpParams {

export interface ResolveAttackStylesParams {
monsterID: number | undefined;
boostMethod?: string;
boostMethod?: string[];
}

export interface BlowpipeData {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/musicCape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const musicCapeRequirements = new Requirements()
}
})
.add({
name: 'Runecraft all runes atleast once',
name: 'Runecraft all runes at least once',
has: ({ uniqueRunesCrafted }) => {
const runesToCheck = resolveItems([
'Mind rune',
Expand Down
5 changes: 4 additions & 1 deletion src/lib/preStartup.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { noOp } from 'e';
import { syncCustomPrices } from '../mahoji/lib/events';
import { syncActivityCache } from './Task';
import { cacheBadges } from './badges';
import { syncBlacklists } from './blacklists';
import { GrandExchange } from './grandExchange';
import { cacheGEPrices } from './marketPrices';
import { populateRoboChimpCache } from './perkTier';
import { RawSQL } from './rawSql';
import { runStartupScripts } from './startupScripts';
import { logWrapFn } from './util';
import { syncActiveUserIDs } from './util/cachedUserIDs';
Expand All @@ -21,6 +23,7 @@ export const preStartup = logWrapFn('PreStartup', async () => {
cacheBadges(),
GrandExchange.init(),
populateRoboChimpCache(),
cacheGEPrices()
cacheGEPrices(),
prisma.$queryRawUnsafe(RawSQL.updateAllUsersCLArrays()).then(noOp)
]);
});
Loading

0 comments on commit 083221b

Please sign in to comment.