Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solis & Clue Tame #5677

Merged
merged 17 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ model ClientStorage {

xmas_ironman_food_bank Json @default("{}") @db.Json

divination_is_released Boolean @default(false)

@@map("clientStorage")
}

Expand Down Expand Up @@ -757,6 +755,14 @@ model Tame {

total_cost Json @default("{}") @db.Json

demonic_jibwings_saved_cost Json @default("{}") @db.JsonB
third_age_jibwings_loot Json @default("{}") @db.JsonB
abyssal_jibwings_loot Json @default("{}") @db.JsonB
implings_loot Json @default("{}") @db.JsonB

last_activity_date DateTime? @db.Timestamp(6)
levels_from_egg_feed Int?

tame_activity TameActivity[]

@@index([user_id])
Expand Down
34 changes: 33 additions & 1 deletion src/lib/MUser.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { userMention } from '@discordjs/builders';
import { UserError } from '@oldschoolgg/toolkit/dist/lib/UserError';
import { Prisma, User, UserStats, xp_gains_skill_enum } from '@prisma/client';
import { Prisma, TameActivity, User, UserStats, xp_gains_skill_enum } from '@prisma/client';
import { calcWhatPercent, objectEntries, randArrItem, sumArr, Time, uniqueArr } from 'e';
import { Bank } from 'oldschooljs';
import { EquipmentSlot, Item } from 'oldschooljs/dist/meta/types';

import { timePerAlch } from '../mahoji/lib/abstracted_commands/alchCommand';
import { getParsedStashUnits } from '../mahoji/lib/abstracted_commands/stashUnitsCommand';
import { userStatsUpdate } from '../mahoji/mahojiSettings';
import { addXP } from './addXP';
import { GodFavourBank, GodName } from './bso/divineDominion';
Expand Down Expand Up @@ -420,7 +421,7 @@

for (const setup of Object.values(this.gear)) {
for (const equipped of Object.values(setup)) {
if (equipped?.item) {

Check warning on line 424 in src/lib/MUser.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected any value in conditional. An explicit comparison or type cast is required
bank.add(equipped.item, equipped.quantity);
}
}
Expand Down Expand Up @@ -615,10 +616,10 @@
}
const scales = Math.ceil((10 / 3) * dart[1]);
const rawBlowpipeData = this.blowpipe;
if (!this.allItemsOwned.has('Toxic blowpipe') || !rawBlowpipeData) {

Check warning on line 619 in src/lib/MUser.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected object value in conditional. The condition is always true
throw new UserError("You don't have a Toxic blowpipe.");
}
if (!rawBlowpipeData.dartID || !rawBlowpipeData.dartQuantity) {

Check warning on line 622 in src/lib/MUser.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected number value in conditional. An explicit zero/NaN check is required
throw new UserError('You have no darts in your Toxic blowpipe.');
}
if (rawBlowpipeData.dartQuantity < dart[1]) {
Expand All @@ -628,7 +629,7 @@
)}s in your Toxic blowpipe, you need ${dart[1]}, but you have only ${rawBlowpipeData.dartQuantity}.`
);
}
if (!rawBlowpipeData.scales || rawBlowpipeData.scales < scales) {

Check warning on line 632 in src/lib/MUser.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected number value in conditional. An explicit zero/NaN check is required
throw new UserError(
`You don't have enough Zulrah's scales in your Toxic blowpipe, you need ${scales} but you have only ${rawBlowpipeData.scales}.`
);
Expand Down Expand Up @@ -769,7 +770,7 @@

private buildPaintedItems(): Map<number, number> {
const rawPaintedItems = this.user.painted_items_tuple;
if (!rawPaintedItems) return new Map();

Check warning on line 773 in src/lib/MUser.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected value in conditional. A boolean expression is required
return new Map(rawPaintedItems as [number, number][]);
}

Expand All @@ -780,7 +781,7 @@

async getGodFavour(): Promise<GodFavourBank> {
let { god_favour_bank: currentFavour } = await this.fetchStats({ god_favour_bank: true });
if (!currentFavour) {

Check warning on line 784 in src/lib/MUser.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected value in conditional. A boolean expression is required
return {
Zamorak: 0,
Armadyl: 0,
Expand Down Expand Up @@ -842,7 +843,7 @@
);
const track = mysteriousTrailTracks.find(i => i.id === trackID)!;
const step = track.steps[currentStepID - 1];
if (!step) {

Check warning on line 846 in src/lib/MUser.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected object value in conditional. The condition is always true
throw new Error(`No step for ${currentStepID} ${this.id}`);
}
return {
Expand Down Expand Up @@ -900,13 +901,13 @@
return resetBackground();
}
if (background.id === 1) return;
if (background.storeBitField && this.user.store_bitfield.includes(background.storeBitField)) {

Check warning on line 904 in src/lib/MUser.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected value in conditional. A boolean expression is required
return;
}
if (background.perkTierNeeded && this.perkTier() >= background.perkTierNeeded) {

Check warning on line 907 in src/lib/MUser.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected value in conditional. A boolean expression is required
return;
}
if (background.bitfield && this.bitfield.includes(background.bitfield)) {

Check warning on line 910 in src/lib/MUser.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected value in conditional. A boolean expression is required
return;
}
if (!background.storeBitField && !background.perkTierNeeded && !background.bitfield && !background.owners) {
Expand Down Expand Up @@ -956,6 +957,11 @@
return { refundBank };
}

async fetchStashUnits() {
const units = await getParsedStashUnits(this.id);
return units;
}

async validateEquippedGear() {
let itemsUnequippedAndRefunded = new Bank();
for (const [gearSetupName, gearSetup] of Object.entries(this.gear) as [GearSetupType, GearSetup][]) {
Expand Down Expand Up @@ -1000,6 +1006,32 @@
itemsUnequippedAndRefunded
};
}

async fetchTames() {
const tames = await prisma.tame.findMany({
where: {
user_id: this.id
}
});
return tames.map(t => new MTame(t));
}

async fetchActiveTame(): Promise<{ tame: null; activity: null } | { activity: TameActivity | null; tame: MTame }> {
if (!this.user.selected_tame) {
return {
tame: null,
activity: null
};
}
const tame = await prisma.tame.findFirst({ where: { id: this.user.selected_tame } });
if (!tame) {
throw new Error('No tame found for selected tame.');
}
const activity = await prisma.tameActivity.findFirst({
where: { user_id: this.id, tame_id: tame.id, completed: false }
});
return { activity, tame: new MTame(tame) };
}
}
declare global {
export type MUser = MUserClass;
Expand Down
4 changes: 3 additions & 1 deletion src/lib/bankImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ const forcedShortNameMap = new Map<number, string>([
[i('Sanguinesti staff (uncharged)'), 'Unch.'],
[i('Scythe of vitur (uncharged)'), 'Unch.'],
[i('Holy scythe of vitur (uncharged)'), 'Unch.'],
[i('Sanguine scythe of vitur (uncharged)'), 'Unch.']
[i('Sanguine scythe of vitur (uncharged)'), 'Unch.'],

[i('Atomic energy'), 'Atomic']
]);

for (const energy of divinationEnergies) {
Expand Down
17 changes: 16 additions & 1 deletion src/lib/bso/divination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { hasUnlockedAtlantis } from '../util';
import getOSItem from '../util/getOSItem';
import itemID from '../util/itemID';

export function calcEnergyPerMemory(energy: DivinationEnergy) {
return (120 - energy.level) / 150;
}

export const divinationEnergies = [
{
level: 1,
Expand Down Expand Up @@ -230,9 +234,20 @@ export const divinationEnergies = [
return null;
}
}
];
] as const;

export function calcAtomicEnergy(energy: DivinationEnergy): number {
let qty = Math.ceil(Math.pow(1 - calcEnergyPerMemory(energy), 3.5) * 250);
if (energy.type === 'Ancient') {
qty *= 2;
}
return qty;
}

export type DivinationEnergy = (typeof divinationEnergies)[number];

for (const energy of divinationEnergies) {
// @ts-ignore Ignore
energy.boonEnergyCost = energy.level * 50;
}

Expand Down
9 changes: 5 additions & 4 deletions src/lib/compCape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { calcWhatPercent, objectEntries, sumArr } from 'e';
import { writeFileSync } from 'fs';
import { Bank, Items } from 'oldschooljs';

import { tameFeedableItems } from '../mahoji/commands/tames';
import { getPOH } from '../mahoji/lib/abstracted_commands/pohCommand';
import { divinationEnergies } from './bso/divination';
import { ClueTiers } from './clues/clueTiers';
Expand Down Expand Up @@ -166,7 +165,7 @@ import { herbloreCL } from './skilling/skills/herblore/mixables';
import { smithingCL } from './skilling/skills/smithing/smithables';
import { slayerUnlockableRewards } from './slayer/slayerUnlocks';
import { RequirementFailure, Requirements } from './structures/Requirements';
import { TameSpeciesID, TameType } from './tames';
import { tameFeedableItems, TameSpeciesID } from './tames';
import { ItemBank } from './types';
import { itemID, itemNameFromID } from './util';
import resolveItems from './util/resolveItems';
Expand Down Expand Up @@ -695,7 +694,9 @@ const tameRequirements = new Requirements()
name: 'Feed a Monkey tame all items that provide a boost',
has: async ({ user }) => {
const tames = await user.getTames();
const itemsToBeFed = tameFeedableItems.filter(i => i.tameSpeciesCanBeFedThis.includes(TameType.Gatherer));
const itemsToBeFed = tameFeedableItems.filter(i =>
i.tameSpeciesCanBeFedThis.includes(TameSpeciesID.Monkey)
);

const oneTameHasAll = tames
.filter(t => t.species.id === TameSpeciesID.Monkey)
Expand All @@ -715,7 +716,7 @@ const tameRequirements = new Requirements()
name: 'Feed a Igne tame all items that provide a boost',
has: async ({ user }) => {
const tames = await user.getTames();
const itemsToBeFed = tameFeedableItems.filter(i => i.tameSpeciesCanBeFedThis.includes(TameType.Combat));
const itemsToBeFed = tameFeedableItems.filter(i => i.tameSpeciesCanBeFedThis.includes(TameSpeciesID.Igne));

const oneTameHasAll = tames
.filter(t => t.species.id === TameSpeciesID.Igne)
Expand Down
8 changes: 7 additions & 1 deletion src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ export enum BitField {
HasLuminousBoon = 223,
HasIncandescentBoon = 224,
HasVibrantBoon = 225,
HasAncientBoon = 226
HasAncientBoon = 226,
DisabledTameClueOpening = 227
}

interface BitFieldData {
Expand Down Expand Up @@ -515,6 +516,11 @@ export const BitFieldData: Record<BitField, BitFieldData> = {
name: 'Disable Item Contract donations',
protected: false,
userConfigurable: true
},
[BitField.DisabledTameClueOpening]: {
name: 'Disable Eagle Tame Opening Caskets',
protected: false,
userConfigurable: true
}
} as const;

Expand Down
Loading
Loading