Esempio n. 1
0
 def test_achievements(self):
     rec = RecordedGame(
         os.path.join(os.path.dirname(os.path.abspath(__file__)),
                      'recs/versions/up1.4.mgz'))
     rec.body()  # Populate achievements on player objects.
     self.assertEqual(7411, rec.get_player(1).achievements()["score"])
     self.assertEqual(9484, rec.get_player(2).achievements()["score"])
Esempio n. 2
0
 def test_parse(self):
     files = self.records_provider()
     for f in files:
         rec = RecordedGame(
             os.path.join(os.path.dirname(os.path.abspath(__file__)), f))
         analysis = rec.run_analyzer(BodyAnalyzer())
         self.assertTrue(analysis.duration > 0)
Esempio n. 3
0
 def test_hd_forgotten(self):
     files = self.hd_forgotten_provider()
     for f in files:
         rec = RecordedGame(
             os.path.join(os.path.dirname(os.path.abspath(__file__)), f))
         # Just make sure it doesn't crash!
         analysis = rec.run_analyzer(BodyAnalyzer())
         self.assertIsNotNone(analysis)
Esempio n. 4
0
 def test_voobly_injected_messages(self):
     rec = RecordedGame(
         os.path.join(os.path.dirname(os.path.abspath(__file__)),
                      'recs/versions/up1.4.mgz'))
     messages = rec.run_analyzer(BodyAnalyzer()).chat_messages
     # Rating messages should belong to a player.
     self.assertEqual(messages[0].group, 'Rating')
     self.assertEqual(messages[0].msg, '2212')
     self.assertEqual(messages[0].player.name, 'Zuppi')
Esempio n. 5
0
    def coop_chat(self):
        rec = RecordedGame(
            os.path.join(
                os.path.dirname(os.path.abspath(__file__)),
                'recs/FluffyFur+yousifr+TheBlackWinds+Mobius_One[Chinese]=VS=MOD3000+Chrazini+ClosedLoop+ [AGM]Wineup[Britons]_1v1_8PlayerCo-op_01222015.mgx2'
            ))
        messages = rec.body().chat_messages

        # All these players are co-oping, so they share a player index.
        # They can all chat separately, though.
        self.assertEqual('yousifr', 'name', messages[0].player)
        self.assertEqual('TheBlackWinds', 'name', messages[3].player)
        self.assertEqual('Mobius One', 'name', messages[4].player)
Esempio n. 6
0
    def test_tributes(self):
        rec = RecordedGame(
            os.path.join(
                os.path.dirname(os.path.abspath(__file__)),
                'recs/versions/MP Replay v4.3 @2015.09.11 221142 (2).msx'))
        tributes = rec.run_analyzer(BodyAnalyzer()).tributes

        self.assertEqual(10000, tributes[0].amount)
        self.assertEqual(Resource.WOOD, tributes[0].resource)
        self.assertEqual('Ruga the Hun (Original AI)',
                         tributes[0].player_from.name)
        self.assertEqual('Mu Gui-ying (Original AI)',
                         tributes[0].player_to.name)
    def test_version(self):
        data = self.versions_provider()

        for case in data:
            file, expected_version, expected = case

            rec = RecordedGame(os.path.join(os.path.dirname(__file__), file))
            version = rec.run_analyzer(VersionAnalyzer())

            for prop, value in expected.items():
                try:
                    self.assertEqual(value, getattr(version, prop))
                except:
                    print("Expected {} of file {} to be {}".format(
                        prop, file, str(value)))
Esempio n. 8
0
parser.add_argument('-r',
                    '--researches',
                    dest="researches",
                    help="Output file for the researches image")
parser.add_argument('-m',
                    '--minimap',
                    dest="minimap",
                    help="Output file for the minimap")

args = parser.parse_args()

if not args.language:
    args.language = 'en'

# Read a recorded game from a file path.
rec = RecordedGame(args.filename,
                   {'translator': BasicTranslator(args.language)})

game = {}

# Game settings
version = rec.version()
game["version"] = version.version_string + " " + str(version.sub_version)
game["map"] = rec.game_settings().map_name()
game["type"] = rec.game_settings().game_type_name()
game["population_limit"] = rec.game_settings().get_pop_limit()
game["map_size"] = rec.game_settings().map_size_name()
game["difficulty"] = rec.game_settings().difficulty_name()
game["speed"] = rec.game_settings().game_speed_name()
game["players"] = {}

post_game_data = rec.achievements()
Esempio n. 9
0
   python examples/chat.py /path/to/your/own/file.mgx
"""

import argparse
import datetime

from pyrecanalyst.RecordedGame import RecordedGame


# Read a recorded game filename from the command line.
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--input', dest="filename", help="Input file", required=True)
args = parser.parse_args()

# Read a recorded game from a file path.
rec = RecordedGame(args.filename)

# There are two types of chat in a recorded game: pre-game multiplayer lobby
# chat, and in-game chat.

# Read the pre-game chat from the file header. Pre-game messages don't have a
# timestamp.
for chat in rec.header().pregame_chat:
    print(f"<{chat.player.name}> {chat.msg}")

# Read the in-game chat from the file body.
for chat in rec.body().chat_messages:
    # Format the millisecond time as HH:MM:SS.
    time = datetime.timedelta(milliseconds=chat.time)
    time_str = str(time).split(".")[0]
Esempio n. 10
0
 def test_custom_map_name_extract(self):
     rec = RecordedGame(os.path.join(os.path.dirname(__file__), 'recs/game-settings/[AoFE-FF DE R1] RoOk_FaLCoN - [Pervert]Moneimon (pov) G1.mgz'))
     self.assertEqual(rec.game_settings().map_name(), 'Acropolis')
     self.assertEqual(rec.game_settings().map_name({
         'extract_rms_name': False
     }), 'Custom')
Esempio n. 11
0
 def test_non_english_map_name_extract(self):
     rec = RecordedGame(os.path.join(os.path.dirname(__file__), 'recs/game-settings/rec.20140311-034826.mgz'))
     self.assertEqual(rec.game_settings().map_name(), 'Golden Pit')
     self.assertEqual(rec.game_settings().map_name({
         'extract_rms_name': False
     }), 'Custom')
Esempio n. 12
0
from pyrecanalyst.RecordedGame import RecordedGame
from pyrecanalyst.BasicTranslator import BasicTranslator

parser = argparse.ArgumentParser()
parser.add_argument('-i',
                    '--input',
                    dest='filename',
                    help='Input file',
                    required=True)
parser.add_argument('-l', '--lang', dest='language', help='Language')
args = parser.parse_args()

# Deafult language is system locale
if args.language is None:
    args.language = locale.getdefaultlocale()[0].split('_')[0]

# Read a recorded game from a file path.
rec = RecordedGame(args.filename,
                   {'translator': BasicTranslator(args.language)})

# Display some metadata.
print(f"Game Type: {rec.game_settings().game_type_name()}")
print(f"Starting Age: {rec.pov().starting_age()}")
print(f"Map Name: {rec.game_settings().map_name()}")

# Display players and their civilizations.
print("Players:")

for player in rec.players():
    print(f" * {player.name} ({player.civ_name()})")
Esempio n. 13
0
import argparse

from pyrecanalyst.RecordedGame import RecordedGame


parser = argparse.ArgumentParser()
parser.add_argument("-i", "--input", dest="filename", help="Input file", required=True)
parser.add_argument("-o", "--output", dest="output", default=None, help="Output file")
args = parser.parse_args()

if not args.output:
    args.output = os.path.basename(args.filename) + ".png"


# Read a recorded game from a file path.
rec = RecordedGame(args.filename)

version = rec.version()

print(f"Version: {version.version_string} ({version.sub_version})")

# Display map name
print(f"Map Name: {rec.game_settings().map_name()}")

# Display players and their civilizations.
print('Players: ')

for player in rec.players():
    symbol = '*'
    if player.owner:
        symbol = '>'
Esempio n. 14
0
 def load(self, path):
     return RecordedGame(os.path.join(os.path.dirname(__file__), path))