Commit c7f9007f by Yannine Alvarez

Agregar la funciòn verificar las cartas para ganador

parent 13c6becc
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="628f93ca-b7ce-4a63-90a4-4fc67deaa2b5" name="Default Changelist" comment="" /> <list default="true" id="628f93ca-b7ce-4a63-90a4-4fc67deaa2b5" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Poker.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/Poker.kt" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
...@@ -110,24 +113,32 @@ ...@@ -110,24 +113,32 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1587433599286</updated> <updated>1587433599286</updated>
</task> </task>
<option name="localTasksCounter" value="5" /> <task id="LOCAL-00005" summary="Se agrega la rama poker_2 que contiene la función ganador.">
<created>1587433850431</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1587433850431</updated>
</task>
<option name="localTasksCounter" value="6" />
<servers /> <servers />
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value="Unificar en una función para retornar valores en el poker" /> <MESSAGE value="Unificar en una función para retornar valores en el poker" />
<MESSAGE value="corrección de valor de retorno." /> <MESSAGE value="corrección de valor de retorno." />
<MESSAGE value="corrección de valor de retorno, agregar return poker." /> <MESSAGE value="corrección de valor de retorno, agregar return poker." />
<option name="LAST_COMMIT_MESSAGE" value="corrección de valor de retorno, agregar return poker." /> <MESSAGE value="Se agrega la rama poker_2 que contiene la función ganador." />
<option name="LAST_COMMIT_MESSAGE" value="Se agrega la rama poker_2 que contiene la función ganador." />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="413" y="109" key="#com.intellij.refactoring.typeMigration.ui.FailedConversionsDialog" timestamp="1586915044775"> <state x="413" y="109" key="#com.intellij.refactoring.typeMigration.ui.FailedConversionsDialog" timestamp="1586915044775">
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
<state x="413" y="109" key="#com.intellij.refactoring.typeMigration.ui.FailedConversionsDialog/0.0.1366.728@0.0.1366.728" timestamp="1586915044775" /> <state x="413" y="109" key="#com.intellij.refactoring.typeMigration.ui.FailedConversionsDialog/0.0.1366.728@0.0.1366.728" timestamp="1586915044775" />
<state x="313" y="0" key="CommitChangelistDialog2" timestamp="1587433753607"> <state x="313" y="0" key="CommitChangelistDialog2" timestamp="1587433848146">
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
<state x="313" y="0" key="CommitChangelistDialog2/0.0.1366.728@0.0.1366.728" timestamp="1587433753607" /> <state x="313" y="0" key="CommitChangelistDialog2/0.0.1366.728@0.0.1366.728" timestamp="1587433848146" />
<state width="1322" height="145" key="GridCell.Tab.0.bottom" timestamp="1587433392572"> <state width="1322" height="145" key="GridCell.Tab.0.bottom" timestamp="1587433392572">
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
...@@ -160,10 +171,10 @@ ...@@ -160,10 +171,10 @@
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
<state width="1322" height="217" key="GridCell.Tab.1.right/0.0.1366.728@0.0.1366.728" timestamp="1587426755633" /> <state width="1322" height="217" key="GridCell.Tab.1.right/0.0.1366.728@0.0.1366.728" timestamp="1587426755633" />
<state x="275" y="95" key="Vcs.Push.Dialog.v2" timestamp="1587433621528"> <state x="275" y="95" key="Vcs.Push.Dialog.v2" timestamp="1587433858527">
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
<state x="275" y="95" key="Vcs.Push.Dialog.v2/0.0.1366.728@0.0.1366.728" timestamp="1587433621528" /> <state x="275" y="95" key="Vcs.Push.Dialog.v2/0.0.1366.728@0.0.1366.728" timestamp="1587433858527" />
<state x="92" y="92" width="1182" height="544" key="com.intellij.history.integration.ui.views.FileHistoryDialog" timestamp="1587430678418"> <state x="92" y="92" width="1182" height="544" key="com.intellij.history.integration.ui.views.FileHistoryDialog" timestamp="1587430678418">
<screen x="0" y="0" width="1366" height="728" /> <screen x="0" y="0" width="1366" height="728" />
</state> </state>
......
// Repositorio https://phoebe.roshka.com/gitlab/yalvarez/kotlin-e004-poker import java.util.*
const val CARAS = "23456789tjqka" const val CARAS = "23456789tjqka"
const val LETRAS = "shdc" const val LETRAS = "shdc"
//clase carta que recibe el valor y el palo
class Carta(completo: String) { class Carta(completo: String) {
fun valorPalo(): String { fun valorPalo(): String {
return valor + palo return valor + palo
...@@ -17,7 +19,7 @@ class Carta(completo: String) { ...@@ -17,7 +19,7 @@ class Carta(completo: String) {
palo = completo[1].toString() palo = completo[1].toString()
} }
} }
//clase que ordena las cartas
class OrdenarCartas { class OrdenarCartas {
val valores = charArrayOf('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K') val valores = charArrayOf('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')
val palos = charArrayOf('S', 'C', 'H', 'D') val palos = charArrayOf('S', 'C', 'H', 'D')
...@@ -73,7 +75,8 @@ class OrdenarCartas { ...@@ -73,7 +75,8 @@ class OrdenarCartas {
} }
} }
//completar para mostrar la mano ganadora de acuerdo a la clasificacion de jugadas del poker
fun ganador(jugadas: MutableList<Array<Carta?>>): String? { fun ganador(jugadas: MutableList<Array<Carta?>>): String? {
//Imprime la cantidad de jugadas //Imprime la cantidad de jugadas
println("Cantidad de jugadas: " + jugadas.size) println("Cantidad de jugadas: " + jugadas.size)
...@@ -96,13 +99,64 @@ fun ganador(jugadas: MutableList<Array<Carta?>>): String? { ...@@ -96,13 +99,64 @@ fun ganador(jugadas: MutableList<Array<Carta?>>): String? {
if (mejoresManos.size == 1) { if (mejoresManos.size == 1) {
return "Jugada " + (mejoresManos[0] + 1) return "Jugada " + (mejoresManos[0] + 1)
} else { }
//agregar para retomar el ganador en caso de verificar la Carta
val variasManos = ArrayList<Array<Carta>>() return "Error"
}
var mejor = 0
fun verificarCarta(): Array<Carta?>? {
var respuesta: ArrayList<Array<Carta?>?>? = null
if (mejor === 1) {
respuesta = siEsPoker()
} else if (mejor === 2) {
respuesta = siEsFull()
} else if (mejor === 3) {
respuesta = siEsColorYCartaAlta()
} else if (mejor === 4) {
respuesta = siEscalera()
} else if (mejor === 5) {
respuesta = siTrio()
} else if (mejor === 6) {
respuesta = siParDoble()
} else if (mejor === 7) {
respuesta = siPar()
} }
return "jugador 1"
return respuesta!![0]
}
fun siPar(): ArrayList<Array<Carta?>?>? {
//completar
}
fun siParDoble(): ArrayList<Array<Carta?>?>? {
}
fun siEscalera(): ArrayList<Array<Carta?>?>? {
}
fun siTrio(): ArrayList<Array<Carta?>?>? {
}
fun siEsColorYCartaAlta(): ArrayList<Array<Carta?>?>? {
}
fun siEsFull(): ArrayList<Array<Carta?>?>? {
}
fun siEsPoker(): ArrayList<Array<Carta?>?>? {
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment