/* Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 1 0 - 2 0 2 1 , ĠNull Non ame Ċ Ġ* ĠKotlin Ġconverted Ġand Ġmodified Ġby ĠV en om = N hel v Ċ Ġ* ĠAll Ġrights Ġreserved . Ċ Ġ* Ċ Ġ* ĠRedistribution Ġand Ġuse Ġin Ġsource Ġand Ġbinary Ġforms , Ġwith Ġor Ġwithout Ċ Ġ* Ġmodification , Ġare Ġpermitted Ġprovided Ġthat Ġthe Ġfollowing Ġconditions Ġare Ġmet : Ċ Ġ* ĠĠĠĠ Ġ* ĠRedistributions Ġof Ġsource Ġcode Ġmust Ġretain Ġthe Ġabove Ġcopyright Ċ Ġ* ĠĠĠĠĠĠ Ġnotice , Ġthis Ġlist Ġof Ġconditions Ġand Ġthe Ġfollowing Ġdisclaimer . Ċ Ġ* ĠĠĠĠ Ġ* ĠRedistributions Ġin Ġbinary Ġform Ġmust Ġreproduce Ġthe Ġabove Ġcopyright Ċ Ġ* ĠĠĠĠĠĠ Ġnotice , Ġthis Ġlist Ġof Ġconditions Ġand Ġthe Ġfollowing Ġdisclaimer Ġin Ġthe Ċ Ġ* ĠĠĠĠĠĠ Ġdocumentation Ġand / or Ġother Ġmaterials Ġprovided Ġwith Ġthe Ġdistribution . Ċ Ġ* ĠĠĠĠ Ġ* ĠNeither Ġthe Ġname Ġof ĠNull Non ame Ġnor Ġthe Ġnames Ġof Ġits Ċ Ġ* ĠĠĠĠĠĠ Ġcontributors Ġmay Ġbe Ġused Ġto Ġendorse Ġor Ġpromote Ġproducts Ġderived Ġfrom Ċ Ġ* ĠĠĠĠĠĠ Ġthis Ġsoftware Ġwithout Ġspecific Ġprior Ġwritten Ġpermission . Ċ Ġ* Ċ Ġ* ĠTHIS ĠSOFTWARE ĠIS ĠPROVIDED ĠBY ĠTHE ĠCOPYRIGHT ĠHOLDERS ĠAND ĠCONTRIBUTORS Ġ" AS ĠIS " Ċ Ġ* ĠAND ĠANY ĠEXPRESS ĠOR ĠIMPLIED ĠWARRANTIES , ĠINCLUDING , ĠBUT ĠNOT ĠLIMITED ĠTO , ĠTHE Ċ Ġ* ĠIMPLIED ĠWARRANTIES ĠOF ĠMERCHANTABILITY ĠAND ĠFITNESS ĠFOR ĠA ĠPARTICULAR ĠPURPOSE Ċ Ġ* ĠARE ĠDISCLAIMED . ĠIN ĠNO ĠEVENT ĠSHALL ĠTHE ĠCOPYRIGHT ĠOWNER ĠOR ĠCONTRIBUTORS ĠBE Ċ Ġ* ĠLIABLE ĠFOR ĠANY ĠDIRECT , ĠINDIRECT , ĠINCIDENTAL , ĠSPECIAL , ĠEXEMPLARY , ĠOR Ċ Ġ* ĠCONSEQUENTIAL ĠDAMAGES Ġ( INCLUDING , ĠBUT ĠNOT ĠLIMITED ĠTO , ĠPROCUREMENT ĠOF Ċ Ġ* ĠSUBSTITUTE ĠGOODS ĠOR ĠSERVICES ; ĠLOSS ĠOF ĠUSE , ĠDATA , ĠOR ĠPROFITS ; ĠOR ĠBUSINESS Ċ Ġ* ĠINTERRUPTION ) ĠHOWEVER ĠCAUSED ĠAND ĠON ĠANY ĠTHEORY ĠOF ĠLIABILITY , ĠWHETHER ĠIN Ċ Ġ* ĠCONTRACT , ĠSTRICT ĠLIABILITY , ĠOR ĠTORT Ġ( INCLUDING ĠNEGLIGENCE ĠOR ĠOTHERWISE ) Ċ Ġ* ĠARISING ĠIN ĠANY ĠWAY ĠOUT ĠOF ĠTHE ĠUSE ĠOF ĠTHIS ĠSOFTWARE , ĠEVEN ĠIF ĠADVISED ĠOF ĠTHE Ċ Ġ* ĠPOSSIBILITY ĠOF ĠSUCH ĠDAMAGE . Ċ Ġ*/ Ċ package Ġmu . nu . null po . game . subsystem . mode Ċ Ċ import Ġmu . nu . null po . game . component . Block Ċ import Ġmu . nu . null po . game . component . Block . COLOR Ċ import Ġmu . nu . null po . game . component . Controller Ċ import Ġmu . nu . null po . game . component . Field Ċ import Ġmu . nu . null po . game . event . Event Receiver Ċ import Ġmu . nu . null po . game . play . Game Engine Ċ import Ġmu . nu . null po . game . play . Game Manager Ċ import Ġmu . nu . null po . util . Custom Properties Ċ import Ġjava . util . LinkedList Ċ import Ġkotlin . random . Random Ċ Ċ /** ĠTO OL - VS ĠMAP ĠEDIT Ġ*/ Ċ class ĠTool VS Map Edit Mode : Abstract Mode () Ġ{ ĊĊ ĉ /** ĠMap Ġdata I Ġwent Ġinto Ġthe Property Ġfile Ġ*/ Ċ ĉ private Ġvar Ġprop Map Ġ= ĠCustom Properties () ĊĊ ĉ /** ĠCurrent ĠMap All Ġcontained Ġin Ġthe Ġfile field Ġdata Ġ*/ Ċ ĉ private Ġvar Ġlist Fields : LinkedList < Field >? Ġ= Ġnull ĊĊ ĉ /** ĠCurrent ĠMap Set ID Ġ*/ Ċ ĉ private Ġvar Ġnow Map Set ID Ġ= Ġ 0 ĊĊ ĉ /** ĠCurrent ĠMap ID Ġ*/ Ċ ĉ private Ġvar Ġnow Map ID Ġ= Ġ 0 ĊĊ ĉ /* ĠMode Ġname Ġ*/ Ċ ĉ override Ġval Ġname Ġ= Ġ" TOOL - VS ĠMAP ĠEDIT " ĊĊ ĉ /* ĠMode Ġinitialization Ġ*/ Ċ ĉ override Ġfun Ġmode Init ( manager : Game Manager ) Ġ{ Ċĉ ĉ owner Ġ= Ġmanager Ċĉ ĉ prop Map Ġ= ĠCustom Properties () Ċĉ ĉ list Fields Ġ= ĠLinkedList () Ċĉ ĉ now Map Set ID Ġ= Ġ 0 Ċĉ ĉ now Map ID Ġ= Ġ 0 Ċ ĉ } ĊĊ ĉ /** ĠMap Read Ġinto Ġ#[ id ]: [ field ] Ġfrom Ġ[ prop ] Ġ*/ Ċ ĉ private Ġfun Ġload Map ( field : Field , Ġprop : Custom Properties , Ġid : Int ) Ġ{ Ċĉ ĉ field . reset () Ċĉ ĉ // field . read Property ( prop , Ġid ); Ċĉ ĉ field . string To Field ( prop . getProperty (" values .$ id ", Ġ"")) Ċĉ ĉ field . set All Attribute ( true , ĠBlock . ATTRIBUTE . VISIBLE , ĠBlock . ATTRIBUTE . OUT LINE ) Ċĉ ĉ field . set All Attribute ( false , ĠBlock . ATTRIBUTE . SELF _ PL AC ED ) Ċ ĉ } ĊĊ ĉ /** ĠMap Save Ġfrom Ġ#[ id ]: [ field ] Ġinto Ġ[ prop ] Ġ*/ Ċ ĉ private Ġfun Ġsave Map ( field : Field , Ġprop : Custom Properties , Ġid : Int ) Ġ{ Ċĉ ĉ // field . write Property ( prop , Ġid ); Ċĉ ĉ prop . setProperty (" values .$ id ", Ġfield . field ToString ()) Ċ ĉ } ĊĊ ĉ /** ĠAll Map Read Ċĉ Ġ* Ġ@ param Ġset ID ĠMap Set ID Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġload All Maps ( set ID : Int ) Ġ{ Ċĉ ĉ prop Map Ġ= Ġreceiver . load Properties (" config / map / vs battle /$ set ID . map ") Ġ?: ĠCustom Properties () ĊĊĉ ĉ list Fields !!. clear () ĊĊĉ ĉ val Ġmax Map Ġ= Ġprop Map . getProperty (" values . max Map Number ", Ġ 0 ) Ċĉ ĉ for ( i Ġin Ġ 0 Ġuntil Ġmax Map ) Ġ{ Ċĉĉ ĉ val Ġfld Ġ= ĠField () Ċĉĉ ĉ load Map ( fld , Ġprop Map , Ġi ) Ċĉĉ ĉ list Fields !!. add ( fld ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ /** ĠAll Map Save Ċĉ Ġ* Ġ@ param Ġset ID ĠMap Set ID Ċĉ Ġ*/ Ċ ĉ private Ġfun Ġsave All Maps ( set ID : Int ) Ġ{ Ċĉ ĉ prop Map Ġ= ĠCustom Properties () ĊĊĉ ĉ val Ġmax Map Ġ= Ġlist Fields !!. size Ċĉ ĉ prop Map . setProperty (" values . max Map Number ", Ġmax Map ) ĊĊĉ ĉ for ( i Ġin Ġ 0 Ġuntil Ġmax Map ) Ċĉĉ ĉ save Map ( list Fields ! ![ i ], Ġprop Map , Ġi ) ĊĊĉ ĉ receiver . save Properties (" config / map / vs battle /$ set ID . map ", Ġprop Map ) Ċ ĉ } ĊĊ ĉ private Ġfun Ġgray To Random Color ( field : Field ) Ġ{ Ċĉ ĉ val Ġrand Ġ= ĠRandom . Default ĊĊĉ ĉ for ( i Ġin Ġfield . hidden Height *- 1 Ġuntil Ġfield . height ) Ċĉĉ ĉ for ( j Ġin Ġ 0 Ġuntil Ġfield . width ) Ġ{ Ċĉĉĉ ĉ val Ġcol = field . getBlock Color ( j , Ġi ) Ċĉĉĉ ĉ if ( col == Block . COLOR . BLACK || col == Block . COLOR . WHITE ) Ġ{ Ċĉĉĉĉ ĉ var Ġcolor : COLOR Ċĉĉĉĉ ĉ do Ċĉĉĉĉĉ ĉ color Ġ= ĠCOLOR . colors ()[ rand . nextInt ( COLOR . COLOR _ NUM )] Ċĉĉĉĉ ĉ while ( color == field . getBlock Color ( j - 1 , Ġi )|| color == field . getBlock Color ( j + 1 , Ġi )|| Ċĉĉĉĉĉ ĉ color == field . getBlock Color ( j , Ġi - 1 )|| color == field . getBlock Color ( j , Ġi - 1 )) Ċĉĉĉĉ ĉ field . set Block Color ( j , Ġi , Ġcolor ) Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċ ĉ } ĊĊ ĉ /* ĠInitialization Ġfor Ġeach Ġplayer Ġ*/ Ċ ĉ override Ġfun Ġplayer Init ( engine : Game Engine , Ġplayer ID : Int ) Ġ{ Ċĉ ĉ engine . frame color Ġ= ĠGame Engine . FRAME _ COLOR _ GRAY Ċĉ ĉ engine . create Field IfNeeded () Ċĉ ĉ load All Maps ( now Map Set ID ) Ċ ĉ } ĊĊ ĉ /* ĠCalled Ġat Ġsettings Ġscreen Ġ*/ Ċ ĉ override Ġfun Ġon Setting ( engine : Game Engine , Ġplayer ID : Int ): Boolean Ġ{ Ċĉ ĉ // ĠConfiguration Ġchanges Ċĉ ĉ val Ġchange Ġ= Ġupdate Cursor ( engine , Ġ 7 ) ĊĊĉ ĉ if ( change != 0 ) Ġ{ Ċĉĉ ĉ engine . play SE (" change ") ĊĊĉĉ ĉ when ( menu Cursor ) Ġ{ Ċĉĉĉĉ 0 , Ġ 1 , Ġ 2 Ġ-> Ġ{ Ċĉĉĉ ĉ } Ċĉĉĉĉ 3 , Ġ 4 , Ġ 5 Ġ-> Ġ{ Ċĉĉĉĉ ĉ now Map ID Ġ+= Ġchange Ċĉĉĉĉ ĉ if ( now Map ID < 0 ) Ġnow Map ID Ġ= Ġlist Fields !!. size Ċĉĉĉĉ ĉ if ( now Map ID > list Fields !!. size ) Ġnow Map ID Ġ= Ġ 0 Ċĉĉĉ ĉ } Ċĉĉĉĉ 6 , Ġ 7 Ġ-> Ġ{ Ċĉĉĉĉ ĉ now Map Set ID Ġ+= Ġchange Ċĉĉĉĉ ĉ if ( now Map Set ID < 0 ) Ġnow Map Set ID Ġ= Ġ 9 9 Ċĉĉĉĉ ĉ if ( now Map Set ID > 9 9 ) Ġnow Map Set ID Ġ= Ġ 0 Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ // Ġæ ± º å®ļ Ċĉ ĉ if ( engine . ctrl . is Push ( Controller . BUTTON _ A ) && menu Time >= 5 ) Ġ{ Ċĉĉ ĉ engine . play SE (" dec ide ") ĊĊĉĉ ĉ if ( menu Cursor == 0 ) Ċĉĉ ĉ // ĠEDIT Ċĉĉĉ ĉ engine . enter Field Edit () Ċĉĉ ĉ else Ġif ( menu Cursor == 1 ) Ċĉĉ ĉ // ĠWH ITE -> ? Ċĉĉĉ ĉ gray To Random Color ( engine . field ) Ċĉĉ ĉ else Ġif ( menu Cursor == 2 ) Ċĉĉ ĉ // ĠCLEAR Ċĉĉĉ ĉ engine . field . reset () Ċĉĉ ĉ else Ġif ( menu Cursor == 3 ) Ġ{ Ċĉĉĉ ĉ // ĠSAVE Ċĉĉĉ ĉ if ( now Map ID >= 0 && now Map ID < list Fields !!. size ) Ċĉĉĉĉ ĉ list Fields ! ![ now Map ID ]. copy ( engine . field ) Ċĉĉĉ ĉ else Ċĉĉĉĉ ĉ list Fields !!. add ( Field ( engine . field )) Ċĉĉ ĉ } Ġelse Ġif ( menu Cursor == 4 ) Ġ{ Ċĉĉĉ ĉ // ĠLOAD Ċĉĉĉ ĉ if ( now Map ID >= 0 && now Map ID < list Fields !!. size ) Ġ{ Ċĉĉĉĉ ĉ engine . field . copy ( list Fields ! ![ now Map ID ]) Ċĉĉĉĉ ĉ engine . field . set All Skin ( engine . skin ) Ċĉĉĉ ĉ } Ġelse Ċĉĉĉĉ ĉ engine . field . reset () Ċĉĉ ĉ } Ġelse Ġif ( menu Cursor == 5 ) Ġ{ Ċĉĉĉ ĉ // ĠDELETE Ċĉĉĉ ĉ if ( now Map ID >= 0 && now Map ID < list Fields !!. size ) Ġ{ Ċĉĉĉĉ ĉ list Fields !!. remove At ( now Map ID ) Ċĉĉĉĉ ĉ if ( now Map ID >= list Fields !!. size ) Ġnow Map ID Ġ= Ġlist Fields !!. size Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ġelse Ġif ( menu Cursor == 6 ) Ċĉĉ ĉ // ĠWRITE Ċĉĉĉ ĉ save All Maps ( now Map Set ID ) Ċĉĉ ĉ else Ġif ( menu Cursor == 7 ) Ġ{ Ċĉĉĉ ĉ // ĠREAD Ċĉĉĉ ĉ load All Maps ( now Map Set ID ) Ċĉĉĉ ĉ now Map ID Ġ= Ġ 0 Ċĉĉĉ ĉ engine . field . reset () Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ // Ġ çµĤ äºĨ Ċĉ ĉ if ( engine . ctrl . is Press ( Controller . BUTTON _ D ) && engine . ctrl . is Press ( Controller . BUTTON _ E ) && menu Time >= 5 ) Ċĉĉ ĉ engine . quit flag Ġ= Ġtrue ĊĊĉ ĉ menu Time ++ Ċĉ ĉ return Ġtrue Ċ ĉ } ĊĊ ĉ /* ĠSetting Ġscreen Ġdrawing Ġ*/ Ċ ĉ override Ġfun Ġrender Setting ( engine : Game Engine , Ġplayer ID : Int ) Ġ{ Ċĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 0 , Ġ 1 , Ġ" FIELD ĠEDIT ", ĠEvent Receiver . COLOR . CO B ALT ) Ċĉ ĉ if ( menu Cursor Ġin Ġ 0 .. 2 ) Ċĉĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 0 , Ġ 2 + menu Cursor , Ġ"\ u 0 0 8 2 ", ĠEvent Receiver . COLOR . RED ) Ċĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 1 , Ġ 2 , Ġ"[ EDIT ]", Ġmenu Cursor == 0 ) Ċĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 1 , Ġ 3 , Ġ"[ WHITE -> ? ]", Ġmenu Cursor == 1 ) Ċĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 1 , Ġ 4 , Ġ"[ CLEAR ]", Ġmenu Cursor == 2 ) ĊĊĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 0 , Ġ 6 , Ġ" MAP ĠDATA ", ĠEvent Receiver . COLOR . CO B ALT ) Ċĉ ĉ if ( list Fields !!. size > 0 ) Ċĉĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 0 , Ġ 7 , Ġ"$ now Map ID "+ "/ "+ ( list Fields !!. size - 1 ), Ġmenu Cursor Ġin Ġ 3 .. 5 ) Ċĉ ĉ else Ċĉĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 0 , Ġ 7 , Ġ" NO ĠMAP S ", Ġmenu Cursor Ġin Ġ 3 .. 5 ) Ċĉ ĉ if ( menu Cursor Ġin Ġ 3 .. 5 ) Ċĉĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 0 , Ġ 8 + menu Cursor - 3 , Ġ"\ u 0 0 8 2 ", ĠEvent Receiver . COLOR . RED ) Ċĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 1 , Ġ 8 , Ġ"[ SAVE ]", Ġmenu Cursor == 3 ) Ċĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 1 , Ġ 9 , Ġ"[ LOAD ]", Ġmenu Cursor == 4 ) Ċĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 1 , Ġ 1 0 , Ġ"[ DELETE ]", Ġmenu Cursor == 5 ) ĊĊĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 0 , Ġ 1 2 , Ġ" MAP ĠFILE ", ĠEvent Receiver . COLOR . CO B ALT ) Ċĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 0 , Ġ 1 3 , Ġ"$ now Map Set ID / 9 9 ", Ġmenu Cursor Ġin Ġ 6 .. 7 ) Ċĉ ĉ if ( menu Cursor Ġin Ġ 6 .. 7 ) Ċĉĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 0 , Ġ 1 4 + menu Cursor - 6 , Ġ"\ u 0 0 8 2 ", ĠEvent Receiver . COLOR . RED ) Ċĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 1 , Ġ 1 4 , Ġ"[ WRITE ]", Ġmenu Cursor == 6 ) Ċĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 1 , Ġ 1 5 , Ġ"[ READ ]", Ġmenu Cursor == 7 ) ĊĊĉ ĉ receiver . draw Menu Font ( engine , Ġplayer ID , Ġ 0 , Ġ 1 9 , Ġ" EXIT -> ĠD + E ", ĠEvent Receiver . COLOR . OR ANGE ) Ċ ĉ } ĊĊ ĉ /* Ġfield Edit Ġscreen Ġ*/ Ċ ĉ override Ġfun Ġrender Field Edit ( engine : Game Engine , Ġplayer ID : Int ) Ġ{ Ċĉ ĉ receiver . draw Score Font ( engine , Ġplayer ID , Ġ 0 , Ġ 2 , Ġ" X ĠPOS ", ĠEvent Receiver . COLOR . BLUE ) Ċĉ ĉ receiver . draw Score Font ( engine , Ġplayer ID , Ġ 0 , Ġ 3 , Ġ"" + engine . fl ded it X ) Ċĉ ĉ receiver . draw Score Font ( engine , Ġplayer ID , Ġ 0 , Ġ 4 , Ġ" Y ĠPOS ", ĠEvent Receiver . COLOR . BLUE ) Ċĉ ĉ receiver . draw Score Font ( engine , Ġplayer ID , Ġ 0 , Ġ 5 , Ġ"" + engine . fl ded it Y ) Ċ ĉ } Ċ } Ċ