(encryptPin = $.encryptPin, help = false)
| 747 | }) |
| 748 | } |
| 749 | async function PickUp(encryptPin = $.encryptPin, help = false) { |
| 750 | $.pickUpMyselfComponent = true; |
| 751 | const GetUserComponentRes = await GetUserComponent(encryptPin, 1500); |
| 752 | if (GetUserComponentRes && GetUserComponentRes['ret'] === 0 && GetUserComponentRes['data']) { |
| 753 | const { componentList } = GetUserComponentRes['data']; |
| 754 | if (componentList && componentList.length <= 0) { |
| 755 | if (help) { |
| 756 | $.log(`好友【${encryptPin}】地下暂无零件可收\n`) |
| 757 | } else { |
| 758 | $.log(`自家地下暂无零件可收\n`) |
| 759 | } |
| 760 | $.pickUpMyselfComponent = false; |
| 761 | } |
| 762 | for (let item of componentList) { |
| 763 | await $.wait(1000); |
| 764 | const PickUpComponentRes = await PickUpComponent(item['placeId'], encryptPin); |
| 765 | if (PickUpComponentRes) { |
| 766 | if (PickUpComponentRes['ret'] === 0) { |
| 767 | const data = PickUpComponentRes['data']; |
| 768 | if (help) { |
| 769 | console.log(`收取好友[${encryptPin}]零件成功:获得${data['increaseElectric']}电力\n`); |
| 770 | $.pickFriendEle += data['increaseElectric']; |
| 771 | } else { |
| 772 | console.log(`收取自家零件成功:获得${data['increaseElectric']}电力\n`); |
| 773 | $.pickEle += data['increaseElectric']; |
| 774 | } |
| 775 | } else { |
| 776 | if (help) { |
| 777 | console.log(`收好友[${encryptPin}]零件失败:${PickUpComponentRes.msg},直接跳出\n`) |
| 778 | } else { |
| 779 | console.log(`收自己地下零件失败:${PickUpComponentRes.msg},直接跳出\n`); |
| 780 | $.pickUpMyselfComponent = false; |
| 781 | } |
| 782 | break |
| 783 | } |
| 784 | } |
| 785 | } |
| 786 | } |
| 787 | } |
| 788 | function GetUserComponent(pin = $.encryptPin, timeout = 0) { |
| 789 | return new Promise(resolve => { |
| 790 | setTimeout(() => { |
no test coverage detected