Skip to content

removed whitespace #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion noobhack/game/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def __init__(self):

def listen(self, event, function):
if not self.listeners.has_key(event):
self.listeners[event] = set()
self.listeners[event] = set()

self.listeners[event].add(function)

Expand Down
4 changes: 2 additions & 2 deletions noobhack/game/graphics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ibm = dict(
ibm = dict(
zip(
(ord(code_point) for code_point in
# Normal IBMgraphics...
Expand All @@ -7,7 +7,7 @@

# Rogue level IBMgraphics...
u'\u2551\u2550\u2554\u2557\u255a\u255d\u256c\u2569\u2566\u2563\u2560' +
u'\u263a\u2666\u2663\u2640\u266b\u263c\u2191[\xa1\u2592\u2593\u03c4' +
u'\u263a\u2666\u2663\u2640\u266b\u263c\u2191[\xa1\u2592\u2593\u03c4' +
u'\u2261\xb7'
),
# And... the normal way we expect them...
Expand Down
4 changes: 2 additions & 2 deletions noobhack/game/intrinsics.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"Disintegration resist.": {
"You are disintegration-resistant":True,
"You feel very firm.":True,
"You feel totally together, man.":True
"You feel totally together, man.":True
},
"Poison resistance": {
"You are poison resistant":True,
Expand All @@ -51,7 +51,7 @@
"See invisible": {
"You see an image of someone stalking you.":True,
"You feel transparent":True,
"You feel very self-conscious":True,
"You feel very self-conscious":True,
"Your vision becomes clear":True
},
"Searching": {
Expand Down
36 changes: 18 additions & 18 deletions noobhack/game/mapping.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class Branch:
"""
"""
Given a level, provide some methods to treat that level's dungeon
branch as a distinct entity. Probably most importantly, Branch's are iters
that iterate from the top (lowest dlvl) to the bottom (highest dlvl).
Expand All @@ -21,7 +21,7 @@ def find_top(self, level):
branch
"""

ups = [l for l
ups = [l for l
in level.stairs.values()
if l.dlvl < level.dlvl
and l.branch == level.branch]
Expand All @@ -36,7 +36,7 @@ def name(self):

def sub_branches(self):
"""
Return all branches that are connected to this one (whether they're
Return all branches that are connected to this one (whether they're
parents or children)
"""

Expand All @@ -54,8 +54,8 @@ def next(self):
raise StopIteration
else:
current = self.current
potential_nexts = [l for l
in current.stairs.values()
potential_nexts = [l for l
in current.stairs.values()
if l.branch == current.branch
and l.dlvl > current.dlvl]
if len(potential_nexts) > 0:
Expand All @@ -67,7 +67,7 @@ def next(self):

class Level(object):
"""
A single dungeon level. This can be thought of as "mines, level 3", or
A single dungeon level. This can be thought of as "mines, level 3", or
"main, level 5". There can be multiple levels of the same dlvl, but
they should generally be in different branches. Dungeons have stairs to
other levels.
Expand All @@ -79,7 +79,7 @@ class Level(object):

def __init__(self, dlvl, branch="main"):
self.dlvl = dlvl
self.branch = branch
self.branch = branch
self.stairs = {}

# Level features
Expand Down Expand Up @@ -116,28 +116,28 @@ def is_a_junction(self):

class Map:
def __init__(self, level, x, y):
self.current = level
self.current = level
self.levels = set([self.current])
self.location = (x, y)
self.location = (x, y)

def move(self, x, y):
self.location = (x, y)
self.current.breadcrumbs.add((x, y))

def level_at(self, branch, dlvl):
maybe_level = [l for l
in self.levels
if l.dlvl == dlvl
maybe_level = [l for l
in self.levels
if l.dlvl == dlvl
and l.branch == branch]
if len(maybe_level) == 1:
return maybe_level[0]
else:
else:
return None

def change_branch_to(self, branch):
peers = [l for l
in self.levels
if l.dlvl == self.current.dlvl
peers = [l for l
in self.levels
if l.dlvl == self.current.dlvl
and l != self.current
and l.branch == "not sure"]

Expand All @@ -158,8 +158,8 @@ def _add(self, new_level, pos):
self._link(new_level, pos)

def _handle_existing_level(self, to_dlvl, to_pos):
has_stairs_to_other_lower = [l for l
in self.current.stairs.values()
has_stairs_to_other_lower = [l for l
in self.current.stairs.values()
if l.dlvl == to_dlvl]

if len(has_stairs_to_other_lower) > 0:
Expand Down
4 changes: 2 additions & 2 deletions noobhack/game/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def load(save_file):
save.close()
else:
raise RuntimeError(
"NetHack is trying to restore a game file, but noobhack " +
"NetHack is trying to restore a game file, but noobhack " +
"doesn't have any memory of this game. While noobhack will " +
"still work on a game it doesn't know anything about, there " +
"will probably be errors. If you'd like to use noobhack, " +
"run nethack and quit your current game, then restart " +
"run nethack and quit your current game, then restart " +
"noobhack."
)

Expand Down
12 changes: 6 additions & 6 deletions noobhack/game/shops.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"quality apparel and accessories": "90/10 wand/misc",
"hardware store": "tools",
"rare books": "90/10 books/scrolls",
"lighting store": "97/3 light/m.lamp"
"lighting store": "97/3 light/m.lamp"
}

amulets = set([
Expand All @@ -30,7 +30,7 @@
("Yendor", 30000, 0, None),
])

weapons = {
weapons = {
"dagger": set([
("orcish dagger", 4, 12, "crude dagger"),
("dagger", 4, 30, None),
Expand Down Expand Up @@ -215,7 +215,7 @@
])

rings = set([
("meat ring", 5, 0, None),
("meat ring", 5, 0, None),
("adornment",100, 1, None),
("hunger",100, 1, None),
("protection",100, 1, None),
Expand Down Expand Up @@ -436,7 +436,7 @@ def get_item_set(name):
def buy_identify(charisma, item, cost, sucker=False):
possibles = get_item_set(item)
if possibles is None:
return set()
return set()

markup = buy_price_markup(charisma)
price_adjusted = [(p[0], p[1] + round(p[1] * markup)) + p[2:] for p in possibles]
Expand All @@ -445,10 +445,10 @@ def buy_identify(charisma, item, cost, sucker=False):

if sucker:
real_possibles = [(p[0], p[1] + round(p[1] * 0.333)) + p[2:] for p in real_possibles]

appearance_ids = set([p for p in real_possibles if p[3] == item and abs(p[1] - cost) <= 1])
if len(appearance_ids) > 0:
return appearance_ids
return appearance_ids

price_ids = set([p for p in real_possibles if abs(p[1] - cost) <= 1])

Expand Down
12 changes: 6 additions & 6 deletions noobhack/game/sounds.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
messages = {
"oracle": set((
"oracle": set((
"You hear a strange wind.",
"You hear convulsive ravings.",
"You hear snoring snakes.",
Expand All @@ -10,19 +10,19 @@
"rogue": set(("You enter what seems to be an older, more primitive world.",)),
"angry watch": set(("You hear the shrill sound of a guard's whistle.",)),
"zoo": set((
"You hear a sound reminiscent of an elephant stepping on a peanut.",
"You hear a sound reminiscent of a seal barking.",
"You hear a sound reminiscent of an elephant stepping on a peanut.",
"You hear a sound reminiscent of a seal barking.",
"You hear Doctor Doolittle!"
)),
"beehive": set((
"You hear a low buzzing.",
"You hear an angry drone.",
"You hear an angry drone.",
"You hear bees in your.*bonnet!"
)),
"barracks": set((
"You hear blades being honed.",
"You hear loud snoring.",
"You hear dice being thrown.",
"You hear loud snoring.",
"You hear dice being thrown.",
"You hear General MacArthur!"
)),
"shop": set((
Expand Down
6 changes: 3 additions & 3 deletions noobhack/game/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def type_of(status):
"""
Return the type of a particular status; either `"good"`, `"bad"` or
Return the type of a particular status; either `"good"`, `"bad"` or
`"neutral"`
"""
if status in bads:
Expand All @@ -26,7 +26,7 @@ def type_of(status):
"You feel quick!": True,
"You seem faster.": True,
"You speed up.": True,
"Your quickness feels more natural.": True,
"Your quickness feels more natural.": True,
"\"and thus I grant thee the gift of Speed!\"": True,
"You are slowing down.": False,
"You feel slow!": False,
Expand Down Expand Up @@ -57,7 +57,7 @@ def type_of(status):
"You feel less jumpy.": False
},
"stoning": {
"You are slowing down.": True,
"You are slowing down.": True,
"Your limbs are stiffening.": True,
"You feel limber!": False,
"You feel more limber.": False,
Expand Down
12 changes: 6 additions & 6 deletions noobhack/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def open(self):
def _close(self, *_):
"""
Raise an exception signaling that the child process has finished.
Whoever catches the exception is responsible for flushing the child's
Whoever catches the exception is responsible for flushing the child's
stdout.
"""

Expand Down Expand Up @@ -91,16 +91,16 @@ def write(self, buf):
self.stdin.write(buf)

def read(self):
"""
Proxy output from the nethack process' stdout. This shouldn't block
"""
Proxy output from the nethack process' stdout. This shouldn't block
"""
buf = ""
while self.data_is_available():
while self.data_is_available():
buf += self.stdout.read(1)
return buf

def data_is_available(self):
"""
Return a non-empty list when the nethack process has data to read
"""
Return a non-empty list when the nethack process has data to read
"""
return select.select([self.stdout], [], [], 0) == ([self.stdout], [], [])
10 changes: 5 additions & 5 deletions noobhack/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class Input:

def __init__(self, game):
self.game = game
self.callbacks = []
self.callbacks = []

def register(self, callback):
"""
Register a function that will be called *before* any input read off of
stdin is forwarded to the game. The callback should return `False` if
stdin is forwarded to the game. The callback should return `False` if
it's not to forward the input to the game.
"""
if callback not in self.callbacks:
Expand Down Expand Up @@ -52,19 +52,19 @@ def proxy(self):

class Output:
"""
Proxies raw output from the game and calls a set of callbacks each time
Proxies raw output from the game and calls a set of callbacks each time
with the stream that was output. Typically you'd want to attach a terminal
emulator, or something that can parse the output as meaningful to this.
"""

def __init__(self, game):
self.game = game
self.callbacks = []
self.callbacks = []

def register(self, callback):
"""
Register a function that will be called whenever any input is read. The
function should accept one argument, which will be the data read from
function should accept one argument, which will be the data read from
the game.
"""
if callback not in self.callbacks:
Expand Down
8 changes: 4 additions & 4 deletions noobhack/telnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Telnet:
"""
Runs and manages the input/output of a remote nethack game. The class
Runs and manages the input/output of a remote nethack game. The class
implements a telnet client in as much as the python telnetlib makes that
possible (grumble, grumble, grumble).
"""
Expand All @@ -20,8 +20,8 @@ def write(self, buf):
self.conn.get_socket().send(buf)

def read(self):
"""
Proxy output from the telnet process' stdout. This shouldn't block
"""
Proxy output from the telnet process' stdout. This shouldn't block
"""
try:
return self.conn.read_very_eager()
Expand Down Expand Up @@ -77,7 +77,7 @@ def set_option(self, socket, command, option):
telnetlib.IAC,
telnetlib.SE))
# We're being asked for the terminal type that we promised earlier
socket.send("%s%s\x18\x00%s%s%s" %
socket.send("%s%s\x18\x00%s%s%s" %
(telnetlib.IAC,
telnetlib.SB,
"xterm-color",
Expand Down
4 changes: 2 additions & 2 deletions noobhack/ui/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import fcntl
import curses
import curses
import struct
import termios

Expand Down Expand Up @@ -52,4 +52,4 @@ def size():
"""

raw = fcntl.ioctl(sys.stdin, termios.TIOCGWINSZ, 'SSSS')
return struct.unpack('hh', raw)
return struct.unpack('hh', raw)
2 changes: 1 addition & 1 deletion noobhack/ui/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _write_attrs(self, window, row):
background = colors.get(background, -1)
char_style = [styles.get(s, curses.A_NORMAL) for s in char_style]
attrs = char_style + [get_color(foreground, background)]
window.chgat(row, col, 1, reduce(lambda a, b: a | b, attrs))
window.chgat(row, col, 1, reduce(lambda a, b: a | b, attrs))

def _redraw_row(self, window, row):
"""
Expand Down
Loading