| 413 | item.requiredfor = json.dumps(itemsByReq[item.typeID]) |
| 414 | |
| 415 | def processReplacements(eveTypesData, eveGroupsData, dogmaTypeAttributesData, dogmaTypeEffectsData): |
| 416 | print('finding item replacements') |
| 417 | |
| 418 | def compareAttrs(attrs1, attrs2): |
| 419 | # Consider items as different if they have no attrs |
| 420 | if len(attrs1) == 0 and len(attrs2) == 0: |
| 421 | return False |
| 422 | if set(attrs1) != set(attrs2): |
| 423 | return False |
| 424 | if all(attrs1[aid] == attrs2[aid] for aid in attrs1): |
| 425 | return True |
| 426 | return False |
| 427 | |
| 428 | skillReqAttribs = { |
| 429 | 182: 277, |
| 430 | 183: 278, |
| 431 | 184: 279, |
| 432 | 1285: 1286, |
| 433 | 1289: 1287, |
| 434 | 1290: 1288} |
| 435 | skillReqAttribsFlat = set(skillReqAttribs.keys()).union(skillReqAttribs.values()) |
| 436 | # Get data on type groups |
| 437 | # Format: {type ID: group ID} |
| 438 | typesGroups = {} |
| 439 | for row in eveTypesData: |
| 440 | typesGroups[row['typeID']] = row['groupID'] |
| 441 | # Get data on item effects |
| 442 | # Format: {type ID: set(effect, IDs)} |
| 443 | typesEffects = {} |
| 444 | for row in dogmaTypeEffectsData: |
| 445 | typesEffects.setdefault(row['typeID'], set()).add(row['effectID']) |
| 446 | # Get data on type attributes |
| 447 | # Format: {type ID: {attribute ID: attribute value}} |
| 448 | typesNormalAttribs = {} |
| 449 | typesSkillAttribs = {} |
| 450 | for row in dogmaTypeAttributesData: |
| 451 | attributeID = row['attributeID'] |
| 452 | if attributeID in skillReqAttribsFlat: |
| 453 | typeSkillAttribs = typesSkillAttribs.setdefault(row['typeID'], {}) |
| 454 | typeSkillAttribs[row['attributeID']] = row['value'] |
| 455 | # Ignore these attributes for comparison purposes |
| 456 | elif attributeID in ( |
| 457 | # We do not need mass as it affects final ship stats only when carried by ship itself |
| 458 | # (and we're not going to replace ships), but it's wildly inconsistent for other items, |
| 459 | # which otherwise would be the same |
| 460 | 4, # mass |
| 461 | 124, # mainColor |
| 462 | 162, # radius |
| 463 | 422, # techLevel |
| 464 | 633, # metaLevel |
| 465 | 1692, # metaGroupID |
| 466 | 1768 # typeColorScheme |
| 467 | ): |
| 468 | continue |
| 469 | else: |
| 470 | typeNormalAttribs = typesNormalAttribs.setdefault(row['typeID'], {}) |
| 471 | typeNormalAttribs[row['attributeID']] = row['value'] |
| 472 | # Get data on skill requirements |