Merge branch 'release/1.4.4'
This commit is contained in:
commit
7f805fbd3e
@ -9,17 +9,19 @@
|
||||
|
||||
* treats
|
||||
* constructs jiggle when clicked
|
||||
* client animation bpm
|
||||
* background colour changes depending on time of day
|
||||
* hit animation wobble
|
||||
* combat text scale + translate
|
||||
* susbcriber gold name in instance
|
||||
|
||||
* bot game grind
|
||||
* stress test
|
||||
|
||||
* msg pane
|
||||
* game invites
|
||||
|
||||
* audio
|
||||
|
||||
## SOON
|
||||
*SERVER*
|
||||
* modules
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mnml-client",
|
||||
"version": "1.4.3",
|
||||
"version": "1.4.4",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mnml-client",
|
||||
"version": "1.4.3",
|
||||
"version": "1.4.4",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@ -1,11 +1,9 @@
|
||||
// Update with your config settings.
|
||||
|
||||
const local = {
|
||||
module.exports = {
|
||||
client: 'postgresql',
|
||||
connection: {
|
||||
database: 'mnml',
|
||||
user: 'mnml',
|
||||
password: process.env.MNML_PG_PASSWORD,
|
||||
password: 'gggggggggg',
|
||||
},
|
||||
pool: {
|
||||
min: 2,
|
||||
@ -15,9 +13,3 @@ const local = {
|
||||
tableName: 'knex_migrations'
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
development: local,
|
||||
production: local,
|
||||
};
|
||||
|
||||
11
ops/migrations/20190914191207_shapes-mtx.js
Normal file
11
ops/migrations/20190914191207_shapes-mtx.js
Normal file
@ -0,0 +1,11 @@
|
||||
const uuidv4 = require('uuid/v4');
|
||||
|
||||
// give everybody the shapes mtx
|
||||
exports.up = async knex => {
|
||||
await knex.raw(`
|
||||
INSERT INTO mtx (id, account, variant)
|
||||
SELECT uuid_generate_v4() as id, id as account, 'Shapes'
|
||||
FROM accounts;
|
||||
`);
|
||||
};
|
||||
exports.down = async () => {};
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mnml-ops",
|
||||
"version": "1.4.3",
|
||||
"version": "1.4.4",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@ -17,6 +17,6 @@
|
||||
"pg": "^7.4.3",
|
||||
"request": "^2.88.0",
|
||||
"sdftosvg": "0.0.4",
|
||||
"uuid": "^3.3.2"
|
||||
"uuid": "^3.3.3"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "mnml"
|
||||
version = "1.4.3"
|
||||
version = "1.4.4"
|
||||
authors = ["ntr <ntr@smokestack.io>"]
|
||||
|
||||
[dependencies]
|
||||
|
||||
@ -891,7 +891,7 @@ pub fn construct_spawn(tx: &mut Transaction, account: Uuid, name: String, team:
|
||||
|
||||
let _returned = result.iter().next().ok_or(err_msg("no row returned"))?;
|
||||
|
||||
img::molecular_write(construct.img)?;
|
||||
img::shapes_write(construct.img)?;
|
||||
|
||||
info!("spawned construct account={:} name={:?}", account, construct.name);
|
||||
return Ok(construct);
|
||||
|
||||
@ -62,7 +62,7 @@ pub fn invader_write(id: Uuid) -> Result<Uuid, Error> {
|
||||
];
|
||||
let colour_dist = WeightedIndex::new(&weights)?;
|
||||
|
||||
write!(&mut svg, "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='-250 -250 1000 1000' width='375' height='375'><g>")?;
|
||||
write!(&mut svg, "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='-500 -500 1500 1500' width='375' height='375'><g>")?;
|
||||
for i in 0..50 {
|
||||
let x = (i % 5) * 50;
|
||||
let y = (i / 5) * 50;
|
||||
@ -84,7 +84,7 @@ pub fn invader_write(id: Uuid) -> Result<Uuid, Error> {
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
enum ConstructShape {
|
||||
enum ConstructShapes {
|
||||
Square,
|
||||
Triangle,
|
||||
Circle,
|
||||
@ -96,14 +96,14 @@ enum ConstructShape {
|
||||
}
|
||||
|
||||
// default ? shape
|
||||
pub fn construct(id: Uuid) -> Result<Uuid, Error> {
|
||||
pub fn shapes_write(id: Uuid) -> Result<Uuid, Error> {
|
||||
let mut rng = thread_rng();
|
||||
let mut svg = Vec::new();
|
||||
|
||||
// distribution for lightness
|
||||
// bellcurve around 75%
|
||||
let l_dist = Normal::new(50.0, 10.0);
|
||||
let s_dist = Normal::new(25.0, 10.0);
|
||||
let s_dist = Normal::new(50.0, 20.0);
|
||||
|
||||
// 8 6 or 4 points in shape
|
||||
// 1 head point
|
||||
@ -112,67 +112,99 @@ pub fn construct(id: Uuid) -> Result<Uuid, Error> {
|
||||
|
||||
// add up to 100 for %
|
||||
let shapes = [
|
||||
(ConstructShape::Square, 100),
|
||||
// (ConstructShape::Triangle, 10),
|
||||
// (ConstructShape::Circle, 10),
|
||||
// (ConstructShape::Line, 10),
|
||||
// (ConstructShape::V, 10),
|
||||
// (ConstructShape::Tri, 3),
|
||||
// (ConstructShape::Plus, 5),
|
||||
// (ConstructShape::Blank, 1),
|
||||
(ConstructShapes::Square, 10),
|
||||
(ConstructShapes::Triangle, 10),
|
||||
(ConstructShapes::Circle, 10),
|
||||
(ConstructShapes::Line, 10),
|
||||
(ConstructShapes::V, 10),
|
||||
// (ConstructShapes::Tri, 3),
|
||||
// (ConstructShapes::Plus, 5),
|
||||
(ConstructShapes::Blank, 1),
|
||||
];
|
||||
let shape_dist = WeightedIndex::new(shapes.iter().map(|v| v.1))?;
|
||||
|
||||
let n_shapes = rng.gen_range(2, 10);
|
||||
let n_shapes_items = [
|
||||
(1, 1),
|
||||
(2, 2),
|
||||
(3, 5),
|
||||
(4, 10),
|
||||
(5, 10),
|
||||
];
|
||||
let num_dist = WeightedIndex::new(n_shapes_items.iter().map(|v| v.1))?;
|
||||
let n_shapes = num_dist.sample(&mut rng) as usize;
|
||||
|
||||
write!(&mut svg, "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='-500 -500 1000 1000' width='1000' height='1000'><g>")?;
|
||||
for i in 0..n_shapes - 1 {
|
||||
write!(&mut svg, "<svg xmlns='http://www.w3.org/2000/svg' version='1.1' viewBox='-250 -250 500 500' width='1000' height='1000'><g>")?;
|
||||
for i in 0..n_shapes + 1 {
|
||||
let h = rng.gen_range(0, 360);
|
||||
let s = s_dist.sample(&mut rng) as usize;
|
||||
let l = l_dist.sample(&mut rng) as usize;
|
||||
let colour = format!("hsl({:}, {:}%, {:}%)", h, s, l);
|
||||
|
||||
let fraction: f64 = (1.0 / n_shapes as f64) * i as f64;
|
||||
let angle: f64 = (fraction * 180.0) / f64::consts::PI;
|
||||
let scalar = match i == n_shapes {
|
||||
true => 0.0,
|
||||
false => rng.gen_range(50.0, 200.0),
|
||||
};
|
||||
|
||||
let rotation = rng.gen_range(0, 180);
|
||||
let angle: f64 = i as f64 * (1.0 / n_shapes as f64) * f64::consts::PI;
|
||||
let x_translate = angle.cos() * scalar;
|
||||
let y_translate = angle.sin() * scalar;
|
||||
|
||||
match shapes[shape_dist.sample(&mut rng)].0 {
|
||||
ConstructShape::Square => {
|
||||
let size = rng.gen_range(5, 50);
|
||||
let distance = rng.gen_range(50, 200);
|
||||
let rotation = rng.gen_range(0, 180);
|
||||
write!(&mut svg, "<rect fill=\"{}\" x=\"-{}\" y=\"{}\" width=\"{}\" height=\"{}\" transform=\"rotate({}) translate(0, {}) rotate({})\" />",
|
||||
colour, size / 2, size / 2, size, size, rotation, distance, angle)?;
|
||||
write!(&mut svg, "<rect fill=\"{}\" x=\"-{}\" y=\"{}\" width=\"{}\" height=\"{}\" transform=\"rotate({}) translate(0, {}) rotate({})\" />",
|
||||
colour, size / 2, size / 2, size, size, rotation, distance, angle + 180.0)?;
|
||||
ConstructShapes::Square => {
|
||||
let size = rng.gen_range(20.0, 50.0);
|
||||
write!(&mut svg, "<rect fill=\"{fill}\" x=\"-{x}\" y=\"-{y}\" width=\"{width}\" height=\"{height}\" transform=\"translate({x_t}, {y_t}) rotate({rotation})\" />",
|
||||
fill = colour, x = size / 2.0, y = size / 2.0, width = size, height = size, x_t = x_translate, y_t = y_translate, rotation = rotation)?;
|
||||
write!(&mut svg, "<rect fill=\"{fill}\" x=\"-{x}\" y=\"-{y}\" width=\"{width}\" height=\"{height}\" transform=\"translate({x_t}, {y_t}) rotate({rotation})\" />",
|
||||
fill = colour, x = size / 2.0, y = size / 2.0, width = size, height = size, x_t = -x_translate, y_t = -y_translate, rotation = rotation)?;
|
||||
},
|
||||
ConstructShape::Triangle => {
|
||||
ConstructShapes::Triangle => {
|
||||
let h = rng.gen_range(20.0, 50.0);
|
||||
let b = rng.gen_range(20.0, 50.0);
|
||||
write!(&mut svg, "<polygon fill=\"{fill}\" x=\"{x}\" y=\"{y}\" points=\"{x0} {y0}, {x1} {y1}, {x2} {y2}\" transform=\"translate({x_translate}, {y_translate}) rotate({rotation})\" />",
|
||||
fill = colour, x = -b / 2.0, y = h / 2.0, x0 = -b / 2.0, y0 = -h / 2.0, x1 = 0, y1 = b / 2.0, x2 = b / 2.0, y2 = -h / 2.0, rotation = rotation, x_translate = x_translate, y_translate = y_translate)?;
|
||||
write!(&mut svg, "<polygon fill=\"{fill}\" x=\"{x}\" y=\"{y}\" points=\"{x0} {y0}, {x1} {y1}, {x2} {y2}\" transform=\"translate({x_translate}, {y_translate}) rotate({rotation})\" />",
|
||||
fill = colour, x = -b / 2.0, y = h / 2.0, x0 = -b / 2.0, y0 = -h / 2.0, x1 = 0, y1 = b / 2.0, x2 = b / 2.0, y2 = -h / 2.0, rotation = rotation + 180, x_translate = -x_translate, y_translate = -y_translate)?;
|
||||
},
|
||||
ConstructShapes::Circle => {
|
||||
let r = rng.gen_range(10.0, 20.0);
|
||||
write!(&mut svg, "<ellipse fill=\"{fill}\" cx=\"{x}\" cy=\"{y}\" rx=\"{r}\" ry=\"{r}\"/>",
|
||||
fill = colour, r = r, x = x_translate, y = y_translate)?;
|
||||
write!(&mut svg, "<ellipse fill=\"{fill}\" cx=\"{x}\" cy=\"{y}\" rx=\"{r}\" ry=\"{r}\"/>",
|
||||
fill = colour, r = r, x = -x_translate, y = -y_translate)?;
|
||||
},
|
||||
ConstructShapes::Line => {
|
||||
let width = rng.gen_range(2.0, 8.0);
|
||||
let height = rng.gen_range(20.0, 50.0);
|
||||
write!(&mut svg, "<rect fill=\"{fill}\" x=\"-{x}\" y=\"-{y}\" width=\"{width}\" height=\"{height}\" transform=\"translate({x_t}, {y_t}) rotate({rotation})\" />",
|
||||
fill = colour, x = width / 2.0, y = height / 2.0, width = width, height = height, x_t = x_translate, y_t = y_translate, rotation = rotation)?;
|
||||
write!(&mut svg, "<rect fill=\"{fill}\" x=\"-{x}\" y=\"-{y}\" width=\"{width}\" height=\"{height}\" transform=\"translate({x_t}, {y_t}) rotate({rotation})\" />",
|
||||
fill = colour, x = width / 2.0, y = height / 2.0, width = width, height = height, x_t = -x_translate, y_t = -y_translate, rotation = rotation)?;
|
||||
},
|
||||
ConstructShapes::V => {
|
||||
let h = rng.gen_range(20.0, 50.0);
|
||||
let b = rng.gen_range(20.0, 50.0);
|
||||
let width = rng.gen_range(2.0, 8.0);
|
||||
|
||||
write!(&mut svg, "<polyline fill=\"none\" stroke=\"{fill}\" stroke-width=\"{width}\" x=\"{x}\" y=\"{y}\" points=\"{x0} {y0}, {x1} {y1}, {x2} {y2}\" transform=\"translate({x_translate}, {y_translate}) rotate({rotation})\" />",
|
||||
fill = colour, width = width, x = -b / 2.0, y = h / 2.0, x0 = -b / 2.0, y0 = -h / 2.0, x1 = 0, y1 = b / 2.0, x2 = b / 2.0, y2 = -h / 2.0, rotation = rotation, x_translate = x_translate, y_translate = y_translate)?;
|
||||
write!(&mut svg, "<polyline fill=\"none\" stroke=\"{fill}\" stroke-width=\"{width}\" x=\"{x}\" y=\"{y}\" points=\"{x0} {y0}, {x1} {y1}, {x2} {y2}\" transform=\"translate({x_translate}, {y_translate}) rotate({rotation})\" />",
|
||||
fill = colour, width = width, x = -b / 2.0, y = h / 2.0, x0 = -b / 2.0, y0 = -h / 2.0, x1 = 0, y1 = b / 2.0, x2 = b / 2.0, y2 = -h / 2.0, rotation = rotation + 180, x_translate = -x_translate, y_translate = -y_translate)?;
|
||||
},
|
||||
ConstructShapes::Tri => {
|
||||
|
||||
},
|
||||
ConstructShape::Circle => {
|
||||
|
||||
},
|
||||
ConstructShape::Line => {
|
||||
|
||||
},
|
||||
ConstructShape::V => {
|
||||
|
||||
},
|
||||
ConstructShape::Tri => {
|
||||
|
||||
},
|
||||
ConstructShape::Plus => {
|
||||
|
||||
},
|
||||
ConstructShape::Blank => {
|
||||
ConstructShapes::Plus => {
|
||||
|
||||
},
|
||||
ConstructShapes::Blank => (),
|
||||
}
|
||||
}
|
||||
|
||||
write!(&mut svg, "</g></svg>")?;
|
||||
|
||||
let dest = format!("/var/lib/mnml/public/imgs/{}.svg", id);
|
||||
println!("default dest={:?}", dest);
|
||||
println!("/var/lib/mnml/public/imgs/{}.svg", id);
|
||||
|
||||
let mut file = File::create(dest)?;
|
||||
file.write_all(&svg)?;
|
||||
@ -214,9 +246,9 @@ mod tests {
|
||||
// }
|
||||
|
||||
#[test]
|
||||
fn construct_img_test() {
|
||||
fn shapes_img_test() {
|
||||
for i in 0..100 {
|
||||
construct(Uuid::new_v4()).unwrap();
|
||||
shapes_write(Uuid::new_v4()).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -712,7 +712,7 @@ pub fn instance_practice(tx: &mut Transaction, account: &Account) -> Result<Inst
|
||||
|
||||
// generate bot imgs for the client to see
|
||||
for c in bot.constructs.iter() {
|
||||
img::molecular_write(c.img)?;
|
||||
img::shapes_write(c.img)?;
|
||||
}
|
||||
|
||||
let mut instance = Instance::new()
|
||||
@ -830,14 +830,14 @@ pub fn demo() -> Result<Vec<Player>, Error> {
|
||||
|
||||
// generate bot imgs for the client to see
|
||||
for c in bot.constructs.iter() {
|
||||
img::molecular_write(c.img)?;
|
||||
img::shapes_write(c.img)?;
|
||||
};
|
||||
|
||||
let bot2 = bot_player();
|
||||
|
||||
// generate bot imgs for the client to see
|
||||
for c in bot2.constructs.iter() {
|
||||
img::molecular_write(c.img)?;
|
||||
img::shapes_write(c.img)?;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -14,8 +14,9 @@ use construct::{Construct, construct_select, construct_write, construct_spawn};
|
||||
use names::{name as generate_name};
|
||||
use img;
|
||||
|
||||
pub const FREE_MTX: [MtxVariant; 1] = [
|
||||
pub const FREE_MTX: [MtxVariant; 2] = [
|
||||
MtxVariant::Rename,
|
||||
MtxVariant::Shapes,
|
||||
];
|
||||
|
||||
pub const SHOP_LISTINGS: [Listing; 2] = [
|
||||
@ -44,6 +45,7 @@ pub enum MtxVariant {
|
||||
Rename,
|
||||
Molecular,
|
||||
Invader,
|
||||
Shapes,
|
||||
}
|
||||
|
||||
impl MtxVariant {
|
||||
@ -61,6 +63,7 @@ impl TryFrom<String> for MtxVariant {
|
||||
"Rename" => Ok(MtxVariant::Rename),
|
||||
"Molecular" => Ok(MtxVariant::Molecular),
|
||||
"Invader" => Ok(MtxVariant::Invader),
|
||||
"Shapes" => Ok(MtxVariant::Shapes),
|
||||
_ => Err(format_err!("mtx variant not found variant={:?}", v)),
|
||||
}
|
||||
}
|
||||
@ -152,9 +155,11 @@ pub fn apply(tx: &mut Transaction, account: &Account, variant: MtxVariant, const
|
||||
MtxVariant::Rename => construct.new_name(name),
|
||||
_ => construct.new_img(),
|
||||
};
|
||||
|
||||
match mtx.variant {
|
||||
MtxVariant::Invader => img::invader_write(construct.img)?,
|
||||
MtxVariant::Molecular => img::molecular_write(construct.img)?,
|
||||
MtxVariant::Shapes => img::shapes_write(construct.img)?,
|
||||
_ => construct.img,
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user