-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from HoseaCodes/feat/gamePage
feat(*): add game console
- Loading branch information
Showing
389 changed files
with
20,021 additions
and
1,267 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
node_modules | ||
npm-debug.log | ||
yarn-error.log | ||
.DS_Store | ||
.git | ||
.gitignore | ||
*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: GitHub Actions Demo | ||
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 | ||
on: [push] | ||
jobs: | ||
Explore-GitHub-Actions: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." | ||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" | ||
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." | ||
- name: Check out repository code | ||
uses: actions/checkout@v3 | ||
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." | ||
- run: echo "🖥️ The workflow is now ready to test your code on the runner." | ||
- name: List files in the repository | ||
run: | | ||
ls ${{ github.workspace }} | ||
- run: echo "🍏 This job's status is ${{ job.status }}." | ||
# - uses: AppThreat/sast-scan-action@master | ||
# with: | ||
# type: "python" | ||
|
||
# - uses: actions/upload-artifact@v1 | ||
# with: | ||
# name: reports | ||
# path: reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,8 @@ src/.eslintrc.js | |
|
||
test/coverage | ||
|
||
animation | ||
animation | ||
|
||
dump | ||
|
||
output.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import Payments from "../models/player"; | ||
import Users from "../models/user.js"; | ||
|
||
|
||
async function getPlayers(req, res) { | ||
try { | ||
const players = await Player.find(); | ||
res.json(players); | ||
} catch (err) { | ||
return res.status(500).json({ msg: err.message }); | ||
} | ||
} | ||
|
||
async function getbadges(req, res) { | ||
try { | ||
const players = await Player.find({username: req.params.username}); | ||
res.json(players.badges); | ||
} catch (err) { | ||
return res.status(500).json({ msg: err.message }); | ||
} | ||
} | ||
|
||
async function createPlayer(req, res) { | ||
try { | ||
const user = await Users.findById(req.user.id); | ||
if (!user) return res.status(400).json({ msg: "User does not exist" }); | ||
|
||
let { username, paymentID } = req.body; | ||
|
||
const { _id, name, email } = user; | ||
|
||
const newPlayer = new Player({ | ||
user_id: _id, | ||
name: name, | ||
email: email, | ||
username: username, | ||
paymentID: paymentID, | ||
rank: 0, | ||
reputation: 0, | ||
badges: { | ||
name: "New User", | ||
points: 10 | ||
} | ||
}); | ||
|
||
await newPlayer.save(); | ||
res.json({ msg: "Player created successfully" }); | ||
} catch (err) { | ||
return res.status(500).json({ msg: err.message }); | ||
} | ||
} | ||
|
||
async function createbadge(req, res) { | ||
try { | ||
const { badge } = req.body; | ||
|
||
const player = await Player.findOneAndUpdate({ _id: req.params.id }, { | ||
badges: badge | ||
}) | ||
|
||
if (!player) return res.status(400).json({ msg: "Plater does not exist" }); | ||
|
||
|
||
res.json({ msg: "Badge assigned successfully" }); | ||
} catch (err) { | ||
return res.status(500).json({ msg: err.message }); | ||
} | ||
} | ||
|
||
async function deletePlayer(req, res) { | ||
try { | ||
|
||
await Player.findByIdAndDelete(req.params.id) | ||
|
||
logger.info(`Deleted player ${req.params.id} has been deleted`); | ||
|
||
res.json({ msg: `Deleted player: ${req.params.id}` }) | ||
} catch (err) { | ||
|
||
logger.error(err) | ||
|
||
return res.status(500).json({ msg: err.message }) | ||
} | ||
} | ||
|
||
async function updatePlayer(req, res) { | ||
try { | ||
const { rank, username, reputation, paymentID, badges } = req.body; | ||
|
||
const originalBody = req.body | ||
|
||
await Player.findOneAndUpdate({ _id: req.params.id }, { | ||
rank, username, reputation, paymentID, badges | ||
}) | ||
|
||
const preparedLog = `Changing the following: ${originalBody} to ${req.body} for the player ${username}`; | ||
|
||
logger.info(preparedLog); | ||
|
||
res.json({ msg: `Updated player ${username}` }) | ||
} catch (err) { | ||
|
||
logger.error(err); | ||
|
||
return res.status(500).json({ msg: err.message }); | ||
} | ||
} | ||
|
||
|
||
|
||
export { | ||
createPlayer, | ||
createbadge, | ||
getPlayers, | ||
getbadges, | ||
deletePlayer, | ||
updatePlayer | ||
}; |
Oops, something went wrong.