Skip to content

Commit

Permalink
Merge pull request #42 from VocalFan/main
Browse files Browse the repository at this point in the history
Fix up some note stuff
  • Loading branch information
FluffyOMC authored May 24, 2024
2 parents 2bc1bde + f14f788 commit ecf524b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
20 changes: 7 additions & 13 deletions psychtobase/src/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,25 @@ def timeChange(timeStamp:float, bpm:float, timeSignatureNum:int, timeSignatureDe
"bt": beatTuplets
}

def note(time:str, data:int, length:float) -> dict:
def note(data:int, length:float, time:str) -> dict:
"""
Function created for faster creation of note data.
"""
return {
"t": time,
"d": data,
"l": length
}
if length == 0:
return {"d": data, "t": time} # This is how the base game charts handle it so...
return {"d": data, "l": length, "t": time}

def event(time:float, event:str, values:dict) -> dict:
def event(event:str, time:float, values:dict) -> dict:
"""
Function created for faster creation of events.
"""
return {
"t": time,
"e": event,
"v": values
}
return {"e": event, "t": time, "v": values}

def focusCamera(time:float, char:bool):
"""
Function created for faster creation of camera change events.
"""
return event(time, "FocusCamera", {"char": "0" if char else "1"})
return event("FocusCamera", time, {"char": "0" if char else "1"})

def coolText(text:str) -> str:
length = max(30, len(text) + 5)
Expand Down
14 changes: 13 additions & 1 deletion psychtobase/src/tools/ChartTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ def convert(self):
notes = self.chart["notes"][diff]
steps = 0

prev_notes = set()

for section in cChart.get("notes"):
mustHit = section.get("mustHitSection", True)
isDuet = False
Expand All @@ -143,7 +145,17 @@ def convert(self):
if not isDuet and noteData < 4:
isDuet = True

notes.append(Utils.note(strumTime, noteData, length))
# Backhands any dupe notes as Psych engine handles this in PlayState, base game doesn't
is_duplicate = any(
abs(existing_note[0] - strumTime) < 1 and existing_note[1] == noteData
for existing_note in prev_notes
)

if is_duplicate:
continue
prev_notes.add((strumTime, noteData))

notes.append(Utils.note(noteData, length, strumTime))

if firstChart:
lengthInSteps = section.get("lengthInSteps", section.get("sectionBeats", 4) * 4)
Expand Down

0 comments on commit ecf524b

Please sign in to comment.