Skip to content

Commit

Permalink
Working on vclaim
Browse files Browse the repository at this point in the history
  • Loading branch information
ThorvaldAagaard committed Oct 8, 2023
1 parent 9403b2f commit 2852e27
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/frontend/bridge.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,15 @@
if (deal.hand.isPlayable(card, deal.currentTrick)) {
ws.send(card.symbol)
deal.expectCardInput = false
} else {
alert("Card not valid")
}
} else if (deal.turn == 0) {
if (deal.public.isPlayable(card, deal.currentTrick)) {
ws.send(card.symbol)
deal.expectCardInput = false
} else {
alert("Card not valid")
}
}
}
Expand Down Expand Up @@ -206,9 +210,10 @@
function claimClick(event) {

let claim = event.target.getAttribute("tricks")
console.log("Claimed "+claim+ "tricks")

ws.send(claim)
console.log("Claimed "+claim+ " tricks")
alert("Claim not implemented")
//ws.send(claim)
deal.expectCardInput = true
}

document.querySelector('body').addEventListener('click', function() {
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class Deal {
renderClaim(element) {
element.textContent = ''
let html = ''
if ((this.tricksCount[0] + this.tricksCount[1]) > 12) {
if ((this.tricksCount[0] + this.tricksCount[1]) > 13) {
html += 'Claim: '
html += '<div id="claim-tricks">'
html += '<div tricks="0">0</div>'
Expand Down
12 changes: 10 additions & 2 deletions src/frontend/viz.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@

</div>

<div id="rebid"></div>
<div id="replay"></div>
<div id="solver"></div>

Expand Down Expand Up @@ -144,9 +145,16 @@
}

let dealer = 'NESW'.charAt(deal.data.dealer)
const replayContent = '<a href="http://127.0.0.1:8080/app/bridge.html?deal=' +
const rebidContent = '<a href="http://127.0.0.1:8080/app/bridge.html?deal=' +
'(\'' + deal.data.hands + '\', \'' + dealer + ' ' + vul + '\')' +
'&P=5&board_no='+deal.board_number()+'"> Play it again </a><br>';
'&P=5&board_no=' + deal.board_number() + '"> Bid and play it again </a><br>';

document.querySelector('#rebid').innerHTML = rebidContent;

console.log(auction.auctionString)
const replayContent = '<a href="http://127.0.0.1:8080/app/bridge.html?deal=' +
'(\'' + deal.data.hands + '\', \'' + dealer + ' ' + vul + ' ' + auction.auctionString +'\')' +
'&P=5&board_no=' + deal.board_number() + '"> Play it again </a><br>';

document.querySelector('#replay').innerHTML = replayContent;

Expand Down
4 changes: 4 additions & 0 deletions src/frontend/viz.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ class Auction {
for (var i = 0; i < bids.length; i++) {
this.paddedBids.push(bids[i]['bid'])
}
this.auctionString = ''
for (var i = 0; i < bids.length; i++) {
this.auctionString += bids[i]['bid'].replace("PASS","P") + " "
}
}

render(element) {
Expand Down

0 comments on commit 2852e27

Please sign in to comment.