Commit 62503a19 authored by 李维's avatar 李维

feat: 修改规则

1.中文选择界面改成英文;
2.每个出现随机几个正确的个数,不是完全一样都是2个;
3.上一个题目音频播放完了再开始下一题,而不是孩子点对了直接就消失掉音频没读完就直接切换下一题了
parent 51ee4291
This diff is collapsed.
......@@ -11,6 +11,9 @@
"e2e": "ng e2e"
},
"private": true,
"browser": {
"querystring": "querystring-es3"
},
"dependencies": {
"@angular/animations": "~9.0.2",
"@angular/common": "~9.0.2",
......@@ -52,6 +55,7 @@
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"protractor": "~5.4.3",
"querystring-es3": "^0.2.1",
"ts-node": "~8.3.0",
"tslint": "~5.18.0",
"typescript": "~3.7.5"
......
......@@ -84,6 +84,9 @@ export class Stage {
/** 随机问题列表 */
questionRandomList: Question[];
/** 本关需要点击的正确鱼数量 */
correctFishCount: number;
/**
* 构造函数
......@@ -99,47 +102,44 @@ export class Stage {
}
/**
* 将问题列表打乱并放置到随机问题列表中
* 1. 从数组中移除正确的答案
* 2. 将打乱的数组的长度限制为不超过4
* 3. 将正确的答案添加两次到列表中
* 4. 使用深拷贝处理数据
* 生成本关出鱼列表
* 1. 筛出错误选项池(除当前正确卡以外的所有选中卡片)
* 2. 正确鱼、错误鱼各随机 1-5 次
* 3. 洗牌决定从屏幕右侧进入的顺序
*/
randomList(): void {
// 使用深拷贝复制问题列表,避免直接修改原数组
const tempList = JSON.parse(JSON.stringify(this.questionList));
// 从列表中移除正确答案
const correctQuestionIndex = tempList.findIndex(q =>
q.audio === this.correctQuestion.audio &&
q.image === this.correctQuestion.image);
if (correctQuestionIndex !== -1) {
tempList.splice(correctQuestionIndex, 1);
const wrongOptions = this.questionList
.filter(q =>
!(q.audio === this.correctQuestion.audio &&
q.image === this.correctQuestion.image)
)
.map(q => JSON.parse(JSON.stringify(q)));
if (wrongOptions.length === 0) {
this.correctFishCount = 1;
this.questionRandomList = [JSON.parse(JSON.stringify(this.correctQuestion))];
return;
}
// 使用Fisher-Yates洗牌算法打乱数组
for (let i = tempList.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[tempList[i], tempList[j]] = [tempList[j], tempList[i]];
this.correctFishCount = Math.floor(Math.random() * 5) + 1;
const wrongFishCount = Math.floor(Math.random() * 5) + 1;
const spawnList: Question[] = [];
for (let i = 0; i < this.correctFishCount; i++) {
spawnList.push(JSON.parse(JSON.stringify(this.correctQuestion)));
}
for (let i = 0; i < wrongFishCount; i++) {
const randomWrong = wrongOptions[Math.floor(Math.random() * wrongOptions.length)];
spawnList.push(JSON.parse(JSON.stringify(randomWrong)));
}
// 限制打乱后的数组长度不超过4(不包括正确答案)
const maxLength = 4;
const limitedList = tempList.slice(0, maxLength);
// 将正确答案添加两次到列表中
const correctQuestionCopy = JSON.parse(JSON.stringify(this.correctQuestion));
limitedList.push(correctQuestionCopy);
limitedList.push(JSON.parse(JSON.stringify(this.correctQuestion)));
// 再次打乱数组,确保正确答案的位置随机
for (let i = limitedList.length - 1; i > 0; i--) {
for (let i = spawnList.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[limitedList[i], limitedList[j]] = [limitedList[j], limitedList[i]];
[spawnList[i], spawnList[j]] = [spawnList[j], spawnList[i]];
}
// 将最终打乱后的列表赋值给随机问题列表
this.questionRandomList = limitedList;
this.questionRandomList = spawnList;
}
}
This diff is collapsed.
src/assets/game/page/kai_shi.png

7.22 KB | W: | H:

src/assets/game/page/kai_shi.png

1.29 KB | W: | H:

src/assets/game/page/kai_shi.png
src/assets/game/page/kai_shi.png
src/assets/game/page/kai_shi.png
src/assets/game/page/kai_shi.png
  • 2-up
  • Swipe
  • Onion skin
src/assets/game/page/xuan_ze.png

6.61 KB | W: | H:

src/assets/game/page/xuan_ze.png

1.35 KB | W: | H:

src/assets/game/page/xuan_ze.png
src/assets/game/page/xuan_ze.png
src/assets/game/page/xuan_ze.png
src/assets/game/page/xuan_ze.png
  • 2-up
  • Swipe
  • Onion skin
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