main.js 1000 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. processData.post('solutions', solutions);
  26. }
  27. })
  28. .finally(() => {
  29. setTimeout(() => {
  30. eventMatch();
  31. }, 2000);
  32. });
  33. }
  34. eventMatch();