PTR Changelog 2015-11-27


  • Dev Team

    There is already undocumented RESOURCES_ALL constant. You can use it like that:

    RESOURCES_ALL.forEach(resourceType => creep.drop(resourceType));
    


  • Breaking change: Properties Creep.carry.energy and Structure.store.energy are now undefined when empty.

    WHY???

    now all comparisons like creep.carry.capacity < creep.carryCapacity fail... Bad change imo! Is there a specific reason for that?


  • Dev Team

    We'll have dozens of resource types in future, when mineral compounds appear. It'd be inconvenient to have defined variables for each of them in carry and store. However, we are considering the impact on backwards compatibility with players scripts due to this change right now, probably it will be a special case with energy resource. This is PTR, so everything can be changed quickly.



  • @Artem Why can't I just say creep.drop(RESOURCES_ALL) instead?


  • Dev Team

    Why can't I just say creep.drop(RESOURCES_ALL) instead?

    Because it won't be a clear API then. This method should be specified with exact types and optional amounts. What you really suggest is another method like creep.dropAll().



  • Effectively, to determine if a creep is full you have to iterate over carry.RESOURCES_ALL. This is tedious. There should be a general carry member like amount displaying the total amount of resource a creep is carrying regardless the type.



  • I just realized, I already implemented this, when you introduced carry in the first place... 😉

    function isFull(){
        return this.carryCapacity - _.reduce(this.carry) === 0;
    }
    

  • Dev Team

    Yes, the total resources amount can be simply obtained by _.sum(creep.carry), so there is no need in a separate property.


  • Culture

    Could the transfer function be added to spawns and links if the transferEnergy function is going to be deprecated for storage?


  • Dev Team

    OK, we have changed carry and store to always include energy:0 as an exceptional backward compatible case. All other resources will be undefined if empty.

    Could the transfer function be added to spawns and links if the transferEnergy function is going to be deprecated for storage?

    It could, but spawns and links are not supposed to contain anything but energy.