{
  "format": "tokbit",
  "version": 1,
  "name": "Oběšenec s vlastními slovy",
  "main": [
    {
      "id": "u32",
      "kind": "declare",
      "name": "slova",
      "type": "list[str]",
      "init": "[\"PROGRAM\", \"MONITOR\", \"DIAGRAM\", \"CYKLUS\", \"FUNKCE\", \"ROBOT\", \"OBRAZOVKA\", \"INTERNET\", \"TABLET\", \"KONZOLE\", \"KLAVESNICE\", \"MYS\", \"PROMENNA\", \"PODMINKA\", \"TOKBIT\"]"
    },
    {
      "id": "u33",
      "kind": "declare",
      "name": "male",
      "type": "str",
      "init": "\"abcdefghijklmnopqrstuvwxyz\""
    },
    {
      "id": "u34",
      "kind": "declare",
      "name": "velke",
      "type": "str",
      "init": "\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\""
    },
    {
      "id": "u35",
      "kind": "declare",
      "name": "slovo",
      "type": "str",
      "init": "choice(slova)"
    },
    {
      "id": "u36",
      "kind": "declare",
      "name": "zkousena",
      "type": "str",
      "init": "\"\""
    },
    {
      "id": "u37",
      "kind": "declare",
      "name": "zprava",
      "type": "str",
      "init": "\"\""
    },
    {
      "id": "u38",
      "kind": "declare",
      "name": "maska",
      "type": "str",
      "init": "\"\""
    },
    {
      "id": "u39",
      "kind": "declare",
      "name": "p",
      "type": "str",
      "init": "\"\""
    },
    {
      "id": "u40",
      "kind": "declare",
      "name": "chyby",
      "type": "int",
      "init": "0"
    },
    {
      "id": "u41",
      "kind": "declare",
      "name": "uhodnuto",
      "type": "bool",
      "init": "False"
    },
    {
      "id": "u42",
      "kind": "while",
      "condition": "chyby < 7 and not uhodnuto",
      "body": [
        {
          "id": "u43",
          "kind": "call",
          "call": "cls()"
        },
        {
          "id": "u44",
          "kind": "call",
          "call": "color(WHITE)"
        },
        {
          "id": "u45",
          "kind": "call",
          "call": "at(2, 0)"
        },
        {
          "id": "u46",
          "kind": "output",
          "values": "\"OBĚŠENEC\"",
          "newline": false
        },
        {
          "id": "u47",
          "kind": "call",
          "call": "sibenice(chyby)"
        },
        {
          "id": "u48",
          "kind": "assign",
          "target": "maska",
          "value": "\"\""
        },
        {
          "id": "u49",
          "kind": "for",
          "variable": "i",
          "range": "len(slovo)",
          "body": [
            {
              "id": "u50",
              "kind": "if",
              "condition": "slovo[i] in zkousena",
              "then": [
                {
                  "id": "u51",
                  "kind": "assign",
                  "target": "maska",
                  "value": "maska + slovo[i] + \" \""
                }
              ],
              "else": [
                {
                  "id": "u52",
                  "kind": "assign",
                  "target": "maska",
                  "value": "maska + \"_ \""
                }
              ]
            }
          ],
          "comment": "Maska ukáže uhodnutá písmena a místo ostatních podtržítka."
        },
        {
          "id": "u53",
          "kind": "call",
          "call": "color(YELLOW)"
        },
        {
          "id": "u54",
          "kind": "call",
          "call": "at(2, 12)"
        },
        {
          "id": "u55",
          "kind": "output",
          "values": "maska",
          "newline": false
        },
        {
          "id": "u56",
          "kind": "call",
          "call": "color(WHITE)"
        },
        {
          "id": "u57",
          "kind": "call",
          "call": "at(2, 14)"
        },
        {
          "id": "u58",
          "kind": "output",
          "values": "\"Zkoušená: \" + zkousena",
          "newline": false
        },
        {
          "id": "u59",
          "kind": "call",
          "call": "color(LIGHT_RED)"
        },
        {
          "id": "u60",
          "kind": "call",
          "call": "at(2, 16)"
        },
        {
          "id": "u61",
          "kind": "output",
          "values": "zprava",
          "newline": false
        },
        {
          "id": "u62",
          "kind": "call",
          "call": "color(WHITE)"
        },
        {
          "id": "u63",
          "kind": "assign",
          "target": "uhodnuto",
          "value": "\"_\" not in maska"
        },
        {
          "id": "u64",
          "kind": "if",
          "condition": "not uhodnuto",
          "then": [
            {
              "id": "u65",
              "kind": "call",
              "call": "at(2, 18)"
            },
            {
              "id": "u66",
              "kind": "input",
              "target": "p",
              "prompt": "Písmeno:"
            },
            {
              "id": "u67",
              "kind": "if",
              "condition": "len(p) == 1",
              "then": [
                {
                  "id": "u68",
                  "kind": "for",
                  "variable": "i",
                  "range": "26",
                  "body": [
                    {
                      "id": "u69",
                      "kind": "if",
                      "condition": "male[i] == p",
                      "then": [
                        {
                          "id": "u70",
                          "kind": "assign",
                          "target": "p",
                          "value": "velke[i]"
                        }
                      ],
                      "else": []
                    }
                  ]
                }
              ],
              "else": [],
              "comment": "Malé písmeno převede na velké, slova jsou velkými."
            },
            {
              "id": "u71",
              "kind": "if",
              "condition": "len(p) != 1 or p not in velke",
              "then": [
                {
                  "id": "u72",
                  "kind": "assign",
                  "target": "zprava",
                  "value": "\"Zadej jedno písmeno A až Z.\""
                }
              ],
              "else": [
                {
                  "id": "u73",
                  "kind": "if",
                  "condition": "p in zkousena",
                  "then": [
                    {
                      "id": "u74",
                      "kind": "assign",
                      "target": "zprava",
                      "value": "\"Tohle písmeno už jsi zkoušel.\""
                    }
                  ],
                  "else": [
                    {
                      "id": "u75",
                      "kind": "assign",
                      "target": "zkousena",
                      "value": "zkousena + p"
                    },
                    {
                      "id": "u76",
                      "kind": "assign",
                      "target": "zprava",
                      "value": "\"\""
                    },
                    {
                      "id": "u77",
                      "kind": "if",
                      "condition": "p not in slovo",
                      "then": [
                        {
                          "id": "u78",
                          "kind": "assign",
                          "target": "chyby",
                          "value": "chyby + 1"
                        },
                        {
                          "id": "u79",
                          "kind": "call",
                          "call": "beep(196, 150)"
                        }
                      ],
                      "else": [
                        {
                          "id": "u80",
                          "kind": "call",
                          "call": "beep(880, 60)"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "else": []
        }
      ]
    },
    {
      "id": "u81",
      "kind": "if",
      "condition": "uhodnuto",
      "then": [
        {
          "id": "u82",
          "kind": "call",
          "call": "color(LIGHT_GREEN)"
        },
        {
          "id": "u83",
          "kind": "call",
          "call": "at(2, 18)"
        },
        {
          "id": "u84",
          "kind": "output",
          "values": "\"Vyhrál jsi! Slovo je celé.\"",
          "newline": false
        }
      ],
      "else": [
        {
          "id": "u85",
          "kind": "call",
          "call": "cls()"
        },
        {
          "id": "u86",
          "kind": "call",
          "call": "sibenice(7)"
        },
        {
          "id": "u87",
          "kind": "call",
          "call": "color(LIGHT_RED)"
        },
        {
          "id": "u88",
          "kind": "call",
          "call": "at(2, 18)"
        },
        {
          "id": "u89",
          "kind": "output",
          "values": "\"Oběšený! Slovo bylo \" + slovo",
          "newline": false
        }
      ]
    },
    {
      "id": "u90",
      "kind": "call",
      "call": "color(WHITE)"
    },
    {
      "id": "u91",
      "kind": "call",
      "call": "at(0, 20)"
    }
  ],
  "functions": [
    {
      "name": "sibenice",
      "params": [
        {
          "name": "chyby",
          "type": "int"
        }
      ],
      "returnType": null,
      "blocks": [
        {
          "id": "u1",
          "kind": "call",
          "call": "color(ORANGE)"
        },
        {
          "id": "u2",
          "kind": "if",
          "condition": "chyby >= 1",
          "then": [
            {
              "id": "u3",
              "kind": "call",
              "call": "at(2, 9)"
            },
            {
              "id": "u4",
              "kind": "output",
              "values": "\"==========\"",
              "newline": false
            }
          ],
          "else": []
        },
        {
          "id": "u5",
          "kind": "if",
          "condition": "chyby >= 2",
          "then": [
            {
              "id": "u6",
              "kind": "for",
              "variable": "y",
              "range": "2, 9",
              "body": [
                {
                  "id": "u7",
                  "kind": "call",
                  "call": "at(4, y)"
                },
                {
                  "id": "u8",
                  "kind": "output",
                  "values": "\"|\"",
                  "newline": false
                }
              ]
            }
          ],
          "else": []
        },
        {
          "id": "u9",
          "kind": "if",
          "condition": "chyby >= 3",
          "then": [
            {
              "id": "u10",
              "kind": "call",
              "call": "at(4, 1)"
            },
            {
              "id": "u11",
              "kind": "output",
              "values": "\"+-----+\"",
              "newline": false
            }
          ],
          "else": []
        },
        {
          "id": "u12",
          "kind": "if",
          "condition": "chyby >= 4",
          "then": [
            {
              "id": "u13",
              "kind": "call",
              "call": "at(10, 2)"
            },
            {
              "id": "u14",
              "kind": "output",
              "values": "\"|\"",
              "newline": false
            }
          ],
          "else": []
        },
        {
          "id": "u15",
          "kind": "if",
          "condition": "chyby >= 5",
          "then": [
            {
              "id": "u16",
              "kind": "call",
              "call": "at(10, 3)"
            },
            {
              "id": "u17",
              "kind": "output",
              "values": "\"O\"",
              "newline": false
            }
          ],
          "else": []
        },
        {
          "id": "u18",
          "kind": "if",
          "condition": "chyby >= 6",
          "then": [
            {
              "id": "u19",
              "kind": "call",
              "call": "at(10, 4)"
            },
            {
              "id": "u20",
              "kind": "output",
              "values": "\"|\"",
              "newline": false
            },
            {
              "id": "u21",
              "kind": "call",
              "call": "at(10, 5)"
            },
            {
              "id": "u22",
              "kind": "output",
              "values": "\"|\"",
              "newline": false
            }
          ],
          "else": []
        },
        {
          "id": "u23",
          "kind": "if",
          "condition": "chyby >= 7",
          "then": [
            {
              "id": "u24",
              "kind": "call",
              "call": "at(9, 4)"
            },
            {
              "id": "u25",
              "kind": "output",
              "values": "\"/\"",
              "newline": false
            },
            {
              "id": "u26",
              "kind": "call",
              "call": "at(11, 4)"
            },
            {
              "id": "u27",
              "kind": "output",
              "values": "\"\\\\\"",
              "newline": false
            },
            {
              "id": "u28",
              "kind": "call",
              "call": "at(9, 6)"
            },
            {
              "id": "u29",
              "kind": "output",
              "values": "\"/\"",
              "newline": false
            },
            {
              "id": "u30",
              "kind": "call",
              "call": "at(11, 6)"
            },
            {
              "id": "u31",
              "kind": "output",
              "values": "\"\\\\\"",
              "newline": false
            }
          ],
          "else": []
        }
      ],
      "comment": "Nakreslí šibenici podle počtu chyb, každá chyba přidá díl."
    }
  ],
  "comment": "Řešení úlohy „Vlastní slova“: Přidej do seznamu slov pět vlastních. Musí být velkými písmeny a bez háčků a čárek – proč?"
}
