-
Notifications
You must be signed in to change notification settings - Fork 2
Multijugador #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Multijugador #7
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,28 +9,71 @@ function Dado() { | |
| } | ||
|
|
||
| function Todito() { | ||
| this.jugar = function () { | ||
| var dado = new Dado(); | ||
|
|
||
| dado.lanzar(); | ||
| definirCastigo(dado.resultado); | ||
| }; | ||
|
|
||
| var castigo = ""; | ||
| var definirCastigo = function (n) { | ||
| switch (n) { | ||
| case 1: | ||
| case 5: | ||
| console.log("Toman todos"); | ||
| castigo = "Toman todos"; | ||
| break; | ||
| case 2: | ||
| case 6: | ||
| console.log("Toma otro"); | ||
| castigo = "Toma otro"; | ||
| break; | ||
| case 3: | ||
| console.log("Toma el de mi derecha"); | ||
| castigo = "Toma el de mi derecha"; | ||
| break; | ||
| case 4: | ||
| console.log("Toma el de mi izquierda"); | ||
| castigo = "Toma el de mi izquierda"; | ||
| break; | ||
| } | ||
| }; | ||
| this.jugar = function () { | ||
| var dado = new Dado(); | ||
| dado.lanzar(); | ||
| definirCastigo(dado.resultado); | ||
| }; | ||
| this.getCastigo = function () { | ||
| return castigo; | ||
| }; | ||
| } | ||
|
|
||
| function Jugador() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Utilizar nivelAlcohol |
||
| var shots = 0; | ||
| this.tomarShot = function () { | ||
| shots++; | ||
| }; | ||
| this.estaEbrio = function () { | ||
| return shots === 10; | ||
| }; | ||
| this.getShots = function () { | ||
| return shots; | ||
| }; | ||
| } | ||
|
|
||
| function Juego(numJugadores) { | ||
| this.jugadores = []; | ||
| var i = 0; | ||
| var j = 0; | ||
| var todito = new Todito(); | ||
| for (i; i < numJugadores; i++) { | ||
| this.jugadores[i] = new Jugador(); | ||
| } | ||
|
|
||
| this.aplicarCastigo = function (castigo, index) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. La función Juego no debe saber sobre reglas específicas del juego, esto le corresponde a cada implementación |
||
| switch (castigo) { | ||
| case "Toman todos": | ||
| for (j; j < this.jugadores.length; j++) { | ||
| this.jugadores[j].tomarShot(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quien hace tomar es Todito
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Todito también debe tener una referencia al Array de jugadores que Juego crea |
||
| } | ||
| break; | ||
| case "Toma otro": | ||
| break; | ||
| case "Toma el de mi derecha": | ||
| index === this.jugadores.length - 1 ? this.jugadores[0].tomarShot() : this.jugadores[index+1].tomarShot(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Esta lógica de izquierda, derecha, debe estar en Todito |
||
| break; | ||
| case "Toma el de mi izquierda": | ||
| index === 0 ? this.jugadores[this.jugadores.length - 1].tomarShot() : this.jugadores[index-1].tomarShot(); | ||
| break; | ||
| } | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lo que deberías medir es el nivelAlcohol