Merge pull request #47 from KevinMidboe/refactor/ballot-becomes-raffle

Renamed all references to ballot to raffle.
This commit is contained in:
2020-10-11 18:23:41 +02:00
committed by GitHub
6 changed files with 19 additions and 19 deletions

View File

@@ -45,7 +45,7 @@ const attendees = async (req, res) => {
attendee = attendees[i]; attendee = attendees[i];
attendeesRedacted.push({ attendeesRedacted.push({
name: attendee.name, name: attendee.name,
ballots: attendee.red + attendee.blue + attendee.yellow + attendee.green, raffles: attendee.red + attendee.blue + attendee.yellow + attendee.green,
red: attendee.red, red: attendee.red,
blue: attendee.blue, blue: attendee.blue,
green: attendee.green, green: attendee.green,
@@ -99,27 +99,27 @@ const drawWinner = async (req, res) => {
message: "No attendees left that have not won." message: "No attendees left that have not won."
}); });
} }
let ballotColors = []; let raffleColors = [];
for (let i = 0; i < allContestants.length; i++) { for (let i = 0; i < allContestants.length; i++) {
let currentContestant = allContestants[i]; let currentContestant = allContestants[i];
for (let blue = 0; blue < currentContestant.blue; blue++) { for (let blue = 0; blue < currentContestant.blue; blue++) {
ballotColors.push("blue"); raffleColors.push("blue");
} }
for (let red = 0; red < currentContestant.red; red++) { for (let red = 0; red < currentContestant.red; red++) {
ballotColors.push("red"); raffleColors.push("red");
} }
for (let green = 0; green < currentContestant.green; green++) { for (let green = 0; green < currentContestant.green; green++) {
ballotColors.push("green"); raffleColors.push("green");
} }
for (let yellow = 0; yellow < currentContestant.yellow; yellow++) { for (let yellow = 0; yellow < currentContestant.yellow; yellow++) {
ballotColors.push("yellow"); raffleColors.push("yellow");
} }
} }
ballotColors = shuffle(ballotColors); raffleColors = shuffle(raffleColors);
let colorToChooseFrom = let colorToChooseFrom =
ballotColors[Math.floor(Math.random() * ballotColors.length)]; raffleColors[Math.floor(Math.random() * raffleColors.length)];
let findObject = { winner: false }; let findObject = { winner: false };
findObject[colorToChooseFrom] = { $gt: 0 }; findObject[colorToChooseFrom] = { $gt: 0 };

View File

@@ -5,9 +5,9 @@
Velg hvilke farger du vil ha, fyll inn antall lodd og klikk 'generer' Velg hvilke farger du vil ha, fyll inn antall lodd og klikk 'generer'
</p> </p>
<RaffleGenerator @numberOfBallots="val => this.numberOfBallots = val" /> <RaffleGenerator @numberOfRaffles="val => this.numberOfRaffles = val" />
<Vipps class="vipps" :amount="numberOfBallots" /> <Vipps class="vipps" :amount="numberOfRaffles" />
<Countdown :hardEnable="hardStart" @countdown="changeEnabled" /> <Countdown :hardEnable="hardStart" @countdown="changeEnabled" />
</div> </div>
</template> </template>
@@ -27,7 +27,7 @@ export default {
data() { data() {
return { return {
hardStart: false, hardStart: false,
numberOfBallots: null numberOfRaffles: null
}; };
}, },
mounted() { mounted() {

View File

@@ -4,10 +4,10 @@
<div class="attendees-container" ref="attendees"> <div class="attendees-container" ref="attendees">
<div class="attendee" v-for="(attendee, index) in flipList(attendees)" :key="index"> <div class="attendee" v-for="(attendee, index) in flipList(attendees)" :key="index">
<span class="attendee-name">{{ attendee.name }}</span> <span class="attendee-name">{{ attendee.name }}</span>
<div class="red-raffle ballot-element small">{{ attendee.red }}</div> <div class="red-raffle raffle-element small">{{ attendee.red }}</div>
<div class="blue-raffle ballot-element small">{{ attendee.blue }}</div> <div class="blue-raffle raffle-element small">{{ attendee.blue }}</div>
<div class="green-raffle ballot-element small">{{ attendee.green }}</div> <div class="green-raffle raffle-element small">{{ attendee.green }}</div>
<div class="yellow-raffle ballot-element small">{{ attendee.yellow }}</div> <div class="yellow-raffle raffle-element small">{{ attendee.yellow }}</div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -8,7 +8,7 @@
color.name + color.name +
'-container ' + '-container ' +
color.name + color.name +
'-raffle inner-bought-container ballot-element' '-raffle inner-bought-container raffle-element'
" "
:key="color.name" :key="color.name"
> >

View File

@@ -4,7 +4,7 @@
<h2>TREKKER</h2> <h2>TREKKER</h2>
<div <div
:class="currentColor + '-raffle'" :class="currentColor + '-raffle'"
class="ballot-element center-new-winner" class="raffle-element center-new-winner"
:style="{ transform: 'rotate(' + getRotation() + 'deg)' }" :style="{ transform: 'rotate(' + getRotation() + 'deg)' }"
> >
<span v-if="currentName && colorDone">{{ currentName }}</span> <span v-if="currentName && colorDone">{{ currentName }}</span>
@@ -20,7 +20,7 @@
<h2>VINNER</h2> <h2>VINNER</h2>
<div <div
:class="currentColor + '-raffle'" :class="currentColor + '-raffle'"
class="ballot-element center-new-winner" class="raffle-element center-new-winner"
:style="{ transform: 'rotate(' + getRotation() + 'deg)' }" :style="{ transform: 'rotate(' + getRotation() + 'deg)' }"
> >
<span v-if="currentName && colorDone">{{ currentName }}</span> <span v-if="currentName && colorDone">{{ currentName }}</span>

View File

@@ -4,7 +4,7 @@
<div class="winners" v-if="winners.length > 0"> <div class="winners" v-if="winners.length > 0">
<div v-for="(winner, index) in winners" :key="index"> <div v-for="(winner, index) in winners" :key="index">
<router-link :to="`/highscore/${ encodeURIComponent(winner.name) }`"> <router-link :to="`/highscore/${ encodeURIComponent(winner.name) }`">
<div :class="winner.color + '-ballot'" class="ballot-element">{{ winner.name }}</div> <div :class="winner.color + '-raffle'" class="raffle-element">{{ winner.name }}</div>
</router-link> </router-link>
</div> </div>
</div> </div>