Commit Graph

349 Commits

Author SHA1 Message Date
LucidCrux 2e3f8abd3f add $SM.setget, refactor Room to better use $SM
game.room.builder >> game.builder.level

setget is mainly for use in local copies of states, useful for keeping
code cleaner and less redundant while maintaining set/get of states by
the $SM

====functions refactored====
Room.unlockForext //remove update calls
Room.buy //remove update calls
Room.build //remove update calls
Room.cooFire //added locals to reduce gets
Room.adjustTemp //added locals to reduce gets
Room.updateBuilderState //added local to reduce gets
Room.craftUnlocked //Room unlock is always going to be true, don't need
to check parents to avoid errors anymore
Room.buyUnlocked //Room unlock is always going to be true, don't need to
check parents to avoid errors anymore
2013-07-25 20:31:30 -06:00
LucidCrux f4520bce91 speed up and bug fix 2013-07-25 02:00:41 -06:00
LucidCrux 766d3879c7 Merge remote-tracking branch 'origin/master' into state_manager_2
Conflicts:
	script/events.js
2013-07-24 21:01:59 -06:00
LucidCrux 2018ca3ae8 create and configure callback handlers for state updates
add $.Dispatch to handle object events
add subscribe calls to files
update SM fireUpdate to use new Dispatch

There are some NaN issues right now, no time to bug hunt right now, it
does kind of function though
2013-07-24 18:33:06 -06:00
LucidCrux dee7cbb9b3 refactor Engine.js for use with $SM
====functions removed====
//I just removed these because most were simpler or at least equal as
	direct $SM get/set/add calls, I realize the store ones are kind of
	subjective since calls were about equal, but oh well. If someone
	really 	feels we need the shortcut/named functions for manipulating
	stores specifically, it shouldn't be crazy to reimplement in $SM 
Engine.setStore >> $SM.set
Engine.setStores >> $SM.setM
Engine.addStore >> $SM.add
Engine.addStores >> $SM.addM
Engine.getStore >> $SM.get(requestZero = true)
Engine.storeAvailable >> $SM.get;
Engine.removeIncome >> $SM.remove //updates moved to handler


====functions moved====
//Any moved function I felt was more directly related to States or
	didn't belong where it was
Engine.addPerk > $SM.addPerk //kept function for now because of notify
	call inside, 'deep' state
Engine.hasPerk > $SM.hasPerk //kept function because of 'deep' state
	name
Engine.setIncome > $SM.setIncome //kept because it has internal logic
**Engine.getIncome > $SM.getIncome //**easily removable with
	Outside.updateVillageIncome refactor
Engine.openPath > Path.openPath //Since I'm refactoring anyways
Engine.addStolen > $SM.addStolen //internal logic
Engine.startThieves > $SM.startThieves //not sure $SM is a better place,
	but Engine should be nice and clean by the end of this, handling
	only engine mechanics
Engine.num > $SM.num //after Outside refacter, this is basically just a
	fancy $SM.get
Engine.upgradeState > $SM.updateOldState


====functions refactored====
$SM.addPerk; //updates moved to event handler, no check/create new perk
$SM.hasPerk; //don't need to check exist and ==true
$SM.collectIncome //removed changed check, update calls now handled by
	'stateUpdate' event listening
$SM.addStolen //fix to set stolen items in case a partial steal happens
$SM.startThieves //updates in handler
$SM.updateOldState //use $SM calls, add placeholder for updating to post
$SM state when more finalized 


====functions affected (by removed)====
Engine.init (Engine.getStore, Engine.storeAvailable)
Engine.collectIncome (Engine.addStores)
Engine.num (Engine.getStore)
Engine.travelTo (Engine.storeAvailable)

Room.init (Engine.getStore)
Room.unlockForest (Engine.setStore)
Room.lightFire (Engine.setStore, Engine.getStore, Engine.storeAvailable)
Room.stokeFire (Engine.setStore, Engine.getStore, Engine.storeAvailable)
Room.coolFire (Engine.setStore)
Room.buy (Engine.setStores, Engine.addStore, Engine.getStore)
Room.build (Engine.setStores, Engine.getStore)
Room.craftUnlocked (Engine.getStore, Engine.storeAvailable)
Room.buyUnlocked (Engine.storeAvailable)
Room.updateButton (Engine.storeAvailable)

Outside.gatherWood (Engine.addStores)
Outside.checkTraps (Engine.addStores, Engine.getStore)
Outside.updateVillage (Engine.getStore)

Path.embark (Engine.addStore)
Path.getCapacity (Engine.getStore)
Path.updateOutfitting (Engine.getStore)
Path.createOutfittingRow (Engine.getStore)
Path.increaseSupply (Engine.getStore)

World.goHome (Engine.addStore)
World.updateSupplies (Engine.getStore)
World.checkDanger (Engine.getStore)
World.getMaxHealth (Engine.getStore)
World.getMaxWater (Engine.getStore)

Ship.reinforceHull (Engine.addStore, Engine.getStore)
Ship.upgradeEngine (Engine.addStore, Engine.getStore)

Events.loadScene (Engine.addStores)
Events.updateButtons (Engine.getStore)
Events.buttonClick (Engine.getStore)

Events.Global (Engine.addStores, Engine.removeIncome)
Events.Room (Engine.addStore, Engine.addStores, Engine.getStore,
Engine.storeAvailable)
2013-07-24 17:41:36 -06:00
Steve Hayes 253f946dbd IE<8 Fixes: Removed trailing commas in string literals and renamed variable char to chara 2013-07-23 23:54:06 -04:00
LucidCrux db4a346d21 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
2013-07-23 01:24:47 -06:00
Zarkonnen 7bf744e386 Fixed issue #42 by fixing wrong city exploration setpiece data. 2013-07-17 09:56:31 +02:00
Michael Townsend 252b731666 Merge pull request #39 from toofarapart/improved_item_dropping
events.js: Item dropping improvements
2013-07-15 08:43:47 -07:00
Matt Rasmus e80fc4d286 events.js: Item dropping improvements
Item drop menu no longer disappears after clicking to drop something.
2013-07-13 17:00:57 -07:00
Zarkonnen 25f1fff6a1 Laser rifles are now listed as weapons, fixing issue #37. 2013-07-13 21:42:15 +02:00
Matt Rasmus 22b850f1c0 outside.js: Fix incorrect display of workers.
Fixed an issue where the workers view would break temporarily if all the villagers were killed.
2013-07-10 17:56:15 -07:00
Michael Townsend 93f8e52e1f Merge pull request #30 from Zarkonnen/medicine
Medicine
2013-07-10 12:07:05 -07:00
Zarkonnen 3515cbf75f Removed mentions of "you". 2013-07-10 20:50:42 +02:00
Michael Townsend 8cb64ad3d8 Merge pull request #29 from Cogito/roadDrawing
Road drawing improvements
2013-07-10 10:57:13 -07:00
Zarkonnen d4034fe244 Fixed hospital never occurring in city. 2013-07-10 15:10:43 +02:00
Zarkonnen bb953de92b Finished first version of medicine feature. 2013-07-10 12:53:28 +02:00
Andrew Ardill 255bdd68fc world.js: Improve road drawing algorithm
Instead of drawing an 'L' shape road to the village, find the closest road,
outpost or village and draw the road to it. Care is taken to ensure that a
road is drawn if you are standing on top of an outpost, as the outpost may be
created before the tile it stands on is connected to the road network.
2013-07-10 20:52:18 +10:00
Andrew Ardill 26b955fee8 world.js: Increase functionality of getDistance
Allow passing 'from' and 'to' positions to getDistance to find the distance
between them.
2013-07-10 20:52:18 +10:00
Andrew Ardill c4afe143a9 world.js: Introduce World.VILLAGE_POS
This constant gets reused in a few places, so extract it out. Work will be
required to migrate existing code away from hard coding World.RADIUS in places
where we are talking about the village location.
2013-07-10 20:52:18 +10:00
Andrew Ardill b97f5d9914 world.js: Introduce function to copy positions 2013-07-10 20:52:17 +10:00
Michael Townsend 05fef5664d Merge pull request #27 from toofarapart/fade_to_black
(SPOILERS) A nice fade to black...
2013-07-09 19:47:45 -07:00
Michael Townsend f56697d9d0 Merge pull request #25 from toofarapart/persistent_stores_view
Stores panel now persists on all non-world/non-space views.
2013-07-08 14:25:20 -07:00
Matt Rasmus eaf2fcdfbb Keep showing the weapons panel while in the Path screen. 2013-07-08 13:58:16 -07:00
Matt Rasmus de2ad91053 Weapons panel hides when not in Room. 2013-07-08 13:10:49 -07:00
Michael Townsend b8dd1125d4 Merge pull request #21 from Zarkonnen/master
Converted zero/max buttons to +-10 buttons
2013-07-08 12:45:01 -07:00
Zarkonnen 4334f36e57 Bugfixes. 2013-07-08 21:39:28 +02:00
Zarkonnen 4641b0b145 Initial medicine implementation. Needs more events. 2013-07-08 19:16:16 +02:00
Matt Rasmus 0b6144660f Fixed a bug in which the share/restart buttons would disappear in certain situations. 2013-07-07 13:25:30 -07:00
Matt Rasmus 4326b2aa2a Game fades to black at the end, and stays that way until the player clicks restart. 2013-07-07 11:41:51 -07:00
Michael Townsend 54cea31db9 Merge pull request #26 from dhutty/patch-1
spelling
2013-07-07 09:09:42 -07:00
Michael Townsend 53ff72d218 Merge pull request #24 from jvantuyl/master
a grammar fix
2013-07-07 09:07:38 -07:00
dhutty aeedc5d10c spelling 2013-07-07 10:18:59 -04:00
Matt Rasmus 8dabee851d Stores panel now persists on all non-world/non-space views. 2013-07-06 14:56:27 -07:00
Jayson Vantuyl 536f09dce3 a grammar fix
"bundle of sticks", not "bundle of stick"
2013-07-06 13:53:33 -07:00
Michael Townsend 12258689e8 Merge pull request #22 from engstrom/master
Moved EatMeatButton to beginning of combat UI
2013-07-06 09:53:24 -07:00
Michael Townsend 95fddcbb2c Merge pull request #20 from evilDave/swipes
Added swipe support
2013-07-06 09:51:54 -07:00
Jayson Vantuyl b14ad39c5a minor spelling fix 2013-07-05 23:43:43 -07:00
engstrom fa655aef1c Moved EatMeatButton to beginning of combat UI 2013-07-05 18:41:22 -06:00
David Clark e9679b3f26 Add swipe support. Modules can implement swipeLeft (etc). Swipes control movement in the World module (map). 2013-07-05 22:36:49 +10:00
Zarkonnen ae044376db Converted min/max buttons to +-10 buttons. Also made code shorter. 2013-07-05 13:47:23 +02:00
Michael Townsend 98719ccf0c Merge pull request #13 from Zarkonnen/master
Max/zero buttons
2013-07-04 07:50:07 -07:00
Michael Townsend 6a7df4d17c Fixed non-combat meat eating 2013-07-04 07:28:19 -07:00
Zarkonnen 6d99cb7c3a Added max/zero buttons to worker assignment and expedition supply packing to prevent eg having to click 50x to fill food supplies. 2013-07-04 16:15:29 +02:00
Michael Townsend cab220a5ac Merge pull request #10 from dmnd/master
Add an 'eat meat' button to the loot screen
2013-07-04 06:59:09 -07:00
Desmond Brand a86c61aaf0 Add an 'eat meat' button to the loot screen
When I played this, I would often madly try to click the 'eat meat' button
after I won a fight, only to have the 'leave' button appear in its place,
causing me to lose my chance at both healing and looting.

This patch adds an 'eat meat' button to the loot screen to avoid this UI
problem.
2013-07-04 02:56:54 -07:00
Andrew Ardill 6fb7f248f7 world.js: Trigger movement with clicks on the map
Clicking on the map in different quadrants will move you in that direction.
Clicks are measured relative to the centre of the current location centre of
the map. Click above the player to move up, click below to move down etc.

This should enable better gameplay on touch devices.
2013-07-04 16:13:30 +10:00
Andrew Ardill d0a171e95b world.js: Refactor move commands out of keyDown
In order to better handle move commands, refactor them out of the keyDown
event handler. This will enable using other input methods to trigger a move
command, such as mouse clicks or touch events.
2013-07-04 14:49:21 +10:00
Michael Townsend 19abccfcc4 Adding ADR to Github 2013-07-03 07:56:13 -07:00