Skip to content

Commit

Permalink
add --anonymous
Browse files Browse the repository at this point in the history
  • Loading branch information
Equim-chan committed Feb 6, 2021
1 parent 530e96f commit bfad68d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ $ akochan-reviewer -k E2.1,E3 "https://tenhou.net/0/?log=2019050417gm-0029-0000-
## Usage
```plain
USAGE:
akochan-reviewer [FLAGS] [OPTIONS] [URL]
akochan-reviewer.exe [FLAGS] [OPTIONS] [URL]
FLAGS:
--anonymous Do not include player names.
-h, --help Prints help information
--json Output review result in JSON instead of HTML.
--no-open Do not open the output file in browser after finishing.
Expand All @@ -65,7 +66,7 @@ OPTIONS:
0.001 when using placement. Default value: "0.001".
-i, --in-file <FILE> Specify a tenhou.net/6 format log file to review. If FILE is "-" or empty,
read from stdin.
-k, --kyokus <ARRAY> Specify kyokus to review. If ARRAY is empty, review all kyokus. Format:
-k, --kyokus <LIST> Specify kyokus to review. If LIST is empty, review all kyokus. Format:
"E1,E4,S3.1".
--lang <LANG> Set the language for the rendered report page. Default value "ja".
Supported languages: ja, en.
Expand All @@ -76,7 +77,7 @@ OPTIONS:
-o, --out-file <FILE> Specify the output file for generated HTML report. If FILE is "-", write to
stdout; if FILE is empty, write to "{tenhou_id}&tw={actor}.html" if
--tenhou-id is specified, otherwise "report.html".
--pt <ARRAY> Shortcut to override "jun_pt" in --tactics-config. Format: "90,45,0,-135".
--pt <LIST> Shortcut to override "jun_pt" in --tactics-config. Format: "90,45,0,-135".
-c, --tactics-config <FILE> Specify the tactics config file for akochan. Default value "tactics.json".
-t, --tenhou-id <ID> Specify a Tenhou log ID to review, overriding --in-file. Example:
"2019050417gm-0029-0000-4f2a8622".
Expand Down
10 changes: 10 additions & 0 deletions convlog/src/tenhou.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ mod json_scheme {
pub use json_scheme::{Log as RawLog, PartialLog as RawPartialLog};

impl RawLog {
#[inline]
pub fn hide_names(&mut self) {
self.names = [
"Aさん".to_owned(),
"Bさん".to_owned(),
"Cさん".to_owned(),
"Dさん".to_owned(),
];
}

#[inline]
pub fn filter_kyokus(&mut self, kyoku_filter: &KyokuFilter) {
self.logs
Expand Down
14 changes: 12 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ fn main() -> Result<()> {
.long("without-viewer")
.help("Do not include log viewer in the generated HTML report."),
)
.arg(
Arg::with_name("anonymous")
.long("anonymous")
.help("Do not include player names."),
)
.arg(
Arg::with_name("no-open")
.long("no-open")
Expand Down Expand Up @@ -300,7 +305,8 @@ fn main() -> Result<()> {
let arg_pt = matches.value_of("pt");
let arg_kyokus = matches.value_of("kyokus");
let arg_use_placement_ev = matches.is_present("use-placement-ev");
let arg_without_reviewer = matches.is_present("without-viewer");
let arg_without_viewer = matches.is_present("without-viewer");
let arg_anonymous = matches.is_present("anonymous");
let arg_no_open = matches.is_present("no-open");
let arg_no_review = matches.is_present("no-review");
let arg_json = matches.is_present("json");
Expand Down Expand Up @@ -393,6 +399,10 @@ fn main() -> Result<()> {
let mut l: tenhou::RawLog =
json::from_reader(log_reader).context("failed to parse tenhou log")?;

if arg_anonymous {
l.hide_names();
}

// filter kyokus
if let Some(s) = arg_kyokus {
let filter = s.parse().context("failed to parse kyoku filter")?;
Expand All @@ -407,7 +417,7 @@ fn main() -> Result<()> {
// See https://manishearth.github.io/blog/2017/04/13/prolonging-temporaries-in-rust/
// for the technique of extending the lifetime of temp var here.
let cloned_raw_log;
let splited_raw_logs = if !arg_without_reviewer {
let splited_raw_logs = if !arg_without_viewer {
cloned_raw_log = raw_log.clone();
Some(cloned_raw_log.split_by_kyoku())
} else {
Expand Down

0 comments on commit bfad68d

Please sign in to comment.