Terminadas funciones en yaku4.kt

master
Araozu 2020-10-21 08:09:31 -05:00
parent 65a792015b
commit c1a3286e1a
5 changed files with 115 additions and 13 deletions

View File

@ -24,6 +24,12 @@ sealed class Carta(val valor: Int) {
fun esCartaVerde() =
valor == 128 || valor == 192 || valor == 224 || valor == 256
fun esCartaRoja() =
(valor in 34..53) || valor == 96
fun esCartaNegra() =
(valor in 2..21) || valor == 64
fun esDragonORey() =
valor == 64 || valor == 96 || valor == 128 || valor == 160 || valor == 192 || valor == 224 || valor == 256

View File

@ -29,6 +29,7 @@ enum class Yaku {
DobleSecuenciaPura
}
// TODO: Recibir como parametro si la mano esta abierta o cerrada y verificar los yakus aqui segun eso
fun Yaku.obtenerListaYakus(contenedorGrupos: ContenedorGrupos): ArrayList<Yaku> {
val listaYakus = ArrayList<Yaku>()
@ -71,8 +72,9 @@ fun Yaku.obtenerListaYakus(contenedorGrupos: ContenedorGrupos): ArrayList<Yaku>
verificarEscalera = false
}
// TODO: Verificar la mano abierta
var verificarTripleTriples = true
if (yakuTripleTriplesCerrados(contenedorGrupos)) {
if (yakuTripleTriples(contenedorGrupos)) {
listaYakus.add(Yaku.TripleTriplesCerrados)
listaYakus.add(Yaku.TripleTriples)
verificarTripleTriples = false

View File

@ -17,10 +17,8 @@ internal fun yakuTripleSecuenciaCerrada(contenedorGrupos: ContenedorGrupos): Boo
return false
}
internal fun yakuTripleTriples(contenedorGrupos: ContenedorGrupos): Boolean {
return false
}
internal fun yakuTripleTriples(contenedorGrupos: ContenedorGrupos) =
contenedorGrupos.tris.size == 3
internal fun yakuInterior(contenedorGrupos: ContenedorGrupos): Boolean {

View File

@ -1,29 +1,127 @@
package dev.araozu.juego.yaku
import dev.araozu.juego.CartaNumero
import dev.araozu.juego.ContenedorGrupos
internal fun yakuSemiExterior(contenedorGrupos: ContenedorGrupos): Boolean {
return false
for (carrl in contenedorGrupos.seqs) {
var terminales = 0
for (c in carrl) {
if (c.esDragonORey() || (c is CartaNumero && c.esExterior())) {
terminales += 1
}
}
if (terminales == 0) return false
}
for (carrl in contenedorGrupos.tris) {
var terminales = 0
for (c in carrl) {
if (c.esDragonORey() || (c is CartaNumero && c.esExterior())) {
terminales += 1
}
}
if (terminales == 0) return false
}
for (carrl in contenedorGrupos.pares) {
for (c in carrl) {
var terminales = 0
if (c.esDragonORey() || (c is CartaNumero && c.esExterior())) {
terminales += 1
}
if (terminales == 0) return false
}
}
return true
}
internal fun yakuRojo(contenedorGrupos: ContenedorGrupos): Boolean {
return false
for (carrl in contenedorGrupos.seqs) {
for (c in carrl) {
if (!c.esCartaRoja()) return false
}
}
for (carrl in contenedorGrupos.tris) {
for (c in carrl) {
if (!c.esCartaRoja()) return false
}
}
for (carrl in contenedorGrupos.pares) {
for (c in carrl) {
if (!c.esCartaRoja()) return false
}
}
return true
}
internal fun yakuNegro(contenedorGrupos: ContenedorGrupos): Boolean {
return false
for (carrl in contenedorGrupos.seqs) {
for (c in carrl) {
if (!c.esCartaNegra()) return false
}
}
for (carrl in contenedorGrupos.tris) {
for (c in carrl) {
if (!c.esCartaNegra()) return false
}
}
for (carrl in contenedorGrupos.pares) {
for (c in carrl) {
if (!c.esCartaNegra()) return false
}
}
return true
}
internal fun yakuTripleCuadruples(contenedorGrupos: ContenedorGrupos): Boolean {
return false
if (contenedorGrupos.tris.size != 3) return false
for (triple in contenedorGrupos.tris) {
if (triple.size != 4) return false
}
return true
}
internal fun yakuEscalera(contenedorGrupos: ContenedorGrupos): Boolean {
return false
if (contenedorGrupos.seqs.size != 3) return false
var primeraCarta = false
var numeroActual = 0
for (carrl in contenedorGrupos.tris) {
for (c in carrl) {
if (c !is CartaNumero) return false
if (!primeraCarta) {
numeroActual = when (c.numero) {
1 -> 2
2 -> 3
else -> return false
}
primeraCarta = true
} else {
if (c.numero != numeroActual) return false
numeroActual += 1
}
}
}
return true
}

View File

@ -52,8 +52,6 @@ internal fun yakuEscaleraFull(contenedorGrupos: ContenedorGrupos): Boolean {
}
}
return false
return true
}
internal fun yakuTripleTriplesCerrados(contenedorGrupos: ContenedorGrupos) =
contenedorGrupos.tris.size == 3