TooAngel / screeps

TooAngel NPC / bot / source code for screeps
https://screeps.com
GNU Affero General Public License v3.0
609 stars 154 forks source link

Error with property price. #485

Open MetaverseRPN opened 7 years ago

MetaverseRPN commented 7 years ago

I was running the AI without a problem until i ran into this error: 7189034 ROOM Executing room failed: ROOM TypeError: Cannot create property 'price' on string '{' TypeError: Cannot create property 'price' on string '{' at _getOrders (/app/node_modules/@screeps/engine/dist/game/market.js:27:53) at Object. (/app/node_modules/@screeps/engine/dist/game/market.js:41:26) at Object.getAllOrders (evalmachine.:1:72) at Object.Room.setRoomInactive (prototype_room_my:493:28) at Object.Room.reviveRoom (prototype_room_my:528:10) at Object.Room.executeRoom (prototype_room_my:303:10) at Object.Room.myHandleRoom (prototype_room_my:35:15) at Object.Room.handle (prototype_room:9:17) at Object.Room.execute (prototyperoom:17:29) at Memory.myRooms..filter (main:48:50) at /app/node_modules/lodash/index.js:1932:13 at /app/node_modules/lodash/index.js:3073:15 at baseForOwn (/app/node_modules/lodash/index.js:2046:14) at /app/node_modules/lodash/index.js:3043:18 at baseFilter (/app/node_modules/lodash/index.js:1931:7) at filter (/app/node_modules/lodash/index.js:6309:14) at interceptor (/app/node_modules/lodash/index.js:12240:26) at Function.thru (/app/node_modules/lodash/index.js:5927:26) at baseWrapperValue (/app/node_modules/lodash/index.js:2768:30) at LodashWrapper.wrapperValue (/app/node_modules/lodash/index.js:6124:14) at main (main:48:80) at Object.module.exports.loop (main:76:5)

now i have no creeps and last time this happened i lost my room and had to respawn

Domkeykong commented 6 years ago

I had the same problem try this at prototype_room_my:490:

Room.prototype.setRoomInactive = function() {
  this.log('Setting room to underSiege');
  // this.memory.underSiege = true;
  try{
  var tokens = Game.market.getAllOrders({
    type: ORDER_SELL,
    resourceType: SUBSCRIPTION_TOKEN,
  });
  } catch (e) {
    this.log('No Subscription Tokens for sale adding value of 5,000,000.000')
    var tokens =  [{
    price : 5000000.000    //change this value to whatever you feel appropriate enough
}]
  }
  let addToIdiot = 3000000;
  if (tokens.length > 0) {
    tokens = _.sortBy(tokens, (object) => {
      return -1 * object.price;
    });
    addToIdiot = Math.max(addToIdiot, tokens[0].price);
  }
  this.log('Increase idiot by subscription token');
  const idiotCreeps = this.findPropertyFilter(FIND_HOSTILE_CREEPS, 'owner.username', ['Invader'], {inverse: true});
  if (idiotCreeps.length > 0) {
    for (const idiotCreep of idiotCreeps) {
      brain.increaseIdiot(idiotCreep.owner.username, addToIdiot);
    }
  }
  this.memory.active = false;
};