self._cache.append((msg_tag, msg))
msg = self._get_msg()
msg_tag = self._msg_tag(msg['Subject'])
self._cache.append((msg_tag, msg))
msg = self._get_msg()
msg_tag = self._msg_tag(msg['Subject'])
else:
body.append(' %s' % c)
self._send_mail(world, log, 'Drawing cards', '\n'.join(body))
else:
body.append(' %s' % c)
self._send_mail(world, log, 'Drawing cards', '\n'.join(body))
tag = self._send_mail(world, log, 'Select territory', '\n'.join(body))
body = self._get_mail(tag)
name = body.splitlines()[0].strip()
return name
tag = self._send_mail(world, log, 'Select territory', '\n'.join(body))
body = self._get_mail(tag)
name = body.splitlines()[0].strip()
return name
- def play_cards(self, world, log, play_required=True):
+ def play_cards(self, world, log, error=None,
+ play_required=True):
"""Decide whether or not to turn in a set of cards.
Return a list of cards to turn in or None. If play_required
"""Decide whether or not to turn in a set of cards.
Return a list of cards to turn in or None. If play_required
'blank to pass). Available sets are:']
for i,h in enumerate(possibles):
body.append(' %d: %s' % (i, h))
'blank to pass). Available sets are:']
for i,h in enumerate(possibles):
body.append(' %d: %s' % (i, h))
tag = self._send_mail(world, log, subject, '\n'.join(body))
body = self._get_mail(tag)
text = body.splitlines()[0].strip()
if text == '':
return None
return possibles[int(text)]
tag = self._send_mail(world, log, subject, '\n'.join(body))
body = self._get_mail(tag)
text = body.splitlines()[0].strip()
if text == '':
return None
return possibles[int(text)]
- def place_armies(self, world, log, remaining=1, this_round=1):
+ def place_armies(self, world, log, error=None,
+ remaining=1, this_round=1):
"""Both during setup and before each turn.
Return {territory_name: num_armies, ...}
"""Both during setup and before each turn.
Return {territory_name: num_armies, ...}
'Your current disposition is:']
for t in self.territories(world):
body.append(' %d : %s' % (t.armies, t))
'Your current disposition is:']
for t in self.territories(world):
body.append(' %d : %s' % (t.armies, t))
tag = self._send_mail(world, log, subject, '\n'.join(body))
body = self._get_mail(tag)
placements = {}
tag = self._send_mail(world, log, subject, '\n'.join(body))
body = self._get_mail(tag)
placements = {}
armies,terr_name = [x.strip() for x in line.split(':')]
placements[terr_name] = int(armies)
return placements
armies,terr_name = [x.strip() for x in line.split(':')]
placements[terr_name] = int(armies)
return placements
- def attack_and_fortify(self, world, log, mode='attack'):
+ def attack_and_fortify(self, world, log, error=None,
+ mode='attack'):
"""Return list of (source, target, armies) tuples. Place None
in the list to end this phase.
"""
"""Return list of (source, target, armies) tuples. Place None
in the list to end this phase.
"""
tag = self._send_mail(world, log, subject, '\n'.join(body))
body = self._get_mail(tag)
if mode == 'fortify':
tag = self._send_mail(world, log, subject, '\n'.join(body))
body = self._get_mail(tag)
if mode == 'fortify':
- def support_attack(self, world, log, source, target):
+ def support_attack(self, world, log, error,
+ source, target):
"""Follow up on a conquest by moving additional armies.
"""
subject = 'Support conquest of %s by %s' % (target, source)
"""Follow up on a conquest by moving additional armies.
"""
subject = 'Support conquest of %s by %s' % (target, source)
'Reply with first line(s) of the body of your email set',
'to "<number_of_armies>", or leave the first line blank',
'to pass.']
'Reply with first line(s) of the body of your email set',
'to "<number_of_armies>", or leave the first line blank',
'to pass.']
tag = self._send_mail(world, log, subject, '\n'.join(body))
body = self._get_mail(tag)
text = body.splitlines()[0].strip()
tag = self._send_mail(world, log, subject, '\n'.join(body))
body = self._get_mail(tag)
text = body.splitlines()[0].strip()