repl.it
@gcard03/

Slot-Machine2

Python

No description

fork
loading
Files
  • main.py
  • Game.txt
  • Money1.txt
  • Money2.txt
  • Save1.txt
  • Save2.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
# What is this for? Hello? Dart20? - PDanielY from os import system
# I don't need it now but later in this program
#hi
from subprocess import call
import os
import cmd
import random
import time
dollar=5
money=str(dollar)+"$"
things=[]
x=input("New game? ")
def clear():
  _ = call('clear' if os.name =='posix' else 'cls')
def goto(function):
  start={1:function}
  start[1]()
class main(cmd.Cmd):
  def help_help(self):
    print("This is the help function");
    # print("");
  def help_combat(self):
    print("Combat is not updated in this game")
  def help_save(self):
    print("save command will save the game")
  def help_get():
    print("The get command will informate you about the price of an object and then you decide how much you want to pay.")
  def do_save(self,arg):
    save=open("Save"+str(game)+".txt","w")
    for x in range(0,len(things)):
      if x/2==int(x/2):
        print("x       SAVING")
      else:
        print("+       SAVING")
      save.write(things[x-1]+"\n")
      time.sleep(0.5)
      clear()
    save.close
if x=="yes" or x=="Yes":
  s=open("Game.txt","r")
  for line in s.readline()[0]:
    line=int(line)
    line+=1

  # Where are you doing the documentation for this code?
  # I don't do the documentation anywhere, but I do it myself and like a normal textadventure in python.
  d=open("Game.txt","w")
  d.write(str(line))
  d.close()
  print("Gamenumber=",line)
  game=line
  print("You start with no things and 5$ in your pocket")
else:
  d=input("Gamenumber?")
  game=int(d)
  i= open("Game.txt","r")
  for t in i.readline()[0]:
    game2=int(t)
  if game2>=game:
    g=open("Save"+str(game)+".txt","r")
    m=open("Money"+str(game)+".txt","r")
    dollar=m.readline()[0]
    dollar=int(dollar)
    print("You have "+str(dollar)+"$")
    print("You have these things: ")
    f=0
    for i in g:
      a=""
      try:
        print(g.readline())
        things.append(g.readline())
      except:
        pass
  else:
    print("This game is not updated.\nStarting new game...")
    j=open("Game.txt","r")
    game2+=1
    line=game2
    game=game2
    d=open("Game.txt","w")
    d.write(str(line))
    d.close()
    print("Gamenumber=",line)
    game=line
    goto(main)
u=open("Save"+str(game)+".txt","w")
u.write("")
u.close()
u=open("Money"+str(game)+".txt","w")
u.write(str(dollar))
u.close()
if __name__=="__main__":
  main().cmdloop()
?