mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-28 00:01:54 +08:00
refactor Outside to use $SM + Room bugfix, \' to "
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
This commit is contained in:
@@ -5,7 +5,7 @@ Events.Outside = [
|
||||
{ /* Ruined traps */
|
||||
title: 'A Ruined Trap',
|
||||
isAvailable: function() {
|
||||
return Engine.activeModule == Outside && Outside.numBuilding('trap') > 0;
|
||||
return Engine.activeModule == Outside && $SM.get('game.buildings["trap"]', true) > 0;
|
||||
},
|
||||
scenes: {
|
||||
'start': {
|
||||
@@ -14,8 +14,8 @@ Events.Outside = [
|
||||
'large prints lead away, into the forest.'
|
||||
],
|
||||
onLoad: function() {
|
||||
var numWrecked = Math.floor(Math.random() * Outside.numBuilding('trap')) + 1;
|
||||
Outside.addBuilding('trap', -numWrecked);
|
||||
var numWrecked = Math.floor(Math.random() * $SM.get('game.buildings["trap"]', true)) + 1;
|
||||
$SM.add('game.buildings["trap"]', -numWrecked);
|
||||
Outside.updateVillage();
|
||||
Outside.updateTrapButton();
|
||||
},
|
||||
@@ -66,7 +66,7 @@ Events.Outside = [
|
||||
{ /* Sickness */
|
||||
title: 'Sickness',
|
||||
isAvailable: function() {
|
||||
return Engine.activeModule == Outside && Outside.getPopulation() > 10 && Outside.getPopulation() < 50;
|
||||
return Engine.activeModule == Outside && $SM.get('game.population', true) > 10 && $SM.get('game.population', true) < 50;
|
||||
},
|
||||
scenes: {
|
||||
'start': {
|
||||
@@ -120,7 +120,7 @@ Events.Outside = [
|
||||
{ /* Plague */
|
||||
title: 'Plague',
|
||||
isAvailable: function() {
|
||||
return Engine.activeModule == Outside && Outside.getPopulation() > 50;
|
||||
return Engine.activeModule == Outside && $SM.get('game.population', true) > 50;
|
||||
},
|
||||
scenes: {
|
||||
'start': {
|
||||
@@ -180,7 +180,7 @@ Events.Outside = [
|
||||
{ /* Beast attack */
|
||||
title: 'A Beast Attack',
|
||||
isAvailable: function() {
|
||||
return Engine.activeModule == Outside && Outside.getPopulation() > 0;
|
||||
return Engine.activeModule == Outside && $SM.get('game.population', true) > 0;
|
||||
},
|
||||
scenes: {
|
||||
'start': {
|
||||
@@ -211,7 +211,7 @@ Events.Outside = [
|
||||
{ /* Soldier attack */
|
||||
title: 'A Military Raid',
|
||||
isAvailable: function() {
|
||||
return Engine.activeModule == Outside && Outside.getPopulation() > 0 && $SM.get('game.cityCleared');;
|
||||
return Engine.activeModule == Outside && $SM.get('game.population', true) > 0 && $SM.get('game.cityCleared');;
|
||||
},
|
||||
scenes: {
|
||||
'start': {
|
||||
|
||||
Reference in New Issue
Block a user