Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/oldschoolgg/oldschoolbot
Browse files Browse the repository at this point in the history
…into blood-reavers
  • Loading branch information
TastyPumPum committed Feb 27, 2024
2 parents 3b61913 + ea735c1 commit 2b2f3e0
Show file tree
Hide file tree
Showing 17 changed files with 207 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"murmurhash": "^2.0.1",
"node-cron": "^3.0.3",
"node-fetch": "^2.6.7",
"oldschooljs": "^2.5.0",
"oldschooljs": "^2.5.1",
"p-queue": "^6.6.2",
"piscina": "^4.3.2",
"random-js": "^2.1.0",
Expand Down
3 changes: 3 additions & 0 deletions prisma/robochimp.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ model User {
store_bitfield Int[]
testing_points Float @default(0)
testing_points_balance Float @default(0)
@@map("user")
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function analyticsTick() {
await Promise.all(
[
'SELECT COUNT(*)::int FROM users WHERE "minion.hasBought" = true;',
'SELECT SUM("sacrificedValue")::int AS count FROM users;',
'SELECT SUM("sacrificedValue") AS count FROM users;',
'SELECT COUNT(*)::int FROM users WHERE "minion.ironman" = true;',
'SELECT SUM("GP") AS count FROM users;'
].map(query => prisma.$queryRawUnsafe(query))
Expand Down
26 changes: 26 additions & 0 deletions src/lib/combat_achievements/easy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { warmGear } from '../data/filterables';
import { SkillsEnum } from '../skilling/types';
import { Requirements } from '../structures/Requirements';
import getOSItem from '../util/getOSItem';
import resolveItems from '../util/resolveItems';
import { isCertainMonsterTrip } from './caUtils';
import { type CombatAchievement } from './combatAchievements';

Expand Down Expand Up @@ -413,5 +414,30 @@ export const easyCombatAchievements: CombatAchievement[] = [
[Monsters.Wyrm.id]: 1
}
})
},
{
id: 34,
name: 'Sit Rat',
type: 'restriction',
monster: 'Scurrius',
desc: 'Finish off Scurrius with a ratbane weapon.',
rng: {
chancePerKill: 1,
hasChance: (data, user) =>
isCertainMonsterTrip(Monsters.Scurrius.id)(data) &&
[resolveItems(['Bone mace', 'Bone staff', 'Bone shortbow'])].some(i => user.hasEquipped(i))
}
},
{
id: 35,
name: 'Scurrius Novice',
type: 'kill_count',
monster: 'Scurrius',
desc: 'Kill Scurrius once.',
requirements: new Requirements().add({
kcRequirement: {
[Monsters.Scurrius.id]: 1
}
})
}
];
34 changes: 34 additions & 0 deletions src/lib/combat_achievements/medium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,5 +491,39 @@ export const mediumCombatAchievements: CombatAchievement[] = [
wintertodt: 10
}
})
},
{
id: 141,
name: 'Scurrius Champion',
type: 'kill_count',
monster: 'Scurrius',
desc: 'Kill Scurrius 10 times.',
requirements: new Requirements().add({
kcRequirement: {
[Monsters.Scurrius.id]: 10
}
})
},
{
id: 142,
name: 'Perfect Scurrius',
type: 'perfection',
monster: 'Scurrius',
desc: 'Kill Scurrius in a private instance without taking damage from the following attacks: Tail Swipe and Falling Bricks. Pray correctly against the following attacks: Flying Fur and Bolts of Electricity.',
rng: {
chancePerKill: 10,
hasChance: isCertainMonsterTrip(Monsters.Scurrius.id)
}
},
{
id: 143,
name: 'Efficient Pest Control',
type: 'mechanical',
monster: 'Scurrius',
desc: "Kill 6 Giant Rats within Scurrius' lair in 3 seconds.",
rng: {
chancePerKill: 10,
hasChance: isCertainMonsterTrip(Monsters.Scurrius.id)
}
}
];
6 changes: 6 additions & 0 deletions src/lib/data/Collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,12 @@ export const allCollectionLogs: ICollection = {
items: scorpiaCL,
fmtProg: kcProg(Monsters.Scorpia)
},
Scurrius: {
alias: Monsters.Scurrius.aliases,
allItems: Monsters.Scurrius.allItems,
items: resolveItems(['Scurry', "Scurrius' spine"]),
fmtProg: kcProg(Monsters.Scurrius)
},
Skotizo: {
alias: Monsters.Skotizo.aliases,
allItems: Monsters.Skotizo.allItems,
Expand Down
3 changes: 2 additions & 1 deletion src/lib/data/CollectionsExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,8 @@ export const allPetsCL = resolveItems([
'Wisp',
"Lil'viathan",
'Butch',
'Baron'
'Baron',
'Scurry'
]);
export const camdozaalCL = resolveItems([
'Barronite mace',
Expand Down
6 changes: 6 additions & 0 deletions src/lib/data/creatablesTable.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@
╟─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────╢
║ Webweaver bow (u) │ 500,000x Coins, 1x Craw's bow (u), 1x Fangs of venenatis │ 1x Webweaver bow (u) │ 0 ║
╟─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────╢
║ Bone mace │ 1x Rune mace, 1x Scurrius' spine │ 1x Bone mace │ 0 ║
╟─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────╢
║ Bone shortbow │ 1x Yew shortbow, 1x Scurrius' spine │ 1x Bone shortbow │ 0 ║
╟─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────╢
║ Bone staff │ 1,000x Chaos rune, 1x Battlestaff, 1x Scurrius' spine │ 1x Bone staff │ 0 ║
╟─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────╢
║ Revert tanzanite fang │ 1x Tanzanite fang │ 20,000x Zulrah's scales │ 0 ║
╟─────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────────╢
║ Revert toxic blowpipe (empty) │ 1x Toxic blowpipe (empty) │ 20,000x Zulrah's scales │ 0 ║
Expand Down
24 changes: 24 additions & 0 deletions src/lib/data/createables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2342,6 +2342,30 @@ const Createables: Createable[] = [
'Webweaver bow (u) ': 1
})
},
{
name: 'Bone mace',
inputItems: new Bank().add('Rune mace').add("Scurrius' spine"),
outputItems: new Bank().add('Bone mace'),
requiredSkills: {
smithing: 35
}
},
{
name: 'Bone shortbow',
inputItems: new Bank().add('Yew shortbow').add("Scurrius' spine"),
outputItems: new Bank().add('Bone shortbow'),
requiredSkills: {
fletching: 35
}
},
{
name: 'Bone staff',
inputItems: new Bank().add('Battlestaff').add('Chaos rune', 1000).add("Scurrius' spine"),
outputItems: new Bank().add('Bone staff'),
requiredSkills: {
crafting: 35
}
},
...Reverteables,
...crystalTools,
...ornamentKits,
Expand Down
13 changes: 13 additions & 0 deletions src/lib/minions/data/killableMonsters/bosses/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,19 @@ const killableBosses: KillableMonster[] = [
messages.push('You got a Charged ice for killing the Phantom Muspah in under 3 minutes!');
},
healAmountNeeded: 150
},
{
id: Monsters.Scurrius.id,
name: Monsters.Scurrius.name,
aliases: Monsters.Scurrius.aliases,
timeToFinish: Time.Minute * 2,
table: Monsters.Scurrius,
notifyDrops: resolveItems(['Scurry']),
qpRequired: 0,
levelRequirements: {
prayer: 43
},
defaultAttackStyles: [SkillsEnum.Attack]
}
];

Expand Down
2 changes: 1 addition & 1 deletion src/lib/slayer/slayerUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export async function getUsersCurrentSlayerInfo(id: string) {
}

const slayerMaster = slayerMasters.find(master => master.id === currentTask.slayer_master_id);
const assignedTask = slayerMaster!.tasks.find(m => m.monster.id === currentTask.monster_id)!;
const assignedTask = slayerMaster?.tasks.find(m => m.monster.id === currentTask.monster_id);

if (!assignedTask || !slayerMaster) {
logError(
Expand Down
3 changes: 2 additions & 1 deletion src/lib/slayer/tasks/turaelTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ export const turaelTasks: AssignableSlayerTask[] = [
Monsters.DungeonRat.id,
Monsters.CryptRat.id,
Monsters.ZombieRat.id,
Monsters.BrineRat.id
Monsters.BrineRat.id,
Monsters.Scurrius.id
],
unlocked: true
},
Expand Down
12 changes: 12 additions & 0 deletions src/mahoji/commands/rp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Bank } from 'oldschooljs';
import { Item } from 'oldschooljs/dist/meta/types';

import { ADMIN_IDS, OWNER_IDS, production, SupportServer } from '../../config';
import { analyticsTick } from '../../lib/analytics';
import { BitField, Channel } from '../../lib/constants';
import { GearSetupType } from '../../lib/gear/types';
import { GrandExchange } from '../../lib/grandExchange';
Expand Down Expand Up @@ -78,6 +79,12 @@ export const rpCommand: OSBMahojiCommand = {
name: 'view_all_items',
description: 'View all item IDs present in banks/cls.',
options: []
},
{
type: ApplicationCommandOptionType.Subcommand,
name: 'analytics_tick',
description: 'analyticsTick.',
options: []
}
]
},
Expand Down Expand Up @@ -309,6 +316,7 @@ export const rpCommand: OSBMahojiCommand = {
validate_ge?: {};
patreon_reset?: {};
view_all_items?: {};
analytics_tick?: {};
};
player?: {
viewbank?: { user: MahojiUserOption; json?: boolean };
Expand Down Expand Up @@ -355,6 +363,10 @@ export const rpCommand: OSBMahojiCommand = {
}
return 'Something was invalid. Check logs!';
}
if (options.action?.analytics_tick) {
await analyticsTick();
return 'Finished.';
}

if (options.action?.view_all_items) {
const result = await prisma.$queryRawUnsafe<
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/commands/sacrifice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ describe('Sacrifice Command', async () => {
expect(result).toEqual(
`${Emoji.Incinerator} **Your Sacrifice Stats** ${Emoji.Incinerator}\n\n` +
`**Current Minion Icon:** ${Emoji.Minion}\n` +
'**Sacrificed Value:** 1,922 GP\n' +
'**Sacrificed Value:** 1,909 GP\n' +
'**Unique Items Sacrificed:** 2 items'
);
});

test('No items provided', async () => {
const result = await user.runCommand(sacrificeCommand, { items: 'aaaa' });
expect(result).toEqual('No items were provided.\nYour current sacrificed value is: 1,922 (1.92k)');
expect(result).toEqual('No items were provided.\nYour current sacrificed value is: 1,909 (1.91k)');
});

test('Successful', async () => {
await user.addItemsToBank({ items: new Bank().add('Trout').add('Coal', 10) });
const result = await user.runCommand(sacrificeCommand, { items: '1 trout, 10 coal' });
expect(result).toEqual(
'You sacrificed 10x Coal, 1x Trout, with a value of 1,922gp (1.92k). Your total amount sacrificed is now: 3,844. '
'You sacrificed 10x Coal, 1x Trout, with a value of 1,909gp (1.91k). Your total amount sacrificed is now: 3,818. '
);
const stats = await user.fetchStats({ sacrificed_bank: true });
expect(user.bank.equals(new Bank())).toBe(true);
expect(new Bank(stats.sacrificed_bank as ItemBank).equals(new Bank().add('Coal', 20).add('Trout', 2))).toBe(
true
);
expect(user.user.sacrificedValue).toEqual(BigInt(3844));
expect(user.user.sacrificedValue).toEqual(BigInt(3818));
const clientSettings = await mahojiClientSettingsFetch({ economyStats_sacrificedBank: true });
expect(
new Bank(clientSettings.economyStats_sacrificedBank as ItemBank).equals(
Expand All @@ -49,15 +49,15 @@ describe('Sacrifice Command', async () => {
await user.addItemsToBank({ items: new Bank().add('Trout').add('Cake') });
const res = await user.runCommand(sacrificeCommand, { items: '1 trout, 1 cake' });
expect(res).toEqual(
'You sacrificed 1x Trout, 1x Cake, with a value of 169gp (169). Your total amount sacrificed is now: 4,013. '
'You sacrificed 1x Trout, 1x Cake, with a value of 156gp (156). Your total amount sacrificed is now: 3,974. '
);
await user.sync();
expect(user.bank.equals(new Bank())).toBe(true);
const stats2 = await user.fetchStats({ sacrificed_bank: true });
expect(
new Bank(stats2.sacrificed_bank as ItemBank).equals(new Bank().add('Coal', 20).add('Trout', 3).add('Cake'))
).toBe(true);
expect(user.user.sacrificedValue).toEqual(BigInt(4013));
expect(user.user.sacrificedValue).toEqual(BigInt(3974));

const clientSettings2 = await mahojiClientSettingsFetch({ economyStats_sacrificedBank: true });
expect(
Expand Down
Loading

0 comments on commit 2b2f3e0

Please sign in to comment.