multiple item drops

This commit is contained in:
ntr 2019-01-14 19:08:14 +11:00
parent 5776b1371f
commit a2fdae45aa
3 changed files with 33 additions and 23 deletions

View File

@ -12,6 +12,12 @@
* players can feel aggressive
# ask sam
* main screen layout
* ping icon
*
* combat screen layout
* health bars
* statuses
* icons
* skill type / damage type
* skills themselves
@ -24,7 +30,6 @@ strangle
## NOW
* rolls as a drop item
* check zone completion
## SOON
@ -35,7 +40,6 @@ strangle
* FAQ
* aoe skills
* keep track of games joined
* concede game on leave
* ko all cryps on team, check status

View File

@ -312,7 +312,7 @@ impl Game {
// check here as well so uncastable spells don't go on the stack
let check = cryp.disabled(skill);
if check.disabled {
return Err(format_err!("cryp cannot cast that skill {:?}", check.effects));
return Err(format_err!("skill disabled {:?}", check.effects));
}
}

View File

@ -7,7 +7,7 @@ use failure::Error;
// drops
use rand::prelude::*;
use rand::{thread_rng};
use rand::distributions::{WeightedIndex};
use rand::distributions::{LogNormal,WeightedIndex};
use account::Account;
use rpc::{ItemUseParams};
@ -90,30 +90,38 @@ fn mode_drops(mode: GameMode) -> Vec<(ItemAction, usize)> {
GameMode::Zone3v3HealerBoss => vec![
(ItemAction::RerollSpeed, 1),
],
_ => vec![
(ItemAction::RerollStamina, 1),
(ItemAction::RerollPhysDamage, 1),
(ItemAction::RerollSpellDamage, 1),
(ItemAction::RerollSpeed, 1),
(ItemAction::RerollArmour, 1),
(ItemAction::RerollSpellShield, 1),
(ItemAction::RerollEvasion, 1),
],
// _ => vec![
// (ItemAction::RerollStamina, 1),
// (ItemAction::RerollPhysDamage, 1),
// (ItemAction::RerollSpellDamage, 1),
// (ItemAction::RerollSpeed, 1),
// (ItemAction::RerollArmour, 1),
// (ItemAction::RerollSpellShield, 1),
// (ItemAction::RerollEvasion, 1),
// ],
}
}
pub fn item_drop(tx: &mut Transaction, account_id: Uuid, mode: GameMode) -> Result<Item, Error> {
pub fn item_drop(tx: &mut Transaction, account_id: Uuid, mode: GameMode) -> Result<(), Error> {
let mut rng = thread_rng();
let actions = mode_drops(mode);
let log_normal = LogNormal::new(1.0, 1.0);
let num_drops = log_normal.sample(&mut rng).floor() as u16;
let dist = WeightedIndex::new(actions.iter().map(|item| item.1)).unwrap();
let kind = actions[dist.sample(&mut rng)].0;
let item = Item::new(kind, account_id);
println!("{:?} drops", num_drops);
println!("{:?} dropped {:?}", account_id, item);
for _i in 0..num_drops {
let actions = mode_drops(mode);
return item_create(item, tx, account_id);
let dist = WeightedIndex::new(actions.iter().map(|item| item.1)).unwrap();
let kind = actions[dist.sample(&mut rng)].0;
let item = Item::new(kind, account_id);
println!("{:?} dropped {:?}", account_id, item);
item_create(item, tx, account_id)?;
}
Ok(())
}
@ -131,8 +139,6 @@ pub fn item_create(item: Item, tx: &mut Transaction, account_id: Uuid) -> Result
result.iter().next().expect("no row returned");
println!("{:?} wrote item {:}", account_id, item.id);
return Ok(item);
}
@ -173,7 +179,7 @@ pub fn item_delete(tx: &mut Transaction, id: Uuid) -> Result<(), Error> {
return Err(format_err!("unable to delete item {:?}", id));
}
println!("item deleted {:?}", id);
// println!("item deleted {:?}", id);
return Ok(());
}