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

feat:merge

parent a386e1cb
......@@ -11,12 +11,12 @@ export const plusProbability = [
},
{
name: 'multiplyFen',
radio: 0.2,
radio: 0.15,
symbolText: 'x'
},
{
name:'percent',
radio: 0.2,
radio: 0.25,
symbolText: '+'
},
{
......@@ -39,12 +39,12 @@ export const minusProbability = [
},
{
name: 'multiplyFen',
radio: 0.2,
radio: 0.15,
symbolText: 'x'
},
{
name:'percent',
radio: 0.2,
radio: 0.25,
symbolText: '-'
},
{
......
......@@ -13,6 +13,8 @@ class GamePage extends Component {
max = 99;
plusNum = 0;
firstInFlag = true;
state = {
......@@ -103,19 +105,28 @@ class GamePage extends Component {
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) {
this.firstInFlag = false;
addition = 'plus';
}
if(this.currentNumber == 0) {
if(this.currentNumber == 0 || this.currentNumber < 100) {
addition = 'plus';
}
if(this.divNum >= 10) {
addition = 'minus';
}
if(addition == 'plus') {
this.plusNum += 1;
}
// console.error("addition", addition, this.plusNum)
this.currentOpt = addition;
const symbolInfo1 = this.createSymbol(addition, -1);
let symbolInfo1 = this.createSymbol(addition, -1);
this.leftSymbol = symbolInfo1.symbolName;
let symbolInfo2 = this.createSymbol(addition, 1);
......@@ -125,7 +136,7 @@ class GamePage extends Component {
// symbolInfo2 = this.createSymbol(addition, 1);
// this.newNumber2 = this.calcNum(symbolInfo2.symbolName, 1);
// }
console.error(symbolInfo1, symbolInfo2);
// console.error(symbolInfo1, symbolInfo2);
this.setState({
addition,
......@@ -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();
......@@ -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);
......@@ -257,9 +274,9 @@ class GamePage extends Component {
break;
case 'multiplyFen':
if(this.currentOpt == 'plus') {
fen1 = this.createSpecialNum(2, 8);
if(fen1 == 8) {
fen2 = 9
fen1 = this.createSpecialNum(2, 7);
if(fen1 == 7) {
fen2 = 8
} else {
fen2 = fen1 + 1
}
......@@ -267,15 +284,44 @@ class GamePage extends Component {
fen1 = this.createSpecialNum(2, 9);
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);
// if(pos == 1) {
// let newNum2 = this.currentNumber * number;
// if(newNum1 == newNum2) {
// number = number + 1;
// }
// }
if(pos == 1) {
let newNum2 = Math.floor(this.currentNumber * fen2 / fen1);
if(newNum1 == newNum2) {
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;
case 'percent':
number = this.createSpecialNum(1, 100);
......@@ -348,7 +394,7 @@ class GamePage extends Component {
newNumber1 = symbolInfo?.number * newNumber1;
break;
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);
break;
case 'percent':
......@@ -402,7 +448,7 @@ class GamePage extends Component {
correctIndex = index;
}
if(correctIndex != index && newNumber1 != newNumber2) {
console.error("选择错误", correctIndex, index)
// console.error("选择错误", correctIndex, index)
store.playWrongSound();
this.setState({
selectIndex: index,
......@@ -430,7 +476,7 @@ class GamePage extends Component {
newNumber = index == -1 ? newNumber1 : newNumber2;
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) {
this.divNum++;
......@@ -439,7 +485,7 @@ class GamePage extends Component {
this.divNum--;
}
console.error("divNum", this.divNum)
// console.error("divNum", this.divNum)
// this.createNewElement();
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