Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | 2x 2x 2x 38x 38x 38x 38x 38x 38x 38x 38x 38x 11x 9x 2x 9x 38x 8x 15x 8x 8x 8x 38x 11x 6x 6x 6x 6x 6x 6x 38x 3x 3x 3x 3x 10x 10x 2x 2x 2x 2x 8x 38x 2x 2x 2x 38x 1x 1x 1x 1x 1x 1x 38x 38x 4x 4x 38x 38x 1x 1x 1x 1x 1x 38x 38x 3x 3x 3x 6x 3x 3x 3x 38x 38x 38x 114x 7x 7x 7x 4x 4x 1x 1x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import React, { useState, useRef, useContext, useEffect } from "react"; import "./SideBuilder.css"; import SideDisplay from "./SideDisplay"; import { WebSocketContext } from "../../WebSocketContext"; import { playSendSound } from "../SoundEffects/playSendSound"; import { playPopSound } from "../SoundEffects/playPopSound"; import Score from "../Score/Score"; import StationStartModal from "../Modal/StationStartModal"; import Tutorial from "../Modal/Tutorial"; const RAW_STATES = ["potatoes", "onions", "cheese"]; const SIDE_TYPES = [ { type: "potatoes", initialState: "potatoes", choppedState: "choppedPotatoes", finalState: "fries" }, { type: "onions", initialState: "onions", choppedState: "choppedOnions", finalState: "onionRings" }, { type: "cheese", initialState: "cheese", choppedState: "choppedCheese", finalState: "mozzarellaSticks" } ]; const SideBuilder = ({ score, day }) => { const [tableState, setTableState] = useState("empty"); const [sideType, setSideType] = useState(""); const [fryTimeLeft, setFryTimeLeft] = useState(0); const [confirmMessage, setConfirmMessage] = useState(""); const [isCutting, setIsCutting] = useState(false); const [showStart, setShowStart] = useState(true); const fryingIntervalRef = useRef(null); const { send } = useContext(WebSocketContext); useEffect(() => { if (showStart) { const timer = setTimeout(() => { setShowStart(false); }, 5000); return () => clearTimeout(timer); } }, [showStart]); const placeSide = (raw) => { Iif (tableState !== "empty") return; const side = SIDE_TYPES.find((s) => s.type === raw); Eif (side) { setTableState(side.initialState); setSideType(side.finalState); } }; const chopSide = () => { const side = SIDE_TYPES.find((s) => s.initialState === tableState); Iif (!side) return; setIsCutting(true); new Audio("/audio/chopping.mp3").play(); setTimeout(() => { setTableState(side.choppedState); setIsCutting(false); }, 2000); }; const startFrying = (finalState) => { setTableState("frying"); setFryTimeLeft(5); Iif (fryingIntervalRef.current) clearInterval(fryingIntervalRef.current); fryingIntervalRef.current = setInterval(() => { setFryTimeLeft((t) => { if (t <= 1) { clearInterval(fryingIntervalRef.current); fryingIntervalRef.current = null; setTableState(finalState); return 0; } return t - 1; }); }, 1000); }; const reset = () => { setTableState("empty"); setFryTimeLeft(0); Iif (fryingIntervalRef.current) clearInterval(fryingIntervalRef.current); }; const sendSide = () => { Iif (tableState === "empty" || tableState === "frying") return; send({ data: { type: "game_state", game_state_update_type: "order_component", component_type: "side", component: { table_state: tableState } } }); playSendSound(); reset(); setConfirmMessage("Side sent to manager!"); setTimeout(() => setConfirmMessage(""), 3000); }; const onDragStart = (e, item) => e.dataTransfer.setData("item", item); const allowDrop = (e) => { e.preventDefault(); e.currentTarget.classList.add("drop-hover"); }; const clearHover = (e) => e.currentTarget.classList.remove("drop-hover"); const onTableDrop = (e) => { e.preventDefault(); clearHover(e); const item = e.dataTransfer.getData("item"); Iif (item === "knife") chopSide(); else Eif (RAW_STATES.includes(item)) placeSide(item); }; const onKnifeDrop = (e) => { e.preventDefault(); clearHover(e); chopSide(); }; const onFryerDrop = (e) => { e.preventDefault(); clearHover(e); const item = e.dataTransfer.getData("item"); const side = SIDE_TYPES.find((s) => s.choppedState === item); Eif (side) { new Audio("/audio/frying.mp3").play(); startFrying(side.finalState); } }; const playRepeat = () => new Audio("/audio/repeat_order.mp3").play(); const overlayImage = sideType === "fries" ? "/images/station_specific/choppedPotatoes.png" : sideType === "onionRings" ? "/images/food_side_view/sliced_onion.png" : sideType === "mozzarellaSticks" ? "/images/food_side_view/SlicedMozzarella.png" : null; return ( <> {showStart && ( <StationStartModal stationName="Side" handleClick={() => setShowStart(false)} /> )} {!showStart && ( <Tutorial classNames={[ "LeftColumn", "ChopButton", "Fryer", "SendButton", ]} audioSourceFolder={"/audio/tutorial/side"} /> )} <div className="SideBuilder"> <div className="TopMenuSides"> <Score score={score} day={day} /> </div> <div className="MainContainer2"> <div className="LeftColumn"> {RAW_STATES.map((raw) => ( <button key={raw} className="LeftButtons" disabled={tableState !== "empty"} onClick={() => { placeSide(raw); playPopSound(); switch (raw){ case "potatoes": new Audio(`/audio/potato.mp3`).play(); break; case "onions": new Audio(`/audio/onion.mp3`).play(); break; default: new Audio(`/audio/${raw}.mp3`).play(); } }} draggable onDragStart={(e) => onDragStart(e, raw)} > <img src={ raw === "potatoes" ? "/images/station_specific/potatoButton.png" : raw === "onions" ? "/images/aac_icons/onion.png" : "/images/food_side_view/Mozzarella.png" } alt={raw} className={`ButtonImages ${raw}-img`} /> {raw.charAt(0).toUpperCase() + raw.slice(1)} </button> ))} </div> <div className={`TableBorder ${isCutting ? "cutting" : ""}`} draggable={tableState !== "empty" && tableState !== "frying"} onDragStart={(e) => onDragStart(e, tableState)} onDragOver={allowDrop} onDrop={onTableDrop} onDragLeave={clearHover} > <SideDisplay tableState={tableState} fryTimeLeft={fryTimeLeft} onDragStart={onDragStart} /> </div> <div className="RightColumn"> <button className="ChopButton" disabled={!RAW_STATES.includes(tableState)} draggable onDragStart={(e) => onDragStart(e, "knife")} onDragOver={allowDrop} onDrop={onKnifeDrop} onDragLeave={clearHover} onClick={chopSide} > <img src="/images/station_specific/knife.png" alt="knife" className="ButtonImages" /> Chop </button> <button className="RightButtons" onDragOver={allowDrop} onDragLeave={clearHover} onDrop={(e) => { e.preventDefault(); clearHover(e); reset(); playPopSound(); }} onClick={() => { reset(); playPopSound(); }} > <img src="/images/button_icons/clear_plate.png" alt="reset" className="ResetImage" /> Reset </button> <button className="SendButton" disabled={tableState === "empty" || tableState === "frying"} onDragOver={allowDrop} onDragLeave={clearHover} onDrop={(e) => { e.preventDefault(); clearHover(e); Eif (tableState !== "empty" && tableState !== "frying") { playPopSound(); sendSide(); } }} onClick={() => { playPopSound(); sendSide(); }} > <img src="/images/button_icons/bag.png" alt="send" className="SendImg" /> Send </button> <button className="RightButtons" onClick={() => { playPopSound(); playRepeat(); }}> <img src="/images/button_icons/repeat_order.png" className="RepeatOrderImage" alt="Repeat" /> Repeat Order </button> </div> </div> <div className={`Fryer ${tableState === "frying" ? "frying" : ""}`} onDragOver={allowDrop} onDrop={onFryerDrop} onDragLeave={clearHover} > <img src="/images/station_specific/fryer.png" alt="Fryer" className="FryerImage" /> {tableState === "frying" && overlayImage && ( <img src={overlayImage} alt="" className="ChoppedOverlay" /> )} </div> {confirmMessage && ( <div className="ConfirmMessage"> <p>{confirmMessage}</p> </div> )} </div> </> ); }; export default SideBuilder; |