Skip to content

Commit

Permalink
Lint, Offering fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkWorldsArtist committed Oct 29, 2024
1 parent d205b07 commit aceac81
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 58 deletions.
18 changes: 8 additions & 10 deletions docs/src/content/docs/getting-started/wiki.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ This is an automatically generated list of pages with possible issues to be look

[/bso/Skills/divination.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/divination.md): Doesnt use the new command formatting

[/bso/Skills/dungeoneering.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/dungeoneering.md): Doesnt use the new command formatting
[/bso/Skills/Dungeoneering.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/Dungeoneering.md): Doesnt use the new command formatting

[/bso/Skills/farming.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/farming.md): Doesnt use the new command formatting

Expand All @@ -251,9 +251,9 @@ This is an automatically generated list of pages with possible issues to be look

[/bso/Skills/runecraft.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/runecraft.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)

[/bso/Skills/Slayer/README.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/Slayer/README.md): Doesnt use the new command formatting
[/bso/Skills/slayer/README.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/slayer/README.md): Doesnt use the new command formatting

[/bso/Skills/Slayer/slayer-masks-helms.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/Slayer/slayer-masks-helms.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)
[/bso/Skills/slayer/slayer-masks-helms.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/slayer/slayer-masks-helms.md): Doesnt use the new command formatting, Contains unintended HTML (e.g. `<td>`)

[/bso/Skills/smithing.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/bso/Skills/smithing.md): Doesnt use the new command formatting

Expand Down Expand Up @@ -291,8 +291,12 @@ This is an automatically generated list of pages with possible issues to be look

[/index.mdx](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/index.mdx): Doesnt use the new command formatting

[/osb/Activities/aerial-fishing.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Activities/aerial-fishing.md): Doesnt use the new command formatting

[/osb/Activities/fountain-of-rune.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Activities/fountain-of-rune.md): Doesnt use the new command formatting

[/osb/Activities/guardians-of-the-rift.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Activities/guardians-of-the-rift.md): Doesnt use the new command formatting

[/osb/Activities/hallowed-sepulchre.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Activities/hallowed-sepulchre.md): Doesnt use the new command formatting

[/osb/Activities/mage-training-arena.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Activities/mage-training-arena.md): Doesnt use the new command formatting
Expand Down Expand Up @@ -421,8 +425,6 @@ This is an automatically generated list of pages with possible issues to be look

[/osb/Skills/firemaking.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/firemaking.md): Doesnt use the new command formatting

[/osb/Skills/fishing/aerial-fishing.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/fishing/aerial-fishing.md): Doesnt use the new command formatting

[/osb/Skills/fishing/drift-net-fishing.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/fishing/drift-net-fishing.md): Doesnt use the new command formatting

[/osb/Skills/fishing/fishing-training.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/fishing/fishing-training.md): Doesnt use the new command formatting
Expand Down Expand Up @@ -453,11 +455,7 @@ This is an automatically generated list of pages with possible issues to be look

[/osb/Skills/prayer.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/prayer.md): Doesnt use the new command formatting

[/osb/Skills/runecrafting/guardians-of-the-rift.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/runecrafting/guardians-of-the-rift.md): Doesnt use the new command formatting

[/osb/Skills/runecrafting/README.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/runecrafting/README.md): Doesnt use the new command formatting

[/osb/Skills/runecrafting/runecrafting-training.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/runecrafting/runecrafting-training.md): Doesnt use the new command formatting
[/osb/Skills/runecrafting.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/runecrafting.md): Doesnt use the new command formatting

[/osb/Skills/slayer/README.md](https://github.com/oldschoolgg/oldschoolbot/blob/master/docs/src/content/docs/osb/Skills/slayer/README.md): Doesnt use the new command formatting

Expand Down
13 changes: 4 additions & 9 deletions src/mahoji/commands/offer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { evilChickenOutfit } from '../../lib/data/CollectionsExport';
import { Offerables } from '../../lib/data/offerData';
import { birdsNestID, treeSeedsNest } from '../../lib/simulation/birdsNest';
import Prayer from '../../lib/skilling/skills/prayer';
import { Bone, SkillsEnum } from '../../lib/skilling/types';
import { type Bone, SkillsEnum } from '../../lib/skilling/types';
import type { OfferingActivityTaskOptions } from '../../lib/types/minions';
import addSubTaskToActivityTask from '../../lib/util/addSubTaskToActivityTask';
import { calcMaxTripLength } from '../../lib/util/calcMaxTripLength';
Expand Down Expand Up @@ -236,11 +236,9 @@ export const offerCommand: OSBMahojiCommand = {
const boneOrFish = [...Prayer.Bones, ...Prayer.PreparedFish].find(
item => stringMatches(item.name, options.name) || stringMatches(item.name.split(' ')[0], options.name)
);

console.log(boneOrFish)

if (!boneOrFish) {
return "That's not a valid bone or fishto offer.";
return "That's not a valid bone or fish to offer.";
}

if (user.skillLevel(SkillsEnum.Prayer) < boneOrFish.level) {
Expand Down Expand Up @@ -284,11 +282,8 @@ export const offerCommand: OSBMahojiCommand = {
duration,
type: 'Offering'
});
const location = Prayer.Bones.includes(boneOrFish as Bone)
? 'the Chaos altar'
: 'the Ruins of Camdozaal';

const location = Prayer.Bones.includes(boneOrFish as Bone) ? 'the Chaos altar' : 'the Ruins of Camdozaal';

return `${user.minionName} is now offering ${quantity}x ${boneOrFish.name} at ${location}, it'll take around ${formatDuration(duration)} to finish.`;

}
};
97 changes: 58 additions & 39 deletions src/tasks/minions/PrayerActivity/offeringActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,58 +27,77 @@ export const offeringTask: MinionTask = {
const user = await mUserFetch(userID);
const { zealOutfitAmount, zealOutfitChance } = zealOutfitBoost(user);

// Determine if the offered item is a bone or a prepared fish
const bone = Prayer.Bones.find(bone => bone.inputId === boneID);
const fish = Prayer.PreparedFish.find(fish => fish.inputId === boneID); // Assuming you can identify fish with boneID

const XPMod = 3.5;
let bonesLost = 0;
if (!bone) return;

// make it so you can't lose more bones then you bring
let maxPK = quantity;
if (quantity >= 27) {
maxPK = 27;
}

const trips = Math.ceil(quantity / 27);
let deathCounter = 0;
// roll a 10% chance to get pked per trip
for (let i = 0; i < trips; i++) {
if (roll(10)) {
deathCounter++;
let newQuantity = quantity; // Initialize newQuantity

if (bone) {
// Logic for bones
// Prevent losing more bones than brought
const maxPK = quantity >= 27 ? 27 : quantity;
const trips = Math.ceil(quantity / 27);
let deathCounter = 0;

// Roll a 10% chance to get pked per trip
for (let i = 0; i < trips; i++) {
if (roll(10)) {
deathCounter++;
}
}
}
// calc how many bones are lost
for (let i = 0; i < deathCounter; i++) {
bonesLost += randInt(1, maxPK);
}
const bonesSaved = Math.floor(quantity * (randInt(90, 110) / 100));
let zealBonesSaved = 0;

if (zealOutfitAmount > 0) {
for (let i = 0; i < quantity; i++) {
if (percentChance(zealOutfitChance)) {
zealBonesSaved++;
// Calculate how many bones are lost
for (let i = 0; i < deathCounter; i++) {
bonesLost += randInt(1, maxPK);
}
const bonesSaved = Math.floor(quantity * (randInt(90, 110) / 100));
let zealBonesSaved = 0;

if (zealOutfitAmount > 0) {
for (let i = 0; i < quantity; i++) {
if (percentChance(zealOutfitChance)) {
zealBonesSaved++;
}
}
}
}

const newQuantity = quantity - bonesLost + bonesSaved + zealBonesSaved;
newQuantity = quantity - bonesLost + bonesSaved + zealBonesSaved;

const xpReceived = newQuantity * bone.xp * XPMod;
const xpReceived = newQuantity * bone.xp * XPMod;

const xpRes = await user.addXP({
skillName: SkillsEnum.Prayer,
amount: xpReceived,
duration: data.duration,
source: 'OfferingBones'
});
const xpRes = await user.addXP({
skillName: SkillsEnum.Prayer,
amount: xpReceived,
duration: data.duration,
source: 'OfferingBones'
});

let str = `${user}, ${user.minionName} finished offering ${newQuantity} ${bone.name}, you managed to offer ${bonesSaved} extra bones because of the effects the Chaos altar and you lost ${bonesLost} to pkers, ${xpRes}.`;
let str = `${user}, ${user.minionName} finished offering ${newQuantity} ${bone.name}, you managed to offer ${bonesSaved} extra bones because of the effects of the Chaos altar and you lost ${bonesLost} to pkers, ${xpRes}.`;

if (zealOutfitAmount > 0) {
str += `\nYour ${zealOutfitAmount} pieces of Zealot's robes helped you offer an extra ${zealBonesSaved} bones.`;
}
if (zealOutfitAmount > 0) {
str += `\nYour ${zealOutfitAmount} pieces of Zealot's robes helped you offer an extra ${zealBonesSaved} bones.`;
}

handleTripFinish(user, channelID, str, undefined, data, null);
handleTripFinish(user, channelID, str, undefined, data, null);
return;
} else if (fish) {
// Logic for prepared fish
const xpReceived = quantity * fish.xp * XPMod;

const xpRes = await user.addXP({
skillName: SkillsEnum.Prayer,
amount: xpReceived,
duration: data.duration,
source: 'OfferingBones'
});

const str = `${user}, ${user.minionName} finished offering ${quantity} ${fish.name}, ${xpRes}`;
handleTripFinish(user, channelID, str, undefined, data, null);
} else {
return;
}
}
};
Binary file modified tests/unit/snapshots/bank.OSB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/unit/snapshots/chatHead.OSB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/unit/snapshots/cl.OSB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/unit/snapshots/cox.OSB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/unit/snapshots/poh.OSB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/unit/snapshots/toa.OSB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit aceac81

Please sign in to comment.