remove molecular mtx
This commit is contained in:
parent
bfecea9a4e
commit
ef5e5170cf
@ -1,82 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const renderer = require('sdftosvg');
|
|
||||||
|
|
||||||
const SVG_OPTS = {
|
|
||||||
backgroundColor: 'none',
|
|
||||||
}
|
|
||||||
|
|
||||||
function convert(i) {
|
|
||||||
const output = `./../client/assets/molecules/${i}.svg`;
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
fs.readFile(`./molecules/mol${i}`, 'utf8', function rfCb(err, sdf) {
|
|
||||||
if (err) return reject(err);
|
|
||||||
// write svg
|
|
||||||
renderer.renderSdfToSvg(sdf, SVG_OPTS, function(err, svg) {
|
|
||||||
if (err) return reject(err);
|
|
||||||
fs.writeFile(output, svg, function written(err) {
|
|
||||||
if (err) reject(err);
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loop() {
|
|
||||||
for (var i = 10000; i >= 0; i--) {
|
|
||||||
try {
|
|
||||||
await convert(i);
|
|
||||||
console.log('finished record', i);
|
|
||||||
} catch (e) {
|
|
||||||
console.error('record error', i, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
loop();
|
|
||||||
|
|
||||||
// const request = require('request');
|
|
||||||
// const fs = require('fs');
|
|
||||||
// const renderer = require('sdftosvg');
|
|
||||||
|
|
||||||
// const SVG_OPTS = {
|
|
||||||
// backgroundColor: 'none',
|
|
||||||
// }
|
|
||||||
|
|
||||||
// function fetch(i) {
|
|
||||||
// return new Promise((resolve, reject) => {
|
|
||||||
// const url = `https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/CID/${i}/record/SDF/?record_type=2d&response_type=save&response_basename=Structure2D_CID_2519`;
|
|
||||||
// const output = `./../client/assets/molecules/${i}.svg`;
|
|
||||||
|
|
||||||
// request(url, function cb(err, res, body) {
|
|
||||||
// if (err) reject(err);
|
|
||||||
|
|
||||||
// // write file
|
|
||||||
// fs.writeFile(`./molecules/Structure2D_CID_${i}.sdf`, body, function written(err) {
|
|
||||||
// if (err) reject(err);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// // write svg
|
|
||||||
// renderer.renderSdfToSvg(body, SVG_OPTS, function(err, svg) {
|
|
||||||
// if (err) reject(err);
|
|
||||||
// fs.writeFile(output, svg, function written(err) {
|
|
||||||
// if (err) reject(err);
|
|
||||||
// resolve();
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// async function loop() {
|
|
||||||
// for (var i = 10000; i >= 0; i--) {
|
|
||||||
// try {
|
|
||||||
// await fetch(i);
|
|
||||||
// console.log('finished record', i);
|
|
||||||
// } catch (e) {
|
|
||||||
// console.error(e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
for (let i = 10000; i >= 0; i--) {
|
|
||||||
fs.access(`./../client/assets/molecules/${i}.svg`, (err) => {
|
|
||||||
if (err) {
|
|
||||||
fs.copyFileSync(`./../client/assets/molecules/726.svg`, `./../client/assets/molecules/${i}.svg`);
|
|
||||||
console.log('defaulted', i);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
10
ops/migrations/20191031203812_remove-molecular.js
Normal file
10
ops/migrations/20191031203812_remove-molecular.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const uuidv4 = require('uuid/v4');
|
||||||
|
|
||||||
|
// give everybody the shapes mtx
|
||||||
|
exports.up = async knex => {
|
||||||
|
await knex.raw(`
|
||||||
|
DELETE from mtx
|
||||||
|
WHERE variant = 'Molecular';
|
||||||
|
`);
|
||||||
|
};
|
||||||
|
exports.down = async () => {};
|
||||||
@ -1,18 +0,0 @@
|
|||||||
const renderer = require('sdftosvg');
|
|
||||||
const uuidv4 = require('uuid/v4');
|
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
function convert(f) {
|
|
||||||
const uuid = uuidv4();
|
|
||||||
const input = `./molecules/${f}`;
|
|
||||||
const output = `./../client/assets/molecules/${uuid}.svg`;
|
|
||||||
fs.readFile(input, 'utf8', (err, sdf) => {
|
|
||||||
renderer.renderSdfToSvg(sdf, {}, function(err, svg) {
|
|
||||||
if (err) console.error(input, err);
|
|
||||||
fs.writeFile(output, svg, 'utf8', err => {
|
|
||||||
if (err) console.error(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,5 +1,4 @@
|
|||||||
use std::f64;
|
use std::f64;
|
||||||
use std::fs::copy;
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::char::from_u32;
|
use std::char::from_u32;
|
||||||
@ -9,25 +8,7 @@ use rand::prelude::*;
|
|||||||
use rand::distributions::{Normal, WeightedIndex};
|
use rand::distributions::{Normal, WeightedIndex};
|
||||||
|
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use failure::err_msg;
|
// use failure::err_msg;
|
||||||
|
|
||||||
pub fn molecular_write(id: Uuid) -> Result<Uuid, Error> {
|
|
||||||
let mut rng = thread_rng();
|
|
||||||
|
|
||||||
for _i in 0..100 {
|
|
||||||
let mol: u32 = rng.gen_range(0, 10000);
|
|
||||||
let src = format!("/var/lib/mnml/data/molecules/{}.svg", mol);
|
|
||||||
let dest = format!("/var/lib/mnml/public/imgs/{}.svg", id);
|
|
||||||
debug!("molecule src={:?}", src);
|
|
||||||
debug!("molecule dest={:?}", dest);
|
|
||||||
if let Ok(_bytes) = copy(&src, &dest) {
|
|
||||||
info!("new molecule img generated src={:?} dest={:?}", src, dest);
|
|
||||||
return Ok(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Err(err_msg("too many missing molecules. wrong directory?"))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn invader_write(id: Uuid) -> Result<Uuid, Error> {
|
pub fn invader_write(id: Uuid) -> Result<Uuid, Error> {
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
@ -361,7 +342,6 @@ pub fn exists(id: Uuid) -> bool {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
// #[test]
|
// #[test]
|
||||||
// fn invader_img_test() {
|
// fn invader_img_test() {
|
||||||
// for i in 0..100 {
|
// for i in 0..100 {
|
||||||
@ -386,106 +366,3 @@ mod tests {
|
|||||||
smile(Uuid::new_v4()).unwrap();
|
smile(Uuid::new_v4()).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// function createColor() {
|
|
||||||
// //saturation is the whole color spectrum
|
|
||||||
// var h = Math.floor(rand() * 360);
|
|
||||||
// //saturation goes from 40 to 100, it avoids greyish colors
|
|
||||||
// var s = ((rand() * 60) + 40) + '%';
|
|
||||||
// //lightness can be anything from 0 to 100, but probabilities are a bell curve around 75%
|
|
||||||
// var l = ((rand()+rand()+rand()+rand()) * 25) + '%';
|
|
||||||
|
|
||||||
// var color = 'hsl(' + h + ',' + s + ',' + l + ')';
|
|
||||||
// return color;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// function createImageData(size) {
|
|
||||||
// var width = size; // Only support square icons for now
|
|
||||||
// var height = size;
|
|
||||||
|
|
||||||
// var dataWidth = Math.ceil(width / 2);
|
|
||||||
// var mirrorWidth = width - dataWidth;
|
|
||||||
|
|
||||||
// var data = [];
|
|
||||||
// for(var y = 0; y < height; y++) {
|
|
||||||
// var row = [];
|
|
||||||
// for(var x = 0; x < dataWidth; x++) {
|
|
||||||
// // this makes foreground and background color to have a 43% (1/2.3) probability
|
|
||||||
// // spot color has 13% chance
|
|
||||||
// row[x] = Math.floor(rand()*2.3);
|
|
||||||
// }
|
|
||||||
// var r = row.slice(0, mirrorWidth);
|
|
||||||
// r.reverse();
|
|
||||||
// row = row.concat(r);
|
|
||||||
|
|
||||||
// for(var i = 0; i < row.length; i++) {
|
|
||||||
// data.push(row[i]);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return data;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// function buildOpts(opts) {
|
|
||||||
// var newOpts = {};
|
|
||||||
|
|
||||||
// newOpts.seed = opts.seed || Math.floor((Math.random()*Math.pow(10,16))).toString(16);
|
|
||||||
|
|
||||||
// seedrand(newOpts.seed);
|
|
||||||
|
|
||||||
// newOpts.size = opts.size || 8;
|
|
||||||
// newOpts.scale = opts.scale || 4;
|
|
||||||
// newOpts.color = opts.color || createColor();
|
|
||||||
// newOpts.bgcolor = opts.bgcolor || createColor();
|
|
||||||
// newOpts.spotcolor = opts.spotcolor || createColor();
|
|
||||||
|
|
||||||
// return newOpts;
|
|
||||||
// }
|
|
||||||
// ],
|
|
||||||
// - _ => vec![
|
|
||||||
// - (ItemAction::RerollStamina, 1),
|
|
||||||
// - (ItemAction::RerollPhysDamage, 1),
|
|
||||||
// - (ItemAction::RerollSpellDamage, 1),
|
|
||||||
// - (ItemAction::RerollSpeed, 1),
|
|
||||||
// - (ItemAction::RerollArmour, 1),
|
|
||||||
// - (ItemAction::RerollSpellShield, 1),
|
|
||||||
// - (ItemAction::RerollEvasion, 1),
|
|
||||||
// - ],
|
|
||||||
// + // _ => vec![
|
|
||||||
// + // (ItemAction::RerollStamina, 1),
|
|
||||||
// + // (ItemAction::RerollPhysDamage, 1),
|
|
||||||
// + // (ItemAction::RerollSpellDamage, 1),
|
|
||||||
// + // (ItemAction::RerollSpeed, 1),
|
|
||||||
// + // (ItemAction::RerollArmour, 1),
|
|
||||||
// + // (ItemAction::RerollSpellShield, 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 actions = mode_drops(mode);
|
|
||||||
// + let log_normal = LogNormal::new(1.0, 1.0);
|
|
||||||
// + let num_drops = log_normal.sample(&mut rng).floor() as usize;
|
|
||||||
// +
|
|
||||||
// + println!("{:?} drops", num_drops);
|
|
||||||
|
|
||||||
// - let dist = WeightedIndex::new(actions.iter().map(|item| item.1)).unwrap();
|
|
||||||
// - let kind = actions[dist.sample(&mut rng)].0;
|
|
||||||
// - let item = Item::new(kind, account_id);
|
|
||||||
// + for _i in 0..num_drops {
|
|
||||||
// + let actions = mode_drops(mode);
|
|
||||||
|
|
||||||
// - println!("{:?} dropped {:?}", account_id, item);
|
|
||||||
// + let dist = WeightedIndex::new(actions.iter().map(|item| item.1)).unwrap();
|
|
||||||
// + let kind = actions[dist.sample(&mut rng)].0;
|
|
||||||
// + let item = Item::new(kind, account_id);
|
|
||||||
|
|
||||||
// - return item_create(item, tx, account_id);
|
|
||||||
// + println!("{:?} dropped {:?}", account_id, item);
|
|
||||||
// + item_create(item, tx, account_id)?;V
|
|
||||||
@ -19,8 +19,7 @@ pub const FREE_MTX: [MtxVariant; 2] = [
|
|||||||
MtxVariant::Shapes,
|
MtxVariant::Shapes,
|
||||||
];
|
];
|
||||||
|
|
||||||
pub const SHOP_LISTINGS: [Listing; 3] = [
|
pub const SHOP_LISTINGS: [Listing; 2] = [
|
||||||
Listing { variant: MtxVariant::Molecular, credits: 10 },
|
|
||||||
Listing { variant: MtxVariant::Invader, credits: 10 },
|
Listing { variant: MtxVariant::Invader, credits: 10 },
|
||||||
Listing { variant: MtxVariant::Smile, credits: 10 },
|
Listing { variant: MtxVariant::Smile, credits: 10 },
|
||||||
];
|
];
|
||||||
@ -44,7 +43,6 @@ pub struct Listing {
|
|||||||
#[derive(Debug,Copy,Clone,PartialEq,Serialize,Deserialize)]
|
#[derive(Debug,Copy,Clone,PartialEq,Serialize,Deserialize)]
|
||||||
pub enum MtxVariant {
|
pub enum MtxVariant {
|
||||||
Rename,
|
Rename,
|
||||||
Molecular,
|
|
||||||
Invader,
|
Invader,
|
||||||
Shapes,
|
Shapes,
|
||||||
Smile,
|
Smile,
|
||||||
@ -63,7 +61,6 @@ impl TryFrom<String> for MtxVariant {
|
|||||||
fn try_from(v: String) -> Result<MtxVariant, Error> {
|
fn try_from(v: String) -> Result<MtxVariant, Error> {
|
||||||
match v.as_ref() {
|
match v.as_ref() {
|
||||||
"Rename" => Ok(MtxVariant::Rename),
|
"Rename" => Ok(MtxVariant::Rename),
|
||||||
"Molecular" => Ok(MtxVariant::Molecular),
|
|
||||||
"Invader" => Ok(MtxVariant::Invader),
|
"Invader" => Ok(MtxVariant::Invader),
|
||||||
"Smile" => Ok(MtxVariant::Smile),
|
"Smile" => Ok(MtxVariant::Smile),
|
||||||
"Shapes" => Ok(MtxVariant::Shapes),
|
"Shapes" => Ok(MtxVariant::Shapes),
|
||||||
@ -84,7 +81,6 @@ impl Mtx {
|
|||||||
match variant {
|
match variant {
|
||||||
_ => Mtx { id: Uuid::new_v4(), account, variant },
|
_ => Mtx { id: Uuid::new_v4(), account, variant },
|
||||||
// MtxVariant::Invader => Mtx { id: Uuid::new_v4(), account, variant: self },
|
// MtxVariant::Invader => Mtx { id: Uuid::new_v4(), account, variant: self },
|
||||||
// MtxVariant::Molecular => Mtx { id: Uuid::new_v4(), account, variant: self },
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +157,6 @@ pub fn apply(tx: &mut Transaction, account: &Account, variant: MtxVariant, const
|
|||||||
|
|
||||||
match mtx.variant {
|
match mtx.variant {
|
||||||
MtxVariant::Invader => img::invader_write(construct.img)?,
|
MtxVariant::Invader => img::invader_write(construct.img)?,
|
||||||
MtxVariant::Molecular => img::molecular_write(construct.img)?,
|
|
||||||
MtxVariant::Shapes => img::shapes_write(construct.img)?,
|
MtxVariant::Shapes => img::shapes_write(construct.img)?,
|
||||||
MtxVariant::Smile => img::smile(construct.img)?,
|
MtxVariant::Smile => img::smile(construct.img)?,
|
||||||
_ => construct.img,
|
_ => construct.img,
|
||||||
@ -183,7 +178,6 @@ pub fn account_apply(tx: &mut Transaction, account: &Account, variant: MtxVarian
|
|||||||
|
|
||||||
match mtx.variant {
|
match mtx.variant {
|
||||||
MtxVariant::Invader => img::invader_write(account.img)?,
|
MtxVariant::Invader => img::invader_write(account.img)?,
|
||||||
MtxVariant::Molecular => img::molecular_write(account.img)?,
|
|
||||||
MtxVariant::Shapes => img::shapes_write(account.img)?,
|
MtxVariant::Shapes => img::shapes_write(account.img)?,
|
||||||
MtxVariant::Smile => img::smile(account.img)?,
|
MtxVariant::Smile => img::smile(account.img)?,
|
||||||
_ => account.img,
|
_ => account.img,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user