-
Notifications
You must be signed in to change notification settings - Fork 90
Create Bcgamevip #13
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
Open
ngocloi93
wants to merge
9
commits into
bcgame-project:main
Choose a base branch
from
ngocloi93:patch-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Create Bcgamevip #13
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
38cc56f
up
bcgameProject 1aab981
Add files via upload
bcgameProject 3c0813d
Update baccaratsingle.html
bcgameProject 89ab2db
Update crash.html
bcgameProject c1dc3ec
forgot a holl
bcgameProject dc38925
change salt
bcgameProject 7eac86d
Add files via upload
bcgameProject 11af0ca
Update double.html
bcgameProject 1ea1783
Create Bcgamevip
ngocloi93 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,235 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Baccarat Single Verify</title> | ||
| <link rel="stylesheet" href="./lib/main.css"> | ||
| <link rel="stylesheet" href="./lib/bootstrap/css/bootstrap.min.css"> | ||
| <script src="./lib/react.production.min.js"></script> | ||
| <script src="./lib/react-dom.production.min.js"></script> | ||
| <script src="./lib/crypto-js.js"></script> | ||
| <script src="./lib/tools.js"></script> | ||
| <script src="./lib/hooks.js"></script> | ||
| <script src="./lib/babel.min.js"></script> | ||
| <style> | ||
| .cards-list { | ||
| margin-bottom: 12px; | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
| .cards-list .card { | ||
| margin-right: 20px; | ||
| } | ||
| .card.red { | ||
| color: #f00; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <div id="app"></div> | ||
| <script type="text/babel"> | ||
| let qs = tools.queryString(); | ||
| let { useEffect, useMemo } = React; | ||
| const { useSetState } = hooks; | ||
| function useInputControl (initState) { | ||
| const [state, setState] = useSetState(initState); | ||
| const bind = key => ({ | ||
| value: state[key], | ||
| onChange: v => setState({[key]: v}) | ||
| }); | ||
| return [ | ||
| state, | ||
| setState, | ||
| bind | ||
| ]; | ||
| } | ||
| function Input ({value, onChange, ...others}) { | ||
| return ( | ||
| <div class="form-group"> | ||
| <input value={value} | ||
| onChange={e => onChange(e.target.value)} | ||
| class="form-control" | ||
| {...others} | ||
| /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| const allNums = [ | ||
| 161, 180, 199, 218, 162, 205, 181, 200, 219, 163, 182, 220, 201, 177, 196, | ||
| 215, 170, 178, 221, 197, 216, 171, 179, 198, 172, 217, 193, 212, 167, 186, | ||
| 194, 173, 213, 168, 187, 195, 214, 188, 169, 209, 164, 183, 202, 210, 189, | ||
| 165, 184, 203, 211, 166, 204, 185, | ||
| ]; | ||
|
|
||
| function createCards (hash, times, cards, hashList) { | ||
| hashList.push(hash); | ||
| if (times <= 0) return | ||
| let h = hash; | ||
| allNums.forEach((c) => { | ||
| cards.push({card: c, hash: h}); | ||
| h = h.substring(1) + h.charAt(0); | ||
| }); | ||
|
|
||
| hash = String(CryptoJS.SHA256(hash)); | ||
| times--; | ||
| createCards(hash, times, cards, hashList); | ||
| } | ||
|
|
||
| function create (hash, times) { | ||
| times = times || 2; | ||
| let cards = []; | ||
| let hashList = []; | ||
| createCards(hash, times, cards, hashList); | ||
| cards.sort(function (o1, o2) { | ||
| if (o1.hash < o2.hash) { | ||
| return -1; | ||
| } else if (o1.hash == o2.hash) { | ||
| return 0; | ||
| } else { | ||
| return 1; | ||
| } | ||
| }) | ||
| return cards; | ||
| } | ||
|
|
||
| function canBankerGetCard (point, palyerPoint, thirdCardPoint) { | ||
| if(palyerPoint >= 8) return false; | ||
| if(point <= 2) return true; | ||
| else if(point === 3) { | ||
| return thirdCardPoint !=8 ; | ||
| } else if(point === 4) { | ||
| return [0, 1, 8, 9].indexOf(thirdCardPoint) < 0; | ||
| } else if(point === 5) { | ||
| return [0, 1, 2, 3, 8, 9].indexOf(thirdCardPoint) < 0; | ||
| } else if(point === 6) { | ||
| return [6, 7].indexOf(thirdCardPoint) >= 0; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| function getPoint (list) { | ||
| const result = list.reduce((pre, item) => { | ||
| const currPoint = item.pointNum > 10 ? 10 : item.pointNum; | ||
| return pre + currPoint; | ||
| }, 0) | ||
| return result % 10; | ||
| } | ||
|
|
||
| function getRestlt (hash) { | ||
| let beginHash = String(tools.sha256(hash)); | ||
| const resultList = create(beginHash); | ||
| return resultList.map((m) => m.card); | ||
| } | ||
|
|
||
| function createCardFram(card) { | ||
| const CARDS = " ,A,2,3,4,5,6,7,8,9,10,J,Q,K".split(","); | ||
| const SUITS = ["♠", "♥", "♣", "♦"]; | ||
| let suitsIndex = (card & 240) / 16 - 10; | ||
| let suits = SUITS[suitsIndex]; | ||
| let point = CARDS[card % 16]; | ||
| let pointNum = card % 16; | ||
| let style = suitsIndex % 2 === 0 ? "black" : "red"; | ||
| let classNames = ["cardbox", style]; | ||
| return { | ||
| style, | ||
| suits, | ||
| point, | ||
| pointNum: pointNum > 10 ? 10 : pointNum | ||
| }; | ||
| } | ||
|
|
||
| function encode(suit, point) { | ||
| return ((suit + 10) << 4) + point; | ||
| } | ||
|
|
||
| function BaccaratSingle () { | ||
| const [state, setState, bind] = useInputControl({ | ||
| clientSeed: qs.c||'', | ||
| serverSeed: qs.s||'', | ||
| nonce: qs.n||'' | ||
| }); | ||
|
|
||
| const result = useMemo(() => { | ||
| const serverSeedHash = tools.sha256(state.serverSeed); | ||
| const resultArr = [state.clientSeed, state.nonce]; | ||
| const hmacSha256Result = String(CryptoJS.HmacSHA256(resultArr.join(":"), state.serverSeed)); | ||
| const resultList = getRestlt(hmacSha256Result); | ||
| const player = [createCardFram(resultList[0]), createCardFram(resultList[2])]; | ||
| const banker = [createCardFram(resultList[1]), createCardFram(resultList[3])]; | ||
| const palyerPoint = getPoint(player); | ||
| const bankerPoint = getPoint(banker); | ||
| const isPlayerGetCard = palyerPoint % 10 < 6; | ||
| const isBankerEnd = bankerPoint % 10 >= 8; | ||
| if(isPlayerGetCard && !isBankerEnd) { | ||
| player.push(new Card(resultList[4])); | ||
| } | ||
| const thirdCardPoint = player[2] ? getPoint([player[2]]) % 10 : -1; | ||
| const flag = canBankerGetCard(bankerPoint % 10, palyerPoint % 10, thirdCardPoint); | ||
| if(flag) banker.push(isPlayerGetCard ? createCardFram(resultList[5]) : createCardFram(resultList[4])); | ||
| const playerPointFinal = getPoint(player); | ||
| const bankerPointFinal = getPoint(banker); | ||
| return { | ||
| player, | ||
| banker, | ||
| playerPointFinal, | ||
| bankerPointFinal, | ||
| hmacSha256Result, | ||
|
|
||
| } | ||
| }, [state]); | ||
| const {player, banker, playerPointFinal, bankerPointFinal} = result; | ||
| return ( | ||
| <div className="main"> | ||
| <h1 className="text-center pb-5">Baccarat single verify</h1> | ||
| <hr /> | ||
| <h2 class="text-center">Input</h2> | ||
| <form className="py-5"> | ||
| <Input placeholder="Server Seed" {...bind('serverSeed')} /> | ||
| <Input placeholder="Client Seed (Hashed)" {...bind('clientSeed')} /> | ||
| <Input placeholder="Nonce" {...bind('nonce')} /> | ||
| </form> | ||
| <h2 class="text-center">Output</h2> | ||
| <form className="py-5"> | ||
| <Input placeholder="HmacSHA256(clientSeed, serverSeed)" readOnly value={result.hmacSha256Result} /> | ||
| <h5 style={{marginTop: 20}}>Result</h5> | ||
| <div className="result-list"> | ||
| <div className="player-cards"> | ||
| <p>Player: {playerPointFinal % 10}</p> | ||
| <div className="cards-list"> | ||
| {player.map((item, index) => { | ||
| const clname = "result-card-item" + (index+1); | ||
| return ( | ||
| <div className={clname + " card " + item.style} key={item.pointNum + "-" + index}> | ||
| <div className="flower">{item.suits}</div> | ||
| <div className="point">{item.point}</div> | ||
| </div> | ||
| ) | ||
| })} | ||
| </div> | ||
| </div> | ||
| <div className="banker-cards"> | ||
| <p>Banker: {bankerPointFinal % 10}</p> | ||
| <div className="cards-list"> | ||
| {banker.map((item, index) => { | ||
| const clname = "result-card-item" + (index+1); | ||
| return ( | ||
| <div className={clname + " card " + item.style} key={item.pointNum + "-" + index}> | ||
| <div className="flower">{item.suits}</div> | ||
| <div className="point">{item.point}</div> | ||
| </div> | ||
| ) | ||
| })} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </form> | ||
| </div> | ||
| ); | ||
| } | ||
| ReactDOM.render(<BaccaratSingle />, document.getElementById("app")); | ||
| </script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//NULL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complete