Advertisement
Usnm

SISR Fleet Splitter utility v0.1

Aug 17th, 2022 (edited)
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. async function splitFleetForSelectedShips(fleet, shipsIDsArray, customName = 'Новый') {
  2.     let newFleet = {
  3.         id: "0",
  4.         name: `${customName}`,
  5.         ships: []
  6.     }
  7.     fleet.ships.forEach(ship => {
  8.         if (true) {
  9.             newFleet.ships.push(ship)
  10.             fleet.ships.splice(fleet.ships.indexOf(ship), 1)
  11.         }
  12.     })
  13.     if (newFleet.ships.length > 0) {
  14.         let splitResponse = await (
  15.           await fetch("https://swg.fedaniil.party/center/exchange", {
  16.             "credentials": "include",
  17.             "headers": {
  18.               "Accept": "application/json, text/plain, */*",
  19.               "Accept-Language": "ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3",
  20.               "Content-Type": "application/json;charset=utf-8",
  21.               "Sec-Fetch-Dest": "empty",
  22.               "Sec-Fetch-Mode": "cors",
  23.               "Sec-Fetch-Site": "same-origin",
  24.             },
  25.             "body": JSON.stringify({ fleets: [fleet, newFleet] }),
  26.             "method": "POST",
  27.           })
  28.         ).json()
  29.         if (splitResponse.status === true) console.log
  30.         else console.log (`ОШИБКА: ${splitResponse.message}`)
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement