mirror of https://github.com/Paoda/blue-gacha.git
fix: improve type signatures of some methods
This commit is contained in:
parent
3c47ec8d4f
commit
d5df9d4d30
|
@ -37,15 +37,15 @@ fn main() {
|
|||
|
||||
let gacha = GachaBuilder::new(ONE_STAR_RATE, TWO_STAR_RATE, THREE_STAR_RATE)
|
||||
.with_pool(students)
|
||||
.with_priority(&priority)
|
||||
.with_priority(priority)
|
||||
.finish()
|
||||
.unwrap();
|
||||
|
||||
// I'm some N5 loser don't judge too hard pls...
|
||||
let banner = BannerBuilder::new("不運ですね。")
|
||||
.with_name_translation(Language::English, "Unlucky, right?")
|
||||
.with_sparkable_students(&sparkable)
|
||||
.with_gacha(&gacha)
|
||||
.with_sparkable_students(sparkable)
|
||||
.with_gacha(gacha)
|
||||
.finish()
|
||||
.unwrap();
|
||||
|
||||
|
|
|
@ -65,9 +65,9 @@ impl BannerBuilder {
|
|||
/// let banner_builder = BannerBuilder::new("ピックアップ募集")
|
||||
/// .with_gacha(&gacha);
|
||||
/// ```
|
||||
pub fn with_gacha(self, gacha: &Gacha) -> Self {
|
||||
pub fn with_gacha(self, gacha: Gacha) -> Self {
|
||||
Self {
|
||||
gacha: Some(gacha.to_owned()),
|
||||
gacha: Some(gacha),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ impl BannerBuilder {
|
|||
/// let banner_builder = BannerBuilder::new("ピックアップ募集")
|
||||
/// .with_sparkable_students(&students);
|
||||
/// ```
|
||||
pub fn with_sparkable_students(self, students: &[Student]) -> Self {
|
||||
pub fn with_sparkable_students(self, students: Vec<Student>) -> Self {
|
||||
Self {
|
||||
sparkable: Some(students.to_vec()),
|
||||
..self
|
||||
|
|
11
src/gacha.rs
11
src/gacha.rs
|
@ -1,6 +1,11 @@
|
|||
use crate::student::{PriorityStudent, Student};
|
||||
use serde_repr::{Deserialize_repr, Serialize_repr};
|
||||
use std::cmp::Ordering;
|
||||
|
||||
const THREE_STAR_RATE: usize = 25;
|
||||
const TWO_STAR_RATE: usize = 185;
|
||||
const ONE_STAR_RATE: usize = 790;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize_repr, Deserialize_repr, PartialEq, Eq)]
|
||||
#[repr(u8)]
|
||||
/// The Available Rarities in Blue Archive's Gacha System
|
||||
|
@ -72,7 +77,7 @@ pub struct GachaBuilder {
|
|||
impl Default for GachaBuilder {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
rates: Some((790, 185, 25)),
|
||||
rates: Some((ONE_STAR_RATE, TWO_STAR_RATE, THREE_STAR_RATE)),
|
||||
pool: Default::default(),
|
||||
priority: Default::default(),
|
||||
}
|
||||
|
@ -146,9 +151,9 @@ impl GachaBuilder {
|
|||
/// .with_pool(pool)
|
||||
/// .with_priority(&priority);
|
||||
/// ```
|
||||
pub fn with_priority(self, students: &[PriorityStudent]) -> Self {
|
||||
pub fn with_priority(self, students: Vec<PriorityStudent>) -> Self {
|
||||
Self {
|
||||
priority: Some(students.to_vec()),
|
||||
priority: Some(students),
|
||||
..self
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue