# ==============================================================================
"""LEAP FROG : implement the LeapFrog puzzle"""
# ==============================================================================
__author__  = "Christophe Schlick modified by Philippe Blasi"
__version__ = "0.0" # skeleton version (for mouse or keyboard interaction)
__date__    = "2022-11-12"
# ------------------------------------------------------------------------------
from ezTK import *
# ------------------------------------------------------------------------------
def main(frog=3):
  """create the main window and pack the widgets"""
  global win
  win = Win(title='LEAP FROG', op=3, click=on_click) # mouse-based version
  #win = Win(title='LEAP FROG', op=3, key=on_key) # keyboard-based version
  # ----------------------------------------------------------------------------
  # TODO (use 1 Frame, (2*frog+1) Bricks, 1 Button)
  # ----------------------------------------------------------------------------
  on_reset(); win.loop() # set initial configuration and start event loop
# ------------------------------------------------------------------------------
def on_reset() -> None:
  """callback function for the 'RESET' button"""
  # TODO (set initial position for all frogs on board)
# ------------------------------------------------------------------------------
def on_click(widget:object, code:str, mods:str) -> None:
  """callback function for all mouse click events"""
  print(widget, widget.master, widget.index, code, mods)
  # TODO (check if mouse click is on a frog, then call 'move' for that frog)
# ------------------------------------------------------------------------------
#def on_key(widget, code, mods):
  #"""callback function for all keyboard events"""
  #print(widget, code, mods)
  # TODO (check if pressed key is valid, then call 'move' for that key)
# ------------------------------------------------------------------------------
def move(n:int) -> None:
  """move frog located at index 'n', after checking if its move is valid"""
  # TODO (check if move is valid, then update corresponding frog position)
# ==============================================================================
if __name__ == '__main__':
  main() # create window with default game parameters: frog=3
  #main(7) # try with 7 frogs per color
# ==============================================================================
