package Ġde . ai arena . community Ċ Ċ import Ġkotlin . streams . toList Ċ Ċ fun Ġmain ( args : ĠArray < String > ){ ĊĠĠĠ ĠSimple Tex as Dice Em Client (" localhost ", 1 8 0 5 ," 6 c 4 f 6 4 9 9 6 8 1 6 5 8 9 c 8 9 d 9 7 f 6 9 ae 2 f 4 2 8 5 0 6 3 9 8 2 a 6 db 7 f 2 5 9 2 0 0 7 c 9 7 7 ea 1 e 2 df 9 3 ", true ) ĊĊĠĠĠ Ġwhile ( true ){ ĊĠĠĠĠĠĠĠ ĠThread . sleep ( 5 0 0 0 ) ĊĠĠĠ Ġ} Ċ } Ċ Ċ class ĠSimple Tex as Dice Em Client ( host : ĠString , Ġport : ĠInt , Ġprivate Ġval Ġsecret : ĠString , Ġdebug : ĠBoolean Ġ= Ġtrue ) Ġ{ ĊĠĠĠ Ġprivate Ġval Ġclient Ġ= ĠAM TP Client ( host , port , secret , this :: on Message , debug = debug ) ĊĠĠĠ Ġprivate Ġval Ġkeys Ġ= ĠlistOf (" Number - 1 "," Number - 2 "," Number - 3 "," Number - 4 "," Number - 5 "," Number - 6 "," Triple "," Four "," Full - House "," Street - Short "," Street - Long "," Five "," J oker ") ĊĠĠĠ Ġprivate Ġvar Ġkey Index Ġ= Ġ 0 ĊĊĠĠĠ Ġprivate Ġfun Ġon Message ( msg : ĠMessage From Server , Ġmy Turn : ĠBoolean ){ ĊĠĠĠĠĠĠĠ Ġif ( my Turn ){ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmy Dice S Ġ= Ġmsg . headers [" Player Dice "] !! ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġboard Dice S Ġ= Ġmsg . headers [" Board Dice "] !! ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmy Dice Ġ= Ġmy Dice S . split ("," ). toList (). stream (). map { it . toInt ()}. toList () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġboard Dice Ġ= Ġboard Dice S . split ("," ). toList (). stream (). map { it . toInt ()}. toList () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġdice Ġ= ĠArrayList < Int >() ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdice . addAll ( my Dice ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdice . addAll ( board Dice ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdice . sort Descending () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġused Ġ= Ġdice . sub List ( 0 , 5 ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġmessage Ġ= ĠMessage ToServer (" GAME "," AM TP / 0 . 0 ", hash Map Of ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Action " Ġto Ġ" Put ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Slot " Ġto Ġkeys [ key Index ], ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" Combination " Ġto Ġused . join ToString (",") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ)) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġkey Index ++ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġclient . send ( message ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ