|
|
@@ -62,9 +62,15 @@ export class GameData {
|
|
|
public nextMake = null;
|
|
|
/** 类型标识 */
|
|
|
private nextType = 0;
|
|
|
-
|
|
|
+ /** 刷新生产按钮信息 */
|
|
|
public init_makeInfo = false;
|
|
|
|
|
|
+ /** 正在生产 */
|
|
|
+ public isProducting = false;
|
|
|
+
|
|
|
+ /** 用户价值等级 1 低 2 中 3 高*/
|
|
|
+ public ecpmLevel = 0;
|
|
|
+
|
|
|
/** 标志位 刷新任务描述 */
|
|
|
public init_task = false;
|
|
|
/**
|
|
|
@@ -104,6 +110,8 @@ export class GameData {
|
|
|
}
|
|
|
this.adShowConfig = response.data;
|
|
|
mk.console.logSingle("user/adShowConfig", response.data);
|
|
|
+ this.setEcpmLevel();
|
|
|
+ gData.adData.setPopClickTimes();
|
|
|
|
|
|
data = {};
|
|
|
response = await mk.http.sendData('welFare/getUserWelFareTaskInfo', data);
|
|
|
@@ -118,8 +126,6 @@ export class GameData {
|
|
|
element.init();
|
|
|
});
|
|
|
|
|
|
- gData.adData.setFullInterShowStr();
|
|
|
-
|
|
|
this.dataFinish = true;
|
|
|
}
|
|
|
|
|
|
@@ -239,77 +245,65 @@ export class GameData {
|
|
|
this.maxTimes = parseInt(this.configs.ServerConfig.ProductionMax);
|
|
|
this.ProductionRecovery = parseInt(this.configs.ServerConfig.ProductionRecovery);
|
|
|
//test
|
|
|
+ this.leftTimes = 100;
|
|
|
+ this.maxTimes = 100;
|
|
|
this.ProductionRecovery = 1;
|
|
|
}
|
|
|
|
|
|
//图鉴领取数据
|
|
|
private _farmMapRewardData = [];
|
|
|
|
|
|
- public getFarmMapRewardState(index)
|
|
|
- {
|
|
|
-
|
|
|
- if(index.i < this._farmMapRewardData.length)
|
|
|
- {
|
|
|
- if(index.j < this._farmMapRewardData[index.i].length)
|
|
|
- {
|
|
|
+ public getFarmMapRewardState(index) {
|
|
|
+
|
|
|
+ if (index.i < this._farmMapRewardData.length) {
|
|
|
+ if (index.j < this._farmMapRewardData[index.i].length) {
|
|
|
return this._farmMapRewardData[index.i][index.j];
|
|
|
}
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- public setFarmMapRewardState(index, state)
|
|
|
- {
|
|
|
- if(index.i < this._farmMapRewardData.length)
|
|
|
- {
|
|
|
- if(index.j < this._farmMapRewardData[index.i].length)
|
|
|
- {
|
|
|
+ public setFarmMapRewardState(index, state) {
|
|
|
+ if (index.i < this._farmMapRewardData.length) {
|
|
|
+ if (index.j < this._farmMapRewardData[index.i].length) {
|
|
|
this._farmMapRewardData[index.i][index.j] = state;
|
|
|
this.setProp(GameProp.farmMapGetRewardData, this._farmMapRewardData);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private initFarmMapGetRewardData()
|
|
|
- {
|
|
|
+
|
|
|
+ private initFarmMapGetRewardData() {
|
|
|
this._farmMapRewardData = this.getProp(GameProp.farmMapGetRewardData);
|
|
|
- if(!this._farmMapRewardData)
|
|
|
- {
|
|
|
+ if (!this._farmMapRewardData) {
|
|
|
this._farmMapRewardData = [];
|
|
|
}
|
|
|
let needSync = false;
|
|
|
let index = 0;
|
|
|
- this._productTypeMap.forEach((value, key)=>{
|
|
|
+ this._productTypeMap.forEach((value, key) => {
|
|
|
|
|
|
- if(this._farmMapRewardData.length <= index)
|
|
|
- {
|
|
|
+ if (this._farmMapRewardData.length <= index) {
|
|
|
let len = value.length;
|
|
|
let arr = [];
|
|
|
- for(let i = 0; i != len; ++i)
|
|
|
- {
|
|
|
+ for (let i = 0; i != len; ++i) {
|
|
|
arr.push(0);
|
|
|
}
|
|
|
this._farmMapRewardData.push(arr);
|
|
|
needSync = true;
|
|
|
console.log("-----add 数组数据")
|
|
|
- }else
|
|
|
- {
|
|
|
+ } else {
|
|
|
let data = this._farmMapRewardData[index];
|
|
|
let len = value.length;
|
|
|
- for(let i = 0; i != len; ++i)
|
|
|
- {
|
|
|
- if(i >= data.length)
|
|
|
- {
|
|
|
+ for (let i = 0; i != len; ++i) {
|
|
|
+ if (i >= data.length) {
|
|
|
data.push(0);
|
|
|
needSync = true;
|
|
|
console.log("-----add 单个数据")
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
++index;
|
|
|
});
|
|
|
- if(needSync)
|
|
|
- {
|
|
|
+ if (needSync) {
|
|
|
this.setProp(GameProp.farmMapGetRewardData, this._farmMapRewardData);
|
|
|
}
|
|
|
}
|
|
|
@@ -354,9 +348,9 @@ export class GameData {
|
|
|
let canArr = [];
|
|
|
let len = arr.length;
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
- if (arr[i] <= max) {
|
|
|
- canArr.push(arr[i]);
|
|
|
- if (arr[i] == max) {
|
|
|
+ if (arr[i].picture <= max) {
|
|
|
+ canArr.push(arr[i].picture);
|
|
|
+ if (arr[i].picture == max) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -367,6 +361,7 @@ export class GameData {
|
|
|
return this.getProductMap(id);
|
|
|
}
|
|
|
|
|
|
+ /** 自动生产选中下一个 */
|
|
|
setNextProduct() {
|
|
|
this.nextMake = null;
|
|
|
let next = gData.farmSystem.selectNextFarm();
|
|
|
@@ -392,6 +387,14 @@ export class GameData {
|
|
|
this.init_makeInfo = true;
|
|
|
}
|
|
|
|
|
|
+ hasFirstCheck = false;
|
|
|
+ firstCheckNext() {
|
|
|
+ if (!this.hasFirstCheck && gData.pastureSystem.pastureIcons.length >= 3 && gData.factorySystem.factoryIcons.length >= 6) {
|
|
|
+ this.hasFirstCheck = true;
|
|
|
+ gData.gameData.setNextProduct();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
makeProduct() {
|
|
|
switch (this.nextType) {
|
|
|
case 0:
|
|
|
@@ -404,6 +407,7 @@ export class GameData {
|
|
|
case 2:
|
|
|
gData.pastureSystem.btnMake();
|
|
|
this.setNextProduct();
|
|
|
+ gData.adData.checkPopRed();
|
|
|
break;
|
|
|
case 3:
|
|
|
gData.factorySystem.btnMake();
|
|
|
@@ -676,12 +680,16 @@ export class GameData {
|
|
|
}
|
|
|
else {
|
|
|
data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
|
|
|
+ //更新最大可购买商品
|
|
|
+ this.setMaxProduct(tab, arr[0].picture, false);
|
|
|
}
|
|
|
this._factoryData.push(data);
|
|
|
this._factoryDataMap.set(id, data);
|
|
|
id++;
|
|
|
}
|
|
|
+
|
|
|
//更新到服务器
|
|
|
+ this.setProp(GameProp.maxProduct, this._maxProduct);
|
|
|
this.setProp(GameProp.factoryData, this._factoryData);
|
|
|
}
|
|
|
else {
|
|
|
@@ -762,7 +770,7 @@ export class GameData {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public setMaxProduct(tab, id) {
|
|
|
+ public setMaxProduct(tab, id, sendToServer = true) {
|
|
|
if (!this._maxProduct) {
|
|
|
this._maxProduct = [];
|
|
|
}
|
|
|
@@ -783,7 +791,9 @@ export class GameData {
|
|
|
this._maxProduct.push(data);
|
|
|
}
|
|
|
|
|
|
- this.setProp(GameProp.maxProduct, this._maxProduct);
|
|
|
+ if (sendToServer) {
|
|
|
+ this.setProp(GameProp.maxProduct, this._maxProduct);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public initSetMaxProduct() {
|
|
|
@@ -809,7 +819,7 @@ export class GameData {
|
|
|
needUpdate = false;
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
data = this.getPastureDataMap(id);
|
|
|
- if (data.state == PastureState.Lock && configArr[i].value >= this.gameData.gradeLevel) {
|
|
|
+ if (data.state == PastureState.Lock && configArr[i].value <= this.gameData.gradeLevel) {
|
|
|
data = { id: id, state: PastureState.Empty, productID: configArr[i].picture, growSpan: 0 };
|
|
|
this.setPastureDataMap(id, data, false);
|
|
|
needUpdate = true;
|
|
|
@@ -819,6 +829,7 @@ export class GameData {
|
|
|
//更新到服务器
|
|
|
if (needUpdate) {
|
|
|
this.setProp(GameProp.pastureData, this._pastureData);
|
|
|
+ this.setNextProduct();
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
@@ -826,7 +837,7 @@ export class GameData {
|
|
|
needUpdate = false;
|
|
|
let configID = this.getConfigIDByTab(tab);
|
|
|
data = this.getFactoryDataMap(configID);
|
|
|
- if (data.state == FactroyState.Lock && gData.gameData.gameData.gradeLevel >= configArr[0].value) {
|
|
|
+ if (data.state == FactroyState.Lock && configArr[0].value <= this.gameData.gradeLevel) {
|
|
|
data = { id: id, state: FactroyState.Empty, productID: 0, growSpan: 0 };
|
|
|
this.setFactoryDataMap(configID, data, false);
|
|
|
needUpdate = true;
|
|
|
@@ -836,11 +847,28 @@ export class GameData {
|
|
|
|
|
|
if (needUpdate) {
|
|
|
this.setProp(GameProp.factoryData, this._factoryData);
|
|
|
+ this.setNextProduct();
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /** 设置用户ecpm分级 */
|
|
|
+ private setEcpmLevel() {
|
|
|
+ let low = parseInt(gData.gameData.configs.ServerConfig.LowValueEcpm.split(',')[1]);
|
|
|
+ let medium = parseInt(gData.gameData.configs.ServerConfig.MediumValueEcpm.split(',')[1]);
|
|
|
+ let high = parseInt(gData.gameData.configs.ServerConfig.HighValueEcpm.split(',')[1]);
|
|
|
+ if (this.adShowConfig.average_ecpm <= low) {
|
|
|
+ this.ecpmLevel = 1;
|
|
|
+ }
|
|
|
+ else if (this.adShowConfig.average_ecpm <= medium) {
|
|
|
+ this.ecpmLevel = 2;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.ecpmLevel = 3;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -880,7 +908,7 @@ export enum GameProp {
|
|
|
|
|
|
/**
|
|
|
图鉴领取数据*/
|
|
|
- farmMapGetRewardData = 17,
|
|
|
+ farmMapGetRewardData = 17,
|
|
|
|
|
|
|
|
|
|