mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-06-05 20:17:13 +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:
@@ -5,7 +5,7 @@ Events.Global = [
|
||||
{ /* The Thief */
|
||||
title: 'The Thief',
|
||||
isAvailable: function() {
|
||||
return (Engine.activeModule == Room || Engine.activeModule == Outside) && State.thieves == 1;
|
||||
return (Engine.activeModule == Room || Engine.activeModule == Outside) && $SM.get('game.thieves') == 1;
|
||||
},
|
||||
scenes: {
|
||||
'start': {
|
||||
@@ -32,9 +32,9 @@ Events.Global = [
|
||||
'the point is made. in the next few days, the missing supplies are returned.'
|
||||
],
|
||||
onLoad: function() {
|
||||
State.thieves = 2;
|
||||
$SM.set('game.thieves', 2);
|
||||
Engine.removeIncome('thieves');
|
||||
Engine.addStores(State.stolen);
|
||||
Engine.addStores($SM.get('game.stolen'));
|
||||
},
|
||||
buttons: {
|
||||
'leave': {
|
||||
@@ -49,7 +49,7 @@ Events.Global = [
|
||||
"shares what he knows about sneaking before he goes."
|
||||
],
|
||||
onLoad: function() {
|
||||
State.thieves = 2;
|
||||
$SM.set('game.thieves', 2);
|
||||
Engine.removeIncome('thieves');
|
||||
Engine.addPerk('stealthy');
|
||||
},
|
||||
|
||||
@@ -211,7 +211,7 @@ Events.Outside = [
|
||||
{ /* Soldier attack */
|
||||
title: 'A Military Raid',
|
||||
isAvailable: function() {
|
||||
return Engine.activeModule == Outside && Outside.getPopulation() > 0 && State.cityCleared;
|
||||
return Engine.activeModule == Outside && Outside.getPopulation() > 0 && $SM.get('game.cityCleared');;
|
||||
},
|
||||
scenes: {
|
||||
'start': {
|
||||
|
||||
@@ -397,7 +397,7 @@ Events.Room = [
|
||||
{ /* The Scout -- Map Merchant */
|
||||
title: 'The Scout',
|
||||
isAvailable: function() {
|
||||
return Engine.activeModule == Room && typeof State.world == 'object';
|
||||
return Engine.activeModule == Room && $SM.get('features.location.world');
|
||||
},
|
||||
scenes: {
|
||||
'start': {
|
||||
@@ -435,7 +435,7 @@ Events.Room = [
|
||||
{ /* The Wandering Master */
|
||||
title: 'The Master',
|
||||
isAvailable: function() {
|
||||
return Engine.activeModule == Room && typeof State.world == 'object';
|
||||
return Engine.activeModule == Room && $SM.get('features.location.world');
|
||||
},
|
||||
scenes: {
|
||||
'start': {
|
||||
@@ -507,7 +507,7 @@ Events.Room = [
|
||||
{ /* The Sick Man */
|
||||
title: 'The Sick Man',
|
||||
isAvailable: function() {
|
||||
return Engine.activeModule == Room && typeof State.world == 'object';
|
||||
return Engine.activeModule == Room && $SM.get('features.location.world');
|
||||
},
|
||||
scenes: {
|
||||
'start': {
|
||||
|
||||
+15
-15
@@ -2244,7 +2244,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
bullets: {
|
||||
@@ -2278,7 +2278,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
torch: {
|
||||
@@ -2308,7 +2308,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
rifle: {
|
||||
@@ -2354,7 +2354,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
rifle: {
|
||||
@@ -2389,7 +2389,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
rifle: {
|
||||
@@ -2429,7 +2429,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
'laser rifle': {
|
||||
@@ -2464,7 +2464,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
'steel sword': {
|
||||
@@ -2499,7 +2499,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
'steel sword': {
|
||||
@@ -2534,7 +2534,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
'rifle': {
|
||||
@@ -2574,7 +2574,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
'energy cell': {
|
||||
@@ -2613,7 +2613,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
'energy cell': {
|
||||
@@ -2646,7 +2646,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
'energy cell': {
|
||||
@@ -2695,7 +2695,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
'steel sword': {
|
||||
@@ -2739,7 +2739,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
'energy cell': {
|
||||
@@ -2782,7 +2782,7 @@ Events.Setpieces = {
|
||||
],
|
||||
onLoad: function() {
|
||||
World.clearDungeon();
|
||||
State.cityCleared = true;
|
||||
$SM.set('game.cityCleared', true);
|
||||
},
|
||||
loot: {
|
||||
'alien alloy': {
|
||||
|
||||
Reference in New Issue
Block a user