Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20240826 demo panic #14

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
1219001
Add a local move for to local ui. We need to route info into it.
prozacchiwawa Aug 20, 2024
b566b8a
Should be enough to convey the right info to the ui receiver
prozacchiwawa Aug 21, 2024
f111105
Separate endpoint for player update taking a player id, separate play…
prozacchiwawa Aug 21, 2024
b0fa644
checkpoint
prozacchiwawa Aug 22, 2024
1571243
Better display, getting turn order and data decoding better
prozacchiwawa Aug 23, 2024
c64e1bd
Checkpoint after adding messages properly. Despite it being a 'their…
prozacchiwawa Aug 23, 2024
72fa669
We now present the cards to each person (without bugs) from each pers…
prozacchiwawa Aug 23, 2024
695b3e9
fmt + clippy
prozacchiwawa Aug 23, 2024
89bde34
Can play fully on auto. player.js is probably the worst code i have …
prozacchiwawa Aug 24, 2024
ab3c311
Fixed non-matching cards in some cases in the demo app. Ultimately n…
prozacchiwawa Aug 27, 2024
09d94b6
Move calpoker decoding code to new source file
prozacchiwawa Aug 27, 2024
c3ac40e
Checkpoint, more moving, integrated the output decoder i made earlier
prozacchiwawa Aug 27, 2024
c08f137
minus one is a valid outcome, so make a nice enum for alice, bob, tie…
prozacchiwawa Aug 27, 2024
8feb6b4
Whole game working to completion in the demo
prozacchiwawa Aug 28, 2024
5d9f28f
Merge up
prozacchiwawa Aug 28, 2024
434b09d
Merge branch 'active' into 20240826-demo-panic
prozacchiwawa Aug 28, 2024
e2b25d9
fmt
prozacchiwawa Aug 28, 2024
65287ca
fmt + clippy
prozacchiwawa Aug 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 63 additions & 2 deletions resources/web/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ body {
margin: 0;
position: relative;
height: 40vh;
width: 98vw;
width: 68vw;
background: #fcc;
}

Expand All @@ -49,11 +49,72 @@ body {
margin-top: 1rem;
position: relative;
height: 40vh;
width: 98vw;
width: 68vw;
background: #cfc;
}

.cardspan {
margin-left: 0.5em;
border: 1px solid black;
}

#p1 iframe {
position: relative;
background: #fcc;
left: 0;
top: 0;
right: 100%;
bottom: 100%;
}

#player-heading {
margin: 0;
}

#player-info {
position: relative;
}

.player-attr {
margin-left: 1em;
}

#player-body {
font-size: 0.6rem;
overflow-y: auto;
}

.card {
display: inline-block;
width: 3rem;
height: 5rem;
box-sizing: border-box;
background: white;
border: 1px solid black;
border-radius: 0.5em;
font-size: 2rem;
padding-left: 0.5rem;
padding-right: 0.5rem;
cursor: pointer;
}

.selected_true {
background: #aca !important;
}

.card_bot {
width: 100%;
text-align: right;
}

.suit2 {
color: red;
}

.suit4 {
color: red;
}

.sent_picks_true {
display: none;
}
9 changes: 7 additions & 2 deletions resources/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
<div>
<h1 id="heading">Calpoker</h1>
<button onclick="exitapp()">Terminate</button>
<button onclick="reset()">Reset Simulator</button>
</div>
<div id="container">
<div id="info"> </div>
<div id="app">
<div id="p1"></div>
<div id="p2"></div>
<div id="p1">
<iframe id="p1" src="player.html?id=1"></iframe>
</div>
<div id="p2">
<iframe id="p2" src="player.html?id=2"></iframe>
</div>
</div>
</div>
</body>
Expand Down
98 changes: 17 additions & 81 deletions resources/web/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
let all_selected_cards = [{}, {}];

function set_card_properties(who, collection) {
for (let i = 0; i < 8; i++) {
let label = `${who}_card${i}`;
let card = document.getElementById(label);
if (!card) {
continue;
}
let n_string = `_${i}`;
if (collection[n_string]) {
card.style.background = 'green';
} else {
card.style.background = 'white';
}
function clear(elt) {
for (let node = elt.firstChild; node; node = elt.firstChild) {
node.parentNode.removeChild(node);
}
}

Expand All @@ -24,81 +12,29 @@ function check() {
}).then((json) => {
if (json.info) {
const info = document.getElementById('info');
info.innerHTML = json.info;
}
if (json.p1) {
const p1 = document.getElementById('p1');
p1.innerHTML = json.p1;
clear(info);
let keys = Object.keys(json.info);
let ul = document.createElement('ul');
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
let li = document.createElement('li');
let tn = document.createTextNode(`${key}: ${json.info[key]}`);
li.appendChild(tn);
ul.appendChild(li);
}
info.appendChild(ul);
}
if (json.p2) {
const p2 = document.getElementById('p2');
p2.innerHTML = json.p2;
}

set_card_properties('alice', all_selected_cards[0]);
set_card_properties('bob', all_selected_cards[1]);

setTimeout(check, 500);
});
}

function send_alice_word() {
let word = Math.random().toString();
return fetch(`alice_word_hash?word=${word}`, {
"method": "POST"
});
}

function send_bob_word() {
let word = Math.random().toString();
return fetch(`bob_word?word=${word}`, {
"method": "POST"
});
}

function toggle_card(label, selected_cards, n) {
let n_string = `_${n}`;
let card = document.getElementById(label);
if (!card) {
return;
}
if (selected_cards[n_string]) {
card.style.background = 'white';
delete selected_cards[n_string];
} else {
card.style.background = 'green';
selected_cards[n_string] = true;
}
console.log(selected_cards);
}

function alice_toggle(n) {
toggle_card(`alice_card${n}`, all_selected_cards[0], n);
}

function bob_toggle(n) {
toggle_card(`bob_card${n}`, all_selected_cards[1], n);
}

function set_picks(who, id) {
let picks = '';
for (let i = 0; i < 8; i++) {
let n_string = `_${i}`;
picks += (all_selected_cards[id][n_string]) ? '1' : '0';
}
return fetch(`${who}_picks?cards=${picks}`, {
"method": "POST"
function reset() {
return fetch("reset", {"method": "POST"}).then((response) => {
console.log("reset...");
});
}

function set_alice_picks() {
set_picks('alice', 0);
}

function set_bob_picks() {
set_picks('bob', 1);
}

function exitapp() {
return fetch("exit", {"method": "POST"}).then((response) => {
console.log("exiting...");
Expand Down
14 changes: 14 additions & 0 deletions resources/web/player.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<head>
<link rel="stylesheet" href="index.css">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.14.0/themes/base/jquery-ui.css">
</head>
<body id="player-body">
<h1 id="player-heading"></h1>
<h4 id="player-info"></h4>
<div id="playspace"></div>
<script type="text/javascript" src="player.js"></script>
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script src="https://code.jquery.com/ui/1.14.0/jquery-ui.js"></script>
</body>
</html>
Loading
Loading