Kaynağa Gözat

工作记忆修复

周玉佂 2 hafta önce
ebeveyn
işleme
f75d1888e8

+ 1 - 1
.env.development

@@ -3,7 +3,7 @@ VITE_NODE_ENV = 'development'
 
 # 应用端口
 #VITE_APP_PORT = 3000
-VITE_APP_PORT = 3000
+VITE_APP_PORT = 5588
 
 # 代理前缀
 VITE_APP_BASE_API = '/dev-api'

+ 20 - 10
src/views/gameCenter/components/games/WorkingMemory/components/ability/topics.json

@@ -8,7 +8,8 @@
         "/static/image/game/WorkingMemory/右上.png",
         "/static/image/game/WorkingMemory/右下.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/H.png"
+      "answer": "/static/image/game/WorkingMemory/H.png",
+      "answers": "H"
     },
     {
       "question": "/static/image/game/WorkingMemory/H.png",
@@ -18,7 +19,8 @@
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/H.png"
+      "answer": "/static/image/game/WorkingMemory/H.png",
+      "answers": "H"
     },
     {
       "question": "/static/image/game/WorkingMemory/E.png",
@@ -28,7 +30,8 @@
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/A.png"
+      "answer": "/static/image/game/WorkingMemory/A.png",
+      "answers": "E"
     },
     {
       "question": "/static/image/game/WorkingMemory/J.png",
@@ -38,7 +41,8 @@
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/J.png"
+      "answer": "/static/image/game/WorkingMemory/J.png",
+      "answers": "J"
     },
     {
       "question": "/static/image/game/WorkingMemory/M.png",
@@ -48,7 +52,8 @@
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/M.png"
+      "answer": "/static/image/game/WorkingMemory/M.png",
+      "answers": "M"
     },
     {
       "question": "/static/image/game/WorkingMemory/P.png",
@@ -58,7 +63,8 @@
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/P.png"
+      "answer": "/static/image/game/WorkingMemory/P.png",
+      "answers": "A"
     },
     {
       "question": "/static/image/game/WorkingMemory/A.png",
@@ -68,7 +74,8 @@
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/T.png"
+      "answer": "/static/image/game/WorkingMemory/T.png",
+      "answers": "A"
     },
     {
       "question": "/static/image/game/WorkingMemory/U.png",
@@ -78,7 +85,8 @@
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/U.png"
+      "answer": "/static/image/game/WorkingMemory/U.png",
+      "answers": "H"
     },
     {
       "question": "/static/image/game/WorkingMemory/A.png",
@@ -88,7 +96,8 @@
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/A.png"
+      "answer": "/static/image/game/WorkingMemory/A.png",
+      "answers": "A"
     },
     {
       "question": "/static/image/game/WorkingMemory/E.png",
@@ -98,7 +107,8 @@
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/E.png"
+      "answer": "/static/image/game/WorkingMemory/E.png",
+      "answers": "H"
     }
   ]
 ]

+ 73 - 50
src/views/gameCenter/components/games/WorkingMemory/components/blend/index.vue

@@ -4,10 +4,13 @@
   <div
     class="child-container bor-radius-8 bg-[#ffffff] w-[1960px] h-[960px] mt-[100px] flex flex-col justify-center items-center gap-y-[30px]"
   >
-    <div id="myButton" class="absolute top-[350px]">
+    <div id="myButton" class="absolute top-[110px]">
       <div class="bg-1" v-if="divShow && !showAdd">
         <img :src="onceData.question" alt="question" class="w-[460px] h-[460px]" />
       </div>
+      <div class="bg-1" v-if="divShow && !showAdd">
+        <img :src="onceData.questions" alt="question" class="w-[460px] h-[460px]" />
+      </div>
     </div>
   </div>
   <!--  </div>-->
@@ -28,6 +31,8 @@ const $emits = defineEmits(['gameOver'])
 interface LevelData {
   level: number
   correct: boolean
+  ifNeedClick: boolean
+  ifUserClick: boolean
   score: number
   responseStartTime: number
   responseEndTime: number
@@ -35,8 +40,10 @@ interface LevelData {
 
 interface OnceItem {
   question: string
+  questions: string
   choices: string[]
   answer: string
+  answers: string
 }
 
 const openDialogRef = ref()
@@ -49,8 +56,10 @@ const fistOpen = ref(true) // 第一屏
 const flage1 = ref(true) // 视觉模式选项
 const flage2 = ref(false) // 听觉模式选项
 const flage3 = ref(false) // 混合模式选项
-const next_stepFlag1 = ref(false) // 图片游戏开始
-const next_stepFlag2 = ref(false) // 数字模式开始
+const next_stepFlag1 = ref(false) // 视觉游戏开始
+const next_stepFlag2 = ref(false) // 听觉模式开始
+const next_stepFlag3 = ref(false) // 混合模式开始
+
 // const next_stepflag = ref(true) // 第二屏
 const countDownVal = ref(560) // 倒计时时间
 const showAdd = ref(false)
@@ -80,7 +89,7 @@ const maxNumber = 9
 let currentNumber = 0
 // 响应开始时间戳
 let responseStartTime = 0
-
+let currentLetterList = []
 let timerId: any
 let divShowInteval: any
 let gameStartTime_record = 0
@@ -88,6 +97,11 @@ let gameStartTime_record = 0
 const planInfo = ref<RTPlanMgrQuery>()
 const instance = getCurrentInstance()
 const userStore = useUserStore()
+function executeMethod() {
+  nextOnce()
+  console.log('执行此方法。')
+  // createCurrentLetterList(onceData.value)
+}
 const setTimetiming = () => {
   let elapsedSeconds = 0
   function startTimer() {
@@ -97,7 +111,8 @@ const setTimetiming = () => {
         // executeMethod()
         elapsedSeconds = 0
         showAdd.value = true
-        nextOnce()
+        // nextOnce()
+        executeMethod()
       }
     }, 1000)
     // if (elapsedSeconds >= 60) {
@@ -125,14 +140,20 @@ const chengFlagek = () => {
     setTimetiming()
     next_stepFlag1.value = true
     next_stepFlag2.value = false
+    next_stepFlag3.value = false
     fistOpen.value = false
     countDownVisible.value = true
   } else if (flage2.value) {
     fistOpen.value = false
     next_stepFlag2.value = true
     next_stepFlag1.value = false
+    next_stepFlag3.value = false
     // countDownVisible.value = true
   } else {
+    fistOpen.value = false
+    next_stepFlag2.value = false
+    next_stepFlag1.value = false
+    next_stepFlag3.value = true
   }
 }
 const chengFlage1 = (answer: string) => {
@@ -225,6 +246,7 @@ const nextOnce = () => {
     } else {
       // 游戏结束
       console.log('游戏结束2')
+      console.log(gameList, '游戏数据')
       clearInterval(timerId)
       clearInterval(divShowInteval)
       // sendData()
@@ -268,46 +290,52 @@ const setOnceData = () => {
   responseStartTime = performance.now()
   // console.log(currentNumber, 'currentNumber')
   onceData.value = gameData.value[currentLevel][currentNumber]
-  //     timerId = setInterval(() => {
-  //       elapsedSeconds++
-  //       if (elapsedSeconds > 3) {
-  //         executeMethod()
-  //         elapsedSeconds = 0
-  //       }
-  //     }, 1000)
-  // divShow.value = true
-  //
-  // divShowInteval = setInterval(() => {
-  //   showAdd.value = true
-  //   nextOnce()
-  // }, 2000)
-  // onceData.value.choices = shuffleArray(onceData.value.choices)
+  console.log(currentLevel, '当前游戏等级')
+  if (currentLevel == 0) {
+    gameList.push({
+      level: currentLevel,
+      correct: false,
+      score: 0,
+      ifNeedClick: gameData.value[currentLevel][0].answer === onceData.value.question,
+      ifUserClick: false,
+      responseEndTime: performance.now(),
+      responseStartTime: responseStartTime
+    })
+  }
 }
 
-const handleClick = (answer: string) => {
-  const correct = onceData.value.answer === answer
-  VoiceImpRef.value.videoPlay('click')
-  setTimeout(() => {
-    if (correct) {
-      console.log(VoiceImpRef.value, 'hbbbbbbbbbbbbbbbbbbbbbbbbbdf=============>')
-
-      VoiceImpRef.value.videoPlay('right')
-    } else {
-      VoiceImpRef.value.videoPlay('error')
-    }
-  }, 200)
-  // 收集当前试次的用户操作数据
-  gameList.push({
-    level: currentLevel,
-    correct: correct,
-    score: correct ? scoreList[currentLevel] : 0,
-    responseEndTime: performance.now(),
-    responseStartTime: responseStartTime
-  })
-  console.log(gameList)
-
-  // 开始下一次
-  nextOnce()
+const handleKeyDown = (event: any) => {
+  console.log(event.button, '判断鼠标点击左键还是右键')
+  console.log(event.key, '判断鼠标点j还是f')
+  console.log(currentNumber, '当前试次', gameList, gameList[currentNumber])
+  if (event.key == 'f') {
+    gameList[currentNumber].ifUserClick = true
+  }
+  if (gameList[currentNumber].ifUserClick === gameList[currentNumber].ifNeedClick) {
+    gameList[currentNumber].correct = true
+  }
+  // }
+  // // VoiceImpRef.value.videoPlay('click')
+  // // setTimeout(() => {
+  // //   if (correct) {
+  // //     console.log(VoiceImpRef.value, 'hbbbbbbbbbbbbbbbbbbbbbbbbbdf=============>')
+  // //
+  // //     VoiceImpRef.value.videoPlay('right')
+  // //   } else {
+  // //     VoiceImpRef.value.videoPlay('error')
+  // //   }
+  // // }, 200)
+  // // 收集当前试次的用户操作数据
+  // // gameList.push({
+  // //   level: currentLevel,
+  // //   correct: correct,
+  // //   score: correct ? scoreList[currentLevel] : 0,
+  // //   responseEndTime: performance.now(),
+  // //   responseStartTime: responseStartTime
+  // // })
+  // // 开始下一次
+  // // nextOnce()
+  // console.log(gameList, '当前试次用户操作数据')
 }
 
 // 发送请求
@@ -423,15 +451,9 @@ async function exec() {
 onMounted(() => {
   exec()
   nextTick(() => {
+    window.addEventListener('keydown', handleKeyDown)
     countDownVisible.value = true
     setTimetiming()
-    // console.log(onceData.value.choices, 'onceData392')
-    // onceData.value = shuffleArray(onceData.value)
-    // onceData.value.choices = shuffleArray(onceData.value.choices)
-    // countDownVisible.value = true
-    // 倒计时
-    // getTime()
-    // setTimetiming()
   })
 })
 watchEffect(() => {
@@ -441,6 +463,7 @@ watchEffect(() => {
 onUnmounted(() => {
   clearInterval(timerId)
 })
+// 添加键盘事件监听
 </script>
 
 <style scoped lang="scss">

+ 30 - 10
src/views/gameCenter/components/games/WorkingMemory/components/blend/topics.json

@@ -2,103 +2,123 @@
   [
     {
       "question": "/static/image/game/WorkingMemory/中上.png",
+      "questions": "/static/image/game/WorkingMemory/A.png",
       "choices": [
         "/static/image/game/WorkingMemory/中上.png",
         "/static/image/game/WorkingMemory/中下.png",
         "/static/image/game/WorkingMemory/右上.png",
         "/static/image/game/WorkingMemory/右下.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/中上.png"
+      "answer": "/static/image/game/WorkingMemory/中上.png",
+      "answers": "H"
     },
     {
       "question": "/static/image/game/WorkingMemory/右上.png",
+      "questions": "/static/image/game/WorkingMemory/H.png",
       "choices": [
         "/static/image/game/WorkingMemory/右中.png",
         "/static/image/game/WorkingMemory/左上.png",
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/右上.png"
+      "answer": "/static/image/game/WorkingMemory/右上.png",
+      "answers": "A"
     },
     {
       "question": "/static/image/game/WorkingMemory/中上.png",
+      "questions": "/static/image/game/WorkingMemory/E.png",
       "choices": [
         "/static/image/game/WorkingMemory/右中.png",
         "/static/image/game/WorkingMemory/左上.png",
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/右上.png"
+      "answer": "/static/image/game/WorkingMemory/右上.png",
+      "answers": "E"
     },
     {
       "question": "/static/image/game/WorkingMemory/左中.png",
+      "questions": "/static/image/game/WorkingMemory/J.png",
       "choices": [
         "/static/image/game/WorkingMemory/右中.png",
         "/static/image/game/WorkingMemory/左上.png",
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/右上.png"
+      "answer": "/static/image/game/WorkingMemory/右上.png",
+      "answers": "J"
     },
     {
       "question": "/static/image/game/WorkingMemory/右下.png",
+      "questions": "/static/image/game/WorkingMemory/M.png",
       "choices": [
         "/static/image/game/WorkingMemory/右中.png",
         "/static/image/game/WorkingMemory/左上.png",
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/右上.png"
+      "answer": "/static/image/game/WorkingMemory/右上.png",
+      "answers": "P"
     },
     {
       "question": "/static/image/game/WorkingMemory/中下.png",
+      "questions": "/static/image/game/WorkingMemory/P.png",
       "choices": [
         "/static/image/game/WorkingMemory/右中.png",
         "/static/image/game/WorkingMemory/左上.png",
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/右上.png"
+      "answer": "/static/image/game/WorkingMemory/右上.png",
+      "answers": "M"
     },
     {
       "question": "/static/image/game/WorkingMemory/中上.png",
+      "questions": "/static/image/game/WorkingMemory/A.png",
       "choices": [
         "/static/image/game/WorkingMemory/右中.png",
         "/static/image/game/WorkingMemory/左上.png",
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/右上.png"
+      "answer": "/static/image/game/WorkingMemory/右上.png",
+      "answers": "P"
     },
     {
       "question": "/static/image/game/WorkingMemory/左下.png",
+      "questions": "/static/image/game/WorkingMemory/T.png",
       "choices": [
         "/static/image/game/WorkingMemory/右中.png",
         "/static/image/game/WorkingMemory/左上.png",
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/右上.png"
+      "answer": "/static/image/game/WorkingMemory/右上.png",
+      "answers": "T"
     },
     {
       "question": "/static/image/game/WorkingMemory/中上.png",
+      "questions": "/static/image/game/WorkingMemory/U.png",
       "choices": [
         "/static/image/game/WorkingMemory/右中.png",
         "/static/image/game/WorkingMemory/左上.png",
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/右上.png"
+      "answer": "/static/image/game/WorkingMemory/右上.png",
+      "answers": "T"
     },
     {
       "question": "/static/image/game/WorkingMemory/左上.png",
+      "questions": "/static/image/game/WorkingMemory/E.png",
       "choices": [
         "/static/image/game/WorkingMemory/右中.png",
         "/static/image/game/WorkingMemory/左上.png",
         "/static/image/game/WorkingMemory/左下.png",
         "/static/image/game/WorkingMemory/左中.png"
       ],
-      "answer": "/static/image/game/WorkingMemory/右上.png"
+      "answer": "/static/image/game/WorkingMemory/右上.png",
+      "answers": "E"
     }
   ]
 ]

+ 2 - 2
src/views/gameCenter/components/games/WorkingMemory/index.vue

@@ -81,10 +81,10 @@
           </div>
         </div>
         <div v-if="next_stepFlag2" id="myButton" class="flex flex-row justify-center gap-x-[20px] mt-[340px]">
-          <ability @handle-close="handleClose" />
+          <ability @game-over="handleClose" />
         </div>
         <div v-if="next_stepFlag3" id="myButton" class="flex flex-row justify-center gap-x-[20px] mt-[340px]">
-          <blend @handle-close="handleClose" />
+          <blend @game-over="handleClose" />
         </div>
       </div>
     </div>