mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-28 08:11:54 +08:00
Merge pull request #113 from Continuities/fire-state
Add fire and temperature to State.game
This commit is contained in:
+29
-30
@@ -9,8 +9,6 @@ var Room = {
|
||||
_STOKE_COOLDOWN: 10, // cooldown to stoke the fire
|
||||
_NEED_WOOD_DELAY: 15 * 1000, // from when the stranger shows up, to when you need wood
|
||||
|
||||
fire:null,
|
||||
temperature:null,
|
||||
buttons:{},
|
||||
|
||||
Craftables: {
|
||||
@@ -476,9 +474,10 @@ var Room = {
|
||||
$SM.set('game.builder.level', -1);
|
||||
}
|
||||
|
||||
Room.temperature = this.TempEnum.Cold;
|
||||
Room.fire = this.FireEnum.Dead;
|
||||
|
||||
// If this is the first time playing, the fire is dead and it's freezing.
|
||||
// Otherwise grab past save state temp and fire level.
|
||||
$SM.set('game.temperature', $SM.get('game.temperature.value')==undefined?this.TempEnum.Freezing:$SM.get('game.temperature'));
|
||||
$SM.set('game.fire', $SM.get('game.fire.value')==undefined?this.FireEnum.Dead:$SM.get('game.fire'));
|
||||
|
||||
// Create the room tab
|
||||
this.tab = Header.addLocation(_("A Dark Room"), "room", Room);
|
||||
@@ -541,8 +540,8 @@ var Room = {
|
||||
}
|
||||
setTimeout($SM.collectIncome, 1000);
|
||||
|
||||
Notifications.notify(Room, _("the room is {0}", Room.temperature.text));
|
||||
Notifications.notify(Room, _("the fire is {0}", Room.fire.text));
|
||||
Notifications.notify(Room, _("the room is {0}", $SM.get('game.temperature.text')));
|
||||
Notifications.notify(Room, _("the fire is {0}", $SM.get('game.fire.text')));
|
||||
},
|
||||
|
||||
options: {}, // Nothing for now
|
||||
@@ -550,8 +549,8 @@ var Room = {
|
||||
onArrival: function(transition_diff) {
|
||||
Room.setTitle();
|
||||
if(Room.changed) {
|
||||
Notifications.notify(Room, _("the fire is {0}", Room.fire.text));
|
||||
Notifications.notify(Room, _("the room is {0}", Room.temperature.text));
|
||||
Notifications.notify(Room, _("the fire is {0}", $SM.get('game.fire.text')));
|
||||
Notifications.notify(Room, _("the room is {0}", $SM.get('game.temperature.text')));
|
||||
Room.changed = false;
|
||||
}
|
||||
if($SM.get('game.builder.level') == 3) {
|
||||
@@ -600,7 +599,7 @@ var Room = {
|
||||
},
|
||||
|
||||
setTitle: function() {
|
||||
var title = Room.fire.value < 2 ? _("A Dark Room") : _("A Firelit Room");
|
||||
var title = $SM.get('game.fire.value') < 2 ? _("A Dark Room") : _("A Firelit Room");
|
||||
if(Engine.activeModule == this) {
|
||||
document.title = title;
|
||||
}
|
||||
@@ -610,7 +609,7 @@ var Room = {
|
||||
updateButton: function() {
|
||||
var light = $('#lightButton.button');
|
||||
var stoke = $('#stokeButton.button');
|
||||
if(Room.fire.value == Room.FireEnum.Dead.value && stoke.css('display') != 'none') {
|
||||
if($SM.get('game.fire.value') == Room.FireEnum.Dead.value && stoke.css('display') != 'none') {
|
||||
stoke.hide();
|
||||
light.show();
|
||||
if(stoke.hasClass('disabled')) {
|
||||
@@ -644,7 +643,7 @@ var Room = {
|
||||
} else if(wood > 4) {
|
||||
$SM.set('stores.wood', wood - 5);
|
||||
}
|
||||
Room.fire = Room.FireEnum.Burning;
|
||||
$SM.set('game.fire', Room.FireEnum.Burning);
|
||||
Room.onFireChange();
|
||||
},
|
||||
|
||||
@@ -658,8 +657,8 @@ var Room = {
|
||||
if(wood > 0) {
|
||||
$SM.set('stores.wood', wood - 1);
|
||||
}
|
||||
if(Room.fire.value < 4) {
|
||||
Room.fire = Room.FireEnum.fromInt(Room.fire.value + 1);
|
||||
if($SM.get('game.fire.value') < 4) {
|
||||
$SM.set('game.fire', Room.FireEnum.fromInt($SM.get('game.fire.value') + 1));
|
||||
}
|
||||
Room.onFireChange();
|
||||
},
|
||||
@@ -668,8 +667,8 @@ var Room = {
|
||||
if(Engine.activeModule != Room) {
|
||||
Room.changed = true;
|
||||
}
|
||||
Notifications.notify(Room, _("the fire is {0}", Room.fire.text), true);
|
||||
if(Room.fire.value > 1 && $SM.get('game.builder.level') < 0) {
|
||||
Notifications.notify(Room, _("the fire is {0}", $SM.get('game.fire.text')), true);
|
||||
if($SM.get('game.fire.value') > 1 && $SM.get('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"));
|
||||
setTimeout(Room.updateBuilderState, Room._BUILDER_STATE_DELAY);
|
||||
@@ -682,30 +681,30 @@ var Room = {
|
||||
|
||||
coolFire: function() {
|
||||
var wood = $SM.get('stores.wood');
|
||||
if(Room.fire.value <= Room.FireEnum.Flickering.value &&
|
||||
if($SM.get('game.fire.value') <= Room.FireEnum.Flickering.value &&
|
||||
$SM.get('game.builder.level') > 3 && wood > 0) {
|
||||
Notifications.notify(Room, _("builder stokes the fire"), true);
|
||||
$SM.set('stores.wood', wood - 1);
|
||||
Room.fire = Room.FireEnum.fromInt(Room.fire.value + 1);
|
||||
$SM.set('game.fire',Room.FireEnum.fromInt($SM.get('game.fire.value') + 1));
|
||||
}
|
||||
if(Room.fire.value > 0) {
|
||||
Room.fire = Room.FireEnum.fromInt(Room.fire.value - 1);
|
||||
if($SM.get('game.fire.value') > 0) {
|
||||
$SM.set('game.fire',Room.FireEnum.fromInt($SM.get('game.fire.value') - 1));
|
||||
Room._fireTimer = setTimeout(Room.coolFire, Room._FIRE_COOL_DELAY);
|
||||
Room.onFireChange();
|
||||
}
|
||||
},
|
||||
|
||||
adjustTemp: function() {
|
||||
var old = Room.temperature.value;
|
||||
if(Room.temperature.value > 0 && Room.temperature.value > Room.fire.value) {
|
||||
Room.temperature = Room.TempEnum.fromInt(Room.temperature.value - 1);
|
||||
Notifications.notify(Room, _("the room is {0}" , Room.temperature.text), true);
|
||||
var old = $SM.get('game.temperature.value');
|
||||
if($SM.get('game.temperature.value') > 0 && $SM.get('game.temperature.value') > $SM.get('game.fire.value')) {
|
||||
$SM.set('game.temperature',Room.TempEnum.fromInt($SM.get('game.temperature.value') - 1));
|
||||
Notifications.notify(Room, _("the room is {0}" , $SM.get('game.temperature.text')), true);
|
||||
}
|
||||
if(Room.temperature.value < 4 && Room.temperature.value < Room.fire.value) {
|
||||
Room.temperature = Room.TempEnum.fromInt(Room.temperature.value + 1);
|
||||
Notifications.notify(Room, _("the room is {0}" , Room.temperature.text), true);
|
||||
if($SM.get('game.temperature.value') < 4 && $SM.get('game.temperature.value') < $SM.get('game.fire.value')) {
|
||||
$SM.set('game.temperature', Room.TempEnum.fromInt($SM.get('game.temperature.value') + 1));
|
||||
Notifications.notify(Room, _("the room is {0}" , $SM.get('game.temperature.text')), true);
|
||||
}
|
||||
if(Room.temperature.value != old) {
|
||||
if($SM.get('game.temperature.value') != old) {
|
||||
Room.changed = true;
|
||||
}
|
||||
Room._tempTimer = setTimeout(Room.adjustTemp, Room._ROOM_WARM_DELAY);
|
||||
@@ -726,7 +725,7 @@ var Room = {
|
||||
lBuilder = $SM.setget('game.builder.level', 1);
|
||||
setTimeout(Room.unlockForest, Room._NEED_WOOD_DELAY);
|
||||
}
|
||||
else if(lBuilder < 3 && Room.temperature.value >= Room.TempEnum.Warm.value) {
|
||||
else if(lBuilder < 3 && $SM.get('game.temperature.value') >= Room.TempEnum.Warm.value) {
|
||||
var msg = "";
|
||||
switch(lBuilder) {
|
||||
case 1:
|
||||
@@ -906,7 +905,7 @@ var Room = {
|
||||
|
||||
build: function(buildBtn) {
|
||||
var thing = $(buildBtn).attr('buildThing');
|
||||
if(Room.temperature.value <= Room.TempEnum.Cold.value) {
|
||||
if($SM.get('game.temperature.value') <= Room.TempEnum.Cold.value) {
|
||||
Notifications.notify(Room, _("builder just shivers"));
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user