1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use std::collections::HashMap;
use super::slab_def::*;
const SKILL_NOOB: &str = "noob";
const SKILL_EASY: &str = "easy";
const SKILL_MEDIUM: &str = "medium";
const SKILL_HARD: &str = "hard";
const SKILL_EXPERT: &str = "expert";
#[derive(Debug, Clone, Copy)]
pub enum Skill {
Noob,
Easy,
Medium,
Hard,
Expert,
}
impl Skill {
pub fn from_str(name: &str) -> Self {
match name {
SKILL_NOOB => Skill::Noob,
SKILL_EASY => Skill::Easy,
SKILL_MEDIUM => Skill::Medium,
SKILL_HARD => Skill::Hard,
SKILL_EXPERT => Skill::Expert,
&_ => Skill::Medium,
}
}
pub fn as_str(&self) -> &'static str {
match self {
Skill::Noob => SKILL_NOOB,
Skill::Easy => SKILL_EASY,
Skill::Medium => SKILL_MEDIUM,
Skill::Hard => SKILL_HARD,
Skill::Expert => SKILL_EXPERT,
}
}
pub fn width(&self) -> usize {
match self {
Skill::Noob => 8,
Skill::Easy => 9,
Skill::Medium => 10,
Skill::Hard => 11,
Skill::Expert => 12,
}
}
pub fn def_density(self) -> HashMap<SlabDef, f64> {
let mut ret = HashMap::new();
match self {
Skill::Noob => {
ret.insert(SlabDef::Floor, 0.94);
ret.insert(SlabDef::Boost, 0.01);
}
Skill::Easy => {
ret.insert(SlabDef::Floor, 0.83);
ret.insert(SlabDef::Boost, 0.02);
}
Skill::Medium => {
ret.insert(SlabDef::Floor, 0.7);
ret.insert(SlabDef::Boost, 0.05);
}
Skill::Hard => {
ret.insert(SlabDef::Floor, 0.6);
ret.insert(SlabDef::Boost, 0.1);
}
Skill::Expert => {
ret.insert(SlabDef::Floor, 0.5);
ret.insert(SlabDef::Boost, 0.1);
}
}
ret
}
}