Skip to content

Commit

Permalink
Move clock node builders to own file
Browse files Browse the repository at this point in the history
  • Loading branch information
cwegrzyn committed Aug 17, 2024
1 parent 1e02ab5 commit 71e1c40
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/clocks/commands.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { determineCampaignContext } from "campaigns/manager";
import IronVaultPlugin from "index";
import { appendNodesToMoveOrMechanicsBlock } from "mechanics/editor";
import { createDetailsNode } from "mechanics/node-builders";
import {
createClockCreationNode,
createClockNode,
createDetailsNode,
} from "mechanics/node-builders";
} from "mechanics/node-builders/clocks";
import { Editor, MarkdownView } from "obsidian";
import { stripMarkdown } from "utils/strip-markdown";
import { ClockFileAdapter, clockUpdater } from "../clocks/clock-file";
Expand Down
32 changes: 32 additions & 0 deletions src/mechanics/node-builders/clocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Clock } from "clocks/clock";
import { ClockFileAdapter } from "clocks/clock-file";
import * as kdl from "kdljs";
import { node } from "utils/kdl";

export function createClockCreationNode(
clockName: string,
clockPath: string,
): kdl.Node {
return node("clock", {
properties: {
name: `[[${clockPath}|${clockName}]]`,
status: "added",
},
});
}

export function createClockNode(
clockName: string,
clockPath: string,
sourceClock: ClockFileAdapter,
endValue: Clock,
): kdl.Node {
return node("clock", {
properties: {
name: `[[${clockPath}|${clockName}]]`,
from: sourceClock.clock.progress,
to: endValue.progress,
"out-of": endValue.segments,
},
});
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Clock } from "clocks/clock";
import { ClockFileAdapter } from "clocks/clock-file";
import { createDataswornMarkdownLink } from "datastore/parsers/datasworn/id";
import * as kdl from "kdljs";
import { Document, Node } from "kdljs";
Expand Down Expand Up @@ -55,34 +53,6 @@ export function createTrackCompletionNode(
});
}

export function createClockCreationNode(
clockName: string,
clockPath: string,
): kdl.Node {
return node("clock", {
properties: {
name: `[[${clockPath}|${clockName}]]`,
status: "added",
},
});
}

export function createClockNode(
clockName: string,
clockPath: string,
sourceClock: ClockFileAdapter,
endValue: Clock,
): kdl.Node {
return node("clock", {
properties: {
name: `[[${clockPath}|${clockName}]]`,
from: sourceClock.clock.progress,
to: endValue.progress,
"out-of": endValue.segments,
},
});
}

export function createOracleNode(
roll: RollWrapper,
prompt?: string,
Expand Down

0 comments on commit 71e1c40

Please sign in to comment.