Unlike other stuff, stores in the side box never disappear during the game when they reach 0, once they've been "seen" (i.e., once State stores[store] has been set). But on reload they appear only if the quantity is positive.
For the sake of consistency, now null stores are visible on load (see what you're missing, bro).
This commit carries some changes.
* the compass is now a "special" item, not "good". It allows a different placing
* Store block is now divided into 2 parts. All the script is adapted to make room for it, including empty block check and insert animation for the new #store children divs
** Above: stackable storable items (resources), whose tooltip shows updated income/consumption rates
** Below: special storable items. As of now, it only contains the compass. Special block has a special style, with some distance from resources block if that one exists.
* Compass row has an empty tooltip which is filled in by World
Legends on boxes and lists are currently added via CSS and as stylesheets cannot be localised, translated strings rely upon an additional inline CSS.
This commit inserts localised legends as "data-legend" attributes on proper elements, and then this attribute is shown by stylesheet rule content: attr(data-legend). No need of localisation script and more compact CSS rules.
I noticed a minor glitch with the Village box position in the DOM. As it is appended to the Outside panel, it can end up after the Wood gather button or after the Traps check. It depends on whether the latter exists or not.
I changed it a little. Now it is "prepended" (thanks jQuery!), so it's always before any other content in the panel.
It would mind e.g. for CSS consistency, as you could decide to use a style for sibling buttons and it wouldn't work unless the box is placed before or after (not between) them.
For consistency with Outside box placement issue, stores are prepended to the Room panel, as first content in the DOM tree.
For consistency with Outside box placement issue, perks are prepended to the Path panel, as first content in the DOM tree.
The bulk of this small change was to sort stores by alphabetical order according to translated names, instead of english strings.
This meant removing the ID splitting as well as hyphen/space replacing, as the ID is not considered for the test.
Also changed:
1. line 800: as the original english string is no longer necessary in the iteration, k takes the value of translated string. k is then used for alphabetical comparison (as before) with the right value.
2. line 816: removed the test on curPrev variable. Items already listed have been placed in alphabetical order, so there is no need to check whether each item actually follows value of control variable.
This change fixes the issue of the game using the text from the saved
fire and temperature states. Clean up of the game store should be done
before next release to just save fire and temperature values only in
`game.fire` and `game.temperature` respectively.
- bugfix Engine.startThieves call changed to $SM call
- bugfix $SM.remove not deleting state
- bugfix workaround for empty string when creating states
For some reason splitting "state.sub.sub2["sub3"]" will result in
empty strings whereas "state.sub.sub2[\'sub3\']" didn't. Maybe a
javascript regex quirk?
Had to add a loop to remove '' from the split string array.
- modified collectIncome so that only one update event fires for the
whole function, no event if no income was added.
- modified updateBuildButtons so that buttons would show up if the
building had already been built.
changed check to be wood != undefined
Also changed room to display store values of 0 instead of removing
the row. It was distracting to have the values shift up and down
when tightly managing a resource. If you haven't seen a resource
yet, it still doesn't show up.
Refactoring of Outside.js to take better advantage of $SM and simplify
the code.
Includes a small bug fix to Room update handler
Also changed instances of escaped single quote (\') to double (") for
readability and simplicity.
====state changes====
//these were changed for the opposite reason the Room states were. These
seem like states that other locations and events may very well want to
interact with and possibly alter themselves
game.outside.buildings >> game.buildings
game.outside.population >> game.population
game.outside.workders >> game.workers
====functions removed====
Outside.numBuilding // just a $SM.get, no shortcut really needed since
Outside.numBuilding is a pretty long name
Outside.getPopulation // same here
Outside.addBuilding // just an add
Outside.addBuildings // just addM, but wasn't even actually used
====functions refactored====
Outside.killVillagers //moved updates to handler
Outside.updateWorkersView //added local to reduce gets
Outside.increasePopulation //updates moved to handler
Outside.increaseWorker // updates moved to handler
Outside.decreaseWorkder // updates moved to handler
Changed these States into properties of room. They are only ever
accessed by Room and there is no real reason to save them. By not
saving the state each time, it also makes the the player start out in
'a dark room' on every load. Rather fitting I think, and gives the fire
a little bit more purpose if you have to rewarm the builder.
game.room.builder >> game.builder.level
setget is mainly for use in local copies of states, useful for keeping
code cleaner and less redundant while maintaining set/get of states by
the $SM
====functions refactored====
Room.unlockForext //remove update calls
Room.buy //remove update calls
Room.build //remove update calls
Room.cooFire //added locals to reduce gets
Room.adjustTemp //added locals to reduce gets
Room.updateBuilderState //added local to reduce gets
Room.craftUnlocked //Room unlock is always going to be true, don't need
to check parents to avoid errors anymore
Room.buyUnlocked //Room unlock is always going to be true, don't need to
check parents to avoid errors anymore
add $.Dispatch to handle object events
add subscribe calls to files
update SM fireUpdate to use new Dispatch
There are some NaN issues right now, no time to bug hunt right now, it
does kind of function though