big getup for ubuntu setup, construct colour based skills
This commit is contained in:
@@ -236,7 +236,7 @@ impl Construct {
|
||||
green_life: ConstructStat { base: 400, value: 400, max: 400, stat: Stat::GreenLife },
|
||||
speed: ConstructStat { base: 100, value: 100, max: 100, stat: Stat::Speed },
|
||||
// evasion: ConstructStat { base: 0, value: 0, max: 0, stat: Stat::Evasion },
|
||||
skills: vec![],
|
||||
skills: vec![ConstructSkill::new(Skill::Attack)],
|
||||
effects: vec![],
|
||||
specs: vec![],
|
||||
colours: Colours::new(),
|
||||
|
||||
+83
-22
@@ -7,7 +7,7 @@ use failure::err_msg;
|
||||
|
||||
use construct::{Construct, Colours};
|
||||
use vbox::{Vbox, ItemType, VboxIndices};
|
||||
use item::{Item, ItemEffect};
|
||||
use item::{Item, ItemEffect, get_combos};
|
||||
use effect::{Effect};
|
||||
|
||||
const DISCARD_COST: usize = 2;
|
||||
@@ -297,17 +297,21 @@ impl Player {
|
||||
Some(ItemEffect::Skill) => {
|
||||
let skill = item.into_skill().ok_or(format_err!("item {:?} has no associated skill", item))?;
|
||||
let construct = self.construct_get(construct_id)?;
|
||||
// done here because i teach them a tonne of skills for tests
|
||||
let max_skills = 3;
|
||||
if construct.skills.len() >= max_skills {
|
||||
return Err(format_err!("construct at max skills ({:?})", max_skills));
|
||||
}
|
||||
|
||||
if construct.knows(skill) {
|
||||
return Err(format_err!("construct already knows skill ({:?})" , skill));
|
||||
}
|
||||
|
||||
construct.skills = vec![];
|
||||
construct.learn_mut(skill);
|
||||
|
||||
// // done here because i teach them a tonne of skills for tests
|
||||
// let max_skills = 1;
|
||||
// if construct.skills.len() >= max_skills {
|
||||
// return Err(format_err!("construct at max skills ({:?})", max_skills));
|
||||
// }
|
||||
|
||||
// if construct.knows(skill) {
|
||||
// return Err(format_err!("construct already knows skill ({:?})" , skill));
|
||||
// }
|
||||
|
||||
// construct.learn_mut(skill);
|
||||
},
|
||||
Some(ItemEffect::Spec) => {
|
||||
let spec = item.into_spec().ok_or(format_err!("item {:?} has no associated spec", item))?;
|
||||
@@ -318,19 +322,76 @@ impl Player {
|
||||
None => return Err(err_msg("item has no effect on constructs")),
|
||||
}
|
||||
|
||||
// now the item has been applied
|
||||
// recalculate the stats of the whole player
|
||||
let player_colours = self.constructs.iter().fold(Colours::new(), |tc, c| {
|
||||
Colours {
|
||||
red: tc.red + c.colours.red,
|
||||
green: tc.green + c.colours.green,
|
||||
blue: tc.blue + c.colours.blue
|
||||
}
|
||||
});
|
||||
let construct = self.construct_get(construct_id)?;
|
||||
|
||||
for construct in self.constructs.iter_mut() {
|
||||
construct.apply_modifiers(&player_colours);
|
||||
}
|
||||
// force 1 skill for auto
|
||||
let mut colour_counts = vec![
|
||||
(Item::Red, construct.colours.red),
|
||||
(Item::Green, construct.colours.green),
|
||||
(Item::Blue, construct.colours.blue),
|
||||
];
|
||||
colour_counts.sort_unstable_by_key(|cc| cc.1);
|
||||
colour_counts.reverse();
|
||||
|
||||
println!("{:?}", colour_counts);
|
||||
|
||||
let total = (construct.colours.red + construct.colours.green + construct.colours.blue) as f64;
|
||||
let colour_pcts = colour_counts.iter_mut()
|
||||
.map(|cc| (cc.0, cc.1 as f64 / total))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
println!("{:?}", colour_pcts);
|
||||
|
||||
let skill_item = match item.into_skill().is_some() {
|
||||
true => item,
|
||||
false => construct.skills[0].skill.base(),
|
||||
};
|
||||
|
||||
let colour_skill = {
|
||||
// no colours
|
||||
if colour_pcts[0].1.is_infinite() {
|
||||
construct.skills[0].skill
|
||||
} else {
|
||||
let mut skill_item_combo = {
|
||||
if colour_pcts[0].1 > 0.75 {
|
||||
vec![skill_item, colour_pcts[0].0, colour_pcts[0].0]
|
||||
} else if colour_pcts[1].1 > 0.4 {
|
||||
vec![skill_item, colour_pcts[0].0, colour_pcts[1].0]
|
||||
} else {
|
||||
// special triple skill_item
|
||||
vec![skill_item, colour_pcts[0].0, colour_pcts[1].0]
|
||||
}
|
||||
};
|
||||
|
||||
skill_item_combo.sort_unstable();
|
||||
|
||||
println!("{:?}", skill_item_combo);
|
||||
let combos = get_combos();
|
||||
let combo = combos.iter().find(|c| c.components == skill_item_combo)
|
||||
.ok_or(err_msg("no combo for colour skill"))?;
|
||||
|
||||
combo.item.into_skill()
|
||||
.ok_or(format_err!("item {:?} has no associated skill", combo.item))?
|
||||
}
|
||||
};
|
||||
|
||||
// unlearn everything
|
||||
construct.skills = vec![];
|
||||
construct.learn_mut(colour_skill);
|
||||
|
||||
// // now the item has been applied
|
||||
// // recalculate the stats of the whole player
|
||||
// let player_colours = self.constructs.iter().fold(Colours::new(), |tc, c| {
|
||||
// Colours {
|
||||
// red: tc.red + c.colours.red,
|
||||
// green: tc.green + c.colours.green,
|
||||
// blue: tc.blue + c.colours.blue
|
||||
// }
|
||||
// });
|
||||
|
||||
// for construct in self.constructs.iter_mut() {
|
||||
// construct.apply_modifiers(&player_colours);
|
||||
// }
|
||||
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
+2
-2
@@ -896,12 +896,12 @@ impl Skill {
|
||||
.collect::<Vec<Colour>>();
|
||||
}
|
||||
|
||||
fn _base(&self) -> Skill {
|
||||
pub fn base(&self) -> Item {
|
||||
let bases = [Item::Attack, Item::Stun, Item::Buff, Item::Debuff, Item::Block];
|
||||
match self.components()
|
||||
.iter()
|
||||
.find(|i| bases.contains(i)) {
|
||||
Some(i) => i.into_skill().unwrap(),
|
||||
Some(i) => *i,
|
||||
None => panic!("{:?} has no base item", self),
|
||||
}
|
||||
}
|
||||
|
||||
+22
-7
@@ -27,11 +27,11 @@ pub enum ItemType {
|
||||
Specs,
|
||||
}
|
||||
|
||||
const STORE_COLOURS_CAPACITY: usize = 6;
|
||||
const STORE_SKILLS_CAPACITY: usize = 3;
|
||||
const STORE_COLOURS_CAPACITY: usize = 0;
|
||||
const STORE_SKILLS_CAPACITY: usize = 2;
|
||||
const STORE_SPECS_CAPACITY: usize = 3;
|
||||
const STASH_CAPACITY: usize = 6;
|
||||
const STARTING_ATTACK_COUNT: usize = 3;
|
||||
const STASH_CAPACITY: usize = 0;
|
||||
const STARTING_ATTACK_COUNT: usize = 0;
|
||||
|
||||
impl Vbox {
|
||||
pub fn new() -> Vbox {
|
||||
@@ -92,9 +92,24 @@ impl Vbox {
|
||||
let skill_dist = WeightedIndex::new(skills.iter().map(|item| item.1)).unwrap();
|
||||
|
||||
let specs = vec![
|
||||
(Item::Power, 1),
|
||||
(Item::Life, 1),
|
||||
(Item::Speed, 1),
|
||||
(Item::PowerGG, 1),
|
||||
(Item::PowerRR, 1),
|
||||
(Item::PowerBB, 1),
|
||||
(Item::PowerRG, 1),
|
||||
(Item::PowerGB, 1),
|
||||
(Item::PowerRB, 1),
|
||||
(Item::LifeGG, 1),
|
||||
(Item::LifeRR, 1),
|
||||
(Item::LifeBB, 1),
|
||||
(Item::LifeRG, 1),
|
||||
(Item::LifeGB, 1),
|
||||
(Item::LifeRB, 1),
|
||||
(Item::SpeedGG, 1),
|
||||
(Item::SpeedRR, 1),
|
||||
(Item::SpeedBB, 1),
|
||||
(Item::SpeedRG, 1),
|
||||
(Item::SpeedGB, 1),
|
||||
(Item::SpeedRB, 1),
|
||||
];
|
||||
let spec_dist = WeightedIndex::new(specs.iter().map(|item| item.1)).unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user