Skip to content

Commit

Permalink
publish: v0.5.0 - up-to-date
Browse files Browse the repository at this point in the history
- Using peace-performance v0.4.0 (latest)
- Fix: Mania calculate (add `score` fields)
  • Loading branch information
Pure-Peace committed Aug 18, 2021
1 parent 06c4faf commit 0880e52
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 49 deletions.
30 changes: 22 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[package]
name = "pp-server"
version = "0.4.2"
version = "0.5.0"
authors = ["Pure-Peace <940857703@qq.com>"]
edition = "2018"
license = "MIT"
repository = "https://github.com/pure-peace/pp-server"
default-run = "pp-server-with-peace"

[[bin]]
name = "pp-server-with-peace"
Expand Down Expand Up @@ -44,26 +45,39 @@ json = "0.12.4"
log = "0.4.14"
ntex = "0.3"
prometheus = { version = "0.12", features = ["process"] }
reqwest = { version = "0.11", features = ["rustls-tls", "json"], default-features = false }
reqwest = { version = "0.11", features = [
"rustls-tls",
"json",
], default-features = false }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_str = "0.1.0"
tokio = { version = "1.7" }
tokio = { version = "1.9" }


# Feature peace
deadpool-postgres = { version = "0.9", optional = true }
deadpool-redis = { version = "0.8", optional = true }
tokio-postgres = { version = "0.7", features = ["with-chrono-0_4", "with-serde_json-1"], optional = true }
tokio-postgres = { version = "0.7", features = [
"with-chrono-0_4",
"with-serde_json-1",
], optional = true }

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

# Git
peace-constants = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main" }
peace-database = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main", features = ["with_peace"], optional = true }
peace-objects = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main", features = ["osu_file_downloader"], optional = true }
peace-database = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main", features = [
"with_peace",
], optional = true }
peace-objects = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main", features = [
"osu_file_downloader",
], optional = true }
peace-settings = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main" }
peace-utils = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main", features = ["web", "async_file"] }
peace-utils = { git = "https://github.com/Pure-Peace/Peace.git", branch = "main", features = [
"web",
"async_file",
] }

# Local (download peace manual)
# peace-constants = { path = "../../Peace/peace-constants" }
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ This method is currently cannot use cache.
Set Cargo.toml

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

to

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

## Note
Expand Down
65 changes: 33 additions & 32 deletions src/objects/calculator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,21 @@ use {
use peace_objects::beatmaps::traits::{BeatmapCacheStorage, MyBeatmapCache};
use peace_performance::{AnyPP, Beatmap as PPbeatmap, FruitsPP, ManiaPP, OsuPP, PpResult, TaikoPP};

macro_rules! set_calculator {
($target:ident.$attr:ident, $calculator:ident) => {
match $target.$attr {
Some($attr) => $calculator.$attr($attr),
None => $calculator,
}
};
($target:ident.$attr:ident, $func:ident, $calculator:ident) => {
match $target.$attr {
Some($attr) => $calculator.$func($attr),
None => $calculator,
}
};
}

#[derive(PartialEq)]
pub enum GetBeatmapError {
FileNotFound,
Expand Down Expand Up @@ -53,6 +68,7 @@ pub struct CalcData {
pub passed_obj: Option<usize>,
pub combo: Option<usize>,
pub miss: Option<usize>,
pub score: Option<u32>,
pub simple: Option<i32>,
pub acc_list: Option<i32>,
pub no_miss: Option<i32>,
Expand All @@ -62,38 +78,23 @@ pub struct CalcData {
pub async fn calculate_pp(beatmap: &PPbeatmap, data: &CalcData) -> PpResult {
// Get target mode calculator
let c = mode_calculator(data.mode.unwrap_or(4), &beatmap);
let c = match data.mods {
Some(mods) => c.mods(mods),
None => c,
};
let c = match data.combo {
Some(combo) => c.combo(combo),
None => c,
};
let c = match data.n50 {
Some(n50) => c.n50(n50),
None => c,
};
let c = match data.n100 {
Some(n100) => c.n100(n100),
None => c,
};
let c = match data.n300 {
Some(n300) => c.n300(n300),
None => c,
};
let c = match data.katu {
Some(katu) => c.n_katu(katu),
None => c,
};
let c = match data.miss {
Some(miss) => c.misses(miss),
None => c,
};
let mut c = match data.passed_obj {
Some(passed_obj) => c.passed_objects(passed_obj),
None => c,
};
let c = set_calculator!(data.mods, c);
// Irrelevant for osu!mania
let c = set_calculator!(data.combo, c);
// Irrelevant for osu!mania and osu!taiko
let c = set_calculator!(data.n50, c);
// Irrelevant for osu!mania
let c = set_calculator!(data.n100, c);
// Irrelevant for osu!mania
let c = set_calculator!(data.n300, c);
// Only relevant for osu!ctb
let c = set_calculator!(data.katu, n_katu, c);
// Irrelevant for osu!mania
let c = set_calculator!(data.miss, misses, c);
let c = set_calculator!(data.passed_obj, passed_objects, c);
// Only relevant for osu!mania
let mut c = set_calculator!(data.score, c);
// Irrelevant for osu!mania
if let Some(acc) = data.acc {
c.set_accuracy(acc)
};
Expand Down
15 changes: 8 additions & 7 deletions templates/main_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ <h1>Hello~ PP-server is DEVELOPING.</h1>
<p>file_name ({artist} - {title} ({mapper}) [{diff_name}].osu)</p>
<p>mode (0 = osu!, 1 = Taiko, 2 = CtB, 3 = osu!mania).</p>
<p>mods (<a href="https://github.com/ppy/osu-api/wiki">See osu-api/wiki</a>)</p>
<p>n50 (Count of 50)</p>
<p>n100 (Count of 100)</p>
<p>n300 (Count of 300)</p>
<p>acc (float: 0-100)</p>
<p>miss (Count of miss)</p>
<p>combo (Your combo)</p>
<p>katu (Count of katu)</p>
<p>n50 (Count of 50) [ Irrelevant for osu!mania and osu!taiko ]</p>
<p>n100 (Count of 100) [ Irrelevant for osu!mania ]</p>
<p>n300 (Count of 300) [ Irrelevant for osu!mania ]</p>
<p>acc (float: 0-100) [ Irrelevant for osu!mania ]</p>
<p>miss (Count of miss) [ Irrelevant for osu!mania ]</p>
<p>score [ Only relevant for osu!mania ]</p>
<p>combo (Your combo) [ Irrelevant for osu!mania ]</p>
<p>katu (Count of katu) [ Only relevant for osu!ctb ]</p>
<p>passed_obj (If failed, use count of passed objects)</p>
<p>simple (0 or 1; if 1, returns simple info)</p>
<p>acc_list (0 or 1; if 1, calculate and returns pp results of acc 95, 98, 99, 100.</p>
Expand Down

0 comments on commit 0880e52

Please sign in to comment.