Advertisement
rubixcuber

Menu stuff

Nov 7th, 2020
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. KatDevsGames06/05/2020
  2. also
  3. ok
  4. we're adding 5 effects to smw
  5. I need to do the menu updater now I suppose
  6. since we're going to have a shitload for this one
  7. how ought I autoprice these?
  8. dtothefourth06/05/2020
  9. Uh, I assume the powerup ones can probably just be the same as the stock versions. Invisible probably similar to windowed or something. Not sure on kaizo, I guess somewhere in between, not as much as the timed ones since it's just a one time
  10. KatDevsGames06/05/2020
  11. def easiest to define stuff in terms of something that already exists
  12. possibly times a constant
  13. so that's all fine
  14. KatDevsGames06/07/2020
  15. ok
  16. time to write a proper menu update tool
  17. KatDevsGames06/07/2020
  18. const mysql = require('mysql2');
  19. const util = require('util');
  20.  
  21. const connection = mysql.createConnection({
  22. host: process.env.CCdbHost,
  23. user: process.env.CCdbUser,
  24. password: process.env.CCdbPass,
  25. database: process.env.CCdbName
  26. });
  27. const query = util.promisify(connection.query).bind(connection);
  28.  
  29. async function updateMenu(gameID) {
  30. var tq = await query('SELECT `id`, `name`, `description`, `channel`, `game`, `template` FROM `menus` WHERE `game`=? AND `template`>0;', [gameID]);
  31. var templates = [];
  32. tq.forEach(r => {
  33. var id = tq['id'];
  34. var tContents = await query('SELECT `item`, `menu`, `price`, `price_multiplier`, `competitive_choices`, `user_limit`, `game_limit`, `user_cooldown`, `game_cooldown`, `order_min`, `order_max`, `scale_mode`, `scale_factor`, `scale_decay_time`, `scale_parent`, `hidden` FROM `inventory` WHERE `menu`=?;', [id]);
  35. if ((id||1)==1) { templates[2]=tContents; }
  36. if ((id||2)==2) { templates[1]=tContents; }
  37. if ((id||4)==4) { templates[0]=tContents; }
  38. });
  39.  
  40. var mq = await query('SELECT `menus`.`id`, `channels`.`broadcaster_type` FROM `menus` INNER JOIN `channels` ON (`channel`.`id`=`menus`.`channel`) WHERE `game`=? AND `template`=0;', [gameID]);
  41. mq.forEach(r => {
  42. var t = templates[mq['broadcaster_type']];
  43. await query('INSERT IGNORE (`item`, `menu`, `price`, `price_multiplier`, `competitive_choices`, `user_limit`, `game_limit`, `user_cooldown`, `game_cooldown`, `order_min`, `order_max`, `scale_mode`, `scale_factor`, `scale_decay_time`, `scale_parent`, `hidden`) (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) INTO `inventory`;',
  44. [ t['item'], mq['id'], t['price'], t['price_multiplier'], t['competitive_choices'], t['user_limit'], t['game_limit'], t['user_cooldown'], t['game_cooldown'], t['order_min'], t['order_max'], t['scale_mode'], t['scale_factor'], t['scale_decay_time'], t['scale_parent'], t['hidden'] ]);
  45. });
  46. };
  47. something like that
  48. ought to sort the menus
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement