• Welcome to the Kancolle Wiki!
  • If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord

Changes

Jump to navigation Jump to search
generalize enemy iterators
Line 143: Line 143:  
-- * Enemy iterators.
 
-- * Enemy iterators.
   −
function Iterator.enemiesByType(context, n)
+
function Iterator.enemiesBy(context, n, pred, pre)
 
     local collection = U.imap(CollectionEnemy, function(name)
 
     local collection = U.imap(CollectionEnemy, function(name)
 
         return EnemyShip(name)
 
         return EnemyShip(name)
Line 156: Line 156:  
         end
 
         end
 
     end)
 
     end)
    local type = numberKey('type', context, n)
  −
    local pred = function(e, i)
  −
        return e:type() == type
  −
    end
  −
    local pre
   
     local i = 1
 
     local i = 1
 
     local current = nil
 
     local current = nil
Line 191: Line 186:  
         end,
 
         end,
 
     }
 
     }
 +
end
 +
 +
function Iterator.enemiesByType(context, n)
 +
    local type = numberKey('type', context, n)
 +
    return Iterator.enemiesBy(context, n, function(e)
 +
        return e:type() == type
 +
    end)
 
end
 
end
  
Anonymous user

Navigation menu