Merge tag '1.4.1' into develop
1.4.1
This commit is contained in:
commit
fc7184de45
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mnml-client",
|
"name": "mnml-client",
|
||||||
"version": "1.4.0",
|
"version": "1.4.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mnml-client",
|
"name": "mnml-client",
|
||||||
"version": "1.4.0",
|
"version": "1.4.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mnml-ops",
|
"name": "mnml-ops",
|
||||||
"version": "1.4.0",
|
"version": "1.4.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "mnml"
|
name = "mnml"
|
||||||
version = "1.4.0"
|
version = "1.4.1"
|
||||||
authors = ["ntr <ntr@smokestack.io>"]
|
authors = ["ntr <ntr@smokestack.io>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@ -43,8 +43,8 @@ pub fn invader_write(id: Uuid) -> Result<Uuid, Error> {
|
|||||||
let mut colours = std::iter
|
let mut colours = std::iter
|
||||||
::repeat_with(|| {
|
::repeat_with(|| {
|
||||||
let h = rng.gen_range(0, 360);
|
let h = rng.gen_range(0, 360);
|
||||||
let s = s_dist.sample(&mut rng) as u16;
|
let s = s_dist.sample(&mut rng) as usize;
|
||||||
let l = l_dist.sample(&mut rng) as u16;
|
let l = l_dist.sample(&mut rng) as usize;
|
||||||
format!("hsl({:}, {:}%, {:}%)", h, s, l)
|
format!("hsl({:}, {:}%, {:}%)", h, s, l)
|
||||||
})
|
})
|
||||||
.take(3)
|
.take(3)
|
||||||
@ -201,7 +201,7 @@ mod tests {
|
|||||||
|
|
||||||
// - let actions = mode_drops(mode);
|
// - let actions = mode_drops(mode);
|
||||||
// + let log_normal = LogNormal::new(1.0, 1.0);
|
// + 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);
|
// + println!("{:?} drops", num_drops);
|
||||||
|
|
||||||
|
|||||||
@ -384,14 +384,14 @@ impl Instance {
|
|||||||
fn game_finished(&mut self, game: &Game) -> Result<&mut Instance, Error> {
|
fn game_finished(&mut self, game: &Game) -> Result<&mut Instance, Error> {
|
||||||
{
|
{
|
||||||
let current_round = self.rounds
|
let current_round = self.rounds
|
||||||
.last_mut()
|
.iter_mut()
|
||||||
.expect("instance does not have any rounds");
|
.filter(|r| r.game_id.is_some())
|
||||||
|
.find(|r| r.game_id.unwrap() == game.id);
|
||||||
|
|
||||||
if current_round.game_id.unwrap() != game.id {
|
match current_round {
|
||||||
return Err(err_msg("instance does not have a round for this game"));
|
Some(c) => c.finished = true,
|
||||||
}
|
None => return Err(err_msg("instance does not have a round for this game")),
|
||||||
|
};
|
||||||
current_round.finished = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if you don't win, you lose
|
// if you don't win, you lose
|
||||||
@ -403,6 +403,8 @@ impl Instance {
|
|||||||
None => return Ok(self.finish()),
|
None => return Ok(self.finish()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let bits = 12 + 6 * self.rounds.len();
|
||||||
|
|
||||||
{
|
{
|
||||||
let loser = self.players.iter()
|
let loser = self.players.iter()
|
||||||
.find(|p| p.id != winner_id)
|
.find(|p| p.id != winner_id)
|
||||||
@ -414,6 +416,7 @@ impl Instance {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
winner.score = winner.score.add_win(&loser);
|
winner.score = winner.score.add_win(&loser);
|
||||||
|
winner.vbox.balance_add(bits.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -422,6 +425,7 @@ impl Instance {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
loser.score = loser.score.add_loss();
|
loser.score = loser.score.add_loss();
|
||||||
|
loser.vbox.balance_add(bits.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.all_games_finished() {
|
if self.all_games_finished() {
|
||||||
|
|||||||
@ -306,7 +306,7 @@ impl Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cost(&self) -> u16 {
|
pub fn cost(&self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
Item::Red => 1,
|
Item::Red => 1,
|
||||||
Item::Green => 1,
|
Item::Green => 1,
|
||||||
|
|||||||
@ -36,7 +36,7 @@ pub struct Shop {
|
|||||||
#[derive(Debug,Copy,Clone,PartialEq,Serialize,Deserialize)]
|
#[derive(Debug,Copy,Clone,PartialEq,Serialize,Deserialize)]
|
||||||
pub struct Listing {
|
pub struct Listing {
|
||||||
variant: MtxVariant,
|
variant: MtxVariant,
|
||||||
credits: u16,
|
credits: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug,Copy,Clone,PartialEq,Serialize,Deserialize)]
|
#[derive(Debug,Copy,Clone,PartialEq,Serialize,Deserialize)]
|
||||||
|
|||||||
@ -12,7 +12,7 @@ use vbox::{Vbox};
|
|||||||
use item::{Item, ItemEffect};
|
use item::{Item, ItemEffect};
|
||||||
use effect::{Effect};
|
use effect::{Effect};
|
||||||
|
|
||||||
const DISCARD_COST: u16 = 2;
|
const DISCARD_COST: usize = 2;
|
||||||
|
|
||||||
#[derive(Debug,Copy,Clone,Serialize,Deserialize,Eq,PartialEq)]
|
#[derive(Debug,Copy,Clone,Serialize,Deserialize,Eq,PartialEq)]
|
||||||
pub enum Score {
|
pub enum Score {
|
||||||
|
|||||||
@ -21,7 +21,7 @@ use item::*;
|
|||||||
|
|
||||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
pub struct Vbox {
|
pub struct Vbox {
|
||||||
pub bits: u16,
|
pub bits: usize,
|
||||||
pub free: Vec<Vec<Option<Item>>>,
|
pub free: Vec<Vec<Option<Item>>>,
|
||||||
pub bound: Vec<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
|
let new_balance = self.bits
|
||||||
.checked_sub(amount)
|
.checked_sub(amount)
|
||||||
.ok_or(format_err!("insufficient balance: {:?}", self.bits))?;
|
.ok_or(format_err!("insufficient balance: {:?}", self.bits))?;
|
||||||
@ -57,7 +57,7 @@ impl Vbox {
|
|||||||
Ok(self)
|
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.bits = self.bits.saturating_add(amount);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user