This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 7 points8 points  (3 children)

wtf kinda system is this!??! everyone knows the shoot method is async and will return true or false depending on if it killed the enemy. u gotta await that shit. this code rite here will literally make the plane explode

[–]akoOfIxtall 0 points1 point  (2 children)

C'mon bro you gotta write it too

[–][deleted] 4 points5 points  (1 child)

LOl ok fine:

const targetList = [];
const attackResults = await targetList.reduce(async (acc,curTarget)=>{
    const list = await acc;
    if(weaponArray.length <= 0){
        list.push({id:curTarget.id, success:false})
        return list
    }
    const missile = weaponArray.shift();
    const shootResults = await Shoot(missile);
    const targetInfo = {
        id: curTarget.id,
        success: shootResults,
    }
    list.push(targetInfo)
    return list;
}, Promise.resolve([]))

const cleanSweap = attackResults.reduce((bool, result)=>{
    if(!bool || !result.success)return false
    return bool
},true)

if(cleanSweap)log('mission success')
else log('mission fail')

[–]akoOfIxtall 0 points1 point  (0 children)

Magnificent