Add autopep8 lint action #2
125 errors
Autopep8 found 125 errors
Annotations
Check failure on line 9 in battleship.py
github-actions / Autopep8
battleship.py#L3-L9
import random
import os
+
class Ship():
"""
Patrol
Check failure on line 71 in battleship.py
github-actions / Autopep8
battleship.py#L28-L71
║»║¤║«║
╚═╩═╩═╝
"""
+
def __init__(self, x: int, y: int, name: str) -> None:
self.x = x
self.y = y
if name == "patrol":
self.icon = "╔═╗╚═╝"
- self.size = (3,2)
+ self.size = (3, 2)
self.name = "Patrol Boat"
self.health = 1
elif name == "submarine":
self.icon = "╔══╦╗╚══╩╝"
- self.size = (5,2)
+ self.size = (5, 2)
self.name = "Submarine"
self.health = 3
elif name == "destroyer":
self.icon = "╔═╦╩╗╣ ╠╣╠╚═╩╦╝"
- self.size = (5,3)
+ self.size = (5, 3)
self.name = "Destroyer"
self.health = 3
elif name == "battleship":
self.icon = "╔╩╩╩╩╗╣╬╬╬╬╠╚╦╦╦╦╝"
- self.size = (6,3)
+ self.size = (6, 3)
self.name = "Battleship"
self.health = 4
elif name == "carrier":
self.icon = "╔═╦═╦═╗║»║¤║«║╚═╩═╩═╝"
- self.size = (7,3)
+ self.size = (7, 3)
self.name = "Aircraft Carrier"
self.health = 5
- else:
+ else:
print("Invalid ship name.")
def in_bounds(self, x, y) -> bool:
return x + self.size[0] <= ss.cols and y + self.size[1] <= ss.rows and x >= 2 and y >= 1
-
+
def __str__(self) -> str:
return self.name
-
+
+
class BattleshipGame():
"""
Battleship Game
Check failure on line 107 in battleship.py
github-actions / Autopep8
battleship.py#L72-L107
Version: 1.0.0
https://en.wikipedia.org/wiki/Battleship_(game)
"""
+
def __init__(self) -> None:
self.board = self.generate_water_and_coords()
self.players = 1
self.player_names = []
self.ships = [[] * self.players]
self.changed_coords = []
- self.gamestate = 'placing ships' # other gamestates are 'p1 turn', 'p2 turn', 'p3 turn', 'p4 turn'
+ # other gamestates are 'p1 turn', 'p2 turn', 'p3 turn', 'p4 turn'
+ self.gamestate = 'placing ships'
def generate_water_and_coords(self) -> str:
texture = ""
texture += s.COLORS.backCOMMUNITY + s.COLORS.BLACK
for x in range(0, ss.cols, 3):
- texture += f"{x} " if x < 10 else f"{x} "
+ texture += f"{x} " if x < 10 else f"{x} "
texture += "\n"
for y in range(1, ss.rows):
texture += s.COLORS.backCOMMUNITY + s.COLORS.BLACK
- texture += (str(y) + (" " if y < 10 else "") if y % 2 == 0 else " ")
+ texture += (str(y) + (" " if y < 10 else "") if y %
+ 2 == 0 else " ")
texture += f"{s.COLORS.backLIGHTBLUE}{s.COLORS.BLUE}"
for _ in range(ss.cols-2):
texture += random.choices(
["░", "▒", "▓"],
- weights=[1, 2, 7], # Adjust weights to create larger pools of dark textures
+ # Adjust weights to create larger pools of dark textures
+ weights=[1, 2, 7],
k=1
)[0]
texture += "\n"
self.board = texture + s.COLORS.RESET
return self.board
- def print_ship(self, sh: Ship, playerNum = 0) -> str:
+ def print_ship(self, sh: Ship, playerNum=0) -> str:
text = s.COLORS.playerColors[playerNum]
for i in range(sh.size[1]):
text += f"{s.set_cursor_str(sh.x+1,sh.y+i+1)}{sh.icon[i*sh.size[0]:(i+1)*sh.size[0]]}\n"
Check failure on line 124 in battleship.py
github-actions / Autopep8
battleship.py#L108-L124
def print_explosion(self, x: int, y: int) -> str:
text = ""
- text += s.set_cursor_str(x,y) + random.choice([s.COLORS.ORANGE, s.COLORS.RED]) + random.choice(["░", "▒", "▓"])
+ text += s.set_cursor_str(x, y) + random.choice(
+ [s.COLORS.ORANGE, s.COLORS.RED]) + random.choice(["░", "▒", "▓"])
return text
def print_miss(self, x: int, y: int) -> str:
text = s.COLORS.LIGHTGRAY
- text += s.set_cursor_str(x,y) + random.choice(["░", "▒", "▓"])
+ text += s.set_cursor_str(x, y) + random.choice(["░", "▒", "▓"])
return text
- def popup(self, message: str, color: str = s.COLORS.WHITE) -> str:
+ def popup(self, message: str, color: str = s.COLORS.WHITE) -> str:
"""
...fill in comment
x and y params should be top left corner of terminal.
Check failure on line 139 in battleship.py
github-actions / Autopep8
battleship.py#L132-L139
if 0 < i < 4:
# Custom text wrapping
p += s.set_cursor_str(27, 5+i) + message[(i-1)*26:(i-1)*26+26]
- return p
+ return p
def get_valid_int(self, prompt):
while True:
Check failure on line 169 in battleship.py
github-actions / Autopep8
battleship.py#L141-L169
value = int(input(prompt))
return value
except ValueError:
- self.popup("Invalid input. Please enter a valid integer.", s.COLORS.RED)
+ self.popup(
+ "Invalid input. Please enter a valid integer.", s.COLORS.RED)
s.set_cursor(0, ss.INPUTLINE)
def is_overlapping(self, x: int, y: int, size: tuple, player_num: int) -> Ship:
for sh in self.ships[player_num]:
if (x < sh.x + sh.size[0] and x + size[0] > sh.x and
- y < sh.y + sh.size[1] and y + size[1] > sh.y):
+ y < sh.y + sh.size[1] and y + size[1] > sh.y):
return sh
return None
- def place_ships(self, current_board:str, player_num:int = 0) -> str:
+ def place_ships(self, current_board: str, player_num: int = 0) -> str:
return_board = current_board
s.set_cursor(0, ss.INPUTLINE)
- ships_to_place = [Ship(-1, -1, "patrol"), Ship(-1, -1, "submarine"), Ship(-1, -1, "destroyer"),
- Ship(-1, -1, "battleship"), Ship(-1, -1, "carrier")]
+ ships_to_place = [Ship(-1, -1, "patrol"), Ship(-1, -1, "submarine"), Ship(-1, -1, "destroyer"),
+ Ship(-1, -1, "battleship"), Ship(-1, -1, "carrier")]
self.ships[player_num].clear()
return_board = self.get_ship_board(player_num)
for ship in ships_to_place:
- while ship.x == -1 :
+ while ship.x == -1:
x = self.get_valid_int(f"Enter x-coordinate for your {ship}: ")
y = self.get_valid_int(f"Enter y-coordinate for your {ship}: ")
-
+
if ship.in_bounds(x, y):
if self.is_overlapping(x, y, ship.size, player_num) == None:
ship.x = x
Check failure on line 196 in battleship.py
github-actions / Autopep8
battleship.py#L173-L196
else:
return self.popup(f"Error! Out of bounds. Max x is {ss.cols-ship.size[0]}. Max y is {ss.rows-ship.size[1]}", s.COLORS.RED)
- return_board = self.get_ship_board(player_num)
+ return_board = self.get_ship_board(player_num)
s.set_cursor(0, ss.INPUTLINE)
-
+
done = input("Does this look good? n for no, anything else for yes.")
if done == 'n':
while done != 'y':
- move = self.get_valid_int(f"Enter a number (0-4) of a ship to remove from the list {[ship.name for ship in self.ships[player_num]]}: ")
+ move = self.get_valid_int(
+ f"Enter a number (0-4) of a ship to remove from the list {[ship.name for ship in self.ships[player_num]]}: ")
if 0 <= move < len(self.ships[player_num]):
self.ships[player_num].pop(move)
return_board = self.get_ship_board(player_num)
s.set_cursor(0, ss.INPUTLINE)
- ship_names = ['patrol', 'submarine', 'destroyer', 'battleship', 'carrier']
+ ship_names = ['patrol', 'submarine',
+ 'destroyer', 'battleship', 'carrier']
new_ship = Ship(-1, -1, ship_names[move])
while new_ship.x == -1:
- x = self.get_valid_int(f"Enter x-coordinate for your {new_ship}: ")
- y = self.get_valid_int(f"Enter y-coordinate for your {new_ship}: ")
-
+ x = self.get_valid_int(
+ f"Enter x-coordinate for your {new_ship}: ")
+ y = self.get_valid_int(
+ f"Enter y-coordinate for your {new_ship}: ")
+
if new_ship.in_bounds(x, y):
if self.is_overlapping(x, y, new_ship.size, player_num) == None:
new_ship.x = x
Check failure on line 211 in battleship.py
github-actions / Autopep8
battleship.py#L199-L211
return self.popup(f"Error! This ship is on another ship. Recall this ship size is {new_ship.size}", s.COLORS.RED)
else:
return self.popup(f"Error! Out of bounds. Max x is {ss.cols-new_ship.size[0]}. Max y is {ss.rows-new_ship.size[1]}", s.COLORS.RED)
- return_board = self.get_ship_board(player_num)
- done = input("Does this look good? y for yes, anything else for no.")
+ return_board = self.get_ship_board(player_num)
+ done = input(
+ "Does this look good? y for yes, anything else for no.")
return return_board
- def get_ship_board(self, player_num:int) -> str:
+ def get_ship_board(self, player_num: int) -> str:
# os.system("cls")
current_board = self.board
for ship in self.ships[player_num]:
Check failure on line 245 in battleship.py
github-actions / Autopep8
battleship.py#L212-L245
return current_board
def attack(self):
- while(len(self.ships) > 0): # not correct final logic, temporary
+ while (len(self.ships) > 0): # not correct final logic, temporary
s.set_cursor(0, ss.INPUTLINE)
x = self.get_valid_int("Enter x-coordinate for your attack: ")
if x < 2 or x > 74:
- self.popup("Error! Out of bounds. Please enter a valid coordinate (2-74) inclusive.", s.COLORS.RED)
+ self.popup(
+ "Error! Out of bounds. Please enter a valid coordinate (2-74) inclusive.", s.COLORS.RED)
continue
y = self.get_valid_int("Enter y-coordinate for your attack: ")
if y < 1 or y > 19:
- self.popup("Error! Out of bounds. Please enter a valid coordinate (1-19) inclusive.", s.COLORS.RED)
+ self.popup(
+ "Error! Out of bounds. Please enter a valid coordinate (1-19) inclusive.", s.COLORS.RED)
continue
- if (x,y) in self.changed_coords:
- self.popup("Error! This coordinate has already been attacked.", s.COLORS.RED)
+ if (x, y) in self.changed_coords:
+ self.popup(
+ "Error! This coordinate has already been attacked.", s.COLORS.RED)
continue
- else:
- self.changed_coords.append((x,y))
+ else:
+ self.changed_coords.append((x, y))
for player_ship_list in self.ships:
for ship in player_ship_list:
- if self.is_overlapping(x, y, (1,1)) == ship:
- self.popup(f"Hit! You hit the {ship.name}!", s.COLORS.dispBLUE)
+ if self.is_overlapping(x, y, (1, 1)) == ship:
+ self.popup(
+ f"Hit! You hit the {ship.name}!", s.COLORS.dispBLUE)
self.board += self.print_explosion(x+1, y+1)
ship.health -= 1
if ship.health == 0:
player_ship_list.remove(ship)
for i in range(ship.size[0]):
for j in range(ship.size[1]):
- self.board += self.print_explosion(ship.x+i+1, ship.y+j+1)
- self.popup(f"You sunk the {ship.name}!", s.COLORS.dispBLUE)
+ self.board += self.print_explosion(
+ ship.x+i+1, ship.y+j+1)
+ self.popup(
+ f"You sunk the {ship.name}!", s.COLORS.dispBLUE)
break
else:
self.popup("Miss!.", s.COLORS.RED)
Check failure on line 256 in battleship.py
github-actions / Autopep8
battleship.py#L246-L256
s.set_cursor(0, ss.INPUTLINE)
input("Press enter to continue.")
print(self.get_board())
-
+
+
def start_game() -> BattleshipGame:
ships = BattleshipGame()
return ships
+
if __name__ == "__main__":
os.system("cls")
Check failure on line 269 in battleship.py
github-actions / Autopep8
battleship.py#L263-L269
# def unittest1():
# ships.p1ships = [Ship(3,10,"patrol"), Ship(12,2,"submarine"), Ship(33,5,"destroyer"), Ship(50,7,"battleship"), Ship(15,9,"carrier")]
- # unittest1()
-
- # ships.attack()
+ # unittest1()
+
+ # ships.attack()
Check failure on line 136 in modules.py
github-actions / Autopep8
modules.py#L4-L136
from socket import socket as Socket
import networking as net
+
def calculator() -> str:
"""A simple calculator module that can perform basic arithmetic operations."""
- #Uses recursion to calculate.
+ # Uses recursion to calculate.
def calculate(equation: str) -> float:
for i in range(0, len(equation)-1):
- if(equation[i] == '+'):
+ if (equation[i] == '+'):
eqLeft = equation[:i]
eqRight = equation[(i+1):]
return calculate(eqLeft) + calculate(eqRight)
-
+
for i in range(0, len(equation)-1):
- if(equation[i] == '-'):
- #Checks for unary operator '-'
- if(i == 0):
+ if (equation[i] == '-'):
+ # Checks for unary operator '-'
+ if (i == 0):
eqLeft = "0"
else:
eqLeft = equation[:i]
eqRight = equation[(i+1):]
return calculate(eqLeft) - calculate(eqRight)
-
+
for i in range(0, len(equation)-1):
- if(equation[i] == '*'):
+ if (equation[i] == '*'):
eqLeft = equation[:i]
eqRight = equation[(i+1):]
return calculate(eqLeft) * calculate(eqRight)
for i in range(0, len(equation)-1):
- if(equation[i] == '/'):
+ if (equation[i] == '/'):
eqLeft = equation[:i]
eqRight = equation[(i+1):]
return calculate(eqLeft)/calculate(eqRight)
-
+
for i in range(0, len(equation)-1):
- if(equation[i] == '%'):
+ if (equation[i] == '%'):
eqLeft = equation[:i]
eqRight = equation[(i+1):]
- return calculate(eqLeft)%calculate(eqRight)
-
+ return calculate(eqLeft) % calculate(eqRight)
+
for i in range(0, len(equation)-1):
- if(equation[i] == '^'):
+ if (equation[i] == '^'):
eqLeft = equation[:i]
eqRight = equation[(i+1):]
return calculate(eqLeft) ** calculate(eqRight)
-
+
return float(equation)
- response = '\nCALCULATOR TERMINAL\n'
+ response = '\nCALCULATOR TERMINAL\n'
digit_result = 0
print("\r", end='')
equation = input(s.COLORS.GREEN)
- if(equation == "e"):
+ if (equation == "e"):
return equation
-
- #Trims unnecessary spaces and pads operators with spaces
+
+ # Trims unnecessary spaces and pads operators with spaces
equation = equation.replace(" ", "")
for op in ['+', '-', '*', '/', '%', '^']:
equation = equation.replace(op, " " + op + " ")
-
- #Removes spaces from negative number
- if(len(equation) > 1 and equation[1] == '-'):
+
+ # Removes spaces from negative number
+ if (len(equation) > 1 and equation[1] == '-'):
equation = "-" + equation[3:]
try:
digit_result = calculate(equation)
except:
return "error"
-
+
responseEQ = f'{equation} = {digit_result}'
- #There are 75 columns for each terminal, making any string longer than 75 characters overflow.
+ # There are 75 columns for each terminal, making any string longer than 75 characters overflow.
numOverflowingChar = len(responseEQ) - 75
lineNumber = 0
wrappedResponse = ""
- while(numOverflowingChar > 0):
- wrappedResponse += responseEQ[(75*lineNumber):(75*(lineNumber + 1))] + '\n'
+ while (numOverflowingChar > 0):
+ wrappedResponse += responseEQ[(75*lineNumber) :(75*(lineNumber + 1))] + '\n'
lineNumber = lineNumber + 1
numOverflowingChar = numOverflowingChar - 75
-
- wrappedResponse += responseEQ[(75*lineNumber):(75*(lineNumber + 1)) + numOverflowingChar] + '\n'
- #response += wrappedResponse
+
+ wrappedResponse += responseEQ[(75*lineNumber) :(75*(lineNumber + 1)) + numOverflowingChar] + '\n'
+ # response += wrappedResponse
print(s.COLORS.RESET, end='')
return wrappedResponse
+
def list_properties() -> str:
"""
Temporary function to list all properties on the board by calling the property list stored in ascii.txt.
Can be reworked to add color and better formatting.
-
+
Parameters: None
Returns: None
"""
ret_val = ""
props = s.get_graphics().get('properties').split('\n')
for prop in props:
- if prop == '':
- ret_val += ' '.center(75) + '\n'
+ if prop == '':
+ ret_val += ' '.center(75) + '\n'
continue
first_word = prop.split()[0]
color = getattr(s.COLORS, first_word.upper(), s.COLORS.RESET)
centered_prop = prop.center(75)
- ret_val +=color+ centered_prop + s.COLORS.RESET + '\n'
+ ret_val += color + centered_prop + s.COLORS.RESET + '\n'
return ret_val
+
def trade():
pass
+
def mortgage():
pass
+
def roll():
pass
+
def gamble():
pass
+
def attack():
pass
+
def stocks():
pass
+
def battleship(server: Socket, gamestate: str) -> str:
net.send_message(server, 'battleship')
+
fishing_game_obj = fishing_game()
+
+
def fishing(gamestate: str) -> tuple[str, str]:
"""
Fishing module handler for player.py. Returns tuple of [visual data, gamestate] both as strings.
Check failure on line 160 in modules.py
github-actions / Autopep8
modules.py#L142-L160
stdIn = fishing_game_obj.get_input()
if stdIn == 'e':
return '', 'e'
- return fishing_game_obj.results(), 'e'
+ return fishing_game_obj.results(), 'e'
case 'e':
- return '', 'start'
+ return '', 'start'
+
def kill() -> str:
return s.get_graphics()['skull']
+
def disable() -> str:
- result = ('X ' * round(ss.cols/2+0.5) + '\n' +
- (' X' * round(ss.cols/2+0.5)) + '\n'
- ) * (ss.rows//2)
+ result = ('X ' * round(ss.cols/2+0.5) + '\n' +
+ (' X' * round(ss.cols/2+0.5)) + '\n'
+ ) * (ss.rows//2)
return result
+
def make_board(board_pieces) -> list[str]:
board = [''] * 35
Check failure on line 167 in modules.py
github-actions / Autopep8
modules.py#L163-L167
if board_pieces[i*80+j] != '\n':
board[i] += (board_pieces[i*80+j])
return board
-
Check failure on line 6 in properties.py
github-actions / Autopep8
properties.py#L1-L6
import style as s
from style import COLORS
+
class Property:
"""
Check failure on line 31 in properties.py
github-actions / Autopep8
properties.py#L24-L31
rentHotel = 0
mortgage = 0
- def __init__(self, num_players:int, name:str, owner:int, position:tuple, color:COLORS, purchasePrice:int, housePrice:int, rent:int, rent1H:int, rent2H:int, rent3H:int, rent4H:int, rentHotel:int,mortgage:int) -> None:
+ def __init__(self, num_players: int, name: str, owner: int, position: tuple, color: COLORS, purchasePrice: int, housePrice: int, rent: int, rent1H: int, rent2H: int, rent3H: int, rent4H: int, rentHotel: int, mortgage: int) -> None:
self.players = list(range(num_players))
self.name = name
self.owner = owner
Check failure on line 48 in properties.py
github-actions / Autopep8
properties.py#L41-L48
self.rent4H = rent4H
self.rentHotel = rentHotel
self.mortgage = mortgage
-
+
def getPrice(self) -> int:
if self.purchasePrice == 0:
return -1
Check failure on line 176 in properties.py
github-actions / Autopep8
properties.py#L172-L176
"Electric Company": (150, 4, 10, -1, -1, 75),
"Water Works": (150, 4, 10, -1, -1, 75)
}
- """
+ """
Check failure on line 5 in monopoly.py
github-actions / Autopep8
monopoly.py#L1-L5
-# Monopoly game is played on Banker's terminal.
+# Monopoly game is played on Banker's terminal.
+from datetime import datetime
import style as s
from style import COLORS
import random
Check failure on line 63 in monopoly.py
github-actions / Autopep8
monopoly.py#L10-L63
from player_class import Player
import screenspace as ss
+
def refresh_board():
"""
Refresh the gameboard\n
"""
print(COLORS.RESET + "\033[0;0H", end="")
print(gameboard)
- for i in range(40):
+ for i in range(40):
# This loop paints the properties on the board with respective color schemes
color = board.locations[i].color
backcolor = board.locations[i].color.replace("38", "48")
- print(COLORS.backBLACK + color + f"\033[{board.locations[i].x};{board.locations[i].y}H{i}" + backcolor + " " * (4 + (1 if i < 10 else 0)))
-
- if(board.locations[i].owner != -1): # If owned
+ print(COLORS.backBLACK + color +
+ f"\033[{board.locations[i].x};{board.locations[i].y}H{i}" + backcolor + " " * (4 + (1 if i < 10 else 0)))
+
+ if (board.locations[i].owner != -1): # If owned
print(end=COLORS.RESET)
color = f"\033[38;5;{board.locations[i].owner+1}m"
- print(f"\033[{board.locations[i].x+2};{board.locations[i].y}H" + color + "▀")
-
- if(board.locations[i].owner == -3): # If community chest
+ print(
+ f"\033[{board.locations[i].x+2};{board.locations[i].y}H" + color + "▀")
+
+ if (board.locations[i].owner == -3): # If community chest
print(end=COLORS.RESET)
- print(f"\033[{board.locations[i].x + 1};{board.locations[i].y}H" + COLORS.COMMUNITY + "█" * 6)
- print(f"\033[{board.locations[i].x + 2};{board.locations[i].y}H" + COLORS.COMMUNITY + "▀" * 6)
-
- if(board.locations[i].owner == -4): # If chance
+ print(f"\033[{board.locations[i].x + 1};{board.locations[i].y}H" +
+ COLORS.COMMUNITY + "█" * 6)
+ print(f"\033[{board.locations[i].x + 2};{board.locations[i].y}H" +
+ COLORS.COMMUNITY + "▀" * 6)
+
+ if (board.locations[i].owner == -4): # If chance
print(end=COLORS.RESET)
- print(f"\033[{board.locations[i].x + 1};{board.locations[i].y}H" + COLORS.CHANCE + "█" * 6)
- print(f"\033[{board.locations[i].x + 2};{board.locations[i].y}H" + COLORS.CHANCE + "▀" * 6)
-
- if(board.locations[i].houses > 0): # If there are houses
+ print(
+ f"\033[{board.locations[i].x + 1};{board.locations[i].y}H" + COLORS.CHANCE + "█" * 6)
+ print(
+ f"\033[{board.locations[i].x + 2};{board.locations[i].y}H" + COLORS.CHANCE + "▀" * 6)
+
+ if (board.locations[i].houses > 0): # If there are houses
print(end=COLORS.RESET)
- print(f"\033[{board.locations[i].x+2};{board.locations[i].y+1}H" + COLORS.GREEN + "▀" * (board.locations[i].houses))
-
- if(board.locations[i].houses == 5): # If there is a hotel
+ print(f"\033[{board.locations[i].x+2};{board.locations[i].y+1}H" +
+ COLORS.GREEN + "▀" * (board.locations[i].houses))
+
+ if (board.locations[i].houses == 5): # If there is a hotel
print(end=COLORS.RESET)
- print(f"\033[{board.locations[i].x+2};{board.locations[i].y+5}H" + COLORS.RED + "▀")
-
- if(board.locations[i].owner == -2): # If mortgaged
+ print(
+ f"\033[{board.locations[i].x+2};{board.locations[i].y+5}H" + COLORS.RED + "▀")
+
+ if (board.locations[i].owner == -2): # If mortgaged
print(end=COLORS.RESET)
- print(f"\033[{board.locations[i].x+2};{board.locations[i].y}H" + COLORS.backLIGHTGRAY + "M")
+ print(f"\033[{board.locations[i].x+2};{board.locations[i].y}H" +
+ COLORS.backLIGHTGRAY + "M")
print(end=COLORS.RESET)
for i in range(num_players):
color = COLORS.playerColors[i]
token = "◙"
- print(color + f"\033[{board.locations[players[i].location].x+1};{board.locations[players[i].location].y+1+i}H{token}")
-
+ print(
+ color + f"\033[{board.locations[players[i].location].x+1};{board.locations[players[i].location].y+1+i}H{token}")
+
print(end=COLORS.RESET)
+
def print_commands():
"""
Check failure on line 74 in monopoly.py
github-actions / Autopep8
monopoly.py#L67-L74
for j in range(len(commandsinfo[i])):
print(f"\033[{34+i};79H" + commandsinfo[i][:j], end="")
+
history = []
+
+
def update_history(message: str):
"""
Update the history\n
Check failure on line 85 in monopoly.py
github-actions / Autopep8
monopoly.py#L75-L85
Split the text into multiple lines (multiple entries to history variable)\n
"""
if "[38;5" in message:
- if(((40 - (len(message) - 9)) * 2) == 0):
- history.append(message[:9] + "─" * ((40 - (len(message) - 9)) // 2) + message[9:] + "─" * ((40 - (len(message) - 9)) // 2))
+ if (((40 - (len(message) - 9)) * 2) == 0):
+ history.append(message[:9] + "─" * ((40 - (len(message) - 9)) //
+ 2) + message[9:] + "─" * ((40 - (len(message) - 9)) // 2))
else:
- history.append(message[:9] + "─" * ((40 - (len(message) - 9)) // 2) + message[9:] + "─" * ((39 - (len(message) - 9)) // 2))
+ history.append(message[:9] + "─" * ((40 - (len(message) - 9)) //
+ 2) + message[9:] + "─" * ((39 - (len(message) - 9)) // 2))
else:
if len(message) > 40:
while len(message) > 40:
Check failure on line 117 in monopoly.py
github-actions / Autopep8
monopoly.py#L86-L117
message = message[40:]
history.append(message + " " * (40 - len(message)))
if len(history) > 31:
- while(len(history) > 31):
+ while (len(history) > 31):
history.pop(0)
refresh_h_and_s()
+
status = []
+
+
def update_status(p: Player, update: str, status: list = status):
"""
Update the status\n
"""
# Property status update (list all properties of player)
status.clear()
- if(update == "properties"):
+ if (update == "properties"):
color = COLORS.playerColors[p.order]
status.append(color + f"{p.name} has properties: " + COLORS.RESET)
for i in range(len(p.properties)):
- status.append(f"{p.properties[i]}: {board.locations[p.properties[i]].name}")
- if(update == "deed"):
+ status.append(
+ f"{p.properties[i]}: {board.locations[p.properties[i]].name}")
+ if (update == "deed"):
propertyid = input("What property to view? Enter property #")
try:
location = board.locations[int(propertyid)]
- if location.owner > -1: # if the location is owned
+ if location.owner > -1: # if the location is owned
color = COLORS.playerColors[location.owner]
- status.append(f"Current owner: " + color + f"Player{location.owner}" + COLORS.RESET)
+ status.append(f"Current owner: " + color +
+ f"Player{location.owner}" + COLORS.RESET)
status.append(f"Houses: {location.houses}")
- if(location.rent != 0): # if location could be owned and is not a utility or railroad
+ if (location.rent != 0): # if location could be owned and is not a utility or railroad
status.append(f"{location.color}=== {location.name} ===")
status.append(f"Purchase Price: {location.purchasePrice}")
status.append(f"Price Per House: {location.housePrice}")
Check failure on line 134 in monopoly.py
github-actions / Autopep8
monopoly.py#L121-L134
status.append(f"Rent w 4 houses: {location.rent4H}")
status.append(f"Rent w hotel: {location.rentHotel}")
status.append(f"Mortgage Value: {location.mortgage}")
- elif (location.owner >= -2 and location.rent == 0): # if is a railroad or utility
+ elif (location.owner >= -2 and location.rent == 0): # if is a railroad or utility
status.append(f"{location.color}=== {location.name} ===")
status.append(f"Purchase Price: {location.purchasePrice}")
- status.append(f"Rent (or mltplr) with 1 owned: {location.rent1H}")
- status.append(f"Rent (or mltplr) with 2 owned: {location.rent2H}")
- status.append(f"Rent with 3 locations owned: {location.rent3H}")
- status.append(f"Rent with 4 locations owned: {location.rent4H}")
+ status.append(
+ f"Rent (or mltplr) with 1 owned: {location.rent1H}")
+ status.append(
+ f"Rent (or mltplr) with 2 owned: {location.rent2H}")
+ status.append(
+ f"Rent with 3 locations owned: {location.rent3H}")
+ status.append(
+ f"Rent with 4 locations owned: {location.rent4H}")
status.append(f"Mortgage Value: {location.mortgage}")
else:
raise ValueError
Check failure on line 143 in monopoly.py
github-actions / Autopep8
monopoly.py#L135-L143
print(f"Invalid input. Please enter a # for a property.")
refresh_h_and_s()
+
border = s.get_graphics().get('history and status')
border = border.split("\n")
+
+
def refresh_h_and_s():
"""
Refresh the history, status, and leaderboard\n