Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random, platform, os
- def clear():
- operating_system = platform.system()
- if operating_system == "Windows":
- os.system('cls')
- elif operating_system == "Linux":
- os.system('clear')
- else:
- ## Something something Idk what to do with OSx
- print("\n" * 100)
- class ship:
- def __init__(self, rank, controlled):
- ## Set the ship type by randomizing one of the ships of that rank
- rank = int(rank)
- if rank == 0:
- rank = random.randint(1, 5)
- if rank == 1:
- ships = ["Sloop", "Schooner", "Pinnace"]
- elif rank == 2:
- ships = ["Brig", "Brigantine", "Bargue"]
- elif rank == 3:
- ships = ["East Indiaman", "Merchantman", "Trade Galleon"]
- elif rank == 4:
- ships = ["War Galleon", "Frigate"]
- else:
- ships = ["Man o War", "Ship of the Line"]
- self.type = ships[random.randint(0, len(ships)-1)]
- ## Stats
- ## Cannons, health, manuverability.
- ## Cannons deal 2 points of damage per cannonball
- ## Manouverability shows the chance to dodge a cannonball.
- if rank == 1:
- self.cannons = random.randint(10, 20)
- self.cannons_max = 20
- self.health = random.randint(10, 20) + 15*3
- self.health_top = 20 + 15*3
- self.cargo_max = random.randint(30, 50)
- elif rank == 2:
- self.cannons = random.randint(14, 24)
- self.cannons_max = 24
- self.health = random.randint(14, 24) + 19*3
- self.health_top = 24 + 19*3
- self.cargo_max = random.randint(55, 75)
- elif rank == 3:
- self.cannons = random.randint(20, 30)
- self.cannons_max = 30
- self.health = random.randint(20, 30) + 25*3
- self.health_top = 30 + 25*3
- self.cargo_max = random.randint(110, 130)
- elif rank == 4:
- self.cannons = random.randint(27, 37)
- self.cannons_max = 37
- self.health = random.randint(27, 37) + 32*3
- self.health_top = 37 + 32*3
- self.cargo_max = random.randint(75, 95)
- elif rank == 5:
- self.cannons = random.randint(38, 48)
- self.cannons_max = 48
- self.health = random.randint(38, 48) + 43*3
- self.health_top = 48 + 43*3
- self.cargo_max = random.randint(80, 100)
- self.health_max = self.health
- self.manuv = random.randint(20, 35)
- self.manuv_max = 50
- self.rank = rank
- ## controllability - if controlled, randomize country and cargo
- ## otherwise leave empty
- self.rum = 0
- self.food = 0
- self.money = 0
- self.sugar = 0
- self.goods = 0
- if controlled:
- empires = ["Dutch", "English", "Spanish", "French", "Pirate"]
- self.country = empires[random.randint(0, 4)]
- self.food = random.randint(5, 10)
- resource_list = [int(round(self.cargo_max*(1/4))), int(round(self.cargo_max*(1/8))), int(round(self.cargo_max*(1/16))), int(round(self.cargo_max*(1/6))), 0, 0]
- self.rum = resource_list.pop(random.randint(0,len(resource_list)-1))
- self.sugar = resource_list.pop(random.randint(0, len(resource_list)-1))
- self.goods = resource_list.pop(random.randint(0, len(resource_list)-1))
- self.money = rank * 100 + (random.randint(0, 50)*rank)
- else:
- self.food = 20
- self.country = "Pirate"
- self.cargo = self.rum + self.food + self.sugar + self.goods
- ## This bit is here to print out the info of the ship whenever required.
- def info(self, incombat):
- print(self.country + " " + self.type + " - Rank " + str(self.rank))
- print("Cannons: " + str(self.cannons))
- print("Health: [{:20}] {:3}/{:3}".format("=" * int(round((self.health / self.health_max)*20)), str(self.health), str(self.health_max)))
- print("Manouvering: " + str(self.manuv) + "%")
- if not incombat:
- print("\nCargo : " + str(self.cargo) + "/" + str(self.cargo_max))
- print("Food : " + str(self.food))
- print("Rum : " + str(self.rum))
- print("Sugar : " + str(self.sugar))
- print("Goods : " + str(self.goods))
- def info_short(self):
- return self.country + " " + self.type
- ship_group = [ship(0, True), ship(0, True), ship(0, True), ship(0, True), ship(0, True)]
- while True:
- clear()
- for i in range(0, len(ship_group)):
- print(str(i+1) + ") " + ship_group[i].info_short())
- print()
- choice = input("Which ship to inspect>> ")
- try:
- clear()
- ship_group[int(choice)-1].info(False)
- input()
- except:
- input("Invalid input.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement