-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adicionando arquivos do projeto ao repositorio
- Loading branch information
Showing
8 changed files
with
275 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,37 @@ | ||
<template> | ||
<div id="app"> | ||
<img alt="Vue logo" src="./assets/logo.png"> | ||
<HelloWorld msg="Welcome to Your Vue.js App"/> | ||
<a href="https://github.com/jprando/vuejv">projeto no github</a> | ||
<jv></jv> | ||
<span> v0.082.72045 </span> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import HelloWorld from './components/HelloWorld.vue' | ||
import jv from '@/views/jv' | ||
export default { | ||
name: 'App', | ||
components: { | ||
HelloWorld | ||
} | ||
name: 'app', | ||
components: { jv } | ||
} | ||
</script> | ||
|
||
<style> | ||
a { | ||
text-decoration: none; | ||
color: gray; | ||
position: relative; | ||
top: -25px; | ||
} | ||
#app { | ||
font-family: Avenir, Helvetica, Arial, sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
text-align: center; | ||
color: #2c3e50; | ||
margin-top: 60px; | ||
font-family: Courier New, Courier, monospace; | ||
float: left; | ||
margin: 20px; | ||
padding: 50px; | ||
height: 480px; | ||
width: 370px; | ||
max-width: 370px; | ||
max-height: 480px; | ||
min-width: 370px; | ||
min-height: 540px; | ||
background-color: #eef; | ||
} | ||
</style> | ||
</style> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<template> | ||
<div class="board"> | ||
<div class="row"> | ||
<jv-cell v-model="value.A1" @jogar="jogarPartida"></jv-cell> | ||
<jv-cell v-model="value.B1" @jogar="jogarPartida"></jv-cell> | ||
<jv-cell v-model="value.C1" @jogar="jogarPartida"></jv-cell> | ||
</div> | ||
<div class="row"> | ||
<jv-cell v-model="value.A2" @jogar="jogarPartida"></jv-cell> | ||
<jv-cell v-model="value.B2" @jogar="jogarPartida"></jv-cell> | ||
<jv-cell v-model="value.C2" @jogar="jogarPartida"></jv-cell> | ||
</div> | ||
<div class="row"> | ||
<jv-cell v-model="value.A3" @jogar="jogarPartida"></jv-cell> | ||
<jv-cell v-model="value.B3" @jogar="jogarPartida"></jv-cell> | ||
<jv-cell v-model="value.C3" @jogar="jogarPartida"></jv-cell> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import jvCell from './jvCell' | ||
export default { | ||
name: 'jvBoard', | ||
components: { jvCell }, | ||
props: ['value'], | ||
methods: { | ||
jogarPartida(pos) { | ||
this.$emit('jogar', pos) | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
.row { | ||
clear: left; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<template> | ||
<button class="cell" | ||
:class="{ganhou:value.ganhou}" | ||
:disabled="value.exibir" | ||
@click="jogar" > {{ value.exibir }} | ||
</button> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'jvCell', | ||
props: ['value'], | ||
methods: { | ||
jogar() { | ||
this.$emit('jogar', this.value) | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
.cell { | ||
cursor: pointer; | ||
float: left; | ||
border: solid 1px black; | ||
width: 100px; | ||
height: 100px; | ||
text-align: center; | ||
line-height: 100px; | ||
font-size: 60px; | ||
} | ||
.cell:hover { | ||
background-color: #fee; | ||
} | ||
.ganhou { | ||
background-color: #aaffaa; | ||
} | ||
.ganhou:hover { | ||
background-color: #aaffaa; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<template> | ||
<div> | ||
<jv-board v-model="posicoes" @jogar="jogarPartida"></jv-board> | ||
<div class="options"> | ||
<button class="reset" @click="reiniciar">reiniciar</button> | ||
<div style="margin-bottom: 10px"> | ||
<h1> | ||
JOGADOR | ||
{{ vezDe }} | ||
<h1 v-show="alguemGanhou">GANHOU</h1> | ||
</h1> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import jvBoard from '@/components/jvBoard' | ||
import ganhador from '@/services/ganhador' | ||
export default { | ||
name: 'jv', | ||
components: { jvBoard }, | ||
data () { | ||
return { | ||
vezDe: 'X', | ||
alguemGanhou: false, | ||
posicoes: { | ||
A1: { | ||
exibir: null, | ||
ganhou: false | ||
}, | ||
A2: { | ||
exibir: null, | ||
ganhou: false | ||
}, | ||
A3: { | ||
exibir: null, | ||
ganhou: false | ||
}, | ||
B1: { | ||
exibir: null, | ||
ganhou: false | ||
}, | ||
B2: { | ||
exibir: null, | ||
ganhou: false | ||
}, | ||
B3: { | ||
exibir: null, | ||
ganhou: false | ||
}, | ||
C1: { | ||
exibir: null, | ||
ganhou: false | ||
}, | ||
C2: { | ||
exibir: null, | ||
ganhou: false | ||
}, | ||
C3: { | ||
exibir: null, | ||
ganhou: false | ||
} | ||
} | ||
} | ||
}, | ||
computed: { | ||
jogada () { | ||
const getExibir = i => i.exibir | ||
const getValues = value => Object.values(value).map(getExibir) | ||
return getValues(this.posicoes) | ||
}, | ||
}, | ||
methods: { | ||
jogarPartida (pos) { | ||
let vezDeJogar = this.vezDe | ||
let ninguemGanhou = !this.alguemGanhou | ||
if (ninguemGanhou) { | ||
let self = this | ||
pos.exibir = vezDeJogar | ||
const result = ganhador(self.jogada) | ||
self.alguemGanhou = result.ganhou == vezDeJogar | ||
if(self.alguemGanhou) { | ||
if(result.ganhou){ | ||
result.posicaoVitoria.forEach(a => { | ||
a.forEach(i => self.posicoes[i].ganhou = true) | ||
}) | ||
} | ||
} | ||
ninguemGanhou = !self.alguemGanhou | ||
if (ninguemGanhou) { | ||
self.vezDe = vezDeJogar === 'X' ? 'O' : 'X' | ||
} | ||
} | ||
}, | ||
reiniciar () { | ||
const self = this | ||
for (const item in self.posicoes) { | ||
let posicao = self.posicoes[item] | ||
posicao.exibir = null | ||
posicao.ganhou = false | ||
} | ||
self.alguemGanhou = false | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style> | ||
h1 { | ||
margin-bottom: 0px; | ||
margin-top: 0px; | ||
} | ||
.reset { | ||
margin-bottom: 20px; | ||
padding: 20px; | ||
font-size: 15px; | ||
font-family: monospace; | ||
} | ||
.options { | ||
clear: left; | ||
padding-top: 30px; | ||
padding-bottom: 30px; | ||
} | ||
</style> |