How to use set_ammo method in yandex-tank

Best Python code snippet using yandex-tank

shotgun.py

Source:shotgun.py Github

copy

Full Screen

...6 self.ammo = 07 self.score = 08 def set_action(self, action):9 self.action = action10 def set_ammo(self, amount):11 self.ammo = amount12 def set_score(self, amount):13 self.score = amount14PLAYER = player()15COMPUTER = player()16def print_pre_game_menu():17 get_input = (18 input(19 '1. Start game\n'20 '2. Rulebook\n'21 '3. Score\n'22 '0. Exit\n'23 'Your choice: '24 )25 )26 try:27 return int(get_input)28 except:29 pass30## prints ammo for player and computer31def print_ammo():32 time.sleep(1)33 print('-' * 15)34 print(f'Your ammo: {PLAYER.ammo}\nComputer\'s ammo: {COMPUTER.ammo}')35 print('-' * 15)36 time.sleep(1)37## Prints winning message38def print_win():39 PLAYER.set_score(PLAYER.score+1)40 time.sleep(1)41 print('-' * 15)42 print('You won the game')43 print('-' * 15)44 time.sleep(1)45## Prints losing message46def print_defeat():47 COMPUTER.set_score(COMPUTER.score+1)48 time.sleep(1)49 print('-' * 15)50 print('You lost the game')51 print('-' * 15)52 time.sleep(1)53## Prints draw message54def print_draw():55 time.sleep(1)56 print('-' * 15)57 print('The game is drawn')58 print('-' * 15)59 time.sleep(1)60"""def print_computer_action(computer_action):61 if computer_action == 1:62 print("Computer is shooting!")63 elif computer_action == 2:64 print("Computer is loading!")65 elif computer_action == 3:66 print("Computer is blocking!")"""67def print_msg(msg):68 time.sleep(1)69 print('-' * 15)70 print(msg)71 print('-' * 15)72 time.sleep(1)73def print_msg_faster(msg2):74 print('-' * 15)75 print(msg2)76 print('-' * 15)77 78## Ends loop and resets players79def end_game():80 global game_is_active81 game_is_active = False82 PLAYER.set_action(0)83 PLAYER.set_ammo(0)84 COMPUTER.set_action(0)85 COMPUTER.set_ammo(0)86#function for shooting, outcome based on computers action87def shoot():88 if COMPUTER.action == 1:89 print_msg_faster('Computer shoots')90 print("Both players shot!")91 PLAYER.set_ammo(PLAYER.ammo-1)92 COMPUTER.set_ammo(COMPUTER.ammo-1)93 elif COMPUTER.action == 2:94 print_msg_faster('Computer loads')95 print_win()96 end_game()97 elif COMPUTER.action == 3:98 print_msg_faster('Computer blocks')99 PLAYER.set_ammo(PLAYER.ammo-1)100 elif COMPUTER.action == 4:101 print_defeat()102 end_game()103#function for blocking, outcome based on computers action104def block(): 105 if COMPUTER.action == 1:106 print_msg_faster('Computer shoots')107 COMPUTER.set_ammo(COMPUTER.ammo-1)108 elif COMPUTER.action == 2:109 print_msg_faster('Computer loads')110 COMPUTER.set_ammo(COMPUTER.ammo+1)111 elif COMPUTER.action == 3:112 print_msg_faster('Computer blocks')113 print("Both players blocked!")114 elif COMPUTER.action == 4:115 print_defeat()116 end_game()117def loading():118 if COMPUTER.action == 1:119 print_msg_faster('Computer shoots')120 print_defeat()121 end_game()122 elif COMPUTER.action == 2:123 print_msg_faster('Computer loads')124 print("Both players loads!")125 COMPUTER.set_ammo(COMPUTER.ammo+1)126 PLAYER.set_ammo(PLAYER.ammo+1)127 elif COMPUTER.action == 3:128 print_msg_faster('Computer blocks')129 PLAYER.set_ammo(PLAYER.ammo+1)130 elif COMPUTER.action == 4:131 print_defeat()132 end_game()133## function for shotgunning134def shotgun():135 if COMPUTER.action == 1:136 print_msg_faster('Computer shoots')137 print("Shotgun beats regular shot!")138 print_win() 139 elif COMPUTER.action == 2:140 print_msg_faster('Computer loads')141 print_win()142 elif COMPUTER.action == 3:143 print_msg_faster('Computer blocks')...

Full Screen

Full Screen

ammo_counter.py

Source:ammo_counter.py Github

copy

Full Screen

...70 if time_idle >= time_to_low_power:71 if time_idle >= time_to_super_low_power:72 if current_brightness != super_low_power_brightness:73 current_brightness = super_low_power_brightness74 set_ammo(current_ammo)75 else:76 if current_brightness != low_power_brightness:77 current_brightness = low_power_brightness78 set_ammo(current_ammo)79 80def wake_up():81 global time_idle82 global current_brightness83 84 time_idle = 085 current_brightness = 186 87def display_number(number):88 first_digit = math.floor(number / 10)89 second_digit = number % 1090 91 digit1.set_digit(first_digit, current_brightness)92 digit2.set_digit(second_digit, current_brightness) 93 94def set_ammo(number):95 global current_ammo96 current_ammo = number97 display_number(current_ammo) 98 99def decrease_ammo():100 wake_up()101 if current_ammo > 0:102 set_ammo(current_ammo -1)103 else:104 set_ammo(current_ammo)105def reset_ammo():106 wake_up()107 set_ammo(ammo_capacity_on_reset)108 109def clear_ammo():110 wake_up()111 set_ammo(0)112 113def magazine_button_check():114 magazine_button.update_button_state()115 if magazine_button.button_just_pressed():116 reset_ammo()117 if magazine_button.button_just_released():118 clear_ammo()119 120def trigger_button_check():121 trigger_button.update_button_state() 122 if trigger_button.button_just_pressed():...

Full Screen

Full Screen

csgo.py

Source:csgo.py Github

copy

Full Screen

...35 base=weapon_manager.ammoprop,36 prop=self.ammoprop,37 )38 )39 def set_ammo(self, value):40 """Set the player's ammo property for the weapon."""41 # Is the weapon not a grenade?42 if 'grenade' not in weapon_manager[self.classname].tags:43 self.primary_ammo_count = value44 return45 player = self._validate_ammo()46 player.set_property_ushort(47 '{base}{prop:03d}'.format(48 base=weapon_manager.ammoprop,49 prop=self.ammoprop,50 ),51 value,52 )53 # Set the "ammo" property methods...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run yandex-tank automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful