Download the Instant Game ZIP
This is the single-player bundle built for Facebook Instant Games. Save it to your device, then upload it in Facebook's developer flow under Instant Games → Web Hosting.
File: walmart-poker-instant-game.zip
Button not saving the file? Open the ZIP link directly and use your browser's download option.
On iPhone or iPad
- Press and hold the Download button above.
- Choose Download Linked File.
- Find it in the Files app under Downloads, then share or upload it from there.
On desktop
- Click the Download button — the file saves to your Downloads folder.
- Don't unzip it. Facebook wants the .zip as-is.
Can't download? Copy the files instead
Each file below has a one-tap Copy button. Save each one with its exact file name into a single folder, then compress them into the ZIP by hand.
- Make a new folder anywhere you can save files.
- Copy each file below and save it with its exact name: index.html, fbapp-config.json, README.txt.
- Select the three files (not the folder) and compress them into a ZIP named walmart-poker-instant-game.zip.
- Upload that ZIP under Instant Games → Web Hosting in Facebook's developer dashboard.
index.html
The entire game — HTML, CSS and JavaScript in one self-contained file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Walmart Poker</title>
<style>
:root{
--bg:#1a1a2e;
--felt:#0d4f3c;
--primary:#dc2626;
--accent:#f0c040;
--card-bg:#ffffff;
--ink:#111111;
--muted:rgba(255,255,255,.65);
}
*{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{
background:var(--bg);
color:#fff;
font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;
overflow:hidden;
user-select:none;
-webkit-user-select:none;
}
#app{
max-width:520px;height:100%;margin:0 auto;
display:flex;flex-direction:column;
background:radial-gradient(ellipse at 50% 30%, #123a2f 0%, var(--felt) 55%, #06281f 100%);
}
#topbar{
display:flex;align-items:center;justify-content:space-between;
padding:10px 14px;background:rgba(10,10,20,.75);
border-bottom:2px solid var(--accent);
flex:0 0 auto;
}
#logo{font-size:20px;font-weight:900;letter-spacing:1px;color:var(--accent);text-transform:uppercase}
#logo span{color:#fff}
#handInfo{font-size:12px;color:var(--muted);text-align:right}
#table{flex:1 1 auto;display:flex;flex-direction:column;padding:8px;min-height:0}
#seats{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}
.seat{
background:rgba(0,0,0,.35);border:1px solid rgba(240,192,64,.35);
border-radius:10px;padding:6px 4px;text-align:center;min-height:58px;
transition:opacity .3s;
}
.seat.folded{opacity:.35}
.seat.active{border-color:var(--accent);box-shadow:0 0 8px rgba(240,192,64,.5)}
.seat .name{font-size:11px;font-weight:700;color:var(--accent);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.seat .chips{font-size:11px;color:#fff}
.seat .status{font-size:10px;color:var(--muted);min-height:12px}
.seat .betc{font-size:10px;color:var(--accent);min-height:13px}
.seat .cards{display:flex;justify-content:center;gap:3px;margin-top:2px}
#communityWrap{flex:1 1 auto;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px}
#potBadge{
background:rgba(0,0,0,.5);border:1px solid var(--accent);border-radius:20px;
padding:4px 16px;font-size:14px;font-weight:800;color:var(--accent);
}
#community{display:flex;gap:6px;min-height:64px;align-items:center}
#message{
font-size:13px;color:#fff;text-align:center;min-height:18px;
text-shadow:0 1px 2px rgba(0,0,0,.7);padding:0 10px;
}
.card{
width:44px;height:62px;border-radius:6px;background:var(--card-bg);color:var(--ink);
display:flex;flex-direction:column;align-items:center;justify-content:center;
box-shadow:0 2px 6px rgba(0,0,0,.5);flex:0 0 auto;
}
.card .r{font-size:17px;line-height:1;font-weight:800}
.card .s{font-size:14px;line-height:1.1}
.card.red{color:#c0392b}
.card.back{
background:linear-gradient(135deg,var(--primary) 0%,#7f1d1d 100%);
color:rgba(255,255,255,.9);font-size:18px;
}
.card.small{width:32px;height:46px}
.card.small .r{font-size:13px}
.card.small .s{font-size:10px}
@keyframes dealIn{from{transform:translateY(-14px) scale(.7);opacity:0}to{transform:none;opacity:1}}
.card.dealt{animation:dealIn .3s ease-out}
#meWrap{flex:0 0 auto;padding:6px 10px 10px;background:rgba(0,0,0,.45);border-top:1px solid rgba(240,192,64,.3)}
#meTop{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}
#meCards{display:flex;gap:6px}
#meStats{text-align:right}
#meName{font-size:13px;font-weight:800;color:var(--accent)}
#meChips{font-size:13px;color:#fff}
#bestHand{font-size:11px;color:var(--muted);min-height:13px;margin-bottom:4px}
#actions{display:none;gap:8px;margin-top:6px}
#actions button{
flex:1;min-height:48px;border:none;border-radius:10px;
font-size:15px;font-weight:800;cursor:pointer;color:#fff;
}
#btnFold{background:#3a3a4a}
#btnCheck{background:var(--primary)}
#btnRaise{background:var(--accent);color:var(--bg)}
button:disabled{opacity:.4;cursor:default}
#raisePanel{
display:none;margin-top:8px;background:rgba(0,0,0,.4);
border-radius:10px;padding:10px;
}
#raisePanel.open{display:block}
#raisePanel .row{display:flex;align-items:center;gap:8px;margin-bottom:8px}
#raiseSlider{flex:1;accent-color:var(--accent)}
#raiseLabel{font-size:14px;font-weight:800;color:var(--accent);min-width:86px;text-align:right}
#raisePanel .quick{display:flex;gap:6px}
#raisePanel .quick button{
flex:1;min-height:38px;font-size:12px;font-weight:700;border-radius:8px;
background:#2a2a3a;border:1px solid rgba(240,192,64,.4);color:#fff;cursor:pointer;
}
#btnConfirmRaise{width:100%;min-height:44px;margin-top:8px;background:var(--accent);
border:none;border-radius:10px;font-size:15px;font-weight:800;color:var(--bg);cursor:pointer}
#overlay{
position:fixed;inset:0;background:rgba(10,10,20,.88);
display:none;align-items:center;justify-content:center;padding:20px;z-index:50;
}
#overlay.show{display:flex}
#overlayPanel{
background:var(--bg);border:2px solid var(--accent);border-radius:16px;
padding:24px;max-width:400px;width:100%;text-align:center;max-height:80vh;overflow-y:auto;
}
#overlayPanel h1{font-size:26px;color:var(--accent);text-transform:uppercase;letter-spacing:1px;margin-bottom:8px}
#overlayPanel h2{font-size:18px;color:#fff;margin-bottom:10px}
#overlayPanel p{font-size:13px;color:var(--muted);margin-bottom:14px;line-height:1.5}
#overlayPanel .results{text-align:left;margin-bottom:14px}
#overlayPanel .results div{font-size:13px;padding:5px 8px;border-radius:6px;margin-bottom:4px;background:rgba(255,255,255,.05)}
#overlayPanel .results div.win{background:rgba(240,192,64,.15);color:var(--accent);font-weight:700}
#overlayPanel button{
min-height:50px;width:100%;border:none;border-radius:12px;
background:var(--primary);color:#fff;font-size:17px;font-weight:800;cursor:pointer;
}
</style>
</head>
<body>
<div id="app">
<header id="topbar">
<div id="logo">Walmart <span>Poker</span></div>
<div id="handInfo"></div>
</header>
<div id="table">
<div id="seats"></div>
<div id="communityWrap">
<div id="potBadge">POT <span id="pot">0</span></div>
<div id="community"></div>
<div id="message"></div>
</div>
</div>
<div id="meWrap">
<div id="bestHand"></div>
<div id="meTop">
<div id="meCards"></div>
<div id="meStats">
<div id="meName">You</div>
<div id="meChips">2,000</div>
</div>
</div>
<div id="actions">
<button id="btnFold">Fold</button>
<button id="btnCheck">Check</button>
<button id="btnRaise">Raise</button>
</div>
<div id="raisePanel">
<div class="row">
<input type="range" id="raiseSlider" min="0" max="100" step="10">
<div id="raiseLabel">0</div>
</div>
<div class="quick">
<button id="qMin">Min</button>
<button id="qHalf">1/2 Pot</button>
<button id="qPot">Pot</button>
<button id="qAllIn">All In</button>
</div>
<button id="btnConfirmRaise">Confirm Raise</button>
</div>
</div>
</div>
<div id="overlay"><div id="overlayPanel"></div></div>
<script src="https://connect.facebook.net/en_US/fbinstant.7.1.js"></script>
<script>
'use strict';
/* ================= Facebook Instant Games bootstrap ================= */
var FB = (typeof FBInstant !== 'undefined') ? FBInstant : null;
var playerName = 'You';
function initFB(){
if(!FB){ return Promise.resolve(); }
return new Promise(function(resolve){
FB.initializeAsync().then(function(){
try{
if(FB.player && FB.player.getName){ playerName = FB.player.getName() || 'You'; }
}catch(e){ /* player info unavailable */ }
FB.setLoadingProgress(30);
FB.setLoadingProgress(60);
FB.setLoadingProgress(100);
return FB.startGameAsync();
}).then(function(){ resolve(); })
.catch(function(){ resolve(); });
});
}
/* ================= constants & helpers ================= */
var SB = 10, BB = 20, START_CHIPS = 2000;
var SUITS = ['♠','♥','♦','♣'];
var RANK_NAMES = ['High Card','Pair','Two Pair','Three of a Kind','Straight','Flush','Full House','Four of a Kind','Straight Flush'];
var RANK_LABELS = {11:'J',12:'Q',13:'K',14:'A'};
function sleep(ms){ return new Promise(function(r){ setTimeout(r, ms); }); }
function fmt(n){ return n.toLocaleString('en-US'); }
function rankLabel(r){ return RANK_LABELS[r] || String(r); }
function makeDeck(){
var d = [];
for(var s=0;s<4;s++) for(var r=2;r<=14;r++) d.push({r:r,s:s});
return d;
}
function shuffle(a){
for(var i=a.length-1;i>0;i--){ var j=Math.floor(Math.random()*(i+1)); var t=a[i]; a[i]=a[j]; a[j]=t; }
return a;
}
/* ================= hand evaluation ================= */
function cmpEval(a, b){
var n = Math.max(a.tie.length, b.tie.length);
for(var i=0;i<n;i++){
var x = a.tie[i]||0, y = b.tie[i]||0;
if(x!==y) return x-y;
}
return 0;
}
function eval5(cards){
var rs = cards.map(function(c){return c.r;}).sort(function(a,b){return b-a;});
var flush = cards.every(function(c){return c.s===cards[0].s;});
var cnt = {};
rs.forEach(function(r){ cnt[r]=(cnt[r]||0)+1; });
var groups = Object.keys(cnt).map(function(k){ return {r:+k, n:cnt[k]}; })
.sort(function(a,b){ return (b.n-a.n)||(b.r-a.r); });
var uniq = Array.from(new Set(rs));
var straightHigh = 0;
if(uniq.length===5){
if(uniq[0]-uniq[4]===4) straightHigh = uniq[0];
else if(uniq[0]===14 && uniq[1]===5 && uniq[1]-uniq[4]===3) straightHigh = 5;
}
var cat, tie;
if(flush && straightHigh){ cat=8; tie=[straightHigh]; }
else if(groups[0].n===4){ cat=7; tie=[groups[0].r, groups[1].r]; }
else if(groups[0].n===3 && groups[1].n===2){ cat=6; tie=[groups[0].r, groups[1].r]; }
else if(flush){ cat=5; tie=rs; }
else if(straightHigh){ cat=4; tie=[straightHigh]; }
else if(groups[0].n===3){ cat=3; tie=[groups[0].r, groups[1].r, groups[2].r]; }
else if(groups[0].n===2 && groups[1].n===2){ cat=2; tie=[groups[0].r, groups[1].r, groups[2].r]; }
else if(groups[0].n===2){ cat=1; tie=[groups[0].r, groups[1].r, groups[2].r, groups[3].r]; }
else { cat=0; tie=rs; }
return {cat:cat, tie:tie};
}
function best7(cards7){
var best = null;
for(var i=0;i<7;i++) for(var j=i+1;j<7;j++){
var five = cards7.filter(function(_,k){ return k!==i && k!==j; });
var e = eval5(five);
if(!best || cmpEval(e,best)>0) best = e;
}
return best;
}
function handName(e){
if(e.cat===1) return 'Pair of ' + rankLabel(e.tie[0]) + 's';
if(e.cat===2) return 'Two Pair, ' + rankLabel(e.tie[0]) + 's and ' + rankLabel(e.tie[1]) + 's';
if(e.cat===3) return 'Three of a Kind, ' + rankLabel(e.tie[0]) + 's';
if(e.cat===4) return 'Straight, ' + rankLabel(e.tie[0]) + ' high';
if(e.cat===5) return 'Flush, ' + rankLabel(e.tie[0]) + ' high';
if(e.cat===6) return 'Full House, ' + rankLabel(e.tie[0]) + 's over ' + rankLabel(e.tie[1]) + 's';
if(e.cat===7) return 'Four of a Kind, ' + rankLabel(e.tie[0]) + 's';
if(e.cat===8) return e.tie[0]===14 ? 'Royal Flush' : 'Straight Flush, ' + rankLabel(e.tie[0]) + ' high';
return RANK_NAMES[0] + ', ' + rankLabel(e.tie[0]) + ' high';
}
/* ================= AI strength ================= */
function preflopStrength(cards){
var hi = Math.max(cards[0].r, cards[1].r), lo = Math.min(cards[0].r, cards[1].r);
if(cards[0].r===cards[1].r) return 0.5 + (cards[0].r-2)*0.014;
var s = (hi+lo-4)/36;
if(cards[0].s===cards[1].s) s += 0.05;
if(hi-lo===1) s += 0.03;
if(hi>=13 && lo>=10) s += 0.05;
return Math.min(0.8, s);
}
function madeStrength(cards7){
var e = best7(cards7);
var base = [0.12,0.42,0.6,0.7,0.8,0.85,0.9,0.95,0.99][e.cat];
if(e.cat===0) base += e.tie[0]/200;
if(e.cat===1) base += (e.tie[0]-2)/80;
return {s:Math.min(0.99, base), e:e};
}
/* ================= state ================= */
var state = {
players: [],
deck: [],
community: [],
pot: 0,
currentBet: 0,
minRaise: BB,
dealer: -1,
bbIdx: 0,
street: 'preflop',
handNum: 0
};
function buildPlayers(){
state.players = [
{name:playerName, isHuman:true, chips:START_CHIPS, bet:0, folded:false, allin:false, cards:[], acted:false, total:0, aggr:0, thinking:false, revealed:false},
{name:'Maria', isHuman:false, chips:START_CHIPS, bet:0, folded:false, allin:false, cards:[], acted:false, total:0, aggr:0.8, thinking:false, revealed:false},
{name:'Duke', isHuman:false, chips:START_CHIPS, bet:0, folded:false, allin:false, cards:[], acted:false, total:0, aggr:1.2, thinking:false, revealed:false},
{name:'Lucky Lena', isHuman:false, chips:START_CHIPS, bet:0, folded:false, allin:false, cards:[], acted:false, total:0, aggr:1.0, thinking:false, revealed:false}
];
}
function potTotal(){
return state.pot + state.players.reduce(function(a,p){ return a+p.bet; }, 0);
}
function activeCount(){
return state.players.filter(function(p){ return !p.folded; }).length;
}
function saveGame(){
try{
var me = state.players[0];
localStorage.setItem('wp_save', JSON.stringify({chips:me.chips, handNum:state.handNum}));
}catch(e){ /* storage unavailable */ }
}
function loadGame(){
try{
var raw = localStorage.getItem('wp_save');
if(raw){ return JSON.parse(raw); }
}catch(e){ /* storage unavailable */ }
return null;
}
/* ================= rendering ================= */
var el = {};
function grabEls(){
el.seats = document.getElementById('seats');
el.community = document.getElementById('community');
el.pot = document.getElementById('pot');
el.message = document.getElementById('message');
el.meCards = document.getElementById('meCards');
el.meName = document.getElementById('meName');
el.meChips = document.getElementById('meChips');
el.bestHand = document.getElementById('bestHand');
el.handInfo = document.getElementById('handInfo');
el.actions = document.getElementById('actions');
el.btnFold = document.getElementById('btnFold');
el.btnCheck = document.getElementById('btnCheck');
el.btnRaise = document.getElementById('btnRaise');
el.raisePanel = document.getElementById('raisePanel');
el.raiseSlider = document.getElementById('raiseSlider');
el.raiseLabel = document.getElementById('raiseLabel');
el.btnConfirmRaise = document.getElementById('btnConfirmRaise');
el.qMin = document.getElementById('qMin');
el.qHalf = document.getElementById('qHalf');
el.qPot = document.getElementById('qPot');
el.qAllIn = document.getElementById('qAllIn');
el.overlay = document.getElementById('overlay');
el.overlayPanel = document.getElementById('overlayPanel');
}
function cardEl(card, opts){
opts = opts || {};
var d = document.createElement('div');
var cls = 'card dealt';
if(opts.small) cls += ' small';
if(!card){ cls += ' back'; d.textContent = '♠'; }
else{
var red = card.s===1 || card.s===2;
if(red) cls += ' red';
var r = document.createElement('div'); r.className='r'; r.textContent = rankLabel(card.r);
var s = document.createElement('div'); s.className='s'; s.textContent = SUITS[card.s];
d.appendChild(r); d.appendChild(s);
}
d.className = cls;
return d;
}
function render(){
el.seats.textContent = '';
state.players.slice(1).forEach(function(p){
var seat = document.createElement('div');
seat.className = 'seat' + (p.folded ? ' folded' : '') + (p.thinking ? ' active' : '');
var n = document.createElement('div'); n.className='name'; n.textContent = p.name;
var c = document.createElement('div'); c.className='chips'; c.textContent = fmt(p.chips);
var st = document.createElement('div'); st.className='status'; st.textContent = p.folded ? 'Folded' : (p.allin ? 'All In' : (p.thinking ? 'Thinking...' : ''));
var bc = document.createElement('div'); bc.className='betc'; bc.textContent = p.bet>0 ? 'Bet ' + fmt(p.bet) : '';
var cd = document.createElement('div'); cd.className='cards';
p.cards.forEach(function(card){ cd.appendChild(cardEl(p.revealed ? card : null, {small:true})); });
seat.appendChild(n); seat.appendChild(c); seat.appendChild(st); seat.appendChild(bc); seat.appendChild(cd);
el.seats.appendChild(seat);
});
el.pot.textContent = fmt(potTotal());
el.community.textContent = '';
state.community.forEach(function(card){ el.community.appendChild(cardEl(card, {})); });
var need = Math.max(0, 5 - state.community.length);
for(var i=0;i<need;i++){
var ph = document.createElement('div');
ph.className = 'card small';
ph.style.opacity = '0.5';
ph.style.background = 'transparent';
ph.style.border = '1px dashed rgba(255,255,255,.3)';
ph.style.boxShadow = 'none';
el.community.appendChild(ph);
}
var me = state.players[0];
el.meName.textContent = me.name;
el.meChips.textContent = fmt(me.chips) + (me.bet>0 ? ' (bet ' + fmt(me.bet) + ')' : '');
el.meCards.textContent = '';
me.cards.forEach(function(card){ el.meCards.appendChild(cardEl(card, {})); });
if(me.folded){ el.bestHand.textContent = 'You folded'; }
else if(state.community.length>=3 && me.cards.length===2){
el.bestHand.textContent = 'You have: ' + handName(best7(me.cards.concat(state.community)));
} else { el.bestHand.textContent = ''; }
el.handInfo.textContent = 'Hand #' + state.handNum + ' · Blinds ' + SB + '/' + BB;
}
function say(msg){ el.message.textContent = msg || ''; }
function showOverlay(html){ el.overlayPanel.innerHTML = html; el.overlay.classList.add('show'); }
function hideOverlay(){ el.overlay.classList.remove('show'); }
/* ================= human turn ================= */
var humanResolve = null;
var pendingToCall = 0, pendingMax = 0, pendingMinTo = 0;
function humanTurn(p){
return new Promise(function(resolve){
humanResolve = resolve;
pendingToCall = state.currentBet - p.bet;
pendingMax = p.chips + p.bet;
pendingMinTo = Math.min(state.currentBet + state.minRaise, pendingMax);
setupActionUI(p);
});
}
function setupActionUI(p){
el.actions.style.display = 'flex';
el.raisePanel.classList.remove('open');
el.btnFold.disabled = false;
if(pendingToCall <= 0){
el.btnCheck.textContent = 'Check';
} else {
el.btnCheck.textContent = 'Call ' + fmt(Math.min(pendingToCall, p.chips));
}
el.btnCheck.disabled = false;
el.btnRaise.textContent = pendingToCall<=0 ? 'Bet' : 'Raise';
el.btnRaise.disabled = pendingMax <= state.currentBet;
}
function hideActionUI(){
el.actions.style.display = 'none';
el.raisePanel.classList.remove('open');
el.btnFold.disabled = true; el.btnCheck.disabled = true; el.btnRaise.disabled = true;
}
function humanAct(action, amount){
if(!humanResolve) return;
var r = humanResolve; humanResolve = null;
hideActionUI();
r({action:action, amount:amount||0});
}
function updateRaiseLabel(){
el.raiseLabel.textContent = 'to ' + fmt(+el.raiseSlider.value);
}
function openRaisePanel(){
el.raisePanel.classList.add('open');
el.raiseSlider.min = pendingMinTo;
el.raiseSlider.max = pendingMax;
el.raiseSlider.step = Math.max(10, Math.round(BB/2));
el.raiseSlider.value = pendingMinTo;
updateRaiseLabel();
}
/* ================= applying actions ================= */
function applyAction(p, act){
var toCall = state.currentBet - p.bet;
if(act.action==='fold'){
p.folded = true;
} else if(act.action==='check'){
// nothing to pay
} else if(act.action==='call'){
var pay = Math.min(toCall, p.chips);
p.chips -= pay; p.bet += pay; p.total += pay;
if(p.chips===0) p.allin = true;
} else if(act.action==='raise'){
var target = Math.min(act.amount, p.chips + p.bet);
if(target <= state.currentBet){
var pay2 = p.chips;
p.chips = 0; p.bet += pay2; p.total += pay2; p.allin = true;
} else {
var prevBet = state.currentBet;
var pay3 = target - p.bet;
p.chips -= pay3; p.bet = target; p.total += pay3;
if(p.chips===0) p.allin = true;
state.minRaise = Math.max(BB, target - prevBet);
state.currentBet = target;
state.players.forEach(function(q){
if(q!==p && !q.folded && !q.allin) q.acted = false;
});
}
}
p.acted = true;
render();
}
/* ================= AI ================= */
function aiDecide(p){
var toCall = state.currentBet - p.bet;
var max = p.chips + p.bet;
var canRaise = max > state.currentBet;
var strength;
if(state.street==='preflop'){
strength = preflopStrength(p.cards);
} else {
strength = madeStrength(p.cards.concat(state.community)).s;
}
strength += (Math.random()*0.14 - 0.07) + (p.aggr - 1) * 0.04;
var potNow = potTotal();
if(toCall <= 0){
if(canRaise && strength > 0.6 && Math.random() < 0.55){
var amt = state.currentBet + Math.max(state.minRaise, Math.round(potNow * (0.5 + Math.random()*0.7)));
return {action:'raise', amount: Math.min(Math.max(amt, state.currentBet + state.minRaise), max)};
}
return {action:'check'};
}
var odds = toCall / (potNow + toCall);
if(canRaise && strength > 0.82 && Math.random() < 0.5){
var amt2 = state.currentBet + Math.max(state.minRaise, Math.round(potNow * 0.6));
return {action:'raise', amount: Math.min(Math.max(amt2, state.currentBet + state.minRaise), max)};
}
if(strength >= odds + 0.05) return {action:'call'};
if(toCall <= BB && strength > 0.28) return {action:'call'};
return {action:'fold'};
}
/* ================= betting round ================= */
function roundDone(){
return state.players.every(function(p){
if(p.folded || p.allin || p.chips===0) return true;
return p.acted && p.bet === state.currentBet;
});
}
function firstToAct(street){
var n = state.players.length;
if(street==='preflop'){
for(var i=1;i<=n;i++){
var p = state.players[(state.bbIdx+i)%n];
if(!p.folded && !p.allin) return (state.bbIdx+i)%n;
}
return state.bbIdx;
}
for(var j=1;j<=n;j++){
var q = state.players[(state.dealer+j)%n];
if(!q.folded && !q.allin) return (state.dealer+j)%n;
}
return (state.dealer+1)%n;
}
function postBlind(p, amt, label){
var pay = Math.min(amt, p.chips);
p.chips -= pay; p.bet += pay; p.total += pay;
if(p.chips===0) p.allin = true;
say(p.name + ' posts ' + label + ' ' + fmt(pay));
render();
}
function postBlinds(){
var n = state.players.length;
var sbIdx = -1;
for(var i=1;i<=n;i++){
var p = state.players[(state.dealer+i)%n];
if(!p.folded && !p.allin){ sbIdx = (state.dealer+i)%n; break; }
}
var bbIdx = -1;
for(var j=sbIdx+1;j<=sbIdx+n;j++){
var q = state.players[j%n];
if(!q.folded && !q.allin){ bbIdx = j%n; break; }
}
postBlind(state.players[sbIdx], SB, 'small blind');
postBlind(state.players[bbIdx], BB, 'big blind');
state.bbIdx = bbIdx;
}
async function bettingRound(street){
state.street = street;
state.players.forEach(function(p){ p.acted = p.folded || p.allin || p.chips===0; });
if(street!=='preflop') state.currentBet = 0;
var n = state.players.length;
var idx = firstToAct(street);
var guard = 0;
while(!roundDone() && guard < 200){
guard++;
var p = state.players[idx];
if(p.folded || p.allin || p.chips===0){
p.acted = true; idx = (idx+1)%n; continue;
}
var act;
if(p.isHuman){
say('Your turn');
act = await humanTurn(p);
} else {
p.thinking = true; render();
await sleep(650 + Math.random()*600);
p.thinking = false;
act = aiDecide(p);
}
applyAction(p, act);
if(act.action==='fold') say(p.name + ' folds');
else if(act.action==='check') say(p.name + ' checks');
else if(act.action==='call') say(p.name + ' calls');
else say(p.name + ' raises to ' + fmt(state.currentBet));
idx = (idx+1)%n;
}
state.pot += state.players.reduce(function(a,p){ return a+p.bet; }, 0);
state.players.forEach(function(p){ p.bet = 0; });
render();
await sleep(400);
}
/* ================= pot distribution ================= */
function distribute(){
var ps = state.players;
var sorted = ps.slice().sort(function(a,b){ return b.total - a.total; });
if(sorted.length>=2 && sorted[0].total > sorted[1].total && !sorted[0].folded){
var refund = sorted[0].total - sorted[1].total;
sorted[0].total -= refund; sorted[0].chips += refund;
state.pot -= refund;
}
var contribs = ps.map(function(p){ return {p:p, c:p.total}; });
var levels = [];
contribs.forEach(function(x){ if(x.c>0 && levels.indexOf(x.c)<0) levels.push(x.c); });
levels.sort(function(a,b){ return a-b; });
var results = [];
var prev = 0;
levels.forEach(function(lvl){
var portion = 0;
contribs.forEach(function(x){ portion += Math.min(x.c, lvl) - Math.min(x.c, prev); });
prev = lvl;
if(portion<=0) return;
var contenders = contribs.filter(function(x){ return x.c >= lvl && !x.p.folded; }).map(function(x){ return x.p; });
if(contenders.length===0) return;
var best = null, winners = [];
contenders.forEach(function(p){
var e = best7(p.cards.concat(state.community));
if(!best || cmpEval(e,best)>0){ best = e; winners = [p]; }
else if(cmpEval(e,best)===0){ winners.push(p); }
});
var share = Math.floor(portion / winners.length);
var rem = portion - share*winners.length;
winners.forEach(function(w, i){
var got = share + (i===0 ? rem : 0);
w.chips += got;
results.push({text: w.name + ' wins {AMT} with ' + handName(best), amount: got, win:true});
});
});
state.pot = 0;
return results;
}
/* ================= hand flow ================= */
async function playHand(){
state.handNum++;
state.community = [];
state.pot = 0;
state.currentBet = 0;
state.minRaise = BB;
state.street = 'preflop';
state.dealer = (state.dealer + 1) % state.players.length;
state.players.forEach(function(p){
if(!p.isHuman && p.chips < BB) p.chips = START_CHIPS;
p.bet = 0; p.folded = false; p.allin = false; p.cards = []; p.acted = false; p.total = 0; p.thinking = false; p.revealed = false;
});
state.deck = shuffle(makeDeck());
for(var round=0; round<2; round++){
for(var i=0;i<state.players.length;i++){
state.players[i].cards.push(state.deck.pop());
}
}
say('Dealing hand #' + state.handNum);
render();
await sleep(700);
postBlinds();
await sleep(500);
var streets = ['preflop','flop','turn','river'];
for(var s=0;s<streets.length;s++){
if(activeCount() <= 1) break;
if(streets[s]==='flop'){ state.community.push(state.deck.pop(), state.deck.pop(), state.deck.pop()); say('Flop'); }
else if(streets[s]==='turn'){ state.community.push(state.deck.pop()); say('Turn'); }
else if(streets[s]==='river'){ state.community.push(state.deck.pop()); say('River'); }
render();
if(streets[s]!=='preflop') await sleep(600);
await bettingRound(streets[s]);
}
var results;
if(activeCount() <= 1){
var last = state.players.find(function(p){ return !p.folded; });
var won = state.pot;
last.chips += won;
state.pot = 0;
var line = last.name + ' wins {AMT} — everyone else folded';
if(last.isHuman && state.community.length>0){
line = last.name + ' wins {AMT} with ' + handName(best7(last.cards.concat(state.community)));
}
results = [{text: line, amount: won, win:true}];
} else {
state.players.forEach(function(p){ if(!p.folded) p.revealed = true; });
render();
await sleep(900);
results = distribute();
}
saveGame();
showResults(results);
}
function showResults(results){
var html = '<h2>Hand #' + state.handNum + ' complete</h2><div class="results">';
results.forEach(function(r){
html += '<div class="win">' + r.text.replace('{AMT}', fmt(r.amount)) + '</div>';
});
html += '</div>';
var me = state.players[0];
if(me.chips <= 0){
html += '<button id="btnNext">Start Over</button>';
showOverlay(html);
document.getElementById('btnNext').addEventListener('click', function(){
me.chips = START_CHIPS;
state.handNum = 0;
saveGame();
hideOverlay();
playHand();
});
return;
}
html += '<button id="btnNext">Deal Next Hand</button>';
showOverlay(html);
document.getElementById('btnNext').addEventListener('click', function(){
hideOverlay();
playHand();
});
}
/* ================= start ================= */
function bindButtons(){
el.btnFold.addEventListener('click', function(){ humanAct('fold'); });
el.btnCheck.addEventListener('click', function(){
humanAct(pendingToCall>0 ? 'call' : 'check');
});
el.btnRaise.addEventListener('click', openRaisePanel);
el.btnConfirmRaise.addEventListener('click', function(){
humanAct('raise', +el.raiseSlider.value);
});
el.raiseSlider.addEventListener('input', updateRaiseLabel);
el.qMin.addEventListener('click', function(){ el.raiseSlider.value = pendingMinTo; updateRaiseLabel(); });
el.qHalf.addEventListener('click', function(){
el.raiseSlider.value = Math.min(pendingMax, state.currentBet + Math.round((state.pot + state.currentBet)/2));
updateRaiseLabel();
});
el.qPot.addEventListener('click', function(){
el.raiseSlider.value = Math.min(pendingMax, state.currentBet + state.pot + state.currentBet);
updateRaiseLabel();
});
el.qAllIn.addEventListener('click', function(){ el.raiseSlider.value = pendingMax; updateRaiseLabel(); });
}
async function start(){
grabEls();
buildPlayers();
bindButtons();
var saved = loadGame();
if(saved && saved.chips > 0){
state.players[0].chips = saved.chips;
state.handNum = saved.handNum || 0;
}
hideActionUI();
render();
showOverlay(
'<h1>Walmart Poker</h1>' +
'<h2>Single Player Hold'em</h2>' +
'<p>Heads-up against three rivals. You start with ' + fmt(state.players[0].chips) + ' chips. Blinds are ' + SB + '/' + BB + '. Bots re-buy; if you bust, you can start over.</p>' +
'<button id="btnStart">Play Now</button>'
);
document.getElementById('btnStart').addEventListener('click', function(){
hideOverlay();
playHand();
});
}
initFB().then(start);
</script>
</body>
</html>fbapp-config.json
Instant Games configuration (portrait orientation).
{
"instant_games": {
"platform_version": {
"stable": {
"revision_id": "29"
}
},
"orientation": "portrait"
}
}
README.txt
Upload notes for Facebook's developer dashboard.
Walmart Poker — Facebook Instant Games upload bundle
=====================================================
Engine: custom HTML5 (vanilla JavaScript, zero dependencies)
Contents
--------
index.html The entire game (HTML + CSS + JS in one self-contained file)
fbapp-config.json Instant Games configuration (portrait orientation)
Size: well under Facebook's 20 MB package limit.
How to upload
-------------
1. Go to developers.facebook.com > My Apps > Create App, and choose the
"Gaming" / Instant Games app type.
2. In the App Dashboard, open Instant Games > Web Hosting.
3. Upload this ZIP as the main game package.
4. Once uploaded, you can test it via the Instant Games test app, then
push it to Live when you are ready.
Notes
-----
- The game is single-player (you vs 3 AI opponents) and makes no calls to
your server, exactly as the Instant Games platform requires.
- Your full multiplayer game at walmartpoker.com is untouched; this bundle
is completely standalone.
- Chip progress is stored locally on the player's device.
- The Facebook Instant Games SDK is loaded from Facebook's own CDN; outside
Facebook the game simply runs without it, so you can open index.html in a
browser to test.
Uploading to Facebook
- In Facebook's game setup, answer custom HTML5 for the engine question.
- Go to Instant Games → Web Hosting.
- Upload this ZIP file and follow Facebook's prompts.