LINUX.ORG.RU

История изменений

Исправление pawnhearts, (текущая версия) :

Ну вот тот же скрипт на питоне.

import sys
import yaml

stats = {
        'STR_PISTOLS': (20, 15, 100),
        'STR_BOWS': (20, 15, 100),
        'STR_SMGS': (20, 15, 100),
        'STR_SHOTGUNS': (50, 40, 100),
        'STR_RIFLES': (50, 40, 100),
        'STR_SNIPER_RIFLES': (50, 40, 100),
        'STR_CANNONS': (65, 50, 100),
        'STR_MACHINE_GUNS': (65, 50, 100),
        'STR_LAUNCHERS': (80, 80, 100),
        }

res = {'items': []}

for item in yaml.load(open(sys.argv[1]))['items']:
    if 'categories' not in item or not set(item['categories']).intersection(stats.keys()) or 'STR_CLIPS' in item['categories']:
        continue
    new_item = {'type': item['type']}
    for k, v in stats.items():
        if k in item['categories']:
            new_item['meleePower'], new_item['tuMelee'], new_item['accuracyMelee'] = v
            break
    res['items'].append(new_item)

yaml.dump(res, open('out.rul', 'w'), default_flow_style=False)

Исправление pawnhearts, :

Ну вот тот же скрипт на питоне.

import sys
import yaml

stats = {
        'STR_PISTOLS': (20, 15, 100),
        'STR_BOWS': (20, 15, 100),
        'STR_SMGS': (20, 15, 100),
        'STR_SHOTGUNS': (50, 40, 100),
        'STR_RIFLES': (50, 40, 100),
        'STR_SNIPER_RIFLES': (50, 40, 100),
        'STR_CANNONS': (65, 50, 100),
        'STR_MACHINE_GUNS': (65, 50, 100),
        'STR_LAUNCHERS': (80, 80, 100),
        }

res = {'items': []}

for item in yaml.load(open(sys.argv[1]))['items']:
    if not set(item.get('categories', [])).intersection(stats.keys()) or 'STR_CLIPS' in item.get('categories', []):
        continue
    new_item = {'type': item['type']}
    for k, v in stats.items():
        if k in item['categories']:
            new_item['meleePower'], new_item['tuMelee'], new_item['accuracyMelee'] = v
            break
    res['items'].append(new_item)

yaml.dump(res, open('out.rul', 'w'), default_flow_style=False)

Исправление pawnhearts, :

Ну вот тот же скрипт на питоне.

import sys
import yaml

stats = {
        'STR_PISTOLS': (20, 15, 100),
        'STR_BOWS': (20, 15, 100),
        'STR_SMGS': (20, 15, 100),
        'STR_SHOTGUNS': (50, 40, 100),
        'STR_RIFLES': (50, 40, 100),
        'STR_SNIPER_RIFLES': (50, 40, 100),
        'STR_CANNONS': (65, 50, 100),
        'STR_MACHINE_GUNS': (65, 50, 100),
        'STR_LAUNCHERS': (80, 80, 100),
        }

res = {'items': []}

for item in yaml.load(open(sys.argv[1]))['items']:
    if not set(item.get('categories', [])).intersection(stats.keys()) or 'STR_CLIPS' in item.get('categories', [])':
        continue
    new_item = {'type': item['type']}
    for k, v in stats.items():
        if k in item['categories']:
            new_item['meleePower'], new_item['tuMelee'], new_item['accuracyMelee'] = v
            break
    res['items'].append(new_item)

yaml.dump(res, open('out.rul', 'w'), default_flow_style=False)

Исходная версия pawnhearts, :

Ну вот тот же скрипт на питоне.

import sys
import yaml

stats = {
        'STR_PISTOLS': (20, 15, 100),
        'STR_BOWS': (20, 15, 100),
        'STR_SMGS': (20, 15, 100),
        'STR_SHOTGUNS': (50, 40, 100),
        'STR_RIFLES': (50, 40, 100),
        'STR_SNIPER_RIFLES': (50, 40, 100),
        'STR_CANNONS': (65, 50, 100),
        'STR_MACHINE_GUNS': (65, 50, 100),
        'STR_LAUNCHERS': (80, 80, 100),
        }

res = {'items': []}

for item in yaml.load(open(sys.argv[1]))['items']:
    if not any(k == category for category in item.get('categories', []) for k in stats.keys()):
        continue
    new_item = {'type': item['type']}
    for k, v in stats.items():
        if k in item['categories']:
            new_item['meleePower'], new_item['tuMelee'], new_item['accuracyMelee'] = v
            break
    res['items'].append(new_item)

yaml.dump(res, open('out.rul', 'w'), default_flow_style=False)