Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. #Author Jordan Lake
  2. #class create_player creates a template to make a player
  3. class Create_player():
  4. #creates a global variable sp = the ascii value of sp/space
  5. global sp
  6. sp = chr(32)
  7. #This function lets you choose what player you are.
  8. def choose_player():
  9. #asks what player you are.
  10. player = input("Which player are you, 001, 011, 111")
  11. print(player)
  12. #returns the value of player
  13. return player
  14.  
  15. #sets up the board for the player
  16. def set_Map():
  17. #asks you for you first row
  18. global row1
  19. row1 = input("Please input your first row, exapmle: 010. a 1 is where your ship is")
  20. #asks you for you second row
  21. global row2
  22. row2 = input("Please input your secon row, exapmle: 010. a 1 is where your ship is")
  23. #asks you for you third row
  24. global row3
  25. row3 = input("Please input your third row, exapmle: 010. a 1 is where your ship is")
  26. print(row1 + sp + row2 + sp + row3)
  27.  
  28. #Creates the class to start actually play the game
  29. class game():
  30. #Set the number of player
  31. def players():
  32. #Creates the global variable amount_of_players
  33. global amount_of_players
  34. #Asks how many players are gonna play and set amount_of_players to the number they input
  35. amount_of_players = input("How many players do you have?")
  36. #Creates the objects that each player needs to play the game
  37. def if_players():
  38. #Calls the player function so you can use the vaiable amount_of_players
  39. game.players()
  40. #Checks to see if the amount of players is 1
  41. if amount_of_players == "1":
  42. #If so print that you need friends to play this game
  43. print("You need friends to play this game.")
  44. #Checks to see if the amount of players is 2
  45. elif amount_of_players == "2":
  46. #Creates objects for the players positions and maps
  47. global player1_position
  48. player1_position = Create_player.choose_player()
  49. global player1_map
  50. player1_map = Create_player.set_Map()
  51. global player2_position
  52. player2_position = Create_player.choose_player()
  53. global player2_map
  54. player2_map = Create_player.set_Map()
  55. #Creates the function used to attack other players
  56. def attack():
  57. #Prints how to attack
  58. print("This is the attack phase of the game. To attack you will be give three rows to place one shot in. A 1 is considered a shot")
  59. #Askes where you want to attack in the first row
  60. global attack_row1
  61. attack_row1 = input("Row one:")
  62. #Askes where you want to attack in the second row
  63. global row2
  64. attack_row2 = input("Row two:")
  65. #Askes where you want to attack in the second row
  66. global row3
  67. attack_row3 = input("Row three:")
  68. def hit_or_miss():
  69. game.attack()
  70. game.if_players()
  71. while amount_of_players == "2":
  72. if attack.attack_row1 == if_players.player1_map.row1:
  73. print("Hit")
  74.  
  75. class main():
  76. game.if_players()
  77.  
  78. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement