Asyoucanseeherenext, we'regonnaaddin a linktagforSTISS, andwe'regonnause a stylesheetcalledstilesdotCSS.
Thisiswherewe'regonnaputallofourstylingsowecanhaveallthehovereffects, andthenwe'regonnacreate a scripttag, whichisjustgoingtobeherescriptdotJsAndthisiswherewe'regonnaputallofthelogicandwe'rejustgonnamakesurewedeferthis.
ThiswilljustmakeitsowecaneasilyaccessthisintheJavascriptandthereason I'm notusingtheclasstoaccessitintheJavascript s sothat I canseparatemyCSSandmyJavaScript.
I haveanentireblockarticleonthiswhich I willlinktodowntheirdescription.
Ifyouwantmoreinformationaboutthatnow, thenextthingweneedtodoisweneedtohaveninedifferentcells, oneforeachoneoftheplaceswecanput a mark.
Andwewantthistobehere a withforexample, of 100 viewwithandwewanttogiveit a heightlivesrightof 100 ofyouheightandwhatthisisgoingtoallowustodoisactuallymakeitsothatourboardisgonnafilltheentirescreen, whichwillmakeitsowecanveryeasilycenteritinsideofourscreen.
Sodissenterit.
We'regonnausedisplayedgridtoe, layoutouritemsinsidethisgrid, andwe'realsogoingtojustifycontentinthecenterand a line I contentinthecenterthisisgoingtocenterareboredelement.
Wecandojustifyitemscenter, andwecoulddo a lineitemsinthecenter, andthisisgoingtoaligntheactualindividualthingsinsideofourcellsandnottheactualcellsthemselves.
Andifyou'reconfusedaboutgreatitall, I haveanentirevideocoveringCSSgridonlikethatagaininthecardsandthedescriptiondownbelow.
Andasyoucansee, ourfirstcellisgoingtobethatexcellsowecanremovethispackerandcolorandgetstartedonaddinginthe X Andyoumaythinktheeasywaytodothisisjusttoaddit X insidethecelllikethis.
Andnow, asyoucansee, wehave a perfectlyscaled X, whichhastheexactsamemenacebasedbetweenallofthedifferentedgeisexactlylikewewantthenextthingwewanttoworkonisthe O class.
Thecircleclass.
Sowecandoisjustmakethis a classofcircle, whichiswhatwe'regonnausetocreatethese O's righthereandagain.
Youmaythink, Let's justputin a bigcapitals.
Oh, andthatmaywork.
Butdependingonyourfontsandeverything, it's notgonnabe a perfectcircle.
Andnow, asyoucansee, weget a lightgrayexeverytimewehoveroverandup.
Andsowhenwehavethis X classonourboard, Sonowlet's justdotheexactsamething.
Butforcirclenow, weshouldget a circlewheneverwehoveroveranyofthesedifferentrose.
Thisisgonnabe a verysimilartactictowhatwedidbeforesowecouldjustfindourcirclecode, whichisrightdownhere.
Andwhatwewanttodoisyouwanttosaywhenwe'reon a boardthathasthecircleclass, wewanttogetthecellsinsideofitthatarenotalreadyin X andthatthey'renotalready a circleWewanttocheckwhenwehoverover.
Brittasaidthetop 20 thelefttozero, theratetozeroandthebottom 20 Andifwecomeinhereandwejustadd a smallbackgroundcolorsowecanactuallyseethis, we'regonnauseour G B A.
WewantustobeBlackswillsay 000 and 90% transparent.
Andasyoucansee, wehave a blackoverlycoveringtheentirescreen.
Andwe'regonnachangeourtextcolortobeWait, waitNowifweeveryoucanseeitjustinvertsthatbuttonwhichisexactlywhatwewantAndtostacktheseverticallyWecanjustchangeourflexdirectiontocolonAndasyoucanseetheseairnowstackedontopofeachotherAnditlooksreallygoodThelastthingtodoisjustbydefaultmakeitdisplayofnoneSincewedon't wantthistoshowitbydefaultandthenwecanmoveourdisplayflicksinto a separateclass.
Sowhatwecandoisjustsay, constantcellelementsisgoingtobeequaltodocumentlipsdocumentdotqueriesselectorallandremember, thesearejust a selectorofdatacelljustlikethat.
Soif I createthatfunctionofhandle, clickjustgoingtotakeourevent I justcancelledoutLogclicked.
Andif I inspectthisdragoverthisinspectionand I clickononeofthesecells, yousee, itsaysclickedif I clickthesamecellagain, isnotgoingtofireuntil I click a differentcell.
Andtodothis, we'reactuallyjustgonnadoitinsideof a functionwillpassthecurrentsoandthecurrentclassandwe'lldoitinsideofthisfunctionherewhichwecallplaceMarkwith a Soandit's goingtohave a currentclass.
Andnowwhenweclickonsomething, youcanseeit's addingit X andgonnaaddanexeverytime.
Becauserightnow a circleisalwaysfalseandwereneveractuallyswitchingturns.
Sothisisallworkingperfectlyfine.
Placingmarksisgoingwell.
We'regonnaskipcheckingforwindandcheckingfor a drawfornow, becauseswitchingturnsisthemostimportantthingtofocusoncevicheminutecreativefunctioncalledswapturns.
Sonowinsteadofhere, wefirstactuallyneedtogetourboardsowecanjustsayourboardisgoingtobedocumentthatgetelementby I D, andifyouremember, wehadan I.
D.
Ofboardisourboardelement.
Howwewantedtodoisboreddotclasslistdotremove.
Soyouwanttoremovethe X Class, andwewanttomakesureweremovethecircleclassthatwehavenoclassesonit.
Andthenifitiscirclesturncurrently.
Thenwewanttoaddinthecircleclass.
Sowe'llsayAddclassgroupsClasslistdotadandwewanttoaddinclips, CircleclassandthenotherwisewewanttoaddintheExclasseswas a boarddotclasslessdotad X classjustlikethat.
Andnow, asyoucansee, wegetthat X hoverthanthecirclehoverand X, andsoon, andit's workingfortherestofourapp.
Nowtheonlythinglefttodoistocheckforwinsandfordraws, andwhatweneedtodoiscreateanarrayforallofthewinningcombinations, andthiswinningcombinationsisgoingtobeanarrayfullof a raise.
Soif, forexample, youhadelementintherayandspot 12 andthree, youwouldbe a winnerifyouhaditin 14 andseven u.
N V.
A winnerandsoon.
Butsincethisisanarray, itneedstobezeroindex.
Sothisspotis 012 345 678 So, forexample, ifyouhad a spotinzeroofoneortwothatwouldbeconsidered a win.
Soifyouhadthreeelementsrighthere, that's a winagain.
Nowwhat's actuallygoingtofigureoutwhatwedoifthere's a draw?
Sowewerestartingtosayhereiselseifthereis a draw, sowesayis a draw, thenwhatwewanttodoisandthegamethepast, Trueforthefactthatitis a drawandthenobviouslyifit's neitherofthose, wewanttomakesureweswappedtheturnandsettheboard.
Weonlywanttoswapturnsifthere's nowinneryet.
Soinsteadof a draw, wecoulddo a verysimilarthingwinningmessagedotinhertext.
Obviouslywehaven't definedisdrawingyet, soit's actuallycreatethatfunctionisdrawandinsideofthisfunctionweneedtodo a verysimilarthingthatwedidwithourwinningcombinations.
ButessentiallywejustneedtochecktomakesureeverysinglecellhasbeenfilledsowecansaysellelementsdotEverywewanttodoiswe'regonnageteverycell, andwewanttocheckifithas a class, sowecouldjustsayso.
Thatclasslistdotcontainsthe X Classorifitcontainsthecircleclass, sowe'llsayitcontainscircleclass.
Soifeverysingleoneofthecellshaseitheran X orcircleclass, thenwewanttoreturn.
Makesure I spellthatquicklyisgoingtobeequaltodocumentthatGetelementby I d.
OfRestartButtonjustlikethat.
Letmemakesurethat's correct.
Andthenwhatwecandoiswecanjustselect a quickeventlistenersowecansayrestart, buttondotadeventlistenerEverytimewewanttoclickonit, wejustwanttocallourstartcamefunction.