| 1 |
#!/usr/bin/env python |
| 2 |
# gods2factions -- convert `crossfire-server -m6` output to factions SQL |
| 3 |
import sys |
| 4 |
|
| 5 |
def print_rels(faction, rel_str, rel): |
| 6 |
rels = rel_str.split(',') |
| 7 |
for r in rels: |
| 8 |
print("insert into relations values ('%s', '%s', %d);" |
| 9 |
% (faction, r, rel)) |
| 10 |
|
| 11 |
for l in sys.stdin.read().splitlines(): |
| 12 |
xs = map(str.strip, l.split(':')) |
| 13 |
if len(xs) < 1: |
| 14 |
continue |
| 15 |
if xs[0] == 'GOD': |
| 16 |
curr_god = xs[1] |
| 17 |
print("insert into regions values ('%s', 'ALL', 0.25);" % curr_god) |
| 18 |
elif xs[0] == 'aligned_race(s)': |
| 19 |
print_rels(curr_god, xs[1], 1) |
| 20 |
elif xs[0] == 'enemy_race(s)': |
| 21 |
print_rels(curr_god, xs[1], -1) |