dimanche 19 novembre 2017

Is there a method of checking if there is a certain object's set in another?

I want to test if the first number in the one of my sets is also the same as a number in either of two different sets, then do the same for the second, third, etc. If it the first number is the same as the player's set's first number I want to have the player be able to do an action, but if it is the enemy's set's then I want them to go. Is there a way to accomplish that?

Pm1 = input("What is your knight's name?")
Pm2 = input("What is your theif's name?")
Pm3 = input("What is your doctor's name?")
Pm4 = input("What is your priest's name?")
import random
Pm1Order = random.randint(1,8) 
Pm2Order = random.randint(1,8)
if Pm2Order == Pm1Order: 
    Pm2Order = Pm1Order - 1
    if Pm2Order == 0:
        Pm2Order = Pm1Order + 1
Pm3Order = random.randint(1,8) 
if Pm3Order == Pm2Order:
    Pm3Order = Pm1Order - 2
    if Pm3Order == 0:
        Pm3Order = Pm1Order + 2
Pm4Order = random.randint(1,8)
if Pm4Order == Pm3Order:
    Pm4Order = Pm1Order - 3
    if Pm4Order == 0:
        Pm4Order = Pm1Order + 3
print("The turn orders for your party is " +str(Pm1Order)+ " for the knight, " +str(Pm2Order)+ " for the theif, " +str(Pm3Order)+ " for the doctor, and " +str(Pm4Order)+ " for the priest.")
PlayerOrder = set([Pm1Order , Pm2Order , Pm3Order , Pm4Order])
print(str(PlayerOrder))
FullOrder = set([1, 2, 3, 4, 5, 6, 7, 8])
EnemyOrder = FullOrder.difference(PlayerOrder)
EnemyOrder2 = FullOrder.difference(PlayerOrder)
print(str(EnemyOrder))
Enemy1Order = random.sample(EnemyOrder, 1)
Enemy2Order = random.sample(EnemyOrder, 1)
Enemy3Order = random.sample(EnemyOrder, 1)
Enemy4Order = random.sample(EnemyOrder, 1)
print(Enemy1Order)
AllOrder = set([Pm1Order, Pm2Order, Pm3Order, Pm4Order, Enemy1Order, Enemy2Order, Enemy3Order, Enemy4Order])
AllOrder.sort(key = int)
print(AllOrder)
####Test for first element if its player then they go if its enemey they go and 




Aucun commentaire:

Enregistrer un commentaire