def rps_fist(): """Fist down event""" global rps_state, rps_rx_enable, rps_choice, rps_score # Number of fist-down events depends on mode: 1-2-3-show, or 1-2-3-4-5-show if spock_mode: choose_state = 5 show_state = 6 else: choose_state = 3 show_state = 4 if rps_state == 0: anim_stop() load_font(DEF8x8, DEF8x8_widths) rps_state += 1 if rps_state < choose_state: display_drv(get_indexed_sym(ord("0") + rps_state)) elif rps_state == choose_state: display_drv(get_indexed_sym(ord("0") + rps_state)) # Choose now! divisor = 820 if spock_mode else 1366 rps_choice = true_random() / divisor rps_score = RPS_WIN # Be optimistic :) # At this point, we will accept other players choices rps_rx_enable = True elif rps_state == show_state: # Done! Play final animation while awaiting stragglers... load_font(Doodads, Doodads_widths) anim_init(rps_await_result_icons, 5, rps_result_anim_done) anim_begin(4) # duration = 50ms * 6 icons * 4 loops = 1.2 sec mcastRpc(1, 1, "rps", rps_choice) else: pass
def dice_anim_done(): """End of 'dice roll' animation is when we actually choose the randomized result""" i = true_random() / 683 # Scale from 0-4095 to range 0-5 anim_show(i)
def reflex_test_begin(): global reflex_t_trigger, reflex_state reflex_t_trigger = 1000 + true_random() # About 1-5 seconds from now reflex_state = REFLEX_ARMED