Added deck search and more hotkeys🔍
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
</aside>
|
||||
<aside id="piles">
|
||||
<div class="pile" id="deck">
|
||||
<img src="./card_back.png" alt="" id="deck" />
|
||||
<img src="./card_back.png" alt="" id="deck-img" />
|
||||
<span id="deck-count"></span>
|
||||
</div>
|
||||
<div class="pile" id="discard-pile">
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
const $view-card-container = document.query-selector '#view-card-container'
|
||||
const $param = document.query-selector '#param'
|
||||
const $play = document.query-selector '#play'
|
||||
window.$play = play
|
||||
const $discard-pile = document.query-selector '#discard-pile'
|
||||
const $discard-pile-img = document.query-selector '#discard-pile-img'
|
||||
const $discard-pile-count = document.query-selector '#discard-pile-count'
|
||||
@ -19,6 +18,7 @@
|
||||
const $shadow-realm-img = document.query-selector '#shadow-realm-img'
|
||||
const $shadow-realm-count = document.query-selector '#shadow-realm-count'
|
||||
const $deck = document.query-selector '#deck'
|
||||
const $deck-img = document.query-selector '#deck-img'
|
||||
const $deck-count = document.query-selector '#deck-count'
|
||||
const $extra = document.query-selector '#extra'
|
||||
const [push-param, pop-param] = (->
|
||||
@ -82,7 +82,7 @@
|
||||
$view-card.style.opacity = 1
|
||||
e.target.add-event-listener \mouseleave hide-card$
|
||||
state = await get-state!
|
||||
const apply-state$ = ->
|
||||
const apply-state$ = ->>
|
||||
{ player-state } = it
|
||||
gen-opponent-cards$ player-state.opponent_cards_in_hand
|
||||
if document.body.class-list.contains \my-turn
|
||||
@ -109,7 +109,8 @@
|
||||
| \discard => player-state.discard_pile
|
||||
| \shadow => player-state.shadow_realm
|
||||
| \deck => gen-array-of state.player-state.deck_size, null
|
||||
| _ => (console.log that) || []
|
||||
| \deck-revealed => await fetch-log \./get_deck .then (.json!)
|
||||
| _ => (console.error that) || []
|
||||
open-list list, $extra.get-attribute \data-pile-type
|
||||
if player-state.hand.length != $own-hand.children.length
|
||||
$own-hand.innerHTML = ''
|
||||
@ -212,8 +213,11 @@
|
||||
$play.add-event-listener \dragover (.prevent-default!)
|
||||
|
||||
$discard-pile-img.add-event-listener \click -> open-list state.player-state.discard_pile, \discard
|
||||
$discard-pile-count.add-event-listener \click -> open-list state.player-state.discard_pile, \discard
|
||||
$shadow-realm-img.add-event-listener \click -> open-list state.player-state.shadow_realm, \shadow
|
||||
$deck.add-event-listener \click -> open-list (gen-array-of state.player-state.deck_size, null), \deck
|
||||
$shadow-realm-count.add-event-listener \click -> open-list state.player-state.shadow_realm, \shadow
|
||||
$deck-img.add-event-listener \click -> open-list (gen-array-of state.player-state.deck_size, null), \deck
|
||||
$deck-count.add-event-listener \click -> open-list (gen-array-of state.player-state.deck_size, null), \deck
|
||||
|
||||
set-interval (->>
|
||||
const new-state = await get-state!
|
||||
@ -234,8 +238,12 @@
|
||||
..add-event-listener \keyup ->
|
||||
$current-mouse-node = [...document.query-selector-all \:hover][* - 1]
|
||||
switch it.key.to-lower-case!
|
||||
| \v =>
|
||||
fetch-log \./shuffle
|
||||
if $extra.has-attribute \data-pile-type and \deck-revealed == $extra.get-attribute \data-pile-type
|
||||
$extra.class-list.add \hidden
|
||||
| \c => fetch-log "./draw/#{pop-param!}"
|
||||
| \e => fetch-log "./pass"
|
||||
| \e => fetch-log \./pass
|
||||
| \0 \1 \2 \3 \4 \5 \6 \7 \8 \9 => push-param that
|
||||
| \t =>
|
||||
if $current-mouse-node?.has-attribute \data-hand-index
|
||||
@ -256,6 +264,8 @@
|
||||
switch $current-mouse-node.get-attribute \data-list-type
|
||||
| \discard
|
||||
fetch-log "./unkill/#{$current-mouse-node.get-attribute \data-index}"
|
||||
| \deck , \deck-revealed
|
||||
return # will add play button
|
||||
| \shadow
|
||||
fetch-log "./unbanish/#{$current-mouse-node.get-attribute \data-index}"
|
||||
$current-mouse-node.parent-element.remove-child $current-mouse-node
|
||||
@ -269,8 +279,8 @@
|
||||
switch $current-mouse-node.get-attribute \data-list-type
|
||||
| \discard
|
||||
fetch-log "./undiscard/#{$current-mouse-node.get-attribute \data-index}"
|
||||
| \deck
|
||||
void #fetch-log "./unshadow/#{$current-mouse-node.get-attribute \data-index}"
|
||||
| \deck , \deck-revealed
|
||||
fetch-log "./yoink/#{$current-mouse-node.get-attribute \data-index}"
|
||||
| \shadow
|
||||
fetch-log "./remember/#{$current-mouse-node.get-attribute \data-index}"
|
||||
$current-mouse-node.parent-element.remove-child $current-mouse-node
|
||||
@ -285,11 +295,11 @@
|
||||
else if $current-mouse-node?.has-attribute \data-list-type
|
||||
switch $current-mouse-node.get-attribute \data-list-type
|
||||
| \discard
|
||||
return #fetch-log "./unkill/#{$current-mouse-node.get-attribute \data-index}"
|
||||
| \deck
|
||||
void #fetch-log "./unkill/#{$current-mouse-node.get-attribute \data-index}"
|
||||
return
|
||||
| \deck , \deck-revealed
|
||||
fetch-log "./yoink_mill/#{$current-mouse-node.get-attribute \data-index}"
|
||||
| \shadow
|
||||
fetch-log "./unshadow/#{$current-mouse-node.get-attribute \data-index}"
|
||||
fetch-log "./undiscard/#{$current-mouse-node.get-attribute \data-index}"
|
||||
$current-mouse-node.parent-element.remove-child $current-mouse-node
|
||||
if !$extra.child-element-count
|
||||
$extra.class-list.add \hidden
|
||||
@ -303,10 +313,10 @@
|
||||
switch $current-mouse-node.get-attribute \data-list-type
|
||||
| \discard
|
||||
fetch-log "./shadow/#{$current-mouse-node.get-attribute \data-index}"
|
||||
| \deck
|
||||
void #fetch-log "./unbanish/#{$current-mouse-node.get-attribute \data-index}"
|
||||
| \deck , \deck-revealed
|
||||
fetch-log "./yoink_xmill/#{$current-mouse-node.get-attribute \data-index}"
|
||||
| \shadow
|
||||
return #fetch-log "./unshadow/#{$current-mouse-node.get-attribute \data-index}"
|
||||
return
|
||||
$current-mouse-node.parent-element.remove-child $current-mouse-node
|
||||
if !$extra.child-element-count
|
||||
$extra.class-list.add \hidden
|
||||
@ -315,10 +325,13 @@
|
||||
$extra.class-list.add \hidden
|
||||
$extra.remove-attribute \data-pile-type
|
||||
| \x =>
|
||||
console.log
|
||||
if it.shift-key || state.player-state.turn_player == state.player-state.you
|
||||
fetch-log \./untap_all
|
||||
[...$play.children]
|
||||
.filter -> \true == it.get-attribute \data-owned
|
||||
.for-each -> it.set-attribute \data-tapped false
|
||||
| \f =>
|
||||
fetch-log \./get_deck .then ->>
|
||||
const deck = await it.json!
|
||||
open-list deck, \deck-revealed
|
||||
)!
|
||||
|
||||
Reference in New Issue
Block a user