player names

This commit is contained in:
ntr 2019-03-15 12:51:30 +11:00
parent c2fe8f779e
commit 42b35f9d8c
4 changed files with 16 additions and 9 deletions

View File

@ -9,11 +9,14 @@
# WORK WORK # WORK WORK
## NOW ## NOW
cost system for items
be able to reclaim skills / specs from cryp be able to reclaim skills / specs from cryp
combo specs combo specs
randomise skill speed randomise skill speed
scoreboard
constants
round system for games round system for games
join instance join instance
is pve? is pve?

View File

@ -58,7 +58,7 @@ impl Instance {
self.players = iter::repeat_with(|| { self.players = iter::repeat_with(|| {
let bot_id = Uuid::new_v4(); let bot_id = Uuid::new_v4();
let cryps = instance_mobs(bot_id); let cryps = instance_mobs(bot_id);
Player::new(bot_id, self.id, cryps).set_bot(true) Player::new(bot_id, self.id, &bot_id.to_string(), cryps).set_bot(true)
}) })
.take(15) .take(15)
.collect::<Vec<Player>>(); .collect::<Vec<Player>>();
@ -400,7 +400,7 @@ pub fn instance_join(params: InstanceJoinParams, tx: &mut Transaction, account:
return Err(format_err!("incorrect team size. ({:})", 3)); return Err(format_err!("incorrect team size. ({:})", 3));
} }
let mut player = Player::new(account.id, instance.id, cryps); let mut player = Player::new(account.id, instance.id, &account.name, cryps);
player.vbox.fill(); player.vbox.fill();
let player = player_create(tx, player, account)?; let player = player_create(tx, player, account)?;
@ -515,7 +515,7 @@ mod tests {
let player_id = Uuid::new_v4(); let player_id = Uuid::new_v4();
let cryps = instance_mobs(player_id); let cryps = instance_mobs(player_id);
let player = Player::new(player_id, instance.id, cryps).set_bot(true); let player = Player::new(player_id, instance.id, &"test".to_string(), cryps).set_bot(true);
instance.add_player(player); instance.add_player(player);
assert!(instance.can_start()); assert!(instance.can_start());

View File

@ -24,7 +24,7 @@ pub struct Player {
pub id: Uuid, pub id: Uuid,
pub instance: Uuid, pub instance: Uuid,
pub account: Uuid, pub account: Uuid,
// name: String, pub name: String,
pub vbox: Vbox, pub vbox: Vbox,
pub score: Score, pub score: Score,
pub cryps: Vec<Cryp>, pub cryps: Vec<Cryp>,
@ -33,11 +33,12 @@ pub struct Player {
} }
impl Player { impl Player {
pub fn new(account: Uuid, instance: Uuid, cryps: Vec<Cryp>) -> Player { pub fn new(account: Uuid, instance: Uuid, name: &String, cryps: Vec<Cryp>) -> Player {
Player { Player {
id: Uuid::new_v4(), id: Uuid::new_v4(),
account, account,
instance, instance,
name: name.clone(),
vbox: Vbox::new(account, instance), vbox: Vbox::new(account, instance),
score: Score { wins: 0, losses: 0 }, score: Score { wins: 0, losses: 0 },
cryps, cryps,
@ -179,7 +180,7 @@ pub fn player_cryps_set(params: PlayerCrypsSetParams, tx: &mut Transaction, acco
player_update(tx, p, false) player_update(tx, p, false)
}, },
Err(_) => { Err(_) => {
return player_create(tx, Player::new(account.id, Uuid::nil(), cryps), &account) return player_create(tx, Player::new(account.id, Uuid::nil(), &account.name, cryps), &account)
} }
} }
} }

View File

@ -217,7 +217,7 @@ impl Vbox {
instance: instance_id, instance: instance_id,
free: vec![], free: vec![],
bound: starting_items, bound: starting_items,
bits: 9, bits: 18,
}; };
vbox.fill(); vbox.fill();
@ -426,8 +426,11 @@ impl Vbox {
} }
} }
const DISCARD_COST: u16 = 5;
pub fn vbox_discard(params: VboxDiscardParams, tx: &mut Transaction, account: &Account) -> Result<Player, Error> { pub fn vbox_discard(params: VboxDiscardParams, tx: &mut Transaction, account: &Account) -> Result<Player, Error> {
let mut player = player_get(tx, account.id, params.instance_id)?; let mut player = player_get(tx, account.id, params.instance_id)?;
player.vbox.balance_sub(DISCARD_COST)?;
player.vbox.fill(); player.vbox.fill();
return player_update(tx, player, false); return player_update(tx, player, false);
} }