diff --git a/Backend/generic-food.js b/Backend/generic-food.js index 4116749..67b0b1d 100644 --- a/Backend/generic-food.js +++ b/Backend/generic-food.js @@ -255,6 +255,12 @@ var filteredWords = [ "Clam", "Squid", "Shrimp", +"Onigiri", +"Alan Wang", +"Keke", +"Software Engineering", +"Cat Corp the Cat", +"Microplastics", "Crayfish", "Flatfish", "Piglet", diff --git a/Backend/user.js b/Backend/user.js index 8aaa8db..e66caea 100644 --- a/Backend/user.js +++ b/Backend/user.js @@ -13,7 +13,7 @@ export async function checkUsernameAvailable(username) { // This function does NOT do any checks for unique usernames, etc. export async function registerAccount(username, password) { const hashedPassword = await bcrypt.hash(password, 10); - const user = await getUserDB().insertOne({ "username": username, "password": hashedPassword, "lastLogin": Date.now(), "gems": 0, "cats": [] }) + const user = await getUserDB().insertOne({ "username": username, "password": hashedPassword, "lastLogin": Date.now(), "gems": 0, "cats": [], "streak": 0 }) return user.insertedId } @@ -109,6 +109,11 @@ export async function getCanvasUserId(session) { } export async function cashSubmissions(session, courses) { + let streakMult = await getUserProperty(session, "streak"); + if (isNaN(streakMult)) { + await setUserProperty(session, "streak", 0) + streakMult = 0; + } var sum = 0 courses.forEach((course, i) => { var temp = course[3]; @@ -137,15 +142,16 @@ export async function cashSubmissions(session, courses) { const frac = (due - sub) / (due - unlock); multiplier *= Math.min(Math.max((Math.cbrt(frac) + .5), .000000001), 1.5); } + + multiplier *= (1 + streakMult/20); // submission.push(Math.ceil(multiplier * 100)) this works too??? sum += Math.ceil(multiplier * 100); courses[i][3][j].push(Math.ceil(multiplier * 100)) }) }) - - - const results = await updateClasses(session, courses) + + const results = await updateClasses(session, courses); await incrementUserProperty(session, "gems", sum); await updateLastLogin(session); return [courses, sum, results[0], results[1]]; @@ -241,11 +247,21 @@ async function updateClasses(session, courses) { } } - effects.push(effect) + if (effect.result !== undefined) { + effects.push(effect) + } bosses.push([data.courseName, data.courseId, data.users]); } })) + if (effects.length > 0) { + const wonAll = effects.every(effect => effect.result === "win") + if (wonAll) { + await incrementUserProperty(session, "streak", 1) + } else if (effects.some(e => e.result === "lose")) { + await setUserProperty(session, "streak", 0) + } + } return [effects, bosses] } diff --git a/Frontend/src/Home.jsx b/Frontend/src/Home.jsx index deb74b3..4d3c190 100644 --- a/Frontend/src/Home.jsx +++ b/Frontend/src/Home.jsx @@ -42,7 +42,7 @@ function Home({ userData, setUserData, courses, setCourses, bossData, overlay, s