I am programming in python I was wondering how in games layer the chance of the object to fall out.
Closed due to the fact that the question is too general by the participants Jarvis_J , jfs , Kromster , 0xdb , andreymal Jun 27, '18 at 10:29 .
Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .
|
1 answer
Damn while waiting for an answer, I almost died and even before someone could solve the problem
def zon_itm(self): #определяет тип a=random.randrange(1,1000) if a <= 1000 and a >= 250: return ('обычный') elif a < 250 and a >= 100: return ('редкий') elif a < 100 and a >= 10: return ('эпический') elif a < 10 and a >= 1: return ('легендарный') - Comparisons
a <= 1000anda >= 1can be removed, there is no benefit from them. You can also remove the first comparison in eachelif, they also do not bring anything new, but only complicate the reading of the code. - Enikeyshchik - self in
def zon_itm(self):also not needed (self not used) - this method can be made a function or a static class method. The parentheses in return are also not needed. Range checks are complicated - just poke thata <= значениеto determine value - gil9red - oneHere, look: github.com/gil9red/SimplePyScripts/blob/… - gil9red
- @ gil9red and what does author = 'ipetrash' do this line - MioMelliot
- @ gil9red ?????? - MioMelliot pm
|
x = base * (1 + chance1) * (1 + chance2)- Kromster