Commit 23afc478 authored by 韦燕's avatar 韦燕

feat:merge

parent a386e1cb
...@@ -11,12 +11,12 @@ export const plusProbability = [ ...@@ -11,12 +11,12 @@ export const plusProbability = [
}, },
{ {
name: 'multiplyFen', name: 'multiplyFen',
radio: 0.2, radio: 0.15,
symbolText: 'x' symbolText: 'x'
}, },
{ {
name:'percent', name:'percent',
radio: 0.2, radio: 0.25,
symbolText: '+' symbolText: '+'
}, },
{ {
...@@ -39,12 +39,12 @@ export const minusProbability = [ ...@@ -39,12 +39,12 @@ export const minusProbability = [
}, },
{ {
name: 'multiplyFen', name: 'multiplyFen',
radio: 0.2, radio: 0.15,
symbolText: 'x' symbolText: 'x'
}, },
{ {
name:'percent', name:'percent',
radio: 0.2, radio: 0.25,
symbolText: '-' symbolText: '-'
}, },
{ {
......
...@@ -13,6 +13,8 @@ class GamePage extends Component { ...@@ -13,6 +13,8 @@ class GamePage extends Component {
max = 99; max = 99;
plusNum = 0;
firstInFlag = true; firstInFlag = true;
state = { state = {
...@@ -103,19 +105,28 @@ class GamePage extends Component { ...@@ -103,19 +105,28 @@ class GamePage extends Component {
this.leftSymbol = '' this.leftSymbol = ''
// 随机生成加减 // 随机生成加减
let addition = Math.random() > 0.5 ? 'minus' : 'plus'; let addition = this.plusNum > 10 ? (Math.random() > 0.5 ? 'minus' : 'plus') : 'plus';
if(this.firstInFlag) { if(this.firstInFlag) {
this.firstInFlag = false; this.firstInFlag = false;
addition = 'plus'; addition = 'plus';
} }
if(this.currentNumber == 0) {
if(this.currentNumber == 0 || this.currentNumber < 100) {
addition = 'plus'; addition = 'plus';
} }
if(this.divNum >= 10) { if(this.divNum >= 10) {
addition = 'minus'; addition = 'minus';
} }
if(addition == 'plus') {
this.plusNum += 1;
}
// console.error("addition", addition, this.plusNum)
this.currentOpt = addition; this.currentOpt = addition;
const symbolInfo1 = this.createSymbol(addition, -1); let symbolInfo1 = this.createSymbol(addition, -1);
this.leftSymbol = symbolInfo1.symbolName; this.leftSymbol = symbolInfo1.symbolName;
let symbolInfo2 = this.createSymbol(addition, 1); let symbolInfo2 = this.createSymbol(addition, 1);
...@@ -125,7 +136,7 @@ class GamePage extends Component { ...@@ -125,7 +136,7 @@ class GamePage extends Component {
// symbolInfo2 = this.createSymbol(addition, 1); // symbolInfo2 = this.createSymbol(addition, 1);
// this.newNumber2 = this.calcNum(symbolInfo2.symbolName, 1); // this.newNumber2 = this.calcNum(symbolInfo2.symbolName, 1);
// } // }
console.error(symbolInfo1, symbolInfo2); // console.error(symbolInfo1, symbolInfo2);
this.setState({ this.setState({
addition, addition,
...@@ -166,7 +177,7 @@ class GamePage extends Component { ...@@ -166,7 +177,7 @@ class GamePage extends Component {
} }
} }
console.error("看看可选的列表", probabilityList, addition, this.leftSymbol, pos == 1 ? '右' : '左'); // console.error("看看可选的列表", probabilityList, addition, this.leftSymbol, pos == 1 ? '右' : '左');
let probability = Math.random(); let probability = Math.random();
...@@ -194,7 +205,13 @@ class GamePage extends Component { ...@@ -194,7 +205,13 @@ class GamePage extends Component {
} }
} }
// console.error(symbolText, symbolName);
// 测试某一种符号
// if(pos == -1) {
// return this.createNum({symbolName: 'percent', symbolText: '%'}, pos);
// } else {
// return this.createNum({symbolName: 'multiplyFen', symbolText: 'x'}, pos);
// }
return this.createNum({symbolName, symbolText}, pos); return this.createNum({symbolName, symbolText}, pos);
...@@ -257,9 +274,9 @@ class GamePage extends Component { ...@@ -257,9 +274,9 @@ class GamePage extends Component {
break; break;
case 'multiplyFen': case 'multiplyFen':
if(this.currentOpt == 'plus') { if(this.currentOpt == 'plus') {
fen1 = this.createSpecialNum(2, 8); fen1 = this.createSpecialNum(2, 7);
if(fen1 == 8) { if(fen1 == 7) {
fen2 = 9 fen2 = 8
} else { } else {
fen2 = fen1 + 1 fen2 = fen1 + 1
} }
...@@ -267,15 +284,44 @@ class GamePage extends Component { ...@@ -267,15 +284,44 @@ class GamePage extends Component {
fen1 = this.createSpecialNum(2, 9); fen1 = this.createSpecialNum(2, 9);
fen2 = this.createSpecialNum(1, Math.max(1, fen1 - 1)); fen2 = this.createSpecialNum(1, Math.max(1, fen1 - 1));
} }
console.error("fen1", fen1, "fen2", fen2) // console.error("fen1", fen1, "fen2", fen2)
number = Math.round(fen2 / fen1); number = Math.round(fen2 / fen1);
// if(pos == 1) { if(pos == 1) {
// let newNum2 = this.currentNumber * number; let newNum2 = Math.floor(this.currentNumber * fen2 / fen1);
// if(newNum1 == newNum2) { if(newNum1 == newNum2) {
// number = number + 1; let found1 = false
// } if(this.currentOpt == 'plus') {
// } for (let f1 = 2; f1 <= 8; f1++) {
for (let f2 = 3; f2 <= 9; f2++) {
const newNum1 = Math.floor(this.currentNumber * f2 / f1);
if (newNum2 !== newNum1) {
fen1 = f1;
fen2 = f2;
found1 = true;
break;
}
}
if (found1) break;
}
} else {
let found2 = false
let newNum2 = Math.floor(this.currentNumber * fen2 / fen1);
for (let f1 = 2; f1 <= 9; f1++) {
for (let f2 = 1; f2 < f1; f2++) {
const temNum = Math.floor(this.currentNumber * f2 / f1);
if (temNum !== newNum2) {
fen1 = f1;
fen2 = f2;
found2 = true;
break;
}
}
if (found2) break;
}
}
}
}
break; break;
case 'percent': case 'percent':
number = this.createSpecialNum(1, 100); number = this.createSpecialNum(1, 100);
...@@ -348,7 +394,7 @@ class GamePage extends Component { ...@@ -348,7 +394,7 @@ class GamePage extends Component {
newNumber1 = symbolInfo?.number * newNumber1; newNumber1 = symbolInfo?.number * newNumber1;
break; break;
case 'multiplyFen': case 'multiplyFen':
console.error("symonl fen2", symbolInfo?.fen2, "fen1", symbolInfo?.fen1, symbolInfo?.fen2 * newNumber1 / symbolInfo?.fen1) // console.error("symonl fen2", symbolInfo?.fen2, "fen1", symbolInfo?.fen1, symbolInfo?.fen2 * newNumber1 / symbolInfo?.fen1)
newNumber1 = Math.round(symbolInfo?.fen2 * newNumber1 / symbolInfo?.fen1); newNumber1 = Math.round(symbolInfo?.fen2 * newNumber1 / symbolInfo?.fen1);
break; break;
case 'percent': case 'percent':
...@@ -402,7 +448,7 @@ class GamePage extends Component { ...@@ -402,7 +448,7 @@ class GamePage extends Component {
correctIndex = index; correctIndex = index;
} }
if(correctIndex != index && newNumber1 != newNumber2) { if(correctIndex != index && newNumber1 != newNumber2) {
console.error("选择错误", correctIndex, index) // console.error("选择错误", correctIndex, index)
store.playWrongSound(); store.playWrongSound();
this.setState({ this.setState({
selectIndex: index, selectIndex: index,
...@@ -430,7 +476,7 @@ class GamePage extends Component { ...@@ -430,7 +476,7 @@ class GamePage extends Component {
newNumber = index == -1 ? newNumber1 : newNumber2; newNumber = index == -1 ? newNumber1 : newNumber2;
this.currentNumber = newNumber; this.currentNumber = newNumber;
console.error("newNumber+++", this.currentNumber != this.state.currentNum) // console.error("newNumber+++", this.currentNumber != this.state.currentNum)
if(this.currentOpt == 'plus' && this.currentNumber > 0 && this.currentNumber != this.state.currentNum) { if(this.currentOpt == 'plus' && this.currentNumber > 0 && this.currentNumber != this.state.currentNum) {
this.divNum++; this.divNum++;
...@@ -439,7 +485,7 @@ class GamePage extends Component { ...@@ -439,7 +485,7 @@ class GamePage extends Component {
this.divNum--; this.divNum--;
} }
console.error("divNum", this.divNum) // console.error("divNum", this.divNum)
// this.createNewElement(); // this.createNewElement();
this.updateNumElementsByOpt(this.currentOpt); this.updateNumElementsByOpt(this.currentOpt);
......
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