Skip to content

Commit

Permalink
Merge pull request #146 from BaptisteLongy/chaos-dungeon-under-1640
Browse files Browse the repository at this point in the history
Only 1 Chaos Dungeon under 1640
  • Loading branch information
fayaine authored Dec 19, 2024
2 parents fc2ac7a + 9279b2e commit 4860283
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 30 deletions.
5 changes: 3 additions & 2 deletions apps/client/src/app/core/database/services/energy.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ export class EnergyService extends FirestoreStorage<Energy> {
}

public getEnergyUpdate(reset: number, completionEntry: CompletionEntry, energy: Energy, task: LostarkTask, entry: { amount: number }): { amount: number } {
const energyPerEntry = task.label === 'Chaos Dungeon' ? 20 : 10
const daysWithoutDoingTheTask = Math.ceil((reset - completionEntry.updated) / 86400000);
const daysWithoutEnergyUpdate = Math.ceil((reset - energy.updated) / 86400000);
const firstTaskUpdateSinceLastDone = daysWithoutDoingTheTask === daysWithoutEnergyUpdate;
const baseBonus = firstTaskUpdateSinceLastDone ? (task.amount - completionEntry.amount) * 10 : 0;
const timeBonus = (daysWithoutEnergyUpdate - (firstTaskUpdateSinceLastDone ? 1 : 0)) * task.amount * 10;
const baseBonus = firstTaskUpdateSinceLastDone ? (task.amount - completionEntry.amount) * energyPerEntry : 0;
const timeBonus = (daysWithoutEnergyUpdate - (firstTaskUpdateSinceLastDone ? 1 : 0)) * task.amount * energyPerEntry;
entry.amount = Math.min(entry.amount + timeBonus + baseBonus, task.label === 'Chaos Dungeon' ? 200 : 100);
return entry;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/app/core/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TaskScope } from "../model/task-scope";

export const tasks = [
// Daily character
createTask("Chaos Dungeon", 302, TaskFrequency.DAILY, TaskScope.CHARACTER, 2, 9999, "chaos-dungeon.webp", {
createTask("Chaos Dungeon", 302, TaskFrequency.DAILY, TaskScope.CHARACTER, 1, 9999, "chaos-dungeon.webp", {
partySize: 4
}),
createTask("Guardian", 302, TaskFrequency.DAILY, TaskScope.CHARACTER, 1, 9999, "guardian.png", {
Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/app/model/lostark-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TaskFrequency } from "./task-frequency";
import { TaskScope } from "./task-scope";
import { DataModel } from "../core/database/data-model";

export const TASKS_VERSION = 53;
export const TASKS_VERSION = 54;

export interface LostarkTask extends DataModel {
authorId?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@
nzType="primary"
[disabled]="col >= row.task.amount"
(click)="markAsDone(completion, energy, roster[i], row.task, roster, true, display.dailyReset, display.weeklyReset, display.biWeeklyReset, $event)">
{{roster[i].ilvl >= 1640 && row.chaosDungeon ? col/2 : col}}
/
{{roster[i].ilvl >= 1640 && row.chaosDungeon ? 1 : row.task.amount}}
{{col}} / {{row.task.amount}}
</button>
</div>
<div *ngIf="col > 0" class="reset-button">
Expand All @@ -193,30 +191,20 @@
</button>
</div>
<div class="energy-bar"
*ngIf="row.energy[i].amount && row.task.frequency === TaskFrequency.DAILY && row.hasEnergy && row.chaosDungeon"
*ngIf="row.energy[i].amount && row.task.frequency === TaskFrequency.DAILY && row.hasEnergy"
nz-tooltip
nzTooltipTitle="Rest bonus: {{row.energy[i].amount}}">
<div class="threshold t-10" *ngIf="roster[i].ilvl < 1640"></div>
<div class="threshold t-20"></div>
<div class="threshold t-30" *ngIf="roster[i].ilvl < 1640"></div>
<div class="threshold t-40"></div>
<div class="threshold t-50" *ngIf="roster[i].ilvl < 1640"></div>
<div class="threshold t-60"></div>
<div class="threshold t-70" *ngIf="roster[i].ilvl < 1640"></div>
<div class="threshold t-80"></div>
<div class="threshold t-90" *ngIf="roster[i].ilvl < 1640"></div>
<div class="progress progress-chaos-{{row.energy[i].amount}}" style="width:{{row.energy[i].amount/2}}%"
<div class="progress progress-chaos-{{row.energy[i].amount}}"
*ngIf="row.chaosDungeon"
style="width:{{row.energy[i].amount/2}}%"
></div>
</div>
<div class="energy-bar"
*ngIf="row.energy[i].amount && row.task.frequency === TaskFrequency.DAILY && row.hasEnergy && !row.chaosDungeon"
nz-tooltip
nzTooltipTitle="Rest bonus: {{row.energy[i].amount}}">
<div class="threshold t-20"></div>
<div class="threshold t-40"></div>
<div class="threshold t-60"></div>
<div class="threshold t-80"></div>
<div class="progress progress-{{row.energy[i].amount}}" [style.width.%]="row.energy[i].amount"></div>
<div class="progress progress-{{row.energy[i].amount}}"
*ngIf="!row.chaosDungeon"
[style.width.%]="row.energy[i].amount"></div>
</div>
</div>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,20 +305,18 @@ export class ChecklistComponent {
if (existingEntry?.updated < reset) {
existingEntry.amount = 0;
}
let newCompletionAmount = setAllDone ? task.amount : (existingEntry?.amount || 0) + 1
if (task.label === 'Chaos Dungeon' && character.ilvl >= 1640) {
newCompletionAmount = 2
}

setCompletionEntry(completion.data, character, task, {
...(existingEntry || {}),
amount: newCompletionAmount,
amount: setAllDone ? task.amount : (existingEntry?.amount || 0) + 1,
updated: Date.now()
});

if (task.scope === TaskScope.CHARACTER
&& task.frequency === TaskFrequency.DAILY
&& ['Chaos', 'Guardian', 'Una'].some(n => task.label?.startsWith(n))) {
const energyEntry = getCompletionEntry(energy.data, character, task) || { amount: 0 };
if (task.label === 'Chaos Dungeon' && character.ilvl >= 1640) {
if (task.label === 'Chaos Dungeon') {
if (energyEntry.amount >= 40) {
energyEntry.amount = Math.max(energyEntry.amount - (20 * (setAllDone ? task.amount : 2)), 0);
this.energyService.updateOne(energy.$key, {
Expand Down

0 comments on commit 4860283

Please sign in to comment.