Skip to content
Browse files

Whitespace changes to appease the latest version of pep8.

  • Loading branch information...
1 parent 742a471 commit 3249123a26184fcadca52395bf6394ca0a8cb631 @dripton committed Jul 15, 2014
View
5 setup.py
@@ -17,10 +17,12 @@
class install_data_twisted(install_data):
+
"""Make sure data files are installed in package.
Yuck. Taken from an old version of Twisted's setup.py.
"""
+
def finalize_options(self):
self.set_undefined_options("install", ("install_lib", "install_dir"),)
install_data.finalize_options(self)
@@ -78,8 +80,7 @@ def write_version_file():
packages=["slugathon", "slugathon.ai", "slugathon.data",
"slugathon.game", "slugathon.gui", "slugathon.net",
"slugathon.util"],
- data_files=
- [
+ data_files=[
("slugathon/images/battlehex", glob("slugathon/images/battlehex/*")),
("slugathon/images/creature", glob("slugathon/images/creature/*")),
("slugathon/images/dice", glob("slugathon/images/dice/*")),
View
28 slugathon/ai/AIClient.py
@@ -101,7 +101,7 @@ def _setup_logging_form_game(self):
if not os.path.exists(logdir):
os.makedirs(logdir)
self.log_path = os.path.join(logdir, "slugathon-%s-%s.log" %
- (self.game_name, self.playername))
+ (self.game_name, self.playername))
file_handler = logging.FileHandler(filename=self.log_path)
file_handler.setFormatter(formatter)
logging.getLogger().addHandler(file_handler)
@@ -249,10 +249,10 @@ def update(self, observed, action, names):
"""Updates from User will come via remote_update, with
observed set to None."""
if (self.game_name is not None and hasattr(action, "game_name")
- and action.game_name != self.game_name):
+ and action.game_name != self.game_name):
return
if (isinstance(action, Action.AddUsername) or
- isinstance(action, Action.DelUsername)):
+ isinstance(action, Action.DelUsername)):
return
logging.info("%s", action)
@@ -313,8 +313,8 @@ def update(self, observed, action, names):
elif isinstance(action, Action.GameOver):
if action.winner_names:
logging.info("Game %s over, won by %s" %
- (action.game_name,
- " and ".join(action.winner_names)))
+ (action.game_name,
+ " and ".join(action.winner_names)))
else:
logging.info("Game %s over, draw" % action.game_name)
logging.info("AI exiting")
@@ -328,8 +328,8 @@ def update(self, observed, action, names):
elif isinstance(action, Action.CreateStartingLegion):
game = self.name_to_game(action.game_name)
logging.info("ps = PredictSplits('%s', '%s', %s)" %
- (action.playername, action.markerid,
- starting_creature_names))
+ (action.playername, action.markerid,
+ starting_creature_names))
ps = predictsplits.PredictSplits(action.playername,
action.markerid,
starting_creature_names)
@@ -400,8 +400,8 @@ def update(self, observed, action, names):
game = self.name_to_game(action.game_name)
player = game.get_player_by_name(self.playername)
if (game.defender_legion and game.defender_legion.player.name ==
- self.playername and action.defender_markerid in
- player.markerid_to_legion):
+ self.playername and action.defender_markerid in
+ player.markerid_to_legion):
reactor.callLater(self.delay, self.ai.move_creatures, game)
elif isinstance(action, Action.MoveCreature):
@@ -514,8 +514,8 @@ def update(self, observed, action, names):
self.ai.choose_engagement, game)
else:
if (game.phase == Phase.FIGHT and
- game.battle_phase != Phase.REINFORCE and
- game.active_player.name == self.playername):
+ game.battle_phase != Phase.REINFORCE and
+ game.active_player.name == self.playername):
reactor.callLater(self.delay, self.ai.choose_engagement,
game)
@@ -538,7 +538,7 @@ def update(self, observed, action, names):
reactor.callLater(self.delay, self.ai.choose_engagement, game)
else:
if (game.phase == Phase.FIGHT and
- game.active_player.name == self.playername):
+ game.active_player.name == self.playername):
reactor.callLater(self.delay, self.ai.choose_engagement,
game)
@@ -599,7 +599,7 @@ def update(self, observed, action, names):
if game.attacker_legion:
legion = game.attacker_legion
if (legion.markerid == action.winner_markerid and
- legion.can_summon):
+ legion.can_summon):
reactor.callLater(self.delay, self.ai.summon_angel,
game)
return
@@ -608,7 +608,7 @@ def update(self, observed, action, names):
legion = game.defender_legion
if legion.player.name == self.playername:
if (legion.markerid == action.winner_markerid and
- legion.can_recruit):
+ legion.can_recruit):
reactor.callLater(self.delay, self.ai.reinforce,
game)
return
View
8 slugathon/game/BattleMap.py
@@ -194,7 +194,7 @@ def range(self, hexlabel1, hexlabel2, allow_entrance=False):
"""
if hexlabel1 not in self.hexes or hexlabel2 not in self.hexes:
logging.info("BattleMap.range invalid hexlabel %s %s %s" %
- (hexlabel1, hexlabel2, allow_entrance))
+ (hexlabel1, hexlabel2, allow_entrance))
return maxint
if hexlabel1 == hexlabel2:
return 1
@@ -397,16 +397,16 @@ def _is_los_blocked_dir(self,
mid_obstacle = True
total_obstacles += 1
if (border == "Cliff" or border2 == "Cliff" or
- border == "Dune" or border2 == "Dune"):
+ border == "Dune" or border2 == "Dune"):
mid_cliff = True
if next_hex.blocks_line_of_sight:
return True
# Creatures block LOS, unless both striker and target are at higher
# elevation than the creature, or unless the creature is at
# the base of a cliff and the striker or target is atop it.
if (game is not None and game.is_battle_hex_occupied(next_hex.label)
- and next_hex.elevation >= strike_elevation and
- (not striker_atop_cliff or current_hex != initial_hex)):
+ and next_hex.elevation >= strike_elevation and
+ (not striker_atop_cliff or current_hex != initial_hex)):
mid_chit = True
return self._is_los_blocked_dir(initial_hex, next_hex, final_hex,
left, strike_elevation, striker_atop,
View
45 slugathon/game/Game.py
@@ -359,7 +359,7 @@ def assign_color(self, playername, color):
return
if playername != self.next_playername_to_pick_color:
raise AssertionError("illegal assign_color attempt %s %s" %
- (playername, color))
+ (playername, color))
if color not in self.colors_left:
raise AssertionError("tried to take unavailable color")
player.assign_color(color)
@@ -579,7 +579,7 @@ def can_move_legion(self, player, legion, hexlabel, entry_side, teleport,
masterhex = self.board.hexes[legion.hexlabel]
if teleport:
if (player.teleported or teleporting_lord not in
- legion.creature_names):
+ legion.creature_names):
return False
moves = self.find_all_teleport_moves(legion, masterhex,
player.movement_roll)
@@ -645,7 +645,7 @@ def resolve_engagement(self, playername, hexlabel):
"""Called from Server."""
logging.info("")
if (self.pending_summon or self.pending_reinforcement or
- self.pending_acquire):
+ self.pending_acquire):
logging.info("cannot move on to next engagement yet")
return
player = self.get_player_by_name(playername)
@@ -880,7 +880,7 @@ def _fight(self, playername, attacker_markerid, defender_markerid):
logging.info("attacker %s", attacker_legion)
logging.info("defender %s", defender_legion)
if (not attacker_legion or not defender_legion or playername not in
- [attacker_legion.player.name, defender_legion.player.name]):
+ [attacker_legion.player.name, defender_legion.player.name]):
logging.info("illegal fight call from %s", playername)
return
if defender_legion.can_flee and not self.defender_chose_not_to_flee:
@@ -911,7 +911,7 @@ def acquire_angels(self, playername, markerid, angel_names):
angel_names)
self.notify(action)
if (self.is_battle_over and not self.pending_summon and not
- self.pending_reinforcement):
+ self.pending_reinforcement):
self._cleanup_battle()
reactor.callLater(1, self._end_dead_player_turn)
@@ -924,7 +924,7 @@ def do_not_acquire_angels(self, playername, markerid):
return
legion.do_not_acquire_angels()
if (self.is_battle_over and not self.pending_summon and not
- self.pending_reinforcement):
+ self.pending_reinforcement):
self._cleanup_battle()
def done_with_engagements(self, playername):
@@ -938,7 +938,7 @@ def done_with_engagements(self, playername):
logging.info("%s ending fight phase out of turn" % playername)
return
if (self.pending_summon or self.pending_reinforcement or
- self.pending_acquire):
+ self.pending_acquire):
raise AssertionError("cannot end engagements yet",
"summon", self.pending_summon,
"reinforcement",
@@ -1230,8 +1230,10 @@ def _find_battle_moves_inner(self, creature, hexlabel, movement_left,
creature2 = self.creatures_in_battle_hex(hex2.label).pop()
except KeyError:
creature2 = None
- if (creature.flies or not creature2 or (ignore_mobile_allies and
- creature2.legion == creature.legion and creature2.mobile)):
+ if (creature.flies or not creature2 or (
+ ignore_mobile_allies and
+ creature2.legion == creature.legion and
+ creature2.mobile)):
if hex1.entrance:
# Ignore hexside penalties from entrances. There aren't
# any on the standard boards, and this avoids having to
@@ -1247,9 +1249,10 @@ def _find_battle_moves_inner(self, creature, hexlabel, movement_left,
hex2.label).pop()
except KeyError:
creature2 = None
- if (not creature2 or (ignore_mobile_allies and
- creature2.legion == creature.legion and
- creature2.mobile)):
+ if (not creature2 or (
+ ignore_mobile_allies and
+ creature2.legion == creature.legion and
+ creature2.mobile)):
result.add(hex2.label)
if creature.flies:
flyover_cost = self.battle_hex_flyover_cost(creature,
@@ -1276,7 +1279,7 @@ def find_battle_moves(self, creature, ignore_mobile_allies=False):
if creature.moved or creature.engaged:
return result
if (self.battle_turn == 1 and creature.legion == self.defender_legion
- and self.battlemap.startlist):
+ and self.battlemap.startlist):
for hexlabel2 in self.battlemap.startlist:
# There can't be any mobile allies there on turn 1.
if not self.is_battle_hex_occupied(hexlabel2):
@@ -1475,7 +1478,7 @@ def _end_battle(self):
elif self.attacker_legion and self.attacker_legion.dead:
# defender wins, possible reinforcement
if (self.defender_legion and self.attacker_entered and
- self.defender_legion.can_recruit):
+ self.defender_legion.can_recruit):
logging.info("setting pending_reinforcement = True")
self.pending_reinforcement = True
self.attacker_legion.die(self.defender_legion, False, False)
@@ -1500,15 +1503,15 @@ def _end_battle(self):
legion.remove_creature_by_name(creature_name)
self.caretaker.kill_one(creature_name)
if (not self.pending_summon and not self.pending_reinforcement and not
- self.pending_acquire):
+ self.pending_acquire):
self._cleanup_battle()
reactor.callLater(1, self._end_dead_player_turn)
def _end_dead_player_turn(self):
"""If the active player is dead then advance phases if possible."""
if self.master:
if (self.active_player.dead and not self.pending_acquire and not
- self.pending_summon and not self.pending_reinforcement):
+ self.pending_summon and not self.pending_reinforcement):
logging.info("_end_dead_player_turn")
if self.phase == Phase.SPLIT:
self.active_player.done_with_splits()
@@ -1533,7 +1536,7 @@ def done_with_counterstrikes(self, playername):
logging.info("ending counterstrike phase out of phase")
return
if (not self.is_battle_over and
- self.battle_active_legion == self.defender_legion):
+ self.battle_active_legion == self.defender_legion):
self.battle_turn += 1
logging.info("bumped battle turn to %s", self.battle_turn)
if self.is_battle_over:
@@ -1599,9 +1602,9 @@ def cleanup_dead_creatures(self):
for creature in legion.creatures:
if creature.dead:
if (self.first_attacker_kill is None
- and creature.legion is self.defender_legion
- and creature.hexlabel != "DEFENDER"
- and creature.hexlabel is not None):
+ and creature.legion is self.defender_legion
+ and creature.hexlabel != "DEFENDER"
+ and creature.hexlabel is not None):
self.first_attacker_kill = self.battle_turn
logging.info("first_attacker_kill %s",
self.battle_turn)
@@ -1899,7 +1902,7 @@ def update(self, observed, action, names):
elif isinstance(action, Action.StartStrikeBattlePhase):
if (not self.attacker_entered and self.attacker_legion and
- self.battle_active_legion == self.attacker_legion):
+ self.battle_active_legion == self.attacker_legion):
for creature in self.attacker_legion.creatures:
if not creature.dead and creature.hexlabel != "ATTACKER":
self.attacker_entered = True
View
2 slugathon/game/Player.py
@@ -292,7 +292,7 @@ def unmoved_legions(self):
def friendly_legions(self, hexlabel=None):
"""Return a set of this player's legions, in hexlabel if not None."""
return set([legion for legion in self.legions if hexlabel in
- (None, legion.hexlabel)])
+ (None, legion.hexlabel)])
def enemy_legions(self, hexlabel=None):
"""Return a set of other players' legions, in hexlabel if not None."""
View
4 slugathon/gui/AcquireAngels.py
@@ -63,8 +63,8 @@ def __init__(self, playername, legion, num_archangels, num_angels,
self.vbox.set_spacing(9)
legion_name = gtk.Label("Acquire angel for legion %s (%s) in hex %s" %
- (legion.markerid, legion.picname,
- legion.hexlabel))
+ (legion.markerid, legion.picname,
+ legion.hexlabel))
self.vbox.pack_start(legion_name)
legion_hbox = gtk.HBox(spacing=3)
View
2 slugathon/gui/Inspector.py
@@ -104,7 +104,7 @@ def cb_destroy(confirmed):
inspector.show_legion(legion)
creatures2 = [Creature.Creature(name) for name in
- ["Angel", "Giant", "Warbear", "Unicorn"]]
+ ["Angel", "Giant", "Warbear", "Unicorn"]]
index = random.randrange(1, 12 + 1)
legion2 = Legion.Legion(player, "%s%02d" % (abbrev, index), creatures2, 2)
inspector.show_legion(legion2)
View
2 slugathon/gui/PickStrikePenalty.py
@@ -47,7 +47,7 @@ def __init__(self, playername, game_name, striker, target, def1, parent):
self.vbox.set_spacing(9)
label = gtk.Label("Choose strike penalty for %r striking %r?" %
- (striker, target))
+ (striker, target))
self.vbox.add(label)
# Map tuple of (num_dice, strike_number) to set of creatures it can hit
View
2 slugathon/gui/PickTeleportingLord.py
@@ -80,7 +80,7 @@ def cb_cancel(self, widget, response_id):
player = Player.Player(playername, game, 0)
player.color = "Red"
creatures1 = [Creature.Creature(name) for name in
- ["Titan", "Archangel", "Angel", "Ogre", "Troll", "Ranger"]]
+ ["Titan", "Archangel", "Angel", "Ogre", "Troll", "Ranger"]]
legion = Legion.Legion(player, "Rd01", creatures1, 1)
player.markerid_to_legion[legion.markerid] = legion
View
12 slugathon/gui/SummonAngel.py
@@ -47,7 +47,7 @@ def __init__(self, playername, legion, def1, parent):
for legion2 in player.legions:
if (legion2.any_summonable and not legion2.engaged and
- legion2 != legion):
+ legion2 != legion):
hbox = gtk.HBox(spacing=3)
self.vbox.pack_start(hbox)
marker = Marker.Marker(legion2, False, scale=20)
@@ -89,15 +89,15 @@ def cb_cancel(self, widget, response_id):
player = Player.Player(playername, game, 0)
player.color = "Red"
creatures1 = [Creature.Creature(name) for name in
- ["Titan", "Ogre", "Troll", "Ranger"]]
+ ["Titan", "Ogre", "Troll", "Ranger"]]
creatures2 = [Creature.Creature(name) for name in
- ["Angel", "Ogre", "Troll", "Ranger"]]
+ ["Angel", "Ogre", "Troll", "Ranger"]]
creatures3 = [Creature.Creature(name) for name in
- ["Archangel", "Centaur", "Lion", "Ranger"]]
+ ["Archangel", "Centaur", "Lion", "Ranger"]]
creatures4 = [Creature.Creature(name) for name in
- ["Gargoyle", "Cyclops", "Gorgon", "Behemoth"]]
+ ["Gargoyle", "Cyclops", "Gorgon", "Behemoth"]]
creatures5 = [Creature.Creature(name) for name in
- ["Angel", "Angel", "Warlock", "Guardian"]]
+ ["Angel", "Angel", "Warlock", "Guardian"]]
legion1 = Legion.Legion(player, "Rd01", creatures1, 1)
legion2 = Legion.Legion(player, "Rd02", creatures2, 2)
legion3 = Legion.Legion(player, "Rd03", creatures3, 3)
View
17 slugathon/net/Server.py
@@ -277,7 +277,7 @@ def _spawn_ais(self, game):
"--port", str(self.port),
"--game-name", game.name,
"--log-path", os.path.join(logdir, "slugathon-%s-%s.log" %
- (game.name, ainame)),
+ (game.name, ainame)),
"--ai-time-limit", str(game.ai_time_limit),
])
if not self.no_passwd:
@@ -535,11 +535,12 @@ def fight(self, playername, game_name, attacker_markerid,
attacker_legion = game.find_legion(attacker_markerid)
defender_legion = game.find_legion(defender_markerid)
if (not attacker_legion or not defender_legion or playername not in
- [attacker_legion.player.name, defender_legion.player.name]):
+ [attacker_legion.player.name,
+ defender_legion.player.name]):
logging.warning("illegal fight call from %s", playername)
return
if (defender_legion.can_flee and not
- game.defender_chose_not_to_flee):
+ game.defender_chose_not_to_flee):
logging.warning(
"Illegal fight call while defender can still flee")
return
@@ -587,7 +588,7 @@ def done_with_reinforcements(self, playername, game_name):
if game:
player = game.get_player_by_name(playername)
if (player is not None and player == game.battle_active_player and
- game.battle_phase == Phase.REINFORCE):
+ game.battle_phase == Phase.REINFORCE):
game.done_with_reinforcements(playername)
def done_with_maneuvers(self, playername, game_name):
@@ -596,7 +597,7 @@ def done_with_maneuvers(self, playername, game_name):
if game:
player = game.get_player_by_name(playername)
if (player is not None and player == game.battle_active_player and
- game.battle_phase == Phase.MANEUVER):
+ game.battle_phase == Phase.MANEUVER):
game.done_with_maneuvers(playername)
def strike(self, playername, game_name, striker_name, striker_hexlabel,
@@ -613,7 +614,7 @@ def done_with_strikes(self, playername, game_name):
if game:
player = game.get_player_by_name(playername)
if (player is not None and player == game.battle_active_player and
- game.battle_phase == Phase.STRIKE):
+ game.battle_phase == Phase.STRIKE):
game.done_with_strikes(playername)
def done_with_counterstrikes(self, playername, game_name):
@@ -622,7 +623,7 @@ def done_with_counterstrikes(self, playername, game_name):
if game:
player = game.get_player_by_name(playername)
if (player is not None and player == game.battle_active_player and
- game.battle_phase == Phase.COUNTERSTRIKE):
+ game.battle_phase == Phase.COUNTERSTRIKE):
game.done_with_counterstrikes(playername)
def acquire_angels(self, playername, game_name, markerid, angel_names):
@@ -690,7 +691,7 @@ def done_with_engagements(self, playername, game_name):
logging.warning("out of turn")
return
if (game.pending_summon or game.pending_reinforcement or
- game.pending_acquire):
+ game.pending_acquire):
logging.warning("waiting on something")
return
if game.phase != Phase.FIGHT:
View
2 slugathon/test/test_battle.py
@@ -1569,7 +1569,7 @@ def test_strikes_brush(self):
assert titan.can_take_strike_penalty(gargoyle2)
assert titan.valid_strike_penalties(ogre) == set([(6, 4), (6, 3),
- (6, 2)])
+ (6, 2)])
assert titan.valid_strike_penalties(gargoyle1) == set([(6, 4)])
assert titan.valid_strike_penalties(gargoyle2) == set([(6, 4), (6, 3)])
View
4 slugathon/test/test_dice.py
@@ -164,7 +164,7 @@ def test_M(self):
n = self.trials
mean_M = 2. * r * (n - r) / n + 1.
var_M = (((2. * r) * (n - r) / n ** 2 * ((2. * r) * (n - r) - n)) /
- (n - 1.))
+ (n - 1.))
logging.info("M test: r = %s M = %s mean = %s var = %s", r, M, mean_M,
var_M)
fail_if_abnormal(M, mean_M, var_M)
@@ -189,7 +189,7 @@ def test_runs(self):
R = 0. + pos
mean_R = 1. + (2 * pos * neg) / (pos + neg)
var_R = (((2. * pos * neg) * (2. * pos * neg - pos - neg)) /
- ((pos + neg) * (pos + neg) * (pos + neg - 1)))
+ ((pos + neg) * (pos + neg) * (pos + neg - 1)))
logging.info("Runs test: R = %s m = %s mean = %s var = %s", R, m,
mean_R, var_R)
fail_if_abnormal(R, mean_R, var_R)

0 comments on commit 3249123

Please sign in to comment.
Something went wrong with that request. Please try again.