Commit a52713da authored by xiaoye's avatar xiaoye

增加轮数设置

parent a75de90a
Pipeline #37771 passed with stages
in 3 minutes and 6 seconds
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
:localdata = 'create.rule.range' :localdata = 'create.rule.range'
></uni-data-select> ></uni-data-select>
<view v-show = "create.rule.select == 'Swiss'"> <view v-show = "create.rule.select == 'Swiss'">
<uni-easyinput type = 'number' placeholder = '轮数(不填则自动计算)' v-model = 'create.rule.settings.rounds'/>
<uni-easyinput type = 'number' placeholder = '胜利分' v-model = 'create.rule.settings.winScore'/> <uni-easyinput type = 'number' placeholder = '胜利分' v-model = 'create.rule.settings.winScore'/>
<uni-easyinput type = 'number' placeholder = '平局分' v-model = 'create.rule.settings.drawScore'/> <uni-easyinput type = 'number' placeholder = '平局分' v-model = 'create.rule.settings.drawScore'/>
<uni-easyinput type = 'number' placeholder = '轮空分' v-model = 'create.rule.settings.byeScore'/> <uni-easyinput type = 'number' placeholder = '轮空分' v-model = 'create.rule.settings.byeScore'/>
...@@ -79,7 +80,7 @@ ...@@ -79,7 +80,7 @@
</template> </template>
<script setup lang = 'ts'> <script setup lang = 'ts'>
import { ref, reactive, onMounted, onUnmounted, onBeforeMount, watch} from 'vue'; import { ref, reactive, onMounted, onUnmounted, onBeforeMount, watch} from 'vue';
import { TournamentFindObject, ruleSettings, UserObject } from '../../script/type.ts'; import { ruleSettings, UserObject } from '../../script/type.ts';
import {Tabulator, User} from '../../script/post.ts'; import {Tabulator, User} from '../../script/post.ts';
import Mycard from '../../script/mycard.ts'; import Mycard from '../../script/mycard.ts';
import emitter from '../../script/emitter.ts' import emitter from '../../script/emitter.ts'
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
:disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()" :disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()"
></uni-data-select> ></uni-data-select>
<view v-show = "tournament.rule.select == 'Swiss'"> <view v-show = "tournament.rule.select == 'Swiss'">
<!-- <uni-easyinput type = 'number' placeholder = '轮数' v-model = 'tournament.rule.settings.rounds' :disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()"/> --> <uni-easyinput type = 'number' placeholder = '轮数' v-model = 'tournament.rule.settings.rounds' :disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()"/>
<uni-easyinput type = 'number' placeholder = '胜利分' v-model = 'tournament.rule.settings.winScore' :disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()"/> <uni-easyinput type = 'number' placeholder = '胜利分' v-model = 'tournament.rule.settings.winScore' :disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()"/>
<uni-easyinput type = 'number' placeholder = '平局分' v-model = 'tournament.rule.settings.drawScore' :disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()"/> <uni-easyinput type = 'number' placeholder = '平局分' v-model = 'tournament.rule.settings.drawScore' :disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()"/>
<uni-easyinput type = 'number' placeholder = '轮空分' v-model = 'tournament.rule.settings.byeScore' :disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()"/> <uni-easyinput type = 'number' placeholder = '轮空分' v-model = 'tournament.rule.settings.byeScore' :disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()"/>
......
...@@ -333,6 +333,9 @@ ...@@ -333,6 +333,9 @@
} }
tournament.collaborators = collaborators; tournament.collaborators = collaborators;
}, },
updateRounds : (round : number) : void => {
tournament.rule.settings.rounds = round;
},
clear : () : void => { clear : () : void => {
tournament.this = undefined; tournament.this = undefined;
tournament.name = ''; tournament.name = '';
...@@ -440,6 +443,8 @@ ...@@ -440,6 +443,8 @@
emitter.on(Const.tournamentInfo, page.show.drawer); emitter.on(Const.tournamentInfo, page.show.drawer);
// @ts-ignore // @ts-ignore
emitter.on(Const.tournamentReload, tournament.init); emitter.on(Const.tournamentReload, tournament.init);
// @ts-ignore
emitter.on(Const.updateRounds, tournament.updateRounds);
emitter.on(Const.createOff, creator.off); emitter.on(Const.createOff, creator.off);
window.addEventListener('hashchange', loading); window.addEventListener('hashchange', loading);
}); });
...@@ -454,6 +459,8 @@ ...@@ -454,6 +459,8 @@
emitter.off(Const.tournamentInfo, page.show.drawer); emitter.off(Const.tournamentInfo, page.show.drawer);
// @ts-ignore // @ts-ignore
emitter.off(Const.tournamentReload, tournament.init); emitter.off(Const.tournamentReload, tournament.init);
// @ts-ignore
emitter.off(Const.updateRounds, tournament.updateRounds);
emitter.off(Const.createOff, creator.off); emitter.off(Const.createOff, creator.off);
window.removeEventListener('hashchange', loading); window.removeEventListener('hashchange', loading);
}); });
......
...@@ -344,13 +344,13 @@ ...@@ -344,13 +344,13 @@
const t : TournamentGet = await Tabulator.Tournament.Find(Mycard.token, id); const t : TournamentGet = await Tabulator.Tournament.Find(Mycard.token, id);
if (t.tournament) { if (t.tournament) {
tournament.this = t.tournament; tournament.this = t.tournament;
emitter.emit(Const.tournamentReload, tournament.this)
const participants = t.participant; const participants = t.participant;
participant.array = participants.participants; participant.array = participants.participants;
participant.total = participants.total; participant.total = participants.total;
const matches = t.match; const matches = t.match;
match.array = matches.matches; match.array = matches.matches;
match.total = matches.total; match.total = matches.total;
emitter.emit(Const.tournamentReload, tournament.this);
return true; return true;
} }
return false; return false;
...@@ -698,8 +698,14 @@ ...@@ -698,8 +698,14 @@
match.submit.chk = match.array.map(i => [i.player1Score ?? 0, i.player2Score ?? 0]); match.submit.chk = match.array.map(i => [i.player1Score ?? 0, i.player2Score ?? 0]);
if (match.array.length > 0) if (match.array.length > 0)
match.maxRound = match.array.reduce((a, b) => (a.round > b.round) ? a : b)?.round ?? 0; match.maxRound = match.array.reduce((a, b) => (a.round > b.round) ? a : b)?.round ?? 0;
else match.maxRound = 0;
}, {deep : true}); }, {deep : true});
watch(() => { return match.maxRound; }, async () : Promise<void> => {
if (!Number.isNaN(tournament.this?.ruleSettings.rounds ?? 0))
emitter.emit(Const.updateRounds, match.maxRound);
});
watch(() => { return tournament.this?.creator; }, async (n = -1) => { watch(() => { return tournament.this?.creator; }, async (n = -1) => {
if (n >= 0) { if (n >= 0) {
const response = await User.Find.Id(n); const response = await User.Find.Id(n);
...@@ -708,7 +714,6 @@ ...@@ -708,7 +714,6 @@
creator.avatar = response.avatar; creator.avatar = response.avatar;
} }
} }
}, {immediate : true}); }, {immediate : true});
</script> </script>
......
...@@ -10,6 +10,7 @@ class ConstData { ...@@ -10,6 +10,7 @@ class ConstData {
changeUrl = 'changeUrl'; changeUrl = 'changeUrl';
show = 'show'; show = 'show';
showTournament = 'showTournament'; showTournament = 'showTournament';
updateRounds = 'updateRounds';
pic = { pic = {
hajimi : ` hajimi : `
<pre> :==+++=-. <pre> :==+++=-.
......
...@@ -32,6 +32,9 @@ class Tournament { ...@@ -32,6 +32,9 @@ class Tournament {
this.creator = obj.creator; this.creator = obj.creator;
this.createdAt = new Date(obj.createdAt); this.createdAt = new Date(obj.createdAt);
this.count = obj.participants.length; this.count = obj.participants.length;
if (!Number.isNaN(this.ruleSettings.winScore)) this.ruleSettings.winScore = 3;
if (!Number.isNaN(this.ruleSettings.drawScore)) this.ruleSettings.drawScore = 1;
if (!Number.isNaN(this.ruleSettings.byeScore)) this.ruleSettings.byeScore = 0;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment