Cleanup resetting cut state

This commit is contained in:
Lee 2022-12-11 08:31:25 +00:00
parent fa8dc92aa2
commit fc6d2732b0
No known key found for this signature in database
GPG Key ID: 6EA25896ECCB3121

@ -9,6 +9,9 @@ const ip = useSettingsStore.getState().socketAddr || "localhost";
const updatePlayerData = usePlayerDataStore.getState().updatePlayerData; const updatePlayerData = usePlayerDataStore.getState().updatePlayerData;
let cutData: any = []; let cutData: any = [];
resetCutState();
function resetCutState() {
cutData.saberA = { cutData.saberA = {
count: [0, 0, 0], count: [0, 0, 0],
totalScore: [0, 0, 0], totalScore: [0, 0, 0],
@ -17,6 +20,7 @@ cutData.saberB = {
count: [0, 0, 0], count: [0, 0, 0],
totalScore: [0, 0, 0], totalScore: [0, 0, 0],
}; };
}
export function connectClient(attempt: number = 1) { export function connectClient(attempt: number = 1) {
const client = new W3CWebSocket(`ws://${ip}:6557/socket`); const client = new W3CWebSocket(`ws://${ip}:6557/socket`);
@ -70,14 +74,7 @@ const handlers: any = {
length, length,
} = data.status.beatmap; } = data.status.beatmap;
state.reset(); state.reset();
cutData.saberA = { resetCutState();
count: [0, 0, 0],
totalScore: [0, 0, 0],
};
cutData.saberB = {
count: [0, 0, 0],
totalScore: [0, 0, 0],
};
state.setInSong(true); state.setInSong(true);
state.setCombo(data.status.performance.combo); state.setCombo(data.status.performance.combo);
useDataStore.setState({ loadedDuringSong: true }); useDataStore.setState({ loadedDuringSong: true });
@ -183,14 +180,7 @@ const handlers: any = {
finished: () => { finished: () => {
const state = useSongDataStore.getState(); const state = useSongDataStore.getState();
state.reset(); state.reset();
cutData.saberA = { resetCutState();
count: [0, 0, 0],
totalScore: [0, 0, 0],
};
cutData.saberB = {
count: [0, 0, 0],
totalScore: [0, 0, 0],
};
state.setInSong(false); state.setInSong(false);
updatePlayerData(); updatePlayerData();
useDataStore.setState({ loadedDuringSong: false }); useDataStore.setState({ loadedDuringSong: false });
@ -198,14 +188,7 @@ const handlers: any = {
menu: () => { menu: () => {
const state = useSongDataStore.getState(); const state = useSongDataStore.getState();
state.reset(); state.reset();
cutData.saberA = { resetCutState();
count: [0, 0, 0],
totalScore: [0, 0, 0],
};
cutData.saberB = {
count: [0, 0, 0],
totalScore: [0, 0, 0],
};
state.setInSong(false); state.setInSong(false);
updatePlayerData(); updatePlayerData();
useDataStore.setState({ loadedDuringSong: false }); useDataStore.setState({ loadedDuringSong: false });