Skip to content

Commit

Permalink
5335
Browse files Browse the repository at this point in the history
  • Loading branch information
ngtin590 committed Dec 18, 2024
1 parent 873edd3 commit 8c12619
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script>
import MainScreen from "./components/MainScreen.vue";
import InteractScreen from "./components/InteractScreen.vue";
import { shuffled } from "./utils/array";
export default {
name: "App",
components: {
Expand All @@ -26,14 +26,20 @@ export default {
},
methods: {
onHandleBeforeStart(configs) {
console.log("Configs:", configs); // Kiểm tra giá trị của configs
this.settings.totalOfBlocks = configs.size; // Đảm bảo rằng bạn dùng 'size' thay vì 'totalOfBlocks'
console.log("Total of blocks:", this.settings.totalOfBlocks); // Kiểm tra giá trị của totalOfBlocks
console.log("Configs:", configs);
this.settings.totalOfBlocks = configs.size;
console.log("Total of blocks:", this.settings.totalOfBlocks);
const firstCards = Array.from(
{ length: this.settings.totalOfBlocks / 2 },
(_, i) => i + 1
);
console.log("First cards:", firstCards); // Kiểm tra mảng firstCards
console.log("First cards:", firstCards);
const secondCards = [...firstCards];
const cards = [...firstCards, ...secondCards];
console.log(cards);
this.settings.cardsContext = shuffled(shuffled(shuffled(cards)));
this.settings.startedAt = new Date().getTime();
this.statusMatch = "match";
},
},
Expand Down
1 change: 1 addition & 0 deletions src/utils/array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const shuffled = (list) => list.sort(() => Math.random() - 0.5)

0 comments on commit 8c12619

Please sign in to comment.