Skip to content

Commit d1b934e

Browse files
committed
Configurable default options for matches
1 parent e73897a commit d1b934e

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ A preview of major changes can be found in the Wiki ([Latest Changes](https://gi
1616
- Holding score buttons to score same dart three times
1717
- Support `Max Rounds` to play for `x01`
1818
- Added option to configure `players` on match presets
19+
- Configurable default options for starting matches
1920
- Lots of new Badges
2021

2122
#### Changed

routes/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ router.get('/', function (req, res, next) {
2222
axios.get(`${req.app.locals.kcapp.api}/venue`),
2323
axios.get(`${req.app.locals.kcapp.api}/office`),
2424
axios.get(`${req.app.locals.kcapp.api}/preset`),
25-
]).then(axios.spread((players, matchModes, oweTypes, matchTypes, outshots, venues, offices, presets) => {
25+
axios.get(`${req.app.locals.kcapp.api}/option/default`),
26+
]).then(axios.spread((players, matchModes, oweTypes, matchTypes, outshots, venues, offices, presets, defaults) => {
2627
res.marko(indexTemplate, {
2728
players: _.sortBy(players.data, (player) => player.name),
2829
modes: matchModes.data,
@@ -36,7 +37,8 @@ router.get('/', function (req, res, next) {
3637
venues: venues.data,
3738
stakes: oweTypes.data,
3839
offices: offices.data,
39-
presets: presets.data
40+
presets: presets.data,
41+
defaults: defaults.data,
4042
});
4143
})).catch(error => {
4244
debug(`Error when getting data for / ${error}`);

src/pages/index/components/new-game-form/new-game-form.component.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ module.exports = {
1515
officeId: 0,
1616
venues: input.venues,
1717
options: {
18-
starting_score: 501,
19-
game_type: types.X01,
20-
game_mode: 1,
21-
outshot_type: types.OUTSHOT_DOUBLE,
18+
starting_score: input.defaults.starting_score || 501,
19+
game_type: input.defaults.match_type.id,
20+
game_mode: input.defaults.match_mode.id,
21+
outshot_type: input.defaults.outshot_type.id,
22+
max_rounds: input.defaults.max_rounds,
2223
stake: null,
2324
venue_id: null
2425
},

src/pages/index/components/new-game-form/new-game-form.marko

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ $ const types = require('../../../../components/scorecard/components/match_types
6565
<game-option-selector values=input.types options=state.options key="game-type" label="Type" attribute="game_type" defaultValue=state.options.game_type on-value-changed('onGameTypeChanged')/>
6666
<game-option-selector values=input.scores options=state.options key="starting-score" label="Starting Score" attribute="starting_score" defaultValue=state.options.starting_score/>
6767
<if(state.options.game_type == types.X01 || state.options.game_type == types.X01HANDICAP)>
68-
<game-option-selector values=input.outshots options=state.options key="outshot-type" label="Outshot Type" attribute="outshot_type" defaultValue=types.OUTSHOT_DOUBLE/>
69-
<game-option-selector values=state.maxRounds options=state.options key="max-rounds-x01" label="Max Rounds" attribute="max_rounds" defaultValue=-1/>
68+
<game-option-selector values=input.outshots options=state.options key="outshot-type" label="Outshot Type" attribute="outshot_type" defaultValue=state.options.outshot_type/>
69+
<game-option-selector values=state.maxRounds options=state.options key="max-rounds-x01" label="Max Rounds" attribute="max_rounds" defaultValue=state.options.max_rounds/>
7070
</if>
7171
<if(state.options.game_type == types.TIC_TAC_TOE)>
72-
<game-option-selector values=input.outshots options=state.options key="outshot-type" label="Outshot Type" attribute="outshot_type" defaultValue=types.OUTSHOT_DOUBLE/>
72+
<game-option-selector values=input.outshots options=state.options key="outshot-type" label="Outshot Type" attribute="outshot_type" defaultValue=state.options.outshot_type/>
7373
</if>
7474
<if(state.options.game_type == types.KNOCKOUT)>
7575
<game-option-selector values=input.lives options=state.options key="starting-lives" label="Starting Lives" attribute="starting_lives" defaultValue=5/>

src/pages/index/index-template.marko

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Layout from "../layout.marko"
66
outshots=input.outshots lives=input.lives points_to_win=input.points_to_win
77
max_rounds_170=input.max_rounds_170
88
max_rounds_x01=input.max_rounds_x01
9-
venues=input.venues stakes=input.stakes offices=input.offices presets=input.presets/>
9+
venues=input.venues stakes=input.stakes offices=input.offices presets=input.presets
10+
defaults=input.defaults />
1011
</@body>
1112
</>

0 commit comments

Comments
 (0)