@@ -66,9 +66,9 @@ private void InvokeEventInvoker(string message) => ((IBanchoBotEventInvoker)_cli
66
66
67
67
private void InvokeBancho ( string banchoBotMessage , string recipient ) => _client . SimulateMessageReceivedAsync (
68
68
PrivateIrcMessage . CreateFromParameters ( "BanchoBot" , recipient , banchoBotMessage ) ) ;
69
-
69
+
70
70
private void InvokeToLobby ( string message ) => Invoke ( PrivateIrcMessage . CreateFromParameters ( "BanchoBot" , _lobby . ChannelName , message ) ) ;
71
-
71
+
72
72
[ SetUp ]
73
73
public void Setup ( )
74
74
{
@@ -100,42 +100,44 @@ public void Setup()
100
100
"Players: 1" ,
101
101
"Slot 1 Not Ready https://osu.ppy.sh/u/8191845 Stage [Host / Easy, Hidden, Relax, Flashlight, SpunOut]" ) ]
102
102
public void TestMpSettingsUpdates ( string lobbyName , string historyUrl , int matchId , Mods lobbyMods ,
103
- int beatmapId , string beatmapTitle , string beatmapArtist , string beatmapDifficulty , LobbyFormat format ,
104
- WinCondition winCondition , TeamColor p1TeamColor , bool p1IsHost , bool p1IsReady , int p1Id ,
103
+ int beatmapId , string beatmapTitle , string beatmapArtist , string beatmapDifficulty ,
104
+ LobbyFormat format ,
105
+ WinCondition winCondition , TeamColor p1TeamColor , bool p1IsHost , bool p1IsReady ,
106
+ int p1Id ,
105
107
string p1Name , int p1Slot , Mods p1Mods , params string [ ] updates )
106
- {
107
- _lobby = new MultiplayerLobby ( _client , matchId , lobbyName ) ;
108
+ {
109
+ _lobby = new MultiplayerLobby ( _client , matchId , lobbyName ) ;
108
110
109
- foreach ( string u in updates )
111
+ foreach ( string u in updates )
110
112
{
111
113
// Generates the !mp settings response for these parameters and calls it
112
114
Invoke ( PrivateIrcMessage . CreateFromParameters ( "BanchoBot" , $ "#mp_{ _lobby . Id } ", u ) ) ;
113
115
}
114
116
115
- Assert . Multiple ( ( ) =>
116
- {
117
- // Assert that all parameters are equal to the corresponding multiplayerlobby values
118
- Assert . That ( _lobby . Name , Is . EqualTo ( lobbyName ) ) ;
119
- Assert . That ( _lobby . HistoryUrl , Is . EqualTo ( historyUrl ) ) ;
120
- Assert . That ( _lobby . Id , Is . EqualTo ( matchId ) ) ;
121
- Assert . That ( _lobby . Mods , Is . EqualTo ( lobbyMods ) ) ;
122
- Assert . That ( _lobby . CurrentBeatmap . Id , Is . EqualTo ( beatmapId ) ) ;
123
- Assert . That ( _lobby . CurrentBeatmap . Title , Is . EqualTo ( beatmapTitle ) ) ;
124
- Assert . That ( _lobby . CurrentBeatmap . Artist , Is . EqualTo ( beatmapArtist ) ) ;
125
- Assert . That ( _lobby . CurrentBeatmap . Difficulty , Is . EqualTo ( beatmapDifficulty ) ) ;
126
- Assert . That ( _lobby . Format , Is . EqualTo ( format ) ) ;
127
- Assert . That ( _lobby . WinCondition , Is . EqualTo ( winCondition ) ) ;
128
- Assert . That ( _lobby . Host . Equals ( _lobby . Players [ 0 ] ) , Is . EqualTo ( p1IsHost ) ) ;
129
- Assert . That ( _lobby . Players [ 0 ] . Team , Is . EqualTo ( p1TeamColor ) ) ;
130
- Assert . That ( _lobby . Players [ 0 ] . IsReady , Is . EqualTo ( p1IsReady ) ) ;
131
- Assert . That ( _lobby . Players [ 0 ] . Id , Is . EqualTo ( p1Id ) ) ;
132
- Assert . That ( _lobby . Players [ 0 ] . Name , Is . EqualTo ( p1Name ) ) ;
133
- Assert . That ( _lobby . Players [ 0 ] . Slot , Is . EqualTo ( p1Slot ) ) ;
134
- Assert . That ( _lobby . Players [ 0 ] . Mods , Is . EqualTo ( p1Mods ) ) ;
135
- } ) ;
136
- }
137
-
138
- [ TestCase ( 1314987 , "Camellia" , @"Feelin Sky (Camellia's ""200step"" Self-remix)" , "Ambivalence" , null ,
117
+ Assert . Multiple ( ( ) =>
118
+ {
119
+ // Assert that all parameters are equal to the corresponding multiplayerlobby values
120
+ Assert . That ( _lobby . Name , Is . EqualTo ( lobbyName ) ) ;
121
+ Assert . That ( _lobby . HistoryUrl , Is . EqualTo ( historyUrl ) ) ;
122
+ Assert . That ( _lobby . Id , Is . EqualTo ( matchId ) ) ;
123
+ Assert . That ( _lobby . Mods , Is . EqualTo ( lobbyMods ) ) ;
124
+ Assert . That ( _lobby . CurrentBeatmap . Id , Is . EqualTo ( beatmapId ) ) ;
125
+ Assert . That ( _lobby . CurrentBeatmap . Title , Is . EqualTo ( beatmapTitle ) ) ;
126
+ Assert . That ( _lobby . CurrentBeatmap . Artist , Is . EqualTo ( beatmapArtist ) ) ;
127
+ Assert . That ( _lobby . CurrentBeatmap . Difficulty , Is . EqualTo ( beatmapDifficulty ) ) ;
128
+ Assert . That ( _lobby . Format , Is . EqualTo ( format ) ) ;
129
+ Assert . That ( _lobby . WinCondition , Is . EqualTo ( winCondition ) ) ;
130
+ Assert . That ( _lobby . Host . Equals ( _lobby . Players [ 0 ] ) , Is . EqualTo ( p1IsHost ) ) ;
131
+ Assert . That ( _lobby . Players [ 0 ] . Team , Is . EqualTo ( p1TeamColor ) ) ;
132
+ Assert . That ( _lobby . Players [ 0 ] . IsReady , Is . EqualTo ( p1IsReady ) ) ;
133
+ Assert . That ( _lobby . Players [ 0 ] . Id , Is . EqualTo ( p1Id ) ) ;
134
+ Assert . That ( _lobby . Players [ 0 ] . Name , Is . EqualTo ( p1Name ) ) ;
135
+ Assert . That ( _lobby . Players [ 0 ] . Slot , Is . EqualTo ( p1Slot ) ) ;
136
+ Assert . That ( _lobby . Players [ 0 ] . Mods , Is . EqualTo ( p1Mods ) ) ;
137
+ } ) ;
138
+ }
139
+
140
+ [ TestCase ( 1314987 , "Camellia" , @"Feelin Sky (Camellia's ""200step"" Self-remix)" , "Ambivalence" , null ,
139
141
@"Camellia - Feelin Sky (Camellia's ""200step"" Self-remix) [Ambivalence] (https://osu.ppy.sh/b/1314987)" ) ]
140
142
[ TestCase ( 676065 , "FLOOR LEGENDS -KAC 2012-" , "KAC 2012 ULTIMATE MEDLEY -HISTORIA SOUND VOLTEX-" , "NOVICE" , null ,
141
143
@"FLOOR LEGENDS -KAC 2012- - KAC 2012 ULTIMATE MEDLEY -HISTORIA SOUND VOLTEX- [NOVICE] (https://osu.ppy.sh/b/676065)" ) ]
@@ -152,19 +154,43 @@ public void TestMpSettingsBeatmap()
152
154
{
153
155
string input = "Beatmap: https://osu.ppy.sh/b/2572163 Kurokotei - Galaxy Collapse" ;
154
156
string input2 = "Beatmap: https://osu.ppy.sh/b/2907160 Silentroom - NULCTRL" ;
155
-
157
+
156
158
var shell = new BeatmapShell ( 2572163 , "Kurokotei" , "Galaxy Collapse" , null , _lobby . GameMode ) ;
157
159
var shell2 = new BeatmapShell ( 2907160 , "Silentroom" , "NULCTRL" , null , _lobby . GameMode ) ;
158
-
160
+
159
161
Assert . Multiple ( ( ) =>
160
162
{
161
163
InvokeToLobby ( input ) ;
162
164
Assert . That ( _lobby . CurrentBeatmap , Is . EqualTo ( shell ) ) ;
163
-
165
+
164
166
InvokeToLobby ( input2 ) ;
165
167
Assert . That ( _lobby . CurrentBeatmap , Is . EqualTo ( shell2 ) ) ;
166
168
} ) ;
167
169
}
170
+
171
+ [ Test ]
172
+ public void TestAllPlayersReady ( )
173
+ {
174
+ _lobby . Players . Add ( new MultiplayerPlayer ( _lobby , "Player 1" , 1 ) ) ;
175
+ _lobby . Players . Add ( new MultiplayerPlayer ( _lobby , "Player 2" , 2 ) ) ;
176
+ _lobby . Players . Add ( new MultiplayerPlayer ( _lobby , "Player 3" , 3 ) ) ;
177
+ _lobby . Players . Add ( new MultiplayerPlayer ( _lobby , "Player 4" , 4 ) ) ;
178
+
179
+ foreach ( var player in _lobby . Players )
180
+ {
181
+ Assert . That ( player . IsReady , Is . False ) ;
182
+ }
183
+
184
+ _lobby . OnAllPlayersReady += ( ) =>
185
+ {
186
+ foreach ( var player in _lobby . Players )
187
+ {
188
+ Assert . That ( player . IsReady , Is . True ) ;
189
+ }
190
+ } ;
191
+
192
+ InvokeToLobby ( "All players are ready!" ) ;
193
+ }
168
194
169
195
[ Test ]
170
196
public void TestHostChangingBeatmap ( )
@@ -189,6 +215,30 @@ public void TestHostChangingBeatmap()
189
215
}
190
216
}
191
217
218
+ // This also gets executed when the host manually selects a map
219
+ [ TestCase ( ":[email protected] PRIVMSG #mp_1 :Beatmap changed to: Various Artists - FINGER CONTROL MEGAPACK [Renard - With Me (LVL1)] (https://osu.ppy.sh/b/3593124)" ,
220
+ 3593124 , "Various Artists" , "FINGER CONTROL MEGAPACK" , "Renard - With Me (LVL1)" ) ]
221
+ [ TestCase ( ":[email protected] PRIVMSG #mp_1 :Beatmap changed to: baker - For a Dead Girl+ [Collab Extra] (https://osu.ppy.sh/b/1444316)" ,
222
+ 1444316 , "baker" , "For a Dead Girl+" , "Collab Extra" ) ]
223
+ [ TestCase ( ":[email protected] PRIVMSG #mp_1 :Beatmap changed to: THE ORAL CIGARETTES - Flower [Sakura] (https://osu.ppy.sh/b/1738018)" ,
224
+ 1738018 , "THE ORAL CIGARETTES" , "Flower" , "Sakura" ) ]
225
+ [ TestCase ( ":[email protected] PRIVMSG #mp_1 :Beatmap changed to: TheFatRat - Mayday (feat. Laura Brehm) [[2B] Calling Out Mayday] (https://osu.ppy.sh/b/1605148)" ,
226
+ 1605148 , "TheFatRat" , "Mayday (feat. Laura Brehm)" , "[2B] Calling Out Mayday" ) ]
227
+ [ TestCase ( ":[email protected] PRIVMSG #mp_106511377 :Beatmap changed to: Toby Fox - MEGALOVANIA (Camellia Remix) [Tocorn x Ciyus Miapah : Inevitable Demise] (https://osu.ppy.sh/b/2169346)" ,
228
+ 2169346 , "Toby Fox" , "MEGALOVANIA (Camellia Remix)" , "Tocorn x Ciyus Miapah : Inevitable Demise" ) ]
229
+ public void TestMpSet ( string message , int id , string artist , string title , string diff )
230
+ {
231
+ var irc = new PrivateIrcMessage ( message ) ;
232
+
233
+ _client . SimulateMessageReceivedAsync ( irc ) ;
234
+
235
+ Assert . Multiple ( ( ) =>
236
+ {
237
+ Assert . That ( _lobby . CurrentBeatmap , Is . Not . Null ) ;
238
+ Assert . That ( _lobby . CurrentBeatmap ! . Equals ( new BeatmapShell ( id , artist , title , diff , _lobby . GameMode ) ) ) ;
239
+ } ) ;
240
+ }
241
+
192
242
[ TestCase ( "a" ) ]
193
243
[ TestCase ( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ) ]
194
244
[ TestCase ( "⍝ږÇ=壕֤Я~𫮒֕�ꊇي탇ݛ暤t2ޥ춸Мᇫe鑨╕" ) ] // Random UTF-8
@@ -214,7 +264,7 @@ public void TestPlayerChangedSlot()
214
264
string player1 = "dummy1" ;
215
265
string player2 = "dummy2" ;
216
266
string player3 = "dummy3" ;
217
-
267
+
218
268
_lobby . OnPlayerSlotMove += e =>
219
269
{
220
270
var playerMatch = _lobby . FindPlayer ( e . Player . Name ) ;
@@ -224,11 +274,11 @@ public void TestPlayerChangedSlot()
224
274
Assert . That ( playerMatch ! . Slot , Is . EqualTo ( e . NewSlot ) ) ;
225
275
} ) ;
226
276
} ;
227
-
277
+
228
278
InvokeEventInvoker ( _playerJoined ( player1 , 1 , null ) ) ;
229
279
InvokeEventInvoker ( _playerJoined ( player2 , 2 , null ) ) ;
230
280
InvokeEventInvoker ( _playerJoined ( player3 , 3 , null ) ) ;
231
-
281
+
232
282
InvokeEventInvoker ( _slotChanged ( player1 , 5 ) ) ;
233
283
InvokeEventInvoker ( _slotChanged ( player2 , 16 ) ) ;
234
284
InvokeEventInvoker ( _slotChanged ( player3 , 2 ) ) ;
0 commit comments