templates/jogo.base.html.twig line 1

  1. {% set rota_controler, rota_base, rota_action = '', '', '' %}
  2. {% if rota|length == 3 %}
  3.     {% set rota_controler, rota_base, rota_action = rota[0], rota[1], rota[2] %}
  4. {% elseif rota|length == 4 %}    
  5.     {% set rota_controler, rota_base, rota_action = rota[1], rota[2], rota[3] %}
  6. {% elseif rota|length == 5 %}    
  7.     {% set rota_controler, rota_base, rota_action = rota[1], rota[2], rota[3] %}
  8. {%  endif %}
  9. <!DOCTYPE html>
  10. <html lang="en">
  11. <head>
  12.     <meta charset="UTF-8">
  13.     <title>Jogos de Palavras</title>
  14.     <meta http-equiv="Cache-Control" content="public, no-store">    
  15.     <meta name="viewport" content="initial-scale=1,  maximum-scale=1, user-scalable=no">
  16.     <meta name="mobile-web-app-capable" content="yes">
  17.     <meta name="HandheldFriendly" content="True">
  18.     <link rel="shortcut icon" href="/img/favicon.png" />
  19.     <link rel="stylesheet" href="/css/bootstrap.min.css" >
  20.     <link rel="stylesheet" href="/css/sweetalert2.min.css">
  21.     <link rel="stylesheet" href="/css/style.css">
  22.     <link rel="stylesheet" href="/css/teclado.css?{{ versaoCss }}">    
  23.     <link rel="stylesheet" href="/css/introjs.min.css" />
  24.     
  25.     {% block css %}{% endblock %}
  26.     {% block google_adsense %}{% endblock %} 
  27.     <style>
  28.         
  29.         body {
  30.             font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  31.             padding: 0;
  32.             margin: 0;
  33.             background-color: #ffffff;
  34.         }
  35.         /* animações */
  36.         .tremor {
  37.             animation: tremorAnimation 0.2s infinite;
  38.         }
  39.         /* Animação de tremor */
  40.         @keyframes tremorAnimation {
  41.             0% { transform: translate(0, 0); }
  42.             25% { transform: translate(-2px, -2px); }
  43.             50% { transform: translate(2px, 2px); }
  44.             75% { transform: translate(-2px, 2px); }
  45.             100% { transform: translate(2px, -2px); }
  46.         }
  47.         
  48.         .pulse{
  49.             animation: pulseAnimation 1s infinite;
  50.         }
  51.         /* Animação de tremor */
  52.         @keyframes pulseAnimation {
  53.             0% { transform: scale(1); }
  54.             50% { transform: scale(1.2); }
  55.             100% { transform: scale(1); }
  56.         }        
  57.         
  58.         
  59.         #idDivDica{
  60.             margin-bottom: 1em;
  61.             color: #d5143a;
  62.         }
  63.         
  64.         .help{
  65.             display: none;
  66.             position: fixed;
  67.             z-index: 10000;
  68.             left: 0;
  69.             top: 0;
  70.             width: 100%;
  71.             height: 100%;
  72.             overflow: auto;
  73.             background-color: #0e2a60;
  74.         }
  75.         
  76.         .table{
  77.             font-size: 0.8em;
  78.         }
  79.         
  80.         .odd td{
  81.             
  82.         }
  83.         
  84.         .even td{
  85.             background-color: #efeff9
  86.         }
  87.         
  88.         
  89.         .derrota{
  90.             transform: rotate(180deg);
  91.             filter: grayscale(100%);
  92.         }
  93.         
  94.         .desempenho{
  95.             display: none;
  96.             position: fixed;
  97.             z-index: 9000;
  98.             left: 0;
  99.             top: 0;
  100.             width: 100%;
  101.             height: 100%;
  102.             overflow: auto;
  103.             background-color: #0e2a60;
  104.         }
  105.         
  106.         .desempenho .title{
  107.             padding: 6%;
  108.             color: #fff;
  109.             font-size: 1.2em;
  110.             height: 13%;
  111.         }
  112.         
  113.         .desempenho .title .title1{
  114.             width: 90%;
  115.         }
  116.         
  117.         .desempenho .title .fechar{
  118.             text-align: center;
  119.             width: 10%;
  120.         }
  121.         
  122.         .desempenho .content{
  123.             background-color: #fff;
  124.             padding: 20px;
  125.             border-top-left-radius: 28px;
  126.             width: 100%;
  127.             height: 87%;
  128.             border-top-right-radius: 28px;
  129.         }
  130.         
  131.         .desempenho .content .header{
  132.             display: flex;
  133.             width: 100%;
  134.             font-size: 14px;
  135.             min-height: 10em;
  136.         }
  137.         
  138.         .desempenho .content .header > div{
  139.             width: 33%;
  140.             border-radius: 13px;
  141.             min-height: 8em;
  142.             padding: 10px;
  143.             color: #fff;
  144.         }
  145.         
  146.         .desempenho .content .header > div{
  147.             background-position-x: 85%;
  148.             background-size: 2.5em;
  149.             background-repeat: no-repeat;
  150.             background-position-y: 85%;
  151.         }
  152.         
  153.         .desempenho .content .header > div.mouse{
  154.             background-color: #21c897;
  155.             background-image: url('/img/mouse.png');            
  156.         }
  157.         
  158.         .desempenho .content .header > div.relogio{
  159.             background-color: #0040ff;
  160.             margin: 0 10px;
  161.             background-image: url('/img/relogio2.png');            
  162.         }
  163.         
  164.         .desempenho .content .header > div.dinheiro{
  165.             background-color: #9f8809;
  166.             margin: 0 10px;
  167.             background-image: url('/img/dinheiro.png');            
  168.         }
  169.         
  170.         .desempenho .content .body{
  171.             padding-top: 1em;
  172.             text-align: left;
  173.             width: 100%;
  174.             color: #000;
  175.         }
  176.         
  177.         .desempenho .content .body .card {
  178.             /* Add shadows to create the "card" effect */
  179.             box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
  180.             transition: 0.3s;
  181.             overflow: auto;
  182.         } 
  183.         
  184.         .desempenho .content .body .certoResumo{
  185.             color: #3232a8;
  186.             font-style: italic;            
  187.         }
  188.         
  189.         .desempenho .content .body .erradoResumo{
  190.             color: #dd3737;
  191.             font-style: italic;            
  192.         }
  193.         
  194.         .desempenho .content .body .certo{
  195.             color: #3232a8;
  196.             font-size: 0.8em;
  197.             font-style: italic;
  198.             opacity: 0.8;
  199.         }
  200.         
  201.         .desempenho .content .body .errado{
  202.             color: #dd3737;
  203.             font-size: 0.8em;
  204.             font-style: italic;
  205.             opacity: 0.8;
  206.         }
  207.         
  208.         .desempenho .content .body .container {
  209.           padding: 1em;
  210.         }
  211.         
  212.         /* ************************ */
  213.         .extrato{
  214.             display: none;
  215.             position: fixed;
  216.             z-index: 10000;
  217.             left: 0;
  218.             top: 0;
  219.             width: 100%;
  220.             height: 100%;
  221.             overflow: auto;
  222.             background-color: #0e2a60;
  223.         }
  224.         
  225.         .extrato .title{
  226.             padding: 6%;
  227.             color: #fff;
  228.             font-size: 1.2em;
  229.             height: 13%;
  230.         }
  231.         
  232.         .extrato .title .title1{
  233.             width: 90%;
  234.         }
  235.         
  236.         .extrato .title .fechar{
  237.             text-align: center;
  238.             width: 10%;
  239.         }
  240.         
  241.         .extrato .title .nivel{
  242.             font-size: 0.7em;
  243.         }
  244.         
  245.         .extrato .content{
  246.             background-color: #fff;
  247.             padding: 20px;
  248.             border-top-left-radius: 28px;
  249.             width: 100%;
  250.             height: 87%;
  251.             border-top-right-radius: 28px;
  252.         }
  253.         
  254.         .extrato .content .header{
  255.             display: flex;
  256.             width: 100%;
  257.             font-size: 14px;
  258.             min-height: 10em;
  259.         }
  260.         
  261.         .extrato .content .header > div{
  262.             width: 33%;
  263.             border-radius: 13px;
  264.             min-height: 8em;
  265.             padding: 10px;
  266.             color: #fff;
  267.         }
  268.         
  269.         .extrato .content .header > div{
  270.             background-position-x: 85%;
  271.             background-size: 2.5em;
  272.             background-repeat: no-repeat;
  273.             background-position-y: 85%;
  274.         }
  275.         
  276.         .extrato .content .header > div.mouse{
  277.             background-color: #21c897;
  278.             background-image: url('/img/mouse.png');            
  279.         }
  280.         
  281.         .extrato .content .header > div.relogio{
  282.             background-color: #0040ff;
  283.             margin: 0 10px;
  284.             background-image: url('/img/relogio2.png');            
  285.         }
  286.         
  287.         .extrato .content .header > div.dinheiro{
  288.             background-color: #9f8809;
  289.             margin: 0 10px;
  290.             background-image: url('/img/dinheiro.png');            
  291.         }
  292.         
  293.         .extrato .content .body{
  294.             padding-top: 1em;
  295.             text-align: left;
  296.             width: 100%;
  297.             color: #000;
  298.         }
  299.         
  300.         .extrato .content .body .card {
  301.             /* Add shadows to create the "card" effect */
  302.             box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
  303.             transition: 0.3s;
  304.             overflow: auto;
  305.         } 
  306.         
  307.         .extrato .content .body .certoResumo{
  308.             color: #3232a8;
  309.             font-style: italic;            
  310.         }
  311.         
  312.         .extrato .content .body .erradoResumo{
  313.             color: #dd3737;
  314.             font-style: italic;            
  315.         }
  316.         
  317.         .extrato .content .body .certo{
  318.             color: #3232a8;
  319.             font-size: 0.8em;
  320.             font-style: italic;
  321.             opacity: 0.8;
  322.         }
  323.         
  324.         .extrato .content .body .errado{
  325.             color: #dd3737;
  326.             font-size: 0.8em;
  327.             font-style: italic;
  328.             opacity: 0.8;
  329.         }
  330.         
  331.         .extrato .content .body .container {
  332.           padding: 1em;
  333.         }
  334.         
  335.         
  336.         .btnAssistirVideo.btnAssistirVideoDisabled{
  337.             opacity: 0.5
  338.         }
  339.         
  340.     </style>
  341. </head>
  342. <body>
  343.     {% if rota_controler == "jogos"%}
  344.         <!-- navbar -->
  345.     <div class="navbar">
  346.             <div class="container">
  347.                 <div class="site-title">
  348.                     <a href="/"><h1>Jogos de palavras</h1></a>
  349.                 </div>                
  350.             </div>
  351.     </div>
  352.     <!-- end navbar -->
  353.         
  354.             <div class="register app-pages">
  355.                 <div class="container" id="idDivContainer">
  356.                     
  357.                     <!-- cabeçalho -->
  358.                     <div id="idDivCabecalho" class="row col-12 text-center" style="font-size: 1.2rem; margin-top: 1em; color: #000">
  359.                         <div class="col-3 p-0 text-center" id="idDivInfoMoedas"></div>
  360.                         <div class="col-6 p-0 text-center" id="idDivInfoNivel"></div>
  361.                         <div class="col-3 p-0" style="text-align: right" id="idDivInfoAjuda">
  362.                             <span onclick="jogo.callbackQuestion()" class="questionTop"><span>?</span></span>
  363.                         </div>
  364.                     </div>
  365.                     
  366.                     <!-- div do jogo -->
  367.                     <div id="idDivJogo" style="margin:10px; overflow: hidden;" >
  368.                         <div id="idDivTabuleiro" style="margin-top: 0.2em;" class="col-lg-12 text-center" ></div>
  369.                     </div>
  370.                     
  371.                     <!-- div dos botoes, dicas e teclado -->
  372.                     <div id="idDivBottom" style="bottom: 0;width: 100%;height: 17.6rem;position: fixed;">        
  373.                         <table id="clsCtrlDicas" style="visibility: hidden;width: 98%;margin-left: 1%; margin-bottom: 0.3rem">
  374.                             <tr>
  375.                             <td class="btnBackMapa">
  376.                                 <svg xmlns="https://www.w3.org/2000/svg" height="2em" viewBox="0 0 512 512">
  377.                                 <!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. -->
  378.                                 <style>svg{fill:#0e2a60}</style>
  379.                                     <path d="M512 256A256 256 0 1 0 0 256a256 256 0 1 0 512 0zM271 135c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-87 87 87 87c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0L167 273c-9.4-9.4-9.4-24.6 0-33.9L271 135z"/>
  380.                                 </svg>
  381.                             </td>
  382.                             <td style="text-align:center; font-size:1em;letter-spacing: 2px;" id="idDivDicasOuPalavras">DICAS</td>
  383.                             <td class="btnNextMapa">
  384.                                 <svg xmlns="https://www.w3.org/2000/svg" height="2em" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><style>svg{fill:#0e2a60}</style><path d="M0 256a256 256 0 1 0 512 0A256 256 0 1 0 0 256zM241 377c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l87-87-87-87c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0L345 239c9.4 9.4 9.4 24.6 0 33.9L241 377z"/></svg>
  385.                             </td>
  386.                             </tr>
  387.                         </table>
  388.                         <div id="idDivDica"></div>
  389.                         <div id="idDivTeclado" style="text-align: center;position: absolute;bottom: 1em;width: 100%;"></div>
  390.                     </div>
  391.                 
  392.                     
  393.     {% else %}
  394.         <!-- cabeçalho -->
  395.         <div id="idDivCabecalho" class="row col-12 text-center" style="font-size: 1.2rem; margin-top: 1em; color: #000">
  396.             <div class="col-3 p-0 text-center" id="idDivInfoMoedas"></div>
  397.             <div class="col-6 p-0 text-center" id="idDivInfoNivel"></div>
  398.             <div class="col-3 p-0" style="text-align: right" id="idDivInfoAjuda">
  399.                 <span onclick="jogo.callbackQuestion()" class="questionTop"><span>?</span></span>
  400.             </div>
  401.         </div>
  402.             
  403.         <!-- div do jogo -->
  404.         <div id="idDivJogo" style="margin:10px; overflow: hidden;" >
  405.             <div id="idDivTabuleiro" style="margin-top: 0.2em;" class="col-lg-12 text-center" ></div>
  406.         </div>
  407.             
  408.         <!-- div dos botoes, dicas e teclado -->
  409.         <div id="idDivBottom" style="bottom: 0;width: 100%;height: 15.6rem;position: fixed;">
  410.         
  411.             <table id="clsCtrlDicas" style="visibility: hidden;width: 98%;margin-left: 1%; margin-bottom: 0.3rem">
  412.                 <tr>
  413.                 <td class="btnBackMapa">
  414.                     <svg xmlns="https://www.w3.org/2000/svg" height="2em" viewBox="0 0 512 512">
  415.                     <!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. -->
  416.                     <style>svg{fill:#0e2a60}</style>
  417.                         <path d="M512 256A256 256 0 1 0 0 256a256 256 0 1 0 512 0zM271 135c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-87 87 87 87c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0L167 273c-9.4-9.4-9.4-24.6 0-33.9L271 135z"/>
  418.                     </svg>
  419.                 </td>
  420.                 <td style="text-align:center; font-size:1em;letter-spacing: 2px;" id="idDivDicasOuPalavras">DICAS</td>
  421.                 <td class="btnNextMapa">
  422.                     <svg xmlns="https://www.w3.org/2000/svg" height="2em" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><style>svg{fill:#0e2a60}</style><path d="M0 256a256 256 0 1 0 512 0A256 256 0 1 0 0 256zM241 377c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l87-87-87-87c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0L345 239c9.4 9.4 9.4 24.6 0 33.9L241 377z"/></svg>
  423.                 </td>
  424.                 </tr>
  425.             </table>
  426.             <div id="idDivDica"></div>
  427.             <div id="idDivTeclado" style="text-align: center;position: absolute;bottom: 1em;width: 100%;"></div>
  428.         </div>
  429.     
  430.     {% endif %}
  431.     
  432.     
  433.     <div class="extrato">
  434.         <div class="title">
  435.             <div style="display: flex;">
  436.                 <div class="title1"></div>
  437.                 <div class="fechar" onclick="jogo.btnShowHideExtrato();">
  438.                     <span style="border: 1px solid;border-radius: 100px;padding: 0 6px;">X</span>
  439.                 </div>
  440.             </div>
  441.             <div class="nivel"></div>
  442.         </div>
  443.         <div class="content" id="idDivPosContentExtrato" style="overflow: auto">
  444.             <div class="header">
  445.                 <div class="mouse">
  446.                     <div>Clicks no teclado</div>
  447.                     <div></div>
  448.                 </div>
  449.                 <div class="relogio">
  450.                     <div>Tempo</div>
  451.                     <div></div>
  452.                 </div>
  453.                 <div class="dinheiro">
  454.                     <div>Saldo</div>
  455.                     <div></div>
  456.                 </div>
  457.             </div>
  458.             <div class="body" id="idDivPosBodyExtrato">
  459.                 <div style="margin: 1em 0em;" id="idDivPosBodyRelatorio">Extrato</div>
  460.                 <div class="card">
  461.                     <div class="container">
  462.                         <p>&nbsp;</p>
  463.                         <p>&nbsp;</p>                        
  464.                         <p>&nbsp;</p>                        
  465.                     </div>
  466.                 </div> 
  467.                 <div style="margin: 1em 0em;" id="idDivPosBodyResumo">Resumo</div>
  468.                 <div class="card">
  469.                     <div class="container">
  470.                         <p>&nbsp;</p>
  471.                     </div>
  472.                 </div> 
  473.                 <p>&nbsp;</p>
  474.                 <p>&nbsp;</p>
  475.             </div>            
  476.         </div>
  477.     </div>
  478.     
  479.     <div class="desempenho">
  480.         <div class="title">
  481.             <div style="display: flex;">
  482.                 <div class="title1">
  483.                     Desempenho no jogo 
  484.                     <span id="idTitle1NomeJogo"></span>
  485.                 </div>
  486.                 <div class="fechar" onclick="jogo.btnShowHideDesempenho();">
  487.                     <span style="border: 1px solid;border-radius: 100px;padding: 0 6px;">X</span>
  488.                 </div>
  489.             </div>
  490.             <div class="nivel"></div>
  491.         </div>
  492.         <div class="content" id="idDivPosContentDesempenho" style="overflow: auto">
  493.             <div class="body" id="idDivPosBodyDesempenho">
  494.                 <ul class="nav nav-tabs" id="myTab" role="tablist">
  495.                     <li class="nav-item">
  496.                         <a class="nav-link active" id="tabHome" data-toggle="tab" href="#" role="tab" aria-controls="home" aria-selected="true">Geral</a>
  497.                     </li>
  498.                     <li class="nav-item">
  499.                         <a class="nav-link" id="tabNivel" data-toggle="tab" href="#" role="tab" aria-controls="nivel" aria-selected="false">Por nível</a>
  500.                     </li>
  501.                     <li class="nav-item">
  502.                         <a class="nav-link" id="tabTabela" data-toggle="tab" href="#" role="tab" aria-controls="tabela" aria-selected="false">Histórico</a>
  503.                     </li>
  504.                 </ul>
  505.                 <div class="tab-content" id="myTabContent">
  506.                     <div class="tab-pane tabHome" role="tabpanel" aria-labelledby="home-tab">
  507.                         <div class="card mb-3" style="padding: 1em">
  508.                             <div id="divGeralTotais"></div>
  509.                         </div>
  510.                         
  511.                         <div id="divGeralChartVerticalCard" class="card mb-3" style="padding: 1em; display: none">
  512.                             <div id="divGeralChartVertical" style="width: 100%; height: 34vh"></div>
  513.                         </div>
  514.                         
  515.                         <div id="divGeralChartHorizontalCard" class="card mb-3" style="padding: 1em; display: none">
  516.                             <div id="divGeralChartHorizontal" style="width: 100%; height: 34vh;"></div>
  517.                         </div>
  518.                         
  519.                         <div id="divGeralChartTempoCard" class="card mb-3" style="padding: 1em; display: none;">
  520.                             <div id="divGeralChartTempo" style="width: 100%; height: 34vh;"></div>
  521.                         </div>
  522.                         <br /><br /><br />                        
  523.                     </div>
  524.                     
  525.                     <div class="tab-pane tabNivel" role="tabpanel" aria-labelledby="nivel-tab">
  526.                         <div class="card nivel1" style="padding: 1em; margin-bottom: 1em">
  527.                             <div class="card-header"></div>
  528.                             <div class="card-body" id="chartNivel1" style="width: 100%; height: 34vh;"></div>
  529.                         </div> 
  530.                         <div class="card nivel2" style="padding: 1em; margin-bottom: 1em">
  531.                             <div class="card-header"></div>
  532.                             <div class="card-body" id="chartNivel2" style="width: 100%; height: 34vh;"></div>
  533.                         </div> 
  534.                         <div class="card nivel3" style="padding: 1em; margin-bottom: 1em">
  535.                             <div class="card-header"></div>
  536.                             <div class="card-body" id="chartNivel3" style="width: 100%; height: 34vh;"></div>
  537.                         </div> 
  538.                         <div class="card nivel4" style="padding: 1em; margin-bottom: 1em">
  539.                             <div class="card-header"></div>
  540.                             <div class="card-body" id="chartNivel4" style="width: 100%; height: 34vh;"></div>
  541.                         </div> 
  542.                         <div class="card nivel5" style="padding: 1em; margin-bottom: 1em">
  543.                             <div class="card-header"></div>
  544.                             <div class="card-body" id="chartNivel5" style="width: 100%; height: 34vh;"></div>
  545.                         </div> 
  546.                         <br /><br /><br />
  547.                     </div>
  548.                     
  549.                     <div class="tab-pane tabTabela" role="tabpanel" aria-labelledby="tabela-tab">
  550.                         <div class="card" style="margin-top: 1em">
  551.                             <div id="divTabelaHistorico"></div>
  552.                         </div> 
  553.                         <br /><br /><br />
  554.                         <div id="divTabelaHistoricoVersao" class="card mb-3" style="padding: 1em;">
  555.                             <p style="text-align: center;font-size: 10px;">Versão {{ versaoApp }}</p>
  556.                         </div>
  557.                     </div>
  558.                 </div>                
  559.             </div>            
  560.         </div>        
  561.     </div>
  562.     
  563.     
  564.     {% if rota_controler == "jogos"%}
  565.                 <br><br><br><br>
  566.             </div>
  567.         </div>
  568.         
  569.     
  570.     <!-- footer -->
  571.     <footer>
  572.             <div class="ft-bottom">
  573.                 <span><a href="/" style="color: #fff;margin-left: 1em;margin-right: 1em;">Jogos de Palavras</a></span>
  574.                 <span><a href="mailto:suporte@jogosdepalavras.com.br" style="color: #fff;">suporte@jogosdepalavras.com.br</a></span><br>
  575.                 <span>Copyright © 2023 All Rights Reserved </span>
  576.                 <span> <a href="/about" style="color: #fff;margin-left: 1em;margin-right: 1em;">Sobre </a></span>
  577.                 <span> <a href="/politica-privacidade" style="color: #fff;">Política de privacidade</a> </span>
  578.             </div>
  579.     </footer>
  580.     {% endif %}
  581.     
  582. </body>
  583.     
  584. <!-- script -->
  585. <script src="/js/teclado.js?{{ versaoJs }}"></script>
  586. <script src="/js/jquery.min.js"></script>
  587. <script src="/js/bootstrap.min.js"></script>
  588. <script src="/js/sweetalert2.js"></script>
  589. <script src="/js/amcharts5/index.js"></script>
  590. <script src="/js/amcharts5/percent.js"></script>
  591. <script src="/js/amcharts5/xy.js"></script>
  592. <script src="/js/amcharts5/themes/Animated.js"></script>
  593. <script src="/js/introjs.min.js" ></script>
  594. <script>
  595.     var faVideo = '<svg xmlns="http://www.w3.org/2000/svg"  height="16" width="18" viewBox="0 0 576 512"><path fill="#ffffff" d="M0 128C0 92.7 28.7 64 64 64H320c35.3 0 64 28.7 64 64V384c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V128zM559.1 99.8c10.4 5.6 16.9 16.4 16.9 28.2V384c0 11.8-6.5 22.6-16.9 28.2s-23 5-32.9-1.6l-96-64L416 337.1V320 192 174.9l14.2-9.5 96-64c9.8-6.5 22.4-7.2 32.9-1.6z"/></svg>';
  596.     var faVideoYellow = '<svg xmlns="http://www.w3.org/2000/svg" style="width: 33%;" viewBox="0 0 576 512"><path fill="#ffc107" d="M0 128C0 92.7 28.7 64 64 64H320c35.3 0 64 28.7 64 64V384c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V128zM559.1 99.8c10.4 5.6 16.9 16.4 16.9 28.2V384c0 11.8-6.5 22.6-16.9 28.2s-23 5-32.9-1.6l-96-64L416 337.1V320 192 174.9l14.2-9.5 96-64c9.8-6.5 22.4-7.2 32.9-1.6z"/></svg>';
  597.     var faChartLine = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 512 512"><path fill="#ffffff" d="M64 64c0-17.7-14.3-32-32-32S0 46.3 0 64V400c0 44.2 35.8 80 80 80H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H80c-8.8 0-16-7.2-16-16V64zm406.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L320 210.7l-57.4-57.4c-12.5-12.5-32.8-12.5-45.3 0l-112 112c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L240 221.3l57.4 57.4c12.5 12.5 32.8 12.5 45.3 0l128-128z"/></svg>';
  598.     var faRotate = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 512 512"><path fill="#ffffff" d="M142.9 142.9c62.2-62.2 162.7-62.5 225.3-1L327 183c-6.9 6.9-8.9 17.2-5.2 26.2s12.5 14.8 22.2 14.8H463.5c0 0 0 0 0 0H472c13.3 0 24-10.7 24-24V72c0-9.7-5.8-18.5-14.8-22.2s-19.3-1.7-26.2 5.2L413.4 96.6c-87.6-86.5-228.7-86.2-315.8 1C73.2 122 55.6 150.7 44.8 181.4c-5.9 16.7 2.9 34.9 19.5 40.8s34.9-2.9 40.8-19.5c7.7-21.8 20.2-42.3 37.8-59.8zM16 312v7.6 .7V440c0 9.7 5.8 18.5 14.8 22.2s19.3 1.7 26.2-5.2l41.6-41.6c87.6 86.5 228.7 86.2 315.8-1c24.4-24.4 42.1-53.1 52.9-83.7c5.9-16.7-2.9-34.9-19.5-40.8s-34.9 2.9-40.8 19.5c-7.7 21.8-20.2 42.3-37.8 59.8c-62.2 62.2-162.7 62.5-225.3 1L185 329c6.9-6.9 8.9-17.2 5.2-26.2s-12.5-14.8-22.2-14.8H48.4h-.7H40c-13.3 0-24 10.7-24 24z"/></svg>';
  599.     var faPenToSquare = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="16" viewBox="0 0 512 512"><path fill="#ffffff" d="M471.6 21.7c-21.9-21.9-57.3-21.9-79.2 0L362.3 51.7l97.9 97.9 30.1-30.1c21.9-21.9 21.9-57.3 0-79.2L471.6 21.7zm-299.2 220c-6.1 6.1-10.8 13.6-13.5 21.9l-29.6 88.8c-2.9 8.6-.6 18.1 5.8 24.6s15.9 8.7 24.6 5.8l88.8-29.6c8.2-2.7 15.7-7.4 21.9-13.5L437.7 172.3 339.7 74.3 172.4 241.7zM96 64C43 64 0 107 0 160V416c0 53 43 96 96 96H352c53 0 96-43 96-96V320c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7-14.3 32-32 32H96c-17.7 0-32-14.3-32-32V160c0-17.7 14.3-32 32-32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H96z"/></svg>';
  600.     var faGears = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="20" viewBox="0 0 640 512"><path fill="#ffffff" d="M308.5 135.3c7.1-6.3 9.9-16.2 6.2-25c-2.3-5.3-4.8-10.5-7.6-15.5L304 89.4c-3-5-6.3-9.9-9.8-14.6c-5.7-7.6-15.7-10.1-24.7-7.1l-28.2 9.3c-10.7-8.8-23-16-36.2-20.9L199 27.1c-1.9-9.3-9.1-16.7-18.5-17.8C173.9 8.4 167.2 8 160.4 8h-.7c-6.8 0-13.5 .4-20.1 1.2c-9.4 1.1-16.6 8.6-18.5 17.8L115 56.1c-13.3 5-25.5 12.1-36.2 20.9L50.5 67.8c-9-3-19-.5-24.7 7.1c-3.5 4.7-6.8 9.6-9.9 14.6l-3 5.3c-2.8 5-5.3 10.2-7.6 15.6c-3.7 8.7-.9 18.6 6.2 25l22.2 19.8C32.6 161.9 32 168.9 32 176s.6 14.1 1.7 20.9L11.5 216.7c-7.1 6.3-9.9 16.2-6.2 25c2.3 5.3 4.8 10.5 7.6 15.6l3 5.2c3 5.1 6.3 9.9 9.9 14.6c5.7 7.6 15.7 10.1 24.7 7.1l28.2-9.3c10.7 8.8 23 16 36.2 20.9l6.1 29.1c1.9 9.3 9.1 16.7 18.5 17.8c6.7 .8 13.5 1.2 20.4 1.2s13.7-.4 20.4-1.2c9.4-1.1 16.6-8.6 18.5-17.8l6.1-29.1c13.3-5 25.5-12.1 36.2-20.9l28.2 9.3c9 3 19 .5 24.7-7.1c3.5-4.7 6.8-9.5 9.8-14.6l3.1-5.4c2.8-5 5.3-10.2 7.6-15.5c3.7-8.7 .9-18.6-6.2-25l-22.2-19.8c1.1-6.8 1.7-13.8 1.7-20.9s-.6-14.1-1.7-20.9l22.2-19.8zM112 176a48 48 0 1 1 96 0 48 48 0 1 1 -96 0zM504.7 500.5c6.3 7.1 16.2 9.9 25 6.2c5.3-2.3 10.5-4.8 15.5-7.6l5.4-3.1c5-3 9.9-6.3 14.6-9.8c7.6-5.7 10.1-15.7 7.1-24.7l-9.3-28.2c8.8-10.7 16-23 20.9-36.2l29.1-6.1c9.3-1.9 16.7-9.1 17.8-18.5c.8-6.7 1.2-13.5 1.2-20.4s-.4-13.7-1.2-20.4c-1.1-9.4-8.6-16.6-17.8-18.5L583.9 307c-5-13.3-12.1-25.5-20.9-36.2l9.3-28.2c3-9 .5-19-7.1-24.7c-4.7-3.5-9.6-6.8-14.6-9.9l-5.3-3c-5-2.8-10.2-5.3-15.6-7.6c-8.7-3.7-18.6-.9-25 6.2l-19.8 22.2c-6.8-1.1-13.8-1.7-20.9-1.7s-14.1 .6-20.9 1.7l-19.8-22.2c-6.3-7.1-16.2-9.9-25-6.2c-5.3 2.3-10.5 4.8-15.6 7.6l-5.2 3c-5.1 3-9.9 6.3-14.6 9.9c-7.6 5.7-10.1 15.7-7.1 24.7l9.3 28.2c-8.8 10.7-16 23-20.9 36.2L315.1 313c-9.3 1.9-16.7 9.1-17.8 18.5c-.8 6.7-1.2 13.5-1.2 20.4s.4 13.7 1.2 20.4c1.1 9.4 8.6 16.6 17.8 18.5l29.1 6.1c5 13.3 12.1 25.5 20.9 36.2l-9.3 28.2c-3 9-.5 19 7.1 24.7c4.7 3.5 9.5 6.8 14.6 9.8l5.4 3.1c5 2.8 10.2 5.3 15.5 7.6c8.7 3.7 18.6 .9 25-6.2l19.8-22.2c6.8 1.1 13.8 1.7 20.9 1.7s14.1-.6 20.9-1.7l19.8 22.2zM464 304a48 48 0 1 1 0 96 48 48 0 1 1 0-96z"/></svg>';
  601.     var faGearsBlack = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="20" viewBox="0 0 640 512"><path fill="#000000" d="M308.5 135.3c7.1-6.3 9.9-16.2 6.2-25c-2.3-5.3-4.8-10.5-7.6-15.5L304 89.4c-3-5-6.3-9.9-9.8-14.6c-5.7-7.6-15.7-10.1-24.7-7.1l-28.2 9.3c-10.7-8.8-23-16-36.2-20.9L199 27.1c-1.9-9.3-9.1-16.7-18.5-17.8C173.9 8.4 167.2 8 160.4 8h-.7c-6.8 0-13.5 .4-20.1 1.2c-9.4 1.1-16.6 8.6-18.5 17.8L115 56.1c-13.3 5-25.5 12.1-36.2 20.9L50.5 67.8c-9-3-19-.5-24.7 7.1c-3.5 4.7-6.8 9.6-9.9 14.6l-3 5.3c-2.8 5-5.3 10.2-7.6 15.6c-3.7 8.7-.9 18.6 6.2 25l22.2 19.8C32.6 161.9 32 168.9 32 176s.6 14.1 1.7 20.9L11.5 216.7c-7.1 6.3-9.9 16.2-6.2 25c2.3 5.3 4.8 10.5 7.6 15.6l3 5.2c3 5.1 6.3 9.9 9.9 14.6c5.7 7.6 15.7 10.1 24.7 7.1l28.2-9.3c10.7 8.8 23 16 36.2 20.9l6.1 29.1c1.9 9.3 9.1 16.7 18.5 17.8c6.7 .8 13.5 1.2 20.4 1.2s13.7-.4 20.4-1.2c9.4-1.1 16.6-8.6 18.5-17.8l6.1-29.1c13.3-5 25.5-12.1 36.2-20.9l28.2 9.3c9 3 19 .5 24.7-7.1c3.5-4.7 6.8-9.5 9.8-14.6l3.1-5.4c2.8-5 5.3-10.2 7.6-15.5c3.7-8.7 .9-18.6-6.2-25l-22.2-19.8c1.1-6.8 1.7-13.8 1.7-20.9s-.6-14.1-1.7-20.9l22.2-19.8zM112 176a48 48 0 1 1 96 0 48 48 0 1 1 -96 0zM504.7 500.5c6.3 7.1 16.2 9.9 25 6.2c5.3-2.3 10.5-4.8 15.5-7.6l5.4-3.1c5-3 9.9-6.3 14.6-9.8c7.6-5.7 10.1-15.7 7.1-24.7l-9.3-28.2c8.8-10.7 16-23 20.9-36.2l29.1-6.1c9.3-1.9 16.7-9.1 17.8-18.5c.8-6.7 1.2-13.5 1.2-20.4s-.4-13.7-1.2-20.4c-1.1-9.4-8.6-16.6-17.8-18.5L583.9 307c-5-13.3-12.1-25.5-20.9-36.2l9.3-28.2c3-9 .5-19-7.1-24.7c-4.7-3.5-9.6-6.8-14.6-9.9l-5.3-3c-5-2.8-10.2-5.3-15.6-7.6c-8.7-3.7-18.6-.9-25 6.2l-19.8 22.2c-6.8-1.1-13.8-1.7-20.9-1.7s-14.1 .6-20.9 1.7l-19.8-22.2c-6.3-7.1-16.2-9.9-25-6.2c-5.3 2.3-10.5 4.8-15.6 7.6l-5.2 3c-5.1 3-9.9 6.3-14.6 9.9c-7.6 5.7-10.1 15.7-7.1 24.7l9.3 28.2c-8.8 10.7-16 23-20.9 36.2L315.1 313c-9.3 1.9-16.7 9.1-17.8 18.5c-.8 6.7-1.2 13.5-1.2 20.4s.4 13.7 1.2 20.4c1.1 9.4 8.6 16.6 17.8 18.5l29.1 6.1c5 13.3 12.1 25.5 20.9 36.2l-9.3 28.2c-3 9-.5 19 7.1 24.7c4.7 3.5 9.5 6.8 14.6 9.8l5.4 3.1c5 2.8 10.2 5.3 15.5 7.6c8.7 3.7 18.6 .9 25-6.2l19.8-22.2c6.8 1.1 13.8 1.7 20.9 1.7s14.1-.6 20.9-1.7l19.8 22.2zM464 304a48 48 0 1 1 0 96 48 48 0 1 1 0-96z"/></svg>';
  602.     
  603.     var faExibirTodasAsLetras = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 576 512"><path fill="#ffffff" d="M183.6 42.4C177.5 35.8 169 32 160 32s-17.5 3.8-23.6 10.4l-88 96c-11.9 13-11.1 33.3 2 45.2s33.3 11.1 45.2-2L128 146.3V448c0 17.7 14.3 32 32 32s32-14.3 32-32V146.3l32.4 35.4c11.9 13 32.2 13.9 45.2 2s13.9-32.2 2-45.2l-88-96zM320 64c0 17.7 14.3 32 32 32h50.7l-73.4 73.4c-9.2 9.2-11.9 22.9-6.9 34.9s16.6 19.8 29.6 19.8H480c17.7 0 32-14.3 32-32s-14.3-32-32-32H429.3l73.4-73.4c9.2-9.2 11.9-22.9 6.9-34.9s-16.6-19.8-29.6-19.8H352c-17.7 0-32 14.3-32 32zm96 192c-12.1 0-23.2 6.8-28.6 17.7l-64 128-16 32c-7.9 15.8-1.5 35 14.3 42.9s35 1.5 42.9-14.3l7.2-14.3h88.4l7.2 14.3c7.9 15.8 27.1 22.2 42.9 14.3s22.2-27.1 14.3-42.9l-16-32-64-128C439.2 262.8 428.1 256 416 256zM395.8 400L416 359.6 436.2 400H395.8z"/></svg>';
  604.     var faMostrarNoTabuleiro  = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 576 512"><path fill="#ffffff" d="M64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H384c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64zm64 64v64h64V96h64v64h64V96h64v64H320v64h64v64H320v64h64v64H320V352H256v64H192V352H128v64H64V352h64V288H64V224h64V160H64V96h64zm64 128h64V160H192v64zm0 64V224H128v64h64zm64 0H192v64h64V288zm0 0h64V224H256v64z"/></svg>';
  605.     var faResolverPalavra     = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 576 512"><path fill="#ffffff" d="M112 0C99.1 0 87.4 7.8 82.5 19.7l-66.7 160-13.3 32c-6.8 16.3 .9 35 17.2 41.8s35-.9 41.8-17.2L66.7 224h90.7l5.1 12.3c6.8 16.3 25.5 24 41.8 17.2s24-25.5 17.2-41.8l-13.3-32-66.7-160C136.6 7.8 124.9 0 112 0zm18.7 160H93.3L112 115.2 130.7 160zM256 32v96 96c0 17.7 14.3 32 32 32h80c44.2 0 80-35.8 80-80c0-23.1-9.8-43.8-25.4-58.4c6-11.2 9.4-24 9.4-37.6c0-44.2-35.8-80-80-80H288c-17.7 0-32 14.3-32 32zm96 64H320V64h32c8.8 0 16 7.2 16 16s-7.2 16-16 16zm-32 64h32 16c8.8 0 16 7.2 16 16s-7.2 16-16 16H320V160zM566.6 310.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L352 434.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l96 96c12.5 12.5 32.8 12.5 45.3 0l192-192z"/></svg>';
  606.     var faDica = '<svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 576 512"><path fill="#ffffff" d="M168.2 384.9c-15-5.4-31.7-3.1-44.6 6.4c-8.2 6-22.3 14.8-39.4 22.7c5.6-14.7 9.9-31.3 11.3-49.4c1-12.9-3.3-25.7-11.8-35.5C60.4 302.8 48 272 48 240c0-79.5 83.3-160 208-160s208 80.5 208 160s-83.3 160-208 160c-31.6 0-61.3-5.5-87.8-15.1zM26.3 423.8c-1.6 2.7-3.3 5.4-5.1 8.1l-.3 .5c-1.6 2.3-3.2 4.6-4.8 6.9c-3.5 4.7-7.3 9.3-11.3 13.5c-4.6 4.6-5.9 11.4-3.4 17.4c2.5 6 8.3 9.9 14.8 9.9c5.1 0 10.2-.3 15.3-.8l.7-.1c4.4-.5 8.8-1.1 13.2-1.9c.8-.1 1.6-.3 2.4-.5c17.8-3.5 34.9-9.5 50.1-16.1c22.9-10 42.4-21.9 54.3-30.6c31.8 11.5 67 17.9 104.1 17.9c141.4 0 256-93.1 256-208S397.4 32 256 32S0 125.1 0 240c0 45.1 17.7 86.8 47.7 120.9c-1.9 24.5-11.4 46.3-21.4 62.9zM144 272a32 32 0 1 0 0-64 32 32 0 1 0 0 64zm144-32a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zm80 32a32 32 0 1 0 0-64 32 32 0 1 0 0 64z"/></svg>';
  607.     
  608.     
  609.     var controleStartJogo = false;
  610.     var token = '';
  611.     var isViewAnuncio = false;
  612.     const jogo = {
  613.         saldo: 0,
  614.         pontos: 0,
  615.         
  616.         regras: [],
  617.         
  618.         idJogo: 0,
  619.         modelo: '',
  620.         desafioDiario: 0,
  621.         
  622.         isAltConfig: false,
  623.         
  624.         /* variaveis de estatisticas */        
  625.         estatisticas: [],
  626.         niveis: [],
  627.         saldoInicial: 0,
  628.         nivelAlertaPulse: 1,
  629.         nivelAlertaStress: 2,
  630.         nivelAlertaFim: 3,
  631.         
  632.         clicExibirDica: 0,
  633.         clicExibirTodasLetras: 0,
  634.         
  635.         consolidacao: [],
  636.         historicoDesempenho: [],
  637.         
  638.         isCanViewVideoRewardedInterstitial: true,
  639.         isCanViewVideoRewarded: true,
  640.         isCanViewVideoInterstitial: true,
  641.         isObrigatorioTrocarDeNivel: false,
  642.         
  643.         palavraSelecionada: '',
  644.         
  645.         handleContador: 0,        
  646.         handleAds: 0,
  647.         
  648.         configUser: '',
  649.         
  650.         configure: function(IdDoJogo, json, modelo){
  651.             
  652.             $("#clsCtrlDicas").css('visibility','hidden');
  653.             if(IdDoJogo == 1){
  654.                 $("#idDivDica").css('color', '#0e2a60');
  655.                 $("#clsCtrlDicas").css('visibility','visible');
  656.             } else {
  657.                 $("#idDivDica").css('color', '#0e2a60');
  658.             }
  659.             
  660.             jogo.idJogo = IdDoJogo;
  661.             jogo.modelo = modelo;
  662.             jogo.isPalavraSelecionada = 0;
  663.             if(modelo.lstPalavrasSalvas){
  664.                 jogo.isPalavraSelecionada = modelo.lstPalavrasSalvas.length;
  665.                 jogo.palavraSelecionada = modelo.lstPalavrasSalvas.length;
  666.             } else if(modelo.palavra){
  667.                 jogo.isPalavraSelecionada = modelo.palavra.length;
  668.                 jogo.palavraSelecionada = modelo.palavra;
  669.             }
  670.             jogo.regras = json.parametros[json.nivel]
  671.             jogo.saldoInicial = jogo.saldo;
  672.             jogo.clicExibirDica = 0;
  673.             jogo.clicExibirTodasLetras = 0;
  674.             
  675.             
  676.             if(jogo.handleContador > 0){
  677.                 clearInterval(jogo.handleContador);
  678.                 jogo.handleContador = 0;
  679.             }
  680.             
  681.             /* start o contador no site, marcando sempre as moedas e os pontos*/
  682.             jogo.handleContador = setInterval(function(){
  683.                 let j = "<img src='/img/tesouro.png' style='width: 1.5em;margin-right: 0.2em;'/>" + jogo.saldo;
  684.                 $("#idDivInfoMoedas").html(j);
  685.                 
  686.                 if(jogo.saldo < 0){
  687.                     if(!Swal.isVisible()){
  688.                         avisoParaAssistirVideoInicioJogo();            
  689.                     }
  690.                 } else {
  691.                     if(Swal.isVisible()){
  692.                         if(Swal.getConfirmButton().textContent == "Ganhar créditos!"){
  693.                             Swal.close();
  694.                         }
  695.                     }
  696.                 }
  697.             }, 100);
  698.             
  699.             
  700.             if(jogo.handleAds > 0){
  701.                 clearInterval(jogo.handleAds);
  702.                 jogo.handleAds = 0;
  703.             }
  704.             
  705.             let dificuldade = '';
  706.             switch(parseInt(jogo.modelo.nivel)){
  707.                 case 0: dificuldade = 'Aprendiz'; break;
  708.                 case 1: dificuldade = 'Fácil'; break;
  709.                 case 2: dificuldade = 'Intermediário'; break;
  710.                 case 3: dificuldade = 'Difícil'; break;
  711.                 case 4: dificuldade = 'Incrível'; break;
  712.             }
  713.             
  714.             let hdificuldade = '<span onclick="jogo.btnConfig()">' + faGearsBlack + ' ' + dificuldade + '</span>';
  715.             $("#idDivInfoNivel").html(hdificuldade);
  716.             
  717.             /* start a estatistica */
  718.             jogo.estatisticas.params = [];
  719.             jogo.setEstatisticas('novo_jogo', '', '');
  720.             jogo.palavras = json.palavras.filter(e => e.usada == true);
  721.             
  722.             /* envia mensagem para o app com os dados do jogo */
  723.             sendMsg({
  724.                 "acao":"excluirPalavras",
  725.                 "palavras": jogo.palavras
  726.             });
  727.             
  728.             /* isso é necessário para reuniciar o jogo, somente com as palavras não usadas */
  729.             json.palavras = json.palavras.filter(e => e.usada == false);            
  730.             
  731.             jogo.aplicaRegras('novo_jogo');
  732.             
  733.             let idModelo = parseInt(json.idModelo);
  734.             if(isNaN(idModelo)){
  735.                 idModelo = 0;
  736.             }
  737.             
  738.             $.ajax({
  739.                 url: '/api/perfil/configuracoes/jogo/' + jogo.idJogo + '/configuracoes',
  740.                 dataType: 'json',
  741.                 type: 'POST',
  742.                 data: {
  743.                     modelo: modelo,
  744.                     idModelo: idModelo
  745.                 },
  746.                 success: function (j){
  747.                     jogo.modelo = j;
  748.                 }
  749.             });
  750.             
  751.             
  752.             $(".nav-link").click(function(){                
  753.                 jogo.setAba($(this));                
  754.             });
  755.             
  756.             $.ajax({
  757.                 url: '/api/jogos/controle/get/historico/' + jogo.idJogo,
  758.                 dataType: 'json',
  759.                 success: function (j){
  760.                     jogo.historicoDesempenho = j;                    
  761.                 }
  762.             });
  763.             
  764.             
  765.             if(jogo.isPalavraSelecionada == 0){
  766.                 this.obrigatorioTrocarDeNivel();
  767.             }
  768.         },
  769.         
  770.         obrigatorioTrocarDeNivel: function(){
  771.             isObrigatorioTrocarDeNivel = true;
  772.             
  773.             Swal.fire({
  774.                 title: '<strong>Não há mais palavras para este nível</strong>',
  775.                 html: '<p>É obrigatório a troca de nível</p>',
  776.                 showConfirmButton: true,
  777.                 showCloseButton: false,
  778.                 showCancelButton: false,
  779.                 focusConfirm: false,
  780.                 confirmButtonText:  'Ok',
  781.                 allowOutsideClick: false                      
  782.             }).then(() => {
  783.                 this.btnConfig();
  784.             });
  785.         },
  786.         
  787.         formatarData: function(data){
  788.             let m = data.getMonth() + 1;
  789.             let dia = data.getDate() < 10 ? '0' + data.getDate() : data.getDate();
  790.             let mes = m < 10 ? '0' + m : m;
  791.             let ano = data.getFullYear();
  792.             
  793.             let hora = data.getHours();
  794.             let min = data.getMinutes() < 10 ? '0' + data.getMinutes() : data.getMinutes();
  795.             
  796.             return dia + '/' + mes + '/' + ano + ' ' + hora + ':' + min;
  797.         },
  798.         
  799.         checkClickAjuda: function(regra, check){
  800.             if(jogo.idJogo == 2 || jogo.idJogo == 3){
  801.                 /* forca                  palavra escondida */
  802.                 if(regra == 'exibir_dica'){
  803.                     if(jogo.clicExibirDica > 0){
  804.                         return false;
  805.                     }
  806.                     if(check){
  807.                         jogo.clicExibirDica++;
  808.                     }                    
  809.                 }
  810.                 
  811.                 if(regra == 'exibir_todas_letras'){
  812.                     if(jogo.clicExibirTodasLetras > 0){
  813.                         return false;
  814.                     }
  815.                     if(check){
  816.                         jogo.clicExibirTodasLetras++;
  817.                     }                    
  818.                 }                
  819.             }
  820.             
  821.             return true;
  822.         },
  823.         
  824.         aplicaRegras: function(regra){
  825.             
  826.             if(!jogo.checkClickAjuda(regra, true)){
  827.                 return;
  828.             }
  829.             
  830.             let r = jogo.getRegras(regra);
  831.             sendMsg({
  832.                 "acao":"aplicarRegras",
  833.                 "regra": r,
  834.                 "jogo": jogo
  835.             });
  836.         },
  837.         
  838.         setEstatisticas: function (label, value, value2){
  839.             /**
  840.              * Estatisticas que o sistema irá contabilizar
  841.              * 
  842.              * - click
  843.              * - inicio / fim
  844.              * - win / loss
  845.              * 
  846.              */
  847.             let tp = ['click','vencer','perder','iniciar','finalizar'];
  848.             let idx = tp.find(e => e == label);
  849.         
  850.             if(!idx){
  851.                 if(jogo.getRegras(label) == ''){
  852.                     return;
  853.                 }
  854.             }
  855.             
  856.             jogo.estatisticas.params.push({
  857.                 'label': label,
  858.                 'value': value,
  859.                 'value2': value2,
  860.                 'data': new Date()
  861.             });
  862.             
  863.             if(label == 'exibir_todas_letras'
  864.             || label == 'exibir_dica'
  865.             || label == 'resolver_palavra'
  866.             || label == 'mostrar_no_tabuleiro_letra'){
  867.                 jogo.aplicaRegras(label);
  868.             }
  869.         },
  870.         
  871.         getRegras: function(parametro){
  872.             if(jogo.regras){
  873.                 return jogo.regras.find(e => e.parametro == parametro);
  874.             } else {
  875.                 return '';
  876.             }
  877.         },
  878.                 
  879.         getConsolidacao: function(venceu){
  880.             let idJogo = jogo.idJogo;
  881.             let palavra = '';
  882.             let nivel = $("#idDivInfoNivel").text();
  883.             if(jogo.idJogo == 1){
  884.                 palavra = jogo.palavras.length + ' palavras';                
  885.             } else {
  886.                 palavra = jogo.palavraSelecionada;                
  887.             }
  888.             
  889.             let params = jogo.estatisticas.params;
  890.             let bonus = jogo.bonus;
  891.             let regras = jogo.regras;
  892.             
  893.             let saldoInicial = jogo.saldoInicial;
  894.             let saldoFinal = jogo.saldo;
  895.             
  896.             return {
  897.                 'idJogo': idJogo,
  898.                 'nivel': nivel,
  899.                 'palavra': palavra,
  900.                 'params': params,
  901.                 'bonus': bonus,
  902.                 'regras': regras,
  903.                 'saldoInicial': saldoInicial,
  904.                 'saldoFinal': saldoFinal,
  905.                 'resultado': venceu ? "venceu": "perdeu"
  906.             }
  907.         },
  908.                 
  909.         viewExtrato: function(){
  910.             /* gerar extrato do jogo */
  911.             let nome = jogo.consolidacao.idJogo == 3 ? 'Forca' : (jogo.consolidacao.idJogo == 2 ? 'Palavra Escondida' : 'Palavras Cruzadas');
  912.             let subNome = jogo.consolidacao.nivel;
  913.             
  914.             let nClick = jogo.consolidacao.params.filter(e => e.label == 'click').length;
  915.             let inicio = jogo.consolidacao.params.filter(e => e.label == 'novo_jogo');
  916.             let fim1 = jogo.consolidacao.params.filter(e => e.label == 'vencer');
  917.             let fim2 = jogo.consolidacao.params.filter(e => e.label == 'perder');
  918.             
  919.             
  920.             let fim = fim1.length == 0 ? fim2 : fim1;
  921.             
  922.             // Calcular a diferença em milissegundos
  923.             let diferencaEmMilissegundos = fim[0].data - inicio[0].data;
  924.             
  925.             // Calcular a diferença em segundos
  926.             let diferencaEmSegundos = diferencaEmMilissegundos / 1000;
  927.             let intDiferencaEmSegundos = parseInt(diferencaEmSegundos);
  928.             
  929.             // Calcular a diferença em minutos
  930.             let diferencaEmMinutos = diferencaEmSegundos / 60;
  931.             let intDiferencaEmMinutos = parseInt(diferencaEmMinutos);
  932.             
  933.             // Calcular a diferença em horas
  934.             let diferencaEmHoras = diferencaEmMinutos / 60;
  935.             let intDiferencaEmHoras = parseInt(diferencaEmHoras);
  936.             
  937.             let modal = document.querySelector(".extrato");
  938.             let title = modal.querySelector('.title');
  939.                 title.querySelector('.title1').innerHTML = nome;
  940.                 title.querySelector('.nivel').innerHTML = subNome;
  941.                 
  942.                 
  943.             let tempo = '';
  944.             if(intDiferencaEmHoras > 0){
  945.                 let m = intDiferencaEmMinutos - (intDiferencaEmHoras * 60);
  946.                 let s = intDiferencaEmSegundos - (m * 60);
  947.                 tempo = intDiferencaEmHoras + "horas e " + m + "min e " + s+"seg";
  948.             } else if(intDiferencaEmMinutos > 0){
  949.                 let s = intDiferencaEmSegundos - (intDiferencaEmMinutos * 60);
  950.                 tempo = intDiferencaEmMinutos + "min e " + s +"seg";
  951.             } else {
  952.                 tempo = intDiferencaEmSegundos+"seg";
  953.             }
  954.                 
  955.             let divs = modal.querySelector('.header');
  956.             divs.children[0].children[1].innerHTML = nClick;
  957.             divs.children[1].children[1].innerHTML = tempo;
  958.             divs.children[2].children[1].innerHTML = jogo.consolidacao.saldoFinal + " moedas";            
  959.             
  960.             let h = jogo.consolidacao.params;
  961.             let rel = '<table style="width: 100%;">';
  962.             let c = 0;
  963.             let debito = 0;
  964.             let credito = 0;
  965.             let viewVideos = 0;
  966.             let saldoAtual = parseInt(jogo.consolidacao.saldoInicial);
  967.             
  968.             function getLinhaTable(cls, idx, l, m, s ){
  969.                 return '<tr class="' + cls + '">' + 
  970.                             '<td>' + idx + '</td>' + 
  971.                             '<td>' + l + '</td>' + 
  972.                             '<td style="text-align: right;">' + m + '</td>' + 
  973.                             '<td>&nbsp;&nbsp;</td>' + 
  974.                             '<td style="text-align: right;">' + s + '</td>' + 
  975.                         '</tr>'
  976.                     ;
  977.             }
  978.             
  979.             for(x in h){
  980.                 if(h[x].label == 'assistirVideo'){
  981.                     c++;
  982.                     saldoAtual+=parseInt(jogo.consolidacao.bonus);
  983.                     rel+=getLinhaTable('certo', c, 'Bônus vídeo', jogo.consolidacao.bonus, saldoAtual);
  984.                     viewVideos++;
  985.                 } else {                
  986.                     let p = null;
  987.                     if(jogo.consolidacao.regras){
  988.                         p = jogo.consolidacao.regras.find(e => e.parametro == h[x].label);
  989.                     }
  990.                     if(p){
  991.                         c++;
  992.                         if(p.acao == 'sub'){
  993.                             s = '-';
  994.                             debito+=p.moedas;
  995.                             saldoAtual-=p.moedas;
  996.                         } else {
  997.                             s = '+';
  998.                             credito+=p.moedas;
  999.                             saldoAtual+=p.moedas;
  1000.                         }
  1001.                         
  1002.                         if(p.nome == 'Letra certa' || p.nome == 'Letra errada'){
  1003.                             nome = p.nome + ' - ' + h[x].value + '';
  1004.                         } else {
  1005.                             nome = p.nome;
  1006.                         }
  1007.                         rel+=getLinhaTable((s == '-' ? 'errado' : 'certo'), c, nome, s + ' ' + p.moedas, saldoAtual);
  1008.                     }                    
  1009.                 }
  1010.             }
  1011.             rel+='</table>';
  1012.             
  1013.             let body = modal.querySelector('.body');
  1014.             let container = body.querySelectorAll('.container');
  1015.             container[0].children[0].innerHTML = 'Saldo inicial ' + jogo.consolidacao.saldoInicial + ' moedas';
  1016.             container[0].children[1].innerHTML = rel;
  1017.             container[0].children[2].innerHTML = 'Saldo final ' + jogo.consolidacao.saldoFinal + ' moedas';
  1018.             
  1019.             let resumo = '<div style="font-size: 0.8em;">';
  1020.                     resumo+= '<ul>';
  1021.                         resumo+= '<li>' + debito + ' moedas debitadas</li>';
  1022.                         resumo+= '<li>' + credito + ' moedas creditadas</li>';
  1023.                         if(viewVideos > 1){
  1024.                             resumo+= '<li>' + (viewVideos *  jogo.consolidacao.bonus) + ' moedas creditadas em ' + viewVideos + ' videos assistidos</li>';
  1025.                         } else {
  1026.                             if(viewVideos > 0){
  1027.                                 resumo+= '<li>' + (viewVideos *  jogo.consolidacao.bonus) + ' moedas creditadas em ' + viewVideos + ' video assistido</li>';
  1028.                             }
  1029.                         }
  1030.                     resumo+= '</ul>';
  1031.                     
  1032.                     let custoJogo = credito - debito;
  1033.                     if(custoJogo > 0){
  1034.                         resumo+= '<p class="certoResumo">Parabêns, você conseguiu ganhar ' + custoJogo + ' moedas, aumentando seu saldo de ' + jogo.consolidacao.saldoInicial + ' para ' + jogo.consolidacao.saldo + ' moedas.</p>';
  1035.                     } else {
  1036.                         resumo+= '<p class="erradoResumo">Este jogo lhe custou ' + (custoJogo *-1) + ' moedas.</p>';
  1037.                     }
  1038.                     if(viewVideos > 0){
  1039.                         resumo+= '<p style="color: #868686;font-size: .8em;font-style: italic;">Para calcular o custo do jogo, não é levado em consideração os créditos recebidos em bônus por vídeos assistidos</p>';
  1040.                     }
  1041.                     
  1042.                 resumo+= '</div>';
  1043.             
  1044.             container[1].children[0].innerHTML = resumo;
  1045.             
  1046.             jogo.btnShowHideExtrato();
  1047.             
  1048.             setTimeout(function(){
  1049.                 let posContent = document.getElementById('idDivPosContentExtrato');
  1050.                 let posBody = document.getElementById('idDivPosBodyExtrato');
  1051.                 
  1052.                 let t1 = posContent.getBoundingClientRect().height;
  1053.                 let t2 = posBody.getBoundingClientRect().top;
  1054.                 let t3 = t1 - t2;
  1055.                 
  1056.                 posBody.style.maxHeight = t3 + "px";
  1057.             }, 50);
  1058.         },
  1059.         
  1060.         
  1061.         setAba: function(e){
  1062.             $(".nav-link").removeClass('active');
  1063.             e.addClass('active');
  1064.             $(".tab-pane").hide();
  1065.             $("." + e.attr('id')).show();    
  1066.         },
  1067.         
  1068.         __GraficosAbaGeral1Vertical: function(params, dadosPorColunaVertical){
  1069.             if(typeof dadosPorColunaVertical != "object") return;
  1070.             
  1071.             $("#divGeralChartVerticalCard").show();
  1072.             am5.array.each(am5.registry.rootElements, function(root) {
  1073.                 if (root && root.dom && root.dom.id == "divGeralChartVertical") {
  1074.                     root.dispose();
  1075.                 }
  1076.             });
  1077.             let root = am5.Root.new("divGeralChartVertical");
  1078.             root.setThemes([
  1079.                 am5themes_Animated.new(root)
  1080.             ]);
  1081.             var chart = root.container.children.push(am5xy.XYChart.new(root, {
  1082.                 panX: false,
  1083.                 panY: false,
  1084.                 wheelX: "panX",
  1085.                 wheelY: "zoomX",
  1086.                 paddingLeft: 0,
  1087.                 layout: root.verticalLayout
  1088.             }));
  1089.             // Create axes
  1090.             // https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
  1091.             var xRenderer = am5xy.AxisRendererX.new(root, {
  1092.                 minGridDistance: 30,
  1093.                 minorGridEnabled: false
  1094.             })
  1095.             var xAxis = chart.xAxes.push(am5xy.CategoryAxis.new(root, {
  1096.                 categoryField: "category",
  1097.                 renderer: xRenderer,                        
  1098.             }));
  1099.             xRenderer.grid.template.setAll({
  1100.               location: 1
  1101.             })
  1102.             xRenderer.labels.template.setAll({
  1103.               paddingTop: 20
  1104.             });
  1105.             xAxis.data.setAll(dadosPorColunaVertical);
  1106.             var yAxis = chart.yAxes.push(am5xy.ValueAxis.new(root, {
  1107.                 renderer: am5xy.AxisRendererY.new(root, {
  1108.                     strokeOpacity: 0.1
  1109.                 })
  1110.             }));
  1111.             // Add series
  1112.             // https://www.amcharts.com/docs/v5/charts/xy-chart/series/
  1113.             var series = chart.series.push(am5xy.ColumnSeries.new(root, {
  1114.                 xAxis: xAxis,
  1115.                 yAxis: yAxis,
  1116.                 valueYField: "value",
  1117.                 categoryXField: "category"
  1118.             }));
  1119.             series.columns.template.setAll({
  1120.                 tooltipText: "{categoryX}: {valueY}",
  1121.                 tooltipY: 0,
  1122.                 strokeOpacity: 0,
  1123.                 templateField: "columnSettings",
  1124.                 cornerRadiusTL: 5, 
  1125.                 cornerRadiusTR: 5, 
  1126.             });
  1127.             series.columns.template.adapters.add("fill", function (fill, target) {
  1128.                 return chart.get("colors").getIndex(series.columns.indexOf(target));
  1129.             });
  1130.             series.columns.template.adapters.add("stroke", function (stroke, target) {
  1131.                 return chart.get("colors").getIndex(series.columns.indexOf(target));
  1132.             });
  1133.             series.data.setAll(dadosPorColunaVertical);
  1134.             // Make stuff animate on load
  1135.             // https://www.amcharts.com/docs/v5/concepts/animations/
  1136.             series.appear();
  1137.             chart.appear(1000, 100);
  1138.         },
  1139.         __GraficosAbaGeral1Horizontal: function(params, dadosPorColunaHorizontal){
  1140.             
  1141.             if(typeof dadosPorColunaHorizontal != "object" || dadosPorColunaHorizontal == null) return;
  1142.             
  1143.             $("#divGeralChartHorizontalCard").show();
  1144.             am5.array.each(am5.registry.rootElements, function(root) {
  1145.                 if (root && root.dom && root.dom.id == "divGeralChartHorizontal") {
  1146.                     root.dispose();
  1147.                 }
  1148.             });
  1149.             let root = am5.Root.new("divGeralChartHorizontal");
  1150.             root.setThemes([
  1151.                 am5themes_Animated.new(root)
  1152.             ]);
  1153.             var chart = root.container.children.push(am5xy.XYChart.new(root, {
  1154.                 panX: false,
  1155.                 panY: false,
  1156.                 wheelX: "panX",
  1157.                 wheelY: "zoomX",
  1158.                 paddingLeft: 0,
  1159.                 layout: root.verticalLayout
  1160.             }));
  1161.             // Create axes
  1162.             var yRenderer = am5xy.AxisRendererY.new(root, {
  1163.                 minGridDistance: 20,
  1164.                 cellStartLocation: 0.1,
  1165.                 cellEndLocation: 0.5,
  1166.                 minorGridEnabled: true
  1167.             });
  1168.             yRenderer.grid.template.set('location', 1);
  1169.             var yAxis = chart.yAxes.push(
  1170.                 am5xy.CategoryAxis.new(root, {
  1171.                     categoryField: dadosPorColunaHorizontal.categoryYField,
  1172.                     renderer: yRenderer,
  1173.                     max: dadosPorColunaHorizontal.qtdTotalLinhas,
  1174.                     min: 1,
  1175.                     strictMinMax: true,
  1176.                     adapter: {
  1177.                         min: 1,
  1178.                         max: dadosPorColunaHorizontal.qtdTotalLinhas,
  1179.                         step: 1
  1180.                     }                       
  1181.                 })
  1182.             );
  1183.             yAxis.data.setAll(dadosPorColunaHorizontal.dados);
  1184.             var xAxis = chart.xAxes.push(
  1185.                 am5xy.ValueAxis.new(root, {
  1186.                     min:0,
  1187.                     renderer: am5xy.AxisRendererX.new(root, {
  1188.                         minGridDistance:30,
  1189.                         minorGridEnabled:false
  1190.                     })
  1191.                 })
  1192.             );
  1193.             var series = chart.series.push(am5xy.ColumnSeries.new(root, {
  1194.                 name: dadosPorColunaHorizontal.name,
  1195.                 xAxis: xAxis,
  1196.                 yAxis: yAxis,
  1197.                 valueXField: dadosPorColunaHorizontal.valueXField,
  1198.                 categoryYField: dadosPorColunaHorizontal.categoryYField,
  1199.                 sequencedInterpolation: true,
  1200.                 tooltip: am5.Tooltip.new(root, {
  1201.                     pointerOrientation: "horizontal",
  1202.                     labelText: "[bold]Tentativa {categoryY}: {valueX} vitórias"
  1203.                 })
  1204.             }));
  1205.             series.columns.template.setAll({
  1206.                 height: am5.percent(100),
  1207.                 tooltipText: "{categoryX}: {valueY}",
  1208.                 tooltipY: 0,
  1209.                 strokeOpacity: 0,
  1210.                 templateField: "columnSettings",
  1211.                 cornerRadiusTL: 5, 
  1212.                 cornerRadiusTR: 5,
  1213.             });
  1214.             series.columns.template.adapters.add("fill", function (fill, target) {
  1215.                 return chart.get("colors").getIndex(series.columns.indexOf(target));
  1216.             });
  1217.             series.columns.template.adapters.add("stroke", function (stroke, target) {
  1218.                 return chart.get("colors").getIndex(series.columns.indexOf(target));
  1219.             });
  1220.             series.data.setAll(dadosPorColunaHorizontal.dados);
  1221.             var legend = chart.children.push(am5.Legend.new(root, {
  1222.                 centerX: am5.p50,
  1223.                 x: am5.p50
  1224.             }));
  1225.             series.appear();
  1226.             legend.data.setAll(chart.series.values);
  1227.             chart.appear(1000, 100);
  1228.         },
  1229.         __GraficosAbaGeral1Tempo: function(params, dadosPorLinhaTemporal){
  1230.             if(typeof dadosPorLinhaTemporal != "object") return;
  1231.             
  1232.             $("#divGeralChartTempoCard").show();
  1233.             am5.array.each(am5.registry.rootElements, function(root) {
  1234.                 if (root && root.dom && root.dom.id == "divGeralChartTempo") {
  1235.                     root.dispose();
  1236.                 }
  1237.             });
  1238.             let root = am5.Root.new("divGeralChartTempo");
  1239.             // Set themes
  1240.             // https://www.amcharts.com/docs/v5/concepts/themes/
  1241.             root.setThemes([
  1242.                 am5themes_Animated.new(root)
  1243.             ]);
  1244.             // Create chart
  1245.             // https://www.amcharts.com/docs/v5/charts/xy-chart/
  1246.             var chart = root.container.children.push(am5xy.XYChart.new(root, {
  1247.                 panX: true,
  1248.                 panY: true,
  1249.                 wheelX: "panX",
  1250.                 wheelY: "zoomX",
  1251.                 pinchZoomX:true,
  1252.                 layout: root.verticalLayout,
  1253.                 maxTooltipDistance: 0
  1254.             }));
  1255.             chart.get("colors").set("step", 3);
  1256.             // Add cursor
  1257.             // https://www.amcharts.com/docs/v5/charts/xy-chart/cursor/
  1258.             var cursor = chart.set("cursor", am5xy.XYCursor.new(root, {}));
  1259.             cursor.lineY.set("visible", false);
  1260.             // Create axes
  1261.             // https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
  1262.             var xAxis = chart.xAxes.push(am5xy.DateAxis.new(root, {
  1263.                 maxDeviation: 0.3,
  1264.                 baseInterval: {
  1265.                     timeUnit: "day",
  1266.                     count: 1
  1267.                 },
  1268.                 renderer: am5xy.AxisRendererX.new(root, { minorGridEnabled: true }),
  1269.                 tooltip: am5.Tooltip.new(root, {})
  1270.             }));
  1271.             var yAxis = chart.yAxes.push(am5xy.ValueAxis.new(root, {
  1272.                 maxDeviation: 0.3,
  1273.                 renderer: am5xy.AxisRendererY.new(root, {})
  1274.             }));
  1275.             let label1 = params.label1 ? params.label1 : 'Vitórias';
  1276.             let label2 = params.label2 ? params.label2 : 'Derrotas';
  1277.             // Add series
  1278.             // https://www.amcharts.com/docs/v5/charts/xy-chart/series/
  1279.             var series = chart.series.push(am5xy.LineSeries.new(root, {
  1280.                 name: label1,
  1281.                 xAxis: xAxis,
  1282.                 yAxis: yAxis,
  1283.                 valueYField: "vitorias",
  1284.                 valueXField: "date",
  1285.                 tooltip: am5.Tooltip.new(root, {
  1286.                     labelText: "{previousDate}\n"+label1+": {valueY}\n"+label2+": {derrotas}"
  1287.                 })
  1288.             }));
  1289.             series.strokes.template.setAll({
  1290.                 strokeWidth: 2
  1291.             });
  1292.             series.get("tooltip").get("background").set("fillOpacity", 0.5);
  1293.             var series2 = chart.series.push(am5xy.LineSeries.new(root, {
  1294.                 name: label2,
  1295.                 xAxis: xAxis,
  1296.                 yAxis: yAxis,
  1297.                 valueYField: "derrotas",
  1298.                 valueXField: "date"
  1299.             }));
  1300.             series2.strokes.template.setAll({
  1301.                 strokeDasharray: [2, 2],
  1302.                 strokeWidth: 2
  1303.             });
  1304.             // Set date fields
  1305.             // https://www.amcharts.com/docs/v5/concepts/data/#Parsing_dates
  1306.             root.dateFormatter.setAll({
  1307.                 dateFormat: "dd/MM/yyyy H:m:s",
  1308.                 dateFields: ["valueX"]
  1309.             });
  1310.             var data = [];
  1311.             for(x in dadosPorLinhaTemporal){
  1312.                 let a = new Date(dadosPorLinhaTemporal[x].inicio.split(' ')[0]);
  1313.                 let idx = data.findIndex(e => e.date == a.getTime());
  1314.                 if(idx == -1){
  1315.                     let dia = a.getDate();
  1316.                     let mes = a.getMonth() + 1;
  1317.                     if(dia < 10){
  1318.                         dia = '0' + dia;
  1319.                     }
  1320.                     if(mes < 10){
  1321.                         mes = '0' + mes;
  1322.                     }
  1323.                     data.push({
  1324.                         date: a.getTime(),
  1325.                         vitorias: dadosPorLinhaTemporal[x].resultado == 1 ? 1 : 0,
  1326.                         derrotas: dadosPorLinhaTemporal[x].resultado == 2 ? 1 : 0,
  1327.                         previousDate: dia + '/' + mes + '/' + a.getFullYear()
  1328.                     });
  1329.                 } else {
  1330.                     let v = dadosPorLinhaTemporal[x].resultado == 1 ? 1 : 0;
  1331.                     let d = dadosPorLinhaTemporal[x].resultado == 2 ? 1 : 0;
  1332.                     data[idx].vitorias += v;
  1333.                     data[idx].derrotas += d;
  1334.                 }
  1335.             }
  1336.             series.data.setAll(data);
  1337.             series2.data.setAll(data);
  1338.             // Make stuff animate on load
  1339.             // https://www.amcharts.com/docs/v5/concepts/animations/
  1340.             series.appear(1000);
  1341.             series2.appear(1000);
  1342.             var legend = chart.children.push(am5.Legend.new(root, {}));
  1343.             legend.data.setAll(chart.series.values);
  1344.             chart.appear(1000, 100);
  1345.         },        
  1346.         __GraficosAbaGeral1: function(params, dadosPorColunaVertical, dadosPorColunaHorizontal, dados){
  1347.             
  1348.             $("#divGeralChartVerticalCard").hide();
  1349.             $("#divGeralChartHorizontalCard").hide();
  1350.             $("#divGeralChartTempoCard").hide();
  1351.             
  1352.             setTimeout(function(){
  1353.                 jogo.__GraficosAbaGeral1Vertical(params, dadosPorColunaVertical);
  1354.             }, 10);
  1355.             
  1356.             
  1357.             setTimeout(function(){
  1358.                 jogo.__GraficosAbaGeral1Horizontal(params, dadosPorColunaHorizontal);
  1359.             }, 100);
  1360.             
  1361.             setTimeout(function(){
  1362.                 jogo.__GraficosAbaGeral1Tempo(params, dados);
  1363.             }, 100);
  1364.         },
  1365.         
  1366.         __GraficosAbaNivel: function(params, dados, nivel){
  1367.             let div = 1;
  1368.             switch(nivel){
  1369.                 case 'Aprendiz': div = 1; break;
  1370.                 case 'Fácil': div = 2; break;
  1371.                 case 'Intermediário': div = 3; break;
  1372.                 case 'Difícil': div = 4; break;
  1373.                 case 'Incrível': div = 5; break;
  1374.             }
  1375.             let divChart = 'chartNivel' + div;
  1376.             let v = dados.reduce((sum, item) => sum + item.vitorias, 0);
  1377.             let d = dados.reduce((sum, item) => sum + item.derrotas, 0);
  1378.             let divTmp = '<div class="row col-12">';
  1379.                 divTmp+=    '<div class="col-6">' + nivel + '</div>';
  1380.                 divTmp+=    '<div class="col-3 p-0" style="text-align: right;">';
  1381.                 divTmp+=        v + '<img style="width: 20px;" src="/img/trophy.png">';
  1382.                 divTmp+=    '</div>';
  1383.                 divTmp+=    '<div class="col-3 p-0" style="text-align: right;">';
  1384.                 divTmp+=        d + '<img style="width: 20px;" class="derrota" src="/img/trophy.png">';
  1385.                 divTmp+=    '</div>';
  1386.                 divTmp+= '</div>';
  1387.             $(".tabNivel .nivel" + div + " .card-header").html(divTmp);
  1388.             $(".tabNivel .nivel" + div).show();
  1389.             am5.array.each(am5.registry.rootElements, function(root) {
  1390.                 if (root && root.dom && root.dom.id == divChart) {
  1391.                     root.dispose();
  1392.                 }
  1393.             });
  1394.             if(dados.length < 2){
  1395.                 $("#" + divChart).html('<p style="text-align: justify;">Não há dados suficiente para montar o grafico. É necessário ter jogado em mais de um dia.<br><br>Neste nivel você jogou somente no dia ' + dados[0].previousDate + '</p>');
  1396.                 return;
  1397.             }
  1398.             let root = am5.Root.new(divChart);
  1399.             // Set themes
  1400.             // https://www.amcharts.com/docs/v5/concepts/themes/
  1401.             root.setThemes([
  1402.                 am5themes_Animated.new(root)
  1403.             ]);
  1404.             // Create chart
  1405.             // https://www.amcharts.com/docs/v5/charts/xy-chart/
  1406.             var chart = root.container.children.push(am5xy.XYChart.new(root, {
  1407.                 panX: true,
  1408.                 panY: true,
  1409.                 wheelX: "panX",
  1410.                 wheelY: "zoomX",
  1411.                 pinchZoomX:true,
  1412.                 layout: root.verticalLayout,
  1413.                 maxTooltipDistance: 0
  1414.             }));
  1415.             chart.get("colors").set("step", 3);
  1416.             // Add cursor
  1417.             // https://www.amcharts.com/docs/v5/charts/xy-chart/cursor/
  1418.             var cursor = chart.set("cursor", am5xy.XYCursor.new(root, {}));
  1419.             cursor.lineY.set("visible", false);
  1420.             // Create axes
  1421.             // https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
  1422.             var xAxis = chart.xAxes.push(am5xy.DateAxis.new(root, {
  1423.                 maxDeviation: 0.3,
  1424.                 baseInterval: {
  1425.                     timeUnit: "day",
  1426.                     count: 1
  1427.                 },
  1428.                 renderer: am5xy.AxisRendererX.new(root, { minorGridEnabled: true }),
  1429.                 tooltip: am5.Tooltip.new(root, {})
  1430.             }));
  1431.             var yAxis = chart.yAxes.push(am5xy.ValueAxis.new(root, {
  1432.                 maxDeviation: 0.3,
  1433.                 renderer: am5xy.AxisRendererY.new(root, {})
  1434.             }));
  1435.             let label1 = params.label1 ? params.label1 : 'Vitórias';
  1436.             let label2 = params.label2 ? params.label2 : 'Derrotas';
  1437.             // Add series
  1438.             // https://www.amcharts.com/docs/v5/charts/xy-chart/series/
  1439.             var series = chart.series.push(am5xy.LineSeries.new(root, {
  1440.                 name: label1,
  1441.                 xAxis: xAxis,
  1442.                 yAxis: yAxis,
  1443.                 valueYField: "vitorias",
  1444.                 valueXField: "date",
  1445.                 tooltip: am5.Tooltip.new(root, {
  1446.                     labelText: "{previousDate}\n" + label1 + ": {valueY}\nn" + label2 + ": {derrotas}"
  1447.                 })
  1448.             }));
  1449.             series.strokes.template.setAll({
  1450.                 strokeWidth: 2
  1451.             });
  1452.             series.get("tooltip").get("background").set("fillOpacity", 0.5);
  1453.             var series2 = chart.series.push(am5xy.LineSeries.new(root, {
  1454.                 name: label2,
  1455.                 xAxis: xAxis,
  1456.                 yAxis: yAxis,
  1457.                 valueYField: "derrotas",
  1458.                 valueXField: "date"
  1459.             }));
  1460.             series2.strokes.template.setAll({
  1461.                 strokeDasharray: [2, 2],
  1462.                 strokeWidth: 2
  1463.             });
  1464.             // Set date fields
  1465.             // https://www.amcharts.com/docs/v5/concepts/data/#Parsing_dates
  1466.             root.dateFormatter.setAll({
  1467.                 dateFormat: "dd/MM/yyyy H:m:s",
  1468.                 dateFields: ["valueX"]
  1469.             });
  1470.             series.data.setAll(dados);
  1471.             series2.data.setAll(dados);
  1472.             // Make stuff animate on load
  1473.             // https://www.amcharts.com/docs/v5/concepts/animations/
  1474.             series.appear(1000);
  1475.             series2.appear(1000);
  1476.             var legend = chart.children.push(am5.Legend.new(root, {}));
  1477.             legend.data.setAll(chart.series.values);
  1478.             chart.appear(1000, 100);
  1479.         },
  1480.         
  1481.         __MontaDadosPorNivel: function(params, dados){                
  1482.             $(".tabNivel .card").hide();
  1483.             var vetDadosPorNivel = [];
  1484.             var vetNiveis = [];
  1485.             for(x in dados){
  1486.                 if(!dados[x].historico.nivel) continue;
  1487.                 let a = new Date(dados[x].inicio.split(' ')[0]);                    
  1488.                 let idxN = vetNiveis.findIndex(e => e.nivel == dados[x].historico.nivel.trim());
  1489.                 if(idxN == -1){
  1490.                     vetNiveis.push({
  1491.                         nivel: dados[x].historico.nivel.trim()
  1492.                     })
  1493.                 }
  1494.                 let idx = vetDadosPorNivel.findIndex(e => e.date == a.getTime() && e.nivel == dados[x].historico.nivel.trim());
  1495.                 if(idx == -1){
  1496.                     let dia = a.getDate();
  1497.                     let mes = a.getMonth() + 1;
  1498.                     if(dia < 10){
  1499.                         dia = '0' + dia;
  1500.                     }
  1501.                     if(mes < 10){
  1502.                         mes = '0' + mes;
  1503.                     }
  1504.                     vetDadosPorNivel.push({
  1505.                         date: a.getTime(),
  1506.                         vitorias: dados[x].resultado == 1 ? 1 : 0,
  1507.                         derrotas: dados[x].resultado == 2 ? 1 : 0,
  1508.                         previousDate: dia + '/' + mes + '/' + a.getFullYear(),
  1509.                         nivel: dados[x].historico.nivel.trim()
  1510.                     });
  1511.                 } else {
  1512.                     let v = dados[x].resultado == 1 ? 1 : 0;
  1513.                     let d = dados[x].resultado == 2 ? 1 : 0;
  1514.                     vetDadosPorNivel[idx].vitorias += v;
  1515.                     vetDadosPorNivel[idx].derrotas += d;
  1516.                 }
  1517.             }
  1518.             count = 0;
  1519.             function b(){
  1520.                 
  1521.                 if(vetNiveis[count]){
  1522.                     let dd = vetDadosPorNivel.filter(e => e.nivel == vetNiveis[count].nivel);
  1523.                     jogo.__GraficosAbaNivel(params, dd, vetNiveis[count].nivel);
  1524.                 }
  1525.                 if(count < 6){
  1526.                     count++;
  1527.                     setTimeout(b(), 100);
  1528.                 }
  1529.             }
  1530.             b();
  1531.         },
  1532.         
  1533.         __MontaDadosTabela: function(params, dados){
  1534.             let vetPalavras = [];
  1535.             let countAcerto = 0;
  1536.             let countErro = 0;
  1537.             let countWin = 0;
  1538.             let countLose = 0;
  1539.             for(x in dados){
  1540.                 let historico = dados[x].historico;
  1541.                 let countA = 0;
  1542.                 let countE = 0;
  1543.                 for(y in historico.params){                    
  1544.                     let p = dados[x].historico.params[y];
  1545.                     if(p.label == 'letra_certa'){
  1546.                         countAcerto++;
  1547.                         countA++;
  1548.                     } else if(p.label == 'letra_errada'){
  1549.                         countErro++;
  1550.                         countE++;
  1551.                     }
  1552.                 }
  1553.                 (historico.resultado == 'venceu')
  1554.                     ? countWin++
  1555.                     : countLose++;
  1556.                 vetPalavras.push({
  1557.                     'palavra': historico.palavra ? historico.palavra : historico.nome,
  1558.                     'bonus': historico.bonus,
  1559.                     'resultado': historico.resultado,
  1560.                     'saldoFinal': historico.saldoFinal,
  1561.                     'saldoInicial': historico.saldoInicial,                    
  1562.                     'data': dados[x].data,
  1563.                     'duracao': dados[x].duracao,
  1564.                     'fim': dados[x].fim,
  1565.                     'inicio': dados[x].inicio,
  1566.                     'certo': countA,
  1567.                     'errado': countE
  1568.                 });
  1569.             }
  1570.             let t = '<table class="table">';
  1571.             let v = [];
  1572.             let vo = [];
  1573.             for(x in vetPalavras){
  1574.                 let c = x % 2 == 0 ? 'odd' : 'even';
  1575.                 let d = vetPalavras[x].data;
  1576.                 let w = vetPalavras[x].resultado == 'venceu' ? 'ok' : 'nok';
  1577.                 let wl = vetPalavras[x].resultado == 'venceu' ? '<img src="/img/trophy.png" style="width: 80%;">' : '<img src="/img/trophy.png" style="width: 80%;" class="derrota">';
  1578.                 let h = '<tr class="' + c + '">' + 
  1579.                         '<td style="width: 15%">' + wl + '</td>' +
  1580.                         '<td style="width: 38%">' + jogo.formatarData(new Date(vetPalavras[x].inicio)) + '</td>' +
  1581.                         '<td style="">' + vetPalavras[x].palavra + '</td>' + 
  1582.                         '<td  style="width: 10%; text-align: right">' + vetPalavras[x].duracao.toString().replace('.',':') + '</td>' +                                 
  1583.                     '</tr>';
  1584.                 v.push(vetPalavras[x].inicio);
  1585.                 vo.push({
  1586.                     'data': vetPalavras[x].inicio,
  1587.                     'linha' : h
  1588.                 });
  1589.             }   
  1590.             v.sort();
  1591.             let vv = v.toReversed();
  1592.             for(x in vv){
  1593.                 t+=vo.find(e => e.data == vv[x]).linha;
  1594.             }
  1595.             t+='</table>';
  1596.             $("#divTabelaHistorico").html(t);
  1597.         },
  1598.         
  1599.         __viewDesempenhoForca(params, dados){
  1600.             function geral(params, dados){
  1601.                 
  1602.                 let countAcerto = 0;
  1603.                 let countErro = 0;            
  1604.                 let countWin = 0;
  1605.                 let countLose = 0;
  1606.                 let vetDadosGraficos = [];
  1607.                 
  1608.                 for(x in dados){
  1609.                     let historico = dados[x].historico;
  1610.                     let countA = 0;
  1611.                     let countE = 0;
  1612.                     for(y in historico.params){                    
  1613.                         let p = dados[x].historico.params[y];
  1614.                         if(p.label == 'letra_certa'){
  1615.                             countAcerto++;
  1616.                             countA++;
  1617.                         } else if(p.label == 'letra_errada'){
  1618.                             countErro++;
  1619.                             countE++;
  1620.                         }
  1621.                     }
  1622.                     
  1623.                     (historico.resultado == 'venceu')
  1624.                         ? countWin++
  1625.                         : countLose++;
  1626.                 }
  1627.                 
  1628.                 $("#divGeralTotais").html("Você jogou o total de " + (countWin + countLose) + " partidas");
  1629.                 
  1630.                 vetDadosGraficos.push({
  1631.                     category: "Vitórias",
  1632.                     value: countWin
  1633.                 });
  1634.                 
  1635.                 vetDadosGraficos.push({
  1636.                     category: "Derrotas",
  1637.                     value: countLose
  1638.                 });
  1639.                 
  1640.                 
  1641.                 jogo.__GraficosAbaGeral1(params, vetDadosGraficos, null, dados);
  1642.             }            
  1643.             
  1644.             geral(params, dados);
  1645.             
  1646.             jogo.__MontaDadosPorNivel(params, dados);
  1647.             
  1648.             jogo.__MontaDadosTabela(params, dados);
  1649.         },
  1650.         
  1651.         __viewDesempenhoPE(params, dados){
  1652.             function geral(params, dados){
  1653.                 
  1654.                 let vetTotaisPorLinha = {
  1655.                     name: "Número de vitórias por tentativa",
  1656.                     valueXField: "qtdVitorias",
  1657.                     categoryYField: "linha",
  1658.                     categoryField: "linha",
  1659.                     qtdTotalLinhas: 6,
  1660.                     dados: []
  1661.                 };
  1662.                 let vetDadosGraficos = [];
  1663.                 let countWin = 0;
  1664.                 let countLose = 0;
  1665.                 
  1666.                 vetTotaisPorLinha.dados.push(
  1667.                     {
  1668.                         linha: 1,
  1669.                         qtdVitorias: 0
  1670.                     },{
  1671.                         linha: 2,
  1672.                         qtdVitorias: 0
  1673.                     },{
  1674.                         linha: 3,
  1675.                         qtdVitorias: 0
  1676.                     },{
  1677.                         linha: 4,
  1678.                         qtdVitorias: 0
  1679.                     },{
  1680.                         linha: 5,
  1681.                         qtdVitorias: 0
  1682.                     },{
  1683.                         linha: 6,
  1684.                         qtdVitorias: 0
  1685.                     }
  1686.                 );
  1687.                 
  1688.                 for(x in dados){
  1689.                     let historico = dados[x].historico;
  1690.                     let idLinha = 0;
  1691.                     for(y in historico.params){                    
  1692.                         let p = dados[x].historico.params[y];
  1693.                         if(p.label == 'linha'){
  1694.                             idLinha = p.value + 1;
  1695.                         }
  1696.                     }
  1697.                     
  1698.                     let idxLinha = vetTotaisPorLinha.dados.findIndex(e => e.linha == idLinha);
  1699.                     vetTotaisPorLinha.dados[idxLinha].qtdVitorias++;
  1700.                     
  1701.                     (historico.resultado == 'venceu')
  1702.                         ? countWin++
  1703.                         : countLose++;                        
  1704.                 }
  1705.                 
  1706.                 vetDadosGraficos.push({
  1707.                     category: "Vitórias",
  1708.                     value: countWin
  1709.                 });
  1710.                 
  1711.                 vetDadosGraficos.push({
  1712.                     category: "Derrotas",
  1713.                     value: countLose
  1714.                 });
  1715.                 $("#divGeralTotais").html("Você jogou o total de " + (countWin + countLose) + " partidas");
  1716.                 jogo.__GraficosAbaGeral1(params, vetDadosGraficos, vetTotaisPorLinha, dados);
  1717.             }            
  1718.             
  1719.             geral(params, dados);
  1720.             
  1721.             jogo.__MontaDadosPorNivel(params, dados);
  1722.             
  1723.             jogo.__MontaDadosTabela(params, dados);
  1724.         },
  1725.         
  1726.         __viewDesempenhoPC(params, dados){
  1727.             function geral(params, dados){
  1728.                 
  1729.                 let vetDadosGraficos = [];
  1730.                 let countWin = 0;
  1731.                 let countLose = 0;
  1732.                 
  1733.                 for(x in dados){
  1734.                     let historico = dados[x].historico;
  1735.                     (historico.resultado == 'venceu')
  1736.                         ? countWin++
  1737.                         : countLose++;                        
  1738.                 }
  1739.                 
  1740.                 vetDadosGraficos.push({
  1741.                     category: "Completas",
  1742.                     value: countWin
  1743.                 });
  1744.                 
  1745.                 vetDadosGraficos.push({
  1746.                     category: "Incompletas",
  1747.                     value: countLose
  1748.                 });
  1749.                 $("#divGeralTotais").html("Você jogou o total de " + (countWin + countLose) + " partidas");
  1750.                 jogo.__GraficosAbaGeral1(params, vetDadosGraficos, null, dados);
  1751.             }      
  1752.             
  1753.             params.label1 = "Completas";
  1754.             params.label2 = "Incompletas";
  1755.             
  1756.             geral(params, dados);
  1757.             
  1758.             jogo.__MontaDadosPorNivel(params, dados);
  1759.             
  1760.             jogo.__MontaDadosTabela(params, dados);
  1761.         },
  1762.         
  1763.         viewDesempenho: function(){
  1764.             
  1765.             $('.tabHome').show();
  1766.             
  1767.             let modal = document.querySelector(".desempenho");
  1768.             
  1769.             $("#idTitle1NomeJogo").html(jogo.historicoDesempenho.info.nome);
  1770.                 
  1771.             if(jogo.historicoDesempenho.info.nome == 'Forca'){
  1772.                 jogo.__viewDesempenhoForca(modal, jogo.historicoDesempenho.dados);
  1773.             }
  1774.             
  1775.             if(jogo.historicoDesempenho.info.nome == "Palavra Escondida"){
  1776.                 jogo.__viewDesempenhoPE(modal, jogo.historicoDesempenho.dados);
  1777.             }
  1778.             
  1779.             if(jogo.historicoDesempenho.info.nome == "Palavras Cruzadas"){
  1780.                 jogo.__viewDesempenhoPC(modal, jogo.historicoDesempenho.dados);
  1781.             }
  1782.             
  1783.             setTimeout(function(){
  1784.                 let posContent = document.getElementById('idDivPosContentDesempenho');
  1785.                 let posBody = document.getElementById('idDivPosBodyDesempenho');
  1786.                 
  1787.                 let t1 = posContent.getBoundingClientRect().height;
  1788.                 let t2 = posBody.getBoundingClientRect().top;
  1789.                 let t3 = t1 - t2;
  1790.                 
  1791.                 posBody.style.maxHeight = t3 + "px";
  1792.             }, 50);
  1793.         },
  1794.         
  1795.         btnShowHideDesempenho: function(){
  1796.             let modal = document.querySelector(".desempenho");
  1797.             modal.style.display = 
  1798.                 (modal.style.display == 'block')
  1799.                 ? 'none'
  1800.                 : 'block';
  1801.                 
  1802.             if(modal.style.display == 'block'){                
  1803.                 jogo.viewDesempenho();
  1804.             }
  1805.         },
  1806.         
  1807.         btnShowHideExtrato: function(){
  1808.             let modal = document.querySelector(".extrato");
  1809.             modal.style.display = 
  1810.                 (modal.style.display == 'block')
  1811.                 ? 'none'
  1812.                 : 'block';
  1813.         },
  1814.         
  1815.         __showEndGame: function(venceu, msg){
  1816.             let j = jogo.getRegras(venceu ? 'vencer' : 'perder');
  1817.             let texto = "";
  1818.             
  1819.             let titulo = "Parabéns";
  1820.             let icone = 'success';
  1821.             if(venceu){
  1822.                 texto = "Parabéns, conseguiu vencer o jogo.";
  1823.                 if(msg){
  1824.                     texto+='<hr>' + msg + '<hr>Ganhou ';
  1825.                 } else {
  1826.                     texto+=' e ganhou ';
  1827.                 }
  1828.                 jogo.setEstatisticas('vencer','Você venceu o jogo');                
  1829.                 if(j.moedas > 0){
  1830.                     texto+= j.moedas + " moedas!";
  1831.                 }
  1832.             } else {
  1833.                 jogo.setEstatisticas('perder','Você perdeu o jogo');
  1834.                 icone = 'error';
  1835.                 titulo = "Não foi desta vez";
  1836.                 texto = "Fim de Jogo! ";
  1837.                 if(msg){
  1838.                     texto+='<hr>' + msg + '<hr>';
  1839.                 }
  1840.                 /*if(j.pontos && j.pontos > 0){
  1841.                     texto+= "Perdeu " + j.pontos + " pontos";
  1842.                     if(j.moedas && j.moedas > 0){
  1843.                         texto+= " e " + j.moedas + " moedas!";
  1844.                     }                
  1845.                 } else { */
  1846.                     if(j && j.moedas && j.moedas > 0){
  1847.                         texto+= "Perdeu " + j.moedas + " moedas!";
  1848.                     }
  1849.                 //}
  1850.             }
  1851.             
  1852.             $.ajax({
  1853.                 url: '/api/jogos/controle/historico',
  1854.                 dataType: 'json',
  1855.                 type: 'POST',
  1856.                 data: {
  1857.                     estatistica: JSON.stringify(jogo.consolidacao),
  1858.                     idModelo: jogo.modelo.idModelo
  1859.                 },
  1860.                 success: function (j){
  1861.                     jogo.historicoDesempenho.dados.push(j.dados);
  1862.                 }
  1863.             });
  1864.             
  1865.             let m = 0;
  1866.             let p = 0;
  1867.             let a = '';
  1868.             if(j && j.moedas && j.moedas > 0){
  1869.                 m = j.moedas;
  1870.             }
  1871.             
  1872.             if(j && j.pontos && j.pontos > 0){
  1873.                 p = j.pontos;
  1874.             }
  1875.             
  1876.             if(j && j.acao){
  1877.                 a = j.acao;
  1878.             }
  1879.             
  1880.             return {
  1881.                 'titulo': titulo,
  1882.                 'texto': texto,
  1883.                 'pontos': m,
  1884.                 'moedas': p,
  1885.                 'acao' : a,
  1886.                 'icone': icone
  1887.             }
  1888.         },        
  1889.         
  1890.         __showEndGameFixed: function(dd, extrato){
  1891.             
  1892.             let param = {
  1893.                 title: dd.titulo,
  1894.                 html: dd.texto + extrato,                
  1895.                 showCancelButton: true,
  1896.                 confirmButtonText: 'Novo jogo',                    
  1897.                 cancelButtonText: 'Ir para o menu de jogos',
  1898.                 allowOutsideClick: false
  1899.             };
  1900.             
  1901.             if(dd.icone == 'success'){
  1902.                 param.iconHtml = '<img src="/img/trophy.png" style="width: 100%;">';
  1903.             } else {
  1904.                 //param.icon = dd.icone
  1905.                 param.iconHtml = '<img src="/img/trophy.png" style="width: 100%;" class="derrota">';
  1906.             }
  1907.             
  1908.             Swal.fire(param).then((result) => {                
  1909.                 if(result.isConfirmed){                    
  1910.                     sendMsg({
  1911.                         "acao":"reload",
  1912.                         "jogo": jogo
  1913.                     });
  1914.                 } else {
  1915.                     jogo.__showEndGameFixed(dd, extrato);   
  1916.                     sendMsg({"acao":"menuDeJogos"});
  1917.                 }
  1918.             });
  1919.         },
  1920.         
  1921.         showEndGame: function(venceu, msg){
  1922.             
  1923.             jogo.aplicaRegras(venceu ? 'vencer' : 'perder');
  1924.             let time = venceu ? 600 : 800;
  1925.             
  1926.             setTimeout(function(){
  1927.                 jogo.consolidacao = jogo.getConsolidacao(venceu);
  1928.             
  1929.                 let extrato = '<hr><div onclick="jogo.viewExtrato()" style="color: #aa7240;margin-top: 1em;"><i class="fa-solid fa-receipt"></i> Extrato do jogo</div>';
  1930.             
  1931.                 let dd = jogo.__showEndGame(venceu, msg);
  1932.                 jogo.__showEndGameFixed(dd, extrato);                
  1933.             }, time);
  1934.         },
  1935.         
  1936.         callbackQuestion: function(){
  1937.             /*
  1938.                 Ajuda A - resolver a palavra (valor = 15)   
  1939.                 Ajuda B - exibir todas as letras que faltam para completar o tabuleiro (valor = 10)  
  1940.                 Ajuda C - mostrar no tabuleiro a letra (?) (jogador escolhe uma letra das que apareceram na dica F (valor = 5)  
  1941.             */
  1942.             if(!jogo.regras){
  1943.                 alert('Não foi definido os parametros para o nivel ' + jogo.modelo.nivel);
  1944.                 return;
  1945.             }
  1946.            
  1947.             let r = jogo.regras.filter(e => e.tpRegra == 'ajuda');
  1948.             
  1949.             let h = '<div id="idDivAreaQuestion">';
  1950.             h+= '<table><tbody>'; 
  1951.             h+= '<tr>';
  1952.                 h+= '<td valign="top">Você tem ' + jogo.saldo + ' moedas em créditos <br><img src="/img/tesouro.png" style="width: 100px;"  class="btnAssistirVideo"><p class="btnAssistirVideo" onclick="assistirVideo(\'video\')">' + faVideoYellow + '</p></td>';
  1953.                 h+= '<td>&nbsp;</td>';
  1954.                 h+= '<td style="text-align:center">';
  1955.                     h+= 'Escolha uma das opções abaixo';
  1956.                     h+= '<hr />';
  1957.                     for(let x in r){
  1958.                         let m = parseInt(r[x].moedas);
  1959.                         icone = '';
  1960.                         switch(r[x].parametro){
  1961.                             case 'exibir_todas_letras':
  1962.                                 icone = faExibirTodasAsLetras; 
  1963.                                 break;
  1964.                                 
  1965.                             case 'mostrar_no_tabuleiro_letra':  
  1966.                                 icone = faMostrarNoTabuleiro;
  1967.                                 break;
  1968.                                 
  1969.                             case 'resolver_palavra':
  1970.                                 icone = faResolverPalavra;
  1971.                                 break;
  1972.                                 
  1973.                             case 'exibir_dica':
  1974.                                 icone = faDica;
  1975.                                 break;  
  1976.                         }
  1977.                         
  1978.                         if(jogo.checkClickAjuda(r[x].parametro)){
  1979.                             
  1980.                             if(m <= jogo.saldo){        
  1981.                                 h+='<button class="btn btn-primary btn-sm" style="margin: 2px;" onclick="jogo.setEstatisticas(\'' + r[x].parametro + '\'); ' + r[x].parametro + '()"><table style="width: 10em;"><tr><td>' + icone + '</td><td>' + r[x].nome + ' por ' + r[x].moedas + ' moedas</td></tr></table></button>';
  1982.                             } else {
  1983.                                 h+='<button class="btn btn-warning btn-sm btnAssistirVideo" style="margin: 2px;" onclick="assistirVideo(\'' + r[x].parametro + '\')">                                 <table style="width: 10em;"><tr><td>' + faVideo + '<br>' + icone + '</td><td>' + r[x].nome + ' por ' + r[x].moedas + ' moedas</td></tr></table></button>';
  1984.                             }
  1985.                         } else {
  1986.                             h+='<button disabled class="btn btn-primary btn-sm" style="margin: 2px;"><table style="width: 10em;"><tr><td>' + icone + '</td><td>' + r[x].nome + ' por ' + r[x].moedas + ' moedas</td></tr></table></button>';
  1987.                         }
  1988.                     }
  1989.                     
  1990.                 h+='</td>';
  1991.                 h+='</tr>';
  1992.                 h+='</table>';
  1993.                 h+='<hr>';
  1994.                 h+='<div style="text-align:center;width: 100%;">';
  1995.                     h+='<button onclick="jogo.btnDesempenho()" class="btn btn-primary btn-sm" style="margin-right: 1em; padding-bottom: 0.5em;">' + faChartLine + '</button>';
  1996.                     h+='<button onclick="jogo.btnReload()" class="btn btn-primary btn-sm" style="margin-right: 1em; padding-bottom: 0.5em;">' + faRotate + '</button>';
  1997.                     h+='<button onclick="jogo.btnViewRegras()" class="btn btn-primary btn-sm"  style="margin-right: 1em; padding-bottom: 0.5em;">' + faPenToSquare + '</button>';
  1998.                     h+='<button onclick="jogo.btnConfig()" class="btn btn-primary btn-sm" style="padding-bottom: 0.5em;">' + faGears + '</button>';
  1999.                 h+='</div>';
  2000.                 h+='</div>';
  2001.                 
  2002.                 h+='<div id="idDivAreaRegras" style="display:none">';
  2003.                     h+='<div id="idDivAreaRegrasRegras" style="font-size: 0.8em;"></div>';
  2004.                     h+='<hr>';
  2005.                     h+='<div style="text-align:center;width: 100%;">';
  2006.                         h+='<div id="idDivAreaRegrasBtn">';
  2007.                             h+='<button onclick="jogo.btnViewOpcoes()" class="btn btn-warning btn-sm">Exibir opções do jogo</button>';
  2008.                         h+='</div>';
  2009.                     h+='</div>';
  2010.                 h+='</div>';                
  2011.             Swal.fire({
  2012.                 title: '<strong>Precisando de ajuda?</strong>',        
  2013.                 html: h,
  2014.                 showConfirmButton: false,
  2015.                 showCloseButton: false,
  2016.                 showCancelButton: true,
  2017.                 focusConfirm: false,
  2018.                 cancelButtonText: 'Voltar ao jogo',
  2019.                 cancelButtonAriaLabel: 'Voltar ao jogo',
  2020.                 allowOutsideClick: false
  2021.             });
  2022.             
  2023.             
  2024.             if(jogo.checkIsCanViewVideo()){
  2025.                 $(".btnAssistirVideo").removeClass("btnAssistirVideoDisabled");
  2026.             } else {
  2027.                 $(".btnAssistirVideo").addClass("btnAssistirVideoDisabled");
  2028.             }
  2029.             
  2030.         },
  2031.         
  2032.         getDescritivoRegra: function(param, eof){
  2033.             let r = jogo.getRegras(param);
  2034.             if(!eof){
  2035.                 eof = "";
  2036.             }
  2037.             if(r){
  2038.                 let gp = r.acao == "add" ? "ganha" : "paga";
  2039.                 
  2040.                 
  2041.                 if(r.moedas > 0){
  2042.                     return r.nome + " - " + gp + " " + r.moedas + " moedas" + eof;                    
  2043.                 } 
  2044.                 /*
  2045.                 if(r.moedas > 0 || r.pontos > 0){
  2046.                     if(r.moedas > 0 && r.pontos > 0){
  2047.                         return r.nome + " - " + gp + " " + r.pontos + " pontos e " + r.moedas + " moedas" + eof;
  2048.                     } else if(r.moedas > 0){
  2049.                         return r.nome + " - " + gp + " " + r.moedas + " moedas" + eof;
  2050.                     } else {
  2051.                         return r.nome + " - " + gp + " " + r.pontos + " pontos" + eof;
  2052.                     }
  2053.                 } */
  2054.             }
  2055.             return '';
  2056.         },
  2057.         
  2058.         btnConfig: function(){
  2059.             let html = '<div class="form-group">';
  2060.                 html+=  '<select data-id="' + jogo.idJogo + '" class="form-select selNivelJogos">';
  2061.                 j = jogo.modelo;
  2062.                 for(x in j.niveis){
  2063.                     html+= '<option value="' + j.niveis[x].id + '" ' + (j.niveis[x].id == j.nivel ? 'selected' : '') + '>';
  2064.                     html+= j.niveis[x].label;
  2065.                     html+= '</option>';
  2066.                 }
  2067.                 html+='</select>';
  2068.                 html+='</div>';
  2069.                     
  2070.             isAltConfig = false;
  2071.             Swal.fire({
  2072.                 title: '<strong>Configurações</strong>',
  2073.                 html: html,
  2074.                 showConfirmButton: true,
  2075.                 showCloseButton: false,
  2076.                 showCancelButton: false,
  2077.                 focusConfirm: false,
  2078.                 confirmButtonText:  'Voltar ao jogo',
  2079.                 allowOutsideClick: false                      
  2080.             }).then(() => {
  2081.                 
  2082.                 if(isAltConfig){
  2083.                     Swal.fire({
  2084.                         icon: 'warning',
  2085.                         title: 'Aguarde, carregando novos dados',
  2086.                         showConfirmButton: false,
  2087.                         allowOutsideClick: false
  2088.                     });                                           
  2089.                 } else {
  2090.                     if(isObrigatorioTrocarDeNivel){
  2091.                         this.obrigatorioTrocarDeNivel();
  2092.                     }
  2093.                 }
  2094.             });
  2095.             
  2096.             $(".selNivelJogos").change(function(){
  2097.                 isAltConfig = true;
  2098.                 Swal.close();                
  2099.                 $.ajax({
  2100.                     url: '/api/perfil/configuracoes/jogo/' + jogo.idJogo + '/setnivel',
  2101.                     dataType: 'json',
  2102.                     type: 'POST',
  2103.                     data: {
  2104.                         nivel: $(this).val()
  2105.                     },
  2106.                     success: function(e){
  2107.                         isObrigatorioTrocarDeNivel = false;
  2108.                         Swal.fire({
  2109.                             icon: 'success',
  2110.                             title: 'Nível alterado com sucesso'
  2111.                         }).then(() => {
  2112.                             sendMsg({
  2113.                                 "acao": "reloaddados",
  2114.                                 "idJogo": jogo.idJogo,
  2115.                                 "novasPalavras": e.palavras                                
  2116.                             });
  2117.                         });
  2118.                     }
  2119.                 })
  2120.             });
  2121.             $(".checkConfiguracoes").click(function(){
  2122.                 $.ajax({
  2123.                     url: '/api/perfil/configuracoes/jogo/' + jogo.idJogo + '/setcategoria',
  2124.                     dataType: 'json',
  2125.                     type: 'POST',
  2126.                     data: {
  2127.                         id: $(this).val(),
  2128.                         checked: $(this).prop('checked')
  2129.                     },
  2130.                     success: function (j){
  2131.                         isAltConfig = true;
  2132.                         let ok = j.isCheck == 'yes';
  2133.                         $(".checkConfiguracoes[value='" + j.idCat + "']").prop('checked', ok);
  2134.                     }
  2135.                 });
  2136.             });
  2137.         },
  2138.         
  2139.         btnReload: function(){
  2140.             
  2141.             Swal.close();
  2142.             Swal.fire({
  2143.                 title: '<strong>Tem certeza que deseja iniciar novo jogo?</strong>',                        
  2144.                 icon: 'info',
  2145.                 showConfirmButton: true,
  2146.                 showCloseButton: false,
  2147.                 showCancelButton: true,
  2148.                 focusConfirm: false,
  2149.                 confirmButtonText:  'Reiniciar jogo',
  2150.                 confirmButtonAriaLabel: 'Reiniciar jogo',
  2151.                 cancelButtonText: 'Voltar ao jogo',
  2152.                 cancelButtonAriaLabel: 'Voltar ao jogo',
  2153.                 allowOutsideClick: false
  2154.             }).then((result) => {
  2155.                 if (result.isConfirmed) {
  2156.                     
  2157.                     jogo.consolidacao = jogo.getConsolidacao(false);
  2158.                     jogo.__showEndGame(false, '');
  2159.                     
  2160.                     sendMsg({
  2161.                         "acao": "reload",
  2162.                         "jogo": jogo
  2163.                     });
  2164.                 }
  2165.             });
  2166.         },
  2167.         
  2168.         btnDesempenho: function(){
  2169.             jogo.btnShowHideDesempenho();            
  2170.         },
  2171.         
  2172.         btnViewRegras: function(){
  2173.             $("#idDivAreaQuestion").hide('slow');
  2174.             $("#idDivAreaRegras").show('slow');         
  2175.             let nj = jogo.getRegras('novo_jogo');
  2176.             let jogoVencer = jogo.getRegras('vencer');
  2177.             let jogoPerder = jogo.getRegras('perder');
  2178.             let h = "";
  2179.             
  2180.             h+="<span style='font-weight: bold;'>Ganhos e perdas de moedas</span>";
  2181.             h+="<div style='text-align:justify'>";
  2182.             h+= "Ao iniciar a partida você paga " + nj.moedas + " moedas, mas se vencer a partida, irá ganhar " + jogoVencer.moedas + " moedas<br>";
  2183.             if(jogoPerder && jogoPerder.moedas > 0){
  2184.                 h+= "Se perder a partida, isso irá lhe custar " + jogoPerder.moedas + " moedas.";
  2185.             }
  2186.             
  2187.             h+="</div>";
  2188.             
  2189.             let lCerta = jogo.getDescritivoRegra('letra_certa');
  2190.             let lErrado = jogo.getDescritivoRegra('letra_errada');
  2191.             if(lCerta != '' || lErrado != '')
  2192.             {
  2193.                 h+="<hr />";
  2194.                 h+="<span style='font-weight: bold;'>Regras ao clicar no teclado</span>";
  2195.                 h+="<div style='text-align:center'>";
  2196.                 h+= jogo.getDescritivoRegra('letra_certa', '<br>');
  2197.                 h+= jogo.getDescritivoRegra('letra_errada', '<br>');                
  2198.                 h+="</div>";
  2199.             }
  2200.             h+="<hr />";
  2201.             h+="<span style='font-weight: bold;'>Regras referente as ajudas do jogo</span>";
  2202.             h+="<div style='text-align:center'>";
  2203.             h+= jogo.getDescritivoRegra('exibir_todas_letras', '<br>');
  2204.             h+= jogo.getDescritivoRegra('exibir_dica', '<br>');
  2205.             h+= jogo.getDescritivoRegra('resolver_palavra', '<br>');
  2206.             h+= jogo.getDescritivoRegra('mostrar_no_tabuleiro_letra', '<br>');
  2207.             h+="</div>";
  2208.             
  2209.             
  2210.             $("#idDivAreaRegrasRegras").html(h);            
  2211.         },
  2212.         
  2213.         btnViewOpcoes: function(){
  2214.             $("#idDivAreaQuestion").show('slow');
  2215.             $("#idDivAreaRegras").hide('slow');
  2216.         },
  2217.         
  2218.         alertAlteracaoConfiguracoes: function(){
  2219.             Swal.fire({
  2220.                 title: '<strong>Aviso</strong>',
  2221.                 html: '<p>Você realizou alterações nas configurações do jogo</p>',
  2222.                 showConfirmButton: true,
  2223.                 showCloseButton: false,
  2224.                 showCancelButton: true,
  2225.                 focusConfirm: false,
  2226.                 confirmButtonText:  '<i class="fa fa-thumbs-up"></i> Quero um novo jogo com as novas configurações!',
  2227.                 confirmButtonAriaLabel: ' <i class="fa fa-thumbs-up"></i> Quero um novo jogo com as novas configurações!',
  2228.                 cancelButtonText: 'Quero voltar ao jogo que estava',
  2229.                 cancelButtonAriaLabel: 'Quero voltar ao jogo que estava',
  2230.                 allowOutsideClick: false
  2231.             }).then((result) => {
  2232.                 if (result.isConfirmed) {
  2233.                     sendMsg({
  2234.                         "acao": "reload",
  2235.                         "jogo": jogo
  2236.                     }); 
  2237.                 }
  2238.             })
  2239.         },
  2240.         
  2241.         showAlertHelp: function(nivel){
  2242.             let c = '';
  2243.             switch(nivel){
  2244.                 case 1: c = 'pulse'; break;
  2245.                 case 2: c = 'tremor'; break;
  2246.                 case 3: 
  2247.                     
  2248.                     
  2249.                     
  2250.                     h = "Você pode pedir ajuda sempre que precisar, basta clicar no icone <div id='idDivInfoAjuda'><span onclick='jogo.callbackQuestion()' class='questionTop'><span>?</span></span></div>";
  2251.                     Swal.fire({
  2252.                         title: '<strong>É sua última chance, que tal uma ajuda?</strong>',        
  2253.                         html: h,
  2254.                         showConfirmButton: true,
  2255.                         showCloseButton: false,
  2256.                         showCancelButton: true,
  2257.                         focusConfirm: false,
  2258.                         confirmButtonText:  '<i class="fa fa-thumbs-up"></i>Pedir ajuda!',
  2259.                         confirmButtonAriaLabel: ' <i class="fa fa-thumbs-up"></i>Pedir ajuda!',
  2260.                         cancelButtonText: 'Não, eu consigo sozinho',
  2261.                         cancelButtonAriaLabel: 'Não, eu consigo sozinho',
  2262.                         allowOutsideClick: false
  2263.                     }).then((result) => {
  2264.                         if (result.isConfirmed) {                
  2265.                             jogo.callbackQuestion();
  2266.                         }
  2267.                     });
  2268.                     break;
  2269.             }
  2270.             
  2271.             $("#idDivInfoAjuda .questionTop").addClass(c);
  2272.             setTimeout(function(){
  2273.                 $("#idDivInfoAjuda .questionTop").removeClass(c);
  2274.             }, 4000);
  2275.         },
  2276.         
  2277.         checkIsCanViewVideo: function(){
  2278.             
  2279.             return jogo.isCanViewVideoRewardedInterstitial || jogo.isCanViewVideoRewarded;
  2280.             
  2281.             
  2282.             if(jogo.isCanViewVideoRewardedInterstitial == true
  2283.             || jogo.isCanViewVideoRewarded == true
  2284.             || jogo.isCanViewVideoInterstitial == true){
  2285.                 return true;
  2286.             } else {
  2287.                 return false;
  2288.             }
  2289.         }
  2290.     }
  2291.     
  2292.     const run = function(v){
  2293.         if(!controleStartJogo){
  2294.             $.ajaxSetup({
  2295.                 headers:{ 'X-AUTH-TOKEN': token }
  2296.             });
  2297.             controleStartJogo = true;
  2298.             
  2299.             $("#idDivTabuleiro").html("");
  2300.             $("#idDivDica").html("");
  2301.             if(jogo.desafioDiario > 0){
  2302.                 $.ajax({
  2303.                     url: '/api/jogos/controle/getDesafiodiario/' + jogo.desafioDiario,
  2304.                     dataType: 'json',
  2305.                     type: 'GET',
  2306.                     beforeSend: function(){
  2307.                         Swal.fire({
  2308.                             title: 'Aguarde',
  2309.                             icon: 'warning',
  2310.                             html: '<p>Carregando desafio diario.</p>',
  2311.                             showConfirmButton: false,
  2312.                             showCloseButton: false,
  2313.                             showCancelButton: false,
  2314.                             allowOutsideClick: false,
  2315.                             focusConfirm: false,
  2316.                         });
  2317.                     },
  2318.                     success: function (v){
  2319.                         let r = init(v);
  2320.                         jogo.desafioDiario = 0;
  2321.                         jogo.configure(r.idJogo, r.json, r.dados);
  2322.                         Swal.close();
  2323.                         if (v.configUser) {
  2324.                             jogo.configUser = v.configUser;
  2325.                         }
  2326.                     }
  2327.                 });
  2328.             } else {
  2329.                 let r = init(v);
  2330.                 jogo.configure(r.idJogo, r.json, r.dados);
  2331.                 if (v.configUser) {
  2332.                     jogo.configUser = v.configUser;
  2333.                 }
  2334.             }
  2335.         }
  2336.     }
  2337.     
  2338.     const receiveMsg = function (j){
  2339.         let localSaldo = 0;
  2340.         let localPontos = 0;
  2341.         switch(j.funcao){
  2342.             case 'errorAnuncio':
  2343.                 $.ajax({
  2344.                     url: '/api/jogos/controle/log',
  2345.                     data:{
  2346.                         'tipo': j.tipo
  2347.                     },
  2348.                     dataType: 'json',                    
  2349.                 });
  2350.                 break;
  2351.             
  2352.             case 'setSaldo':
  2353.                 if(isViewAnuncio) {
  2354.                     Swal.close();
  2355.                     isViewAnuncio = false;
  2356.                 }
  2357.                 localSaldo = parseInt(j.saldo)
  2358.                 jogo.saldo = isNaN(localSaldo) ? 0 : localSaldo;
  2359.                 if(j.metodo != "" && typeof eval(j.metodo) == "function" && j.metodo != "video"){
  2360.                     setTimeout(function(){
  2361.                         eval(j.metodo + "()");
  2362.                         jogo.setEstatisticas(j.metodo);
  2363.                     }, 100);
  2364.                 }
  2365.                 break;
  2366.             
  2367.             case 'setSaldoPontos':
  2368.                 localSaldo = parseInt(j.saldo)
  2369.                 localPontos = parseInt(j.pontos)
  2370.                 jogo.saldo = isNaN(localSaldo) ? 0 : localSaldo;
  2371.                 jogo.pontos = isNaN(localPontos) ? 0 : localPontos;
  2372.                 break;
  2373.                 
  2374.             case 'reload':
  2375.                 Swal.close();
  2376.                 controleStartJogo = false;                
  2377.                 run(j.p);                
  2378.                 break;
  2379.                 
  2380.             case 'viewAlertAlteracaoConfiguracoes':
  2381.                 Swal.close();
  2382.                 setTimeout(function(){
  2383.                     jogo.alertAlteracaoConfiguracoes();
  2384.                 }, 100);
  2385.                 break;
  2386.             case 'videoIndisponivel':
  2387.                 videoIndisponivel();
  2388.                 break;
  2389.             case 'message':
  2390.                 alert(j.message);
  2391.                 break;
  2392.         }
  2393.     }
  2394.     
  2395.     const assistirVideo = function(metodo) {
  2396.         Swal.close();
  2397.         isViewAnuncio = true;
  2398.         sendMsg({
  2399.             "acao": "assistirVideo",
  2400.             "metodo": metodo
  2401.         });
  2402.     }
  2403.     const videoIndisponivel = function(){
  2404.         setTimeout(function(){
  2405.             Swal.fire({
  2406.                 title: '',
  2407.                 icon: 'warning',
  2408.                 html: '<p>No momento não há anúncios disponíveis<hr />Tente mais um pouco, você consegue, acredito em você.</p>',
  2409.                 showConfirmButton: true,
  2410.                 showCloseButton: false,
  2411.                 showCancelButton: false,
  2412.                 allowOutsideClick: false,
  2413.                 focusConfirm: false,
  2414.                 confirmButtonText: '<img src="/img/positive_icon_transparent.png" alt="Confirmar" style="width: 100px; height: 100px; vertical-align: middle;">',
  2415.                 confirmButtonColor: "#fff",
  2416.             });
  2417.             sendMsg({"acao":"loading","exec":"stop"});
  2418.         }, 6000);
  2419.     }
  2420.     const avisoParaAssistirVideoInicioJogo = function (){
  2421.         let h = ''; 
  2422.         h+= '<div>Você tem ' + jogo.saldo + ' moedas de créditos <br><img src="/img/tesouro.png" class="btnAssistirVideo" style="width: 100px;" onclick="assistirVideo(\'video\')"></div></div><hr />';
  2423.         
  2424.         Swal.fire({
  2425.             title: '<strong>Você esta sem moedas suficiente?</strong>',        
  2426.             html: h,
  2427.             showConfirmButton: true,
  2428.             showCloseButton: false,
  2429.             showCancelButton: true,
  2430.             focusConfirm: false,
  2431.             confirmButtonText:  '<i class="fa fa-thumbs-up"></i>Ganhar créditos!',
  2432.             confirmButtonAriaLabel: ' <i class="fa fa-thumbs-up"></i>Ganhar créditos!',
  2433.             cancelButtonText: 'Voltar ao menu de jogos',
  2434.             cancelButtonAriaLabel: 'Voltar ao menu de jogos',
  2435.             allowOutsideClick: false
  2436.         }).then((result) => {
  2437.             if (result.isConfirmed) {                
  2438.                 assistirVideo('video');                
  2439.             } else {
  2440.                 if(result.dismiss && result.dismiss == 'cancel'){
  2441.                     sendMsg({"acao":"menuDeJogos"});
  2442.                 }
  2443.             }
  2444.         });
  2445.     }
  2446.     {% if rota_controler == "jogos"%}
  2447.         let nome_param_storage = getParamStorageJogo(3);
  2448.     
  2449.         async function carregaDados(){
  2450.             let tmptoken = await localStorage.getItem('token');
  2451.             if(tmptoken != "" && tmptoken != null){
  2452.                 token = tmptoken;
  2453.                 jogos = await JSON.parse(localStorage.getItem(nome_param_storage));
  2454.                 jogo.saldo = await localStorage.getItem('saldo');
  2455.                 jogo.bonus = await localStorage.getItem('bonus');
  2456.                 jogo.desafioDiario = 2;
  2457.                 run(jogos);
  2458.                 return true;
  2459.             }
  2460.             return false;
  2461.         }
  2462.         
  2463.         function trocaNivel(idJogo){
  2464.             getDados(idJogo, function(j){
  2465.                 jJogo = j.jogos.findIndex(e => e.id == idJogo);
  2466.                 localStorage.setItem(getParamStorageJogo(idJogo), JSON.stringify(j.jogos[jJogo]));
  2467.                 location.reload();
  2468.             });
  2469.         }
  2470.         
  2471.         function getDados(idJogo, callback){
  2472.             $.ajax({
  2473.                 url: '/api/jogos/controle/getPalavras',
  2474.                 data:{
  2475.                     'idJogos': idJogo
  2476.                 },
  2477.                 dataType: 'json',
  2478.                 success: function (j){
  2479.                     if(typeof callback == 'function'){
  2480.                         callback(j);
  2481.                     }
  2482.                 }
  2483.             });
  2484.         }
  2485.         
  2486.         async function start(idJogo){
  2487.             nome_param_storage = getParamStorageJogo(idJogo);
  2488.             if(!await carregaDados()){            
  2489.                 $.ajax({
  2490.                     url: '/api/login/setUserAnonimo',
  2491.                     data:{
  2492.                         'deviceId': 'web'
  2493.                     },
  2494.                     dataType: 'json',
  2495.                     success: function (j){
  2496.                         token = j.token;
  2497.                         jogo.saldo = j.jogos.saldo;
  2498.                         jogo.bonus = j.jogos.bonusVideo;
  2499.                         jogo.desafioDiario = 2;
  2500.                         run(j.jogos.jogos[idJogo]);
  2501.                         localStorage.setItem('token', j.token);
  2502.                         localStorage.setItem('saldo', j.jogos.saldo);
  2503.                         localStorage.setItem('bonus', j.jogos.bonusVideo);
  2504.                         localStorage.setItem(getParamStorageJogo(1), JSON.stringify(j.jogos.jogos[1]));
  2505.                         localStorage.setItem(getParamStorageJogo(2), JSON.stringify(j.jogos.jogos[2]));
  2506.                         localStorage.setItem(getParamStorageJogo(3), JSON.stringify(j.jogos.jogos[3]));
  2507.                     }
  2508.                 });
  2509.             }
  2510.         }
  2511.                                                                 
  2512.         async function fnJogoWebExcluirPalavras(msg, nome_param_storage){
  2513.             
  2514.             let jogos = await JSON.parse(localStorage.getItem(nome_param_storage));
  2515.             for(x in msg.palavras){
  2516.                 let i = jogos.palavras.findIndex(e => e.palavra == msg.palavras[x].palavra);
  2517.                 if(i > -1){
  2518.                     jogos.palavras[i].usada = true;
  2519.                 }
  2520.             }
  2521.             localStorage.setItem(nome_param_storage, JSON.stringify(jogos));
  2522.         }
  2523.                                                                 
  2524.         function getParamStorageJogo(idJogo){
  2525.             switch(parseInt(idJogo)){
  2526.                 case 1: return 'jogo_palavras_cruzadas'; break;
  2527.                 case 2: return 'jogo_palavra_escondida'; break;
  2528.                 case 3: return 'jogo_forca'; break;
  2529.             }
  2530.             return '';
  2531.         }
  2532.                                                                 
  2533.         function sendMsg(msg){
  2534.             
  2535.             switch(msg.acao){
  2536.                 case 'reloaddados':
  2537.                     idJogo = msg.idJogo;
  2538.                     jJogo = msg.novasPalavras.jogos.findIndex(e => e.id == idJogo);
  2539.                     localStorage.setItem(getParamStorageJogo(idJogo), JSON.stringify(msg.novasPalavras.jogos[jJogo]));
  2540.                     location.reload();
  2541.                     break;
  2542.                 
  2543.                 case 'reload':
  2544.                     controleStartJogo = false;
  2545.                     start();
  2546.                     break;
  2547.                 
  2548.                 case 'excluirPalavras':
  2549.                     fnJogoWebExcluirPalavras(msg, getParamStorageJogo(jogo.idJogo));
  2550.                     break;
  2551.                 
  2552.                 
  2553.                 case 'assistirVideo':
  2554.                     jogo.saldo = parseInt(jogo.saldo) + parseInt(jogo.bonus);
  2555.                     localStorage.setItem('saldo', jogo.saldo);
  2556.                     
  2557.                     $.ajax({
  2558.                         url: '/api/perfil/saldo/add',
  2559.                         type: 'POST',
  2560.                         contentType: 'application/json', // Define o tipo de conteúdo como JSON
  2561.                         data: JSON.stringify({
  2562.                             'saldo': jogo.saldo,
  2563.                             'nome': 'Video assistido',
  2564.                             'add': jogo.bonus,
  2565.                             'tipo': 3
  2566.                         })
  2567.                     });
  2568.                 
  2569.                     break;
  2570.                     
  2571.                 case 'aplicarRegras':
  2572.                     let r = msg.regra;
  2573.                     let param = {};
  2574.                     if(r.acao == 'sub'){
  2575.                         jogo.saldo = parseInt(jogo.saldo) - parseInt(r.moedas);
  2576.                         param.sub = r.moedas;                        
  2577.                     } else {
  2578.                         jogo.saldo = parseInt(jogo.saldo) + parseInt(r.moedas);
  2579.                         param.add = r.moedas;
  2580.                     }
  2581.                     localStorage.setItem('saldo', jogo.saldo);
  2582.                     param.saldo = jogo.saldo;
  2583.                     param.nome = r.nome;
  2584.                     param.tipo = 5;
  2585.                     $.ajax({
  2586.                         url: '/api/perfil/saldo/' + r.acao,
  2587.                         type: 'POST',
  2588.                         contentType: 'application/json', // Define o tipo de conteúdo como JSON
  2589.                         data: JSON.stringify(param)
  2590.                     });
  2591.                     break;
  2592.             }
  2593.         }
  2594.         
  2595.         $("#idDivBottom").css('width', $('.container').innerWidth());
  2596.         
  2597.         let newHeight = $('#idDivBottom').innerHeight() - $('footer').innerHeight();
  2598.         
  2599.         $("#idDivBottom").css('bottom', $('footer').innerHeight());
  2600.         $("#idDivBottom").css('height', newHeight);
  2601.         
  2602.     {% else %}
  2603.         function sendMsg(msg){
  2604.             if(window.ReactNativeWebView){
  2605.                 msg.token = token;
  2606.                 window.ReactNativeWebView.postMessage(JSON.stringify(msg));
  2607.             }
  2608.         }
  2609.         
  2610.         window.addEventListener('message',function(event){
  2611.             let j = event.data;
  2612.             if(typeof receiveMsg === 'function'){
  2613.                 receiveMsg(j);
  2614.             }        
  2615.         },false);
  2616.         document.addEventListener('message',function(event){
  2617.             let j = event.data;
  2618.             if(typeof receiveMsg == 'function'){
  2619.                 receiveMsg(j);
  2620.             }
  2621.         },false);
  2622.         
  2623.     {% endif %}
  2624.         
  2625.         
  2626.     /* calculando a área do jogo */
  2627.     var alturaDaJanela = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
  2628.     var tamanhoDoCabecalho = 1;
  2629.     var alturaCabecalho = document.getElementById('idDivCabecalho').clientHeight;
  2630.     var alturaBottom = document.getElementById('idDivBottom').clientHeight;
  2631.     
  2632.     var alturaJogo = (alturaDaJanela - (alturaBottom + alturaCabecalho)) * .8;
  2633.     
  2634.     $("#idDivJogo").css('height', alturaJogo + 'px');
  2635.     
  2636.     function execIntro(){
  2637.         $.ajax({
  2638.             url: '/api/jogos/controle/viewintro',
  2639.             dataType: 'json',
  2640.             success: function(e){
  2641.                 if(e.view && e.view == 'nok'){
  2642.                     iconeVideo = "<svg xmlns='http://www.w3.org/2000/svg' style='width: 15%;' viewBox='0 0 576 512'><path fill='#ffc107' d='M0 128C0 92.7 28.7 64 64 64H320c35.3 0 64 28.7 64 64V384c0 35.3-28.7 64-64 64H64c-35.3 0-64-28.7-64-64V128zM559.1 99.8c10.4 5.6 16.9 16.4 16.9 28.2V384c0 11.8-6.5 22.6-16.9 28.2s-23 5-32.9-1.6l-96-64L416 337.1V320 192 174.9l14.2-9.5 96-64c9.8-6.5 22.4-7.2 32.9-1.6z'></path></svg>"; 
  2643.                     introJs().setOptions({
  2644.                         nextLabel: 'Próximo',
  2645.                         prevLabel: 'Voltar',
  2646.                         doneLabel: 'Finalizar',
  2647.                         exitOnEsc: false,
  2648.                         skipLabel: '',
  2649.                         steps: [{
  2650.                             title: "Jogos de palavras",
  2651.                             intro: "<p style='text-align:justify'>Vamos conheçer os principais elementos da tela, clique em next para continuar</p>"
  2652.                         }, {
  2653.                             title: "Moedas",
  2654.                             element: document.querySelector('#idDivInfoMoedas'),
  2655.                             intro: "<p style='text-align:justify'>Suas moedas para jogar, elas irão aumentar ou diminuir conforme as regras de cada jogo! Quando suas moedas chegarem a zero, você poderá assistir a um ou mais videos para ganhar moedas e continuar seus jogos. Sempre que visualizar o icone " + iconeVideo + " so clicar para ganhar as moedas</p>"
  2656.                         },{
  2657.                             title: "Nível de dificuldade",
  2658.                             element: document.querySelector('#idDivInfoNivel'),
  2659.                             intro: "<p style='text-align:justify'>O nível do jogo que vôce se encontra. Clique aqui para aumentar ou diminuir o nível do jogo. As possibilidades são: aprendiz, fácil, intermediário, difícil, incrível. São mais de 2500 palavras para você se divertir e testar seus conhecimentos</p>"
  2660.                         },{
  2661.                             title: "Ajuda",
  2662.                             element: document.querySelector('#idDivInfoAjuda'),
  2663.                             intro: "<p style='text-align:justify'>Clique aqui para obter ajuda ao jogo, como dicas, mostrar letras que faltam, completar palavras, entre outras possibilidades!</p>"
  2664.                         },{
  2665.                             title: "Tabuleiro",
  2666.                             element: document.querySelector('#idDivJogo'),
  2667.                             intro: "<p style='text-align:justify'>Tabuleiro onde o jogo acontece, boa diversão!</p>"
  2668.                         }]
  2669.                     }).start();
  2670.                 }
  2671.             }
  2672.         });
  2673.         
  2674.     }
  2675.     execIntro();
  2676. </script>
  2677. {% block javascript %}{% endblock %} 
  2678. </html>