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 * players can feel aggressive
# ask sam # ask sam
* main screen layout
* ping icon
*
* combat screen layout
* health bars
* statuses
* icons * icons
* skill type / damage type * skill type / damage type
* skills themselves * skills themselves
@ -24,7 +30,6 @@ strangle
## NOW ## NOW
* rolls as a drop item
* check zone completion * check zone completion
## SOON ## SOON
@ -35,7 +40,6 @@ strangle
* FAQ * FAQ
* aoe skills * aoe skills
* keep track of games joined * keep track of games joined
* concede game on leave * concede game on leave
* ko all cryps on team, check status * 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 // check here as well so uncastable spells don't go on the stack
let check = cryp.disabled(skill); let check = cryp.disabled(skill);
if check.disabled { 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 // drops
use rand::prelude::*; use rand::prelude::*;
use rand::{thread_rng}; use rand::{thread_rng};
use rand::distributions::{WeightedIndex}; use rand::distributions::{LogNormal,WeightedIndex};
use account::Account; use account::Account;
use rpc::{ItemUseParams}; use rpc::{ItemUseParams};
@ -90,21 +90,27 @@ fn mode_drops(mode: GameMode) -> Vec<(ItemAction, usize)> {
GameMode::Zone3v3HealerBoss => vec![ GameMode::Zone3v3HealerBoss => vec![
(ItemAction::RerollSpeed, 1), (ItemAction::RerollSpeed, 1),
], ],
_ => vec![ // _ => vec![
(ItemAction::RerollStamina, 1), // (ItemAction::RerollStamina, 1),
(ItemAction::RerollPhysDamage, 1), // (ItemAction::RerollPhysDamage, 1),
(ItemAction::RerollSpellDamage, 1), // (ItemAction::RerollSpellDamage, 1),
(ItemAction::RerollSpeed, 1), // (ItemAction::RerollSpeed, 1),
(ItemAction::RerollArmour, 1), // (ItemAction::RerollArmour, 1),
(ItemAction::RerollSpellShield, 1), // (ItemAction::RerollSpellShield, 1),
(ItemAction::RerollEvasion, 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 mut rng = thread_rng();
let log_normal = LogNormal::new(1.0, 1.0);
let num_drops = log_normal.sample(&mut rng).floor() as u16;
println!("{:?} drops", num_drops);
for _i in 0..num_drops {
let actions = mode_drops(mode); let actions = mode_drops(mode);
let dist = WeightedIndex::new(actions.iter().map(|item| item.1)).unwrap(); let dist = WeightedIndex::new(actions.iter().map(|item| item.1)).unwrap();
@ -112,8 +118,10 @@ pub fn item_drop(tx: &mut Transaction, account_id: Uuid, mode: GameMode) -> Resu
let item = Item::new(kind, account_id); let item = Item::new(kind, account_id);
println!("{:?} dropped {:?}", account_id, item); println!("{:?} dropped {:?}", account_id, item);
item_create(item, tx, account_id)?;
}
return 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"); result.iter().next().expect("no row returned");
println!("{:?} wrote item {:}", account_id, item.id);
return Ok(item); 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)); return Err(format_err!("unable to delete item {:?}", id));
} }
println!("item deleted {:?}", id); // println!("item deleted {:?}", id);
return Ok(()); return Ok(());
} }