-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
41 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use std::collections::HashMap; | ||
|
||
use crate::tarnished::Tarnished; | ||
|
||
pub trait StrikeClient { | ||
fn add_strike(&self, name: &str) -> HashMap<String, i8>; | ||
fn get_tarnished(&self) -> Vec<Tarnished>; | ||
fn clear_strikes(&self); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod local_client; | ||
pub mod remote_client; | ||
pub mod client; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod configuration; | ||
pub mod clients; | ||
pub mod output; | ||
pub mod tarnished; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use std::collections::HashMap; | ||
|
||
#[derive(Debug, PartialEq, Clone)] | ||
pub struct Tarnished { | ||
pub name: String, | ||
pub strikes: u8, | ||
} | ||
|
||
impl Tarnished { | ||
pub fn sort_desc_by_strike(tarnished: Vec<Tarnished>) -> Vec<Tarnished> { | ||
let mut tarnished = tarnished.clone(); | ||
tarnished.sort_by(|a, b| b.strikes.partial_cmp(&a.strikes).unwrap()); | ||
tarnished | ||
} | ||
|
||
pub fn as_tarnished(db: HashMap<String, u8>) -> Vec<Tarnished> { | ||
db.iter() | ||
.map(|(name, strikes)| Tarnished { | ||
name: name.to_string(), | ||
strikes: *strikes, | ||
}) | ||
.collect() | ||
} | ||
} | ||
|