mercredi 11 janvier 2023

How do I get the variable and get it to sort the numbers and print how many passed?

I am somewhat new coding, and tried to make a "macro" of sorts to roll a large amount of dice, and show how many hit, and while I have not got to it yet, apply a modifier if x number was rolled, I am trying to get a variable, "roll dice" for the number from the variable, and then show how many were above a number from another variable.

import random

#whatisneededtoday will be used to bring up other pieces of code that is needed for the        diffrent actions

whatisneededtoday = input('Select an action attack, psychic, charge, unit table.')

#typeofattack will dictate whether a meele attack is going to be made or a ranged attack

if whatisneededtoday [1] == 't':

  typeofattack = input('meele or ranged? ')

  if typeofattack[0] == 'r':

    print(typeofattack)
    bs = input('what is your balistic skill? ')
    print(bs)
    dice = input('how many dice are needed to roll?')
    randomlist = [random.randint(1,6) for i in range (int(dice))]

    for i in randomlist:
      if randomlist[i] >= int(bs):
        print(dice)
    
  
        #if typeofattack[0] == 'm':        
         #print(typeofattack)
        #ws = input('what is your weapon skill? ')
        #print(ws)
        #meelehittingphase = input('how many dice are needed to roll? ')

#if whatisneededtoday [0] == 'p':
  #print ("test psychic")
#if whatisneededtoday [0] == 'c':
  #print("charge test")
#if whatisneededtoday [0] == 'u':
  #print("unit table test")`

I was hoping for it to take the variables dice, "roll" them, and if they are equal or greater then(gettint this from the variable bs) count them as hit, and if they are x number, either add more hits, wound, or do other affects.`




Aucun commentaire:

Enregistrer un commentaire