Skip to content

Commit

Permalink
feat: timeline sync once
Browse files Browse the repository at this point in the history
  • Loading branch information
Souma-Sumire committed Mar 18, 2024
1 parent 75124dc commit db6cd1f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
9 changes: 7 additions & 2 deletions src/pages/timeline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,18 @@ function handleLogEvent(e: { detail: { logs: string[] } }) {
const timelineSync = syncLines.value.find((item) => {
// console.log(item.sync, log);
return (
item.sync!.test(log) &&
item.sync &&
((item.syncOnce && !item.syncAlready) || !item.syncOnce) &&
item.sync.test(log) &&
runtimeTimeSeconds.value >= item.time - item.windowBefore &&
runtimeTimeSeconds.value <= item.time + Number(item.windowAfter)
);
});
//如果匹配sync则同步到time,有jump则同步至jump
if (timelineSync) syncTimeline(timelineSync.jump || timelineSync.time);
if (timelineSync) {
timelineSync.syncAlready = true;
syncTimeline(timelineSync.jump || timelineSync.time);
}
}
if (/^.{14} ChatLog 00:0038::/.test(log)) {
//echo
Expand Down
5 changes: 4 additions & 1 deletion src/store/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ export async function parseTimeline(
for (let i = 0; i < matchs.length; i++) {
const match = matchs[i];
const jump = match[0].match(/(?<=jump ?)[-:\d.]+/)?.[0];
const sync = match[0].match(/(?<=sync ?\/).+(?=\/)/)?.[0];
const sync = match[0].match(/(?<=sync(?:\.once)? ?\/).+(?=\/)/)?.[0];
const syncOnce = /sync\.once/.test(match[0]);
const windowBefore = match[0].match(/(?<=window ?)[-:\d.]+/)?.[0];
const windowAfter = match[0].match(
/(?<=window ?[-:\d.]+,)[-:\d.]+/,
Expand All @@ -228,6 +229,8 @@ export async function parseTimeline(
action: match.groups?.action || "",
alertAlready: false,
sync: sync ? new RegExp(sync) : undefined,
syncOnce: syncOnce,
syncAlready: false,
show: !sync,
windowBefore: Number.parseFloat(windowBefore || windowAfter || "2.5"),
windowAfter: Number.parseFloat(windowAfter || windowBefore || "2.5"),
Expand Down
1 change: 1 addition & 0 deletions src/types/fflogs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export type FFlogsStance = {
sourceIsFriendly: boolean;
url: string;
window?: Array<number>;
syncOnce?:boolean;
}[];

export type FFlogsQuery = {
Expand Down
4 changes: 3 additions & 1 deletion src/types/timeline.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Job } from "cactbot/types/job";
import type { Job } from "cactbot/types/job";

export interface ITimeline {
name: string;
Expand All @@ -17,6 +17,8 @@ export interface ITimelineLine {
time: number;
action: string;
sync?: RegExp;
syncOnce?:boolean;
syncAlready?:boolean;
show: boolean;
windowBefore: number;
windowAfter: number;
Expand Down
28 changes: 18 additions & 10 deletions src/utils/timelineSpecialRules.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { FFlogsStance, FFlogsType } from "../types/fflogs";
import type { FFlogsStance, FFlogsType } from "../types/fflogs";

const windowAction: Map<number, { type: FFlogsType; window: [number, number] }> = new Map();
const windowAction: Map<
number,
{ type: FFlogsType; window: [number, number]; once?: boolean }
> = new Map();
windowAction.set(26155, { type: "cast", window: [999, 999] }); //海德林转场 众生离绝
windowAction.set(28027, { type: "cast", window: [999, 999] }); //佐迪亚克转场 悼念
windowAction.set(26340, { type: "cast", window: [999, 999] }); //P3S转场 黑暗不死鸟
Expand Down Expand Up @@ -35,23 +38,28 @@ windowAction.set(31624, { type: "begincast", window: [30, 30] }); //绝欧米茄
windowAction.set(31649, { type: "begincast", window: [30, 30] }); //绝欧米茄 宇宙记忆

// 绝亚未实测
windowAction.set(0x49b0, { type: "cast", window: [10, 2.5] }); // 流体摆动
windowAction.set(0x4830, { type: "cast", window: [200, 60] }); // 鹰式破坏炮
windowAction.set(0x4854, { type: "cast", window: [250, 65] }); // 正义飞踢
windowAction.set(0x485a, { type: "begincast", window: [500, 500] }); // 时间停止
windowAction.set(0x4878, { type: "begincast", window: [67, 67] }); // 神圣审判
windowAction.set(0x4879, { type: "cast", window: [67, 67] }); // 神圣审判
windowAction.set(0x4a8b, { type: "cast", window: [900, 0] }); // unknown
windowAction.set(0x49b0, { type: "cast", window: [10, 2.5], once: true }); // 流体摆动
windowAction.set(0x4830, { type: "cast", window: [200, 60], once: true }); // 鹰式破坏炮
windowAction.set(0x4854, { type: "cast", window: [250, 65], once: true }); // 正义飞踢
windowAction.set(0x485a, { type: "begincast", window: [500, 500], once: true }); // 时间停止
windowAction.set(0x4878, { type: "begincast", window: [67, 67], once: true }); // 神圣审判
windowAction.set(0x4879, { type: "cast", window: [67, 67], once: true }); // 神圣审判
windowAction.set(0x4a8b, { type: "cast", window: [900, 0], once: true }); // unknown

export function factory(events: FFlogsStance): FFlogsStance {
const statistics = new Map<number, number>();
events.filter((e) => e.type === "begincast").map((e) => statistics.set(e.actionId, (statistics.get(e.actionId) ?? 0) + 1)); // 统计每一个ability出现的次数
events
.filter((e) => e.type === "begincast")
.map((e) =>
statistics.set(e.actionId, (statistics.get(e.actionId) ?? 0) + 1),
); // 统计每一个ability出现的次数
for (const event of events) {
if (statistics.get(event.actionId) === 1 && event.type === "begincast") {
event.window = [12, 12]; // 为独一无二的能力赋予window,不能太长了,否则双轴boss会出问题。
}
const w = windowAction.get(event.actionId);
if (w?.type === event.type) event.window = w?.window;
event.syncOnce = Boolean(w?.once);
}
return events;
}

0 comments on commit db6cd1f

Please sign in to comment.