Fixed "stealable", and wrote spy instructions
This commit is contained in:
@@ -71,7 +71,9 @@ Scientists don't fight. Instead, they offer other means of gaining advantage ove
|
||||
|
||||
<div class="break" />
|
||||
|
||||
--Coming Soon--
|
||||
Spies are another way to gain an advantage over your enemies. They're more expensive than soldiers, and they might not always produce results. However, they can be used at the same time as soldiers, and they can also steal your target's equipment. Spies have a 50% chance of stealing gold, and each spy has a 50% chance of stealing an item. Since their job is harder, they take 10 minutes for each spy used.
|
||||
|
||||
Be careful though - if the spies are found, they will <span>all be killed</span>.
|
||||
|
||||
<div class="break" />
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
Major
|
||||
---
|
||||
|
||||
* Implement spies.
|
||||
* Write the instructions for spies.
|
||||
* Implement badges.
|
||||
* Write the instructions for badges.
|
||||
* Implement countdown timers for combat and training.
|
||||
|
||||
+10
-2
@@ -234,7 +234,7 @@ const spyGameplayLogic = (connection, pendingSpying) => {
|
||||
});
|
||||
} else {
|
||||
//steal this much gold on success
|
||||
let spoilsGold = Math.random() >= 0.5 ? Math.floor(results[0].gold * 0.1) : 0; //50% chance of stealing gold
|
||||
let spoilsGold = Math.random() >= 0.5 ? Math.floor(results[0].gold * 0.2) : 0; //50% chance of stealing gold
|
||||
let query = 'INSERT INTO pastSpying (eventTime, attackerId, defenderId, attackingUnits, success, spoilsGold) VALUES (?, ?, ?, ?, "success", ?);';
|
||||
connection.query(query, [pendingSpying.eventTime, pendingSpying.attackerId, pendingSpying.defenderId, pendingSpying.attackingUnits, spoilsGold], (err) => {
|
||||
if (err) throw err;
|
||||
@@ -290,6 +290,12 @@ const spyStealEquipmentInner = (connection, attackerId, defenderId, attackingUni
|
||||
connection.query(query, [defenderId], (err, results) => {
|
||||
if (err) throw err;
|
||||
|
||||
getStatistics((err, { statistics }) => {
|
||||
if (err) throw err;
|
||||
|
||||
//don't steal certain items
|
||||
results = results.filter(item => statistics[item.type][item.name].stealable);
|
||||
|
||||
//if he's not attacking, skip to the next step
|
||||
if (!attacking) {
|
||||
return spyStealEquipmentSelectItemsToSteal(connection, attackerId, defenderId, attackingUnits, results, pastSpyingId);
|
||||
@@ -337,11 +343,13 @@ const spyStealEquipmentInner = (connection, attackerId, defenderId, attackingUni
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const removeForEachSoldier = (results, soldiers, cb) => {
|
||||
getStatistics((err, { statistics }) => {
|
||||
if (err) throw err;
|
||||
|
||||
results.sort((a, b) => statistics[a.type][a.name].combatBoost < statistics[b.type][b.name].combatBoost);
|
||||
|
||||
results = results.map((item) => {
|
||||
@@ -357,7 +365,7 @@ const removeForEachSoldier = (results, soldiers, cb) => {
|
||||
return item;
|
||||
});
|
||||
|
||||
results = results.filter(item => item.quantity > 0 && statistics[item.type][item.name].stealable);
|
||||
results = results.filter(item => item.quantity > 0);
|
||||
|
||||
cb(undefined, results);
|
||||
});
|
||||
|
||||
@@ -112,7 +112,7 @@ class Equipment extends React.Component {
|
||||
}
|
||||
|
||||
//if you can't see it and you don't own it, don't render it (for legendary items)
|
||||
if (!structure.statistics[type][name].visible && !structure.owned[name]) {
|
||||
if (!structure.statistics[type][name].visible && !structure.owned[name]) { //TODO: sort out the visible mixup
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ class PagedCombatLog extends React.Component {
|
||||
if (xhr.status === 200) {
|
||||
let json = JSON.parse(xhr.responseText);
|
||||
|
||||
json.sort((a, b) => new Date(b.eventTime) - new Date(a.eventTime));
|
||||
|
||||
//on success
|
||||
this.setState(json);
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ class PagedSpyingLog extends React.Component {
|
||||
if (xhr.status === 200) {
|
||||
let json = JSON.parse(xhr.responseText);
|
||||
|
||||
json.sort((a, b) => new Date(b.eventTime) - new Date(a.eventTime));
|
||||
|
||||
//on success
|
||||
this.setState(json);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user