<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Draft: Store prototype API]]></title><description><![CDATA[<p>In the new <a href="https://screeps.com/forum/topic/2557/draft-factories-and-commodities-new-crafting-trading-mechanic" rel="nofollow">Factories update</a> we're going to introduce 40 new resources types. This will increase complexity of both engine code and player code. We think it is time to revisit and refactor both database decisions and game APIs that work with resource entities.</p>
<h2>Database</h2>
<p>In the database, we will shift from storing all resource properties as root properties in the parent object document, to a unified <code>store</code> object property. It will affect both official MongoDB database schema, and private server schema:</p>
<pre><code>{
  _id: 'XXX',
  type: 'storage',
  store: {
    energy: 1000,
    power: 1000,
    XGH2O: 1000
  }
}
</code></pre>
<p>This schema will be used for <em>all</em> game objects capable to store any kind of resources - not only with general-purpose stores (like storages and terminals), but also spawns, extensions, labs, nukers, creeps, power creeps. The property will always be named <code>store</code> regardless of the object type.</p>
<p>Why do we tell you about inner database schema changes? Because if you have a mod that works with private server database directly, you will have to change it accordingly starting from the server version <code>4.x.x</code>.</p>
<h2>Game API</h2>
<p>We're going to implement new global prototype called <code>Store</code> and use it in all properties such as <code>StructureStorage.store</code>, <code>StructureSpawn.store</code>, <code>Creep.store</code> (<code>Creep.carry</code> will remain as a deprecated alias), etc. This change is supposed to be non-breaking and backwards compatible: all resources can be addressed as object properties as before <code>creep.store[RESOURCE_ENERGY]</code>. But it will also have some methods for more functionality:</p>
<ul>
<li>
<p><strong><code>Store.getCapacity([resourceType])</code></strong></p>
<ul>
<li>
<p><em><code>resourceType</code> is undefined:</em> returns total capacity for general purpose stores or <code>null</code> for limited stores;</p>
</li>
<li>
<p><em><code>resourceType</code> is defined:</em> returns capacity for that particular resource (for general purpose stores equals to total capacity) or <code>null</code> if this resource cannot be stored.</p>
</li>
</ul>
</li>
</ul>
<ul>
<li>
<p><strong><code>Store.getUsedCapacity([resourceType])</code></strong></p>
<ul>
<li>
<p><em><code>resourceType</code> is undefined</em>: equals to <code>_.sum(store)</code> with internal caching or <code>null</code> if this is not a general purpose store;</p>
</li>
<li>
<p><em><code>resourceType</code> is defined:</em> returns used capacity for that particular resource or <code>null</code> if this resource cannot be stored in this particular structure</p>
</li>
</ul>
</li>
</ul>
<ul>
<li>
<p><strong><code>Store.getFreeCapacity([resourceType])</code></strong> - equals to <code>getCapacity - getUsedCapacity</code>.</p>
</li>
<li>
<p><strong><code>Store.isWithdrawable()</code></strong> - a boolean flag whether you are able to withdraw from this game object.</p>
</li>
</ul>
<p>This new API is going to remove all inconsistencies and ambiguities that we currently have in different game objects that complicate dealing with resources too much.</p>
<p><s>The only breaking change will be that <code>Store.energy</code> (unlike <code>StructureSpawn.energy</code>!) will be undefined instead of 0 if there is no energy, this change is long due, since energy is an ugly exception there.</s> <strong>UPD:</strong> See <a href="https://screeps.com/forum/post/13661" rel="nofollow">another option below</a>.</p>
<p>Old-style properties like <code>StructureSpawn.energy</code> and <code>energyCapacity</code> will also remain for backwards compatibility (but deprecated).</p>
<p>We will deploy this change to the PTR with factories simultaneously, and allow for a month or two to test everything on the PTR (and <code>ptr</code> branch on npm), so you can test your game code and mods.</p>
<p>What do you think can be improved further in the proposed change?</p>
]]></description><link>http://screeps.com/forum/topic/2708/draft-store-prototype-api</link><generator>RSS for Node</generator><lastBuildDate>Mon, 18 May 2026 19:11:14 GMT</lastBuildDate><atom:link href="http://screeps.com/forum/topic/2708.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 26 Apr 2019 13:17:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Draft: Store prototype API on Thu, 02 May 2019 21:08:53 GMT]]></title><description><![CDATA[<p>In the new <a href="https://screeps.com/forum/topic/2557/draft-factories-and-commodities-new-crafting-trading-mechanic" rel="nofollow">Factories update</a> we're going to introduce 40 new resources types. This will increase complexity of both engine code and player code. We think it is time to revisit and refactor both database decisions and game APIs that work with resource entities.</p>
<h2>Database</h2>
<p>In the database, we will shift from storing all resource properties as root properties in the parent object document, to a unified <code>store</code> object property. It will affect both official MongoDB database schema, and private server schema:</p>
<pre><code>{
  _id: 'XXX',
  type: 'storage',
  store: {
    energy: 1000,
    power: 1000,
    XGH2O: 1000
  }
}
</code></pre>
<p>This schema will be used for <em>all</em> game objects capable to store any kind of resources - not only with general-purpose stores (like storages and terminals), but also spawns, extensions, labs, nukers, creeps, power creeps. The property will always be named <code>store</code> regardless of the object type.</p>
<p>Why do we tell you about inner database schema changes? Because if you have a mod that works with private server database directly, you will have to change it accordingly starting from the server version <code>4.x.x</code>.</p>
<h2>Game API</h2>
<p>We're going to implement new global prototype called <code>Store</code> and use it in all properties such as <code>StructureStorage.store</code>, <code>StructureSpawn.store</code>, <code>Creep.store</code> (<code>Creep.carry</code> will remain as a deprecated alias), etc. This change is supposed to be non-breaking and backwards compatible: all resources can be addressed as object properties as before <code>creep.store[RESOURCE_ENERGY]</code>. But it will also have some methods for more functionality:</p>
<ul>
<li>
<p><strong><code>Store.getCapacity([resourceType])</code></strong></p>
<ul>
<li>
<p><em><code>resourceType</code> is undefined:</em> returns total capacity for general purpose stores or <code>null</code> for limited stores;</p>
</li>
<li>
<p><em><code>resourceType</code> is defined:</em> returns capacity for that particular resource (for general purpose stores equals to total capacity) or <code>null</code> if this resource cannot be stored.</p>
</li>
</ul>
</li>
</ul>
<ul>
<li>
<p><strong><code>Store.getUsedCapacity([resourceType])</code></strong></p>
<ul>
<li>
<p><em><code>resourceType</code> is undefined</em>: equals to <code>_.sum(store)</code> with internal caching or <code>null</code> if this is not a general purpose store;</p>
</li>
<li>
<p><em><code>resourceType</code> is defined:</em> returns used capacity for that particular resource or <code>null</code> if this resource cannot be stored in this particular structure</p>
</li>
</ul>
</li>
</ul>
<ul>
<li>
<p><strong><code>Store.getFreeCapacity([resourceType])</code></strong> - equals to <code>getCapacity - getUsedCapacity</code>.</p>
</li>
<li>
<p><strong><code>Store.isWithdrawable()</code></strong> - a boolean flag whether you are able to withdraw from this game object.</p>
</li>
</ul>
<p>This new API is going to remove all inconsistencies and ambiguities that we currently have in different game objects that complicate dealing with resources too much.</p>
<p><s>The only breaking change will be that <code>Store.energy</code> (unlike <code>StructureSpawn.energy</code>!) will be undefined instead of 0 if there is no energy, this change is long due, since energy is an ugly exception there.</s> <strong>UPD:</strong> See <a href="https://screeps.com/forum/post/13661" rel="nofollow">another option below</a>.</p>
<p>Old-style properties like <code>StructureSpawn.energy</code> and <code>energyCapacity</code> will also remain for backwards compatibility (but deprecated).</p>
<p>We will deploy this change to the PTR with factories simultaneously, and allow for a month or two to test everything on the PTR (and <code>ptr</code> branch on npm), so you can test your game code and mods.</p>
<p>What do you think can be improved further in the proposed change?</p>
]]></description><link>http://screeps.com/forum/post/13653</link><guid isPermaLink="true">http://screeps.com/forum/post/13653</guid><dc:creator><![CDATA[artch]]></dc:creator><pubDate>Thu, 02 May 2019 21:08:53 GMT</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p>I don't really like StructureSpawn.store or StructureExtension.store. If it's just energy please consider continuing support as it is now through the energy field. This will also prevent breaking everyone's code in many many places. For labs and nukers I would prefer the same, it's not 'storage', even though you can withdraw if you must from spawns and extension, it's energy to operate with.</p>
]]></description><link>http://screeps.com/forum/post/13654</link><guid isPermaLink="true">http://screeps.com/forum/post/13654</guid><dc:creator><![CDATA[TuN9aN0]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/1886">@tun9an0</a> They have <em>stores</em> capable to store only one kind of resources: energy. Making one unified prototype for all game objects will simplify the API to understand and work with a lot, you will be able to reuse a lot of code for different types of game objects.</p>
<blockquote>
<p>This will also prevent breaking everyone's code in many many places.</p>
</blockquote>
<p>What do you mean?</p>
]]></description><link>http://screeps.com/forum/post/13655</link><guid isPermaLink="true">http://screeps.com/forum/post/13655</guid><dc:creator><![CDATA[artch]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/3">@artch</a> Nevermind I missed the sentence about StructureSpawn.energy and energyCapacity. I think deprecation is not needed though as they are semantically better then a store object with one always there energy entry. It's not that things are suddenly becoming dynamic.</p>
]]></description><link>http://screeps.com/forum/post/13656</link><guid isPermaLink="true">http://screeps.com/forum/post/13656</guid><dc:creator><![CDATA[TuN9aN0]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p>How would store.getFreeCapacity work for say a nuker where the energy and ghodium capacity are in their own bucket?</p>
]]></description><link>http://screeps.com/forum/post/13657</link><guid isPermaLink="true">http://screeps.com/forum/post/13657</guid><dc:creator><![CDATA[TuN9aN0]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p>I like the idea of a unified <code>Store</code>-object, but only for <code>Structure</code>, <code>Terminal</code>, <code>Creep</code> and <code>PowerCreep</code>. But for 'other structures' it would be nice to have a unified way to access resources.</p>
<p>Almost every structure depends on <code>energy</code>, so it's good to be never <code>undefined</code>. <code>energy===0</code> is an ugly exception in <code>store</code>, but it's not ugly in 'other structures' like extensions, towers, spawns, etc.</p>
<p>But every player can change the prototypes to get the desired behaviour, so it's not a big deal.</p>
<p>I'm worried that a preinitialized <code>store</code> for 'other structures' just increases memory consumption a lot more, which is already an issue for some players.</p>
]]></description><link>http://screeps.com/forum/post/13658</link><guid isPermaLink="true">http://screeps.com/forum/post/13658</guid><dc:creator><![CDATA[Xenofix]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/1886">@tun9an0</a> It's still to be decided. I see two options:</p>
<ul>
<li>
<p>One store bucket for both resources (and you will be able to load only 5000 units of ghodium in it)</p>
</li>
<li>
<p>Two separate stores <code>energyStore</code> and <code>ghodiumStore</code> each with its own capacity.</p>
</li>
</ul>
]]></description><link>http://screeps.com/forum/post/13659</link><guid isPermaLink="true">http://screeps.com/forum/post/13659</guid><dc:creator><![CDATA[artch]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Fri, 26 Apr 2019 14:01:57 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/132">@xenofix</a> Yes, implementing Store prototype only for general-purpose stores is also an option which we consider. But it will not allow for massive convenience improvement in the API for transfer/withdraw/whatever code reuse cases.</p>
<blockquote>
<p>Almost every structure depends on energy, so it's good to be never undefined. energy===0 is an ugly exception in store, but it's not ugly in 'other structures' like extensions, towers, spawns, etc.</p>
</blockquote>
<p>It will be undefined only in the <code>Store</code> prototype, but not in <code>StructureSpawn.energy</code> for example.</p>
]]></description><link>http://screeps.com/forum/post/13660</link><guid isPermaLink="true">http://screeps.com/forum/post/13660</guid><dc:creator><![CDATA[artch]]></dc:creator><pubDate>Fri, 26 Apr 2019 14:01:57 GMT</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Wed, 15 May 2019 07:34:19 GMT]]></title><description><![CDATA[<p>OK, another idea came to my mind (top post updated): we can make <code>Store</code> prototype have getters for every resource types which will always return 0 for any resource, and never return undefined at all, i.e. we fix the inconsistency in favor of energy rather than in favor of non-energy:</p>
<pre><code>storage.store[RESOURCE_ENERGY] === 0 // true
storage.store[RESOURCE_HYDROGEN] === 0 // true
</code></pre>
<p>Enumeration will work only through properties that are greater than 0.</p>
]]></description><link>http://screeps.com/forum/post/13661</link><guid isPermaLink="true">http://screeps.com/forum/post/13661</guid><dc:creator><![CDATA[artch]]></dc:creator><pubDate>Wed, 15 May 2019 07:34:19 GMT</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/3">@artch</a> I do appreciate the infrastructure concern but I do think it's kind of leaking here, I wouldn't model this as a store as it's obviously different from say a storage or container. Most of my code dealing with energy is kind of ortoganal to dealing with non-energy as is, checking structure.energy versus structure.store.energy otherwise is just shifting thing about. Another concern is store.energy though, the API currently guarentees .energy to be set. I am sure like me there will be a lot of people who deal with it like this also. undefined &lt; 10 returns false, this will send some quite a few people astray I am sure. I will need to dig through a lot of code to get this fixed everywhere..</p>
]]></description><link>http://screeps.com/forum/post/13662</link><guid isPermaLink="true">http://screeps.com/forum/post/13662</guid><dc:creator><![CDATA[TuN9aN0]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/3">@artch</a> How many resources were factories going to add again? I sure hope for the Game Object's footprint on the heap it will come through some proxy, otherwise each Structure that can potentially hold something will have this massive hash with 0 values in it...</p>
]]></description><link>http://screeps.com/forum/post/13663</link><guid isPermaLink="true">http://screeps.com/forum/post/13663</guid><dc:creator><![CDATA[TuN9aN0]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/3">@artch</a> said in <a href="/forum/post/13659">Draft: Store prototype API</a>:</p>
<blockquote>
<ul>
<li>Two separate stores <code>energyStore</code> and <code>ghodiumStore</code> each with its own capacity.</li>
</ul>
</blockquote>
<p>With any other property than <code>store</code> it's not a simple unified API anymore. It has to be one <code>store</code> or no <code>store</code>, but we don't win anything if we wrap number fields in <code>xxxStore</code>-objects.</p>
<p>For developing I must disagree with making the <code>energy</code> and <code>energyCapacity</code> deprecated. If you know the structure you are using, then these fields are the preferred way to access these values. The function of <code>store</code> is just to simplify some code for generic transfer/withdraw.</p>
<p>I like the idea with store-properties returning 0. I think what <a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/1886">@TuN9aN0</a> pointed out is an implementation detail here. I would be against <code>Proxy</code>. Store-objects for Extension or Tower could be using a Prototype which is just a view to the Structure without own memory, which has a property defined in the prototype to be const <code>0</code> for each resourceType and energy is a getter to the (hopefully not deprecated) energy field of structure.</p>
]]></description><link>http://screeps.com/forum/post/13664</link><guid isPermaLink="true">http://screeps.com/forum/post/13664</guid><dc:creator><![CDATA[Xenofix]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/1886">@tun9an0</a> Database and API changes are irrelevant. They introduce separate optimizations for engine code and for player code, but they are not related to each other, we might deploy them in separate updates if we want to, but it seems logical to deploy them together. There is no &quot;leaking&quot; in that regard.</p>
<p>As to your compatibility concern, please see <a href="https://screeps.com/forum/post/13661" rel="nofollow">the post above</a>.</p>
<blockquote>
<p>How many resources were factories going to add again? I sure hope for the Game Object's footprint on the heap it will come through some proxy, otherwise each Structure that can potentially hold something will have this massive hash with 0 values in it...</p>
</blockquote>
<p>40 new resource types. But there is no real data for absent resources in a <code>Store</code>. <code>Store.prototype</code> will just contain a getter for every resource type which returns 0 if the underlying DB data object doesn't have the corresponding resource property.</p>
]]></description><link>http://screeps.com/forum/post/13665</link><guid isPermaLink="true">http://screeps.com/forum/post/13665</guid><dc:creator><![CDATA[artch]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/132">@xenofix</a> said in <a href="/forum/post/13664">Draft: Store prototype API</a>:</p>
<blockquote>
<p>For developing I must disagree with making the energy and energyCapacity deprecated. If you know the structure you are using, then these fields are the preferred way to access these values.</p>
</blockquote>
<p>I don't get it, why exactly is <code>extension.energy</code> so much more convenient than <code>extension.store.energy</code> that we have to keep this ugly duplication forever?</p>
]]></description><link>http://screeps.com/forum/post/13666</link><guid isPermaLink="true">http://screeps.com/forum/post/13666</guid><dc:creator><![CDATA[artch]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/3">@artch</a> Ok well if it's not for infrastructure concerns, then my feedback is I do not need this change, I think it's currently fine. In my view it actually introduces a leaky abstraction. I don't need unified access to things that are essentially different logically. I would not model it this way.</p>
]]></description><link>http://screeps.com/forum/post/13667</link><guid isPermaLink="true">http://screeps.com/forum/post/13667</guid><dc:creator><![CDATA[TuN9aN0]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/1886">@tun9an0</a> Very well then, thanks for your feedback! Let's see what other people will say, since this inconsistency and ambiguity in how resources are stored is being  long complained by many players.</p>
]]></description><link>http://screeps.com/forum/post/13668</link><guid isPermaLink="true">http://screeps.com/forum/post/13668</guid><dc:creator><![CDATA[artch]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p>To me, <code>carry</code> is inconsistent. I would want to have it be named <code>store</code> instead. And a <code>Store</code>-object for general purpose stores is also very welcomed.</p>
<p>But for every other non-general-purpose structure this is only a little nice-to-have feature to simplify withdraw/transfer. If dealing with structure-specific code, I would prefer to access <code>energy</code> and other fields directly. If it's general purpose refiller/robbery code, then I would go for <code>store</code>.</p>
<p>Important to be is that such a change does not have a negative performance impact.</p>
]]></description><link>http://screeps.com/forum/post/13669</link><guid isPermaLink="true">http://screeps.com/forum/post/13669</guid><dc:creator><![CDATA[Xenofix]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/132">@xenofix</a></p>
<blockquote>
<p>If dealing with structure-specific code, I would prefer to access energy and other fields directly.</p>
</blockquote>
<p>Still can't seem to understand what's the difference between addressing <code>.energy</code> and <code>.store.energy</code>?</p>
<p>As to performance, CPU-wise it will not be affected, only heap-wise concern is valid here, and we can simply raise the heap limit on deploying this change.</p>
]]></description><link>http://screeps.com/forum/post/13670</link><guid isPermaLink="true">http://screeps.com/forum/post/13670</guid><dc:creator><![CDATA[artch]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p>As both a mod developer and player I'm exited about this update, for modding, it was always annoying not being able to iterate over resources in a simple way. As a player, the entire <code>store</code>/<code>carry</code>/<code>energyCapacity</code>/<code>carryCapacity</code> mess was annoying, in some cases, I actually wrapped all those to make them match, very similar to how this is designed. It might seem a bit more clunky for stuff with only one resource, but simplifies more than enough other code to make it worth it.</p>
<p>For those wanting to keep <code>energy</code>/<code>energyCapacity</code>, they can easily do a simple prototype extension in their code. <code>Object.defineProperty(StructureExtension.prototype, 'energy', { get() { return this.store.energy } })</code>
<code>Object.defineProperty(StructureExtension.prototype, 'energyCapacity', { get() { return this.store.capacity } })</code></p>
]]></description><link>http://screeps.com/forum/post/13671</link><guid isPermaLink="true">http://screeps.com/forum/post/13671</guid><dc:creator><![CDATA[ags131]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Fri, 26 Apr 2019 14:49:14 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/17">@ags131</a> yeah I've had to abstract around energy, store etc in various places (e.g. if (instanceof_energy_structure(struc)) { } else if (instanceof_store_structure(struc)) { } )</p>
<p>Before I used typescript and enforced this at &quot;compile-time&quot;, I remember fixing various bugs where I tried to treat an extension as if it had a store, or some other structure the other way around.</p>
<p>I will be glad to have a unified interface, even though I'll have to at some point rework some of my code.</p>
<p>It will make the game slightly less complex for new players.</p>
]]></description><link>http://screeps.com/forum/post/13672</link><guid isPermaLink="true">http://screeps.com/forum/post/13672</guid><dc:creator><![CDATA[wtfrank]]></dc:creator><pubDate>Fri, 26 Apr 2019 14:49:14 GMT</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p>From my point of view, I like and welcome this change, it will allow me to streamline my creep states so they can exit faster (Thus saving CPU.) I am concerned that heap use may increase, but that's Artch's problem... and in reality, any heap issue impacts everyone, mostly heavy users and users past the 300 CPU limit first, so I don't have a problem with that, despite that I'm breathing down the 300 CPU limit's neck. At the end of the day, it's pretty fair.</p>
<p>Two potential issues. First, the obvious one: Nukers with their 5000 ghodium. Two stores? Ewww! Don't make them all the same except for this one weird bird. Applying a limit object with, for example: {G:5000,energy:250000} to it is the best solution, other structures would have null there to short circuit any checks.</p>
<p>Then the 800 pound Gorilla: LABS. Labs are incompatible with a Store object unless you dynamically reset the limit object on the fly. Sure, the capacity remains 5000, but it can change from (for example.)  {UO:3000,energy:2000} to {energy:2000} to {KH:3000,energy:2000}. It can have only one non-energy resource as it uses that to determine what it's doing.</p>
]]></description><link>http://screeps.com/forum/post/13673</link><guid isPermaLink="true">http://screeps.com/forum/post/13673</guid><dc:creator><![CDATA[Smokeman]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p>I like the idea of a unified way of withdrawing / transferring resources, specially with getters that return <code>0</code> instead of <code>undefined</code>. I already have something like that in my code. I would have to keep it, though, since mine also supports <code>pickup</code> and  <code>drop</code>. I'm not sure this change would benefit me specifically, but I see its value for general purpose code.
The only things I don't like about this proposal are including nuker into this, which seems like a stretch and doesn't really add any value, and deprecating the old API. Forcing everybody to change their code, making it slightly more convoluted or it will eventually break, will just make people angry. I see no benefit in that. Keep both and everybody is happy.</p>
]]></description><link>http://screeps.com/forum/post/13674</link><guid isPermaLink="true">http://screeps.com/forum/post/13674</guid><dc:creator><![CDATA[eduter]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p>I also like the new structure .. I already had added prototypes for  some of the features, like a cached <code>storeSum</code> and <code>carrySum</code> and having it official is a plus.
If the api is decided I'd like to add a polyfill so I can already start to use the new store object <img
      src="http://screeps.com/forum/plugins/nodebb-plugin-emoji/emoji/android/1f609.png?v=a1k070tfs06"
      class="not-responsive emoji emoji-android emoji--wink"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>http://screeps.com/forum/post/13675</link><guid isPermaLink="true">http://screeps.com/forum/post/13675</guid><dc:creator><![CDATA[W4rl0ck]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p>I also welcome the API change but without deprecation of <code>energy</code>. If <code>energy</code> must be deprecated, then please make sure they are <code>configurable</code> to deactivate any warnings.</p>
<p>I think professional players already know how to overwrite prototypes and have aliases and getters for their needs already. Everyone can already model a unified <code>store</code>, and properties for <code>energy</code> and whatever. Keeping that in mind, the API change is mainly for newbies and those who cannot change prototypes using typescript or have found ugly ways around the inconsistent API which they like to simplify.</p>
<p>As a newbie I did often access <code>creep.energy</code> directly instead of <code>creep.carry.energy</code>. The same for storages, it was just so annoying that I always have to access either <code>carry.energy</code> or <code>store.energy</code> or <code>energy</code> when at first all I care about is just simple energy. The tower has no <code>store</code>, the creep has no <code>energy</code> and no <code>store</code> but <code>carry</code> instead; just not consistent. But I can make it consistent with prototypes. So yes, this change would not really help me, but it will help other newbies. One <code>store</code> for all kind of objects is a great change for the API.</p>
<p>About the database change: Please just choose the most efficient model.</p>
<p>I think every high-level player at 300 cpu cap and those who are looking forward to be one agrees with me that <strong>performance is more important than convenience</strong>. The database is hidden from us, so I prefer an efficient database model over a simple engine code. I have no idea if your proposed database change will have a positive or negative impact on overall performance, but I just fear that it's a negative impact because it looks more complex than before. In my eyes, the API and the database change are two different changes.</p>
<p>In the end these proposed convenience changes should meet the following requirements:</p>
<ol>
<li>one <code>store</code> for every relevant object to allow a unified way to access energy and resources for convenience.</li>
<li>It shall not increase overall tick rate, better decrease it.</li>
<li>It shall not significantly decrease the free memory we can use</li>
<li>It shall not increase our cpu consumption, better decrease it.</li>
</ol>
<p>If that's all met, then I believe every single player in the community will be happy about this change.</p>
]]></description><link>http://screeps.com/forum/post/13678</link><guid isPermaLink="true">http://screeps.com/forum/post/13678</guid><dc:creator><![CDATA[Xenofix]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/132">@xenofix</a></p>
<blockquote>
<p>I have no idea if your proposed database change will have a positive or negative impact on overall performance, but I just fear that it's a negative impact because it looks more complex than before.</p>
</blockquote>
<p>It will be positive. Look at <a href="https://github.com/screeps/engine/blob/c4ec4d8b51d76f9c03511f427e32849a2e7d0879/src/utils.js#L1113-L1115" rel="nofollow">this engine code</a>:</p>
<pre><code>exports.calcResources = function(object) {
    return _.sum(C.RESOURCES_ALL, i =&gt; typeof object[i] == 'object' ? object[i].amount : (object[i] || 0));
};
</code></pre>
<p>It will benefit greatly from this database change:</p>
<pre><code>exports.calcResources = function(object) {
    return _.sum(object.store);
};
</code></pre>
]]></description><link>http://screeps.com/forum/post/13679</link><guid isPermaLink="true">http://screeps.com/forum/post/13679</guid><dc:creator><![CDATA[artch]]></dc:creator><pubDate>Invalid Date</pubDate></item><item><title><![CDATA[Reply to Draft: Store prototype API on Invalid Date]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="http://screeps.com/forum/uid/154">@eduter</a></p>
<blockquote>
<p>Keep both and everybody is happy.</p>
</blockquote>
<p>This is exactly how legacy monsters are born <img
      src="http://screeps.com/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f47e.png?v=a1k070tfs06"
      class="not-responsive emoji emoji-emoji-one emoji--alien_monster"
      title=":alien_monster:"
      alt="👾"
    /></p>
]]></description><link>http://screeps.com/forum/post/13680</link><guid isPermaLink="true">http://screeps.com/forum/post/13680</guid><dc:creator><![CDATA[artch]]></dc:creator><pubDate>Invalid Date</pubDate></item></channel></rss>