@@ -68,13 +68,11 @@ export function make(send: SocketSend, ctrl: RoundController): RoundSocket {
68
68
} ) ;
69
69
} ;
70
70
71
- const d = ctrl . data ;
72
-
73
71
const handlers : Handlers = {
74
72
takebackOffers ( o ) {
75
73
ctrl . setLoading ( false ) ;
76
- d . player . proposingTakeback = o [ d . player . color ] ;
77
- const fromOp = d . opponent . proposingTakeback = o [ d . opponent . color ] ;
74
+ ctrl . data . player . proposingTakeback = o [ ctrl . data . player . color ] ;
75
+ const fromOp = ctrl . data . opponent . proposingTakeback = o [ ctrl . data . opponent . color ] ;
78
76
if ( fromOp ) notify ( ctrl . noarg ( 'yourOpponentProposesATakeback' ) ) ;
79
77
ctrl . redraw ( ) ;
80
78
} ,
@@ -90,34 +88,34 @@ export function make(send: SocketSend, ctrl: RoundController): RoundSocket {
90
88
} ,
91
89
cclock ( o ) {
92
90
if ( ctrl . corresClock ) {
93
- d . correspondence . white = o . white ;
94
- d . correspondence . black = o . black ;
91
+ ctrl . data . correspondence . white = o . white ;
92
+ ctrl . data . correspondence . black = o . black ;
95
93
ctrl . corresClock . update ( o . white , o . black ) ;
96
94
ctrl . redraw ( ) ;
97
95
}
98
96
} ,
99
97
crowd ( o ) {
100
- game . setOnGame ( d , 'white' , o [ 'white' ] ) ;
101
- game . setOnGame ( d , 'black' , o [ 'black' ] ) ;
98
+ game . setOnGame ( ctrl . data , 'white' , o [ 'white' ] ) ;
99
+ game . setOnGame ( ctrl . data , 'black' , o [ 'black' ] ) ;
102
100
ctrl . redraw ( ) ;
103
101
} ,
104
102
endData ( o : ApiEnd ) {
105
103
ctrl . endWithData ( o ) ;
106
104
} ,
107
105
rematchOffer ( by : Color ) {
108
- d . player . offeringRematch = by === d . player . color ;
109
- if ( d . opponent . offeringRematch = by === d . opponent . color )
106
+ ctrl . data . player . offeringRematch = by === ctrl . data . player . color ;
107
+ if ( ctrl . data . opponent . offeringRematch = by === ctrl . data . opponent . color )
110
108
notify ( ctrl . noarg ( 'yourOpponentWantsToPlayANewGameWithYou' ) ) ;
111
109
ctrl . redraw ( ) ;
112
110
} ,
113
111
rematchTaken ( nextId : string ) {
114
- d . game . rematch = nextId ;
115
- if ( ! d . player . spectator ) ctrl . setLoading ( true ) ;
112
+ ctrl . data . game . rematch = nextId ;
113
+ if ( ! ctrl . data . player . spectator ) ctrl . setLoading ( true ) ;
116
114
else ctrl . redraw ( ) ;
117
115
} ,
118
116
drawOffer ( by ) {
119
- d . player . offeringDraw = by === d . player . color ;
120
- const fromOp = d . opponent . offeringDraw = by === d . opponent . color ;
117
+ ctrl . data . player . offeringDraw = by === ctrl . data . player . color ;
118
+ const fromOp = ctrl . data . opponent . offeringDraw = by === ctrl . data . opponent . color ;
121
119
if ( fromOp ) notify ( ctrl . noarg ( 'yourOpponentOffersADraw' ) ) ;
122
120
ctrl . redraw ( ) ;
123
121
} ,
@@ -127,16 +125,16 @@ export function make(send: SocketSend, ctrl: RoundController): RoundSocket {
127
125
gone : ctrl . setGone ,
128
126
goneIn : ctrl . setGone ,
129
127
checkCount ( e ) {
130
- d . player . checks = d . player . color == 'white' ? e . white : e . black ;
131
- d . opponent . checks = d . opponent . color == 'white' ? e . white : e . black ;
128
+ ctrl . data . player . checks = ctrl . data . player . color == 'white' ? e . white : e . black ;
129
+ ctrl . data . opponent . checks = ctrl . data . opponent . color == 'white' ? e . white : e . black ;
132
130
ctrl . redraw ( ) ;
133
131
} ,
134
132
simulPlayerMove ( gameId : string ) {
135
133
if (
136
134
ctrl . opts . userId &&
137
- d . simul &&
138
- ctrl . opts . userId == d . simul . hostId &&
139
- gameId !== d . game . id &&
135
+ ctrl . data . simul &&
136
+ ctrl . opts . userId == ctrl . data . simul . hostId &&
137
+ gameId !== ctrl . data . game . id &&
140
138
ctrl . moveOn . get ( ) &&
141
139
! isPlayerTurn ( ctrl . data ) ) {
142
140
ctrl . setRedirecting ( ) ;
@@ -160,7 +158,7 @@ export function make(send: SocketSend, ctrl: RoundController): RoundSocket {
160
158
send,
161
159
handlers,
162
160
moreTime : throttle ( 300 , ( ) => send ( 'moretime' ) ) ,
163
- outoftime : backoff ( 500 , 1.1 , ( ) => send ( 'flag' , d . game . player ) ) ,
161
+ outoftime : backoff ( 500 , 1.1 , ( ) => send ( 'flag' , ctrl . data . game . player ) ) ,
164
162
berserk : throttle ( 200 , ( ) => send ( 'berserk' , null , { ackable : true } ) ) ,
165
163
sendLoading ( typ : string , data ?: any ) {
166
164
ctrl . setLoading ( true ) ;
0 commit comments