Skip to content

Commit

Permalink
Added players to match presets
Browse files Browse the repository at this point in the history
  • Loading branch information
thordy committed Dec 1, 2024
1 parent a07ed5f commit 3e1e1ad
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ A preview of major changes can be found in the Wiki ([Latest Changes](https://gi
- Ability to configure: "Announcement Volume", "Auto Busting" and "Auto Leg Finish" from frontend
- Holding score buttons to score same dart three times
- Support `Max Rounds` to play for `x01`
- Added option to configure `players` on match presets
- Lots of new Badges

#### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ module.exports = {

let name = input.players[player.player_id].name;
if (player.player.is_bot) {
if (player.bot_config.player_id) {
if (!player.bot_config) {
name = `${name} (${skill.fromInt(skill.MEDIUM.skill).name})`;
} else if (player.bot_config.player_id) {
name = `${name} as ${input.players[player.bot_config.player_id].name}`;
} else {
name = `${name} (${skill.fromInt(player.bot_config.skill_level).name})`;
}
}

this.state = {
player: player,
name: name,
Expand Down
2 changes: 1 addition & 1 deletion src/components/scorecard-header/scorecard-header.marko
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $ const types = require("../scorecard/components/match_types");
</else-if>
<else-if(input.type == types.ONESEVENTY)>
<div class="label-player-name">
$ let dartsRemaining = 9 - state.player.darts_thrown;
$ let dartsRemaining = 9 - state.player.darts_thrown;
<if(dartsRemaining === 0)>
&nbsp;
</if>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ module.exports = {
modeComponent.state.index = preset.match_mode.id;
this.state.options.game_mode = modeComponent.state.index;

if (preset.players) {
// loop through and add each player
preset.players.forEach((playerId) => {
const player = _.find(this.input.players, (p) => {
return p.id === playerId;
});
if (player) {
this.addPlayer(null, player);
}
});
}

alertify.success(`Configured preset "${preset.name}"`);
if (this.state.selected.length > 1) {
this.newGame();
Expand Down
2 changes: 1 addition & 1 deletion src/util/socket.io-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ exports.onScoreUpdate = (data, thiz) => {
component.reset();
component.state.jdcDart = null;

isSecondLastRound = player.player_id === players[0].player_id && leg.parameters.max_rounds && leg.parameters.max_rounds === leg.round;
isSecondLastRound = leg.parameters && player.player_id === players[0].player_id && leg.parameters.max_rounds && leg.parameters.max_rounds === leg.round;
} else {
if (currentPlayerIdx <= i) {
component.state.jdcDart = null;
Expand Down

0 comments on commit 3e1e1ad

Please sign in to comment.