-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
614 additions
and
239 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
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 |
---|---|---|
@@ -1,26 +1,15 @@ | ||
import React from 'react'; | ||
import logo from './logo.svg'; | ||
import './App.css'; | ||
import React,{Component} from 'react' | ||
import Routes from './routes'; | ||
|
||
function App() { | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<p> | ||
Edit <code>src/App.js</code> and save to reload. | ||
</p> | ||
<a | ||
className="App-link" | ||
href="https://reactjs.org" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React | ||
</a> | ||
</header> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; | ||
class App extends Component { | ||
|
||
render() { | ||
|
||
return ( | ||
<Routes/> | ||
); | ||
} | ||
} | ||
|
||
export default App; |
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,103 @@ | ||
import React, { Fragment } from 'react'; | ||
import '../index.css'; | ||
import 'bootstrap/dist/css/bootstrap.min.css'; | ||
import {Button, Alert, ListGroup, Badge} from 'react-bootstrap'; | ||
import {Container} from 'react-bootstrap'; | ||
import Helmet from 'react-helmet'; | ||
import { useAlert } from 'react-alert' | ||
import {Header,Intentos} from './manejadorContenido' | ||
import validateCode from './manejadorContenido' | ||
|
||
class GameConfig extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.number= React.createRef() | ||
this.state = { | ||
intentosA:[], | ||
intentosB:[], | ||
aNumber: null, | ||
bNumber: null, | ||
aIsNext: true, | ||
}; | ||
} | ||
|
||
handeUnblock(){ | ||
let numero= String(this.number.current.value) | ||
if( numero.length !== 4) return false | ||
if(this.state.aIsNext){ | ||
let numbers = this.state.intentosA.map(function(x) { return x['num'] }); | ||
if( numbers.includes(numero)) return false | ||
this.setState({ | ||
intentosA: this.state.intentosA.concat(validateCode(numero,this.state.aIsNext ? this.state.bNumber : this.state.aNumber)), | ||
aIsNext: false, | ||
}); | ||
|
||
} | ||
else{ | ||
let numbers = this.state.intentosA.map(function(x) { return x['num'] }); | ||
if( numbers.includes(numero)) return false | ||
this.setState({ | ||
intentosB:this.state.intentosB.concat(validateCode(numero,this.state.aIsNext ? this.state.bNumber : this.state.aNumber)), | ||
aIsNext: true, | ||
}); | ||
} | ||
|
||
this.number.current.value = '' | ||
} | ||
|
||
handeClick(){ | ||
let numero= String(this.number.current.value) | ||
if(numero.length !== 4) return false | ||
|
||
if(this.state.aIsNext){ | ||
this.setState({ | ||
aNumber: numero, | ||
aIsNext: false, | ||
}); | ||
this.number.current.value = '' | ||
} | ||
else{ | ||
this.setState({ | ||
bNumber: numero, | ||
aIsNext: true, | ||
}); | ||
this.number.current.value = '' | ||
}} | ||
|
||
render() { | ||
let content; | ||
if (this.state.bNumber == null) { | ||
content = | ||
<Fragment> | ||
<input ref={this.number} type="number" max='9999' className="form-control form-control-lg text-center" id="number" aria-describedby="numer" placeholder="Registre su codigo de 4 digitos"></input> | ||
<Button variant='warning' block size="lg" className="text-center mt-4" onClick={() => this.handeClick()}> | ||
Confirmar codigo | ||
</Button> | ||
</Fragment> | ||
} else { | ||
content = | ||
<Fragment> | ||
<input ref={this.number} type="number" max='9999' className="form-control form-control-lg text-center" id="number" aria-describedby="numer" placeholder="Desbloquee el codigo de 4 digitos"></input> | ||
<Button variant='warning' block size="lg" className="text-center mt-4" onClick={() => this.handeUnblock()}> | ||
Desbloquear codigo | ||
</Button> | ||
<Intentos | ||
numbers={ this.state.aIsNext ? this.state.intentosA : this.state.intentosB} | ||
/> | ||
</Fragment> | ||
} | ||
return ( | ||
<Fragment> | ||
<Helmet bodyAttributes={{style: 'background-color : #e497cd'}}/> | ||
<Container> | ||
<Header | ||
value={this.state.aIsNext ? 1 : 2} | ||
/> | ||
{content} | ||
</Container> | ||
</Fragment> | ||
); | ||
} | ||
} | ||
|
||
export default GameConfig; |
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,92 @@ | ||
import React, { Fragment } from 'react'; | ||
import '../index.css'; | ||
import 'bootstrap/dist/css/bootstrap.min.css'; | ||
import {Button, Alert, ListGroup, Badge} from 'react-bootstrap'; | ||
|
||
|
||
export default (intento,objetivo) => { | ||
let res = {num: intento} | ||
|
||
for(let i=0;i<4 ;i++){ | ||
let ok = null | ||
for(let j=0;j<4;j++){ | ||
if((String(intento)[i] == String(objetivo)[j]) && ok == null ){ | ||
if(i == j ) res[i]='success' | ||
else res[i]='warning' | ||
ok= true | ||
} | ||
} | ||
if(ok == null) res[i]='danger' | ||
} | ||
return res | ||
} | ||
|
||
|
||
|
||
function digitos(index){ | ||
|
||
const items = [] | ||
for (let i=0;i<4;i++) { | ||
items.push( | ||
<Badge | ||
style={{ | ||
fontSize:'2rem' | ||
}} | ||
className='m-4 p-4' | ||
variant={index[String(i)]} | ||
>{index['num'][String(i)]} | ||
</Badge> | ||
) | ||
} | ||
return items | ||
} | ||
|
||
|
||
export function Intentos(props) { | ||
|
||
|
||
return ( | ||
<> | ||
<h4 className="text-center digitL display-3 mb-4"> | ||
Intentos: {props.numbers.length} | ||
</h4> | ||
{props.numbers.reverse().map((index) => { | ||
return <ListGroup.Item> | ||
<div | ||
className='text-center digitL number' | ||
style={{ | ||
backgroundColor: '#7581F3' | ||
}} | ||
> | ||
<Badge | ||
style={{ | ||
fontSize:'2rem' | ||
}} | ||
className='m-4 p-4' variant='dark' | ||
><b><h3>{index['num']}</h3></b> | ||
</Badge> | ||
{digitos(index)} | ||
</div> | ||
|
||
</ListGroup.Item> | ||
})} | ||
</> | ||
|
||
) | ||
} | ||
|
||
|
||
export function Header(props) { | ||
return ( | ||
<h2 | ||
style={{ | ||
width:'100%' | ||
}} | ||
className="text-center digitL display-3 mb-4"> | ||
{'Jugador ' + props.value} | ||
</h2> | ||
|
||
); | ||
} | ||
|
||
|
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,57 @@ | ||
import React, { Fragment } from 'react'; | ||
import {Link} from 'react-router-dom'; | ||
// import styles | ||
import '../index.css'; | ||
import 'bootstrap/dist/css/bootstrap.min.css'; | ||
import {Button} from 'react-bootstrap'; | ||
import {Container} from 'react-bootstrap'; | ||
import Helmet from 'react-helmet'; | ||
|
||
function Header(props) { | ||
return ( | ||
<h1 class="text-center digitL display-2 mb-4"> | ||
Digitos | ||
</h1> | ||
|
||
); | ||
} | ||
|
||
function MenuButtons(props) { | ||
|
||
const buttons = ['Jugar','Historial','Instrucciones','Ajustes'].map(( move) => { | ||
return ( | ||
<div class='mb-1'> | ||
<Link to="/GameConfig"> | ||
<Button variant="warning" class='text-center ' size="lg" block> | ||
{move} | ||
</Button> | ||
</Link> | ||
|
||
</div> | ||
|
||
); | ||
}); | ||
return ( | ||
<Fragment> | ||
<Container> | ||
{buttons} | ||
</Container> | ||
</Fragment> | ||
); | ||
} | ||
|
||
class Menu extends React.Component { | ||
|
||
render() { | ||
|
||
return ( | ||
<Fragment> | ||
<Helmet bodyAttributes={{style: 'background-color : #e497cd'}}/> | ||
<Header/> | ||
<MenuButtons/> | ||
</Fragment> | ||
); | ||
} | ||
} | ||
|
||
export default Menu; |
Oops, something went wrong.