From 1962a4c5866109732727ca55c4214f9ef1baa62a Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 21 Oct 2023 16:34:33 +0200 Subject: Battle box. --- play.css | 29 +++++++++++++++---------- play.html | 16 +++++++------- play.js | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++------------- 3 files changed, 85 insertions(+), 34 deletions(-) diff --git a/play.css b/play.css index 274cf68..fc62746 100644 --- a/play.css +++ b/play.css @@ -107,10 +107,6 @@ header.your_turn { background-color: orange; } position: absolute; } -#map svg image { - pointer-events: none; -} - #map svg path.area { fill: green; stroke: green; @@ -147,6 +143,14 @@ header.your_turn { background-color: orange; } fill: none; } +#map svg path.area.battle { + fill-opacity: 0.6; + stroke-opacity: 0.8; + fill: #600; + stroke-width: 60; + stroke: #700; +} + #map.hide_blocks #blocks { visibility: hidden; } @@ -159,11 +163,11 @@ body.shift .block.known:hover { z-index: 100; } -#battle div.block { +#battle > div.block { position: relative; } -#map div.block { +#blocks > div.block { position: absolute; } @@ -196,6 +200,11 @@ div.block.selected { box-shadow: 0 0 3px 1px yellow; } div.block.moved { filter: grayscale(50%) brightness(85%); } div.block.highlight.moved { filter: grayscale(60%) brightness(95%); } +/* +div.block.battle { filter: grayscale(80%) brightness(50%) !important } +*/ +div.block.battle { opacity: 0; pointer-events: none; } + div.block:hover { z-index: 1; } div.block.r1 { transform: rotate(-90deg); } @@ -203,15 +212,13 @@ div.block.r2 { transform: rotate(-180deg); } div.block.r3 { transform: rotate(-270deg); } div.block { - transition-property: top, left, transform; - transition-duration: 700ms, 700ms, 200ms; - transition-timing-function: ease; + transition-property: top, left, transform, opacity; + transition-duration: 700ms, 700ms, 250ms, 250ms; + transition-timing-function: ease, ease, ease, linear; } /* BATTLE BOARD */ -#battle { top: 295px; left: 195px; } - #battle { background-color: silver; } #battle_message { background-color: lightsteelblue; } #battle_header { background-color: steelblue; color: white; } diff --git a/play.html b/play.html index c6b06f5..0f935fe 100644 --- a/play.html +++ b/play.html @@ -21,10 +21,10 @@
- Notes - Rules - Cards - Blocks +
  • Notes +
  • Rules +
  • Cards +
  • Blocks
  • Resign
  • @@ -59,17 +59,17 @@
    +
    -
    -
    +
    +
    -
    +
    -
    > 1 + + // reset position + box.classList.add("show") + box.style.top = null + box.style.left = null + box.setAttribute("open", true) + + // calculate size + let w = box.clientWidth + let h = box.clientHeight + + // center where possible + let x = space.x - w / 2 + if (x < 60) + x = 60 + if (x > 1688 - w - 60) + x = 1688 - w - 60 + + let y = space.y - sh - h - 60 + if (y < 60) + y = space.y + sh + 60 + + box.style.top = y + "px" + box.style.left = x + "px" + + scroll_into_view_if_needed(box) +} + function update_battle() { function fill_cell(name, list, reserve) { let cell = window[name] @@ -816,25 +862,23 @@ function on_update() { remember_position(ui.cards[c]) update_cards() - update_map() if (view.battle) { document.getElementById("battle_header").textContent = view.battle.title document.getElementById("battle_message").textContent = view.battle.flash - if (!document.getElementById("battle").classList.contains("show")) { - document.getElementById("battle").classList.add("show") - scroll_into_view_if_mobile(document.getElementById("battle")) - } update_battle() + if (!document.getElementById("battle").classList.contains("show")) + show_battle() } else { document.getElementById("battle").classList.remove("show") } + update_map() + for (let c = 1; c <= 25; ++c) animate_position(ui.cards[c]) } -build_map() +document.getElementById("battle").addEventListener("toggle", on_update) -drag_element_with_mouse("#battle", "#battle_header") -scroll_with_middle_mouse("main", 2) +build_map() -- cgit v1.2.3