| Line 194: |
Line 194: |
| | function Iterator.shipsByTrueId(context, n) | | function Iterator.shipsByTrueId(context, n) |
| | local from = numberKey('from', context, n, 1) | | local from = numberKey('from', context, n, 1) |
| − | local to = numberKey('to', context, n, 500) | + | local to = numberKey('to', context, n, 1500) |
| | return Iterator.shipsBy(context, n, function(e) | | return Iterator.shipsBy(context, n, function(e) |
| | if e._true_id then | | if e._true_id then |
| Line 218: |
Line 218: |
| | local collectionKey = stringKey('collection', context, n) | | local collectionKey = stringKey('collection', context, n) |
| | if collectionKey then | | if collectionKey then |
| − | local _, CollectionData = U.requireModule(string.format("Collection/%s", collectionKey)) | + | local _, CollectionData = U.requireModule(collectionKey == 'Equipment' and 'Data/Equipment' or string.format("Collection/%s", collectionKey)) |
| | collection = U.icopy(CollectionData) | | collection = U.icopy(CollectionData) |
| | else | | else |
| Line 277: |
Line 277: |
| | function Iterator.equipmentById(context, n) | | function Iterator.equipmentById(context, n) |
| | local from = numberKey('from', context, n, 1) | | local from = numberKey('from', context, n, 1) |
| − | local to = numberKey('to', context, n, 500) | + | local to = numberKey('to', context, n, 1500) |
| | return Iterator.equipmentBy(context, n, function(e) | | return Iterator.equipmentBy(context, n, function(e) |
| | return e._id >= from and e._id <= to | | return e._id >= from and e._id <= to |
| Line 285: |
Line 285: |
| | function Iterator.equipmentByIdWithHeaders(context, n) | | function Iterator.equipmentByIdWithHeaders(context, n) |
| | local from = numberKey('from', context, n, 1) | | local from = numberKey('from', context, n, 1) |
| − | local to = numberKey('to', context, n, 500) | + | local to = numberKey('to', context, n, 1500) |
| | local prevMod = 0 | | local prevMod = 0 |
| | return Iterator.equipmentBy( | | return Iterator.equipmentBy( |
| Line 308: |
Line 308: |
| | function Iterator.equipmentByIdWithEmptyWithHeaders(context, n) | | function Iterator.equipmentByIdWithEmptyWithHeaders(context, n) |
| | local from = numberKey('from', context, n, 1) | | local from = numberKey('from', context, n, 1) |
| − | local to = numberKey('to', context, n, 500) | + | local to = numberKey('to', context, n, 1500) |
| | local prevMod = 0 | | local prevMod = 0 |
| | local nItems = (math.floor(U.ilast(CollectionEquipment)._id / 10) + 1) * 10 | | local nItems = (math.floor(U.ilast(CollectionEquipment)._id / 10) + 1) * 10 |
| Line 355: |
Line 355: |
| | | | |
| | function Iterator.enemiesBy(context, n, pred, pre) | | function Iterator.enemiesBy(context, n, pred, pre) |
| − | local collection = U.imap(CollectionEnemy, function(name) | + | local base_ids = {} |
| − | return EnemyShip(name)
| + | local collection = U.imap(CollectionEnemy, function(name, i) |
| | + | local obj = EnemyShip(name) |
| | + | if not base_ids[obj:base_name()] then |
| | + | base_ids[obj:base_name()] = i |
| | + | end |
| | + | return obj |
| | end) | | end) |
| | table.sort(collection, function(a, b) | | table.sort(collection, function(a, b) |
| − | local ai = U.ifind(CollectionEnemy, a:base_name()) | + | local ai = base_ids[a:base_name()] |
| − | local bi = U.ifind(CollectionEnemy, b:base_name()) | + | local bi = base_ids[b:base_name()] |
| | if ai and bi and ai ~= bi then | | if ai and bi and ai ~= bi then |
| | return ai < bi | | return ai < bi |
| Line 420: |
Line 425: |
| | | | |
| | local selectBoss = stringKey('boss', context, n, ''):lower() | | local selectBoss = stringKey('boss', context, n, ''):lower() |
| − | -- treat unknwon _back as bosses? why it is unknwon?
| + | |
| | local predBoss = selectBoss == 'yes' and | | local predBoss = selectBoss == 'yes' and |
| − | function(e) return (e._back or -11) <= -11 end | + | function(e) return e._boss ~= false and (e._boss == true or (e._back or -11) <= -11) end |
| | or selectBoss == 'no' and | | or selectBoss == 'no' and |
| − | function(e) return (e._back or -11) >= -10 end | + | function(e) return e._boss ~= true and (e._boss == false or (e._back or -11) >= -10) end |
| | or | | or |
| | function(e) return true end | | function(e) return true end |
| Line 450: |
Line 455: |
| | end | | end |
| | | | |
| − | testIterator('shipsByType', { type = '11', sort = '_class' , listBase = 'true'}) | + | --testIterator('shipsByType', { type = '11', sort = '_class' , listBase = 'true'}) |
| − | testIterator('shipsByType', { sort = '_name'}) | + | --testIterator('shipsByType', { sort = '_name'}) |
| − | testIterator('shipsByTrueId', { sort = '_id', from = '1', to = '20', listBase = 'true'}) | + | --testIterator('shipsByTrueId', { sort = '_id', from = '1', to = '20', listBase = 'true'}) |
| − | testIterator('shipsBy', { pred = 'is_auxiliary' , sort = '_name'}) | + | --testIterator('shipsBy', { pred = 'is_auxiliary' , sort = '_name'}) |
| | | | |
| − | testIterator('equipmentById', { from = '11', to = '20' }) | + | --testIterator('equipmentById', { from = '11', to = '20' }) |
| − | testIterator('equipmentByIdWithHeaders', { from = '1', to = '30' }) | + | --testIterator('equipmentByIdWithHeaders', { from = '1', to = '30' }) |
| − | testIterator('equipmentByType', { type = '2' }) | + | --testIterator('equipmentByType', { type = '2' }) |
| − | testIterator('equipmentByType', { type = '1', sort = '_icon' }) | + | --testIterator('equipmentByType', { type = '1', sort = '_icon' }) |
| − | testIterator('equipmentByTypeAndIcon', { type = '1', icon = '16' }) | + | --testIterator('equipmentByTypeAndIcon', { type = '1', icon = '16' }) |
| − | testIterator('equipmentBy', { pred = 'is_large_caliber_main_gun', sort = '_type' }) | + | --testIterator('equipmentBy', { pred = 'is_large_caliber_main_gun', sort = '_type' }) |
| | | | |
| − | testIterator('enemiesByType', { type = '2' }) | + | testIterator('enemiesByType', { type = '8' }) |
| | end | | end |
| | -- p.test() | | -- p.test() |
| | | | |
| | return Iterator | | return Iterator |