Coverage(actions) - Adds coverage of actions.rs #27
|
|
@ -1,6 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="coverage: 22%">
|
||||
<title>coverage: 22%</title>
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="coverage: 48%">
|
||||
<title>coverage: 48%</title>
|
||||
<linearGradient id="s" x2="0" y2="100%">
|
||||
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
||||
<stop offset="1" stop-opacity=".1"/>
|
||||
|
|
@ -16,8 +16,8 @@
|
|||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
|
||||
<text aria-hidden="true" x="315" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">coverage</text>
|
||||
<text x="315" y="140" transform="scale(.1)" fill="#fff" textLength="510">coverage</text>
|
||||
<text aria-hidden="true" x="775" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">22%</text>
|
||||
<text x="775" y="140" transform="scale(.1)" fill="#fff" textLength="250">22%</text>
|
||||
<text aria-hidden="true" x="775" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">48%</text>
|
||||
<text x="775" y="140" transform="scale(.1)" fill="#fff" textLength="250">48%</text>
|
||||
</g>
|
||||
<script xmlns=""/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
|
@ -1,13 +1,13 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="coverage: 22%">
|
||||
<title>coverage: 22%</title>
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="coverage: 48%">
|
||||
<title>coverage: 48%</title>
|
||||
<g shape-rendering="crispEdges">
|
||||
<rect width="61" height="20" fill="#555"/>
|
||||
<rect x="61" width="35" height="20" fill="#e05d44"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
|
||||
<text x="315" y="140" transform="scale(.1)" fill="#fff" textLength="510">coverage</text>
|
||||
<text x="775" y="140" transform="scale(.1)" fill="#fff" textLength="250">22%</text>
|
||||
<text x="775" y="140" transform="scale(.1)" fill="#fff" textLength="250">48%</text>
|
||||
</g>
|
||||
<script xmlns=""/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 712 B After Width: | Height: | Size: 712 B |
|
|
@ -1,13 +1,13 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" width="142.5" height="28" role="img" aria-label="COVERAGE: 22%">
|
||||
<title>COVERAGE: 22%</title>
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" width="142.5" height="28" role="img" aria-label="COVERAGE: 48%">
|
||||
<title>COVERAGE: 48%</title>
|
||||
<g shape-rendering="crispEdges">
|
||||
<rect width="91" height="28" fill="#555"/>
|
||||
<rect x="91" width="51.5" height="28" fill="#e05d44"/>
|
||||
</g>
|
||||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="100">
|
||||
<text fill="#fff" x="455" y="175" transform="scale(.1)" textLength="670">COVERAGE</text>
|
||||
<text fill="#fff" x="1167.5" y="175" font-weight="bold" transform="scale(.1)" textLength="275">22%</text>
|
||||
<text fill="#fff" x="1167.5" y="175" font-weight="bold" transform="scale(.1)" textLength="275">48%</text>
|
||||
</g>
|
||||
<script xmlns=""/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 739 B After Width: | Height: | Size: 739 B |
|
|
@ -1,6 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="18" role="img" aria-label="coverage: 22%">
|
||||
<title>coverage: 22%</title>
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="18" role="img" aria-label="coverage: 48%">
|
||||
<title>coverage: 48%</title>
|
||||
<linearGradient id="s" x2="0" y2="100%">
|
||||
<stop offset="0" stop-color="#fff" stop-opacity=".7"/>
|
||||
<stop offset=".1" stop-color="#aaa" stop-opacity=".1"/>
|
||||
|
|
@ -18,8 +18,8 @@
|
|||
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
|
||||
<text aria-hidden="true" x="315" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">coverage</text>
|
||||
<text x="315" y="130" transform="scale(.1)" fill="#fff" textLength="510">coverage</text>
|
||||
<text aria-hidden="true" x="775" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">22%</text>
|
||||
<text x="775" y="130" transform="scale(.1)" fill="#fff" textLength="250">22%</text>
|
||||
<text aria-hidden="true" x="775" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">48%</text>
|
||||
<text x="775" y="130" transform="scale(.1)" fill="#fff" textLength="250">48%</text>
|
||||
</g>
|
||||
<script xmlns=""/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
|
@ -1,6 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" width="99" height="20" role="img" aria-label="Coverage: 22%">
|
||||
<title>Coverage: 22%</title>
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink" width="99" height="20" role="img" aria-label="Coverage: 48%">
|
||||
<title>Coverage: 48%</title>
|
||||
<style>a:hover #llink{fill:url(#b);stroke:#ccc}a:hover #rlink{fill:#4183c4}</style>
|
||||
<linearGradient id="a" x2="0" y2="100%">
|
||||
<stop offset="0" stop-color="#fcfcfc" stop-opacity="0"/>
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
<rect id="llink" stroke="#d5d5d5" fill="url(#a)" x=".5" y=".5" width="61" height="19" rx="2"/>
|
||||
<text aria-hidden="true" x="305" y="150" fill="#fff" transform="scale(.1)" textLength="510">Coverage</text>
|
||||
<text x="305" y="140" transform="scale(.1)" textLength="510">Coverage</text>
|
||||
<text aria-hidden="true" x="825" y="150" fill="#fff" transform="scale(.1)" textLength="230">22%</text>
|
||||
<text id="rlink" x="825" y="140" transform="scale(.1)" textLength="230">22%</text>
|
||||
<text aria-hidden="true" x="825" y="150" fill="#fff" transform="scale(.1)" textLength="230">48%</text>
|
||||
<text id="rlink" x="825" y="140" transform="scale(.1)" textLength="230">48%</text>
|
||||
</g>
|
||||
<script xmlns=""/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
|
@ -454,3 +454,96 @@ lazy_static! {
|
|||
/// Initialize a static pseudo &Craft: ACTIONS
|
||||
pub static ref ACTIONS: ActionList = ActionList::default();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::action::ACTIONS;
|
||||
use pretty_assertions::assert_eq;
|
||||
use strum::IntoEnumIterator;
|
||||
#[test]
|
||||
pub fn test_structs() {
|
||||
let ac = crate::action::Action {
|
||||
name: "Michel".to_string(),
|
||||
dur: 0,
|
||||
cp: 0,
|
||||
progress: 0,
|
||||
quality: 0,
|
||||
buff: None,
|
||||
short_name: "miguel".to_string(),
|
||||
};
|
||||
let ab = crate::action::ActionBuilder { action: ac };
|
||||
let ba = crate::action::ActionBuilder::new(&"Basic Synthesis");
|
||||
let _ = crate::action::ActionBuilder::new(&"Groundwork");
|
||||
let cs = crate::action::ActionBuilder::new(&"Careful Synthesis");
|
||||
ab.dur(10)
|
||||
.cp(10)
|
||||
.progress(10)
|
||||
.quality(10)
|
||||
.buff(None)
|
||||
.build();
|
||||
let act1 = ba.cp(10).dur(22).progress(33).quality(44).build();
|
||||
let act2 = cs.cp(10).dur(22).progress(33).quality(44).build();
|
||||
assert_eq!(act1, act2);
|
||||
format!("{:?}", act1);
|
||||
let _ = crate::action::ActionList::default();
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_with_craft() {
|
||||
let mut bbs = crate::specs::BuffState::default();
|
||||
for buff in crate::specs::Buff::iter() {
|
||||
bbs.apply(buff, 2);
|
||||
}
|
||||
let mut act1 = crate::action::ActionBuilder::new(&"Basic Synthesis")
|
||||
.dur(22)
|
||||
.cp(10)
|
||||
.progress(100)
|
||||
.quality(100)
|
||||
.build();
|
||||
let mut craft = crate::craft::Craft::default();
|
||||
craft.buffs = bbs;
|
||||
|
||||
assert_eq!(act1.get_name(), "Basic Synthesis");
|
||||
assert_eq!(act1.get_cp_cost(&craft), 10);
|
||||
assert_eq!(act1.get_durability_cost(&craft), 11);
|
||||
assert_eq!(act1.get_progress(&craft), 250);
|
||||
assert_eq!(act1.get_quality(&craft), 300);
|
||||
assert_eq!(act1.get_buff(), None);
|
||||
|
||||
assert!(act1.can_use(&craft));
|
||||
|
||||
assert_eq!(&ACTIONS.standard_touch.get_cp_cost(&craft), &18);
|
||||
assert_eq!(&ACTIONS.advanced_touch.get_cp_cost(&craft), &18);
|
||||
assert_eq!(&ACTIONS.masters_mend.get_durability_cost(&craft), &30);
|
||||
|
||||
assert_eq!(&ACTIONS.byregot_blessing.get_quality(&craft), &420);
|
||||
assert_eq!(&ACTIONS.byregot_blessing.can_use(&craft), &true);
|
||||
assert_eq!(&ACTIONS.muscle_memory.can_use(&craft), &true);
|
||||
assert_eq!(&ACTIONS.trained_finesse.can_use(&craft), &false);
|
||||
assert_eq!(&ACTIONS.reflect.can_use(&craft), &true);
|
||||
|
||||
act1.progress = 0;
|
||||
act1.quality = 0;
|
||||
assert_eq!(act1.get_durability_cost(&craft), 0);
|
||||
act1.dur = 0;
|
||||
act1.progress = 100;
|
||||
act1.quality = 100;
|
||||
assert_eq!(act1.get_durability_cost(&craft), 0);
|
||||
|
||||
act1.dur = 20;
|
||||
craft.durability = 10;
|
||||
craft.buffs = crate::specs::BuffState::default();
|
||||
assert_eq!(act1.get_progress(&craft), 50);
|
||||
assert_eq!(act1.get_quality(&craft), 50);
|
||||
|
||||
act1.dur = 2;
|
||||
assert_eq!(act1.get_durability_cost(&craft), 5);
|
||||
|
||||
craft.cp = 0;
|
||||
assert_eq!(&ACTIONS.reflect.can_use(&craft), &false);
|
||||
|
||||
craft.cp = 100;
|
||||
craft.success = crate::specs::Success::Failure;
|
||||
assert_eq!(&ACTIONS.reflect.can_use(&craft), &false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
36
src/craft.rs
|
|
@ -42,7 +42,6 @@ pub struct Craft<'a> {
|
|||
|
||||
impl<'a> Craft<'a> {
|
||||
/// Create a new craft with a recipe, stats and parameters
|
||||
///
|
||||
pub fn new(recipe: Recipe, stats: Stats, params: Parameters) -> Craft<'a> {
|
||||
Self {
|
||||
recipe,
|
||||
|
|
@ -184,9 +183,42 @@ impl<'a> Display for Craft<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl<'a> Craft<'a> {
|
||||
/// Create a "Default" craft, testing only
|
||||
pub fn default() -> Craft<'a> {
|
||||
Self::new(
|
||||
crate::specs::Recipe {
|
||||
durability: 200,
|
||||
progress: 200,
|
||||
progress_divider: 100,
|
||||
progress_modifier: 100,
|
||||
quality: 100,
|
||||
quality_divider: 100,
|
||||
quality_modifier: 100,
|
||||
},
|
||||
crate::specs::Stats {
|
||||
craftsmanship: 200,
|
||||
control: 200,
|
||||
max_cp: 200,
|
||||
},
|
||||
crate::io::Parameters {
|
||||
threads: 10,
|
||||
verbose: 2,
|
||||
depth: 10,
|
||||
desperate: false,
|
||||
byregot_step: 10,
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
// use pretty_assertions::assert_eq;
|
||||
// Struct Test
|
||||
#[test]
|
||||
pub fn struct_tests() {}
|
||||
pub fn struct_tests() {
|
||||
let _craft = crate::craft::Craft::default();
|
||||
}
|
||||
}
|
||||
|
|
|
|||