From e2480034781475d0834fe4d6f61e6bbf8479e20d Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Tue, 4 Jun 2019 11:26:19 +1000 Subject: [PATCH] Improved the instructions --- public/content/instructions.md | 12 ++++++++++++ public/content/task_list.md | 2 +- public/news/2019-06-04-01.md | 7 +++++++ src/components/panels/attack_button.jsx | 25 +++++++++++++++++-------- src/components/panels/common_links.jsx | 2 +- src/components/panels/markdown.jsx | 4 ++-- src/components/panels/spy_button.jsx | 0 webpack.config.js | 2 +- 8 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 public/news/2019-06-04-01.md create mode 100644 src/components/panels/spy_button.jsx diff --git a/public/content/instructions.md b/public/content/instructions.md index cb16f52..2acc58c 100644 --- a/public/content/instructions.md +++ b/public/content/instructions.md @@ -19,6 +19,18 @@ The goal of the game is to be at the top of the game ladder for as long as possi
+### Attacking + +
+ +The best way to gain gold in this game is to attack other players. You can do this via the [game ladder](/ladder). Click on someone's profile, and click the "attack" button as soon as you have a soldier. You'll earn gold from attacking, even if you lose the battle, so attacking high-ranked players is encouraged! + +
+ +--- + +
+ ### Recruits
diff --git a/public/content/task_list.md b/public/content/task_list.md index e4b8ea9..cad09ce 100644 --- a/public/content/task_list.md +++ b/public/content/task_list.md @@ -11,7 +11,6 @@ Major Minor --- -* Disable attack button with no soldiers. * Implement game ladder sorting. * Write unit tests (ensure that the game doesn't break from an update). @@ -32,6 +31,7 @@ Wishlist * In-game events. * Hire a graphic designer. * Implement nations (player alliances). +* In-game chat. Event Ideas --- diff --git a/public/news/2019-06-04-01.md b/public/news/2019-06-04-01.md new file mode 100644 index 0000000..0a5e8d0 --- /dev/null +++ b/public/news/2019-06-04-01.md @@ -0,0 +1,7 @@ +Today's Tasks Completed +--- +_4 June 2019_ + +* Improved the instructions. +* Disable attack button with no soldiers. +* More coming later today... \ No newline at end of file diff --git a/src/components/panels/attack_button.jsx b/src/components/panels/attack_button.jsx index c7a731a..b355be3 100644 --- a/src/components/panels/attack_button.jsx +++ b/src/components/panels/attack_button.jsx @@ -6,10 +6,12 @@ class AttackButton extends React.Component { constructor(props) { super(props); this.state = { + soldiers: 0, //NOTE: not stored in profile afterall message: '' }; - this.sendRequest('/attackstatusrequest', {attacker: this.props.attacker}); + this.sendRequest('/attackstatusrequest', {attacker: this.props.attacker}, this.attackStatus.bind(this)); + this.sendRequest('/profilerequest', {username: this.props.attacker}, this.profileData.bind(this)); } render() { @@ -20,20 +22,20 @@ class AttackButton extends React.Component { } else { //inject something extra let onClick = (e) => { - this.sendRequest('/attackrequest', {attacker: this.props.attacker, defender: this.props.defender}); + this.sendRequest('/attackrequest', {attacker: this.props.attacker, defender: this.props.defender}, this.attackStatus.bind(this)); if (this.props.onClick) { this.props.onClick(e); } }; return ( - + ); } } //gameplay functions - sendRequest(url, args = {}) { //send a unified request, using my credentials + sendRequest(url, args = {}, onSuccess) { //send a unified request, using my credentials //build the XHR let xhr = new XMLHttpRequest(); xhr.open('POST', url, true); @@ -43,10 +45,7 @@ class AttackButton extends React.Component { if (xhr.status === 200) { let json = JSON.parse(xhr.responseText); - //on success - if (json.status === 'attacking') { - this.setState({ message: `Your soldiers are attacking ${json.defender}` }); - } + onSuccess(json); } else if (xhr.status === 400 && this.props.setWarning) { this.props.setWarning(xhr.responseText); @@ -61,6 +60,16 @@ class AttackButton extends React.Component { ...args })); } + + attackStatus(json) { + if (json.status === 'attacking') { + this.setState({ message: `Your soldiers are attacking ${json.defender}` }); + } + } + + profileData(json) { + this.setState({ soldiers: json.soldiers }); + } }; AttackButton.propTypes = { diff --git a/src/components/panels/common_links.jsx b/src/components/panels/common_links.jsx index 03155eb..e9b422d 100644 --- a/src/components/panels/common_links.jsx +++ b/src/components/panels/common_links.jsx @@ -30,7 +30,7 @@ class CommonLinks extends React.Component {

Your Kingdom

Your Equipment

-

Game Ladder

+

Attack (Game Ladder)

Combat Log

Change Password

Task List

diff --git a/src/components/panels/markdown.jsx b/src/components/panels/markdown.jsx index 09729b6..399564c 100644 --- a/src/components/panels/markdown.jsx +++ b/src/components/panels/markdown.jsx @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import ReactMarkdown from 'react-markdown'; +import ReactMarkdown from 'react-markdown/with-html'; class Markdown extends React.Component { constructor(props) { @@ -20,7 +20,7 @@ class Markdown extends React.Component { render() { if (this.state) { - return (); + return (); } else { return (

Loading markdown...

); } diff --git a/src/components/panels/spy_button.jsx b/src/components/panels/spy_button.jsx new file mode 100644 index 0000000..e69de29 diff --git a/webpack.config.js b/webpack.config.js index 212c444..6b67c6c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -24,7 +24,7 @@ module.exports = { ] }, optimization: { - minimize: true, + minimize: process.env.production, minimizer: [ new TerserPlugin({ terserOptions: {