Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
feat: adding exp based on difficulty and wpm when adding a new game
Browse files Browse the repository at this point in the history
  • Loading branch information
vycdev committed Jul 16, 2020
1 parent 21fa6f0 commit d2723e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/api/src/modules/games/actions/createGame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ export const createGame = async (

await knex("users")
.where({ id: userid })
.update({ totaltests: user.totaltests + 1 });
.update({
totaltests: user.totaltests + 1,
exp: Math.floor(user.exp + (wpm * difficulty) / 10)
});

achievements.map(async l => {
await knex("users")
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/components/profilePage/profilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const ProfilePage = () => {
};

const updateLevel = () => {
setLevel(Math.sqrt(userData?.exp / 10));
setLevel(Math.floor(Math.sqrt(userData?.exp / 10) * 100) / 100);
};

const updateUserGames = async () => {
Expand Down

0 comments on commit d2723e8

Please sign in to comment.