Skip to content

Commit 0880e52

Browse files
committed
publish: v0.5.0 - up-to-date
- Using peace-performance v0.4.0 (latest) - Fix: Mania calculate (add `score` fields)
1 parent 06c4faf commit 0880e52

4 files changed

Lines changed: 65 additions & 49 deletions

File tree

Cargo.toml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[package]
22
name = "pp-server"
3-
version = "0.4.2"
3+
version = "0.5.0"
44
authors = ["Pure-Peace <940857703@qq.com>"]
55
edition = "2018"
66
license = "MIT"
77
repository = "https://github.com/pure-peace/pp-server"
8+
default-run = "pp-server-with-peace"
89

910
[[bin]]
1011
name = "pp-server-with-peace"
@@ -44,26 +45,39 @@ json = "0.12.4"
4445
log = "0.4.14"
4546
ntex = "0.3"
4647
prometheus = { version = "0.12", features = ["process"] }
47-
reqwest = { version = "0.11", features = ["rustls-tls", "json"], default-features = false }
48+
reqwest = { version = "0.11", features = [
49+
"rustls-tls",
50+
"json",
51+
], default-features = false }
4852
serde = { version = "1.0", features = ["derive"] }
4953
serde_json = "1.0"
5054
serde_str = "0.1.0"
51-
tokio = { version = "1.7" }
55+
tokio = { version = "1.9" }
5256

5357

5458
# Feature peace
5559
deadpool-postgres = { version = "0.9", optional = true }
5660
deadpool-redis = { version = "0.8", optional = true }
57-
tokio-postgres = { version = "0.7", features = ["with-chrono-0_4", "with-serde_json-1"], optional = true }
61+
tokio-postgres = { version = "0.7", features = [
62+
"with-chrono-0_4",
63+
"with-serde_json-1",
64+
], optional = true }
5865

59-
peace-performance = { version = "0.2.5", git = "https://github.com/Pure-Peace/Peace-performance.git", branch = "main" }
66+
peace-performance = { version = "0.4.0" }
6067

6168
# Git
6269
peace-constants = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main" }
63-
peace-database = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main", features = ["with_peace"], optional = true }
64-
peace-objects = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main", features = ["osu_file_downloader"], optional = true }
70+
peace-database = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main", features = [
71+
"with_peace",
72+
], optional = true }
73+
peace-objects = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main", features = [
74+
"osu_file_downloader",
75+
], optional = true }
6576
peace-settings = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main" }
66-
peace-utils = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main", features = ["web", "async_file"] }
77+
peace-utils = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main", features = [
78+
"web",
79+
"async_file",
80+
] }
6781

6882
# Local (download peace manual)
6983
# peace-constants = { path = "../../Peace/peace-constants" }

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ This method is currently cannot use cache.
167167
Set Cargo.toml
168168

169169
```rust
170-
peace-performance = { git = "https://github.com/Pure-Peace/Peace-performance.git", branch = "main" }
170+
peace-performance = { ... }
171171
```
172172

173173
to
174174

175175
```rust
176-
peace-performance = { git = "https://github.com/Pure-Peace/Peace-performance.git", branch = "main", feature = "no_sliders_no_leniency" }
176+
peace-performance = { ..., feature = "no_sliders_no_leniency" }
177177
```
178178

179179
## Note

src/objects/calculator.rs

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@ use {
1313
use peace_objects::beatmaps::traits::{BeatmapCacheStorage, MyBeatmapCache};
1414
use peace_performance::{AnyPP, Beatmap as PPbeatmap, FruitsPP, ManiaPP, OsuPP, PpResult, TaikoPP};
1515

16+
macro_rules! set_calculator {
17+
($target:ident.$attr:ident, $calculator:ident) => {
18+
match $target.$attr {
19+
Some($attr) => $calculator.$attr($attr),
20+
None => $calculator,
21+
}
22+
};
23+
($target:ident.$attr:ident, $func:ident, $calculator:ident) => {
24+
match $target.$attr {
25+
Some($attr) => $calculator.$func($attr),
26+
None => $calculator,
27+
}
28+
};
29+
}
30+
1631
#[derive(PartialEq)]
1732
pub enum GetBeatmapError {
1833
FileNotFound,
@@ -53,6 +68,7 @@ pub struct CalcData {
5368
pub passed_obj: Option<usize>,
5469
pub combo: Option<usize>,
5570
pub miss: Option<usize>,
71+
pub score: Option<u32>,
5672
pub simple: Option<i32>,
5773
pub acc_list: Option<i32>,
5874
pub no_miss: Option<i32>,
@@ -62,38 +78,23 @@ pub struct CalcData {
6278
pub async fn calculate_pp(beatmap: &PPbeatmap, data: &CalcData) -> PpResult {
6379
// Get target mode calculator
6480
let c = mode_calculator(data.mode.unwrap_or(4), &beatmap);
65-
let c = match data.mods {
66-
Some(mods) => c.mods(mods),
67-
None => c,
68-
};
69-
let c = match data.combo {
70-
Some(combo) => c.combo(combo),
71-
None => c,
72-
};
73-
let c = match data.n50 {
74-
Some(n50) => c.n50(n50),
75-
None => c,
76-
};
77-
let c = match data.n100 {
78-
Some(n100) => c.n100(n100),
79-
None => c,
80-
};
81-
let c = match data.n300 {
82-
Some(n300) => c.n300(n300),
83-
None => c,
84-
};
85-
let c = match data.katu {
86-
Some(katu) => c.n_katu(katu),
87-
None => c,
88-
};
89-
let c = match data.miss {
90-
Some(miss) => c.misses(miss),
91-
None => c,
92-
};
93-
let mut c = match data.passed_obj {
94-
Some(passed_obj) => c.passed_objects(passed_obj),
95-
None => c,
96-
};
81+
let c = set_calculator!(data.mods, c);
82+
// Irrelevant for osu!mania
83+
let c = set_calculator!(data.combo, c);
84+
// Irrelevant for osu!mania and osu!taiko
85+
let c = set_calculator!(data.n50, c);
86+
// Irrelevant for osu!mania
87+
let c = set_calculator!(data.n100, c);
88+
// Irrelevant for osu!mania
89+
let c = set_calculator!(data.n300, c);
90+
// Only relevant for osu!ctb
91+
let c = set_calculator!(data.katu, n_katu, c);
92+
// Irrelevant for osu!mania
93+
let c = set_calculator!(data.miss, misses, c);
94+
let c = set_calculator!(data.passed_obj, passed_objects, c);
95+
// Only relevant for osu!mania
96+
let mut c = set_calculator!(data.score, c);
97+
// Irrelevant for osu!mania
9798
if let Some(acc) = data.acc {
9899
c.set_accuracy(acc)
99100
};

templates/main_page.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ <h1>Hello~ PP-server is DEVELOPING.</h1>
2424
<p>file_name ({artist} - {title} ({mapper}) [{diff_name}].osu)</p>
2525
<p>mode (0 = osu!, 1 = Taiko, 2 = CtB, 3 = osu!mania).</p>
2626
<p>mods (<a href="https://github.com/ppy/osu-api/wiki">See osu-api/wiki</a>)</p>
27-
<p>n50 (Count of 50)</p>
28-
<p>n100 (Count of 100)</p>
29-
<p>n300 (Count of 300)</p>
30-
<p>acc (float: 0-100)</p>
31-
<p>miss (Count of miss)</p>
32-
<p>combo (Your combo)</p>
33-
<p>katu (Count of katu)</p>
27+
<p>n50 (Count of 50) [ Irrelevant for osu!mania and osu!taiko ]</p>
28+
<p>n100 (Count of 100) [ Irrelevant for osu!mania ]</p>
29+
<p>n300 (Count of 300) [ Irrelevant for osu!mania ]</p>
30+
<p>acc (float: 0-100) [ Irrelevant for osu!mania ]</p>
31+
<p>miss (Count of miss) [ Irrelevant for osu!mania ]</p>
32+
<p>score [ Only relevant for osu!mania ]</p>
33+
<p>combo (Your combo) [ Irrelevant for osu!mania ]</p>
34+
<p>katu (Count of katu) [ Only relevant for osu!ctb ]</p>
3435
<p>passed_obj (If failed, use count of passed objects)</p>
3536
<p>simple (0 or 1; if 1, returns simple info)</p>
3637
<p>acc_list (0 or 1; if 1, calculate and returns pp results of acc 95, 98, 99, 100.</p>

0 commit comments

Comments
 (0)