From f700daeb258227791f6127e038009a5debe1b061 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Wed, 29 May 2019 03:24:43 +1000 Subject: [PATCH] Wrote an update --- public/news/2019-05-22-01.md | 1 + public/news/2019-05-24-01.md | 3 ++- public/news/2019-05-26-01.md | 1 + public/news/2019-05-27-01.md | 3 ++- public/news/2019-05-29-01.md | 20 ++++++++++++++++++++ server/combat.js | 14 ++++++++++++++ server/index.js | 4 +++- server/profiles.js | 6 ------ 8 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 public/news/2019-05-29-01.md create mode 100644 server/combat.js diff --git a/public/news/2019-05-22-01.md b/public/news/2019-05-22-01.md index e4bf5b0..bdcedd8 100644 --- a/public/news/2019-05-22-01.md +++ b/public/news/2019-05-22-01.md @@ -15,3 +15,4 @@ Check back often for more information! In the mean time, here are my social medi * https://discord.gg/FQmz8TN * https://www.patreon.com/krgamestudios * https://github.com/KRGameStudios + diff --git a/public/news/2019-05-24-01.md b/public/news/2019-05-24-01.md index ae7761f..a4ffe6f 100644 --- a/public/news/2019-05-24-01.md +++ b/public/news/2019-05-24-01.md @@ -8,4 +8,5 @@ I've also implemented a logging system, so that if any errors occur, I'll be abl Finally, I've also fixed the email bug - before, it could take over a minute for the verification email to arrive. Now it should arrive instantly. Interestingly, that wasn't a problem with my code, but rather how the server was configured. I'll have to keep that in mind if I ever migrate this project. -OK, I'll keep working, since it's still early in the day. \ No newline at end of file +OK, I'll keep working, since it's still early in the day. + diff --git a/public/news/2019-05-26-01.md b/public/news/2019-05-26-01.md index 4617d1a..2ae4b49 100644 --- a/public/news/2019-05-26-01.md +++ b/public/news/2019-05-26-01.md @@ -5,3 +5,4 @@ _26 May 2019_ I keep wanting to start working on the combat, but I keep getting feedback about the site as a whole. I'm happy to receive it, of course, it just means I'll have to work even harder! I've removed the forms to the right, and moved them into their own pages. This should make it cleaner to signup and login. I've also added a blurb to the main page, and tweaked the styling so it's not simply a wall of text. Hopefully, it looks better - I really can't tell, since I'm too close to the project. + diff --git a/public/news/2019-05-27-01.md b/public/news/2019-05-27-01.md index 7f18cec..d6b9d3f 100644 --- a/public/news/2019-05-27-01.md +++ b/public/news/2019-05-27-01.md @@ -6,4 +6,5 @@ I neglect my sleeping pattern... I'm testing code minimization and code splitting to deal with the slow load times reported by multiple people. The main cause is that this website is hosted in Australia, but I'm trying to minimize the impact with various techniques before progressing. -I didn't want to spend the night on something incredibly demanding like the attack button, so instead I spent the night on something incredibly demanding like optimisation. -_- \ No newline at end of file +I didn't want to spend the night on something incredibly demanding like the attack button, so instead I spent the night on something incredibly demanding like optimisation. -_- + diff --git a/public/news/2019-05-29-01.md b/public/news/2019-05-29-01.md new file mode 100644 index 0000000..c9168d2 --- /dev/null +++ b/public/news/2019-05-29-01.md @@ -0,0 +1,20 @@ +Button, Button, Who's Got The Button? +--- +_29 May 2019_ + +OK, the attack button is now visible on other people's profiles. This isn't active yet because I've only been working on the client code - next up is the server and game code. + +The plan is this: + +* You can attack another player using your soldiers (it doesn't work without soldiers). +* Doing so takes time, up to 10 seconds for every soldier you have. +* Combat takes place at the end of the time delay, at which point you can attack people again (after reloading the page). +* While attacking, you are undefended. +* While undefended, your recruits act as combatants, otherwise your soldiers do. +* The chance of success is determined by the ratio of each side's combatant strength. +* Recruits have a strength equal to 0.25 times that of a soldier. +* On a success, you steal 10% of the target's gold. On a failure, you steal 2% of the target's gold. +* The attacking force will lose a percentage, rounded down, of their units - 5% on a success, 10% on a failure. + +All of these numbers can be adjusted later, but this is the initial gameplan for combat. + diff --git a/server/combat.js b/server/combat.js new file mode 100644 index 0000000..f85a0c2 --- /dev/null +++ b/server/combat.js @@ -0,0 +1,14 @@ +//environment variables +require('dotenv').config(); + +//utilities +let { log } = require('../common/utilities.js'); + +const attackRequest = (connection) => (req, res) => { + res.status(400).write(log('Not yet implemented')); + res.end(); +} + +module.exports = { + attackRequest: attackRequest +} \ No newline at end of file diff --git a/server/index.js b/server/index.js index d8f1f24..42363de 100644 --- a/server/index.js +++ b/server/index.js @@ -38,9 +38,11 @@ app.post('/recruitrequest', profiles.recruitRequest(connection)); app.post('/trainrequest', profiles.trainRequest(connection)); app.post('/untrainrequest', profiles.untrainRequest(connection)); app.post('/ladderrequest', profiles.ladderRequest(connection)); -app.post('/attackrequest', profiles.attackRequest(connection)); profiles.runGoldTick(connection); +let combat = require('./combat.js'); +app.post('/attackrequest', combat.attackRequest(connection)); + //static directories app.use('/styles', express.static(path.resolve(__dirname + '/../public/styles')) ); app.use('/img', express.static(path.resolve(__dirname + '/../public/img')) ); diff --git a/server/profiles.js b/server/profiles.js index 013078e..8ba6dba 100644 --- a/server/profiles.js +++ b/server/profiles.js @@ -366,11 +366,6 @@ const ladderRequest = (connection) => (req, res) => { }); } -const attackRequest = (connection) => (req, res) => { - res.status(400).write(log('Not yet implemented')); - res.end(); -} - const runGoldTick = (connection) => { let goldTickJob = new CronJob('0 */30 * * * *', () => { let query = 'UPDATE profiles SET gold = gold + recruits;'; @@ -391,6 +386,5 @@ module.exports = { trainRequest: trainRequest, untrainRequest: untrainRequest, ladderRequest: ladderRequest, - attackRequest: attackRequest, runGoldTick: runGoldTick } \ No newline at end of file