simfile-scripts/docs/mirror-a-charts-notes.py
2022-08-20 18:02:25 -07:00

24 lines
804 B
Python

from typing import Iterator
from simfile.types import Chart
from simfile.notes import Note, NoteData
def mirror_note(note: Note, columns: int) -> Note:
# Make a new Note with all fields the same except for column
return note._replace(
# You could replace this expression with anything you want
column=columns - note.column - 1
)
def mirror_notes(notedata: NoteData) -> Iterator[Note]:
columns = notedata.columns
for note in notedata:
yield mirror_note(note, columns)
def mirror_chart_in_place(chart: Chart) -> None:
notedata = NoteData(chart)
mirrored = NoteData.from_notes(
mirror_notes(notedata),
columns=notedata.columns,
)
# Assign str(NoteData) to Chart.notes to update the chart's notes
chart.notes = str(mirrored)