Skip to content

Commit

Permalink
mvp
Browse files Browse the repository at this point in the history
  • Loading branch information
CKjolhede committed Jun 20, 2024
1 parent f508d93 commit 37ad0a2
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 54 deletions.
116 changes: 96 additions & 20 deletions lib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from models.game_space import Game_space
from models.game import Game
from models.__init__ import CONN, CURSOR
from models.setup_helper import (exit_program, exit_program_early, player_home_position, )


player_house_positions = [4, 10, 16, 22]
Expand Down Expand Up @@ -40,6 +41,16 @@ def exit_program():
os.system('clear')
print("Goodbye!")
exit()

def exit_program_early(game, players, homes):
for player in players:
Player.delete(player)
for home in homes:
Game_space.delete(home)
Game.delete(game)
os.system('clear')
print("Goodbye!")
exit()

def new_game_setup_menu():
print("New Game Menu:")
Expand All @@ -66,15 +77,15 @@ def new_game_setup(game):
os.system('clear')
print("That is not a valid input.")
print("Enter the number next to your choice.\n")
time.sleep(2.5)
time.sleep(1)
new_game_setup(game)


def player_setup_menu():
print("Players Menu")
print("1 Add Player")
print("2 See All Players")
print("3 Remove Player") #add home position back into list
print("3 Remove Player")
print("4 Edit Player")
print("5 Return to Game Setup")
print("6 Quit Game")
Expand All @@ -99,15 +110,15 @@ def player_setup(game):
remove_player(game)
elif choice == "4":
os.system('clear')
edit_player(game)
edit_player_menu(game)
elif choice == "5":
os.system('clear')
new_game_setup(game)
elif choice == "6":
players = Player.get_all_players_by_gameid(game.id)
homes = Game_space.get_all_homes_by_gameid(game.id)
os.system('clear')
exit_program(game, players, homes)
exit_program_early(game, players, homes)
else:
os.system('clear')
print("Invalid choice, please select again")
Expand All @@ -119,25 +130,26 @@ def check_num_players(game):
return len(players)

def remove_player(game):
os.system('clear')
players = print_players(game)
print("Enter the number of the player you would like to remove")
print("0 - Back to Player Setup")
choice = input()
value = int(choice) if choice in ["0","1","2","3","4"] else 10
if value > len(players):
os.system('clear')
print("INVALID ENTRY \n")
print("INVALID ENTRY\n")
time.sleep(1)
remove_player(game)
elif value == 0:
os.system('clear')
player_setup(game)
remove_player_home(game, players[(value - 1)])
print(f"{players[(value - 1)].name}'s home has been deleted")
print(f'{players[(value -1)].name} has been deleted')
Player.delete(players[(value - 1)])
print("press ENTER to continue")
input()
os.system('clear')
remove_player(game)

def remove_player_home(game, player):
Expand All @@ -147,12 +159,76 @@ def remove_player_home(game, player):
Game_space.delete(game, player)


def edit_player_menu(game):
players = print_players(game)
print("enter the number of the player you would like to EDIT")
print("0 - Back to Player Setup")
choice = input()
value = int(choice) if choice in ["0","1","2","3","4"] else 10
if value > len(players):
os.system('clear')
print("INVALID ENTRY\n")
time.sleep(1)
edit_player_menu(game)
elif value == 0:
os.system('clear')
player_setup(game)
else:
player = players[(value - 1)]
edit_player(game, player)

def edit_player(game, player):
os.system('clear')
print(f"Enter {player.name}'s new name")
print("Name must be less than 16 characters")
name = input()
if not 0 < len(name) < 16:
os.system('clear')
print("INVALID ENTRY\n")
edit_player(game, player)
else:
os.system('clear')
player.name = name

while True:
print(f"{player.name}, which type of player you would like to be?\n")
print('1 REALTOR = The REALTOR receives 10 percent of all property purchases')
print('2 COP = The COP receives $50 from any player occupying the same space')
print('3 BUILDER = The BUILDER recieves a 20 percent discount on home purchases')
print('4 PILOT = The PILOT can roll an unlimited number of doubles')
value = input()
if value == "1":
player.player_type = "REALTOR"
break
elif value == "2":
player.player_type = "COP"
break
elif value == "3":
player.player_type = "BUILDER"
break
elif value == "4":
player.player_type = "PILOT"
break
else:
os.system('clear')
print("You must choose from the 4 player types\n")
time.sleep(2.5)
player.update()
os.system('clear')
print("Updated Player Info:\n")
print(player)
print(" ")
player_setup(game)

def enter_new_player(game):
print("Enter Your Player's Name (required)")
print("Name must be less than 16 characters")
print("Enter '0' to return to Player Setup")
name = input()
if not 0 < len(name) < 16:
if name == "0":
os.system('clear')
player_setup(game)
elif not 0 < len(name) < 16:
os.system('clear')
print("INVALID ENTRY\n")
enter_new_player(game)
Expand All @@ -166,6 +242,7 @@ def create_player_type(game, name):
print('2 COP = The COP receives $50 from any player occupying the same space')
print('3 BUILDER = The BUILDER recieves a 20 percent discount on home purchases')
print('4 PILOT = The PILOT can roll an unlimited number of doubles')
print('0 Return to Player Setup')
value = input()
if value == "1":
player_type = "REALTOR"
Expand All @@ -175,18 +252,23 @@ def create_player_type(game, name):
player_type = "BUILDER"
elif value == "4":
player_type = "PILOT"
elif value == "0":
os.system('clear')
player_setup(game)
else:
os.system('clear')
print("You must choose from the 4 player types\n")
time.sleep(2.5)
create_player_type(game, name)

player = Player.create(name, player_type, 0, 1800, 1800, game.id)
print(f"Good Luck {player.name}!")
time.sleep(.5)
position = player_home_position.pop()
os.system('clear')
enter_player_home(position, player, game)
set_player(game, name, player_type)

def set_player(game, name, player_type):
player = Player.create(name, player_type, 0, 1800, 1800, game.id)
print(f"Good Luck {player.name}!")
time.sleep(.5)
position = player_home_position.pop()
os.system('clear')
enter_player_home(position, player, game)

def enter_player_home(position, player, game):
print("Each player begins with a home property.\n")
Expand Down Expand Up @@ -248,11 +330,5 @@ def print_players(game):
def start_game(game):
pass

def exit_program_prestart(game):
pass

def edit_player(game):
pass

if __name__ == "__main__":
main()
51 changes: 51 additions & 0 deletions lib/migrate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from models.__init__ import CONN, CURSOR
from models.game import Game
from models.space import Space
from models.player import Player
from models.game_space import Game_space
from sqlite3 import *

def migrate():
Game.drop_table()
Space.drop_table()
Game_space.drop_table()
Player.drop_table()
print("Tables have been dropped")
Game_space.create_table()
Game.create_table()
Space.create_table()
Player.create_table()
print("Tables have been created")

def seed_spaces():
spaces = [('GO', 0, 0, 1, "Game", 1),
('unowned', 60, 30, 2, "Pink", 0),
('unowned', 80, 40, 3, "Pink", 0),
('unowned', 0, 100, 4, "Player", 0),
('unowned', 100, 50, 5, "Lt Blue", 0),
('unowned', 120, 60, 6, "Lt Blue", 0),
('CASINO', 0, 0, 0, "Game", 1),
('unowned', 140, 70, 8, "Purple", 0),
('unowned', 160, 80, 9, "Purple", 0),
('unowned', 0, 100, 10, "Player", 0),
('unowned', 180, 90, 11, "Orange", 0),
('unowned', 200, 100, 12, "Orange", 0),
("Free Spasce", 0, 0, 13, "Game", 1),
("unowned", 220, 110, 14, "Red", 0),
("unowned", 240, 120, 15, "Red", 0),
("unowned", 0, 100, 16, "Player", 0),
('unowned', 260, 130, 17, "Yellow", 0),
("unowned", 280, 140, 18, "Yellow", 0),
("Pay HOA", 0, 200, 19, "Game", 1),
("unowned", 300, 150, 20, "Green", 0),
("unowned", 320, 160, 21, "Green", 0),
("unowned", 0, 100, 22, "Player", 0),
("unowned", 360, 130, 23, "Blue", 0),
("unowned", 400, 200, 24, "Blue", 0)]
for space in spaces:
Space.create(*space)
print("Spaces have successfully seeded")

if __name__ == "__main__":
migrate()
seed_spaces()
23 changes: 0 additions & 23 deletions lib/models/helper.py

This file was deleted.

29 changes: 29 additions & 0 deletions lib/models/setup_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# lib/helper.py
import time
from sqlite3 import *
import os
import random
import ipdb
from models.player import Player
from models.game_space import Game_space
from models.game import Game
from models.__init__ import CONN, CURSOR

player_house_positions = [4, 10, 16, 22]
player_home_position = random.sample(player_house_positions, k=4)

def exit_program():
os.system('clear')
print("Goodbye!")
exit()

def exit_program_early(game, players, homes):
for player in players:
Player.delete(player)
for home in homes:
Game_space.delete(home)
Game.delete(game)
os.system('clear')
print("Goodbye!")
exit()

13 changes: 2 additions & 11 deletions lib/seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,8 @@
from models.game_space import Game_space
from sqlite3 import *

Game.drop_table()
Space.drop_table()
Game_space.drop_table()
Player.drop_table()
print("Tables have been dropped")
#ipdb.set_trace()
Game_space.create_table()
Game.create_table()
Space.create_table()
Player.create_table()
print("Tables have been created")



def seed_spaces():
spaces = [('GO', 0, 0, 1, "Game", 1),
Expand Down

0 comments on commit 37ad0a2

Please sign in to comment.