more vecs

This commit is contained in:
ntr 2018-08-05 23:02:04 +10:00
parent 2dd7128455
commit 820c56bb64

View File

@ -46,16 +46,16 @@ fn assign_dmg(a: &Cryp, t: &Turn) -> Cryp {
}
}
fn combat_phase(a: &Cryp, b: &Cryp) -> (Cryp, Cryp) {
fn combat_phase(a: &Cryp, b: &Cryp) -> Vec<Cryp> {
let a_turn = cryp_turn(&a);
let b_turn = cryp_turn(&b);
return (
return vec![
assign_dmg(&a, &b_turn),
assign_dmg(&b, &a_turn),
);
];
}
fn battle(a: Cryp, b: Cryp) -> (Cryp, Cryp) {
fn battle(a: &Cryp, b: &Cryp) -> Vec<Cryp> {
let mut cryps = vec![
a.clone(),
b.clone()
@ -63,10 +63,10 @@ fn battle(a: Cryp, b: Cryp) -> (Cryp, Cryp) {
loop {
let combat = combat_phase(&cryps[0], &cryps[1]);
println!("{:?}", combat);
if combat.0.stam == 0 || combat.1.stam == 0 {
if combat.iter().any(|c| c.stam == 0) {
return combat;
}
cryps = vec![combat.0, combat.1];
cryps = combat;
}
}
@ -107,7 +107,7 @@ pub fn main() {
stam: 25,
};
battle(a, b);
battle(&a, &b);
return;
}