Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.66 KB | None | 0 0
  1. # Mining Game (For Python)
  2.  
  3. # Import Modules
  4. import time
  5. import os
  6. from sys import platform
  7. from random import randint
  8.  
  9. # Define Variables
  10. copperOre = 0
  11. aluminiumOre = 0
  12. ironOre = 0
  13. copper = 0
  14. aluminium = 0
  15. iron = 0
  16. compound = 0
  17. resin = 0
  18. tank = 10
  19. uses = 0
  20. foundStructure = 0
  21. fuel = 0
  22. solarPanels = 0
  23. unlockedFuelC = False
  24. unlockedPrint = False
  25. fuelCondBuilt = False
  26. upgraderBuilt = False
  27. smelteryBuilt = False
  28. printerBuilt = False
  29. fuelCondPower = "Empty"
  30. _MAIN = True
  31. menu = "N/A"
  32.  
  33. # Define Functions
  34. if platform == "linux" or platform == "linux2":
  35. clear = lambda: os.system("clear")
  36. elif platform == "darwin":
  37. clear = lambda: os.system("clear && printf '\e[3J'")
  38. elif platform == "win32":
  39. clear = lambda: os.system("cls")
  40.  
  41. def wait(x):
  42. time.sleep(x)
  43.  
  44. # Create sub-menus
  45. def main_mine():
  46. clear()
  47. global compound
  48. global resin
  49. global copperOre
  50. global aluminiumOre
  51. global ironOre
  52. for i in range(0, tank):
  53. compound += randint(1, 10)
  54. resin += randint(1, 10)
  55. copperOre += randint(1, 5)
  56. aluminiumOre += randint(1, 5)
  57. ironOre += randint(1, 5)
  58. print("Material Mined (in total)")
  59. print(" ")
  60. print("Compound: " + str(compound))
  61. print("Resin: " + str(resin))
  62. print("Copper Ore: " + str(copperOre))
  63. print("Aluminium Ore: " + str(aluminiumOre))
  64. print("Iron Ore: " + str(ironOre))
  65. print(" ")
  66. input("Press enter to return... ")
  67. def main_explore():
  68. clear()
  69. discover = 0
  70. global unlockedFuelC
  71. global unlockedPrint
  72. global fuelCondBuilt
  73. global printerBuilt
  74. for i in range(1, tank):
  75. discover = randint(0, 1)
  76. if bool(discover):
  77. print("You found a strange structure.")
  78. menu = input("Explore? (Y/N) ")
  79. if menu == "n":
  80. print("lol bie")
  81. else:
  82. print("You enter the structure.")
  83. print("Outside it looks like a crashes satellite,")
  84. print("But inside it looks like an abandoned spaceship.")
  85. input()
  86. if not unlockedFuelC:
  87. print("You see something that looks like a blueprint")
  88. print("for a machine that produces fuel out of energy.")
  89. menu = input("Examine? (Y/N) ")
  90. if menu == "n":
  91. print("It was probably a trap anyway...")
  92. else:
  93. print("You have picked it up.")
  94. input()
  95. unlockedFuelC = True
  96. print("You have researched and unlocked the Fuel Condenser!")
  97. print("Now, you can add it to your base in the build menu.")
  98. elif not unlockedPrint:
  99. print("You see something that looks like a blueprint")
  100. print("for a machine that looks like a 3D Printer.")
  101. menu = input("Examine? (Y/N) ")
  102. if menu == "n":
  103. print("It was probably a trap anyway...")
  104. else:
  105. print("You have picked it up.")
  106. input()
  107. unlockedPrint = True
  108. print("You have researched and unlocked the Printer!")
  109. print("Now, you can add it to your base in the build menu.")
  110. print(" ")
  111. print("There's nothing left to explore,")
  112. input("Press enter to return to base... ")
  113. else:
  114. print("You didn't find anything of intrest...")
  115. input("Press enter to return... ")
  116. def main_base():
  117. global resin
  118. global unlockedPrint
  119. global unlockedFuelC
  120. global fuelCondBuilt
  121. global upgraderBuilt
  122. global smelteryBuilt
  123. global printerBuilt
  124. _BASE = True
  125. while _BASE:
  126. clear()
  127. print("Your Base")
  128. print(" ")
  129. print("0) Return to Menu")
  130. print("1) Build Menu")
  131. if fuelCondBuilt: print("f) Fuel Condenser")
  132. if upgraderBuilt: print("u) Upgrader")
  133. if smelteryBuilt: print("s) Smeltery")
  134. if printerBuilt: print("p) Printer")
  135. print(" ")
  136. menu = input()
  137. if menu == "0":
  138. _BASE = False
  139. elif menu == "1":
  140. _BUILD = True
  141. while _BUILD:
  142. clear()
  143. print("Build Menu")
  144. print(" ")
  145. print("0) Return to Base")
  146. if not fuelCondBuilt and unlockedFuelC: print("f) Fuel Condenser")
  147. if not printerBuilt and unlockedPrint: print("p) Printer")
  148. if not upgraderBuilt: print("u) Upgrader")
  149. if not smelteryBuilt: print("s) Smeltery")
  150. print(" ")
  151. menu = input()
  152. if menu == "0":
  153. _BUILD = False
  154. elif menu == "f":
  155. if not fuelCondBuilt and unlockedFuelC:
  156. print("Build 'Fuel Condenser' for 50 Resin?")
  157. menu = input("(Y/N) ")
  158. if menu == "y":
  159. if resin >= 50:
  160. print("Building... (10 Seconds)")
  161. wait(10)
  162. resin -= 50
  163. fuelCondBuilt = True
  164. else:
  165. print("Not enough Resin!")
  166. input()
  167. elif menu == "p":
  168. if not printerBuilt and unlockedPrint:
  169. print("Build 'Printer' for 200 Resin?")
  170. menu = input("(Y/N) ")
  171. if menu == "y":
  172. if resin >= 200:
  173. print("Building... (10 Seconds)")
  174. wait(10)
  175. resin -= 200
  176. printerBuilt = True
  177. else:
  178. print("Not enough Resin!")
  179. input()
  180. elif menu == "u":
  181. if not upgraderBuilt:
  182. print("Build 'Upgrader' for 200 Resin?")
  183. menu = input("(Y/N) ")
  184. if menu == "y":
  185. if resin >= 200:
  186. print("Building... (10 Seconds)")
  187. wait(10)
  188. resin -= 200
  189. upgraderBuilt = True
  190. else:
  191. print("Not enough Resin!")
  192. input()
  193. elif menu == "s":
  194. if not smelteryBuilt:
  195. print("Build 'Smeltery' for 100 Resin?")
  196. menu = input("(Y/N) ")
  197. if menu == "y":
  198. if resin >= 100:
  199. print("Building... (10 Seconds)")
  200. wait(10)
  201. resin -= 100
  202. smelteryBuilt = True
  203. else:
  204. print("Not enough Resin!")
  205. input()
  206. elif menu == "f":
  207. if fuelCondBuilt and unlockedFuelC: main_base_fc()
  208. elif menu == "p":
  209. if printerBuilt and unlockedPrint: main_base_pr()
  210. elif menu == "s":
  211. if smelteryBuilt: main_base_sm()
  212. elif menu == "u":
  213. if upgraderBuilt: main_base_up()
  214. def main_base_fc():
  215. global fuel
  216. global solarPanels
  217. global fuelCondPower
  218. _CONDENSER = True
  219. while _CONDENSER:
  220. clear()
  221. print("Fuel Condenser")
  222. print(" ")
  223. if fuelCondPower == "Empty":
  224. print("Container [Empty]")
  225. print(" ")
  226. print("1) Insert Item")
  227. print("2) Collect Fuel")
  228. print("0) Back to Base")
  229. print(" ")
  230. menu = input()
  231. if menu == "0":
  232. _CONDENSER = False
  233. elif menu == "1":
  234. print("Select a Power Source")
  235. print(" ")
  236. print("1) Solar Panel")
  237. print("0) Cancel")
  238. print(" ")
  239. menu = input()
  240. if menu == "0":
  241. print("Operation Canceled")
  242. if menu == "1":
  243. if solarPanels >= 1:
  244. solarPanels -= 1
  245. fuelCondPower = "Solar Panel"
  246. else:
  247. print("You need at least one solar panel!")
  248. input()
  249. elif menu == "2":
  250. print("Please insert an item into the")
  251. print("Fuel Condenser to power it.")
  252. input()
  253. else:
  254. print("Container [" + fuelCondPower + "]")
  255. print(" ")
  256. print("1) Retrieve " + fuelCondPower)
  257. print("2) Collect Fuel")
  258. print("0) Back to Base")
  259. print(" ")
  260. menu = input()
  261. if menu == "0":
  262. _CONDENSER = False
  263. elif menu == "1":
  264. print("Extracting... (3 Seconds)")
  265. wait(3)
  266. if fuelCondPower == "Solar Panel": solarPanels += 1
  267. fuelCondPower = "Empty"
  268. elif menu == "2":
  269. print("Collecting... (5 Seconds)")
  270. wait(5)
  271. fuel += 1
  272. print("Recieved [1x Fuel]")
  273. input()
  274. def main_base_pr():
  275. global solarPanels
  276. global aluminium
  277. _PRINT = True
  278. while _PRINT:
  279. clear()
  280. print("Printer")
  281. print(" ")
  282. print("1) Solar Panel")
  283. print("0) Back to Base")
  284. print(" ")
  285. menu = input()
  286. if menu == "0":
  287. _PRINT = False
  288. if menu == "1":
  289. print("Craft [1x Solar Panel] for 100 aluminium?")
  290. menu = input("(Y/N) ")
  291. if menu == "y":
  292. if aluminium >= 100:
  293. aluminium -= 100
  294. solarPanels += 1
  295. else:
  296. print("Not enough Aluminium!")
  297. input()
  298. def main_base_up():
  299. global compound
  300. global tank
  301. _UPGRADE = True
  302. while _UPGRADE:
  303. clear()
  304. print("Upgrader")
  305. print(" ")
  306. print("1) Upgrade Tank - Longer Mining Sessions")
  307. print("0) Back to Base")
  308. print(" ")
  309. menu = input()
  310. if menu == "0":
  311. _UPGRADE = False
  312. elif menu == "1":
  313. print("Upgrade 'Oxygen Tank' for " + str((tank/2)*10) + " compound?")
  314. menu = input("(Y/N) ")
  315. if menu == "y":
  316. if compound >= (tank/2)*10:
  317. compound -= (tank/2)*10
  318. tank += 10
  319. else:
  320. print("Not enough Compound!")
  321. input()
  322. def main_base_sm():
  323. global copperOre
  324. global aluminiumOre
  325. global ironOre
  326. global copper
  327. global aluminium
  328. global iron
  329. _SMELTERY = True
  330. while _SMELTERY:
  331. clear()
  332. print("Smeltery")
  333. print(" ")
  334. print("0) Back to Base")
  335. print("1) Smelt Copper")
  336. print("2) Smelt Aluminium")
  337. print("3) Smelt Iron")
  338. print(" ")
  339. menu = input()
  340. if menu == "0":
  341. _SMELTERY = False
  342. elif menu == "1":
  343. print("Smelting... (5 seconds)")
  344. wait(5)
  345. copper += copperOre
  346. copperOre = 0
  347. elif menu == "2":
  348. print("Smelting... (5 seconds)")
  349. wait(5)
  350. aluminium += aluminiumOre
  351. aluminiumOre = 0
  352. elif menu == "3":
  353. print("Smelting... (5 seconds)")
  354. wait(5)
  355. iron += ironOre
  356. ironOre = 0
  357. def main_inventory():
  358. clear()
  359. print("Inventory:")
  360. print(" ")
  361. print("Ores")
  362. print("Copper: " + str(copperOre))
  363. print("Aluminium: " + str(aluminiumOre))
  364. print("Iron: " + str(ironOre))
  365. print(" ")
  366. print("Refined Ores")
  367. print("Copper: " + str(copper))
  368. print("Aluminium: " + str(aluminium))
  369. print("Iron: " + str(iron))
  370. print(" ")
  371. print("Materials")
  372. print("Compound: " + str(compound))
  373. print("Resin: " + str(resin))
  374. print(" ")
  375. print("Items")
  376. print("Solar Panels: " + str(solarPanels))
  377. print(" ")
  378. print("Stats")
  379. print("Oxygen Tank: " + str(tank) + "m")
  380. print("Fuel: " + str(fuel) + "l")
  381. print(" ")
  382. input("Press enter to return... ")
  383.  
  384. # Main Process
  385. while _MAIN:
  386. clear()
  387. print("Mining Game")
  388. print(" ")
  389. print("1) Mine")
  390. print("2) Explore")
  391. print("3) Base")
  392. print("4) Inventory")
  393. print(" ")
  394. #print("s) Save Game")
  395. #print("l) Load Saved Game")
  396. #print("d) Delete Saved Game")
  397. #print(" ")
  398. print("0) Exit")
  399. print(" ")
  400. menu = input()
  401. if menu == "0":
  402. _MAIN = False
  403. elif menu == "1":
  404. main_mine()
  405. elif menu == "2":
  406. main_explore()
  407. elif menu == "3":
  408. main_base()
  409. elif menu == "4":
  410. main_inventory()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement