Commit Graph

49 Commits

Author SHA1 Message Date
Andrea Rendine aae770c5a1 Timing for winning and efficiency 2016-02-16 11:02:10 +01:00
Andrea Rendine 24e744a27e Heal when necessary
Events.setHeal() enables/disables eatMeat and useMeds buttons depending on player's HP.
The check is done in 4 cases:

* when a fight starts
* after an attack
* after healing
* in the loot screen
2016-02-16 03:02:45 +01:00
Andrea Rendine aa62b7f9be Buttons positioning 2
The last 2 remainings from original structure
2016-02-16 02:58:51 +01:00
Andrea Rendine bf7472ba37 Buttons positioning
Residual structure fixed.
2016-02-16 02:56:44 +01:00
Andrea Rendine 091929cf90 Cleanup
Events.damage method now groups all common lines for Events.animateRanged and Events.animateMelee.
Balance between success and failure is now determined by Events.lost. It is set to "true" when the player is killed and prevents Events.winFight() altogether.
Events.endFight() groups the 2 consistent actions in winFight and loseFight, i.e., pause unsetting and stopping the enemy.
Completely renewed trap method: instead of relying on a separate counter, enemy.data('stunned') now returns the number of remaining seconds of stunning. Enemy's timed attack decreases this value by the attack delay time (the enemy fights for its freedom).
2016-02-16 00:26:23 +01:00
AndySky21 6ace681a91 Pause during fight
This commit adds a pause button during the fight. It relies upon the new
Events.paused property: when set to true, no buttons will work except
the pause button itself, and cooldown on attack/healing buttons is
interrupted.
This commit also groups event buttons in different groups (attack,
healing, scene), so that the position of "eat meat" and "use meds" does
not depend on how many scene buttons are present (sometimes 1, other
times 2)
2016-02-15 21:04:02 +01:00
Andrea Rendine 65d7cfd784 Hyper-proof cooldown state
Kept the distinction between "argument" time and script time. I called the latter "time" instead of "milliseconds" because, well, it's just tenth of seconds.
Residual timeout is always stored in "nominal" time, not adjusted by hyper. I.e. if a button has a nominal timeout of 60 seconds and half cooldown had expired on reload, residual is stored as 300. In cooldown, Engine.setInterval makes the time flow with double speed
2015-06-29 12:49:57 -04:00
Andrea Rendine 7208b845b1 Take all, take everything, leave if possible
Multiple fixes:
1. take all of a kind
2. take everything
3. if possible, leave
4. drop menu on hover
5. Same item not shown as drop option
2015-06-27 02:13:14 -04:00
Andrea Rendine da0d39b579 Check for delayed events
This triggers onload for all those events whose (possible) reward is registered with a time delay.
2015-06-27 01:43:09 -04:00
wmassingham f94cfe2590 disable tab navigation during events (fixes #403) depends on @AndySky21's branch world-to-path 2015-06-27 00:26:40 -04:00
Andrea Rendine 64a02c162c Modified command destination for save
Export dialog replaces selection dialog, rather than overlapping it.
Closing it exits the panel and returns to current game.
Aborting Import dialog returns the player to the selection screen, so that s/he can save before trying to load.
2015-06-26 23:49:30 -04:00
Andrea Rendine de705e4a5e Load event before anything else
An event could produce different notifications or rewards according to different outcomes of the event itself (e.g. a negative event impacting on buildings and/or villagers, or a wanderer leaving items of some specific kind), but the notification is generated before the onLoad() call.
I'd say that this is the best action order:
1. event action
2. event notification
3. event reward (and possible additional notifications due to that)
2015-05-13 12:08:00 -04:00
Travis Weston 8c368d363a Add take all button 2015-05-13 11:35:25 -04:00
Andrea Rendine fb13f6e808 Notification before reward
Noticed when buying the compass.
I found it weird that *first* the compass points and *then* it appears in good condition.
Now event notification precedes event reward, and it should be corrected.
2015-05-11 10:16:43 -04:00
Travis Weston 6ee6470972 Merging updates 2015-02-11 18:55:27 -05:00
Blake Grotewold c87541b8b9 Merge pull request #222 from anubisthejackle/issue80 2015-02-09 19:37:10 -05:00
Travis Weston 6e044292ae Add in doubleTime capabilities
Add hyper / classic to menu
2015-02-09 19:31:24 -05:00
Blake Grotewold 5d921d9464 Merge pull request #204 from rgravina/188_fix_jshint_warnings 2015-02-09 19:25:08 -05:00
Robert Gravina 67b3c7fb7e Low-risk fixes suggested by JSHint. 2015-02-09 19:20:29 -05:00
Alex Liebscher 5d12670979 Prevent negative HP
Closes #201
2015-01-05 01:38:35 -05:00
Olexandr Nesterenko 465c636b5d Add new strings to localization 2014-08-26 16:57:25 +03:00
Michael Townsend 3852fbebb6 Prevent user from modifying the displayed export code 2014-08-13 19:25:42 -04:00
Michael Townsend 20539fdd18 Merge branch 'master' into title-blink 2014-07-29 18:20:10 -04:00
skj3gg e1f3d31dea Add variable for blink interval and remove unnecessary type checking
Cleans up global variable that was introduced in favor of a variable in
Events. Removes type checking from conditionals and instead sets
BLINK_INTERVAL variable to false when stopped.
2014-07-28 13:42:11 -04:00
skj3gg 79e765eb08 Blink only happens on specified events
Now event objects must have a blink flag if they want to use the title
blink. For starters, this is only global, outside, and room events.
2014-07-24 12:00:51 -04:00
Blake Grotewold d6a6a7a000 Add title blinking on events
When there is an event, blink the title so that a user can know when an
event happens, even if they aren't on that tab. From discussion in #121
2014-07-23 02:43:06 -04:00
Blake Grotewold 8ceb9488aa Add cooldown when leaving events
Adding this cooldown prevents users from accidently clicking leave or
continue before they have a chance to eat or collect loot.  This was
originally brought up in and resolves #8. May be of interest to #122 as
well
2014-07-23 02:02:05 -04:00
Travis Weston 82edff18b4 Fixing issue where buttons would not update when Wandering Nomad was active as referenced in Issue #108 2014-07-17 21:53:54 -04:00
Travis Weston 4b079a22f1 Fixed whitespace conformity in events.js 2014-07-13 00:49:38 -04:00
Michael 957dbdf0e5 merged 2014-05-19 12:44:30 -04:00
Michael 2ca0a7a948 Expand import dialog to a textarea 2014-05-19 11:48:40 -04:00
Vanadar c7ad5384f4 suite des trads 2014-02-07 18:26:03 +01:00
vanadar f986e0323e Start trad fr 2014-02-04 22:27:00 +01:00
Michael 16824386eb Use a textarea instead of a prompt for export to prevent truncation in
Chrome.
2013-11-14 21:33:14 -05:00
Michael dde477aade Some general code cleanup. 2013-10-10 20:53:53 -04:00
LucidCrux 99800f1abd 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
2013-07-26 19:21:12 -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
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 bb953de92b Finished first version of medicine feature. 2013-07-10 12:53:28 +02: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
engstrom fa655aef1c Moved EatMeatButton to beginning of combat UI 2013-07-05 18:41:22 -06:00
Michael Townsend 6a7df4d17c Fixed non-combat meat eating 2013-07-04 07:28:19 -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
Michael Townsend 19abccfcc4 Adding ADR to Github 2013-07-03 07:56:13 -07:00