mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-28 08:11:54 +08:00
db4a346d21
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
65 lines
1.7 KiB
JavaScript
65 lines
1.7 KiB
JavaScript
/**
|
|
* Events that can occur when any module is active (Except World. It's special.)
|
|
**/
|
|
Events.Global = [
|
|
{ /* The Thief */
|
|
title: 'The Thief',
|
|
isAvailable: function() {
|
|
return (Engine.activeModule == Room || Engine.activeModule == Outside) && $SM.get('game.thieves') == 1;
|
|
},
|
|
scenes: {
|
|
'start': {
|
|
text: [
|
|
'the villagers haul a filthy man out of the store room.',
|
|
"say his folk have been skimming the supplies.",
|
|
'say he should be strung up as an example.'
|
|
],
|
|
notification: 'a thief is caught',
|
|
buttons: {
|
|
'kill': {
|
|
text: 'hang him',
|
|
nextScene: {1: 'hang'}
|
|
},
|
|
'spare': {
|
|
text: 'spare him',
|
|
nextScene: {1: 'spare'}
|
|
}
|
|
}
|
|
},
|
|
'hang': {
|
|
text: [
|
|
'the villagers hang the thief high in front of the store room.',
|
|
'the point is made. in the next few days, the missing supplies are returned.'
|
|
],
|
|
onLoad: function() {
|
|
$SM.set('game.thieves', 2);
|
|
Engine.removeIncome('thieves');
|
|
Engine.addStores($SM.get('game.stolen'));
|
|
},
|
|
buttons: {
|
|
'leave': {
|
|
text: 'leave',
|
|
nextScene: 'end'
|
|
}
|
|
}
|
|
},
|
|
'spare': {
|
|
text: [
|
|
"the man says he's grateful. says he won't come around any more.",
|
|
"shares what he knows about sneaking before he goes."
|
|
],
|
|
onLoad: function() {
|
|
$SM.set('game.thieves', 2);
|
|
Engine.removeIncome('thieves');
|
|
Engine.addPerk('stealthy');
|
|
},
|
|
buttons: {
|
|
'leave': {
|
|
text: 'leave',
|
|
nextScene: 'end'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]; |