|
|
@@ -1,3 +1,4 @@
|
|
|
+import Util from "../../before/util/Util";
|
|
|
import FunBtns from "../game/FunBtns";
|
|
|
import Game from "../game/Game";
|
|
|
|
|
|
@@ -281,6 +282,24 @@ export class GameData {
|
|
|
//刷新农田
|
|
|
public needFreshArr = [];
|
|
|
|
|
|
+ /** 最大可种植植物ID */
|
|
|
+ private _maxCanPlantID = 10003;
|
|
|
+
|
|
|
+ /** 设置最大可种植id 用于判断随机种植植物*/
|
|
|
+ setMaxPlantID(id) {
|
|
|
+ this._maxCanPlantID = id;
|
|
|
+ this.setProp(GameProp.maxCanPlantID, this._maxCanPlantID);
|
|
|
+ }
|
|
|
+
|
|
|
+ getMaxPlantID() {
|
|
|
+ return this._maxCanPlantID;
|
|
|
+ }
|
|
|
+
|
|
|
+ getRandomPlantConfig() {
|
|
|
+ let id = Util.rnd(10001, this._maxCanPlantID);
|
|
|
+ return this.getProductMap(id);
|
|
|
+ }
|
|
|
+
|
|
|
public setFarmDataMap(id, data, sendToServer = true) {
|
|
|
this._farmDataMap.set(id, data);
|
|
|
let len = this._farmData.length;
|
|
|
@@ -294,10 +313,10 @@ export class GameData {
|
|
|
}
|
|
|
|
|
|
this.needFreshArr.push(id);
|
|
|
- // //更新到服务器
|
|
|
- // if (sendToServer) {
|
|
|
- // this.setProp(GameProp.farmData, this._farmData);
|
|
|
- // }
|
|
|
+ //更新到服务器
|
|
|
+ if (sendToServer) {
|
|
|
+ this.setProp(GameProp.farmData, this._farmData);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public getFarmDataMap(id) {
|
|
|
@@ -325,6 +344,9 @@ export class GameData {
|
|
|
this._farmDataMap.set(id, data);
|
|
|
id++;
|
|
|
}
|
|
|
+
|
|
|
+ //第一次初始数据
|
|
|
+ this.setMaxPlantID(this._maxCanPlantID);
|
|
|
//更新到服务器
|
|
|
this.setProp(GameProp.farmData, this._farmData);
|
|
|
}
|
|
|
@@ -399,6 +421,17 @@ export class GameData {
|
|
|
this._productMakeTimesData.push(data);
|
|
|
}
|
|
|
|
|
|
+ //设置可种植植物最大id
|
|
|
+ let nextID = id + 1;
|
|
|
+ let nextConfig = this.getProductMap(nextID);
|
|
|
+ if (nextConfig) {
|
|
|
+ if (nextConfig.tab == '农作物' && nextID > this.getMaxPlantID()) {
|
|
|
+ if (nextConfig.unlock == 1 && nextConfig.value <= times) {
|
|
|
+ this.setMaxPlantID(nextID);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
this.setProp(GameProp.productMakeTimes, this._productMakeTimesData);
|
|
|
}
|
|
|
|
|
|
@@ -438,6 +471,9 @@ export enum GameProp {
|
|
|
/** 产品生产次数 */
|
|
|
productMakeTimes = 12,
|
|
|
|
|
|
+ /** 最大可种植id */
|
|
|
+ maxCanPlantID = 13,
|
|
|
+
|
|
|
|
|
|
/** ------------------ 转盘数据 ------------------------------ */
|
|
|
turnable_leftTimes = 20,
|