Merge tag '1.4.1' into develop

1.4.1
This commit is contained in:
ntr 2019-09-09 16:46:38 +10:00
commit fc7184de45
11 changed files with 25 additions and 21 deletions

View File

@ -1 +1 @@
1.4.0
1.4.1

View File

@ -1,6 +1,6 @@
{
"name": "mnml-client",
"version": "1.4.0",
"version": "1.4.1",
"description": "",
"main": "index.js",
"scripts": {

View File

@ -1,6 +1,6 @@
{
"name": "mnml-client",
"version": "1.4.0",
"version": "1.4.1",
"description": "",
"main": "index.js",
"scripts": {

View File

@ -1,6 +1,6 @@
{
"name": "mnml-ops",
"version": "1.4.0",
"version": "1.4.1",
"description": "",
"main": "index.js",
"scripts": {

View File

@ -1,6 +1,6 @@
[package]
name = "mnml"
version = "1.4.0"
version = "1.4.1"
authors = ["ntr <ntr@smokestack.io>"]
[dependencies]

View File

@ -43,8 +43,8 @@ pub fn invader_write(id: Uuid) -> Result<Uuid, Error> {
let mut colours = std::iter
::repeat_with(|| {
let h = rng.gen_range(0, 360);
let s = s_dist.sample(&mut rng) as u16;
let l = l_dist.sample(&mut rng) as u16;
let s = s_dist.sample(&mut rng) as usize;
let l = l_dist.sample(&mut rng) as usize;
format!("hsl({:}, {:}%, {:}%)", h, s, l)
})
.take(3)
@ -201,7 +201,7 @@ mod tests {
// - 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 num_drops = log_normal.sample(&mut rng).floor() as usize;
// +
// + println!("{:?} drops", num_drops);

View File

@ -384,14 +384,14 @@ impl Instance {
fn game_finished(&mut self, game: &Game) -> Result<&mut Instance, Error> {
{
let current_round = self.rounds
.last_mut()
.expect("instance does not have any rounds");
.iter_mut()
.filter(|r| r.game_id.is_some())
.find(|r| r.game_id.unwrap() == game.id);
if current_round.game_id.unwrap() != game.id {
return Err(err_msg("instance does not have a round for this game"));
}
current_round.finished = true;
match current_round {
Some(c) => c.finished = true,
None => return Err(err_msg("instance does not have a round for this game")),
};
}
// if you don't win, you lose
@ -403,6 +403,8 @@ impl Instance {
None => return Ok(self.finish()),
};
let bits = 12 + 6 * self.rounds.len();
{
let loser = self.players.iter()
.find(|p| p.id != winner_id)
@ -414,6 +416,7 @@ impl Instance {
.unwrap();
winner.score = winner.score.add_win(&loser);
winner.vbox.balance_add(bits.into());
}
{
@ -422,6 +425,7 @@ impl Instance {
.unwrap();
loser.score = loser.score.add_loss();
loser.vbox.balance_add(bits.into());
}
if self.all_games_finished() {

View File

@ -306,7 +306,7 @@ impl Item {
}
}
pub fn cost(&self) -> u16 {
pub fn cost(&self) -> usize {
match self {
Item::Red => 1,
Item::Green => 1,

View File

@ -36,7 +36,7 @@ pub struct Shop {
#[derive(Debug,Copy,Clone,PartialEq,Serialize,Deserialize)]
pub struct Listing {
variant: MtxVariant,
credits: u16,
credits: usize,
}
#[derive(Debug,Copy,Clone,PartialEq,Serialize,Deserialize)]

View File

@ -12,7 +12,7 @@ use vbox::{Vbox};
use item::{Item, ItemEffect};
use effect::{Effect};
const DISCARD_COST: u16 = 2;
const DISCARD_COST: usize = 2;
#[derive(Debug,Copy,Clone,Serialize,Deserialize,Eq,PartialEq)]
pub enum Score {

View File

@ -21,7 +21,7 @@ use item::*;
#[derive(Debug,Clone,Serialize,Deserialize)]
pub struct Vbox {
pub bits: u16,
pub bits: usize,
pub free: Vec<Vec<Option<Item>>>,
pub bound: Vec<Item>,
}
@ -47,7 +47,7 @@ impl Vbox {
}
}
pub fn balance_sub(&mut self, amount: u16) -> Result<&mut Vbox, Error> {
pub fn balance_sub(&mut self, amount: usize) -> Result<&mut Vbox, Error> {
let new_balance = self.bits
.checked_sub(amount)
.ok_or(format_err!("insufficient balance: {:?}", self.bits))?;
@ -57,7 +57,7 @@ impl Vbox {
Ok(self)
}
pub fn balance_add(&mut self, amount: u16) -> &mut Vbox {
pub fn balance_add(&mut self, amount: usize) -> &mut Vbox {
self.bits = self.bits.saturating_add(amount);
self
}