Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # oryginalne
- def generate(self):
- if config.allow_bonuses==True:
- return "Bonus: OFF"
- config.allow_bonuses == False
- elif config.allow_bonuses==False:
- return "Bonus: ON"
- config.allow_bonuses==True
- # poprawione
- def generate(self):
- if config.allow_bonuses: # rownowazne z uzyciem == True
- config.allow_bonuses = False # pojedynczy znak równości
- return "Bonus: OFF" # `return` jako ostatnia linia
- else: # nie trzeba sprawdzać już czy jest False
- config.allow_bonuses = True
- return "Bonus: ON"
- # inaczej zrobione
- def generate(self):
- # przelaczenie stanu na przeciwny
- config.allow_bonuses = not config.allow_bonuses
- # zwrocenie odpowiedniej wartosci
- # korzystajac ze specjalnej postaci `if/else`
- return "Bonus: ON" if config.allow_bonuses else "Bonus: OFF"
- //////////////////////////////////////////////////
- # oryginal
- def generate(self):
- for event in pygame.event.get():
- if config.allow_bonuses == True and event.type == pygame.K_RETURN:
- return "Bonus: OFF"
- config.allow_bonuses == False
- elif not config.allow_bonuses == False and event.type == pygame.K_RETURN:
- return "Bonus: ON"
- config.allow_bonuses == True
- # poprawione
- def generate(self):
- for event in pygame.event.get():
- if event.type == pygame.K_RETURN: # wyciagniecie wspólnego elementu
- if config.allow_bonuses:
- config.allow_bonuses = False
- return "Bonus: OFF"
- else :
- config.allow_bonuses = True
- return "Bonus: ON"
- # inaczej zrobione
- def generate(self):
- for event in pygame.event.get():
- if event.type == pygame.K_RETURN:
- # przelaczenie stanu na przeciwny
- config.allow_bonuses = not config.allow_bonuses
- # zwrocenie odpowiedniej wartosci
- # korzystajac ze specjalnej postaci `if/else`
- return "Bonus: ON" if config.allow_bonuses else "Bonus: OFF"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement