|
|
@@ -446,9 +446,114 @@ export class GameData {
|
|
|
public needFreshArr = [];
|
|
|
|
|
|
/** 随机获取可种植物品 */
|
|
|
- getRandomPlantConfig() {
|
|
|
- let id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
|
|
|
- return this.getProductMap(id);
|
|
|
+ getRandomPlantConfig(out?:any) {
|
|
|
+ let id = 0;
|
|
|
+ let isNoHaveCurTab = true;
|
|
|
+ let isNoAllComplete = false;
|
|
|
+ let isOrderDataInvalid = false;
|
|
|
+ let productType = [];
|
|
|
+ let animalId = [];
|
|
|
+ let data = gData.gameData.playerProp.orderData;
|
|
|
+ let orderData = data.orderTaskList;
|
|
|
+ if(data && orderData)
|
|
|
+ {
|
|
|
+ let productJson = gData.gameData.configs.Product;
|
|
|
+ for(let i = 0; i != orderData.length; ++i)
|
|
|
+ {
|
|
|
+ let dataE = orderData[i];
|
|
|
+ if (dataE.completeCount < dataE.taskCount && dataE.Id <= productJson.length) {
|
|
|
+
|
|
|
+ isNoAllComplete = true;
|
|
|
+ let productData = productJson[dataE.Id - 1];
|
|
|
+ if(productData.tab == ProductType.nzw)
|
|
|
+ {
|
|
|
+ let max = gData.gameData.getMaxProduct(ProductType.nzw);
|
|
|
+ if(productData.picture <= max)
|
|
|
+ {
|
|
|
+ id = productData.picture;
|
|
|
+ isNoHaveCurTab = false;
|
|
|
+ mk.console.logSingle("getRandomPlantConfig=>", id);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }else if(productData.tab == ProductType.dw)
|
|
|
+ {
|
|
|
+ animalId.push(productData.picture);
|
|
|
+ }else{
|
|
|
+ productType.push(productData.tab);
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ isOrderDataInvalid = true;
|
|
|
+ id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
|
|
|
+ console.log("订单数据有问题,随机id");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
|
|
|
+ console.log("订单数据没有合适的物品");
|
|
|
+ }else{
|
|
|
+ isOrderDataInvalid = true;
|
|
|
+ id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
|
|
|
+ console.log("订单数据为null");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isOrderDataInvalid)
|
|
|
+ {
|
|
|
+ return this.getProductMap(id);
|
|
|
+ }else{
|
|
|
+ if(isNoHaveCurTab)
|
|
|
+ {
|
|
|
+ if(isNoAllComplete)
|
|
|
+ {
|
|
|
+ let isHaveEmpty = false;
|
|
|
+ for(let i = 0; i != productType.length; ++i)
|
|
|
+ {
|
|
|
+ let factoryIcon = gData.factorySystem.factoryIcons;
|
|
|
+ let len = factoryIcon.length;
|
|
|
+ for (var j = 0; j < len; j++) {
|
|
|
+ let tab = this.getTabByConfigID(factoryIcon[j].configID);
|
|
|
+ if (tab == productType[j] && factoryIcon[j].data.state == FactroyState.Empty) {
|
|
|
+ isHaveEmpty = true;
|
|
|
+ out.state = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!isHaveEmpty)
|
|
|
+ {
|
|
|
+ for(let i = 0; i != animalId.length; ++i)
|
|
|
+ {
|
|
|
+ let pastureIcon = gData.pastureSystem.pastureIcons;
|
|
|
+ let len = pastureIcon.length;
|
|
|
+ for (var j = 0; j < len; j++) {
|
|
|
+ if (pastureIcon[j].data.productID ==animalId[i] && pastureIcon[j].data.state == PastureState.Empty) {
|
|
|
+ isHaveEmpty = true;
|
|
|
+ out.state = 2;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isHaveEmpty)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+
|
|
|
+ }else{
|
|
|
+ return this.getProductMap(id);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return this.getProductMap(id);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return this.getProductMap(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //id = Util.rnd(10001, this.getMaxProduct(ProductType.nzw));
|
|
|
+ //return this.getProductMap(id);
|
|
|
}
|
|
|
|
|
|
/** 随机获取可生产产品 */
|
|
|
@@ -477,11 +582,13 @@ export class GameData {
|
|
|
if (this.nextMake) {
|
|
|
return;
|
|
|
}
|
|
|
- let next = gData.farmSystem.selectNextFarm(sel);
|
|
|
+ //-1无效,1:工厂有空位,2:饲养厂有空位
|
|
|
+ let haveEmpty = {state: -1};
|
|
|
+ let next = gData.farmSystem.selectNextFarm(haveEmpty, sel);
|
|
|
if (!next) {
|
|
|
- let next1 = gData.pastureSystem.nextPasture();
|
|
|
+ let next1 = gData.pastureSystem.nextPasture(haveEmpty);
|
|
|
if (!next1) {
|
|
|
- let next2 = gData.factorySystem.nextFactory();
|
|
|
+ let next2 = gData.factorySystem.nextFactory(haveEmpty);
|
|
|
if (!next2) {
|
|
|
this.nextType = 0;
|
|
|
}
|