Skip to content
This repository was archived by the owner on Jan 31, 2019. It is now read-only.

Commit 9267e5e

Browse files
committed
Update readme with v2 code sample
1 parent 4eb4c47 commit 9267e5e

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,32 @@ OppaiSharp is a C# port of [oppai-ng](//github.com/Francesco149/oppai-ng) by [Fr
55
It is "licensed" under the Unlicense, so you're free to do whatever you want with it. But giving me or Francesco149 a bit of credit doesn't hurt, and I would appreciate it if you didn't claim it as your own :)
66

77
## Example usage
8+
v2:
9+
```cs
10+
//create a StreamReader for your beatmap
11+
byte[] data = new WebClient().DownloadData("https://osu.ppy.sh/osu/774965");
12+
var stream = new MemoryStream(data, false);
13+
var reader = new StreamReader(stream);
14+
15+
//read a beatmap
16+
var beatmap = Beatmap.Read(reader);
17+
18+
//calculate star ratings for HDDT
19+
Mods mods = Mods.Hidden | Mods.DoubleTime;
20+
var diff = new DiffCalc().Calc(beatmap, mods);
21+
Console.WriteLine(string.Format("Star rating: {0:F2} (aim stars: {1:F2}, speed stars: {2:F2})",
22+
diff.Total, diff.Aim, diff.Speed));
23+
24+
//calculate the PP for a play on this map
25+
//the play has no misses or 50's, so we don't specify them
26+
var pp = new PPv2(new PPv2Parameters(beatmap, diff, c100: 8, mods: mods));
27+
28+
Console.WriteLine(string.Format("Play is worth {0:F2}pp ({1:F2} aim pp, {2:F2} acc pp, {3:F2} speed pp) " +
29+
"and has an accuracy of {4:F2}%",
30+
pp.Total, pp.Aim, pp.Acc, pp.Speed, pp.ComputedAccuracy.Value() * 100));
31+
```
832

33+
v1 (old):
934
```cs
1035
//create a StreamReader for your beatmap
1136
byte[] data = new WebClient().DownloadData("https://osu.ppy.sh/osu/774965");
@@ -31,6 +56,7 @@ var pp = new PPv2(new PPv2Parameters {
3156
Count50 = 0,
3257
CountMiss = 0,
3358
});
34-
Console.WriteLine(string.Format("Play is worth {0:F2}pp ({1:F2} aim pp, {2:F2} acc pp, {3:F2} speed pp) and has an accuracy of {4:F2}",
59+
Console.WriteLine(string.Format("Play is worth {0:F2}pp ({1:F2} aim pp, {2:F2} acc pp, {3:F2} speed pp) " +
60+
"and has an accuracy of {4:F2}%",
3561
pp.Total, pp.Aim, pp.Acc, pp.Speed, pp.ComputedAccuracy.Value() * 100));
3662
```

0 commit comments

Comments
 (0)