Commit Graph

103 Commits

Author SHA1 Message Date
Marty-D
167ee1d00d Move the multi-target modifier to the right place. 2013-01-30 12:04:02 -05:00
Guangcong Luo
561393658b Fix Spite 2013-01-29 14:55:24 -08:00
Guangcong Luo
6634330e78 Make it possible for moves to deal 0 damage 2013-01-29 14:33:26 -08:00
Cathy J. Fitzpatrick
1aa3ffed4b Add debug message for spread modifier 2013-01-29 02:43:51 -07:00
Guangcong Luo
9bb1731562 Developer console now supports battle events
In other words, if messages etc show up as a consequence of using the
>>> developer console, they'll actually appear instead of being
suppressed.
2013-01-28 10:42:46 -08:00
Guangcong Luo
a475ea5901 Fix Beat Up crash 2013-01-28 10:27:01 -08:00
Guangcong Luo
8e4ba6a585 Team preview works with less than 6 pokemon now 2013-01-28 09:37:29 -08:00
Guangcong Luo
7f5cfe584a Implement Fusion Bolt and Fusion Flare 2013-01-27 15:44:04 -08:00
Cathy J. Fitzpatrick
9d6f936a0d Don't resend request in case of wrong rqid
It is not actually necessary to resend the request if the rqid
is wrong because the player will have received the request after
sending in the move, so the client will still be in the move
selection phase.
2013-01-26 13:24:43 -07:00
Cathy J. Fitzpatrick
9b3e433bc7 Actually fix bug causing crashes on live server
The following sequence of events was causing a crash:

1) User sends in decision to server (with the wrong rqid specified).
2) Server receives decision and sends message M to simulator process.
3) User leaves battle and sends the server a message to inform of this.
4) Server removes the user from his or her battle in the main process,
   which sets the user's entry in simulator.player to null.
5) The simulator process processes message M and, since the rqid in
   the decision is wrong, send a resendrequest message back to the
   main process.
6) The main process in resendRequest() tries to access properties of
   the player, which are now null as of event (4), causing a crash.

This commit fixes the problem by making sure that user is not null
before accessing its properties.
2013-01-26 12:49:21 -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
Guangcong Luo
3b0ddd2b4d Implement Pledges
This introduces a new function battle.prioritizeQueue which
will move a decision to the front of the queue
2013-01-26 09:22:04 -08:00
Cathy J. Fitzpatrick
0ab7d87af0 Refactor requiring the client to ack requests
This refactored version checks the rqid as part of the decision
data, rather than introducing a new /ackrequest command. This
change is done in a backward-compatible way.

Most of the code does not change compared to the previous version.

The corresponding client commit is Zarel/Pokemon-Showdown-Client@3b82cf5cec
2013-01-25 12:22:34 -07:00
Guangcong Luo
23e25c0b4b Fix Ditto with new Hidden Power code 2013-01-25 07:35:40 -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
b67454743b Hidden Power fix:
- Random battles and automatic detection sets Hidden Power IVs correctly
- Hidden Power now always does damage based on user's IVs
- User's Hidden Power base power is now reported
2013-01-24 15:03:04 -08:00
Guangcong Luo
b49b86a1ab Fix a bunch of bugs in the stats refactor 2013-01-21 15:24:16 -08:00
Guangcong Luo
7fa7f24a39 Refactor how stats are calculated
They're now read on-the-fly instead of being recalculated and cached
every update.
2013-01-21 11:49:22 -08:00
Guangcong Luo
1a275479a2 Refactor runEvent for readability 2013-01-21 11:49:21 -08:00
Cathy J. Fitzpatrick
31faa73e96 Refactored getTarget and validTargetLoc. 2013-01-21 07:44:35 -07:00
Cathy J. Fitzpatrick
6b16dd6139 Fix redirection of randomNormal target moves.
Previously, Follow Me (and anything else that redirects moves, such as
various abilities) was unable to redirect the target of a
'randomNormal' target move, because validTargetLoc() always returned
false for a 'randomNormal' type move; this reflects the fact that the
client is not allowed to specify the target for such a move, because it
is chosen randomly. However, the internal game logic does need to be
able to specify a target for 'randomNormal' moves.

This commit adds a new parameter to validTargetLoc that specifies whether
the proposed target was chosen by the client or by the internal game logic.
If the proposed target was chosen by the internal game logic, then the same
targeting rules apply as in the case of a "normal" target move.

Note that it is necessary to add this new parameter, rather than just making
'randomNormal' behave the same as 'normal', because without the userSelected
check, a user could send a crafted choice string to the server specifying a
target for a 'randomNormal' move, and the server would respect the choice.
This implementation correctly prevents the client from specifying the target
of a 'randomNormal' move.
2013-01-21 00:04:21 -07:00
Guangcong Luo
b2ace51c59 Make sure Mold Breaker nullifies Snow Cloak and Sand Veil 2013-01-14 19:23:15 -08:00
Guangcong Luo
7bfae196eb Fix crash in obscure situations with 1 pokemon
(It would previously crash if you used U-turn in doubles with a starting
team of 1 pokemon)
2013-01-14 19:18:59 -08:00
Guangcong Luo
f6f2d0febc Properly fix spread hits and damage reduction 2013-01-11 16:03:51 -08:00
Guangcong Luo
14f8460755 Don't do redundant checks for fainted pokemon switching 2013-01-10 02:14:15 -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
13aafe2909 New battle timer 2013-01-09 00:31:07 -08:00
Marty-D
01906be31e Fix Normal Gem + Explosion, Red Card / Eject Button for real. 2013-01-08 12:01:00 -05:00
Marty-D
6022285639 Fix Red Card and Eject Button activating after fainting. 2013-01-04 12:16:11 -05:00
Guangcong Luo
cdd3af07c1 Implement Safeguard preventing confusion 2013-01-02 07:59:38 -08:00
Marty-D
d1aab22862 Recoil damage rounds half up in Gen 5. 2012-12-22 15:50:44 -05:00
Guangcong Luo
2b0c0f6358 NEXT: Buff and nerf a bunch of stuff
buff Eelektross, Claydol, Cryogonal
buff Bide, Steel Wing, Marvel Scale, Withdraw, Water Veil
nerf Sheer Force
change Relic Song, Snore, Armor abilities
2012-12-18 19:38:34 -08:00
Guangcong Luo
fd512f4fc4 More efficient toId implementation 2012-12-14 19:05:30 -08:00
Guangcong Luo
cae58c2fde More consistent name validation 2012-12-14 18:58:18 -08:00
Guangcong Luo
2575c53797 Fix sub-ordered events from firing backwards 2012-12-14 15:02:01 -08:00
Guangcong Luo
4c0d6ec85c Make sure events happen in Speed order 2012-12-14 14:44:55 -08:00
Guangcong Luo
7ed88a77a3 New seasonal ladder: Winter Wonderland 2012-12-14 14:44:55 -08:00
Guangcong Luo
8d5f2884ca Fix Baton Pass circumventing Natural Cure and Regenerator 2012-12-14 06:57:13 -08:00
Guangcong Luo
5922f301c7 Implement Power Split and Guard Split 2012-12-14 02:42:24 -08:00
Guangcong Luo
5adb75956d Choose first four in VGC before Illusion activates 2012-12-13 15:11:32 -08:00
Guangcong Luo
54bcd9ab33 Make sure a Pokemon faints properly after using Explosion 2012-12-13 04:10:14 -08:00
Guangcong Luo
7ed807aacc Fix crash with one pokemon in doubles 2012-12-13 03:11:44 -08:00
Guangcong Luo
02d2c1cba8 Normal Gem Explosion now works correctly 2012-12-13 02:26:13 -08:00
Guangcong Luo
d218cc9871 Fix some crashes from bringing 1 pokemon to doubles
(there are still others, it is still not possible to do so yet)
2012-12-13 02:25:52 -08:00
Guangcong Luo
6f96a06440 Allow underleveled pokemon at level 50 if forced by VGC rules
(also add item clause to VGC)
2012-12-12 15:51:02 -08:00
Guangcong Luo
3b7c1c6dbb Filter out empty moves from a moveset
- this makes sure Last Resort works correctly
2012-12-12 12:44:54 -08:00
Guangcong Luo
7625846be7 Proper implementation of Follow Me, Lightningrod et al. 2012-12-12 11:55:30 -08:00