Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
node_modules/
dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
Expand All @@ -11,8 +12,3 @@ yarn-error.log*
*.ntvs*
*.njsproj
*.sln

# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/config.yml
!.elasticbeanstalk/*.global.yml
1 change: 0 additions & 1 deletion dist/pokerhand.min.js

This file was deleted.

18 changes: 0 additions & 18 deletions example/index.js

This file was deleted.

77 changes: 38 additions & 39 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Poker Texas Holdem Cactus Kev's algorithm</title>
<meta charset="utf-8" />
<title>Poker Texas Holdem - Cactus Kev's Algorithm</title>
</head>
<body>
<label for="my-hand">My Hand</label>
<input type="text" id="my-hand" name="my-hand" value="KS KH QC QD AD">
<input type="text" id="my-hand" name="my-hand" value="KS KH QC QD AD" />

<label for="his-hand">His Hand</label>
<input type="text" id="his-hand" name="his-hand" value="KD KC AS AH TD">
<input type="text" id="his-hand" name="his-hand" value="KD KC AS AH TD" />

<button type="button" id="compare" name="compare">Find winner</button>

<span id="result">I loose</span>

<span id="result"></span>

<script type="module">
import { PokerHand, CompareResult } from './src/index.ts';

const myPokerHand = new PokerHand('KS KH QC QD AD');
const hisPokerHand = new PokerHand('KD KC AS AH TD');

const $myHand = document.getElementById('my-hand');
const $hisHand = document.getElementById('his-hand');
const $compare = document.getElementById('compare');
const $result = document.getElementById('result');

$compare.addEventListener('click', () => {
let result = -1;
try {
myPokerHand.update($myHand.value);
hisPokerHand.update($hisHand.value);
result = myPokerHand.compareWith(hisPokerHand);
} catch (e) {
$result.innerHTML = e.message;
return;
}

if (result === CompareResult.Win) {
$result.innerHTML = 'I win';
} else if (result === CompareResult.Loss) {
$result.innerHTML = 'I lose';
} else if (result === CompareResult.Tie) {
$result.innerHTML = 'Tie';
}
});
</script>
</body>
<script src="dist/pokerhand.min.js"></script>
<script>
const myPokerHand = new PokerHand('KS KH QC QD AD');
const hisPokerHand = new PokerHand('KD KC AS AH TD');

const $myHand = document.getElementById('my-hand');
const $hisHand = document.getElementById('his-hand');
const $compare = document.getElementById('compare');
const $result = document.getElementById('result');

$compare.addEventListener('click', function() {
let result = -1;
try {
myPokerHand.update($myHand.value);
hisPokerHand.update($hisHand.value);
result = myPokerHand.compareWith(hisPokerHand);
} catch (e) {
$result.innerHTML = e;
}

if (result === 1) {
$result.innerHTML = 'I win';
} else if (result === 2) {
$result.innerHTML = 'I loose';
} else if (result === 3) {
$result.innerHTML = 'Tie';
} else {
$result.innerHTML = 'Error';
}

});
</script>
</html>
1 change: 0 additions & 1 deletion index.js

This file was deleted.

Loading