{"version":3,"sources":["akq_image.png","Rules.js","Room.js","App.js","serviceWorker.js","index.js"],"names":["module","exports","Rules","useState","isVisible","setIsVisible","Modal","open","closeOnDimmerClick","trigger","className","onClick","size","Header","icon","content","Content","Button","color","Actions","cards","API_URL","process","WEBSOCKET","Room","props","slug","match","params","id","state","gameState","playerNumber","myScore","opponentScore","myCard","opponentCard","roundNumber","modal","myAction","opponentAction","winner","pot","rules","finish","waiting","message","bind","buttonPanel","score","join","handleMessage","handleJoin","handleTurn","handleCards","nextRound","move","finishRound","this","conn","WebSocket","onmessage","messageArray","data","split","messageData","console","log","JSON","parse","type","player_number","action","valid","handleFinish","setState","player_1_card","player_2_card","roundPacket","send","stringify","finishPacket","axios","put","headers","then","res","joinPacket","num_clients","turnPacket","result","style","display","Dimmer","active","Loader","to","Icon","name","text","Component","App","redirect","setRedirect","createGame","post","joinGame","prompt","path","component","render","src","akq_image","alt","Boolean","window","location","hostname","ReactDOM","document","getElementById","navigator","serviceWorker","ready","registration","unregister","catch","error"],"mappings":"2GAAAA,EAAOC,QAAU,IAA0B,uC,uTCG9BC,EAAQ,WAAO,IAAD,EAESC,oBAAS,GAFlB,mBAElBC,EAFkB,KAEPC,EAFO,KAIzB,OACE,kBAACC,EAAA,EAAD,CAAOC,KAAMH,EACXI,oBAAoB,EACpBC,QAAS,uBAAGC,UAAU,iBAAiBC,QAAS,kBAAMN,GAAa,MACnEO,KAAK,SACL,kBAACC,EAAA,EAAD,CAAQC,KAAK,OAAOC,QAAQ,sBAC5B,kBAACT,EAAA,EAAMU,QAAP,KACE,yBAAKN,UAAU,iBAEb,4BACE,uHACA,yEACA,uHACA,yBAAKA,UAAU,gBACb,yBAAKA,UAAU,UAAS,kBAACO,EAAA,EAAD,cACxB,yBAAKP,UAAU,UAAS,kBAACO,EAAA,EAAD,CAAQC,MAAM,UAAd,WAE1B,mNAEA,yBAAKR,UAAU,gBACb,yBAAKA,UAAU,UAAS,kBAACO,EAAA,EAAD,CAAQC,MAAM,OAAd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AS+F,GAA9B,wBC1DFQ,QACW,cAA7BC,OAAOC,SAASC,UAEe,UAA7BF,OAAOC,SAASC,UAEhBF,OAAOC,SAASC,SAAS1F,MACvB,2DCZN2F,IAASR,OAAO,kBAAC,EAAD,MAASS,SAASC,eAAe,SD6H3C,kBAAmBC,WACrBA,UAAUC,cAAcC,MACrBtC,MAAK,SAAAuC,GACJA,EAAaC,gBAEdC,OAAM,SAAAC,GACL7D,QAAQ6D,MAAMA,EAAMjF,c","file":"static/js/main.834b4486.chunk.js","sourcesContent":["module.exports = __webpack_public_path__ + \"static/media/akq_image.df786eab.png\";","import React, { useState } from 'react'\nimport { Button, Header, Modal } from 'semantic-ui-react'\n\nexport const Rules = () => {\n\n const [isVisible, setIsVisible] = useState(false);\n\n return (\n setIsVisible(true)}>}\n size='small'>\n
\n \n
\n\n
    \n
  • To play, each player starts by paying 1 chip. This is done the beginning of each round
  • \n
  • Players alternate going first and second
  • \n
  • The first player has the option of passing (paying 0 chips) or raising (paying 1 chip)
  • \n
    \n
    \n
    \n
    \n
  • The second player has the option of giving up (losing 1 chip paid at the beginning) or matching what player 1 did (paying 0 chips if\n player 1 passed or 1 chip if player 1 raised)
  • \n
    \n
    \n
    \n
    \n
  • If the second player gives up, the first player wins automatically
  • \n
  • If the second player matches the amount player 1 put in, then the player with the highest card is the winner\n
  • \n
  • The winner of each round takes all chips paid in the round, including the chips paid by each player at the start of the round\n
  • \n
  • A is higher than K, K is higher than Q, and transitively, A is higher than Q\n
  • \n
\n
\n
\n \n \n \n \n )\n}\n\n","import React, { Component } from 'react';\nimport { Button, Modal, Header, Dimmer, Loader } from 'semantic-ui-react';\nimport axios from \"axios\";\nimport {CopyToClipboard} from 'react-copy-to-clipboard';\nimport './App.css';\nimport { Icon } from 'semantic-ui-react'\nimport { NavLink } from 'react-router-dom';\nimport { Rules } from \"./Rules\";\n\nconst cards = [\"A\", \"K\", \"Q\"]\nconst API_URL = process.env.REACT_APP_API_URL ?? \"http://localhost:8080/api\"\nconst WEBSOCKET = process.env.REACT_APP_WEBSOCKET ?? \"ws://localhost:8080/ws\"\n\nclass Room extends Component {\n constructor(props) {\n super(props);\n const slug = this.props.match.params.id;\n this.state = {\n slug: slug,\n // gameState information\n // 0 means waiting for player to join\n // 1 means player 1's turn\n // 2 means player 2's turn\n // 3 means final result displayed + update score + next round button appears\n // 4 is waiting page for both players to hit next round\n gameState: 0,\n playerNumber: 0,\n myScore: 100,\n opponentScore: 100,\n myCard: -1,\n opponentCard: \"\",\n roundNumber: 0,\n modal: true,\n myAction: \"\",\n opponentAction: \"\",\n winner: 0,\n pot: 0,\n rules: false,\n finish: 0,\n waiting: false,\n }\n this.message = this.message.bind(this)\n this.buttonPanel = this.buttonPanel.bind(this)\n this.score = this.score.bind(this)\n this.join = this.join.bind(this)\n this.handleMessage = this.handleMessage.bind(this)\n this.handleJoin = this.handleJoin.bind(this)\n this.handleTurn = this.handleTurn.bind(this)\n this.handleCards = this.handleCards.bind(this)\n this.nextRound = this.nextRound.bind(this)\n this.move = this.move.bind(this)\n this.finishRound = this.finishRound.bind(this)\n }\n\n componentDidMount() {\n this.conn = new WebSocket(WEBSOCKET);\n this.conn.onmessage = (message) => {\n const messageArray = message.data.split(\"\\n\");\n for (const messageData of messageArray) {\n console.log(messageData)\n this.handleMessage(JSON.parse(messageData));\n }\n };\n }\n\n handleMessage(message) {\n // filter messages only relevant to current room\n if (message.slug === this.state.slug) {\n if (message.type === \"join\") this.handleJoin(message.player_number);\n else if (message.type === \"turn\") this.handleTurn(message.player_number, message.action);\n else if (message.type === \"round\" && message.valid) this.handleCards(message);\n else if (message.type === \"finish\") this.handleFinish(message);\n }\n }\n\n handleFinish(message) {\n if (this.state.finish + message.player_number === 3) {\n this.nextRound();\n } else{\n this.setState({\n opponentScore: (this.state.winner !== this.state.playerNumber)? this.state.opponentScore + this.state.pot : this.state.opponentScore,\n myScore: (this.state.winner === this.state.playerNumber)? this.state.myScore + this.state.pot : this.state.myScore,\n finish: message.player_number,\n }); \n }\n }\n\n handleCards(message) {\n if (this.state.roundNumber === 0) {\n if (this.state.playerNumber === 1) {\n this.setState({\n roundNumber: 1,\n myCard: message.player_1_card,\n opponentCard: message.player_2_card,\n gameState: 1,\n myAction: \"\",\n opponentAction: \"\",\n myScore: this.state.myScore - 1,\n opponentScore: this.state.opponentScore -1,\n pot: 2,\n finish:0,\n waiting: false,\n winner:0,\n })\n } else {\n this.setState({\n roundNumber: 1,\n myCard: message.player_2_card,\n opponentCard: message.player_1_card,\n gameState: 1,\n myAction: \"\",\n opponentAction: \"\",\n myScore: this.state.myScore - 1,\n opponentScore: this.state.opponentScore -1,\n pot: 2,\n finish:0,\n waiting: false,\n winner:0,\n })\n }\n } else {\n if (this.state.playerNumber === 1) {\n this.setState({\n roundNumber: this.state.roundNumber + 1,\n playerNumber: this.state.playerNumber % 2 + 1,\n myCard: message.player_2_card,\n opponentCard: message.player_1_card,\n gameState: 1,\n myAction: \"\",\n opponentAction: \"\",\n myScore: this.state.myScore - 1,\n opponentScore: this.state.opponentScore -1,\n pot: 2,\n finish:0,\n waiting: false,\n winner:0,\n })\n } else {\n this.setState({\n roundNumber: this.state.roundNumber + 1,\n playerNumber: this.state.playerNumber % 2 + 1,\n myCard: message.player_1_card,\n opponentCard: message.player_2_card,\n gameState: 1,\n myAction: \"\",\n opponentAction: \"\",\n myScore: this.state.myScore - 1,\n opponentScore: this.state.opponentScore -1,\n pot: 2,\n finish:0,\n waiting: false,\n winner:0,\n })\n }\n }\n }\n\n handleJoin(playerNumber) {\n if (playerNumber === 2) {\n this.nextRound()\n }\n }\n\n handleTurn(playerNumber, action) {\n if (this.state.playerNumber === 1) {\n if (playerNumber === 1) {\n this.setState({\n gameState: 2,\n myAction: action,\n pot: (action === \"raise\")? this.state.pot + 1 : this.state.pot,\n myScore: (action === \"raise\")? this.state.myScore - 1 : this.state.myScore,\n })\n } else if (playerNumber === 2) {\n this.setState({\n gameState: 3,\n opponentAction: action,\n opponentScore: (action === \"match\" && this.state.pot === 3)? this.state.opponentScore - 1 : this.state.opponentScore,\n pot: (action === \"match\" && this.state.pot === 3)? this.state.pot + 1 : this.state.pot,\n winner: (this.state.myCard < this.state.opponentCard || action === \"give up\") ? 1 : 2\n })\n }\n } else if (this.state.playerNumber === 2) {\n if (playerNumber === 1) {\n this.setState({\n gameState: 2,\n opponentAction: action,\n opponentScore: (action === \"raise\")? this.state.opponentScore - 1 : this.state.opponentScore,\n pot: (action === \"raise\")? this.state.pot + 1 : this.state.pot,\n })\n } else if (playerNumber === 2) {\n this.setState({\n gameState: 3,\n myAction: action,\n myScore: (action === \"match\" && this.state.pot === 3)? this.state.myScore - 1 : this.state.myScore,\n pot: (action === \"match\" && this.state.pot === 3)? this.state.pot + 1 : this.state.pot,\n winner: (this.state.myCard > this.state.opponentCard || action === \"give up\") ? 1 : 2\n })\n }\n }\n }\n\n nextRound() {\n let roundPacket = {\n type: 'round',\n player_number: this.state.playerNumber,\n slug: this.state.slug\n };\n\n // Connected to remote\n this.conn.send(JSON.stringify(roundPacket));\n }\n\n finishRound() {\n let finishPacket = {\n type: 'finish',\n player_number: this.state.playerNumber,\n slug: this.state.slug\n };\n\n // Connected to remote\n this.conn.send(JSON.stringify(finishPacket));\n this.setState({\n waiting: true\n })\n }\n\n join() {\n axios.put(API_URL + \"/rooms/join/\" + this.state.slug,\n {},\n {\n headers: { \"Access-Control-Allow-Origin\": \"*\" }\n }).then((res) => {\n let joinPacket = {\n type: 'join',\n player_number: res.data.num_clients,\n slug: this.state.slug\n };\n\n // Connected to remote\n this.conn.send(JSON.stringify(joinPacket));\n\n this.setState({\n playerNumber: res.data.num_clients,\n modal: false\n })\n })\n }\n\n move(action) {\n let turnPacket = {\n type: 'turn',\n player_number: this.state.playerNumber,\n slug: this.state.slug,\n action: action\n };\n\n // Connected to remote\n this.conn.send(JSON.stringify(turnPacket));\n this.setState({\n gameState: this.state.gameState + 1\n })\n }\n\n message() {\n if (this.state.myCard === -1 || this.state.waiting) {\n return (\n
\n )\n } else {\n return (\n
\n Round {this.state.roundNumber}: You have been dealt {cards[this.state.myCard]}\n
\n )\n }\n }\n\n result() {\n if (this.state.playerNumber === 1 || this.state.playerNumber === 2) {\n return (\n
\n
Results:
\n
Your card: {cards[this.state.myCard]}, Opponent's card: {cards[this.state.opponentCard]}
\n
Your action: {this.state.myAction}, Opponent's action: {this.state.opponentAction}
\n
You win {(this.state.winner === this.state.playerNumber)? this.state.pot : 0}
\n
\n
\n )\n } else {\n return (\n
\n )\n }\n \n }\n\n buttonPanel() {\n if (this.state.waiting) {\n return (\n
\n Waiting for opponent...\n
\n )\n }\n if (this.state.gameState === 3) {\n return this.result()\n }\n if (this.state.playerNumber === 1) {\n if (this.state.gameState === 1) {\n return (\n
\n
It's your turn!
\n
\n
\n
\n
\n
\n )\n } else if (this.state.gameState === 2) {\n return (\n
\n Action taken: {this.state.myAction}. Waiting for opponent...\n
\n )\n } else {\n return (\n
\n Waiting for opponent...\n
\n )\n }\n } else if (this.state.playerNumber === 2) {\n if (this.state.gameState === 2) {\n return (\n
\n
Opponent chose to {this.state.opponentAction}, now it's your turn!
\n
\n
\n
\n
\n
\n )\n } else {\n return (\n
\n Waiting for opponent...\n
\n )\n }\n } else {\n return (\n
\n )\n }\n }\n\n score() {\n if (this.state.playerNumber === 1 || this.state.playerNumber === 2) {\n return (\n
\n
\n Your score: {this.state.myScore}\n
\n
\n Opponent's score: {this.state.opponentScore}\n
\n
\n )\n } else if (this.state.playerNumber === 0) {\n return (\n
\n \n \n \n Loading ...\n
\n )\n } else {\n return (\n
\n Room at capacity. Please create another game.\n
\n )\n }\n }\n\n render() {\n return (\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n {this.message()}\n {this.buttonPanel()}\n {this.score()}\n
\n
\n Game code is: {this.state.slug}\n \n \n \n
\n
\n
\n \n
\n \n
\n

\n Welcome to the AKQ game! Below are some tips to guide you:\n

\n\n
    \n
  • On the top of the page, there will be a help button\n containing the rules should you need it.
  • \n
  • Your game code is {this.state.slug}
  • \n
  • Only share the game code with one other person.
  • \n
  • Never refresh or press back; all progress will be lost.
  • \n
  • There may be lag at times so please be patient.
  • \n
  • If the site breaks down or is taking too long, both players should exit and create a new game.
  • \n
  • Since it costs 1 chip to play, 1 chip is deducted from both player's scores at the start of each round.
  • \n
  • The player going first sees the following buttons:
  • \n
    \n
    \n
    \n
    \n
  • The player going second sees the following buttons:
  • \n
    \n
    \n
    \n
    \n
\n
\n\n
\n \n\n \n \n \n
\n )\n }\n}\n\nexport default Room;","import React, { useState } from 'react';\nimport { Button } from 'semantic-ui-react';\nimport { BrowserRouter, Redirect, Route, Switch } from \"react-router-dom\";\nimport axios from \"axios\";\nimport Room from \"./Room\";\nimport './App.css';\nimport akq_image from './akq_image.png';\nimport { Icon } from 'semantic-ui-react'\nimport { NavLink } from 'react-router-dom';\nimport { Rules } from \"./Rules\";\n\nconst API_URL = process.env.REACT_APP_API_URL ?? \"http://localhost:8080/api\"\n\nexport const App = () => {\n\n const [redirect, setRedirect] = useState(null)\n\n const createGame = () => {\n axios.post(API_URL + \"/rooms\",\n { \"num_clients\": 0 },\n {\n headers: { \"Access-Control-Allow-Origin\": \"*\" }\n }).then(res => {\n setRedirect(\"/room/\" + res.data.slug)\n })\n }\n\n const joinGame = () => {\n let slug = prompt(\"Enter room code:\")\n if (slug !== null) {\n setRedirect(\"/room/\" + slug)\n } else {\n setRedirect(\"/\")\n }\n }\n\n return (\n \n {redirect && }\n
\n \n \n { }} />\n {\n return (\n
\n
\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n

AKQ

\n

A 2-player, 3-card, betting game

\n
\n \"\"/\n
\n The AKQ game is a game that involves a deck containing exactly three cards the ace (A), the king (K), and the queen (Q). To learn the rules, click the question mark icon. To return to this page, click the home icon. To begin game play, create a game below and share the game code or link with another player. To join a game, click the join game button.\n
\n
\n
\n \n
\n
\n \n
\n
\n
\n
\n );\n }} />\n
\n
\n
\n );\n}\n\nexport default App;\n","// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n window.location.hostname === 'localhost' ||\n // [::1] is the IPv6 localhost address.\n window.location.hostname === '[::1]' ||\n // 127.0.0.0/8 are considered localhost for IPv4.\n window.location.hostname.match(\n /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n )\n);\n\nexport function register(config) {\n if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n // The URL constructor is available in all browsers that support SW.\n const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n if (publicUrl.origin !== window.location.origin) {\n // Our service worker won't work if PUBLIC_URL is on a different origin\n // from what our page is served on. This might happen if a CDN is used to\n // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n return;\n }\n\n window.addEventListener('load', () => {\n const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n if (isLocalhost) {\n // This is running on localhost. Let's check if a service worker still exists or not.\n checkValidServiceWorker(swUrl, config);\n\n // Add some additional logging to localhost, pointing developers to the\n // service worker/PWA documentation.\n navigator.serviceWorker.ready.then(() => {\n console.log(\n 'This web app is being served cache-first by a service ' +\n 'worker. To learn more, visit https://bit.ly/CRA-PWA'\n );\n });\n } else {\n // Is not localhost. Just register service worker\n registerValidSW(swUrl, config);\n }\n });\n }\n}\n\nfunction registerValidSW(swUrl, config) {\n navigator.serviceWorker\n .register(swUrl)\n .then(registration => {\n registration.onupdatefound = () => {\n const installingWorker = registration.installing;\n if (installingWorker == null) {\n return;\n }\n installingWorker.onstatechange = () => {\n if (installingWorker.state === 'installed') {\n if (navigator.serviceWorker.controller) {\n // At this point, the updated precached content has been fetched,\n // but the previous service worker will still serve the older\n // content until all client tabs are closed.\n console.log(\n 'New content is available and will be used when all ' +\n 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n );\n\n // Execute callback\n if (config && config.onUpdate) {\n config.onUpdate(registration);\n }\n } else {\n // At this point, everything has been precached.\n // It's the perfect time to display a\n // \"Content is cached for offline use.\" message.\n console.log('Content is cached for offline use.');\n\n // Execute callback\n if (config && config.onSuccess) {\n config.onSuccess(registration);\n }\n }\n }\n };\n };\n })\n .catch(error => {\n console.error('Error during service worker registration:', error);\n });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n // Check if the service worker can be found. If it can't reload the page.\n fetch(swUrl, {\n headers: { 'Service-Worker': 'script' },\n })\n .then(response => {\n // Ensure service worker exists, and that we really are getting a JS file.\n const contentType = response.headers.get('content-type');\n if (\n response.status === 404 ||\n (contentType != null && contentType.indexOf('javascript') === -1)\n ) {\n // No service worker found. Probably a different app. Reload the page.\n navigator.serviceWorker.ready.then(registration => {\n registration.unregister().then(() => {\n window.location.reload();\n });\n });\n } else {\n // Service worker found. Proceed as normal.\n registerValidSW(swUrl, config);\n }\n })\n .catch(() => {\n console.log(\n 'No internet connection found. App is running in offline mode.'\n );\n });\n}\n\nexport function unregister() {\n if ('serviceWorker' in navigator) {\n navigator.serviceWorker.ready\n .then(registration => {\n registration.unregister();\n })\n .catch(error => {\n console.error(error.message);\n });\n }\n}\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './App';\nimport * as serviceWorker from './serviceWorker';\n\nReactDOM.render(, document.getElementById('root'));\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n"],"sourceRoot":""}