repl.it
Python

A pet from python

fork
loading
Files
  • main.py
  • changelog.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Notes:
# - check line 58 and its adjacent lines. Error with 'indentation' without any actual error being there in the first place. Not sure what to do with that, without it the user can't progress past the shop.



import random, replit, time
#import pickle
# i like pickles. (for save/load feature if we implement it)
snakeBought = 0
#            ⬇️ - what does 'sleep' mean?
def welcome(sleep=True):
  print(
      "welcome to...\n _           _   __ ___\n|_/  \/  __ |_/ |__  |   |\n|    |      |   |    |   |\n|    |      |   |__  |   ."
  )
  if sleep:
    time.sleep(1)

welcome()

# ⬇️ some information: Name of pet can only be 8 letters or less so temporary name is 9 letters long. This can't be inputted by the player as a valid name, so we can use it to check if the player is either wanting to name their pet for the first time or rename it. Photo is N/A, will be the photo of the snake (~<:<<<<<>) but I'm hoping on getting more than one pet in here - probably cat, dog, guineau pig, etc. with leveling up features. Inventory will hopefully have more to it such as playthings or care (brushes, washkit, etc).
player_dict = {
    'Name': '123456789',
    'Photo': 'N/A',
    'Age': 5,
    'Weight': 5.5,
    'Hunger': 100,
    'PyDollars': 75,
    'Inventory': {
      'food' : 0,
      'Mfood' : 0
    }
}

def success_message():
  replit.clear()
  print('Transaction Successful!')
  input('Press enter to continue... ')




def shopMarket():
  replit.clear()
  print("- your balance is Py$", player_dict['PyDollars'], "\n")
  if snakeBought == 0:
    print("1- [Snake | Py$25]> ~<:<<<<<>")
  elif snakeBought == 1:
    print("1- [Snake | SOLD OUT] ")
  print("2- [Snake Food (5 pellets) | Py$5]>88o")
  print("3- [Snake Food (25 pellets) | Py$20]>888888888888o")
  print("4- [Mega Snake Food (1 pellet) | Py$5]>õ")
  print("5- [Exit]")
  shopChoice = input("\nWhich item do you wish to buy?\n> ")
  if shopChoice == "1":
    if snakeBought == 1:
      shopMarket()
    elif snakeBought == 0:
      if player_dict['PyDollars'] > 24:
            player_dict['PyDollars'] = player_dict['PyDollars'] - 25
				# ⬇️ This is the issue I'm having. The shop doesn't recognise that you have bought the snake as it doesn't set to 0. Says something about indentation but I'm not sure what it means... It doesn't have to be this, it is usually just the first running code after line 56.
            snakeBought = 1     
				# ⬆️ It might just be a problem with Repl.it or Python malfunctioning. In that case we may have to ask a Repl.it dev about it or someone like that.
            success_message()
            shopMarket()
      else:
        input("\nInvalid funds. Press enter to continue... ")
        shopMarket()
  elif shopChoice =="2":
    if player_dict['PyDollars'] > 4:
      player_dict['PyDollars'] = player_dict['PyDollars'] - 5
      player_dict['Inventory']['food'] = player_dict['Inventory']['food'] +25
      success_message()
      shopMarket()
    else:
      shopMarket()
  elif shopChoice =="3":
    if player_dict['PyDollars'] > 19:
      player_dict['PyDollars'] = player_dict['PyDollars'] - 20
      player_dict['Inventory']['food'] = player_dict['Inventory']['food'] + 25
      success_message()
      shopMarket()
  elif shopChoice =="4":
    if player_dict['PyDollars'] > 4:
      player_dict['PyDollars'] = player_dict['PyDollars'] - 5
      player_dict['Inventory']['Mfood'] = player_dict['Inventory']['Mfood'] + 1
      success_message()
      shopMarket()
  elif shopChoice == "5":
    if snakeBought == 0:
      replit.clear()
      print("You're at the pet store for a reason; get a snake! ")
      input('Press enter to continue... ')
      shopMarket()
    else:
      replit.clear()
      confirmation_choice = input('Are you sure you want to quit the shop? (y/n)\n> ').lower()
      if confirmation_choice == 'n':
        shopMarket()
      else:
        #mainMenu()
        pass
  else:
    input('Invalid choice. Press enter to continue... ')
    shopMarket()


if __name__ == '__main__':
  welcome(sleep=False)
  shopMarket()
?