main.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import Logs from "../libs/logs.js";
  2. import ProcessData from "../libs/processData.js";
  3. import { getPassableEvents, eventsCombination } from "./trangleCalc.js";
  4. const processData = new ProcessData(process, 'triangle');
  5. // setInterval(() => {
  6. // Logs.outDev('get games relations');
  7. // processData.get('gamesRelations')
  8. // .then(relations => {
  9. // Logs.outDev('relations', relations);
  10. // })
  11. // .catch(error => {
  12. // Logs.err('triangle error', error);
  13. // });
  14. // }, 5000);
  15. const eventMatch = () => {
  16. processData.get('gamesRelations')
  17. .then(relations => {
  18. if (!relations?.length) {
  19. Logs.outDev('relation list is empty');
  20. }
  21. Logs.outDev('relations', relations);
  22. const passableEvents = getPassableEvents(relations);
  23. const solutions = eventsCombination(passableEvents);
  24. if (solutions?.length) {
  25. Logs.outDev('solutions', solutions);
  26. processData.post('solutions', solutions);
  27. }
  28. else {
  29. Logs.outDev('no solutions');
  30. }
  31. })
  32. .finally(() => {
  33. setTimeout(() => {
  34. eventMatch();
  35. }, 2000);
  36. });
  37. }
  38. eventMatch();