I have a pull request #234 where I refactored the getDestroyAP function such that all the data about a portal can be retrieved as a hash. I think that function would work well here instead of having to individually figure out the link edges and fields. You could loop the visible portals and call the getAttackApGain(portal).