-
Notifications
You must be signed in to change notification settings - Fork 0
boardObject ( For Board Games )
There Is a boardObject That You Can Work With Boards With This Objects Easier Than Before.
Way To Use :
var player = new boardObject("board");
player.[function]();
Everything In gameObjects Can Be Used Here Too.
All Methods Are Here :
Ban A Cell And Make It Read Only For Some Games Like XO .
Remove The Ban Mode From A Cell And Make It Writable Again.
It Will Check If The Cell Is Banned Or Not. If Its Banned It Will Return -1 Else Return The Index In Banned Array.
It Will Remove All Ban Modes From Board. ( Not Remove Data And Text From Board. )
It Will Update Some Data. ( htmls , texts ).
Add A Text To Specific Cell Of A Board. ( cell Is Just Place Object Like document.getElementsById("id") Or $("id") Magic Of JSHA XD ) css_class can be list of css classes or one class to set for texts. center will specify that texts will be in center of cell or not.
This Will Act Better That addText. Because After Once That You Added A Text, addText Will Not Do What You Want XD. Better That Use setText ( Default Text Is In Center ).
Just Get Text Of A Cell.
It Will Make A cell Uneditable. The can Is A Boolean That Specify User Can Edit ( Add Or Set A Text ) To This Cell Or Not.
It Will Clears The Board.
It Will Give You A JSON That Contains Status Of Game. ( Banned Cells , Width , Height , texts ( A List Of Cells Texts ) , htmls ( A List Of cells HTMLs. ) )
If "func" is A Function It Will Run This { func(board.getStatus()) }. And Your Function Will RunLike This And Give Status Like This. But If "func" is a string It Will Try To Specify Your Game Type That You Told JSHA To Check For You. Now Just There Is One Option ( "xo" ) Game That Will Report You Winner.
An Example Of Using :
var board = new boardObject("board",3,3,"100px","100px","rgb(255,0,0)",test);
It Will Convert A div Into A Board That Is 3 * 3 And Each Cell Has 100px For Width And 100px For Height And The Color Will Be Red. test Is Just A Function That Will Be Called In Each Click.
You Can Access To The Html Object Like That :
var a = new boardObject("test");
->a.object
You Can Find If Object Is boardObject Like That :
var a = new boardObject("test");
->a.type // If Returns "boardObject" , That's It ! Else Its Not A boardObject.