-
Notifications
You must be signed in to change notification settings - Fork 1
/
EightyOneShogi.mxml
3488 lines (3312 loc) · 157 KB
/
EightyOneShogi.mxml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="1180" height="690" backgroundColor="0xcccc77" creationComplete="{initApp()}" xmlns:eightyOneSquare="*" frameRate="24" initialize="systemManager.stage.scaleMode=StageScaleMode.SHOW_ALL">
<mx:Style>
global{
layoutDirection: "ltr";
}
Alert {
fontSize: 13px;
color: Black;
backgroundColor: "0x99CCFF";
borderColor: "0x99CCFF";
}
ToolTip {
font-size: 13px;
font-weight: "bold";
backgroundColor: "0xFFDD00";
}
.header81 {
fontFamily: "Meiryo UI";
leading: 0;
font-weight: "bold";
}
</mx:Style>
<mx:Script>
<![CDATA[
import flash.display.*;
import flash.events.ContextMenuEvent;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.filters.ColorMatrixFilter;
import flash.geom.Point;
import flash.media.SoundTransform;
import flash.net.FileReference;
import flash.net.SharedObject;
import flash.net.URLLoader;
import flash.net.URLVariables;
import flash.ui.ContextMenu;
import flash.ui.Mouse;
import flash.utils.Timer;
import mx.utils.ObjectProxy;
import mx.containers.Canvas;
import mx.containers.utilityClasses.Flex;
import mx.events.FlexEvent;
import mx.events.CloseEvent;
import flash.media.Sound;
import mx.controls.*;
import mx.managers.PopUpManager;
import mx.core.IFlexDisplayObject;
import CsaShogiClient;
import ApiClient;
import InfoFetcher;
import Board;
import GameTimer;
import ChallengeForm;
import GameRuleEvent;
import User;
import Game;
import mx.utils.StringUtil;
import flash.system.Security;
public const VERSION:String = "ver.2011/09/25";
private const IMAGE_DIRECTORY:String = "http://49.212.52.151/dojo/images/";
private var _servers: Array = new Array();
public var serverName: String;
[Bindable]
public var lan:ObjectProxy;
private var _so:SharedObject = SharedObject.getLocal("81dojo");
private var _client:CsaShogiClient;
private var _api:ApiClient;
private var _viewerAlone:Boolean;
[Bindable]
private var _game_name:String;
private var _user_list:Array = new Array();
private var _users:Object = new Object();
private var _waiter_list:Array = new Array();
private var _game_list:Array = new Array();
private var _games:Object = new Object();
private var _watcher_list:Array = new Array();
private var _kifu_search_list:Array;
private var _player_search_list:Array;
private var _ranking_rate_list:Array;
private var _ranking_wins_list:Array;
private var _ranking_total_list:Array;
private var _ranking_percentage_list:Array;
private var _ranking_streak_list:Array;
private var _gameHistories:Array;
public var login_name:String;
private var _watch_game:Object;
private var _challengeUser:Object;
private var _monitoring:Boolean;
private var _waiting:Boolean = false;
private var _challenging:Boolean = false;
private var _shareKifuEnabled:Boolean = false;
private var _gameAccepted:Boolean = false;
private var _rematching:Boolean = false;
private var _leaving:Boolean = false;
private var _panelReplayColor:uint = 0xFF88CC;
private var _status_disconnected:Boolean = false;
private const arrow_comments:Array = new Array("", "Good move is this.", "My guess is this.", "How about this?", "This might not work.", "The aim here is this.");
[Embed(source = "/sound/win.mp3")]
private var Sound_win:Class;
private var _sound_win:Sound = new Sound_win();
[Embed(source = "/sound/lose.mp3")]
private var Sound_lose:Class;
private var _sound_lose:Sound = new Sound_lose();
[Embed(source = "/sound/chat_lobby.mp3")]
private var Sound_chat1:Class;
private var _sound_chat1:Sound = new Sound_chat1();
[Embed(source = "/sound/chat_board.mp3")]
private var Sound_chat2:Class;
private var _sound_chat2:Sound = new Sound_chat2();
[Embed(source = "/sound/chat_private.mp3")]
private var Sound_chat3:Class;
private var _sound_chat3:Sound = new Sound_chat3();
[Embed(source = "/sound/chat_auto.mp3")]
private var Sound_chat4:Class;
private var _sound_chat4:Sound = new Sound_chat4();
[Embed(source = "/sound/door_open.mp3")]
private var Sound_door_open:Class;
private var _sound_door_open:Sound = new Sound_door_open();
[Embed(source = "/sound/door_close.mp3")]
private var Sound_door_close:Class;
private var _sound_door_close:Sound = new Sound_door_close();
[Embed(source = "/sound/game_start.mp3")]
private var Sound_game_start:Class;
private var _sound_game_start:Sound = new Sound_game_start();
[Embed(source = "/sound/madoka_kitao/timeup.mp3")]
private var Sound_timeup:Class;
private var _sound_timeup:Sound = new Sound_timeup();
[Embed(source = "/sound/challenger.mp3")]
private var Sound_challenger:Class;
[Embed(source = "/images/earth.png")]
private var _icon_earth:Class
[Embed(source = "/images/moon.png")]
private var _icon_moon:Class
[Embed(source = "/images/mars.png")]
private var _icon_mars:Class
[Embed(source = "/images/venus.png")]
private var _icon_venus:Class
[Embed(source = "/images/mercury.png")]
private var _icon_mercury:Class
[Embed(source = "/images/saturn.png")]
private var _icon_saturn:Class
private var _sound_challenger:Sound = new Sound_challenger();
private var _end_sound_play:Boolean = true;
private var _chat_sound1_play:Boolean = true;
private var _chat_sound2_play:Boolean = true;
private var _chat_sound3_play:Boolean = true;
private var _prev_piece_type:int;
private var _pmAutoOpen:Boolean = false;
private var _accept_arrows:Boolean = true;
private var _arrow_color:uint = 0x00CC00;
private var _ignore_list:Array = new Array();
private var _favorite_list:Array = new Array();
private var _chat_auto_scroll1:Boolean = true;
private var _chat_auto_scroll2:Boolean = true;
private var _userMessageScrollPos1:int;
private var _userMessageScrollPos2:int;
private var _initPositionStr:String;
private var _idleTimer:Timer;
private var _pmRingTimer:Timer;
private var _keepAliveTimer:Timer;
private var _leaveTimer:Timer;
private var _leaveMinutes:int;
private var _leaveMessage:String;
private var _infoFetcher:InfoFetcher;
private var _pmLog:Object = new Object();
private var _pmRingBuffer:Array = new Array();
private var _allowWatcherChat:Boolean = false;
private var _adminLog:String = "";
private var _chatHistory:Array = new Array();
private var _nHistory:int = 0;
private var _mouseX:Number;
private var _mouseY:Number;
private var _optionWindow:OptionDialog;
private var _newGameWindow:NewGameForm;
private var _playerInfoWindows:Object = new Object();
private var _playerDetailWindow:PlayerDetailWindow;
private var _challengerAlertWindow:ChallengerAlertWindow;
private var _greetMenuWindow:GreetMenuWindow;
private var _gameResultWindow:GameResultWindow;
private var _leavePCWindow:LeavePCForm;
private var _kifuShareWindow:KifuShareWindow;
private var _impasseStatusWindow:ImpasseStatusWindow;
private var _disconnectAlertWindow:DisconnectAlertWindow;
private var _adminPanelWindow:AdminPanelWindow;
private function initApp():void
{
trace("application initialized..");
Security.loadPolicyFile('http://81dojo.com/crossdomain.xml');
_infoFetcher = new InfoFetcher();
board.setMoveCallback(_playerMove);
board.setTimeoutCallback(_checkTimeout);
board.setTimerLagCallback(_checkTimerLag);
board.setAddMyArrowCallback(_addMyArrow);
board.setHoverPieceCallback(_hoverPiece);
board.setGrabPieceCallback(_grabPiece);
_api = new ApiClient();
if (this.parameters["kid"]) {
languageSelector.readDefault()
login_name = "guest";
mainViewStack.selectedIndex = 2;
_viewerAlone = true;
_api.addEventListener(ApiClient.KIFU_DETAIL, _handleKifuDetail);
_api.kifuDetail(this.parameters["kid"]);
board.kid = this.parameters["kid"];
return;
}
_client = new CsaShogiClient();
serverListGrid.dataProvider = { 'name':"Loading..."};
var server:Object = { 'name':"EARTH", 'description':"main", 'icon':_icon_earth, 'host':"49.212.52.151", 'port':"4081", 'alive':"NO" };
_servers.push(server);
server = { 'name':"MARS", 'description':"sub", 'icon':_icon_mars, 'host':"81dojo.dyndns.org", 'port':"4081", 'alive':"NO" };
_servers.push(server);
server = { 'name':"VENUS", 'description':"sub", 'icon':_icon_venus, 'host':"49.212.52.151", 'port':"4082", 'alive':"NO" };
_servers.push(server);
server = { 'name':"SATURN", 'description':"3X4", 'icon':_icon_saturn, 'host':"49.212.52.151", 'port':"4083", 'alive':"NO" };
_servers.push(server);
server = { 'name':"MERCURY", 'description':"beta test", 'icon':_icon_mercury, 'host':"81dojo.com", 'port':"4081", 'alive':"NO" };
_servers.push(server);
server = { 'name':"MOON", 'description':"for admin", 'icon':_icon_moon, 'host':"127.0.0.1", 'port':"4081", 'alive':"YES" };
_servers.push(server);
if (_so.data.savelogin) {
savelogin.selected = true;
if (_so.data.login) loginname.text = _so.data.login;
if (_so.data.pass) password.text = _so.data.pass;
if (_so.data.language) languageSelector.selectedIndex = _so.data.language;
}
arrowComent.dataProvider = arrow_comments;
languageSelector.loadLanguage();
_api.addEventListener(ApiClient.READ_SERVER, _handleReadServer);
_api.readServer();
var date:Date = new Date();
kifuSearchToChooser.selectedDate = date;
date.setTime(date.getTime() - (1000 * 60 * 60 * 24 * 7));
kifuSearchFromChooser.selectedDate = date;
_client.addEventListener(CsaShogiClient.CONNECTED,_handleConnected);
_client.addEventListener(CsaShogiClient.LOGIN,_handleLoggedIn);
_client.addEventListener(CsaShogiClient.LOGIN_FAILED, _handleLoginFailed);
_client.addEventListener(CsaShogiClient.LOGOUT_COMPLETED, _handleLogout);
_client.addEventListener(CsaShogiClient.GAME_STARTED,_handleGameStarted);
_client.addEventListener(CsaShogiClient.GAME_END,_handleGameEnd);
_client.addEventListener(CsaShogiClient.CHAT, _handleChat);
_client.addEventListener(CsaShogiClient.GAMECHAT, _handleGameChat);
_client.addEventListener(CsaShogiClient.PRIVATECHAT, _handlePrivateChat);
_client.addEventListener(CsaShogiClient.OFFLINE_PM, _handleOfflinePM);
_client.addEventListener(CsaShogiClient.MOVE,_handleMove);
_client.addEventListener(CsaShogiClient.WHO,_handleWho);
_client.addEventListener(CsaShogiClient.MONITOR, _handleMonitor);
_client.addEventListener(CsaShogiClient.RECONNECT, _handleReconnect);
_client.addEventListener(CsaShogiClient.LIST, _handleList);
_client.addEventListener(CsaShogiClient.GAME_SUMMARY, _handleGameSummary);
_client.addEventListener(CsaShogiClient.WATCHERS, _handleWatchers);
_client.addEventListener(CsaShogiClient.ENTER, _handleEnter);
_client.addEventListener(CsaShogiClient.LEAVE, _handleLeave);
_client.addEventListener(CsaShogiClient.DISCONNECT, _handleDisconnect);
_client.addEventListener(CsaShogiClient.CHALLENGE, _handleChallenger);
_client.addEventListener(CsaShogiClient.ACCEPT, _handleAccept);
_client.addEventListener(CsaShogiClient.DECLINE, _handleDecline);
_client.addEventListener(CsaShogiClient.LOBBY_IN, _handleLobbyIn);
_client.addEventListener(CsaShogiClient.LOBBY_OUT, _handleLobbyOut);
_client.addEventListener(CsaShogiClient.START, _handleStart);
_client.addEventListener(CsaShogiClient.GAME, _handleGame);
_client.addEventListener(CsaShogiClient.RESULT, _handleResult);
_client.addEventListener(CsaShogiClient.SETRATE, _handleSetRate);
_client.addEventListener(CsaShogiClient.ADMIN_MONITOR, _handleAdminMonitor);
_api.addEventListener(ApiClient.KIFU_SEARCH, _handleKifuSearch);
_api.addEventListener(ApiClient.KIFU_DETAIL, _handleKifuDetail);
_api.addEventListener(ApiClient.PLAYER_SEARCH, _handlePlayerSearch);
_api.addEventListener(ApiClient.PLAYER_DETAIL, _handlePlayerDetail);
_api.addEventListener(ApiClient.RANKING_SEARCH, _handleRankingSearch);
_api.addEventListener(ApiClient.LOAD_HISTORY, _handleLoadHistory);
_api.addEventListener(ApiClient.NOT_FOUND, _handleSearchNotFound);
_api.addEventListener(ApiClient.ADMIN_MONITOR, _handleAdminMonitor);
boardBox.addEventListener(MouseEvent.ROLL_OUT, _rollOut);
boardBox.addEventListener(MouseEvent.ROLL_OVER, _rollOver);
chatMessage1.addEventListener(FlexEvent.ENTER, _handleSendChat1);
chatMessage1.addEventListener(KeyboardEvent.KEY_DOWN, _handleKeyDown);
chatMessage2.addEventListener(FlexEvent.ENTER, _handleSendChat2);
chatMessage2.addEventListener(KeyboardEvent.KEY_DOWN, _handleKeyDown);
loginname.addEventListener(FlexEvent.ENTER,_handleLogin);
password.addEventListener(FlexEvent.ENTER, _handleLogin);
loginButton.addEventListener(MouseEvent.CLICK, _handleLogin);
playerSearchNameText.addEventListener(FlexEvent.ENTER, _handlePlayerSearchEnter);
board.name_labels[0].addEventListener(MouseEvent.DOUBLE_CLICK, _gamePlayerInfo);
board.name_labels[1].addEventListener(MouseEvent.DOUBLE_CLICK, _gamePlayerInfo);
_user_list = new Array();
userListGrid.dataProvider = _user_list;
}
//=========================================================
// EVENT HANDLERS for Client.as
//=========================================================
//----------------------------------------------------------------------------------------------------------------------------- CONNECTION
private function _handleConnected(e:Event):void {
loginButton.enabled = false;
loginMessage.text = "Logging in...";
_client.login(loginname.text, password.text);
login_name = loginname.text;
}
private function _handleLoggedIn(e:ServerMessageEvent):void {
if (savelogin.selected) {
_so.data.savelogin = true;
_so.data.login = loginname.text;
_so.data.pass = password.text;
_so.data.language = languageSelector.selectedIndex;
_so.data.server = serverListGrid.selectedIndex;
_so.flush();
}
loginMessage.text = "Logged in Successfully";
clock.start();
this.addEventListener(MouseEvent.MOUSE_MOVE, _idleClear(true));
this.addEventListener(KeyboardEvent.KEY_DOWN, _idleClear(false));
if (InfoFetcher.isAdminLv1(login_name) || InfoFetcher.isAdminLv2(login_name)) { adminButton.visible = true; _client.adminOn(); _api.adminOn(); }
mainViewStack.selectedIndex = 1;
rankingCountryList.dataProvider = InfoFetcher.country_list_names;
rankingCountryList.selectedIndex = 0;
_infoFetcher.addEventListener("loadComplete", _handleLoadOption);
_infoFetcher.loadSettings(login_name.toLowerCase());
_keepAliveTimer = new Timer(81000);
_keepAliveTimer.addEventListener(TimerEvent.TIMER, _handleKeepAlive);
_pmRingTimer = new Timer(81000, 1);
_pmRingTimer.addEventListener(TimerEvent.TIMER_COMPLETE, _handlePmRingTimer);
_idleTimer = new Timer(900000, 1);
_idleTimer.addEventListener(TimerEvent.TIMER_COMPLETE, _handleIdleTimer);
_refresh();
if (_infoFetcher.initMessage != null) {
_writeUserMessage(_infoFetcher.initMessage + "\n", 1, "#008800");
if (VERSION != _infoFetcher.newestVer) _writeUserMessage("CAUTION: This version is old! The newest is " + _infoFetcher.newestVer + ". Please reload!\n", 1, "#FF0000");
} else {
_writeUserMessage("Couldn't load initial condition file. Please refresh.\n", 1, "#008800");
}
var rank:String = "a " + InfoFetcher.makeRankFromRating(e.message.split(":")[1]);
if (parseInt(e.message.split(":")[3]) + parseInt(e.message.split(":")[4]) < 10) rank = "a new player";
for (var i:int = 0; i < InfoFetcher.titleUser.length; i++) {
if (InfoFetcher.titleUser[i] == login_name.toLowerCase()) {
rank = "the " + InfoFetcher.titleName[i];
break;
}
}
// if (!login_name.match(/^test\d$/)) _sendAutoChat("I've logged in. Hello. I'm " + rank + " from " + InfoFetcher.country_names[e.message.split(":")[2]] + ".");
_writeUserMessage("Current status: R" + e.message.split(":")[1] + ", " + e.message.split(":")[3] + " win - " + e.message.split(":")[4] + " loss, " + Math.max(0, e.message.split(":")[5]) + " streak (best: " + e.message.split(":")[6] + ")\n", 1, "#008800", true);
if (parseInt(e.message.split(":")[2]) <= 4) _writeUserMessage("Please register your country\n", 1, "#FF0000");
if (login_name.match(/\-/)) _writeUserMessage("Having '-' in your nickname causes bug. Please ask admin to change your ID.\nIDにハイフンが含まれているとバグが発生することが判明しています。管理者にID変更を依頼して下さい。\n", 1, "#FF0000", true);
}
private function _handleLoginFailed(e:ServerMessageEvent):void{
loginMessage.text = "";
errorMessage.text = e.message;
loginButton.enabled = true;
}
private function _handleLogout(e:ServerMessageEvent):void {
_keepAliveTimer.stop();
_idleTimer.stop();
_keepAliveTimer.removeEventListener(TimerEvent.TIMER, _handleKeepAlive);
_pmRingTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, _handlePmRingTimer);
_idleTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, _handleIdleTimer);
this.removeEventListener(MouseEvent.MOUSE_MOVE, _idleClear(true));
this.removeEventListener(KeyboardEvent.KEY_DOWN, _idleClear(false));
loginMessage.text = "logged out successfully";
titleBanner.source = IMAGE_DIRECTORY + "81Dojo_bye.jpg";
mainViewStack.selectedIndex = 0;
// loginButton.enabled = true;
}
//----------------------------------------------------------------------------------------------------------------------------- INFO
private function _handleWho(e:ServerMessageEvent):void{ //<<<<<< Handle WHO response
var users:Array = e.message.split("\n");
for each(var user:User in _users) user.exist = false;
for each(var user_data:String in users){
if(user_data.match("##[WHO] +OK") != null){
break;
}
var match:Array = user_data.match(/\#\#\[WHO\] (.*) x1 (.*)/);
if (match != null) {
var tokens:Array = match[2].split(" ");
if (!_users[match[1]]) _users[match[1]] = new User(match[1]);
_users[match[1]].setFromWho(parseInt(tokens[3]), parseInt(tokens[4]), parseInt(tokens[8]), parseInt(tokens[9]), Math.max(0, parseInt(tokens[10])), parseInt(tokens[11]), StringUtil.trim(tokens[0]), tokens[5], tokens[1], tokens[2], tokens[6], parseInt(tokens[7]), tokens[12] == "true");
if (match[1] == login_name) {
_users[match[1]].markSelf();
if (_status_disconnected) _users[match[1]].disconnected = true;
} else if (_favorite_list.indexOf(match[1].toLowerCase()) >= 0) {
_users[match[1]].markFavorite();
}
}
}
for each(user in _users) {
if (!user.exist) delete _users[user.name];
}
_refreshUserList();
_refreshWaiterList();
}
private function _refreshUserList():void {
_user_list = new Array();
for each (var user:User in _users) {
var userProxy:ObjectProxy = new ObjectProxy(user);
_user_list.push(userProxy);
}
_user_list.sortOn("rating", Array.NUMERIC | Array.DESCENDING);
userListGrid.dataProvider = _user_list;
for (var i:int = 0; i < _user_list.length; i++) {
if (_user_list[i].name == login_name) {
userListGrid.selectedIndex = i;
userListGrid.callLater(_scrollDownUser);
break;
}
}
userListPanel.title = "81Dojo - " + serverName + " : " + lan.lobby + " (" + _user_list.length + " players)";
}
private function _refreshWaiterList():void {
_waiter_list = new Array();
for (var i:int = 0; i < _user_list.length; i++) {
if (_user_list[i].status == User.STATE_GAME_WAITING ) {
_waiter_list.push(_user_list[i]);
}
}
waiterListGrid.dataProvider = _waiter_list;
}
private function _handleList(e:ServerMessageEvent):void { //<<<<<< Handle LIST response
var lines:Array = e.message.split("\n");
for each(var game:Game in _games) game.exist = false;
for each(var line:String in lines) {
if (line.match(/^##\[LIST\] \+OK$/)) break;
var tokens:Array = line.split(" ");
if (!_games[tokens[1]]) {
var black:User = _users[tokens[1].split("+")[2]];
if (!black) {
black = new User(tokens[1].split("+")[2]);
black.setFromList(parseInt(tokens[3]), parseInt(tokens[5]));
}
var white:User = _users[tokens[1].split("+")[3]];
if (!white) {
white = new User(tokens[1].split("+")[3]);
white.setFromList(parseInt(tokens[4]), parseInt(tokens[6]));
}
_games[tokens[1]] = new Game(tokens[1], black, white);
}
_games[tokens[1]].setFromList(parseInt(tokens[2]), tokens[7], tokens[8] == "true", tokens[9] == "true", parseInt(tokens[10]), tokens[11]);
if (_games[tokens[1]].watchers > 0) {
_games[tokens[1]].watcher_names = "";
var i:int = 0;
for each (var user:User in _users) {
if (_games[tokens[1]].id == user.monitor_game) {
_games[tokens[1]].watcher_names += (user.name + " (" + user.country3 + ")\n");
i += 1;
if (i >= _games[tokens[1]].watchers) break;
}
}
}
}
for each(game in _games) {
if (!game.exist) delete _games[game.id];
}
_refreshGameList();
}
private function _refreshGameList():void {
_game_list = new Array();
for each (var game:Game in _games) {
var gameProxy:ObjectProxy = new ObjectProxy(game);
_game_list.push(gameProxy);
}
_game_list.sortOn("maxRating", Array.NUMERIC | Array.DESCENDING);
for (var i:int = 0; i < _game_list.length; i++) _game_list[i].tag = String(i + 1);
gameListGrid.dataProvider = _game_list;
}
private function _handleWatchers(e:ServerMessageEvent):void{
var watchers:Array = e.message.split("\n");
_watcher_list = new Array();
for each(var watcher_data:String in watchers){
if(watcher_data.match(/^##\[WATCHERS\] \+OK$/)){
break;
}
var match:Array = watcher_data.match(/^##\[WATCHERS\] (.*)$/);
if (match && _users[match[1]]) _watcher_list.push(_users[match[1]]);
}
_watcher_list.sortOn("rating", Array.NUMERIC | Array.DESCENDING);
watcherListGrid.dataProvider = _watcher_list;
watcherListTitle.text = lan.watchers + " (" + _watcher_list.length +")";
}
private function _handleLobbyIn(e:ServerMessageEvent):void {
var tokens:Array = e.message.split(",");
var rank:String
if (tokens[2] == "true") {
rank = "A new player";
} else {
rank = "A " + InfoFetcher.makeRankFromRating(tokens[1]);
for (var i:int = 0; i < InfoFetcher.titleUser.length; i++) {
if (InfoFetcher.titleUser[i] == tokens[0].toLowerCase()) {
rank = "The " + InfoFetcher.titleName[i];
break;
}
}
}
var isFavorite:Boolean = _favorite_list.indexOf(tokens[0].toLowerCase()) >= 0;
_writeUserMessage(" - [" + tokens[0] + "] logged in. " + rank + " from " + InfoFetcher.country_names[tokens[3]] + ".\n", 1, "#008800", isFavorite);
if (mainViewStack.selectedIndex == 1 && _chat_sound1_play) {
if (isFavorite) _sound_door_open.play();
else _sound_chat4.play();
}
var add:Boolean = false;
if (tokens[0] == login_name) return;
if (!_users[tokens[0]]) {
_users[tokens[0]] = new User(tokens[0]);
add = true;
} else {
_users[tokens[0]].initialize();
}
_users[tokens[0]].setFromLobbyIn(parseInt(tokens[1]), parseInt(tokens[3]),parseInt(tokens[4]),parseInt(tokens[5]),Math.max(0, parseInt(tokens[6])),parseInt(tokens[7]))
if (_favorite_list.indexOf(tokens[0].toLowerCase()) >= 0) _users[tokens[0]].markFavorite();
if (add) {
_user_list.push(_users[tokens[0]]);
userListPanel.title = "81Dojo - " + serverName + " : " + lan.lobby + " (" + _user_list.length + " players)";
}
_user_list.sortOn("rating", Array.NUMERIC | Array.DESCENDING);
_updateList(userListGrid, _user_list);
}
private function _handleLobbyOut(e:ServerMessageEvent):void {
if (mainViewStack.selectedIndex == 1) {
var isFavorite:Boolean = _favorite_list.indexOf(e.message.toLowerCase()) >= 0;
// _writeUserMessage(" - " + e.message + " left.\n", 1, "#008800", isFavorite);
// if (_chat_sound1_play && isFavorite) _sound_door_close.play();
if (isFavorite) {
_writeUserMessage(" - " + e.message + " left.\n", 1, "#008800", true);
if (_chat_sound1_play) _sound_door_close.play();
}
}
for (var i:int = 0; i < _user_list.length; i++){
if (_user_list[i].name == e.message) {
_user_list.splice(i, 1);
_updateList(userListGrid, _user_list);
break;
}
}
userListPanel.title = "81Dojo - " + serverName + " : " + lan.lobby + " (" + _user_list.length + " players)";
_refreshWaiterList();
delete _users[e.message];
}
private function _handleGame(e:ServerMessageEvent):void {
var tokens:Array;
if ((tokens = e.message.match(/^\[(.+)\]$/))) {
if (_users[tokens[1]]) _users[tokens[1]].setFromGame("*", "*");
} else {
tokens = e.message.match(/^([0-9a-z]+?)_(.*)-([0-9]*)-([0-9]*),/);
if (tokens[2].match(/^@/)) return;
if (tokens[2].match(/\-\-..$/)) {
var name:String = tokens[2].substr(0, tokens[2].length - 4);
} else {
name = tokens[2];
}
if (_users[name]) _users[name].setFromGame(e.message.split(",")[0], e.message.split(",")[1]);
}
_updateList(userListGrid, _user_list);
_refreshWaiterList();
}
private function _handleStart(e:ServerMessageEvent):void {
if (mainViewStack.selectedIndex != 1) return;
var tokens:Array = e.message.split("+");
if (tokens[0] == "STUDY") {
var game_info:Array = tokens[1].match(/^([0-9a-z]+?)_(.*)-([0-9]*)-([0-9]*)$/);
_writeUserMessage(game_info[2] + " CREATED STUDY ROOM.\n", 1, "#008800");
if (_chat_sound1_play) {
if (_favorite_list.indexOf(game_info[2].toLowerCase()) >= 0) _sound_game_start.play();
else _sound_chat1.play();
}
var black:User = new User(tokens[2]);
black.setFromStudy();
var white:User = new User(tokens[3]);
white.setFromStudy();
_games[e.message] = new Game(e.message, black, white);
} else {
_writeUserMessage("GAME STARTED: ▲" + tokens[2] + " vs △" + tokens[3] + "\n", 1, "#008800");
if (_chat_sound1_play) {
if (_favorite_list.indexOf(tokens[0].toLowerCase()) >= 0 || _favorite_list.indexOf(tokens[3].toLowerCase()) >= 0) _sound_game_start.play();
}
if (_users[tokens[2]]) _users[tokens[2]].setFromStart(tokens[1], "+");
if (_users[tokens[3]]) _users[tokens[3]].setFromStart(tokens[1], "-");
_updateList(userListGrid, _user_list);
_refreshWaiterList();
_games[e.message] = new Game(e.message, _users[tokens[2]], _users[tokens[3]]);
}
_game_list.unshift(new ObjectProxy(_games[e.message]));
_updateList(gameListGrid, _game_list);
}
private function _handleAdminMonitor(e:ServerMessageEvent):void {
_adminLog += e.message;
if (_adminLog.length > 20000) _adminLog = _adminLog.substr(1000);
if (_adminPanelWindow) _adminPanelWindow.showLog(_adminLog);
}
//----------------------------------------------------------------------------------------------------------------------------- MATCH MAKING
private function _handleChallenger(e:ServerMessageEvent):void {
if (_gameAccepted) {
_client.decline("Already starting a game.");
return;
}
var challenger:User = _users[e.message];
if (!challenger) {
_client.decline("Data could not sent properly.");
return;
}
_sound_challenger.play();
_challengerAlertWindow = ChallengerAlertWindow(PopUpManager.createPopUp(this, ChallengerAlertWindow, true));
PopUpManager.centerPopUp(_challengerAlertWindow);
_challengerAlertWindow.challenger = new ObjectProxy(challenger);
_challengerAlertWindow.addEventListener("accept", _handleChallengerAcceptButton);
_challengerAlertWindow.addEventListener("decline", _handleChallengerRejectButton);
_challengerAlertWindow.startTimer();
}
private function _handleChallengerAcceptButton(e:Event):void {
_client.accept();
_gameAccepted = true;
_challengerAlertWindow = null;
}
private function _handleChallengerRejectButton(e:Event):void {
_client.decline(e.target.declineComment);
_challengerAlertWindow = null;
}
private function _handleDecline(e:ServerMessageEvent):void {
_writeUserMessage(e.message + "\n", 1, "#008800", true);
_challenging = false;
if (_challengerAlertWindow) {
_challengerAlertWindow.terminate();
_challengerAlertWindow = null;
}
}
private function _handleAccept(e:ServerMessageEvent):void {
_gameAccepted = true;
_writeUserMessage(e.message + "\n", 1, "#008800", true);
if (_challengeUser) _client.seek(_challengeUser);
}
private function _handleGameSummary(e:ServerMessageEvent):void {
_gameAccepted = false;
_refresh();
_initPositionStr = "";
for each(var line:String in e.message.split("\n")) {
if (line.match(/^P[0-9\+\-]/)) _initPositionStr += line + "\n";
}
// _client.agree();
}
private function _handleGameStarted(e:ServerMessageEvent):void {
_waiting = false;
_challenging = false;
_rematching = false;
if(_game_name && _monitoring){
_client.monitorOff(_game_name);
_monitoring = false;
board.closeGame();
} else if (board.viewing) {
board.closeGame();
chatMessage2.enabled = true;
board.viewing = false;
}
var match:Array = e.message.match(/^START:(.*)\+(.*)-([0-9]*)-([0-9]*)/);
_game_name = e.message.split(":")[1];
var game:Game = new Game(_game_name, _users[_client.playerNames[0]], _users[_client.playerNames[1]]);
board.kid = parseInt(e.message.split(":")[2]);
if (_game_name.split("+")[1].match(/^r_/)) {
board.gameType = "r";
} else if (_game_name.split("+")[1].match(/^nr_/)) {
board.gameType = "nr";
} else if (_game_name.split("+")[1].match(/^hc/)) {
board.gameType = "hc";
} else if (_game_name.split("+")[1].match(/^(va.+?)_/)) {
board.gameType = _game_name.split("+")[1].match(/^(va.+?)_/)[1];
}
if (board.gameType == "r") {
allowWatcherChatCheckbox.visible = false;
} else {
_allowWatcherChat = true;
allowWatcherChatCheckbox.selected = true;
allowWatcherChatCheckbox.visible = true;
}
board.superior = game.superior;
board.startGame(_initPositionStr, _client.myTurn, game);
_watcher_list = new Array();
watcherListGrid.dataProvider = _watcher_list;
userMessage2.htmlText = "";
_writeUserMessage(_infoFetcher.gameMessage + "\n", 2, "#008800");
if (match[2].match(/\-\-..$/)) _imgUserMessage(IMAGE_DIRECTORY + "banners/" + match[2].substr(match[2].length - 2, 2) + ".jpg", 2);
if(_client.myTurn == Kyokumen.SENTE){
_writeUserMessage("You are Black " + (board.gameType == "hc" ? "(Handicap taker).\n" : "(Sente).\n"), 2, "#008800");
} else {
_writeUserMessage("You are White " + (board.gameType == "hc" ? "(Handicap giver).\n" : "(Gote).\n"), 2, "#008800");
}
startButton.enabled = false;
stopButton.enabled = false;
closeButton.enabled = false;
resignButton.enabled = true;
reverseButton.enabled = false;
greetButton.visible = true;
rematchButton.visible = false;
_shareKifuEnabled = false;
rewindAllButton.enabled = false;
rewindOneButton.enabled = false;
forwardOneButton.enabled = false;
forwardAllButton.enabled = false;
kifuDataGrid.selectable = false;
logoutButton.enabled = false;
kifuDataGrid.dataProvider = board.kifu_list;
mainViewStack.selectedIndex = 2;
radioKifuListen.selected = true;
radioKifuListen.enabled = false;
radioKifuReplay.enabled = false;
board.onListen = true;
sidePanel.setStyle('borderColor', undefined);
if (board.piece_type == 4) _sendAutoChat("Pieces set to Blind, Middle.");
else if (board.piece_type == 5) _sendAutoChat("Pieces set to Blind, Hard.");
else if (board.piece_type == 6) _sendAutoChat("Pieces set to Blind, Extreme.");
}
private function _handleReconnect(e:ServerMessageEvent):void {
_waiting = false;
_challenging = false;
_rematching = false;
if (_game_name.split("+")[1].match(/^r_/)) {
board.gameType = "r";
} else if (_game_name.split("+")[1].match(/^nr_/)) {
board.gameType = "nr";
} else if (_game_name.split("+")[1].match(/^hc/)) {
board.gameType = "hc";
} else if (_game_name.split("+")[1].match(/^(va.+?)_/)) {
board.gameType = _game_name.split("+")[1].match(/^(va.+?)_/)[1];
}
if (board.gameType == "r") {
allowWatcherChatCheckbox.visible = false;
} else {
_allowWatcherChat = true;
allowWatcherChatCheckbox.selected = true;
allowWatcherChatCheckbox.visible = true;
}
board.superior = _watch_game.superior;
match = _game_name.split("+")[1].match(/\-(\d+)\-(\d+)$/);
var end_game:Boolean = false;
var result:String = "";
var moves:Array = new Array();
for each (var line:String in e.message.split("\n")) {
var match:Array;
if ((match = line.match(/^##\[RECONNECT\]\[(.+)\]\sTo_Move\:(\+|\-)$/))) {
board.kid = parseInt(match[1]);
_initPositionStr = "P0" + match[2] + "\n";
} else if ((match = line.match(/^##\[RECONNECT\]\[.+\]\s(P[0-9\+\-].*)$/))) {
_initPositionStr += match[1] + "\n";
} else if ((match = line.match(/^##\[RECONNECT\]\[.+\]\s([-+][0-9]{4}.{2}|%TORYO)$/))) {
var move_and_time:Object = new Object();
move_and_time.move = match[1];
moves.push(move_and_time);
} else if ((match = line.match(/^##\[RECONNECT\]\[.+\]\s(T.*)$/))) {
Object(moves[moves.length - 1]).time = match[1];
} else if (line.match(/#SENTE_WIN$/)) {
end_game = true;
result = _client.myTurn == Kyokumen.SENTE ? "WIN" : "LOSE";
} else if (line.match(/#GOTE_WIN$/)) {
end_game = true;
result = _client.myTurn == Kyokumen.SENTE ? "LOSE" : "WIN";
} else if (line.match(/#DRAW$/)) {
end_game = true;
result = "DRAW";
} else if ((match = line.match(/SINCE_LAST_MOVE:(\d+)/))) {
board.since_last_move = parseInt(match[1]);
}
}
radioKifuListen.selected = true;
radioKifuListen.enabled = false;
radioKifuReplay.enabled = false;
board.onListen = true;
sidePanel.setStyle('borderColor', undefined);
board.startGame(_initPositionStr, _client.myTurn, _watch_game, moves);
_client.watchers(_game_name);
userMessage2.htmlText = "";
_writeUserMessage(_infoFetcher.gameMessage + "\n", 2, "#008800");
_writeUserMessage("Reconnected to game.\n", 2, "#008800", true);
startButton.enabled = false;
stopButton.enabled = false;
closeButton.enabled = false;
resignButton.enabled = true;
reverseButton.enabled = false;
greetButton.visible = true;
rematchButton.visible = false;
_shareKifuEnabled = false;
rewindAllButton.enabled = false;
rewindOneButton.enabled = false;
forwardOneButton.enabled = false;
forwardAllButton.enabled = false;
kifuDataGrid.selectable = false;
logoutButton.enabled = false;
kifuDataGrid.dataProvider = board.kifu_list;
mainViewStack.selectedIndex = 2;
if (board.piece_type == 4) _sendAutoChat("Pieces set to Blind, Middle.");
else if (board.piece_type == 5) _sendAutoChat("Pieces set to Blind, Hard.");
else if (board.piece_type == 6) _sendAutoChat("Pieces set to Blind, Extreme.");
if (end_game) {
var mv:Movement = new Movement(board.kifu_list.length);
if (e.message.indexOf("#TIME_UP") >= 0) {
board.timeout();
_writeUserMessage((board.last_pos.turn == Kyokumen.SENTE ? "Black: " : "White: ") + "Time up.\n", 2, "#DD0088");
mv.setGameEnd(board.last_pos.turn, Movement.TIMEUP);
board.kifu_list.push(mv);
} else if (e.message.indexOf("#DISCONNECT") >= 0) {
_writeUserMessage("Player disconnected.\n", 2, "#DD0088");
} else if(e.message.indexOf("#ILLEGAL_MOVE") >= 0){
_writeUserMessage("Illegal Move.\n", 2, "#DD0088");
mv.setGameEnd(board.last_pos.turn, Movement.ILLEGAL);
board.kifu_list.push(mv);
} else if (e.message.indexOf("#RESIGN") >= 0) {
_writeUserMessage((board.last_pos.turn == Kyokumen.SENTE ? "Black" : "White") + " resigned.\n", 2, "#DD0088");
} else if (e.message.indexOf("#OUTE_SENNICHITE") >= 0) {
_writeUserMessage("Illegal Perpetual Check.\n", 2, "#DD0088");
mv.setGameEnd(board.last_pos.turn, Movement.OUTE_SENNICHITE);
board.kifu_list.push(mv);
} else if (e.message.indexOf("#SENNICHITE") >= 0) {
_writeUserMessage("Sennichite. (Repetition)\n", 2, "#DD0088");
mv.setGameEnd(board.last_pos.turn, Movement.SENNICHITE);
board.kifu_list.push(mv);
}
board.post_game = true;
radioKifuReplay.enabled = true;
radioKifuListen.enabled = true;
if (result == "LOSE") {
board.infoBoxes[1].setStyle('borderThickness', 2);
board.infoBoxes[1].setStyle('borderColor', 0xFF0000);
_writeUserMessage("### You Lose ###\n", 2, "#DD0088", true);
if (_end_sound_play) _sound_lose.play();
} else if (result == "WIN") {
board.infoBoxes[0].setStyle('borderThickness', 2);
board.infoBoxes[0].setStyle('borderColor', 0xFF0000);
_writeUserMessage("### You Win ###\n", 2, "#DD0088", true);
if (_end_sound_play) _sound_win.play();
} else if (result == "DRAW") {
_writeUserMessage("### Draw ###\n", 2, "#DD0088", true);
if (_end_sound_play) _sound_win.play();
}
closeButton.enabled = true;
resignButton.enabled = false;
rematchButton.visible = true;
_shareKifuEnabled = true;
rewindAllButton.enabled = true;
rewindOneButton.enabled = true;
forwardOneButton.enabled = true;
forwardAllButton.enabled = true;
startButton.enabled = true;
kifuDataGrid.dataProvider = board.kifu_list;
kifuDataGrid.scrollToIndex(board.kifu_list.length+1);
kifuDataGrid.selectable = true;
kifuDataGrid.selectedIndex = board.kifu_list.length;
board.endGame();
} else {
board.timers[board.my_turn == board.last_pos.turn ? 0 : 1].accumulateTime(board.since_last_move);
}
}
private function _handleGameEnd(e:ServerMessageEvent):void {
var mv:Movement = new Movement(board.kifu_list.length);
if (_disconnectAlertWindow) {
_disconnectAlertWindow.terminate();
_disconnectAlertWindow = null;
}
board.post_game = true;
if (e.message.indexOf("TIME_UP") >= 0) {
if (GameTimer.soundType == 2) _sound_timeup.play();
board.timeout();
_writeUserMessage((board.position.turn == Kyokumen.SENTE ? "Black: " : "White: ") + "Time up.\n", 2, "#DD0088");
mv.setGameEnd(board.position.turn, Movement.TIMEUP);
board.kifu_list.push(mv);
} else if (e.message.indexOf("DISCONNECT") >= 0) {
_writeUserMessage("Opponent disconnected.\n", 2, "#DD0088");
} else if(e.message.indexOf("ILLEGAL_MOVE") >= 0){
_writeUserMessage("Illegal Move.\n", 2, "#DD0088");
mv.setGameEnd(board.position.turn, Movement.ILLEGAL);
board.kifu_list.push(mv);
} else if (e.message.indexOf("RESIGN") >= 0) {
_writeUserMessage((board.position.turn == board.my_turn ? "You" : "Opponent") + " resigned.\n", 2, "#DD0088");
} else if (e.message.indexOf("OUTE_SENNICHITE") >= 0) {
_writeUserMessage("Illegal Perpetual Check.\n", 2, "#DD0088");
mv.setGameEnd(board.position.turn, Movement.OUTE_SENNICHITE);
board.kifu_list.push(mv);
} else if (e.message.indexOf("SENNICHITE") >= 0) {
_writeUserMessage("Sennichite. (Repetition)\n", 2, "#DD0088");
mv.setGameEnd(board.position.turn, Movement.SENNICHITE);
board.kifu_list.push(mv);
}
radioKifuReplay.enabled = true;
radioKifuListen.enabled = true;
if (e.message.indexOf("LOSE") >= 0) {
board.isStudyHost = true;
_openGameResultWindow(-1);
board.infoBoxes[1].setStyle('borderThickness', 2);
board.infoBoxes[1].setStyle('borderColor', 0xFF0000);
_writeUserMessage("### You Lose ###\n", 2, "#DD0088", true);
if (_end_sound_play) _sound_lose.play();
} else if (e.message.indexOf("WIN") >= 0) {
board.isSubHost = true;
_openGameResultWindow(1);
board.infoBoxes[0].setStyle('borderThickness', 2);
board.infoBoxes[0].setStyle('borderColor', 0xFF0000);
_writeUserMessage("### You Win ###\n", 2, "#DD0088", true);
if (_end_sound_play) _sound_win.play();
} else if (e.message.indexOf("DRAW") >= 0) {
if (board.my_turn == Kyokumen.GOTE) board.isStudyHost = true;
else board.isSubHost = true;
_openGameResultWindow(0);
_writeUserMessage("### Draw ###\n", 2, "#DD0088", true);
if (_end_sound_play) _sound_win.play();
}
if (board.gameType == "hc") {
if (board.my_turn == Kyokumen.GOTE) {
board.isStudyHost = true;
board.isSubHost = false;
} else {
board.isStudyHost = false;
board.isSubHost = true;
}
}
allowWatcherChatCheckbox.visible = false;
closeButton.enabled = true;
resignButton.enabled = false;
rematchButton.visible = true;
_shareKifuEnabled = true;
rewindAllButton.enabled = true;
rewindOneButton.enabled = true;
forwardOneButton.enabled = true;
forwardAllButton.enabled = true;
startButton.enabled = true;
kifuDataGrid.scrollToIndex(0);
kifuDataGrid.dataProvider = board.kifu_list;
kifuDataGrid.selectable = true;
kifuDataGrid.selectedIndex = board.kifu_list.length - 1;
kifuDataGrid.callLater(_scrollDownKifu); //kifuDataGrid.scrollToIndex(board.kifu_list.length+1);
if (board.isStudyHost) _toggleHostStatus(true);
if (board.isSubHost) _writeUserMessage("You are a sub-host of study mode. You can move the host's pieces.\n", 2, "#008800", true);
board.endGame();
_status_disconnected = false;
}
private function _openGameResultWindow(v:int):void {
_gameResultWindow = GameResultWindow(PopUpManager.createPopUp(board, GameResultWindow, false));
PopUpManager.centerPopUp(_gameResultWindow);
_gameResultWindow.initWindow(board.playerInfos[board.my_turn].name, board.playerInfos[1 - board.my_turn].name, v);
}
private function _handleResult(e:ServerMessageEvent):void {
var tokens:Array = e.message.split(",");
if (_gameResultWindow) _gameResultWindow.readRateChange(parseInt(tokens[0]), parseInt(tokens[1]), parseInt(tokens[2]), parseInt(tokens[3]));
}
private function _handleMove(e:ServerMessageEvent):void {
board.clearArrows(Board.ARROWS_PUBLIC);
if (e.message.match(/%TORYO/)) {
var mv:Movement = new Movement(board.kifu_list.length);
mv.setGameEnd(board.position.turn, Movement.RESIGN, parseInt(e.message.split(",T")[1]));
board.kifu_list.push(mv);
} else {
if (board.since_last_move > 0) {
board.timers[board.my_turn == board.last_pos.turn ? 0 : 1].accumulateTime(- board.since_last_move);
board.since_last_move = 0;
}
board.makeMove(e.message, true, true);
}
kifuDataGrid.dataProvider = board.kifu_list;
kifuDataGrid.scrollToIndex(board.kifu_list.length + 1);
if (_impasseStatusWindow) {
board.position.calcImpasse();
_impasseStatusWindow.setStatus(board.position.impasseStatus, board.position.turn == board.my_turn ? board.my_turn : -1);
}
if (board.isRelay) _checkRelaySwitch();
}