Exemplo n.º 1
0
    def test_ast2textmap(self, ast, textmap):
        returned = ast2textmap(ast)

        assert textmap.namespace == returned.namespace
        assert textmap.vertices == returned.vertices
        assert textmap.linedefs == returned.linedefs
        assert textmap.sidedefs == returned.sidedefs
        assert textmap.sectors == returned.sectors
        assert textmap.things == returned.things
        assert textmap == returned
Exemplo n.º 2
0
    def test_ast2textmap(self, ast, textmap):
        returned = ast2textmap(ast)

        assert textmap == returned
Exemplo n.º 3
0
 def test_bijection(self, textmap):
     visage = SebelinoVisage()
     returned_textmap = ast2textmap(visage.textmap2ast(textmap))
     assert returned_textmap == textmap
Exemplo n.º 4
0
#!/usr/bin/env python
import argparse

from pyudmf.model.factory import ast2textmap, textmap2ast
from pyudmf.ops.scaler import scaled
from pyudmf.parser import parse_udmf

if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description="Scale an UDMF formatted Doom map.")
    parser.add_argument('infile', help="Path to the TEXTMAP lump file.")
    parser.add_argument(
        'scalingfactor',
        type=float,
        help="Scaling factor. E.g. if the factor is 0.5, the map will"
        " shrink to 25 %% of its original area.")

    args = parser.parse_args()

    with open(args.infile, 'r') as f:
        textmap_string = f.read().strip()
    ast = parse_udmf(textmap_string)
    textmap = ast2textmap(ast)
    scaled_textmap = scaled(textmap, args.scalingfactor)
    scaled_ast = textmap2ast(scaled_textmap)

    print(scaled_ast)