Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kotlin-e004-poker
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yannine Alvarez
kotlin-e004-poker
Commits
9584e506
Commit
9584e506
authored
Apr 22, 2020
by
Yannine Alvarez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modificar la función ganador
parent
d69ced50
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
402 additions
and
157 deletions
+402
-157
Poker/.idea/workspace.xml
+72
-27
Poker/out/production/Poker/Carta.class
+0
-0
Poker/out/production/Poker/PokerKt.class
+0
-0
Poker/src/Poker.kt
+330
-130
No files found.
Poker/.idea/workspace.xml
View file @
9584e506
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
<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$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/out/production/Poker/Carta.class"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/out/production/Poker/Carta.class"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/out/production/Poker/PokerKt.class"
beforeDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/Poker.kt"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/Poker.kt"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/src/Poker.kt"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/src/Poker.kt"
afterDir=
"false"
/>
</list>
</list>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
...
@@ -38,7 +40,7 @@
...
@@ -38,7 +40,7 @@
<property
name=
"SHARE_PROJECT_CONFIGURATION_FILES"
value=
"true"
/>
<property
name=
"SHARE_PROJECT_CONFIGURATION_FILES"
value=
"true"
/>
<property
name=
"android.sdk.path"
value=
"$USER_HOME$/AppData/Local/Android/Sdk"
/>
<property
name=
"android.sdk.path"
value=
"$USER_HOME$/AppData/Local/Android/Sdk"
/>
</component>
</component>
<component
name=
"RunManager"
selected=
"Kotlin.P
oker
Kt"
>
<component
name=
"RunManager"
selected=
"Kotlin.P
rueba
Kt"
>
<configuration
name=
"MyClass"
type=
"Application"
factoryName=
"Application"
temporary=
"true"
nameIsGenerated=
"true"
>
<configuration
name=
"MyClass"
type=
"Application"
factoryName=
"Application"
temporary=
"true"
nameIsGenerated=
"true"
>
<option
name=
"MAIN_CLASS_NAME"
value=
"MyClass"
/>
<option
name=
"MAIN_CLASS_NAME"
value=
"MyClass"
/>
<module
name=
"Poker"
/>
<module
name=
"Poker"
/>
...
@@ -53,6 +55,19 @@
...
@@ -53,6 +55,19 @@
<option
name=
"Make"
enabled=
"true"
/>
<option
name=
"Make"
enabled=
"true"
/>
</method>
</method>
</configuration>
</configuration>
<configuration
name=
"MyClass"
type=
"JetRunConfigurationType"
temporary=
"true"
nameIsGenerated=
"true"
>
<module
name=
"Poker"
/>
<option
name=
"VM_PARAMETERS"
/>
<option
name=
"PROGRAM_PARAMETERS"
/>
<option
name=
"ALTERNATIVE_JRE_PATH_ENABLED"
value=
"false"
/>
<option
name=
"ALTERNATIVE_JRE_PATH"
/>
<option
name=
"PASS_PARENT_ENVS"
value=
"true"
/>
<option
name=
"MAIN_CLASS_NAME"
value=
"MyClass"
/>
<option
name=
"WORKING_DIRECTORY"
/>
<method
v=
"2"
>
<option
name=
"Make"
enabled=
"true"
/>
</method>
</configuration>
<configuration
name=
"PokerKt"
type=
"JetRunConfigurationType"
temporary=
"true"
nameIsGenerated=
"true"
>
<configuration
name=
"PokerKt"
type=
"JetRunConfigurationType"
temporary=
"true"
nameIsGenerated=
"true"
>
<module
name=
"Poker"
/>
<module
name=
"Poker"
/>
<option
name=
"VM_PARAMETERS"
/>
<option
name=
"VM_PARAMETERS"
/>
...
@@ -66,9 +81,24 @@
...
@@ -66,9 +81,24 @@
<option
name=
"Make"
enabled=
"true"
/>
<option
name=
"Make"
enabled=
"true"
/>
</method>
</method>
</configuration>
</configuration>
<configuration
name=
"PruebaKt"
type=
"JetRunConfigurationType"
temporary=
"true"
nameIsGenerated=
"true"
>
<module
name=
"Poker"
/>
<option
name=
"VM_PARAMETERS"
/>
<option
name=
"PROGRAM_PARAMETERS"
/>
<option
name=
"ALTERNATIVE_JRE_PATH_ENABLED"
value=
"false"
/>
<option
name=
"ALTERNATIVE_JRE_PATH"
/>
<option
name=
"PASS_PARENT_ENVS"
value=
"true"
/>
<option
name=
"MAIN_CLASS_NAME"
value=
"PruebaKt"
/>
<option
name=
"WORKING_DIRECTORY"
/>
<method
v=
"2"
>
<option
name=
"Make"
enabled=
"true"
/>
</method>
</configuration>
<recent_temporary>
<recent_temporary>
<list>
<list>
<item
itemvalue=
"Kotlin.PruebaKt"
/>
<item
itemvalue=
"Kotlin.PokerKt"
/>
<item
itemvalue=
"Kotlin.PokerKt"
/>
<item
itemvalue=
"Kotlin.MyClass"
/>
<item
itemvalue=
"Application.Poker"
/>
<item
itemvalue=
"Application.Poker"
/>
<item
itemvalue=
"Application.MyClass"
/>
<item
itemvalue=
"Application.MyClass"
/>
</list>
</list>
...
@@ -120,7 +150,21 @@
...
@@ -120,7 +150,21 @@
<option
name=
"project"
value=
"LOCAL"
/>
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1587433850431
</updated>
<updated>
1587433850431
</updated>
</task>
</task>
<option
name=
"localTasksCounter"
value=
"6"
/>
<task
id=
"LOCAL-00006"
summary=
"Agregar la funciòn verificar las cartas para ganador"
>
<created>
1587434443625
</created>
<option
name=
"number"
value=
"00006"
/>
<option
name=
"presentableId"
value=
"LOCAL-00006"
/>
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1587434443625
</updated>
</task>
<task
id=
"LOCAL-00007"
summary=
"Agregar la funciòn verificar las cartas para ganador"
>
<created>
1587434573538
</created>
<option
name=
"number"
value=
"00007"
/>
<option
name=
"presentableId"
value=
"LOCAL-00007"
/>
<option
name=
"project"
value=
"LOCAL"
/>
<updated>
1587434573539
</updated>
</task>
<option
name=
"localTasksCounter"
value=
"8"
/>
<servers
/>
<servers
/>
</component>
</component>
<component
name=
"VcsManagerConfiguration"
>
<component
name=
"VcsManagerConfiguration"
>
...
@@ -128,61 +172,62 @@
...
@@ -128,61 +172,62 @@
<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."
/>
<MESSAGE
value=
"Se agrega la rama poker_2 que contiene la función ganador."
/>
<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."
/>
<MESSAGE
value=
"Agregar la funciòn verificar las cartas para ganador"
/>
<option
name=
"LAST_COMMIT_MESSAGE"
value=
"Agregar la funciòn verificar las cartas para 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=
"1587434
440282
"
>
<state
x=
"313"
y=
"0"
key=
"CommitChangelistDialog2"
timestamp=
"1587434
570510
"
>
<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=
"1587434
440282
"
/>
<state
x=
"313"
y=
"0"
key=
"CommitChangelistDialog2/0.0.1366.728@0.0.1366.728"
timestamp=
"1587434
570510
"
/>
<state
width=
"1322"
height=
"1
45"
key=
"GridCell.Tab.0.bottom"
timestamp=
"1587433392572
"
>
<state
width=
"1322"
height=
"1
67"
key=
"GridCell.Tab.0.bottom"
timestamp=
"1587606119790
"
>
<screen
x=
"0"
y=
"0"
width=
"1366"
height=
"728"
/>
<screen
x=
"0"
y=
"0"
width=
"1366"
height=
"728"
/>
</state>
</state>
<state
width=
"1322"
height=
"1
45"
key=
"GridCell.Tab.0.bottom/0.0.1366.728@0.0.1366.728"
timestamp=
"1587433392572
"
/>
<state
width=
"1322"
height=
"1
67"
key=
"GridCell.Tab.0.bottom/0.0.1366.728@0.0.1366.728"
timestamp=
"1587606119790
"
/>
<state
width=
"1322"
height=
"1
45"
key=
"GridCell.Tab.0.center"
timestamp=
"1587433392572
"
>
<state
width=
"1322"
height=
"1
67"
key=
"GridCell.Tab.0.center"
timestamp=
"1587606119790
"
>
<screen
x=
"0"
y=
"0"
width=
"1366"
height=
"728"
/>
<screen
x=
"0"
y=
"0"
width=
"1366"
height=
"728"
/>
</state>
</state>
<state
width=
"1322"
height=
"1
45"
key=
"GridCell.Tab.0.center/0.0.1366.728@0.0.1366.728"
timestamp=
"1587433392572
"
/>
<state
width=
"1322"
height=
"1
67"
key=
"GridCell.Tab.0.center/0.0.1366.728@0.0.1366.728"
timestamp=
"1587606119790
"
/>
<state
width=
"1322"
height=
"1
45"
key=
"GridCell.Tab.0.left"
timestamp=
"1587433392572
"
>
<state
width=
"1322"
height=
"1
67"
key=
"GridCell.Tab.0.left"
timestamp=
"1587606119790
"
>
<screen
x=
"0"
y=
"0"
width=
"1366"
height=
"728"
/>
<screen
x=
"0"
y=
"0"
width=
"1366"
height=
"728"
/>
</state>
</state>
<state
width=
"1322"
height=
"1
45"
key=
"GridCell.Tab.0.left/0.0.1366.728@0.0.1366.728"
timestamp=
"1587433392572
"
/>
<state
width=
"1322"
height=
"1
67"
key=
"GridCell.Tab.0.left/0.0.1366.728@0.0.1366.728"
timestamp=
"1587606119790
"
/>
<state
width=
"1322"
height=
"1
45"
key=
"GridCell.Tab.0.right"
timestamp=
"1587433392572
"
>
<state
width=
"1322"
height=
"1
67"
key=
"GridCell.Tab.0.right"
timestamp=
"1587606119790
"
>
<screen
x=
"0"
y=
"0"
width=
"1366"
height=
"728"
/>
<screen
x=
"0"
y=
"0"
width=
"1366"
height=
"728"
/>
</state>
</state>
<state
width=
"1322"
height=
"1
45"
key=
"GridCell.Tab.0.right/0.0.1366.728@0.0.1366.728"
timestamp=
"1587433392572
"
/>
<state
width=
"1322"
height=
"1
67"
key=
"GridCell.Tab.0.right/0.0.1366.728@0.0.1366.728"
timestamp=
"1587606119790
"
/>
<state
width=
"1322"
height=
"217"
key=
"GridCell.Tab.1.bottom"
timestamp=
"15874
26755634
"
>
<state
width=
"1322"
height=
"217"
key=
"GridCell.Tab.1.bottom"
timestamp=
"15874
35162543
"
>
<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.bottom/0.0.1366.728@0.0.1366.728"
timestamp=
"15874
26755634
"
/>
<state
width=
"1322"
height=
"217"
key=
"GridCell.Tab.1.bottom/0.0.1366.728@0.0.1366.728"
timestamp=
"15874
35162543
"
/>
<state
width=
"1322"
height=
"217"
key=
"GridCell.Tab.1.center"
timestamp=
"15874
2675563
3"
>
<state
width=
"1322"
height=
"217"
key=
"GridCell.Tab.1.center"
timestamp=
"15874
3516254
3"
>
<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.center/0.0.1366.728@0.0.1366.728"
timestamp=
"15874
2675563
3"
/>
<state
width=
"1322"
height=
"217"
key=
"GridCell.Tab.1.center/0.0.1366.728@0.0.1366.728"
timestamp=
"15874
3516254
3"
/>
<state
width=
"1322"
height=
"217"
key=
"GridCell.Tab.1.left"
timestamp=
"15874
2675563
3"
>
<state
width=
"1322"
height=
"217"
key=
"GridCell.Tab.1.left"
timestamp=
"15874
3516254
3"
>
<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.left/0.0.1366.728@0.0.1366.728"
timestamp=
"15874
2675563
3"
/>
<state
width=
"1322"
height=
"217"
key=
"GridCell.Tab.1.left/0.0.1366.728@0.0.1366.728"
timestamp=
"15874
3516254
3"
/>
<state
width=
"1322"
height=
"217"
key=
"GridCell.Tab.1.right"
timestamp=
"15874
2675563
3"
>
<state
width=
"1322"
height=
"217"
key=
"GridCell.Tab.1.right"
timestamp=
"15874
3516254
3"
>
<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=
"15874
2675563
3"
/>
<state
width=
"1322"
height=
"217"
key=
"GridCell.Tab.1.right/0.0.1366.728@0.0.1366.728"
timestamp=
"15874
3516254
3"
/>
<state
x=
"275"
y=
"95"
key=
"Vcs.Push.Dialog.v2"
timestamp=
"1587434
462567
"
>
<state
x=
"275"
y=
"95"
key=
"Vcs.Push.Dialog.v2"
timestamp=
"1587434
580613
"
>
<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=
"1587434
462567
"
/>
<state
x=
"275"
y=
"95"
key=
"Vcs.Push.Dialog.v2/0.0.1366.728@0.0.1366.728"
timestamp=
"1587434
580613
"
/>
<state
x=
"92"
y=
"92"
width=
"1182"
height=
"544"
key=
"com.intellij.history.integration.ui.views.FileHistoryDialog"
timestamp=
"1587
430678418
"
>
<state
x=
"92"
y=
"92"
width=
"1182"
height=
"544"
key=
"com.intellij.history.integration.ui.views.FileHistoryDialog"
timestamp=
"1587
594115834
"
>
<screen
x=
"0"
y=
"0"
width=
"1366"
height=
"728"
/>
<screen
x=
"0"
y=
"0"
width=
"1366"
height=
"728"
/>
</state>
</state>
<state
x=
"92"
y=
"92"
width=
"1182"
height=
"544"
key=
"com.intellij.history.integration.ui.views.FileHistoryDialog/0.0.1366.728@0.0.1366.728"
timestamp=
"1587
430678418
"
/>
<state
x=
"92"
y=
"92"
width=
"1182"
height=
"544"
key=
"com.intellij.history.integration.ui.views.FileHistoryDialog/0.0.1366.728@0.0.1366.728"
timestamp=
"1587
594115834
"
/>
<state
x=
"378"
y=
"186"
key=
"com.intellij.ide.util.TipDialog"
timestamp=
"1587
232896641
"
>
<state
x=
"378"
y=
"186"
key=
"com.intellij.ide.util.TipDialog"
timestamp=
"1587
585342335
"
>
<screen
x=
"0"
y=
"0"
width=
"1366"
height=
"728"
/>
<screen
x=
"0"
y=
"0"
width=
"1366"
height=
"728"
/>
</state>
</state>
<state
x=
"378"
y=
"186"
key=
"com.intellij.ide.util.TipDialog/0.0.1366.728@0.0.1366.728"
timestamp=
"1587
232896641
"
/>
<state
x=
"378"
y=
"186"
key=
"com.intellij.ide.util.TipDialog/0.0.1366.728@0.0.1366.728"
timestamp=
"1587
585342335
"
/>
<state
x=
"424"
y=
"5"
key=
"refactoring.ChangeSignatureDialog"
timestamp=
"1587430721574"
>
<state
x=
"424"
y=
"5"
key=
"refactoring.ChangeSignatureDialog"
timestamp=
"1587430721574"
>
<screen
x=
"0"
y=
"0"
width=
"1366"
height=
"728"
/>
<screen
x=
"0"
y=
"0"
width=
"1366"
height=
"728"
/>
</state>
</state>
...
...
Poker/out/production/Poker/Carta.class
View file @
9584e506
No preview for this file type
Poker/out/production/Poker/PokerKt.class
deleted
100644 → 0
View file @
d69ced50
File deleted
Poker/src/Poker.kt
View file @
9584e506
import
java.util.*
import
java.util.*
import
kotlin.collections.ArrayList
const
val
CARAS
=
"23456789tjqka"
const
val
LETRAS
=
"shdc"
class
Carta
(
completo
:
String
)
{
class
Carta
(
completo
:
String
)
{
fun
valorPalo
():
String
{
fun
valorPalo
():
String
{
...
@@ -20,175 +15,380 @@ class Carta(completo: String) {
...
@@ -20,175 +15,380 @@ class Carta(completo: String) {
}
}
}
}
class
OrdenarCartas
{
val
valores
=
charArrayOf
(
'A'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'T'
,
'J'
,
'Q'
,
'K'
)
val
palos
=
charArrayOf
(
'S'
,
'C'
,
'H'
,
'D'
)
fun
compararValor
(
valor1
:
Char
,
valor2
:
Char
):
Int
{
var
numValor1
=
0
var
numValor2
=
0
for
(
i
in
valores
.
indices
)
{
fun
ganadores
(
jugadas
:
MutableList
<
Array
<
Carta
?>>):
String
{
if
(
valor1
==
valores
[
i
])
{
numValor1
=
i
break
}
}
for
(
i
in
valores
.
indices
)
{
print
(
"Cantidad de jugadas ${jugadas.size}"
)
if
(
valor2
==
valores
[
i
])
{
val
ganadores
:
ArrayList
<
Array
<
Carta
>>
=
ArrayList
<
Array
<
Carta
>>()
numValor2
=
i
var
prim
=
true
break
val
indices
=
ArrayList
<
Int
>()
var
index
=
0
for
(
mano
in
jugadas
)
{
if
(
prim
)
{
ganadores
.
add
(
mano
)
indices
.
add
(
index
)
prim
=
false
}
else
{
val
resultadoMayor
=
mostrarResultado
(
ganadores
[
ganadores
.
size
])
val
mostrarResultadoActual
=
mostrarResultado
(
mano
)
if
(
resultadoMayor
[
0
]
<
mostrarResultadoActual
[
0
])
{
ganadores
.
clear
()
indices
.
clear
()
indices
.
add
(
index
)
ganadores
.
add
(
mano
)
}
}
}
index
++
}
}
return
if
(
numValor1
==
numValor2
)
{
var
stringGanadores
=
""
0
for
(
i
in
indices
.
indices
)
{
}
else
if
(
numValor1
>
numValor2
)
{
stringGanadores
+=
" "
+
indices
[
i
]
1
}
else
{
-
1
}
}
return
stringGanadores
}
}
fun
esAnterior
(
carta1
:
Carta
,
carta2
:
Carta
):
Boolean
{
var
valor1
=
0
var
valor2
=
0
for
(
i
in
valores
.
indices
)
{
fun
mostrarResultado
(
mano
:
Array
<
Carta
>):
ArrayList
<
Int
>
{
if
(
carta1
.
valorPalo
()[
0
]
==
valores
[
i
])
{
val
mostrarResultado
=
ArrayList
<
Int
>()
valor1
=
i
val
valores
=
IntArray
(
13
)
break
val
palos
=
IntArray
(
4
)
ArrayNuevo
(
valores
,
palos
,
mano
)
if
(
esEscaleraColor
(
valores
,
palos
))
{
val
ordenado
=
ordenarCartas
(
mano
)
mostrarResultado
.
add
(
9
)
if
(
ordenado
[
4
]
==
12
&&
ordenado
[
0
]
==
0
)
{
mostrarResultado
.
add
(
14
)
}
else
{
mostrarResultado
.
add
(
ordenado
[
4
])
}
}
}
}
else
if
(
esPoker
(
valores
))
{
mostrarResultado
.
add
(
8
)
if
(
indiceDe
(
4
,
valores
)
==
0
)
{
mostrarResultado
.
add
(
14
)
mostrarResultado
.
add
(
indiceDe
(
1
,
valores
))
}
else
{
mostrarResultado
.
add
(
indiceDe
(
4
,
valores
))
if
(
indiceDe
(
1
,
valores
)
==
0
)
{
mostrarResultado
.
add
(
14
)
}
else
{
mostrarResultado
.
add
(
indiceDe
(
1
,
valores
))
}
}
}
else
if
(
esFull
(
valores
))
{
mostrarResultado
.
add
(
7
)
if
(
indiceDe
(
3
,
valores
)
==
0
)
{
mostrarResultado
.
add
(
14
)
mostrarResultado
.
add
(
indiceDe
(
2
,
valores
))
}
else
{
mostrarResultado
.
add
(
indiceDe
(
3
,
valores
))
if
(
indiceDe
(
2
,
valores
)
==
0
)
{
mostrarResultado
.
add
(
14
)
}
else
{
mostrarResultado
.
add
(
indiceDe
(
2
,
valores
))
}
}
}
else
if
(
esColor
(
palos
))
{
var
aux
=
0
mostrarResultado
.
add
(
6
)
val
ordenado
=
ordenarCartas
(
mano
)
if
(
ordenado
[
0
]
==
0
)
{
mostrarResultado
.
add
(
14
)
aux
=
1
}
for
(
i
in
4
downTo
aux
)
{
mostrarResultado
.
add
(
ordenado
[
i
])
}
}
else
if
(
esEscalera
(
valores
))
{
val
ordenado
=
ordenarCartas
(
mano
)
mostrarResultado
.
add
(
5
)
if
(
ordenado
[
4
]
==
12
&&
ordenado
[
0
]
==
1
)
{
mostrarResultado
.
add
(
14
)
}
else
{
mostrarResultado
.
add
(
ordenado
[
4
])
}
}
else
if
(
esTrio
(
valores
))
{
mostrarResultado
.
add
(
4
)
for
(
i
in
valores
.
indices
)
{
if
(
indiceDe
(
3
,
valores
)
==
0
)
{
if
(
carta2
.
valorPalo
()[
0
]
==
valores
[
i
])
{
mostrarResultado
.
add
(
14
)
valor2
=
i
}
else
{
break
mostrarResultado
.
add
(
indiceDe
(
3
,
valores
))
}
val
ordenado
=
ordenarCartas
(
mano
)
var
aux
=
0
if
(
ordenado
[
0
]
==
0
)
{
mostrarResultado
.
add
(
14
)
aux
=
1
}
for
(
i
in
4
downTo
aux
)
{
if
(
mostrarResultado
[
1
]
!=
ordenado
[
i
])
{
mostrarResultado
.
add
(
ordenado
[
i
])
}
}
}
else
if
(
esParDoble
(
valores
))
{
mostrarResultado
.
add
(
3
)
if
(
indiceDe
(
2
,
valores
)
==
0
)
{
mostrarResultado
.
add
(
14
)
mostrarResultado
.
add
(
indiceDeReversa
(
2
,
valores
))
}
else
{
mostrarResultado
.
add
(
indiceDeReversa
(
2
,
valores
))
mostrarResultado
.
add
(
indiceDe
(
2
,
valores
))
}
if
(
indiceDe
(
1
,
valores
)
==
0
)
{
mostrarResultado
.
add
(
14
)
}
else
{
mostrarResultado
.
add
(
indiceDe
(
1
,
valores
))
}
}
else
if
(
esPar
(
valores
))
{
mostrarResultado
.
add
(
2
)
if
(
indiceDe
(
2
,
valores
)
==
0
)
{
mostrarResultado
.
add
(
14
)
}
else
{
mostrarResultado
.
add
(
indiceDe
(
2
,
valores
))
}
val
ordenado
=
ordenarCartas
(
mano
)
var
aux
=
0
if
(
ordenado
[
0
]
==
0
)
{
mostrarResultado
.
add
(
14
)
aux
=
1
}
for
(
i
in
4
downTo
aux
)
{
if
(
mostrarResultado
[
1
]
!=
ordenado
[
i
])
{
mostrarResultado
.
add
(
ordenado
[
i
])
}
}
}
else
{
var
aux
=
0
mostrarResultado
.
add
(
1
)
val
ordenado
=
ordenarCartas
(
mano
)
if
(
ordenado
[
0
]
==
0
)
{
mostrarResultado
.
add
(
14
)
aux
=
1
}
for
(
i
in
4
downTo
aux
)
{
mostrarResultado
.
add
(
ordenado
[
i
])
}
}
}
}
return
if
(
valor1
!=
valor2
+
1
)
{
return
mostrarResultado
false
}
else
true
}
}
}
fun
indiceDe
(
elemento
:
Int
,
vector
:
IntArray
):
Int
{
for
(
i
in
vector
.
indices
)
{
if
(
vector
[
i
]
==
elemento
)
return
i
}
fun
ganador
(
jugadas
:
MutableList
<
Array
<
Carta
?>>):
String
?
{
return
-
1
//Imprime la cantidad de jugadas
}
println
(
"Cantidad de jugadas: "
+
jugadas
.
size
)
val
manos
=
IntArray
(
jugadas
.
size
)
fun
indiceDeReversa
(
elemento
:
Int
,
vector
:
IntArray
):
Int
{
var
mejor
=
8
for
(
i
in
vector
.
indices
.
reversed
())
{
for
(
indice1
in
manos
.
indices
)
{
if
(
vector
[
i
]
==
elemento
)
return
i
if
(
manos
[
indice1
]
<
mejor
)
{
mejor
=
manos
[
indice1
]
}
}
}
val
mejoresManos
=
ArrayList
<
Int
>()
return
-
1
for
(
indice1
in
manos
.
indices
)
{
}
if
(
mejor
==
manos
[
indice1
])
{
mejoresManos
.
add
(
indice1
)
fun
ordenarCartas
(
mano
:
Array
<
Carta
>):
IntArray
{
val
ordenado
=
IntArray
(
5
)
for
(
i
in
0
..
4
)
{
val
valorString
:
String
=
mano
[
i
].
valor
if
(
valorString
==
"A"
||
valorString
==
"a"
)
{
ordenado
[
i
]
=
0
}
else
if
(
valorString
==
"T"
||
valorString
==
"t"
)
{
ordenado
[
i
]
=
9
}
else
if
(
valorString
==
"J"
||
valorString
==
"j"
)
{
ordenado
[
i
]
=
10
}
else
if
(
valorString
==
"Q"
||
valorString
==
"q"
)
{
ordenado
[
i
]
=
11
}
else
if
(
valorString
==
"K"
||
valorString
==
"k"
)
{
ordenado
[
i
]
=
12
}
else
{
ordenado
[
i
]
=
valorString
.
toInt
()
-
1
}
}
}
Arrays
.
sort
(
ordenado
)
return
ordenado
}
}
if
(
mejoresManos
.
size
==
1
)
{
fun
esEscaleraColor
(
valores
:
IntArray
,
palos
:
IntArray
):
Boolean
{
return
"Jugada "
+
(
mejoresManos
[
0
]
+
1
)
}
var
sum
=
false
//agregar para retomar el ganador en caso de verificar la Carta
return
"Error"
var
sumador
=
0
}
var
mejor
=
0
for
(
i
in
1
..
12
)
{
fun
verificarCarta
():
Array
<
Carta
?>?
{
if
(
valores
[
i
]
>
1
)
{
var
respuesta
:
ArrayList
<
Array
<
Carta
?>?>?
=
null
return
false
}
if
(
valores
[
i
]
==
1
)
{
sum
=
true
}
if
(
valores
[
i
]
==
0
&&
sum
)
{
break
}
if
(
sum
)
{
sumador
++
}
}
if
(
mejor
===
1
)
{
if
(
sumador
==
5
||
sumador
==
4
&&
valores
[
0
]
==
1
&&
valores
[
9
]
==
1
&&
valores
[
8
]
==
0
)
{
respuesta
=
siEsPoker
()
for
(
i
in
0
..
3
)
{
}
else
if
(
mejor
===
2
)
{
if
(
palos
[
i
]
==
5
)
{
respuesta
=
siEsFull
()
return
true
}
else
if
(
mejor
===
3
)
{
}
respuesta
=
siEsColorYCartaAlta
()
}
}
else
if
(
mejor
===
4
)
{
}
respuesta
=
siEscalera
()
return
false
}
else
if
(
mejor
===
5
)
{
respuesta
=
siTrio
()
}
else
if
(
mejor
===
6
)
{
respuesta
=
siParDoble
()
}
else
if
(
mejor
===
7
)
{
respuesta
=
siPar
()
}
}
return
respuesta
!!
[
0
]
fun
esPoker
(
valores
:
IntArray
):
Boolean
{
}
val
ordenado
=
valores
.
clone
()
Arrays
.
sort
(
ordenado
)
return
if
(
ordenado
[
12
]
==
4
)
{
true
}
else
false
}
fun
siPar
():
ArrayList
<
Array
<
Carta
?>?>?
{
fun
esFull
(
valores
:
IntArray
):
Boolean
{
//completar
val
ordenado
=
valores
.
clone
()
Arrays
.
sort
(
ordenado
)
return
if
(
ordenado
[
12
]
==
3
&&
ordenado
[
11
]
==
2
)
true
else
false
}
}
fun
esColor
(
palos
:
IntArray
):
Boolean
{
val
ordenado
=
palos
.
clone
()
Arrays
.
sort
(
ordenado
)
return
if
(
ordenado
[
3
]
==
5
)
true
else
false
}
fun
siParDoble
():
ArrayList
<
Array
<
Carta
?>?>?
{
fun
esEscalera
(
valores
:
IntArray
):
Boolean
{
}
var
sum
=
false
fun
siEscalera
():
ArrayList
<
Array
<
Carta
?>?>?
{
var
sumador
=
0
for
(
i
in
1
..
12
)
{
}
if
(
valores
[
i
]
>
1
)
{
return
false
}
if
(
valores
[
i
]
==
1
)
{
sum
=
true
}
if
(
valores
[
i
]
==
0
&&
sum
)
{
break
}
if
(
sum
)
{
sumador
++
}
}
return
if
(
sumador
==
5
||
sumador
==
4
&&
valores
[
0
]
==
1
&&
valores
[
9
]
==
1
&&
valores
[
8
]
==
0
)
{
true
}
else
false
}
fun
siTrio
():
ArrayList
<
Array
<
Carta
?>?>?
{
fun
esTrio
(
valores
:
IntArray
):
Boolean
{
val
ordenado
=
valores
.
clone
()
Arrays
.
sort
(
ordenado
)
return
if
(
ordenado
[
12
]
==
3
&&
ordenado
[
11
]
==
1
&&
ordenado
[
10
]
==
1
)
true
else
false
}
}
fun
esParDoble
(
valores
:
IntArray
):
Boolean
{
fun
siEsColorYCartaAlta
():
ArrayList
<
Array
<
Carta
?>?>?
{
val
ordenado
=
valores
.
clone
()
}
Arrays
.
sort
(
ordenado
)
return
if
(
ordenado
[
12
]
==
2
&&
ordenado
[
11
]
==
2
&&
ordenado
[
10
]
==
1
)
true
else
false
}
fun
siEsFull
():
ArrayList
<
Array
<
Carta
?>?>?
{
fun
esPar
(
valores
:
IntArray
):
Boolean
{
val
ordenado
=
valores
.
clone
()
Arrays
.
sort
(
ordenado
)
return
if
(
ordenado
[
12
]
==
2
&&
ordenado
[
11
]
==
1
&&
ordenado
[
10
]
==
1
&&
ordenado
[
9
]
==
1
)
true
else
false
}
}
fun
mostrarGanador
(
ganadores
:
ArrayList
<
Array
<
Carta
>>)
{
for
(
i
in
ganadores
.
indices
)
{
for
(
j
in
0
..
4
)
{
print
(
ganadores
[
i
][
j
].
valorPalo
())
}
println
()
}
}
fun
siEsPoker
():
ArrayList
<
Array
<
Carta
?>?>?
{
}
fun
ArrayNuevo
(
valores
:
IntArray
,
palos
:
IntArray
,
mano
:
Array
<
Carta
>)
{
for
(
i
in
0
..
12
)
{
valores
[
i
]
=
0
}
for
(
i
in
0
..
3
)
{
palos
[
i
]
=
0
}
for
(
i
in
0
..
4
)
{
val
valorString
:
String
=
mano
[
i
]
!!
.
valor
val
paloString
:
String
=
mano
[
i
].
palo
if
(
valorString
==
"A"
||
valorString
==
"a"
)
{
valores
[
0
]++
}
else
if
(
valorString
==
"T"
||
valorString
==
"t"
)
{
valores
[
9
]++
}
else
if
(
valorString
==
"J"
||
valorString
==
"j"
)
{
valores
[
10
]++
}
else
if
(
valorString
==
"Q"
||
valorString
==
"q"
)
{
valores
[
11
]++
}
else
if
(
valorString
==
"K"
||
valorString
==
"k"
)
{
valores
[
12
]++
}
else
if
(
valorString
==
"J"
||
valorString
==
"j"
)
{
valores
[
10
]++
}
else
{
val
index
=
valorString
.
toInt
()
valores
[
index
-
1
]++
}
if
(
paloString
==
"S"
||
paloString
==
"s"
)
{
palos
[
0
]++
}
else
if
(
paloString
==
"C"
||
paloString
==
"c"
)
{
palos
[
1
]++
}
else
if
(
paloString
==
"H"
||
paloString
==
"h"
)
{
palos
[
2
]++
}
else
if
(
paloString
==
"D"
||
paloString
==
"d"
)
{
palos
[
3
]++
}
}
}
fun
main
(
args
:
Array
<
String
>)
{
fun
main
(
args
:
Array
<
String
>)
{
/*val manos = arrayOf(
"ah ad th tc 6s",
"as 2s 3s 4s 5s"
)
for (mano in manos) {
println("Jugada: ${jugada(mano)}")
}*/
val
jugadas
:
MutableList
<
Array
<
Carta
?>>
=
ArrayList
()
val
jugada1
=
arrayOfNulls
<
Carta
>(
5
)
jugada1
[
0
]
=
Carta
(
"AH"
)
jugada1
[
1
]
=
Carta
(
"AD"
)
jugada1
[
2
]
=
Carta
(
"TH"
)
jugada1
[
3
]
=
Carta
(
"TC"
)
jugada1
[
4
]
=
Carta
(
"6S"
)
val
jugada2
=
arrayOfNulls
<
Carta
>(
5
)
jugada2
[
0
]
=
Carta
(
"AH"
)
jugada2
[
1
]
=
Carta
(
"KD"
)
jugada2
[
2
]
=
Carta
(
"QH"
)
jugada2
[
3
]
=
Carta
(
"3C"
)
jugada2
[
4
]
=
Carta
(
"3S"
)
jugadas
.
add
(
jugada1
)
jugadas
.
add
(
jugada2
)
// val ganadores: String = mc.ganadores(jugadas)
println
(
"Jugada: ${ganador(jugadas)}"
)
}
val
jugadas
:
MutableList
<
Array
<
Carta
?>>
=
ArrayList
<
Array
<
Carta
?>>()
val
m1
:
Array
<
Carta
?>
=
arrayOfNulls
<
Carta
>(
5
)
m1
[
0
]
=
Carta
(
"AH"
)
m1
[
1
]
=
Carta
(
"AD"
)
m1
[
2
]
=
Carta
(
"5D"
)
m1
[
3
]
=
Carta
(
"5D"
)
m1
[
4
]
=
Carta
(
"2D"
)
val
m2
:
Array
<
Carta
?>
=
arrayOfNulls
<
Carta
>(
5
)
m2
[
0
]
=
Carta
(
"5H"
)
m2
[
1
]
=
Carta
(
"5D"
)
m2
[
2
]
=
Carta
(
"2D"
)
m2
[
3
]
=
Carta
(
"2D"
)
m2
[
4
]
=
Carta
(
"AD"
)
jugadas
.
add
(
m1
)
jugadas
.
add
(
m2
)
val
ganadores
=
ganadores
(
jugadas
)
println
(
"Ganadores = $ganadores"
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment