Modern Full-Stack Development


The Big Kahuna: tileClick()



Download 5,64 Mb.
Pdf ko'rish
bet87/107
Sana06.08.2021
Hajmi5,64 Mb.
#140576
1   ...   83   84   85   86   87   88   89   90   ...   107
Bog'liq
Modern Full-Stack Development Using TypeScript, React, Node

 The Big Kahuna: tileClick()
Now we come to what is the longest, probably most complex (though it’s still nothing 
overly complicated!) and certainly key bit of code that makes BattleJong tick: the one that 
gets called any tile you click a tile:
tileClick : function(inLayer: number, inRow: number,
  inColumn: number) {
Chapter 11   time for fun: BattleJong, the Client


336
The tileClick() method is passed the layer, row, and column of the tile that the 
player clicked. That’s all it needs to do its work. But, before it even gets to the real work, 
there are a few trivial rejections that need to be done:
if (this.state.gameState !== "playing") {
  return;
}
The board isn’t visible until gameState is either “playing” or “gameOver”, but in 
the latter case, we don’t want the player to be able to click tiles, so we’ll abort early if 
gameState isn’t “playing”.
Next, we need to determine if a tile can be selected:
if (!this.state.canTileBeSelected(inLayer, inRow, inColumn)) {
  return;
}
The canTileBeSelected() is a helper function that tells us whether a tile is free, in 
terms of Mahjongg rules. Let’s jump over to that function now.

Download 5,64 Mb.

Do'stlaringiz bilan baham:
1   ...   83   84   85   86   87   88   89   90   ...   107




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish