from pyrisk.base import generate_earth, Player, Engine
from pyrisk.player.email import IncomingEmailDispatcher, \
OutgoingEmailDispatcher, EmailPlayer
+ from pyrisk.graphics import WorldRenderer
world = generate_earth()
ied = IncomingEmailDispatcher(fifo_path='/tmp/pyrisk.in')
oed = OutgoingEmailDispatcher(return_address='server@example.com')
- players = [EmailPlayer('Alice', 'alice@big.edu', ied, oed),
- EmailPlayer('Bob', 'bob@fish.net', ied, oed),
+ wr = WorldRenderer()
+ players = [EmailPlayer('Alice', 'alice@big.edu', ied, oed, wr),
+ EmailPlayer('Bob', 'bob@fish.net', ied, oed, wr),
Player('Charlie')]
e = Engine(world, players)
e.run()
import tempfile
from ..base import Player, PlayerError
-from ..graphics import WorldRenderer
# Configure alternative sendmail command in case smtplib is too
else:
body.append(' %s\t%s\t%d' % (terr, terr.player, terr.armies))
return encodedMIMEText('\n'.join(body), filename='world')
- def _rendered_world_part(self, log, world):
+ def _rendered_world_part(self, world, log):
start_event = log[0]
players = start_event.players
body = self.world_renderer.render(world, players)
filename,subtype = \
self.world_renderer.filename_and_mime_image_type(world)
part = MIMEImage(body, subtype)
- part.add_header('Content-Disposition', 'attachment', filename)
+ part.add_header('Content-Disposition', 'attachment', filename=filename)
return part
def _log_part(self, log):
- return encodedMIMEText('\n'.join(log), filename='log')
+ return encodedMIMEText('\n'.join([str(e) for e in log]),
+ filename='log')
def report(self, world, log):
"""Send reports about death and game endings.