From 1e149f7bb038f14e975d22c92d4616a8f1882114 Mon Sep 17 00:00:00 2001 From: Jeudi Prando Date: Thu, 27 Aug 2020 20:47:13 -0300 Subject: [PATCH] adicionando arquivos do projeto ao repositorio --- src/App.vue | 39 ++++++---- src/components/HelloWorld.vue | 58 --------------- src/components/jvBoard.vue | 39 ++++++++++ src/components/jvCell.vue | 41 +++++++++++ src/main.js | 7 +- src/services/ganhador.js | 31 ++++++++ src/services/posicaoGanhador.js | 10 +++ src/views/jv.vue | 125 ++++++++++++++++++++++++++++++++ 8 files changed, 275 insertions(+), 75 deletions(-) delete mode 100644 src/components/HelloWorld.vue create mode 100644 src/components/jvBoard.vue create mode 100644 src/components/jvCell.vue create mode 100644 src/services/ganhador.js create mode 100644 src/services/posicaoGanhador.js create mode 100644 src/views/jv.vue diff --git a/src/App.vue b/src/App.vue index 55df315..b7b8159 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,28 +1,37 @@ + \ No newline at end of file diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue deleted file mode 100644 index 879051a..0000000 --- a/src/components/HelloWorld.vue +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - diff --git a/src/components/jvBoard.vue b/src/components/jvBoard.vue new file mode 100644 index 0000000..8db31e8 --- /dev/null +++ b/src/components/jvBoard.vue @@ -0,0 +1,39 @@ + + + + + \ No newline at end of file diff --git a/src/components/jvCell.vue b/src/components/jvCell.vue new file mode 100644 index 0000000..af3e69e --- /dev/null +++ b/src/components/jvCell.vue @@ -0,0 +1,41 @@ + + + + + \ No newline at end of file diff --git a/src/main.js b/src/main.js index 63eb05f..bf1adf1 100644 --- a/src/main.js +++ b/src/main.js @@ -1,8 +1,11 @@ import Vue from 'vue' -import App from './App.vue' +import App from './App' Vue.config.productionTip = false new Vue({ - render: h => h(App), + name: 'WebApp', + render: h => h(App) }).$mount('#app') + +// teste git commit -S \ No newline at end of file diff --git a/src/services/ganhador.js b/src/services/ganhador.js new file mode 100644 index 0000000..176c95b --- /dev/null +++ b/src/services/ganhador.js @@ -0,0 +1,31 @@ +const vitorias = [448, 56, 7, 292, 146, 73, 273, 84] +const convertLetra = letra => value => (value == letra ? 1 : 0) +const toBinario = (arr, verificaLetra) => arr.map(verificaLetra).join`` +const haGanhador = valor => element => (element & valor) == element + +import posicaoGanhador from './posicaoGanhador' + +const verificaSe = letra => { + const nessa = partida => parseInt(toBinario(partida, convertLetra(letra)), 2) + return { + ganhou: partida => ({ + ganhou: vitorias.some(haGanhador(nessa(partida))) && letra, + posicaoVitoria: vitorias.filter(haGanhador(nessa(partida))).map(i => posicaoGanhador[i]) + }) + + } +} + +const ganhador = partida => { + const xResult = verificaSe`X`.ganhou(partida) + if(xResult.ganhou) { + return xResult + } else { + const oResult = verificaSe`O`.ganhou(partida) + if(oResult) { + return oResult + } + } +} + +export default ganhador \ No newline at end of file diff --git a/src/services/posicaoGanhador.js b/src/services/posicaoGanhador.js new file mode 100644 index 0000000..aa76cc7 --- /dev/null +++ b/src/services/posicaoGanhador.js @@ -0,0 +1,10 @@ +export default { + 448: ['A1', 'A2', 'A3'], + 56: ['B1', 'B2', 'B3'], + 7:['C1', 'C2', 'C3'], + 292:['A1','B1','C1'], + 146:['A2','B2','C2'], + 73:['A3', 'B3', 'C3'], + 273:['A1','B2','C3'], + 84:['A3','B2','C1'] +} \ No newline at end of file diff --git a/src/views/jv.vue b/src/views/jv.vue new file mode 100644 index 0000000..b73250a --- /dev/null +++ b/src/views/jv.vue @@ -0,0 +1,125 @@ + + + + + \ No newline at end of file