Skip to content

Commit

Permalink
Last refactor I swear
Browse files Browse the repository at this point in the history
  • Loading branch information
apache1123 committed Mar 27, 2024
1 parent 70ed18a commit ce67b25
Show file tree
Hide file tree
Showing 45 changed files with 1,118 additions and 976 deletions.
56 changes: 29 additions & 27 deletions src/features/combat-simulator/CombatSimulatorTimeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Loadout } from '../../models/loadout';
import { Team } from '../../models/team';
import { CombatSimulator } from '../../models/v4/combat-simulator';
import { Relics } from '../../models/v4/relics';
import type { TimelineEvent } from '../../models/v4/timelines/timeline-event';
import type { TimelineEvent } from '../../models/v4/timeline/timeline-event';
import { Weapon } from '../../models/weapon';
import { AttackBuffEventRenderer } from './AttackBuffEventRenderer';
import { AttackEventRenderer } from './AttackEventRenderer';
Expand Down Expand Up @@ -101,39 +101,41 @@ export function CombatSimulatorTimeline() {

const editorData: CombatSimulatorTimelineRow[] = [];

for (const [weapon, attackTimeline] of combatSimulatorSnap.attackTimelines) {
for (const [weapon, weaponAttackController] of combatSimulatorSnap
.teamAttackController.weaponAttackControllers) {
editorData.push({
id: weapon.definition.id,
displayName: weapon.definition.displayName,
actions: attackTimeline.events.map<CombatSimulatorTimelineAction>(
(attackEvent, index) => ({
id: `${weapon.definition.id}-attack-${index}`,
start: attackEvent.startTime,
end: attackEvent.endTime,
effectId: 'attack-event',
event: attackEvent,
})
),
actions:
weaponAttackController.combinedAttackTimeline.attacks.map<CombatSimulatorTimelineAction>(
(attackEvent, index) => ({
id: `${weapon.definition.id}-attack-${index}`,
start: attackEvent.startTime,
end: attackEvent.endTime,
effectId: 'attack-event',
event: attackEvent,
})
),
classNames: [styles.timelineRow],
});
}

for (const effectGroup of combatSimulatorSnap.effectPool.allEffectGroups) {
for (const { id, displayName, timeline } of effectGroup.items.values()) {
editorData.push({
id,
displayName,
actions: timeline.events.map<CombatSimulatorTimelineAction>(
(effectEvent, index) => ({
id: `${id}-${index}`,
start: effectEvent.startTime,
end: effectEvent.endTime,
effectId: 'effect-event',
event: effectEvent,
})
),
});
}
for (const effectController of combatSimulatorSnap.effectControllerContext
.allEffectControllers) {
const { id, displayName, timeline } = effectController;
editorData.push({
id,
displayName,
actions: timeline.effects.map<CombatSimulatorTimelineAction>(
(effectEvent, index) => ({
id: `${id}-${index}`,
start: effectEvent.startTime,
end: effectEvent.endTime,
effectId: 'effect-event',
event: effectEvent,
})
),
});
}

return (
Expand Down
86 changes: 41 additions & 45 deletions src/models/v4/__tests__/__snapshots__/combat-simulator.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`CombatSimulator available attacks includes attacks from all weapons at the start of combat 1`] = `
exports[`CombatSimulator next available attacks includes attacks from all weapons at the start of combat 1`] = `
[
{
"attackDefinition": {
Expand Down Expand Up @@ -932,58 +932,54 @@ exports[`CombatSimulator available attacks includes attacks from all weapons at
]
`;

exports[`CombatSimulator relic damage buff is added at the start of combat and lasts for the entire combat duration 1`] = `
exports[`CombatSimulator relic passive damage buff is added at the start of combat and lasts for the entire combat duration 1`] = `
[
EffectTimeline {
"_events": [
EffectEvent {
"cooldown": 0,
"displayName": "Alternative Destiny passive damage buff",
"duration": 150000,
"maxStacks": 1,
"stacks": 1,
"startTime": 0,
},
],
"totalDuration": 150000,
},
EffectTimeline {
"_events": [
EffectEvent {
"cooldown": 0,
"displayName": "Cybernetic arm passive damage buff",
"duration": 150000,
"maxStacks": 1,
"stacks": 1,
"startTime": 0,
},
],
"timeline": Timeline {
"_events": [
Effect {
"cooldown": 0,
"displayName": "Alternative Destiny passive damage buff",
"duration": 150000,
"maxStacks": 1,
"stacks": 1,
"startTime": 0,
},
],
"totalDuration": 150000,
},
"totalDuration": 150000,
},
EffectTimeline {
"_events": [
EffectEvent {
"cooldown": 0,
"displayName": "Thalassic Heart passive damage buff",
"duration": 150000,
"maxStacks": 1,
"stacks": 1,
"startTime": 0,
},
],
"timeline": Timeline {
"_events": [
Effect {
"cooldown": 0,
"displayName": "Cybernetic arm passive damage buff",
"duration": 150000,
"maxStacks": 1,
"stacks": 1,
"startTime": 0,
},
],
"totalDuration": 150000,
},
"totalDuration": 150000,
},
EffectTimeline {
"_events": [
EffectEvent {
"cooldown": 0,
"displayName": "Triple Mask damage buff",
"duration": 150000,
"maxStacks": 1,
"stacks": 1,
"startTime": 0,
},
],
"timeline": Timeline {
"_events": [
Effect {
"cooldown": 0,
"displayName": "Thalassic Heart passive damage buff",
"duration": 150000,
"maxStacks": 1,
"stacks": 1,
"startTime": 0,
},
],
"totalDuration": 150000,
},
"totalDuration": 150000,
},
]
Expand Down
Loading

0 comments on commit ce67b25

Please sign in to comment.