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

Uncharge glory #5732

Closed
wants to merge 4 commits into from
Closed
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
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,7 @@ enum activity_type_enum {
Casting
GloryCharging
WealthCharging
GloryUncharging
BarbarianAssault
AgilityArena
ChampionsChallenge
Expand Down
3 changes: 2 additions & 1 deletion src/lib/Task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import { firemakingTask } from '../tasks/minions/firemakingActivity';
import { fishingTask } from '../tasks/minions/fishingActivity';
import { fletchingTask } from '../tasks/minions/fletchingActivity';
import { gloryChargingTask } from '../tasks/minions/gloryChargingActivity';
import { gloryChargingTask, gloryUnchargingTask } from '../tasks/minions/gloryChargingActivity';
import { groupoMonsterTask } from '../tasks/minions/groupMonsterActivity';
import { herbloreTask } from '../tasks/minions/herbloreActivity';
import { aerialFishingTask } from '../tasks/minions/HunterActivity/aerialFishingActivity';
Expand Down Expand Up @@ -145,6 +145,7 @@
fishingTask,
fletchingTask,
gloryChargingTask,
gloryUnchargingTask,
groupoMonsterTask,
herbloreTask,
fletchingTask,
Expand Down Expand Up @@ -213,7 +214,7 @@
return activities;
}
export async function syncActivityCache() {
const tasks = await prisma.activity.findMany({ where: { completed: false } });

Check warning on line 217 in src/lib/Task.ts

View workflow job for this annotation

GitHub Actions / Node v18.12.0 - ubuntu-latest

'tasks' is already declared in the upper scope on line 97 column 14

Check warning on line 217 in src/lib/Task.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'tasks' is already declared in the upper scope on line 97 column 14

minionActivityCache.clear();
for (const task of tasks) {
Expand All @@ -238,7 +239,7 @@
}

const task = tasks.find(i => i.type === activity.type)!;
if (!task) {

Check warning on line 242 in src/lib/Task.ts

View workflow job for this annotation

GitHub Actions / Node v18.12.0 - ubuntu-latest

Unexpected object value in conditional. The condition is always true

Check warning on line 242 in src/lib/Task.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

Unexpected object value in conditional. The condition is always true
throw new Error('Missing task');
}

Expand Down
2 changes: 2 additions & 0 deletions src/lib/types/minions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface ActivityTaskOptionsWithNoChanges extends ActivityTaskOptions {
| 'Wintertodt'
| 'Cyclops'
| 'GloryCharging'
| 'GloryUncharging'
| 'WealthCharging'
| 'BarbarianAssault'
| 'AgilityArena'
Expand Down Expand Up @@ -56,6 +57,7 @@ export interface ActivityTaskOptionsWithQuantity extends ActivityTaskOptions {
| 'DriftNet'
| 'WealthCharging'
| 'GloryCharging'
| 'GloryUncharging'
| 'AerialFishing'
| 'FishingTrawler'
| 'CamdozaalFishing'
Expand Down
5 changes: 5 additions & 0 deletions src/lib/util/minionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
case 'Agility': {
const data = currentTask as AgilityActivityTaskOptions;

const course = Agility.Courses.find(course => course.name === data.courseID);

Check warning on line 130 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v18.12.0 - ubuntu-latest

'course' is already declared in the upper scope on line 130 column 10

Check warning on line 130 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'course' is already declared in the upper scope on line 130 column 10

return `${name} is currently running ${data.quantity}x ${course!.name} laps. ${formattedDuration} Your ${
Emoji.Agility
Expand All @@ -137,7 +137,7 @@
case 'Cooking': {
const data = currentTask as CookingActivityTaskOptions;

const cookable = Cooking.Cookables.find(cookable => cookable.id === data.cookableID);

Check warning on line 140 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v18.12.0 - ubuntu-latest

'cookable' is already declared in the upper scope on line 140 column 10

Check warning on line 140 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'cookable' is already declared in the upper scope on line 140 column 10

return `${name} is currently cooking ${data.quantity}x ${cookable!.name}. ${formattedDuration} Your ${
Emoji.Cooking
Expand All @@ -147,7 +147,7 @@
case 'Fishing': {
const data = currentTask as FishingActivityTaskOptions;

const fish = Fishing.Fishes.find(fish => fish.id === data.fishID);

Check warning on line 150 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v18.12.0 - ubuntu-latest

'fish' is already declared in the upper scope on line 150 column 10

Check warning on line 150 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'fish' is already declared in the upper scope on line 150 column 10

return `${name} is currently fishing ${data.quantity}x ${fish!.name}. ${formattedDuration} Your ${
Emoji.Fishing
Expand All @@ -157,7 +157,7 @@
case 'Mining': {
const data = currentTask as MiningActivityTaskOptions;

const ore = Mining.Ores.find(ore => ore.id === data.oreID);

Check warning on line 160 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v18.12.0 - ubuntu-latest

'ore' is already declared in the upper scope on line 160 column 10

Check warning on line 160 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'ore' is already declared in the upper scope on line 160 column 10

return `${name} is currently mining ${ore!.name}. ${
data.fakeDurationMax === data.fakeDurationMin
Expand Down Expand Up @@ -187,7 +187,7 @@
case 'Smelting': {
const data = currentTask as SmeltingActivityTaskOptions;

const bar = Smithing.Bars.find(bar => bar.id === data.barID);

Check warning on line 190 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v18.12.0 - ubuntu-latest

'bar' is already declared in the upper scope on line 190 column 10

Check warning on line 190 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'bar' is already declared in the upper scope on line 190 column 10

return `${name} is currently smelting ${data.quantity}x ${bar!.name}. ${formattedDuration} Your ${
Emoji.Smithing
Expand All @@ -207,7 +207,7 @@
case 'Offering': {
const data = currentTask as OfferingActivityTaskOptions;

const bones = Prayer.Bones.find(bones => bones.inputId === data.boneID);

Check warning on line 210 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v18.12.0 - ubuntu-latest

'bones' is already declared in the upper scope on line 210 column 10

Check warning on line 210 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'bones' is already declared in the upper scope on line 210 column 10

return `${name} is currently offering ${data.quantity}x ${bones!.name}. ${formattedDuration} Your ${
Emoji.Prayer
Expand All @@ -217,7 +217,7 @@
case 'Burying': {
const data = currentTask as BuryingActivityTaskOptions;

const bones = Prayer.Bones.find(bones => bones.inputId === data.boneID);

Check warning on line 220 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v18.12.0 - ubuntu-latest

'bones' is already declared in the upper scope on line 220 column 10

Check warning on line 220 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'bones' is already declared in the upper scope on line 220 column 10

return `${name} is currently burying ${data.quantity}x ${bones!.name}. ${formattedDuration} Your ${
Emoji.Prayer
Expand All @@ -227,7 +227,7 @@
case 'Scattering': {
const data = currentTask as ScatteringActivityTaskOptions;

const ashes = Prayer.Ashes.find(ashes => ashes.inputId === data.ashID);

Check warning on line 230 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v18.12.0 - ubuntu-latest

'ashes' is already declared in the upper scope on line 230 column 10

Check warning on line 230 in src/lib/util/minionStatus.ts

View workflow job for this annotation

GitHub Actions / Node v20 - ubuntu-latest

'ashes' is already declared in the upper scope on line 230 column 10

return `${name} is currently scattering ${data.quantity}x ${ashes!.name}. ${formattedDuration} Your ${
Emoji.Prayer
Expand Down Expand Up @@ -483,6 +483,11 @@
return `${name} is currently charging ${data.quantity}x inventories of glories at the Fountain of Rune. ${formattedDuration}`;
}

case 'GloryUncharging': {
const data = currentTask as ActivityTaskOptionsWithQuantity;
return `${name} is currently uncharging ${data.quantity}x glories. ${formattedDuration}`;
}

case 'WealthCharging': {
const data = currentTask as ActivityTaskOptionsWithQuantity;
return `${name} is currently charging ${data.quantity}x inventories of rings of wealth at the Fountain of Rune. ${formattedDuration}`;
Expand Down
6 changes: 6 additions & 0 deletions src/lib/util/repeatStoredTrip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@ export const tripHandlers = {
commandName: 'activities',
args: (data: ActivityTaskOptionsWithQuantity) => ({ charge: { item: 'glory', quantity: data.quantity } })
},
[activity_type_enum.GloryUncharging]: {
commandName: 'activities',
args: (data: ActivityTaskOptionsWithQuantity) => ({
charge: { item: 'unchargeglory', quantity: data.quantity }
})
},
[activity_type_enum.GnomeRestaurant]: {
commandName: 'minigames',
args: () => ({ gnome_restaurant: { start: {} } })
Expand Down
1 change: 1 addition & 0 deletions src/lib/util/taskGroupFromActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function taskGroupFromActivity(type: activity_type_enum): ActivityGroup {
case 'Enchanting':
case 'Casting':
case 'GloryCharging':
case 'GloryUncharging':
case 'WealthCharging':
case 'Collecting':
case 'BlastFurnace':
Expand Down
9 changes: 8 additions & 1 deletion src/mahoji/commands/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { butlerCommand } from '../lib/abstracted_commands/butlerCommand';
import { camdozaalCommand } from '../lib/abstracted_commands/camdozaalCommand';
import { castCommand } from '../lib/abstracted_commands/castCommand';
import { championsChallengeCommand } from '../lib/abstracted_commands/championsChallenge';
import { chargeGloriesCommand } from '../lib/abstracted_commands/chargeGloriesCommand';
import { chargeGloriesCommand, unchargeGloriesCommand } from '../lib/abstracted_commands/chargeGloriesCommand';
import { chargeWealthCommand } from '../lib/abstracted_commands/chargeWealthCommand';
import { chompyHuntClaimCommand, chompyHuntCommand } from '../lib/abstracted_commands/chompyHuntCommand';
import { collectables, collectCommand } from '../lib/abstracted_commands/collectCommand';
Expand Down Expand Up @@ -222,6 +222,10 @@ export const activitiesCommand: OSBMahojiCommand = {
{
name: 'Ring of wealth',
value: 'wealth'
},
{
name: 'Uncharge amulet of glory',
value: 'unchargeglory'
}
]
},
Expand Down Expand Up @@ -594,6 +598,9 @@ export const activitiesCommand: OSBMahojiCommand = {
if (options.charge?.item === 'wealth') {
return chargeWealthCommand(user, channelID, options.charge.quantity);
}
if (options.charge?.item === 'unchargeglory') {
return unchargeGloriesCommand(user, channelID, options.charge.quantity);
}
if (options.fight_caves) {
return fightCavesCommand(user, channelID);
}
Expand Down
44 changes: 44 additions & 0 deletions src/mahoji/lib/abstracted_commands/chargeGloriesCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,47 @@ export async function chargeGloriesCommand(user: MUser, channelID: string, quant
hasDiary ? ' 3x Boost for Wilderness Elite diary.' : ''
}`;
}

export async function unchargeGloriesCommand(user: MUser, channelID: string, quantity: number | undefined) {
const userBank = user.bank;

const unchargeGloriesTime = Time.Second * 2;

const maxTripLength = calcMaxTripLength(user, 'GloryUncharging');

const amountHas = userBank.amount('Amulet of glory(6)');

const max = Math.min(amountHas, Math.floor(maxTripLength / unchargeGloriesTime));

if (!quantity) quantity = Math.floor(max);
if (quantity > max) quantity = max;
if (quantity === 0) return "You don't have any Amulet of glory (6) to uncharge.";

const duration = quantity * unchargeGloriesTime;

if (duration > maxTripLength) {
return `${user.minionName} can't go on trips longer than ${formatDuration(
maxTripLength
)}, try a lower quantity. The highest amount of inventories of glories you can uncharge is ${Math.floor(
maxTripLength / unchargeGloriesTime
)}.`;
}

if (userBank.amount('Amulet of glory (6)') < quantity) {
return `You don't have enough ${quantity}x Amulet of glory (6).`;
}

await addSubTaskToActivityTask<ActivityTaskOptionsWithQuantity>({
userID: user.id,
channelID: channelID.toString(),
quantity,
duration,
type: 'GloryUncharging'
});

await user.removeItemsFromBank(new Bank().add('Amulet of glory (6)', quantity));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove before creating the activity. Also the cleaner way to do it is: const cost = ... if (!user.owns(cost))


return `${user.minionName} is now uncharging ${quantity} Amulet of glory (6), it'll take around ${formatDuration(
duration
)} to finish. Removed ${quantity}x Amulet of glory (6) from your bank.`;
}
20 changes: 20 additions & 0 deletions src/tasks/minions/gloryChargingActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,23 @@ export const gloryChargingTask: MinionTask = {
handleTripFinish(user, channelID, str, undefined, data, loot);
}
};

export const gloryUnchargingTask: MinionTask = {
type: 'GloryUncharging',
async run(data: ActivityTaskOptionsWithQuantity) {
const { quantity, userID, channelID } = data;
const user = await mUserFetch(userID);
let loot = new Bank().add('Amulet of glory', quantity);

const amnt = loot.amount('Amulet of glory');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable looks pointless, just use quantity?


const str = `${user}, ${user.minionName} finished uncharging ${amnt} Amulets of glory (6).`;

await transactItems({
userID: user.id,
collectionLog: false,
itemsToAdd: loot
});
handleTripFinish(user, channelID, str, undefined, data, loot);
}
};
Loading