mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-06-10 22:47:13 +08:00
change to property Room.fire, Room.temperature, Room.buttons
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.
This commit is contained in:
+28
-36
@@ -450,11 +450,6 @@ var Room = {
|
|||||||
if(typeof $SM.get('features.location.room') == 'undefined') {
|
if(typeof $SM.get('features.location.room') == 'undefined') {
|
||||||
$SM.set('features.location.room', true);
|
$SM.set('features.location.room', true);
|
||||||
$SM.set('game.builder.level', -1);
|
$SM.set('game.builder.level', -1);
|
||||||
$SM.set('game.room', {
|
|
||||||
temperature: this.TempEnum.Cold,
|
|
||||||
fire: this.FireEnum.Dead,
|
|
||||||
buttons: {},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Room.temperature = this.TempEnum.Cold;
|
Room.temperature = this.TempEnum.Cold;
|
||||||
@@ -522,8 +517,8 @@ var Room = {
|
|||||||
}
|
}
|
||||||
setTimeout($SM.collectIncome, 1000);
|
setTimeout($SM.collectIncome, 1000);
|
||||||
|
|
||||||
Notifications.notify(Room, "the room is " + $SM.get('game.room.temperature.text'));
|
Notifications.notify(Room, "the room is " + Room.temperature.text);
|
||||||
Notifications.notify(Room, "the fire is " + $SM.get('game.room.fire.text'));
|
Notifications.notify(Room, "the fire is " + Room.fire.text);
|
||||||
},
|
},
|
||||||
|
|
||||||
options: {}, // Nothing for now
|
options: {}, // Nothing for now
|
||||||
@@ -531,8 +526,8 @@ var Room = {
|
|||||||
onArrival: function(transition_diff) {
|
onArrival: function(transition_diff) {
|
||||||
Room.setTitle();
|
Room.setTitle();
|
||||||
if(Room.changed) {
|
if(Room.changed) {
|
||||||
Notifications.notify(Room, "the fire is " + $SM.get('game.room.fire.text'));
|
Notifications.notify(Room, "the fire is " + Room.fire.text);
|
||||||
Notifications.notify(Room, "the room is " + $SM.get('game.room.temperature.text'));
|
Notifications.notify(Room, "the room is " + Room.temperature.text);
|
||||||
Room.changed = false;
|
Room.changed = false;
|
||||||
}
|
}
|
||||||
if($SM.get('game.builder.level') == 3) {
|
if($SM.get('game.builder.level') == 3) {
|
||||||
@@ -581,7 +576,7 @@ var Room = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setTitle: function() {
|
setTitle: function() {
|
||||||
var title = $SM.get('game.room.fire.value') < 2 ? "A Dark Room" : "A Firelit Room";
|
var title = Room.fire.value < 2 ? "A Dark Room" : "A Firelit Room";
|
||||||
if(Engine.activeModule == this) {
|
if(Engine.activeModule == this) {
|
||||||
document.title = title;
|
document.title = title;
|
||||||
}
|
}
|
||||||
@@ -591,7 +586,7 @@ var Room = {
|
|||||||
updateButton: function() {
|
updateButton: function() {
|
||||||
var light = $('#lightButton.button');
|
var light = $('#lightButton.button');
|
||||||
var stoke = $('#stokeButton.button');
|
var stoke = $('#stokeButton.button');
|
||||||
if($SM.get('game.room.fire.value') == Room.FireEnum.Dead.value && stoke.css('display') != 'none') {
|
if(Room.fire.value == Room.FireEnum.Dead.value && stoke.css('display') != 'none') {
|
||||||
stoke.hide();
|
stoke.hide();
|
||||||
light.show();
|
light.show();
|
||||||
if(stoke.hasClass('disabled')) {
|
if(stoke.hasClass('disabled')) {
|
||||||
@@ -625,7 +620,7 @@ var Room = {
|
|||||||
} else if(wood > 4) {
|
} else if(wood > 4) {
|
||||||
$SM.set('stores.wood', wood - 5);
|
$SM.set('stores.wood', wood - 5);
|
||||||
}
|
}
|
||||||
$SM.set('game.room.fire', Room.FireEnum.Burning);
|
Room.fire = Room.FireEnum.Burning;
|
||||||
Room.onFireChange();
|
Room.onFireChange();
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -639,8 +634,8 @@ var Room = {
|
|||||||
if(wood > 0) {
|
if(wood > 0) {
|
||||||
$SM.set('stores.wood', wood - 1);
|
$SM.set('stores.wood', wood - 1);
|
||||||
}
|
}
|
||||||
if($SM.get('game.room.fire.value') < 4) {
|
if(Room.fire.value < 4) {
|
||||||
$SM.set('game.room.fire', Room.FireEnum.fromInt($SM.get('game.room.fire.value') + 1));
|
Room.fire = Room.FireEnum.fromInt(Room.fire.value + 1);
|
||||||
}
|
}
|
||||||
Room.onFireChange();
|
Room.onFireChange();
|
||||||
},
|
},
|
||||||
@@ -649,8 +644,8 @@ var Room = {
|
|||||||
if(Engine.activeModule != Room) {
|
if(Engine.activeModule != Room) {
|
||||||
Room.changed = true;
|
Room.changed = true;
|
||||||
}
|
}
|
||||||
Notifications.notify(Room, "the fire is " + $SM.get('game.room.fire.text'), true);
|
Notifications.notify(Room, "the fire is " + Room.fire.text, true);
|
||||||
if($SM.get('game.room.fire.value') > 1 && $SM.get('game.builder.level') < 0) {
|
if(Room.fire.value > 1 && $SM.get('game.builder.level') < 0) {
|
||||||
$SM.set('game.builder.level', 0);
|
$SM.set('game.builder.level', 0);
|
||||||
Notifications.notify(Room, "the light from the fire spills from the windows, out into the dark");
|
Notifications.notify(Room, "the light from the fire spills from the windows, out into the dark");
|
||||||
setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
|
setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
|
||||||
@@ -663,33 +658,30 @@ var Room = {
|
|||||||
|
|
||||||
coolFire: function() {
|
coolFire: function() {
|
||||||
var wood = $SM.get('stores.wood');
|
var wood = $SM.get('stores.wood');
|
||||||
var roomFire = $SM.get('game.room.fire');
|
if(Room.fire.value <= Room.FireEnum.Flickering.value &&
|
||||||
if(roomFire.value <= Room.FireEnum.Flickering.value &&
|
|
||||||
$SM.get('game.builder.level') > 3 && wood > 0) {
|
$SM.get('game.builder.level') > 3 && wood > 0) {
|
||||||
Notifications.notify(Room, "builder stokes the fire", true);
|
Notifications.notify(Room, "builder stokes the fire", true);
|
||||||
$SM.set('stores.wood', wood - 1);
|
$SM.set('stores.wood', wood - 1);
|
||||||
roomFire = $SM.setget('game.room.fire', Room.FireEnum.fromInt(roomFire.value + 1));
|
Room.fire = Room.FireEnum.fromInt(Room.fire.value + 1);
|
||||||
}
|
}
|
||||||
if(roomFire.value > 0) {
|
if(Room.fire.value > 0) {
|
||||||
$SM.set('game.room.fire', Room.FireEnum.fromInt(roomFire.value - 1));
|
Room.fire = Room.FireEnum.fromInt(Room.fire.value - 1);
|
||||||
Room._fireTimer = setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
|
Room._fireTimer = setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
|
||||||
Room.onFireChange();
|
Room.onFireChange();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
adjustTemp: function() {
|
adjustTemp: function() {
|
||||||
var roomTemp = $SM.get('game.room.temperature');
|
var old = Room.temperature.value;
|
||||||
var roomFire = $SM.get('game.room.fire');
|
if(Room.temperature.value > 0 && Room.temperature.value > Room.fire.value) {
|
||||||
var old = roomTemp.value;
|
Room.temperature = Room.TempEnum.fromInt(Room.temperature.value - 1);
|
||||||
if(roomTemp.value > 0 && roomTemp.value > roomFire.value) {
|
Notifications.notify(Room, "the room is " + Room.temperature.text, true);
|
||||||
roomTemp = $SM.setget('game.room.temperature', Room.TempEnum.fromInt(roomTemp.value - 1));
|
|
||||||
Notifications.notify(Room, "the room is " + roomTemp.text, true);
|
|
||||||
}
|
}
|
||||||
if(roomTemp.value < 4 && roomTemp.value < roomFire.value) {
|
if(Room.temperature.value < 4 && Room.temperature.value < Room.fire.value) {
|
||||||
roomTemp = $SM.setget('game.room.temperature', Room.TempEnum.fromInt(roomTemp.value + 1));
|
Room.temperature = Room.TempEnum.fromInt(Room.temperature.value + 1);
|
||||||
Notifications.notify(Room, "the room is " + roomTemp.text, true);
|
Notifications.notify(Room, "the room is " + Room.temperature.text, true);
|
||||||
}
|
}
|
||||||
if(roomTemp.value != old) {
|
if(Room.temperature.value != old) {
|
||||||
Room.changed = true;
|
Room.changed = true;
|
||||||
}
|
}
|
||||||
Room._tempTimer = setTimeout(Room.adjustTemp, Room._ROOM_WARM_DELAY);
|
Room._tempTimer = setTimeout(Room.adjustTemp, Room._ROOM_WARM_DELAY);
|
||||||
@@ -710,7 +702,7 @@ var Room = {
|
|||||||
lBuilder = $SM.setget('game.builder.level', 1);
|
lBuilder = $SM.setget('game.builder.level', 1);
|
||||||
setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
|
setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
|
||||||
}
|
}
|
||||||
else if(lBuilder < 3 && $SM.get('game.room.temperature.value') >= Room.TempEnum.Warm.value) {
|
else if(lBuilder < 3 && Room.temperature.value >= Room.TempEnum.Warm.value) {
|
||||||
var msg;
|
var msg;
|
||||||
switch(lBuilder) {
|
switch(lBuilder) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -892,7 +884,7 @@ var Room = {
|
|||||||
|
|
||||||
build: function(buildBtn) {
|
build: function(buildBtn) {
|
||||||
var thing = $(buildBtn).attr('buildThing');
|
var thing = $(buildBtn).attr('buildThing');
|
||||||
if($SM.get('game.room.temperature.value') <= Room.TempEnum.Cold.value) {
|
if(Room.temperature.value <= Room.TempEnum.Cold.value) {
|
||||||
Notifications.notify(Room, "builder just shivers");
|
Notifications.notify(Room, "builder just shivers");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -949,7 +941,7 @@ var Room = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
craftUnlocked: function(thing) {
|
craftUnlocked: function(thing) {
|
||||||
if($SM.get('game.room.buttons[\''+thing+'\']')) {
|
if(Room.buttons[thing]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if($SM.get('game.builder.level') < 4) return false;
|
if($SM.get('game.builder.level') < 4) return false;
|
||||||
@@ -967,13 +959,13 @@ var Room = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$SM.set('game.room.buttons[\''+thing+'\']', true);
|
Room.buttons[thing] = true;
|
||||||
Notifications.notify(Room, craftable.availableMsg);
|
Notifications.notify(Room, craftable.availableMsg);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
buyUnlocked: function(thing) {
|
buyUnlocked: function(thing) {
|
||||||
if($SM.get('game.room.buttons[\''+thing+'\']')) {
|
if(Room.buttons[thing]) {
|
||||||
return true;
|
return true;
|
||||||
} else if(Outside.numBuilding('trading post') > 0) {
|
} else if(Outside.numBuilding('trading post') > 0) {
|
||||||
if(thing == 'compass' || $SM.get('stores[\''+thing+'\']')) {
|
if(thing == 'compass' || $SM.get('stores[\''+thing+'\']')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user