mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-28 08:11:54 +08:00
create StateManager, change all State calls to managed calls
Introduced state_manager.js almost all State gets/sets are now run through the manager (alias $SM). For now it was a simple, mostly straightforward replacement of calls. This means that there are redundancies and a lot of now unneeded code for things the SM will handle. However, since I had trouble with making those changes as well as introducing the manager all at once my first attempt, I am taking the wiser approach and making "one change" at a time like I should have instead of being too sure of myself. At this point, it seems to work, but there may be bugs I didn't catch. There was also no attempt made to update old saves to work with this. In theory, it shouldn't be too hard. (included is a list of all state changes) TODO: Save Update. Refactor: a lot, many many redundancies now. Refactor: "location centric" to "global centric". Relocate all calls to different update functions to event listeners where possible. ====================================================== The changes to State are as follows: .room (exists) > features.location.room .room > game.room .room.builder > game.room.builder .room.temperature > game.room.temperature .room.fire > game.room.fire .room.buttons > game.room.buttons .outside (exists) > features.location.outside .outside > game.outside .outside.population > game.outside.population .outside.buildings > game.outside.buildings .outside.workers > game.outside.workers .outside.seenForest > game.outside.seenForest .world (exists) > features.location.world .world > game.world .world.map > game.world.map .world.mask > game.world.mask .starved > character.starved .dehydrated > character.dehydrated .ship (exists) > featuers.location.spaceShip .ship > game.spaceShip .ship.hull > game.spaceShip.hull .ship.thrusters > game.spaceShip.thrusters .ship.seenWarning > game.spaceShip.seenWarning .ship.seenShip > game.spaceShip.seenShip .punches > character.punches .perks > character.perks .thieves > game.thieves .stolen > game.stolen .cityCleared > game.cityCleared .stores > stores .income > income
This commit is contained in:
+4
-4
@@ -85,17 +85,17 @@ var Path = {
|
||||
},
|
||||
|
||||
updatePerks: function() {
|
||||
if(State.perks) {
|
||||
if($SM.get('character.perks')) {
|
||||
var perks = $('#perks');
|
||||
var needsAppend = false;
|
||||
if(perks.length == 0) {
|
||||
needsAppend = true;
|
||||
perks = $('<div>').attr('id', 'perks');
|
||||
}
|
||||
for(var k in State.perks) {
|
||||
for(var k in $SM.get('character.perks')) {
|
||||
var id = 'perk_' + k.replace(' ', '-');
|
||||
var r = $('#' + id);
|
||||
if(State.perks[k] && r.length == 0) {
|
||||
if($SM.get('character.perks[\''+k+'\']') && r.length == 0) {
|
||||
r = $('<div>').attr('id', id).addClass('perkRow').appendTo(perks);
|
||||
$('<div>').addClass('row_key').text(k).appendTo(r);
|
||||
$('<div>').addClass('tooltip bottom right').text(Engine.Perks[k].desc).appendTo(r);
|
||||
@@ -166,7 +166,7 @@ var Path = {
|
||||
|
||||
for(var k in carryable) {
|
||||
var store = carryable[k];
|
||||
var have = State.stores[k];
|
||||
var have = $SM.get('stores[\''+k+'\']');
|
||||
var num = Path.outfit[k];
|
||||
num = typeof num == 'number' ? num : 0;
|
||||
var numAvailable = Engine.getStore(k);
|
||||
|
||||
Reference in New Issue
Block a user