forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_daily_challenge_final.py
More file actions
45 lines (35 loc) · 1.71 KB
/
Copy pathfix_daily_challenge_final.py
File metadata and controls
45 lines (35 loc) · 1.71 KB
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
with open('osu.Game/Screens/OnlinePlay/DailyChallenge/DailyChallenge.cs', 'r') as f:
content = f.read()
# Bot wants null propagation for:
# var item = playlistItem;
# if (item == null) return;
# This pattern is used in: presentScore, updateMods, startPlay, PresentBeatmap.
# Since playlistItem is a field, we can use null-propagation directly in most cases.
# However, for startPlay and PresentBeatmap we need to perform actions.
content = content.replace(''' private void presentScore(long id)
{
if (!this.IsCurrentScreen())
return;
var item = playlistItem;
if (item == null) return;
this.Push(new PlaylistItemScoreResultsScreen(id, (room.RoomID ?? 0), item));
}''', ''' private void presentScore(long id)
{
if (this.IsCurrentScreen() && playlistItem != null)
this.Push(new PlaylistItemScoreResultsScreen(id, room.RoomID ?? 0, playlistItem));
}''')
content = content.replace(''' private void updateMods()
{
if (!this.IsCurrentScreen())
return;
var item = playlistItem;
if (item == null) return;
Mods.Value = userMods.Value.Concat(item.RequiredMods.Select(m => m.ToMod(Ruleset.Value.CreateInstance()))).ToList();
}''', ''' private void updateMods()
{
if (!this.IsCurrentScreen() || playlistItem == null)
return;
Mods.Value = userMods.Value.Concat(playlistItem.RequiredMods.Select(m => m.ToMod(Ruleset.Value.CreateInstance()))).ToList();
}''')
with open('osu.Game/Screens/OnlinePlay/DailyChallenge/DailyChallenge.cs', 'w') as f:
f.write(content)