Beispiel #1
0
def ac_qrcode(session,dom,id):
  mark = dom.get_mark(id)

  if mark:
    url = atlastk.get_app_url(mark)
    dom.inner(dom.last_child(id), f'<a href="{url}" title="{url}" target="_blank"><img src="https://api.qrserver.com/v1/create-qr-code/?size=125x125&data={url}"/></a>')
    dom.set_mark(id,"")
Beispiel #2
0
def get_rooms():
  xml = atlastk.create_XML("Rooms")

  for id in rooms:
    xml.push_tag("Room")
    xml.put_attribute("id", id)
    xml.put_attribute("URL", atlastk.get_app_url(id))
    xml.put_value(rooms[id]["name"])
    xml.pop_tag()

  return xml
Beispiel #3
0
def new_between_humans(reversi, dom):
    token = str(uuid.uuid4())
    url = atlastk.get_app_url(token)
    dom.inner(
        "qrcode",
        f'<a href="{url}" title="{url}" target="_blank"><img style="margin: auto; width:100%;" src="https://api.qrserver.com/v1/create-qr-code/?size=200x200&data={urllib.parse.quote(url)}"/></a>'
    )
    set_status(dom, "Play or wait for the opponent's move.", "green")
    dom.disableElements(("HideHHStatusSection", "HideHHLinkSection"))
    reversi.init(token=token, board=create(token))
    draw_board(reversi, dom)
Beispiel #4
0
def new_between_humans(user, dom):
    global games

    token = "debug" if debug() else str(uuid.uuid4())

    create_game(token)

    url = atlastk.get_app_url(token)
    dom.inner(
        "qrcode",
        f'<a href="{url}" title="{url}" target="_blank"><img style="margin: auto; width:100%;" src="https://api.qrserver.com/v1/create-qr-code/?size=200x200&data={urllib.parse.quote(url)}&bgcolor=FFB6C1"/></a>'
    )
    dom.disable_element("HideHHLinkSection")

    return user.init(token)
Beispiel #5
0
def ac_create(session,dom):
  global rooms

  name = dom.get_content("Name").strip()

  if not name:
    dom.alert(f"A room name can not be empty!")
  elif any( room["name"] == name for room in rooms.values()):
    dom.alert(f"There is already a room named '{name}'")
  else:
    id = str(uuid.uuid4())
    url = atlastk.get_app_url(id)
    rooms[id]={"name": name, "core": Room()}
    display_rooms(dom)
    dom.set_content("Name", "")

  dom.focus("Name")