enefel 1.0.122 → 1.0.123
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +17 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -830,6 +830,9 @@ const isCoach = (player, team = null) => {
|
|
|
830
830
|
};
|
|
831
831
|
|
|
832
832
|
const getMoralModifier = (player) => {
|
|
833
|
+
if (player.experience == null) {
|
|
834
|
+
throw Error("empty experience player");
|
|
835
|
+
}
|
|
833
836
|
const career = getCareerFromPlayer(player);
|
|
834
837
|
let range = ranges.findIndex((range) => player.experience < range);
|
|
835
838
|
if (range === -1) {
|
|
@@ -838,6 +841,18 @@ const getMoralModifier = (player) => {
|
|
|
838
841
|
return career.cost / 10 + range;
|
|
839
842
|
};
|
|
840
843
|
|
|
844
|
+
const getTeamMoral = (team) => {
|
|
845
|
+
let moral = 0;
|
|
846
|
+
for (const player of team.players) {
|
|
847
|
+
moral += getMoralModifier(player);
|
|
848
|
+
}
|
|
849
|
+
return moral;
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
const getTeamMoralByPlayer = (team) => {
|
|
853
|
+
return Math.round(getTeamMoral(team) / team.players.length);
|
|
854
|
+
};
|
|
855
|
+
|
|
841
856
|
const getAttackerStrength = (
|
|
842
857
|
player,
|
|
843
858
|
isBlitz = false,
|
|
@@ -933,4 +948,6 @@ module.exports = {
|
|
|
933
948
|
shuffleArray,
|
|
934
949
|
arrayMove,
|
|
935
950
|
TAKE_BALL_TYPE,
|
|
951
|
+
getTeamMoralByPlayer,
|
|
952
|
+
getTeamMoral,
|
|
936
953
|
};
|