Commit Graph

211 Commits

Author SHA1 Message Date
小太
5c8fc7b982 Space after function for anonymous functions 2014-04-22 01:58:16 +10:00
小太
6fb3bc332a Spaces around operators and === instead of == 2014-04-22 01:56:11 +10:00
Slayer95
05e7060474 Deprecate 'toUserid' global
Replaced by 'toId'.
2014-04-18 16:49:16 -05:00
Slayer95
75559362b4 Rename global config to Config 2014-04-17 01:12:28 -04:00
Guangcong Luo
692f47fc0a Support dynamically spawning simulator processes 2014-04-17 00:16:15 -04:00
小太
4f6a3e9c36 Merge remote-tracking branch 'upstream/master' into tournaments-frontend
Conflicts:
	package.json
2014-03-10 12:15:35 +11:00
Tyler Stark
bff353cc58 Second Pass at cleaning up the code. These are pretty safe edits that include adding 0 to decimal values, fixing variables that are declared multiple times, and removing duplicate keys 2014-02-09 23:38:57 -06:00
Tyler Stark
afb3dc0c09 First pass at code quality: adding semicolons. 2014-02-09 20:35:42 -06:00
小太
f9101abbe7 Merge remote-tracking branch 'upstream/master' into tournaments-frontend
Conflicts:
	package.json
2014-02-03 00:24:23 +11:00
Guangcong Luo
1b0b3ec63b Optimize team validator
The main process no longer does any JSON parsing/stringifying of
teams. The communication protocol with validator processes has
been changed from JSON to a string protocol delimited by pipes.

A variety of more minor optimizations have also been done.
2014-01-23 21:35:26 -08:00
小太
250aeb3260 Merge branch 'tournaments' into tournaments-frontend
Conflicts:
	app.js
2013-09-16 16:05:45 +10:00
Guangcong Luo
ae62e9e737 Update ResourceMonitor to control bandwidth 2013-09-01 02:37:35 -07:00
小太
f2f973fe29 Obliterate trailing whitespace 2013-08-18 21:33:15 +10:00
小太
24279166b3 Core file edits to support frontend 2013-08-07 23:22:07 +10:00
Guangcong Luo
15297f2c0f Less logging 2013-07-12 22:32:10 -07:00
Guangcong Luo
238a709f3b Rename battles.js to battle-engine.js 2013-05-24 20:50:30 -07:00
Guangcong Luo
27be062395 Tons of documentation 2013-05-24 14:59:29 -07:00
Guangcong Luo
9f79b1423e Switch to new protocol 2013-05-22 20:43:13 -07:00
Guangcong Luo
355f906e3f Fix timer issue 2013-05-01 03:05:00 -07:00
Cathy J. Fitzpatrick
3b6d0792f9 Fix rejoining battles 2013-04-21 18:42:28 -06:00
Cathy J. Fitzpatrick
a0dc8bb12a Fix /potd 2013-04-14 17:48:38 -06:00
Cathy J. Fitzpatrick
7b98429a75 Implement /hotpatch battles 2013-04-14 17:46:39 -06:00
Cathy J. Fitzpatrick
31fac973e0 Correct trapping mechanics
This doesn't yet handle modded formats that don't validate ability
selection in the ordinary manner. Those formats will continue to work
essentially in the same manner as before, rather than with the correct
mechanics.
2013-04-10 21:19:35 -06:00
Cathy J. Fitzpatrick
6259cd8ed0 Implement multiple simulator processes 2013-02-22 23:14:00 -07:00
Cathy J. Fitzpatrick
6e54bccb16 Commit missing file for last commit
I accidentally forgot to commit the other file for Zarel/Pokemon-Showdown@9b3e433bc7
2013-01-26 13:01:58 -07:00
Cathy J. Fitzpatrick
923498e7ba Reinstate stopgap for now
On further analysis, I'm not sure what the bug is here so I will
leave in the stopgap until is more thoroughly analysed.
2013-01-26 12:36:51 -07:00
Cathy J. Fitzpatrick
5b74e24a90 Fix bug causing crashes
Previously, Simulator.prototype.resendRequest() called user.sendTo()
with an invalid room specified, causing the server to send the
message to all rooms, leading to problems on the live server.
2013-01-26 12:26:30 -07:00
Guangcong Luo
1d9b1a5852 Stopgap fix for server crash 2013-01-26 10:44:33 -08:00
Cathy J. Fitzpatrick
f09d287070 Require client to acknowledge requests
In certain laggy situations, the following sequence of events
was previously possible in a battle:

1) Server makes request R_1 and R_2.
2) User 1 selects decision D_1 for request R_1
3) User 2 selects decision D_2 for request R_2
4) Server receives D_1 and D_2 and runs the turn
5) Server makes request R_3 and R_4.
4) Due to lag, User 1 does not realise that the server has
   already run the turn. User 1 wants to change his or her move
   for request R_1, so User 1 cancels decision D_1 and sends in
   decision D_3, intending it to be for request R_1.
5) User 2 selects decision D_4 for R_4.
6) Server receives D_3 and considers it to be the response to R_3,
   rather than the response to R_1 (which was what User 1 intended).
7) Server receives D_4 and considers it to be the response to R_4.
8) Server runs the turn.

The result of this sequence of events is that a move that User 1
intended to be for request R_1 is instead used for R_3, which has
the effect of depriving the user of the ability to make a reasoned
choice of which move to use for R_3.

This commit attempts to solve this problem by requiring the client
to acknowledge having received a request before the server will
accept a decision for that request.

Unfortunately, there is no seamless way to implement this in a
backward-compatible way. In other words, if the client were updated
to always send acks, it would no longer be able to work with old
versions of the server. For example, if the ack were added to the
choice string, old servers would no longer be able to handle choice
strings sent from the client. Similarly, if the ack were added
in the form of a new command (say, /ackrequest), old servers would
emit an unrecognised command error on receiving the command.

This commit maintains backward-compatibility by introducing a version
field to the init data structure sent to the client when joining a
battle room. This version should be incremented for any future
backward-incompatible changes as well.

The implementation of the ack request system is that the client must
send in "/ackrequest rqid" for each request, where rqid is the ID of
the request. If the server has not received an ack for request 'rqid'
when it receives a decision for request 'rqid', it discards the
decision and asks the client for another decision.

The corresponding client commit is Zarel/Pokemon-Showdown-Client@ccf0a97733
2013-01-25 01:19:03 -07:00
Guangcong Luo
68c989907a /potd is supported again
I've introduced a new function: Simulator.eval, which allows chat
commands to evaluate raw JavaScript in the simulator process.
2013-01-24 15:03:04 -08:00
Guangcong Luo
42abd07ef0 Fix where the timer messages appear
(timer messages should be much less confusing now)
2013-01-10 02:02:02 -08:00
Guangcong Luo
d4ab09b9f7 Fix some bugs with the reset timer 2013-01-10 00:50:20 -08:00
Guangcong Luo
13aafe2909 New battle timer 2013-01-09 00:31:07 -08:00
Guangcong Luo
248446d1c2 Making an invalid choice no longer restarts the kick timer
(it could previously be abused to postpone a turn indefinitely)
2012-11-19 14:44:59 -08:00
Guangcong Luo
cf8e19789b Make sure users can always continue playing after rejoining 2012-11-06 22:31:32 -08:00
Guangcong Luo
3187dee583 Fix /forcetie 2012-09-15 21:43:03 -07:00
Guangcong Luo
66b86f9678 Don't mark rooms as active if they're not 2012-08-01 23:23:18 -07:00
Guangcong Luo
60ca007255 Many stability improvements 2012-08-01 23:08:55 -07:00
Guangcong Luo
97a3977106 Fix team preview not working 2012-08-01 18:19:57 -07:00
Guangcong Luo
3714979815 Many fixes to multi-process system:
- crashes mostly gone
- teams work
- debug console available for battle process (use >>>)
2012-08-01 16:29:49 -07:00
Guangcong Luo
c47eb6b160 Battle process properly deallocates itself 2012-08-01 13:56:48 -07:00
Guangcong Luo
4831e68a8c Multi-process battles!
Battles now occur in a separate process.
Hopefully, this results in a substantial increase in network stability.
WARNING: Battle crashes are now practically unrecoverable.
2012-08-01 13:48:58 -07:00
Guangcong Luo
31e642c5a2 Rename simulator.js to battles.js 2012-07-31 19:48:09 -07:00
Bill Meltsner
d92c7e9ffb Update some out of date Baton Pass-related code.
Fixes Pursuit interacting incorrectly with Baton Pass (that is, at all).

I think this code breaks Baton Pass + Regenerator/Natural Cure, though.
2012-07-17 01:34:24 -05:00
Guangcong Luo
59846cc0ba Fewer debug messages:
Pokemon and Side allocation messages hidden
2012-07-16 22:52:03 -07:00
Bill Meltsner
29d4511c45 Hack in Foul Play.
This implementation sucks and should be replaced with a proper one as soon as the new damage formula is implemented.
2012-07-16 00:23:47 -05:00
TheImmortal
71a386447f Correct immunity message 2012-07-15 18:38:15 +04:00
Guangcong Luo
99aba198c9 Fix many switch-order bugs:
- In double-switches, abilities now activate before the second switch
- When starting or double-faint, abilities activate after all switches
  in speed order
- Double-switches now happen in speed order of the switch-outs
2012-07-11 18:35:43 -04:00
Guangcong Luo
d753365d8e Make sure Trace can't make the Start event happen twice
(This fixes the double-Intimidate when Traced bug)
2012-07-11 17:38:58 -04:00
Bill Meltsner
2e75e80bc0 Enable happiness when creating a Pokemon, and actually derive Frustration/Return's base power from it. 2012-07-10 18:16:13 -05:00