Skip to content
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

Shop module interface and graphics #70

Open
wants to merge 4 commits into
base: main
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
22 changes: 21 additions & 1 deletion ascii.txt
Original file line number Diff line number Diff line change
Expand Up @@ -432,4 +432,24 @@ BREAK_TEXT
█ █
█ █
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█
BREAK_TEXT
BREAK_TEXT
┌─────────────────────────────────────────────────────────────────────────┐
│ | | │
│ |____________| │
│ | $ SHOP $ | │
│ |____________| │
│ │
│ │
│ ( got fish? ) │
│ |/ │
│ /\ __/\ │
│ |  , , | │
│ /` > __x_ )< │
│ /   (>o<) __[$]__ │
│_____ /  \   / ____|_____|_ │
│ │   │ │ │ ------------│_______________________________ │
│ ~--│   │ │ │ │ \ │
│ │ ( \___\_)__) │ │
│ \ __) -----------------| │
│ │
└─────────────────────────────────────────────────────────────────────────┘
2 changes: 1 addition & 1 deletion banker.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ def monopoly_game(client: Client = None, cmd: str = None) -> None:

if __name__ == "__main__":

os.system("cls")
os.system('cls' if os.name == 'nt' else 'clear')
print("Welcome to Terminal Monopoly, Banker!")

set_unittest()
Expand Down
7 changes: 7 additions & 0 deletions error_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,10 @@ Failed to connect to Banker's receiver. [WinError 10061] No connection could be
Failed to connect to Banker's receiver. [WinError 10061] No connection could be made because the target machine actively refused it
Failed to connect to Banker's receiver. [WinError 10061] No connection could be made because the target machine actively refused it
Failed to connect to Banker's receiver. [WinError 10061] No connection could be made because the target machine actively refused it
Failed to connect to Banker's receiver. 'socket' object is not callable
Failed to connect to Banker's receiver. 'socket' object is not callable
Failed to connect to Banker's receiver. 'socket' object is not callable
Failed to connect to Banker's receiver. 'socket' object is not callable
Failed to connect to Banker's receiver. 'socket' object is not callable
Failed to connect to Banker's receiver. 'socket' object is not callable
Failed to connect to Banker's receiver. 'socket' object is not callable
2 changes: 1 addition & 1 deletion modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from modules_directory.tictactoe import destruct_board, construct_board
from socket import socket as Socket
import networking as net
import keyboard

import time

calculator_history_queue = []
Expand Down
17 changes: 14 additions & 3 deletions modules_directory/fishing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import time
import random
from style import get_graphics, set_cursor, set_cursor_str, COLORS
import sys
sys.path.insert(0, '/home/haley/TERMINALMONOPOLY')
from style import get_graphics, set_cursor, set_cursor_str



class fishing_game():
"""
Expand Down Expand Up @@ -46,8 +50,9 @@ def results(self) -> str:
return retval

if __name__ == "__main__":

import os
os.system('cls')
os.system('cls' if os.name == 'nt' else 'clear')
graphics = get_graphics()

pictures = []
Expand All @@ -62,7 +67,7 @@ def results(self) -> str:
start = int(time.time())
delay = random.randint(3,10)
catchtime = start + delay

input()
set_cursor(0,0)
print(pictures[1])
Expand All @@ -77,6 +82,12 @@ def results(self) -> str:
retval += set_cursor_str(37,9) + fish_graphic[0:3]
retval += set_cursor_str(37,10) + fish_graphic[3:6]
retval += set_cursor_str(37,11) + fish_graphic[6:9]







print(retval)

Expand Down
2 changes: 1 addition & 1 deletion modules_directory/tictactoe.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import keyboard


class TicTacToe:
def __init__(self):
Expand Down
104 changes: 104 additions & 0 deletions shop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@


import screenspace as ss
import keyboard
import os
from style import get_graphics, set_cursor, set_cursor_str, COLORS


class FishInventory():
def __init__(self):
self.caughtfish = {"Carp": 1, "Bass": 0, "Salmon": 0}

def getinventory(self):
return self.caughtfish

def addfish(self, fish):
self.caughtfish[fish] += 1
return self.caughtfish

def removefish(self, fish):
self.caughtfish[fish] -= 1
return self.caughtfish

# need function for viewing inventory

testfishinventory = FishInventory()

class Shop():
# TODO : Shop needs to reference the players own inventory
def __init__(self):
self.fishprices = {"Carp": 5, "Bass": 8, "Salmon": 12}
graphics = get_graphics()
self.__shopimages = graphics.copy()
self.__pictures = []
self.__pictures.append(self.__shopimages.pop('shop'))

def display_shop(self, selected_index):
os.system('cls' if os.name == 'nt' else 'clear')
print(self.__pictures[0])
retval = ""
y = 6
retval += set_cursor_str(33, 3) + "=== Welcome to the Shop ==="
retval += set_cursor_str(33, 4) + "Use W/S to navigate and Enter to select."
for i, price in enumerate(self.fishprices.keys()):
if i == selected_index:
retval += set_cursor_str(43, y) + f"> {price}: ${self.fishprices[price]}"
else:
retval += set_cursor_str(43, y) + f" {price}: ${self.fishprices[price]}"
y += 1
y += 1

retval += set_cursor_str(45, y) + "Your inventory: "
for fish in testfishinventory.caughtfish.keys():
if testfishinventory.caughtfish[fish] > 0:
retval += set_cursor_str(45, y+1) + f"{fish} x{testfishinventory.caughtfish[fish]} "

print(retval)

def sellfish(self, fish):
# TODO: implement selling properly


# TODO: update shop screen in response to input
def shop_interface(self):


selected_index = 0
shopping = True
while shopping:
self.display_shop(selected_index)
key = keyboard.read_event()
if key.event_type == "down":
if key.name == "w": # Move up
selected_index = (selected_index - 1) % len(self.fishprices)
elif key.name == "up":
selected_index = (selected_index - 1) % len(self.fishprices)
elif key.name == "s": # Move down
selected_index = (selected_index + 1) % len(self.fishprices)
elif key.name == "down":
selected_index = (selected_index + 1) % len(self.fishprices)
elif key.name == "enter": # Select item
os.system('cls' if os.name == 'nt' else 'clear')
selected_fish = self.fishprices[list(self.fishprices.keys())[selected_index]]


keyboard.read_event()
elif key.name == "q": # Quit shop
shopping = False

os.system('cls' if os.name == 'nt' else 'clear')


def main():
os.system('cls' if os.name == 'nt' else 'clear')
shop = Shop()
shop.shop_interface()



if __name__ == '__main__':
main()



3 changes: 2 additions & 1 deletion style.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def get_graphics() -> dict:
'casino_tie': text[21],
'coin_flip_heads': text[22],
'coin_flip_middle': text[23],
'coin_flip_tails': text[24]
'coin_flip_tails': text[24],
'shop' : text[25]
}
return text_dict

Expand Down