├── Poker
├── .idea
│ ├── .name
│ ├── dictionaries
│ │ └── zyshi.xml
│ ├── misc.xml
│ ├── scopes
│ │ └── scope_settings.xml
│ ├── encodings.xml
│ ├── vcs.xml
│ ├── jsLibraryMappings.xml
│ ├── modules.xml
│ └── Joker.iml
├── assets
│ ├── 2x
│ │ ├── coin.png
│ │ ├── .DS_Store
│ │ ├── dealer.png
│ │ ├── btn-blue.png
│ │ ├── btn-grey.png
│ │ ├── btn-rules.png
│ │ ├── check-off.png
│ │ ├── check-on.png
│ │ ├── chip-pool.png
│ │ ├── fill-box.png
│ │ ├── light_dot.png
│ │ ├── player-me.png
│ │ ├── roomLight.png
│ │ ├── slidebar.png
│ │ ├── win-frame.png
│ │ ├── background.png
│ │ ├── btn-4-blue.png
│ │ ├── btn-4-grey.png
│ │ ├── btn-slider.png
│ │ ├── btn-yellow.png
│ │ ├── card_typebg.png
│ │ ├── add-chips-box.png
│ │ ├── btn-4-yellow.png
│ │ ├── btn-big-blue.png
│ │ ├── btn-big-green.png
│ │ ├── defaultProfile.png
│ │ ├── player-blank.png
│ │ ├── player-guest.png
│ │ ├── sliderGroove.png
│ │ ├── texas_chip01.png
│ │ ├── texas_chip05.png
│ │ ├── texas_chip10w.png
│ │ ├── texas_chip1k.png
│ │ ├── texas_chip50w.png
│ │ ├── texas_chip5k.png
│ │ ├── win-frame-bg.png
│ │ ├── btn-small-red@2x.png
│ │ ├── cards
│ │ │ ├── card_back.png
│ │ │ ├── card_clubs_1.png
│ │ │ ├── card_clubs_10.png
│ │ │ ├── card_clubs_11.png
│ │ │ ├── card_clubs_12.png
│ │ │ ├── card_clubs_13.png
│ │ │ ├── card_clubs_2.png
│ │ │ ├── card_clubs_3.png
│ │ │ ├── card_clubs_4.png
│ │ │ ├── card_clubs_5.png
│ │ │ ├── card_clubs_6.png
│ │ │ ├── card_clubs_7.png
│ │ │ ├── card_clubs_8.png
│ │ │ ├── card_clubs_9.png
│ │ │ ├── card_hearts_1.png
│ │ │ ├── card_hearts_2.png
│ │ │ ├── card_hearts_3.png
│ │ │ ├── card_hearts_4.png
│ │ │ ├── card_hearts_5.png
│ │ │ ├── card_hearts_6.png
│ │ │ ├── card_hearts_7.png
│ │ │ ├── card_hearts_8.png
│ │ │ ├── card_hearts_9.png
│ │ │ ├── card_spades_1.png
│ │ │ ├── card_spades_2.png
│ │ │ ├── card_spades_3.png
│ │ │ ├── card_spades_4.png
│ │ │ ├── card_spades_5.png
│ │ │ ├── card_spades_6.png
│ │ │ ├── card_spades_7.png
│ │ │ ├── card_spades_8.png
│ │ │ ├── card_spades_9.png
│ │ │ ├── card_diamonds_1.png
│ │ │ ├── card_diamonds_2.png
│ │ │ ├── card_diamonds_3.png
│ │ │ ├── card_diamonds_4.png
│ │ │ ├── card_diamonds_5.png
│ │ │ ├── card_diamonds_6.png
│ │ │ ├── card_diamonds_7.png
│ │ │ ├── card_diamonds_8.png
│ │ │ ├── card_diamonds_9.png
│ │ │ ├── card_hearts_10.png
│ │ │ ├── card_hearts_11.png
│ │ │ ├── card_hearts_12.png
│ │ │ ├── card_hearts_13.png
│ │ │ ├── card_spades_10.png
│ │ │ ├── card_spades_11.png
│ │ │ ├── card_spades_12.png
│ │ │ ├── card_spades_13.png
│ │ │ ├── card_diamonds_10.png
│ │ │ ├── card_diamonds_11.png
│ │ │ ├── card_diamonds_12.png
│ │ │ └── card_diamonds_13.png
│ │ ├── pop-up-window@2x.png
│ │ ├── win-frameWaiting.png
│ │ ├── btn-big-orange@2x.png
│ │ ├── btn-small-blue@2x.png
│ │ └── card_backs_rotate.png
│ ├── 1x
│ │ ├── .DS_Store
│ │ ├── dealer.png
│ │ ├── btn-blue.png
│ │ ├── btn-grey.png
│ │ ├── check-off.png
│ │ ├── check-on.png
│ │ ├── chip-pool.png
│ │ ├── light_dot.png
│ │ ├── player-me.png
│ │ ├── roomLight.png
│ │ ├── win-frame.png
│ │ ├── background.png
│ │ ├── btn-3-blue.png
│ │ ├── btn-3-grey.png
│ │ ├── btn-4-blue.png
│ │ ├── btn-4-grey.png
│ │ ├── btn-yellow.png
│ │ ├── cards
│ │ │ ├── .DS_Store
│ │ │ ├── card_back.png
│ │ │ ├── card_back_ver.png
│ │ │ ├── card_clubs_1.png
│ │ │ ├── card_clubs_10.png
│ │ │ ├── card_clubs_11.png
│ │ │ ├── card_clubs_12.png
│ │ │ ├── card_clubs_13.png
│ │ │ ├── card_clubs_2.png
│ │ │ ├── card_clubs_3.png
│ │ │ ├── card_clubs_4.png
│ │ │ ├── card_clubs_5.png
│ │ │ ├── card_clubs_6.png
│ │ │ ├── card_clubs_7.png
│ │ │ ├── card_clubs_8.png
│ │ │ ├── card_clubs_9.png
│ │ │ ├── card_hearts_1.png
│ │ │ ├── card_hearts_2.png
│ │ │ ├── card_hearts_3.png
│ │ │ ├── card_hearts_4.png
│ │ │ ├── card_hearts_5.png
│ │ │ ├── card_hearts_6.png
│ │ │ ├── card_hearts_7.png
│ │ │ ├── card_hearts_8.png
│ │ │ ├── card_hearts_9.png
│ │ │ ├── card_spades_1.png
│ │ │ ├── card_spades_2.png
│ │ │ ├── card_spades_3.png
│ │ │ ├── card_spades_4.png
│ │ │ ├── card_spades_5.png
│ │ │ ├── card_spades_6.png
│ │ │ ├── card_spades_7.png
│ │ │ ├── card_spades_8.png
│ │ │ ├── card_spades_9.png
│ │ │ ├── card_diamonds_1.png
│ │ │ ├── card_diamonds_2.png
│ │ │ ├── card_diamonds_3.png
│ │ │ ├── card_diamonds_4.png
│ │ │ ├── card_diamonds_5.png
│ │ │ ├── card_diamonds_6.png
│ │ │ ├── card_diamonds_7.png
│ │ │ ├── card_diamonds_8.png
│ │ │ ├── card_diamonds_9.png
│ │ │ ├── card_hearts_10.png
│ │ │ ├── card_hearts_11.png
│ │ │ ├── card_hearts_12.png
│ │ │ ├── card_hearts_13.png
│ │ │ ├── card_spades_10.png
│ │ │ ├── card_spades_11.png
│ │ │ ├── card_spades_12.png
│ │ │ ├── card_spades_13.png
│ │ │ ├── card_back_qingxie.png
│ │ │ ├── card_backs_rotate.png
│ │ │ ├── card_diamonds_10.png
│ │ │ ├── card_diamonds_11.png
│ │ │ ├── card_diamonds_12.png
│ │ │ └── card_diamonds_13.png
│ │ ├── add-chips-box.png
│ │ ├── btn-3-yellow.png
│ │ ├── btn-4-yellow.png
│ │ ├── defaultProfile.png
│ │ ├── player-blank.png
│ │ ├── player-guest.png
│ │ ├── sliderGroove.png
│ │ ├── texas_chip01.png
│ │ ├── texas_chip05.png
│ │ ├── texas_chip10w.png
│ │ ├── texas_chip1k.png
│ │ ├── texas_chip50w.png
│ │ ├── texas_chip5k.png
│ │ ├── win-frame-bg.png
│ │ ├── win-frameWaiting.png
│ │ └── card_backs_rotate.png
│ └── sound
│ │ ├── win.mp3
│ │ ├── click.mp3
│ │ ├── ding.mp3
│ │ ├── lose.mp3
│ │ ├── sendcard.mp3
│ │ ├── chipsmoving.mp3
│ │ └── reordercard.mp3
├── index.html
├── betapi.js
├── server.js
├── animations.js
├── main.js
└── loginState.js
├── README.md
├── server
├── eva
│ ├── allfive
│ ├── Makefile
│ ├── Makefile.txt
│ ├── poker.h
│ ├── allfive.c
│ └── pokerlib.c
├── examples
│ ├── card.go
│ ├── server
│ │ └── main.go
│ └── client
│ │ └── client.go
├── pot.go
├── poker.go
├── conn.go
├── ws.go
├── occupant.go
├── card.go
└── room.go
├── iOS
└── Pocker
│ ├── Pocker.xcodeproj
│ ├── project.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcuserdata
│ │ │ └── zhengying.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcuserdata
│ │ └── zhengying.xcuserdatad
│ │ ├── xcschemes
│ │ ├── xcschememanagement.plist
│ │ └── Pocker.xcscheme
│ │ └── xcdebugger
│ │ └── Breakpoints_v2.xcbkptlist
│ ├── Pocker
│ ├── ViewController.h
│ ├── AppDelegate.h
│ ├── main.m
│ ├── SettingViewController.h
│ ├── PokerViewController.h
│ ├── PokerViewControllerEx.h
│ ├── ViewController.m
│ ├── Images.xcassets
│ │ ├── LaunchImage.launchimage
│ │ │ └── Contents.json
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── Info.plist
│ ├── WebViewJavascriptBridge
│ │ ├── WebViewJavascriptBridge.h
│ │ └── WebViewJavascriptBridge.js.txt
│ ├── AppDelegate.m
│ ├── SettingViewController.m
│ ├── Base.lproj
│ │ └── LaunchScreen.xib
│ ├── DQAlertView
│ │ └── DQAlertView.h
│ ├── PokerViewController.m
│ └── PokerViewControllerEx.m
│ ├── PockerTests
│ ├── Info.plist
│ └── PockerTests.m
│ └── WebViewJavascriptBridge
│ ├── WebViewJavascriptBridge.h
│ └── WebViewJavascriptBridge.js.txt
├── .gitignore
└── LICENSE
/Poker/.idea/.name:
--------------------------------------------------------------------------------
1 | Joker
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | webpoker
2 | ========
3 |
4 | a poker game use phaser framework
--------------------------------------------------------------------------------
/server/eva/allfive:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/server/eva/allfive
--------------------------------------------------------------------------------
/Poker/assets/2x/coin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/coin.png
--------------------------------------------------------------------------------
/Poker/assets/1x/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/.DS_Store
--------------------------------------------------------------------------------
/Poker/assets/1x/dealer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/dealer.png
--------------------------------------------------------------------------------
/Poker/assets/2x/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/.DS_Store
--------------------------------------------------------------------------------
/Poker/assets/2x/dealer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/dealer.png
--------------------------------------------------------------------------------
/Poker/assets/sound/win.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/sound/win.mp3
--------------------------------------------------------------------------------
/Poker/assets/1x/btn-blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/btn-blue.png
--------------------------------------------------------------------------------
/Poker/assets/1x/btn-grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/btn-grey.png
--------------------------------------------------------------------------------
/Poker/assets/1x/check-off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/check-off.png
--------------------------------------------------------------------------------
/Poker/assets/1x/check-on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/check-on.png
--------------------------------------------------------------------------------
/Poker/assets/1x/chip-pool.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/chip-pool.png
--------------------------------------------------------------------------------
/Poker/assets/1x/light_dot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/light_dot.png
--------------------------------------------------------------------------------
/Poker/assets/1x/player-me.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/player-me.png
--------------------------------------------------------------------------------
/Poker/assets/1x/roomLight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/roomLight.png
--------------------------------------------------------------------------------
/Poker/assets/1x/win-frame.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/win-frame.png
--------------------------------------------------------------------------------
/Poker/assets/2x/btn-blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/btn-blue.png
--------------------------------------------------------------------------------
/Poker/assets/2x/btn-grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/btn-grey.png
--------------------------------------------------------------------------------
/Poker/assets/2x/btn-rules.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/btn-rules.png
--------------------------------------------------------------------------------
/Poker/assets/2x/check-off.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/check-off.png
--------------------------------------------------------------------------------
/Poker/assets/2x/check-on.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/check-on.png
--------------------------------------------------------------------------------
/Poker/assets/2x/chip-pool.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/chip-pool.png
--------------------------------------------------------------------------------
/Poker/assets/2x/fill-box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/fill-box.png
--------------------------------------------------------------------------------
/Poker/assets/2x/light_dot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/light_dot.png
--------------------------------------------------------------------------------
/Poker/assets/2x/player-me.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/player-me.png
--------------------------------------------------------------------------------
/Poker/assets/2x/roomLight.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/roomLight.png
--------------------------------------------------------------------------------
/Poker/assets/2x/slidebar.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/slidebar.png
--------------------------------------------------------------------------------
/Poker/assets/2x/win-frame.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/win-frame.png
--------------------------------------------------------------------------------
/Poker/assets/sound/click.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/sound/click.mp3
--------------------------------------------------------------------------------
/Poker/assets/sound/ding.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/sound/ding.mp3
--------------------------------------------------------------------------------
/Poker/assets/sound/lose.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/sound/lose.mp3
--------------------------------------------------------------------------------
/Poker/assets/1x/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/background.png
--------------------------------------------------------------------------------
/Poker/assets/1x/btn-3-blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/btn-3-blue.png
--------------------------------------------------------------------------------
/Poker/assets/1x/btn-3-grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/btn-3-grey.png
--------------------------------------------------------------------------------
/Poker/assets/1x/btn-4-blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/btn-4-blue.png
--------------------------------------------------------------------------------
/Poker/assets/1x/btn-4-grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/btn-4-grey.png
--------------------------------------------------------------------------------
/Poker/assets/1x/btn-yellow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/btn-yellow.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/.DS_Store
--------------------------------------------------------------------------------
/Poker/assets/2x/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/background.png
--------------------------------------------------------------------------------
/Poker/assets/2x/btn-4-blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/btn-4-blue.png
--------------------------------------------------------------------------------
/Poker/assets/2x/btn-4-grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/btn-4-grey.png
--------------------------------------------------------------------------------
/Poker/assets/2x/btn-slider.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/btn-slider.png
--------------------------------------------------------------------------------
/Poker/assets/2x/btn-yellow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/btn-yellow.png
--------------------------------------------------------------------------------
/Poker/assets/2x/card_typebg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/card_typebg.png
--------------------------------------------------------------------------------
/Poker/assets/sound/sendcard.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/sound/sendcard.mp3
--------------------------------------------------------------------------------
/Poker/assets/1x/add-chips-box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/add-chips-box.png
--------------------------------------------------------------------------------
/Poker/assets/1x/btn-3-yellow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/btn-3-yellow.png
--------------------------------------------------------------------------------
/Poker/assets/1x/btn-4-yellow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/btn-4-yellow.png
--------------------------------------------------------------------------------
/Poker/assets/1x/defaultProfile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/defaultProfile.png
--------------------------------------------------------------------------------
/Poker/assets/1x/player-blank.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/player-blank.png
--------------------------------------------------------------------------------
/Poker/assets/1x/player-guest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/player-guest.png
--------------------------------------------------------------------------------
/Poker/assets/1x/sliderGroove.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/sliderGroove.png
--------------------------------------------------------------------------------
/Poker/assets/1x/texas_chip01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/texas_chip01.png
--------------------------------------------------------------------------------
/Poker/assets/1x/texas_chip05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/texas_chip05.png
--------------------------------------------------------------------------------
/Poker/assets/1x/texas_chip10w.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/texas_chip10w.png
--------------------------------------------------------------------------------
/Poker/assets/1x/texas_chip1k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/texas_chip1k.png
--------------------------------------------------------------------------------
/Poker/assets/1x/texas_chip50w.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/texas_chip50w.png
--------------------------------------------------------------------------------
/Poker/assets/1x/texas_chip5k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/texas_chip5k.png
--------------------------------------------------------------------------------
/Poker/assets/1x/win-frame-bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/win-frame-bg.png
--------------------------------------------------------------------------------
/Poker/assets/2x/add-chips-box.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/add-chips-box.png
--------------------------------------------------------------------------------
/Poker/assets/2x/btn-4-yellow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/btn-4-yellow.png
--------------------------------------------------------------------------------
/Poker/assets/2x/btn-big-blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/btn-big-blue.png
--------------------------------------------------------------------------------
/Poker/assets/2x/btn-big-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/btn-big-green.png
--------------------------------------------------------------------------------
/Poker/assets/2x/defaultProfile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/defaultProfile.png
--------------------------------------------------------------------------------
/Poker/assets/2x/player-blank.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/player-blank.png
--------------------------------------------------------------------------------
/Poker/assets/2x/player-guest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/player-guest.png
--------------------------------------------------------------------------------
/Poker/assets/2x/sliderGroove.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/sliderGroove.png
--------------------------------------------------------------------------------
/Poker/assets/2x/texas_chip01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/texas_chip01.png
--------------------------------------------------------------------------------
/Poker/assets/2x/texas_chip05.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/texas_chip05.png
--------------------------------------------------------------------------------
/Poker/assets/2x/texas_chip10w.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/texas_chip10w.png
--------------------------------------------------------------------------------
/Poker/assets/2x/texas_chip1k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/texas_chip1k.png
--------------------------------------------------------------------------------
/Poker/assets/2x/texas_chip50w.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/texas_chip50w.png
--------------------------------------------------------------------------------
/Poker/assets/2x/texas_chip5k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/texas_chip5k.png
--------------------------------------------------------------------------------
/Poker/assets/2x/win-frame-bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/win-frame-bg.png
--------------------------------------------------------------------------------
/Poker/assets/sound/chipsmoving.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/sound/chipsmoving.mp3
--------------------------------------------------------------------------------
/Poker/assets/sound/reordercard.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/sound/reordercard.mp3
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_back.png
--------------------------------------------------------------------------------
/Poker/assets/1x/win-frameWaiting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/win-frameWaiting.png
--------------------------------------------------------------------------------
/Poker/assets/2x/btn-small-red@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/btn-small-red@2x.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_back.png
--------------------------------------------------------------------------------
/Poker/assets/2x/pop-up-window@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/pop-up-window@2x.png
--------------------------------------------------------------------------------
/Poker/assets/2x/win-frameWaiting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/win-frameWaiting.png
--------------------------------------------------------------------------------
/Poker/.idea/dictionaries/zyshi.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Poker/assets/1x/card_backs_rotate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/card_backs_rotate.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_back_ver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_back_ver.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_clubs_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_clubs_1.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_clubs_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_clubs_10.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_clubs_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_clubs_11.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_clubs_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_clubs_12.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_clubs_13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_clubs_13.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_clubs_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_clubs_2.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_clubs_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_clubs_3.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_clubs_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_clubs_4.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_clubs_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_clubs_5.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_clubs_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_clubs_6.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_clubs_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_clubs_7.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_clubs_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_clubs_8.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_clubs_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_clubs_9.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_hearts_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_hearts_1.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_hearts_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_hearts_2.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_hearts_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_hearts_3.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_hearts_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_hearts_4.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_hearts_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_hearts_5.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_hearts_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_hearts_6.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_hearts_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_hearts_7.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_hearts_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_hearts_8.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_hearts_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_hearts_9.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_spades_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_spades_1.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_spades_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_spades_2.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_spades_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_spades_3.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_spades_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_spades_4.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_spades_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_spades_5.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_spades_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_spades_6.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_spades_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_spades_7.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_spades_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_spades_8.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_spades_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_spades_9.png
--------------------------------------------------------------------------------
/Poker/assets/2x/btn-big-orange@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/btn-big-orange@2x.png
--------------------------------------------------------------------------------
/Poker/assets/2x/btn-small-blue@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/btn-small-blue@2x.png
--------------------------------------------------------------------------------
/Poker/assets/2x/card_backs_rotate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/card_backs_rotate.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_clubs_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_clubs_1.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_clubs_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_clubs_10.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_clubs_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_clubs_11.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_clubs_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_clubs_12.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_clubs_13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_clubs_13.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_clubs_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_clubs_2.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_clubs_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_clubs_3.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_clubs_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_clubs_4.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_clubs_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_clubs_5.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_clubs_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_clubs_6.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_clubs_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_clubs_7.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_clubs_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_clubs_8.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_clubs_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_clubs_9.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_hearts_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_hearts_1.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_hearts_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_hearts_2.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_hearts_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_hearts_3.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_hearts_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_hearts_4.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_hearts_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_hearts_5.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_hearts_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_hearts_6.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_hearts_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_hearts_7.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_hearts_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_hearts_8.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_hearts_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_hearts_9.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_spades_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_spades_1.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_spades_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_spades_2.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_spades_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_spades_3.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_spades_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_spades_4.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_spades_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_spades_5.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_spades_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_spades_6.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_spades_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_spades_7.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_spades_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_spades_8.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_spades_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_spades_9.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_diamonds_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_diamonds_1.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_diamonds_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_diamonds_2.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_diamonds_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_diamonds_3.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_diamonds_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_diamonds_4.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_diamonds_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_diamonds_5.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_diamonds_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_diamonds_6.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_diamonds_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_diamonds_7.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_diamonds_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_diamonds_8.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_diamonds_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_diamonds_9.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_hearts_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_hearts_10.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_hearts_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_hearts_11.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_hearts_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_hearts_12.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_hearts_13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_hearts_13.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_spades_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_spades_10.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_spades_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_spades_11.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_spades_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_spades_12.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_spades_13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_spades_13.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_diamonds_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_diamonds_1.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_diamonds_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_diamonds_2.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_diamonds_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_diamonds_3.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_diamonds_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_diamonds_4.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_diamonds_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_diamonds_5.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_diamonds_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_diamonds_6.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_diamonds_7.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_diamonds_7.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_diamonds_8.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_diamonds_8.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_diamonds_9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_diamonds_9.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_hearts_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_hearts_10.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_hearts_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_hearts_11.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_hearts_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_hearts_12.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_hearts_13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_hearts_13.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_spades_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_spades_10.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_spades_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_spades_11.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_spades_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_spades_12.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_spades_13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_spades_13.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_back_qingxie.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_back_qingxie.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_backs_rotate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_backs_rotate.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_diamonds_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_diamonds_10.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_diamonds_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_diamonds_11.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_diamonds_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_diamonds_12.png
--------------------------------------------------------------------------------
/Poker/assets/1x/cards/card_diamonds_13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/1x/cards/card_diamonds_13.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_diamonds_10.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_diamonds_10.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_diamonds_11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_diamonds_11.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_diamonds_12.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_diamonds_12.png
--------------------------------------------------------------------------------
/Poker/assets/2x/cards/card_diamonds_13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/Poker/assets/2x/cards/card_diamonds_13.png
--------------------------------------------------------------------------------
/Poker/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Poker/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/Poker/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Poker/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/server/eva/Makefile:
--------------------------------------------------------------------------------
1 |
2 | CC=cc
3 |
4 | allfive: allfive.c pokerlib.o
5 | ${CC} ${CFLAGS} allfive.c pokerlib.o -o allfive
6 |
7 | pokerlib.o: pokerlib.c arrays.h
8 | ${CC} -c ${CFLAGS} pokerlib.c -o pokerlib.o
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/server/eva/Makefile.txt:
--------------------------------------------------------------------------------
1 |
2 | CC=cc
3 | CFLAGS=-fast
4 |
5 | allfive: allfive.c pokerlib.o
6 | ${CC} ${CFLAGS} allfive.c pokerlib.o -s -o allfive
7 |
8 | pokerlib.o: pokerlib.c arrays.h
9 | ${CC} -c ${CFLAGS} pokerlib.c -o pokerlib.o
10 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker.xcodeproj/project.xcworkspace/xcuserdata/zhengying.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginuerzh/poker/HEAD/iOS/Pocker/Pocker.xcodeproj/project.xcworkspace/xcuserdata/zhengying.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/Poker/.idea/jsLibraryMappings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Poker/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Poker/.idea/Joker.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // Pocker
4 | //
5 | // Created by zhengying on 3/9/15.
6 | // Copyright (c) 2015 zhengying. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface ViewController : UIViewController
13 |
14 |
15 | @end
16 |
17 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // Pocker
4 | //
5 | // Created by zhengying on 3/9/15.
6 | // Copyright (c) 2015 zhengying. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files, Static and Dynamic libs (Shared Objects)
2 | *.o
3 | *.a
4 | *.so
5 |
6 | # Folders
7 | _obj
8 | _test
9 |
10 | # Architecture specific extensions/prefixes
11 | *.[568vq]
12 | [568vq].out
13 |
14 | *.cgo1.go
15 | *.cgo2.c
16 | _cgo_defun.c
17 | _cgo_gotypes.go
18 | _cgo_export.*
19 |
20 | _testmain.go
21 |
22 | *.exe
23 | *.test
24 | *.prof
25 | DerivedData
26 | .DS_Store
27 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // Pocker
4 | //
5 | // Created by zhengying on 3/9/15.
6 | // Copyright (c) 2015 zhengying. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/SettingViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // SettingViewController.h
3 | // Pocker
4 | //
5 | // Created by zhengying on 3/9/15.
6 | // Copyright (c) 2015 zhengying. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SettingViewController : UIViewController
12 | @property(nonatomic, weak) IBOutlet UISwitch* linodeSwitch;
13 | @property(nonatomic, weak) IBOutlet UITextField* txtFieldUserName;
14 | @end
15 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/PokerViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // PokerViewController.h
3 | // Pocker
4 | //
5 | // Created by zhengying on 3/13/15.
6 | // Copyright (c) 2015 zhengying. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface PokerViewController : UIViewController
13 | @property(nonatomic, weak) IBOutlet UIWebView* webView;
14 | @property(nonatomic, strong) NSString* token;
15 | @property(nonatomic, strong) NSString* joinroom;
16 | @end
17 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/PokerViewControllerEx.h:
--------------------------------------------------------------------------------
1 | //
2 | // PokerViewControllerEx.h
3 | // Pocker
4 | //
5 | // Created by zhengying on 3/30/15.
6 | // Copyright (c) 2015 zhengying. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 |
12 | typedef void(^blockProfileShow)(NSString* userID);
13 |
14 | @interface PokerViewControllerEx : UIViewController
15 | @property(nonatomic, strong) UIWebView* webView;
16 | @property(nonatomic, strong) NSString* token;
17 | @property(nonatomic, strong) NSString* joinroom;
18 | @property(nonatomic, copy) blockProfileShow profileShowBlock;
19 | @end
20 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker.xcodeproj/xcuserdata/zhengying.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | Pocker.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | 53B023441AAD3AD0004BAA2D
16 |
17 | primary
18 |
19 |
20 | 53B0235D1AAD3AD1004BAA2D
21 |
22 | primary
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/server/examples/card.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "flag"
5 | "fmt"
6 | "github.com/ginuerzh/poker"
7 | )
8 |
9 | func init() {
10 | flag.Parse()
11 | }
12 |
13 | func main() {
14 | args := flag.Args()
15 | if len(args) < 5 {
16 | return
17 | }
18 |
19 | if len(args) == 5 {
20 | var cards [5]poker.Card
21 | for i, v := range args {
22 | card := poker.ParseCard(v)
23 | if card == poker.NilCard {
24 | return
25 | }
26 | cards[i] = card
27 | }
28 | hand := poker.Eva5Hand(cards)
29 | fmt.Println(hand)
30 | }
31 |
32 | if len(args) == 7 {
33 | var cards [7]poker.Card
34 | for i, v := range args {
35 | card := poker.ParseCard(v)
36 | if card == poker.NilCard {
37 | return
38 | }
39 | cards[i] = card
40 | }
41 | fmt.Println(poker.Eva7Hand(cards))
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/iOS/Pocker/PockerTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.tcl.tct.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // Pocker
4 | //
5 | // Created by zhengying on 3/9/15.
6 | // Copyright (c) 2015 zhengying. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "WebViewJavascriptBridge/WebViewJavascriptBridge.h"
11 | #import "PokerViewControllerEx.h"
12 |
13 | @interface ViewController ()
14 |
15 | @end
16 |
17 | @implementation ViewController {
18 |
19 | }
20 |
21 |
22 | -(IBAction)actionLoadGameEx:(id)sender {
23 | PokerViewControllerEx* pocker = [[PokerViewControllerEx alloc]init];
24 | pocker.joinroom = @"1001";
25 |
26 | /*
27 | __weak __typeof(self) weakSelf = self;
28 | pocker.profileShowBlock = ^(NSString* userID) {
29 | // TODO: show profile window
30 | };
31 | */
32 | [self.navigationController presentViewController:pocker animated:YES completion:nil];
33 | }
34 |
35 |
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/server/examples/server/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "flag"
5 | "log"
6 | "strconv"
7 | "time"
8 |
9 | "github.com/ginuerzh/poker/server"
10 | )
11 |
12 | var (
13 | WebRoot string
14 | Addr string
15 | MongoAddr string
16 | RedisAddr string
17 | )
18 |
19 | func init() {
20 | log.SetFlags(log.Lshortfile | log.LstdFlags)
21 |
22 | flag.StringVar(&Addr, "addr", ":8989", "server address ip:port")
23 | flag.StringVar(&WebRoot, "web", "", "web directory rooted path")
24 | flag.Parse()
25 | }
26 |
27 | func main() {
28 | poker := &poker.Poker{
29 | Addr: Addr,
30 | WebRoot: WebRoot,
31 | OnAuth: onAuth,
32 | }
33 | log.Fatal(poker.ListenAndServe())
34 | }
35 |
36 | func onAuth(conn *poker.Conn, mechanism, text string) (*poker.Occupant, error) {
37 | id := strconv.FormatInt(time.Now().Unix(), 10)
38 | if text != "" {
39 | id = text
40 | }
41 | o := poker.NewOccupant(id, conn)
42 | o.Name = id
43 |
44 | return o, nil
45 | }
46 |
--------------------------------------------------------------------------------
/iOS/Pocker/PockerTests/PockerTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // PockerTests.m
3 | // PockerTests
4 | //
5 | // Created by zhengying on 3/9/15.
6 | // Copyright (c) 2015 zhengying. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 |
12 | @interface PockerTests : XCTestCase
13 |
14 | @end
15 |
16 | @implementation PockerTests
17 |
18 | - (void)setUp {
19 | [super setUp];
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 | }
22 |
23 | - (void)tearDown {
24 | // Put teardown code here. This method is called after the invocation of each test method in the class.
25 | [super tearDown];
26 | }
27 |
28 | - (void)testExample {
29 | // This is an example of a functional test case.
30 | XCTAssert(YES, @"Pass");
31 | }
32 |
33 | - (void)testPerformanceExample {
34 | // This is an example of a performance test case.
35 | [self measureBlock:^{
36 | // Put the code you want to measure the time of here.
37 | }];
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/Poker/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Hello
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
29 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/server/pot.go:
--------------------------------------------------------------------------------
1 | package poker
2 |
3 | import (
4 | "sort"
5 | )
6 |
7 | type handBet struct {
8 | Pos int
9 | Bet int
10 | }
11 |
12 | type handBets []handBet
13 |
14 | func (p handBets) Len() int {
15 | return len(p)
16 | }
17 |
18 | func (p handBets) Less(i, j int) bool {
19 | return p[i].Bet < p[j].Bet
20 | }
21 |
22 | func (p handBets) Swap(i, j int) {
23 | p[i], p[j] = p[j], p[i]
24 | }
25 |
26 | type handPot struct {
27 | Pot int
28 | OPos []int
29 | }
30 |
31 | // main pot and side-pot calculation
32 | func calcPot(bets []int) (pots []handPot) {
33 | var obs []handBet
34 |
35 | //fmt.Println("amount bets:", bets)
36 | for i, bet := range bets {
37 | if bet > 0 {
38 | obs = append(obs, handBet{Pos: i + 1, Bet: bet})
39 | }
40 | }
41 | sort.Sort(handBets(obs))
42 |
43 | //fmt.Println("amount bets(sorted):", obs)
44 |
45 | for i, ob := range obs {
46 | if ob.Bet > 0 {
47 | s := obs[i:]
48 | hpot := handPot{Pot: ob.Bet * len(s)}
49 |
50 | for j, _ := range s {
51 | s[j].Bet -= ob.Bet
52 | hpot.OPos = append(hpot.OPos, s[j].Pos)
53 | }
54 | pots = append(pots, hpot)
55 | }
56 | }
57 | return
58 | }
59 |
--------------------------------------------------------------------------------
/server/eva/poker.h:
--------------------------------------------------------------------------------
1 | #define STRAIGHT_FLUSH 1
2 | #define FOUR_OF_A_KIND 2
3 | #define FULL_HOUSE 3
4 | #define FLUSH 4
5 | #define STRAIGHT 5
6 | #define THREE_OF_A_KIND 6
7 | #define TWO_PAIR 7
8 | #define ONE_PAIR 8
9 | #define HIGH_CARD 9
10 |
11 | #define RANK(x) ((x >> 8) & 0xF)
12 |
13 | static char *value_str[] = {
14 | "",
15 | "Straight Flush",
16 | "Four of a Kind",
17 | "Full House",
18 | "Flush",
19 | "Straight",
20 | "Three of a Kind",
21 | "Two Pair",
22 | "One Pair",
23 | "High Card"
24 | };
25 |
26 | #define CLUB 0x8000
27 | #define DIAMOND 0x4000
28 | #define HEART 0x2000
29 | #define SPADE 0x1000
30 |
31 | #define Deuce 0
32 | #define Trey 1
33 | #define Four 2
34 | #define Five 3
35 | #define Six 4
36 | #define Seven 5
37 | #define Eight 6
38 | #define Nine 7
39 | #define Ten 8
40 | #define Jack 9
41 | #define Queen 10
42 | #define King 11
43 | #define Ace 12
44 |
45 | int findit( int key );
46 | void init_deck( int *deck );
47 | int find_card( int rank, int suit, int *deck );
48 | void shuffle_deck( int *deck );
49 | void print_hand( int *hand, int n );
50 | int hand_rank( short val );
51 | short eval_5cards( int c1, int c2, int c3, int c4, int c5 );
52 | short eval_5hand( int *hand );
53 | short eval_7hand( int *hand );
54 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/Images.xcassets/LaunchImage.launchimage/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "orientation" : "portrait",
5 | "idiom" : "ipad",
6 | "minimum-system-version" : "7.0",
7 | "extent" : "full-screen",
8 | "scale" : "2x"
9 | },
10 | {
11 | "orientation" : "landscape",
12 | "idiom" : "ipad",
13 | "minimum-system-version" : "7.0",
14 | "extent" : "full-screen",
15 | "scale" : "1x"
16 | },
17 | {
18 | "orientation" : "landscape",
19 | "idiom" : "ipad",
20 | "minimum-system-version" : "7.0",
21 | "extent" : "full-screen",
22 | "scale" : "2x"
23 | },
24 | {
25 | "orientation" : "portrait",
26 | "idiom" : "iphone",
27 | "minimum-system-version" : "7.0",
28 | "scale" : "2x"
29 | },
30 | {
31 | "orientation" : "portrait",
32 | "idiom" : "iphone",
33 | "minimum-system-version" : "7.0",
34 | "subtype" : "retina4",
35 | "scale" : "2x"
36 | },
37 | {
38 | "orientation" : "portrait",
39 | "idiom" : "ipad",
40 | "minimum-system-version" : "7.0",
41 | "extent" : "full-screen",
42 | "scale" : "1x"
43 | }
44 | ],
45 | "info" : {
46 | "version" : 1,
47 | "author" : "xcode"
48 | }
49 | }
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "ipad",
35 | "size" : "29x29",
36 | "scale" : "1x"
37 | },
38 | {
39 | "idiom" : "ipad",
40 | "size" : "29x29",
41 | "scale" : "2x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "40x40",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "40x40",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "76x76",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "76x76",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | com.tcl.tct.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UIStatusBarHidden
34 |
35 | UISupportedInterfaceOrientations
36 |
37 | UIInterfaceOrientationPortrait
38 |
39 | UISupportedInterfaceOrientations~ipad
40 |
41 | UIInterfaceOrientationPortrait
42 | UIInterfaceOrientationPortraitUpsideDown
43 | UIInterfaceOrientationLandscapeLeft
44 | UIInterfaceOrientationLandscapeRight
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/iOS/Pocker/WebViewJavascriptBridge/WebViewJavascriptBridge.h:
--------------------------------------------------------------------------------
1 | //
2 | // WebViewJavascriptBridge.h
3 | // ExampleApp-iOS
4 | //
5 | // Created by Marcus Westin on 6/14/13.
6 | // Copyright (c) 2013 Marcus Westin. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #define kCustomProtocolScheme @"wvjbscheme"
12 | #define kQueueHasMessage @"__WVJB_QUEUE_MESSAGE__"
13 |
14 | #if defined __MAC_OS_X_VERSION_MAX_ALLOWED
15 | #import
16 | #define WVJB_PLATFORM_OSX
17 | #define WVJB_WEBVIEW_TYPE WebView
18 | #define WVJB_WEBVIEW_DELEGATE_TYPE NSObject
19 | #elif defined __IPHONE_OS_VERSION_MAX_ALLOWED
20 | #import
21 | #define WVJB_PLATFORM_IOS
22 | #define WVJB_WEBVIEW_TYPE UIWebView
23 | #define WVJB_WEBVIEW_DELEGATE_TYPE NSObject
24 | #endif
25 |
26 | typedef void (^WVJBResponseCallback)(id responseData);
27 | typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback);
28 |
29 | @interface WebViewJavascriptBridge : WVJB_WEBVIEW_DELEGATE_TYPE
30 |
31 | + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView handler:(WVJBHandler)handler;
32 | + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler;
33 | + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler resourceBundle:(NSBundle*)bundle;
34 | + (void)enableLogging;
35 |
36 | - (void)send:(id)message;
37 | - (void)send:(id)message responseCallback:(WVJBResponseCallback)responseCallback;
38 | - (void)registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler;
39 | - (void)callHandler:(NSString*)handlerName;
40 | - (void)callHandler:(NSString*)handlerName data:(id)data;
41 | - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback;
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/WebViewJavascriptBridge/WebViewJavascriptBridge.h:
--------------------------------------------------------------------------------
1 | //
2 | // WebViewJavascriptBridge.h
3 | // ExampleApp-iOS
4 | //
5 | // Created by Marcus Westin on 6/14/13.
6 | // Copyright (c) 2013 Marcus Westin. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | #define kCustomProtocolScheme @"wvjbscheme"
12 | #define kQueueHasMessage @"__WVJB_QUEUE_MESSAGE__"
13 |
14 | #if defined __MAC_OS_X_VERSION_MAX_ALLOWED
15 | #import
16 | #define WVJB_PLATFORM_OSX
17 | #define WVJB_WEBVIEW_TYPE WebView
18 | #define WVJB_WEBVIEW_DELEGATE_TYPE NSObject
19 | #elif defined __IPHONE_OS_VERSION_MAX_ALLOWED
20 | #import
21 | #define WVJB_PLATFORM_IOS
22 | #define WVJB_WEBVIEW_TYPE UIWebView
23 | #define WVJB_WEBVIEW_DELEGATE_TYPE NSObject
24 | #endif
25 |
26 | typedef void (^WVJBResponseCallback)(id responseData);
27 | typedef void (^WVJBHandler)(id data, WVJBResponseCallback responseCallback);
28 |
29 | @interface WebViewJavascriptBridge : WVJB_WEBVIEW_DELEGATE_TYPE
30 |
31 | + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView handler:(WVJBHandler)handler;
32 | + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler;
33 | + (instancetype)bridgeForWebView:(WVJB_WEBVIEW_TYPE*)webView webViewDelegate:(WVJB_WEBVIEW_DELEGATE_TYPE*)webViewDelegate handler:(WVJBHandler)handler resourceBundle:(NSBundle*)bundle;
34 | + (void)enableLogging;
35 |
36 | - (void)send:(id)message;
37 | - (void)send:(id)message responseCallback:(WVJBResponseCallback)responseCallback;
38 | - (void)registerHandler:(NSString*)handlerName handler:(WVJBHandler)handler;
39 | - (void)callHandler:(NSString*)handlerName;
40 | - (void)callHandler:(NSString*)handlerName data:(id)data;
41 | - (void)callHandler:(NSString*)handlerName data:(id)data responseCallback:(WVJBResponseCallback)responseCallback;
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/server/poker.go:
--------------------------------------------------------------------------------
1 | package poker
2 |
3 | import (
4 | "fmt"
5 | "github.com/facebookgo/grace/gracehttp"
6 | "log"
7 | "net/http"
8 | "os"
9 | "strconv"
10 | "time"
11 | )
12 |
13 | type Poker struct {
14 | WebRoot string
15 | Addr string
16 | OnAuth func(conn *Conn, mechanism, text string) (*Occupant, error)
17 | OnExit func(o *Occupant)
18 | }
19 |
20 | func (p *Poker) ListenAndServe() error {
21 | http.HandleFunc("/ws", p.pokerHandler)
22 | http.Handle("/", http.FileServer(http.Dir(p.WebRoot)))
23 | //return http.ListenAndServe(p.Addr, nil)
24 | return gracehttp.Serve(&http.Server{Addr: p.Addr})
25 | }
26 |
27 | func (p *Poker) pokerHandler(w http.ResponseWriter, r *http.Request) {
28 | ws, err := upgrader.Upgrade(w, r, nil)
29 | if err != nil {
30 | fmt.Fprintln(os.Stderr, err)
31 | return
32 | }
33 | defer ws.Close()
34 |
35 | ws.SetReadLimit(maxMessageSize)
36 | ws.SetPongHandler(
37 | func(string) error {
38 | ws.SetReadDeadline(time.Now().Add(pongWait))
39 | return nil
40 | })
41 | conn := NewConn(ws, 128)
42 | defer conn.Close()
43 |
44 | ver := &Version{}
45 | if err := conn.ReadJSONTimeout(ver, readWait); err != nil {
46 | return
47 | }
48 | if err := conn.WriteJSON(ver); err != nil {
49 | return
50 | }
51 |
52 | auth := &Auth{}
53 | if err := conn.ReadJSONTimeout(auth, readWait); err != nil {
54 | return
55 | }
56 |
57 | var o *Occupant
58 | if p.OnAuth != nil {
59 | o, err = p.OnAuth(conn, auth.Mechanism, auth.Text)
60 | if err != nil {
61 | log.Println(err)
62 | //conn.WriteJSON(err)
63 | //return
64 | o = NewOccupant(strconv.FormatInt(time.Now().Unix(), 10), conn)
65 | o.Name = auth.Text
66 | }
67 | o.Chips = 10000
68 | }
69 |
70 | if err := conn.WriteJSON(o); err != nil {
71 | return
72 | }
73 |
74 | for {
75 | message, _ := o.GetMessage(0)
76 | if message == nil {
77 | break
78 | }
79 |
80 | switch message.Type {
81 | case MsgIQ:
82 | go handleIQ(o, message)
83 | case MsgPresence:
84 | go handlePresence(o, message)
85 | case MsgMessage:
86 | }
87 | }
88 |
89 | o.Leave()
90 |
91 | if p.OnExit != nil {
92 | p.OnExit(o)
93 | }
94 | log.Println(o.Name, "disconnected.")
95 | }
96 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // Pocker
4 | //
5 | // Created by zhengying on 3/9/15.
6 | // Copyright (c) 2015 zhengying. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 |
11 | @interface AppDelegate ()
12 |
13 | @end
14 |
15 | @implementation AppDelegate
16 |
17 |
18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19 | // Override point for customization after application launch.
20 | return YES;
21 | }
22 |
23 | - (void)applicationWillResignActive:(UIApplication *)application {
24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26 | }
27 |
28 | - (void)applicationDidEnterBackground:(UIApplication *)application {
29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31 | }
32 |
33 | - (void)applicationWillEnterForeground:(UIApplication *)application {
34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35 | }
36 |
37 | - (void)applicationDidBecomeActive:(UIApplication *)application {
38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39 | }
40 |
41 | - (void)applicationWillTerminate:(UIApplication *)application {
42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43 | }
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/SettingViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // SettingViewController.m
3 | // Pocker
4 | //
5 | // Created by zhengying on 3/9/15.
6 | // Copyright (c) 2015 zhengying. All rights reserved.
7 | //
8 |
9 | #import "SettingViewController.h"
10 |
11 | @interface SettingViewController ()
12 |
13 | @end
14 |
15 | @implementation SettingViewController
16 |
17 | - (void)viewDidLoad {
18 | [super viewDidLoad];
19 | // Do any additional setup after loading the view.
20 | }
21 |
22 | - (void)didReceiveMemoryWarning {
23 | [super didReceiveMemoryWarning];
24 | // Dispose of any resources that can be recreated.
25 | }
26 |
27 |
28 | -(IBAction)actionClosed {
29 | [self dismissViewControllerAnimated:YES completion:nil];
30 | }
31 |
32 | -(IBAction)actionSave:(id)sender {
33 | BOOL linodeEnable = [[NSUserDefaults standardUserDefaults]boolForKey:@"linode_enable"];
34 | NSString* username = [[NSUserDefaults standardUserDefaults]stringForKey:@"user_name"];
35 |
36 | BOOL uiLinodeSwitch = _linodeSwitch.isOn;
37 | NSString* uiUserName = _txtFieldUserName.text;
38 |
39 | if (uiLinodeSwitch == linodeEnable && [uiUserName isEqualToString:username] ){
40 | [self actionClosed];
41 | return;
42 | }
43 |
44 | [[NSUserDefaults standardUserDefaults]setBool:uiLinodeSwitch forKey:@"linode_enable"];
45 | [[NSUserDefaults standardUserDefaults]setObject:_txtFieldUserName.text forKey:@"user_name"];
46 |
47 | [[NSNotificationCenter defaultCenter]postNotificationName:@"SettingUpdate" object:nil];
48 | [self actionClosed];
49 | }
50 |
51 | -(void)viewWillAppear:(BOOL)animated {
52 | BOOL linodeEnable = [[NSUserDefaults standardUserDefaults]boolForKey:@"linode_enable"];
53 | NSString* username = [[NSUserDefaults standardUserDefaults]stringForKey:@"user_name"];
54 | [_linodeSwitch setOn:linodeEnable];
55 | _txtFieldUserName.text = username?username:@"TestUser";
56 | [super viewWillAppear:animated];
57 | }
58 |
59 | /*
60 |
61 | -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
62 | {
63 | return UIInterfaceOrientationLandscapeLeft;
64 | //return UIInterfaceOrientationPortrait;
65 | }
66 |
67 | - (NSUInteger)supportedInterfaceOrientations
68 | {
69 | return UIInterfaceOrientationMaskLandscape;
70 | //return UIInterfaceOrientationMaskPortrait;
71 | }
72 | */
73 |
74 |
75 | /*
76 | #pragma mark - Navigation
77 |
78 | // In a storyboard-based application, you will often want to do a little preparation before navigation
79 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
80 | // Get the new view controller using [segue destinationViewController].
81 | // Pass the selected object to the new view controller.
82 | }
83 | */
84 |
85 | @end
86 |
--------------------------------------------------------------------------------
/server/conn.go:
--------------------------------------------------------------------------------
1 | package poker
2 |
3 | import (
4 | "encoding/json"
5 | "errors"
6 | "fmt"
7 | "github.com/gorilla/websocket"
8 | "io/ioutil"
9 | "log"
10 | "time"
11 | )
12 |
13 | const (
14 | // Time allowed to write a message to the peer.
15 | writeWait = 10 * time.Second
16 |
17 | readWait = 60 * time.Second
18 |
19 | // Time allowed to read the next pong message from the peer.
20 | pongWait = 60 * time.Second
21 |
22 | // Send pings to peer with this period. Must be less than pongWait.
23 | pingPeriod = (pongWait * 9) / 10
24 |
25 | // Maximum message size allowed from peer.
26 | maxMessageSize = 1024
27 | )
28 |
29 | type Conn struct {
30 | ws *websocket.Conn
31 | send chan []byte
32 | }
33 |
34 | func NewConn(ws *websocket.Conn, sendBuffer int) *Conn {
35 | conn := &Conn{
36 | ws: ws,
37 | send: make(chan []byte, sendBuffer),
38 | }
39 | go conn.writePump()
40 |
41 | return conn
42 | }
43 |
44 | // write writes a message with the given message type and payload.
45 | func (c *Conn) write(mt int, payload []byte) error {
46 | return c.ws.WriteMessage(mt, payload)
47 | }
48 |
49 | func (c *Conn) ReadJSON(v interface{}) error {
50 | return c.ReadJSONTimeout(v, 0)
51 | }
52 |
53 | func (c *Conn) ReadJSONTimeout(v interface{}, timeout time.Duration) error {
54 | if timeout > 0 {
55 | c.ws.SetReadDeadline(time.Now().Add(timeout))
56 | } else {
57 | c.ws.SetReadDeadline(time.Time{})
58 | }
59 |
60 | return c.readJson(v)
61 | }
62 |
63 | func (c *Conn) readJson(v interface{}) error {
64 | _, r, err := c.ws.NextReader()
65 | if err != nil {
66 | return err
67 | }
68 | b, err := ioutil.ReadAll(r)
69 | if err != nil {
70 | return err
71 | }
72 | fmt.Println(">>>", time.Now().Format("15:04:05"), string(b))
73 |
74 | return json.Unmarshal(b, v)
75 | }
76 |
77 | func (c *Conn) WriteJSON(v interface{}) error {
78 | b, err := json.Marshal(v)
79 | if err != nil {
80 | return err
81 | }
82 |
83 | select {
84 | case c.send <- b:
85 | return nil
86 | default:
87 | fmt.Println("buffer full")
88 | return errors.New("buffer full")
89 | }
90 | }
91 |
92 | func (c *Conn) Close() {
93 | close(c.send)
94 | c.send = nil
95 | }
96 |
97 | // writePump pumps messages from the hub to the websocket connection.
98 | func (c *Conn) writePump() {
99 | ticker := time.NewTicker(pingPeriod)
100 | defer func() {
101 | ticker.Stop()
102 | c.ws.Close()
103 | }()
104 |
105 | for {
106 | select {
107 | case message, ok := <-c.send:
108 | if !ok {
109 | c.write(websocket.CloseMessage, []byte{})
110 | return
111 | }
112 | c.ws.SetWriteDeadline(time.Now().Add(writeWait))
113 | if err := c.write(websocket.TextMessage, message); err != nil {
114 | log.Println(err)
115 | return
116 | }
117 |
118 | fmt.Println("<<<", time.Now().Format("15:04:05"), string(message))
119 | case <-ticker.C:
120 | c.ws.SetWriteDeadline(time.Now().Add(writeWait))
121 | if err := c.write(websocket.PingMessage, []byte{}); err != nil {
122 | return
123 | }
124 | }
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/Poker/betapi.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var BetApi = function() {
4 |
5 | this.betServer;
6 | this.userName = "";
7 | this.userID = "";
8 | this.roomID = "";
9 | }
10 |
11 | BetApi.prototype = {
12 |
13 | connect:function() {
14 |
15 | this.betServer = new Server();
16 | this.betServer.connect();
17 | },
18 |
19 | registerCallback:function(openCallback, closeCallback, messageCallback, errorCallback) {
20 |
21 | this.betServer.registerCallback(openCallback, closeCallback, messageCallback, errorCallback);
22 | },
23 |
24 | setUserID:function(strUserID) {
25 | this.userID = strUserID;
26 | },
27 |
28 | setRoomID:function(strRoomID) {
29 | this.roomID = strRoomID;
30 | },
31 |
32 | checkVersion:function(strVersion, callback) {
33 |
34 | var data = {version:strVersion}
35 | this.betServer.sendCommand(data, callback);
36 | },
37 |
38 | loginCertification:function(strName, callback) {
39 |
40 | var data = {mechanism:"plain", text:strName}
41 | this.betServer.sendCommand(data, callback);
42 | },
43 |
44 |
45 | createRoom:function(strRoomID, nSB, nBB, nTimeout, nMaxPlayer, callback) {
46 |
47 | var data = {type:"iq", id:"createRoom", from:this.userID, to:strRoomID, action:"set", class: "room", room: {sb:nSB, bb:nBB, timeout:nTimeout, max:nMaxPlayer}};
48 | this.betServer.sendCommand(data, callback);
49 | },
50 |
51 | getRoomList:function(callback) {
52 |
53 | var data = {type:"iq", id:"getRoomList", from:this.userID, to:"", action:"get", class: "roomlist"};
54 | this.betServer.sendCommand(data, callback);
55 | },
56 |
57 | getRoomInfo:function(callback) {
58 |
59 | var data = {type:"iq", id:"getRoomInfo", from:this.userID, to:this.roomID, action:"get", class: "room"};
60 | this.betServer.sendCommand(data, callback);
61 | },
62 |
63 | getUserInfo:function(playerID, callback) {
64 |
65 | var data = {type:"iq", id:"getUserInfo", from:this.userID, to:playerID, action:"get", class: "occupant"};
66 | this.betServer.sendCommand(data, callback);
67 | },
68 |
69 | enterRoom:function(callback, roomID) {
70 |
71 | if(roomID != undefined ) {
72 | this.roomID = roomID
73 | }
74 |
75 | var data = {type:"presence", id:"enterRoom", from:this.userID, to:this.roomID, action:"join"};
76 | this.betServer.sendCommand(data, callback);
77 | },
78 |
79 | leaveRoom:function(callback) {
80 |
81 | var data = {type:"presence", id:"leaveRoom", from:this.userID, to:this.roomID, action:"gone"};
82 | this.betServer.sendCommand(data, callback);
83 | },
84 |
85 | betFold:function(callback) {
86 | this.bet("-1", callback);
87 | },
88 |
89 | betCheck:function(callback) {
90 | this.bet("0", callback);
91 | },
92 |
93 | bet:function(number, callback) {
94 |
95 | var data = {type:"presence", id:"bet", from:this.userID, to:this.roomID, action:"bet", class:number+""};
96 | this.betServer.sendCommand(data, callback);
97 | },
98 |
99 | getRoomWholeStatus:function(callback) {
100 |
101 | var data = {type:"iq", id:"getRoomWholeStatus", from:this.userID, to:this.roomID, action:"get", class:"state"};
102 | this.betServer.sendCommand(data, callback);
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/Poker/server.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Server = function() {
4 |
5 | this.wsServer = 'ws://' + gParam.ws_server; //172.24.222.54:8989';
6 | this.websocket;
7 | this.isConnect;
8 | this.openCallback;
9 | this.closeCallback;
10 | this.messageCallback;
11 | this.errorCallback;
12 | }
13 |
14 | Server.prototype = {
15 |
16 | connect:function() {
17 |
18 | console.log("ready to connect ...");
19 | if(this.websocket && (this.websocket.readyState == 0 || this.websocket.readyState == 1))
20 | {
21 | this.websocket.close();
22 | }
23 |
24 | this.isConnect = false;
25 |
26 | try {
27 | this.websocket = new WebSocket(this.wsServer);
28 | }
29 | catch (ex) {
30 | console.log(ex, "ERROR");
31 | return;
32 | }
33 |
34 | var that = this;
35 | this.websocket.onopen = function (evt) { that.onOpen(evt); };
36 | this.websocket.onclose = function (evt) { that.onClose(evt); };
37 | this.websocket.onmessage = function (evt) { that.onMessage(evt); };
38 | this.websocket.onerror = function (evt) { that.onError(evt); };
39 | },
40 |
41 | registerCallback:function(openCallback, closeCallback, messageCallback, errorCallback) {
42 |
43 | this.openCallback = openCallback;
44 | this.closeCallback = closeCallback;
45 | this.messageCallback = messageCallback;
46 | this.errorCallback = errorCallback;
47 | },
48 |
49 | onOpen:function(evt) {
50 | console.log("Connected to WebSocket server.");
51 | this.isConnect = true;
52 | var data = {}
53 | if (evt.data)
54 | {
55 | try
56 | {
57 | data = JSON.parse(evt.data)
58 | }
59 | catch(e)
60 | {
61 | console.log(e);
62 | }
63 | }
64 | if(this.openCallback)
65 | {
66 | this.openCallback(data)
67 | }
68 | },
69 | onClose:function(evt) {
70 | console.log("Disconnected");
71 | var data = {}
72 | if (evt.data)
73 | {
74 | try
75 | {
76 | data = JSON.parse(evt.data)
77 | }
78 | catch(e)
79 | {
80 | console.log(e);
81 | }
82 | }
83 | if(this.closeCallback)
84 | {
85 | this.closeCallback(data)
86 | }
87 | },
88 | onMessage:function(evt) {
89 | console.log('Retrieved data from server: ' + evt.data);
90 | var data = {}
91 | if (evt.data)
92 | {
93 | try
94 | {
95 | data = JSON.parse(evt.data)
96 | }
97 | catch(e)
98 | {
99 | console.log(e);
100 | }
101 | }
102 | if(this.messageCallback)
103 | {
104 | this.messageCallback(data)
105 | }
106 | },
107 | onError:function(evt) {
108 | console.log('Error occured: ' + evt.data);
109 | var data = {}
110 | if (evt.data)
111 | {
112 | try
113 | {
114 | data = JSON.parse(evt.data)
115 | }
116 | catch(e)
117 | {
118 | console.log(e);
119 | }
120 | }
121 | if(this.errorCallback)
122 | {
123 | this.errorCallback(data)
124 | }
125 | },
126 |
127 | quit:function() {
128 | console.log("ready to disconnect");
129 | this.websocket.close(1000, "");
130 | },
131 |
132 | sendCommand:function(jsonData, callback) {
133 |
134 | var jsonStr = ""
135 | var isOK = true;
136 | if (jsonData) {
137 | try{
138 | jsonStr = JSON.stringify(jsonData)
139 | }catch(e){
140 | console.log(e);
141 | isOK = false;
142 | }
143 | };
144 | console.log("send data:", jsonStr);
145 | try{
146 | this.websocket.send(jsonStr);
147 | }catch(e){
148 | console.log(e);
149 | isOK = false;
150 | }
151 |
152 | if(callback)
153 | {
154 | callback(isOK);
155 | }
156 | }
157 | }
158 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker.xcodeproj/xcuserdata/zhengying.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
8 |
18 |
19 |
20 |
22 |
32 |
33 |
34 |
36 |
48 |
49 |
50 |
52 |
64 |
65 |
66 |
68 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/server/eva/allfive.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "poker.h"
5 |
6 | int extract_rank(char c) {
7 | int rank;
8 | if (c == 't' || c == 'T')
9 | rank = 10;
10 | else if (c == 'j' || c == 'J')
11 | rank = 11;
12 | else if (c == 'q' || c == 'Q')
13 | rank = 12;
14 | else if (c == 'k' || c == 'K')
15 | rank = 13;
16 | else if (c == 'a' || c == 'A')
17 | rank = 14;
18 | else if (c >= '2' && c <= '9')
19 | rank = c - '0';
20 | else
21 | rank = 101;
22 |
23 | rank -= 2;
24 | return rank;
25 | }
26 |
27 | int extract_suit(char c) {
28 | int suit;
29 | if (c == 'c' || c == 'C')
30 | suit = CLUB;
31 | else if (c == 'd' || c == 'D')
32 | suit = DIAMOND;
33 | else if (c == 'h' || c == 'H')
34 | suit = HEART;
35 | else if (c == 's' || c == 'S')
36 | suit = SPADE;
37 | else
38 | suit = 99;
39 | return suit;
40 | }
41 |
42 | int check_format(char *str) {
43 | if (strlen(str) == 2)
44 | return 1; // true
45 | return 0; // false
46 | }
47 |
48 | void print_rank(int rank) {
49 | char *str;
50 | switch(rank) {
51 | case STRAIGHT_FLUSH: str = "STRAIGHT_FLUSH"; break;
52 | case FOUR_OF_A_KIND: str = "FOUR_OF_A_KIND"; break;
53 | case FULL_HOUSE: str = "FULL_HOUSE"; break;
54 | case FLUSH: str = "FLUSH"; break;
55 | case STRAIGHT: str = "STRAIGHT"; break;
56 | case THREE_OF_A_KIND: str = "THREE_OF_A_KIND"; break;
57 | case TWO_PAIR: str = "TWO_PAIR"; break;
58 | case ONE_PAIR: str = "ONE_PAIR"; break;
59 | case HIGH_CARD: str = "HIGH_CARD"; break;
60 | default: str = "NOT_FOUND"; break;
61 | }
62 | printf("Rank: %s (%d)\n", str, rank);
63 | }
64 |
65 | int main(int argc, char *argv[]) {
66 | // printf("===== poker-eval =====\n");
67 |
68 | if (argc != 6) {
69 | printf("Usage: ./allfive card1 card2 card3 card4 card5\n");
70 | return -1;
71 | }
72 |
73 | if (!check_format(argv[1]) || !check_format(argv[2]) || !check_format(argv[3]) || !check_format(argv[4]) || !check_format(argv[5])) {
74 | printf("Invalid card format\n");
75 | return -1;
76 | }
77 |
78 | int deck[52];
79 | init_deck(deck);
80 |
81 | int r1 = extract_rank(argv[1][0]);
82 | int s1 = extract_suit(argv[1][1]);
83 | int r2 = extract_rank(argv[2][0]);
84 | int s2 = extract_suit(argv[2][1]);
85 | int r3 = extract_rank(argv[3][0]);
86 | int s3 = extract_suit(argv[3][1]);
87 | int r4 = extract_rank(argv[4][0]);
88 | int s4 = extract_suit(argv[4][1]);
89 | int r5 = extract_rank(argv[5][0]);
90 | int s5 = extract_suit(argv[5][1]);
91 |
92 | int c1_index = find_card(r1, s1, deck);
93 | int c2_index = find_card(r2, s2, deck);
94 | int c3_index = find_card(r3, s3, deck);
95 | int c4_index = find_card(r4, s4, deck);
96 | int c5_index = find_card(r5, s5, deck);
97 |
98 | if (c1_index == -1 || r1 == 99 || s1 == 99)
99 | printf("!!!!! c1_index is invalid !!!!!\n");
100 | if (c2_index == -1 || r2 == 99 || s2 == 99)
101 | printf("!!!!! c2_index is invalid !!!!!\n");
102 | if (c3_index == -1 || r3 == 99 || s3 == 99)
103 | printf("!!!!! c3_index is invalid !!!!!\n");
104 | if (c4_index == -1 || r4 == 99 || s4 == 99)
105 | printf("!!!!! c4_index is invalid !!!!!\n");
106 | if (c5_index == -1 || r5 == 99 || s5 == 99)
107 | printf("!!!!! c5_index is invalid !!!!!\n");
108 |
109 | int c1 = deck[c1_index];
110 | int c2 = deck[c2_index];
111 | int c3 = deck[c3_index];
112 | int c4 = deck[c4_index];
113 | int c5 = deck[c5_index];
114 |
115 | printf("Hand: %d-%d %d-%d %d-%d %d-%d %d-%d\n", r1, s1, r2, s2, r3, s3, r4, s4, r5, s5);
116 |
117 | printf( "eval_5cards: %d\n", eval_5cards(c1, c2, c3, c4, c5));
118 | int rank = hand_rank(eval_5cards(c1, c2, c3, c4, c5));
119 |
120 | print_rank(rank);
121 |
122 | return rank;
123 | }
--------------------------------------------------------------------------------
/iOS/Pocker/WebViewJavascriptBridge/WebViewJavascriptBridge.js.txt:
--------------------------------------------------------------------------------
1 | ;(function() {
2 | if (window.WebViewJavascriptBridge) { return }
3 | var messagingIframe
4 | var sendMessageQueue = []
5 | var receiveMessageQueue = []
6 | var messageHandlers = {}
7 |
8 | var CUSTOM_PROTOCOL_SCHEME = 'wvjbscheme'
9 | var QUEUE_HAS_MESSAGE = '__WVJB_QUEUE_MESSAGE__'
10 |
11 | var responseCallbacks = {}
12 | var uniqueId = 1
13 |
14 | function _createQueueReadyIframe(doc) {
15 | messagingIframe = doc.createElement('iframe')
16 | messagingIframe.style.display = 'none'
17 | messagingIframe.src = CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE
18 | doc.documentElement.appendChild(messagingIframe)
19 | }
20 |
21 | function init(messageHandler) {
22 | if (WebViewJavascriptBridge._messageHandler) { throw new Error('WebViewJavascriptBridge.init called twice') }
23 | WebViewJavascriptBridge._messageHandler = messageHandler
24 | var receivedMessages = receiveMessageQueue
25 | receiveMessageQueue = null
26 | for (var i=0; i
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
21 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/server/ws.go:
--------------------------------------------------------------------------------
1 | package poker
2 |
3 | import (
4 | "fmt"
5 | "github.com/gorilla/websocket"
6 | "net/http"
7 | )
8 |
9 | const (
10 | MsgIQ = "iq"
11 | MsgPresence = "presence"
12 | MsgMessage = "message"
13 |
14 | ActGet = "get"
15 | ActSet = "set"
16 | ActResult = "result"
17 |
18 | ActPreflop = "preflop"
19 | ActFlop = "flop"
20 | ActTurn = "turn"
21 | ActRiver = "river"
22 | ActShowdown = "showdown"
23 | ActPot = "pot"
24 |
25 | ActActive = "active"
26 | ActJoin = "join"
27 | ActLeave = "gone"
28 | ActBet = "bet"
29 | ActButton = "button"
30 | ActState = "state"
31 |
32 | ActAction = "action"
33 | ActReady = "ready"
34 | ActCall = "call"
35 | ActCheck = "check"
36 | ActRaise = "raise"
37 | ActFold = "fold"
38 | ActAllin = "allin"
39 | )
40 |
41 | var (
42 | upgrader = websocket.Upgrader{
43 | ReadBufferSize: 1024,
44 | WriteBufferSize: 1024,
45 | CheckOrigin: func(r *http.Request) bool { return true },
46 | }
47 | )
48 |
49 | type Message struct {
50 | Id string `json:"id,omitempty"`
51 | Type string `json:"type"`
52 | From string `json:"from,omitempty"`
53 | To string `json:"to,omitempty"`
54 | Action string `json:"action"`
55 | Class string `json:"class,omitempty"`
56 | Occupant *Occupant `json:"occupant,omitempty"`
57 | Room *Room `json:"room,omitempty"`
58 | Rooms []*Room `json:"rooms,omitempty"`
59 | }
60 |
61 | type Version struct {
62 | //Id string `json:"id"`
63 | Ver string `json:"version"`
64 | }
65 |
66 | type Auth struct {
67 | Mechanism string `json:"mechanism"`
68 | Text string `json:"text"`
69 | }
70 |
71 | type AuthResp struct {
72 | Id string `json:"id"`
73 | Name string `json:"name"`
74 | Level int `json:"level"`
75 | Chips int `json:"chips"`
76 | }
77 |
78 | type Error struct {
79 | Code int `json:"code,omitempty"`
80 | Err string `json:"error,omitempty"`
81 | }
82 |
83 | func NewError(code int, err string) *Error {
84 | return &Error{
85 | Code: code,
86 | Err: err,
87 | }
88 | }
89 |
90 | func (e *Error) Error() string {
91 | return fmt.Sprintf("%d: %s", e.Code, e.Err)
92 | }
93 |
94 | func handlePresence(o *Occupant, message *Message) {
95 | switch message.Action {
96 | case ActJoin:
97 | if room := o.Join(message.To); room == nil {
98 | o.SendError(1, "room not found")
99 | return
100 | }
101 | case ActLeave:
102 | o.Leave()
103 | case ActBet:
104 | select {
105 | case o.Actions <- message:
106 | default:
107 | }
108 | }
109 | }
110 |
111 | func handleIQ(o *Occupant, message *Message) {
112 | switch message.Action {
113 | case ActSet:
114 | switch message.Class {
115 | case "room":
116 | room := NewRoom("", 9, 5, 10)
117 |
118 | if message.Room != nil {
119 | if message.Room.SB > 0 {
120 | room.SB = message.Room.SB
121 | }
122 | if message.Room.BB > 0 {
123 | room.BB = message.Room.BB
124 | }
125 | if message.Room.Timeout > 0 {
126 | room.Timeout = message.Room.Timeout
127 | }
128 |
129 | if message.Room.Max > 0 && message.Room.Max <= MaxN {
130 | room.Max = message.Room.Max
131 | room.Occupants = room.Occupants[:room.Max]
132 | room.Chips = room.Chips[:room.Max]
133 | }
134 |
135 | SetRoom(room)
136 | }
137 | o.SendMessage(&Message{
138 | Type: message.Type,
139 | Id: message.Id,
140 | From: room.Id,
141 | Action: ActResult,
142 | Class: message.Class,
143 | Room: room,
144 | })
145 | }
146 |
147 | case ActGet:
148 | switch message.Class {
149 | case "room":
150 | o.SendMessage(&Message{
151 | Type: message.Type,
152 | Id: message.Id,
153 | From: message.To,
154 | Action: ActResult,
155 | Class: message.Class,
156 | Room: GetRoom(message.To),
157 | })
158 | case "roomlist":
159 | rooms := []*Room{}
160 | for _, room := range Rooms() {
161 | rooms = append(rooms, &Room{
162 | Id: room.Id,
163 | SB: room.SB,
164 | BB: room.BB,
165 | N: room.N,
166 | Max: room.Max,
167 | })
168 | }
169 | o.SendMessage(&Message{
170 | Type: message.Type,
171 | Id: message.Id,
172 | Action: ActResult,
173 | Class: message.Class,
174 | Rooms: rooms,
175 | })
176 | }
177 | }
178 | }
179 |
--------------------------------------------------------------------------------
/server/occupant.go:
--------------------------------------------------------------------------------
1 | package poker
2 |
3 | import (
4 | "errors"
5 | "log"
6 | //"strconv"
7 | "time"
8 | )
9 |
10 | type Occupant struct {
11 | Id string `json:"id"`
12 | Name string `json:"name"`
13 | Profile string `json:"profile"`
14 | Level int `json:"level"`
15 | Chips int `json:"chips"`
16 |
17 | Pos int `json:"index,omitempty"`
18 | Bet int `json:"bet,omitempty"`
19 | Action string `json:"action,omitempty"`
20 | Cards []Card `json:"cards,omitempty"`
21 | Hand int `json:"hand,omitempty"`
22 |
23 | conn *Conn
24 | Room *Room `json:"-"`
25 |
26 | recv chan *Message
27 | Actions chan *Message `json:"-"`
28 | timer *time.Timer // action timer
29 | }
30 |
31 | func NewOccupant(id string, conn *Conn) *Occupant {
32 | o := &Occupant{
33 | Id: id,
34 | conn: conn,
35 | recv: make(chan *Message, 128),
36 | Actions: make(chan *Message),
37 | //Profile: "http://172.24.222.42:8082/4,0aaaffedfc7b",
38 | }
39 |
40 | go func() {
41 | for {
42 | m := &Message{}
43 | if err := o.conn.ReadJSON(m); err != nil {
44 | close(o.recv)
45 | o.recv = nil
46 | return
47 | }
48 | select {
49 | case o.recv <- m:
50 | default:
51 | log.Println("dropped")
52 | }
53 | }
54 | }()
55 |
56 | return o
57 | }
58 |
59 | func (o *Occupant) Broadcast(message *Message) {
60 | if o.Room == nil {
61 | return
62 | }
63 |
64 | for _, oc := range o.Room.Occupants {
65 | if oc != nil && oc != o {
66 | oc.SendMessage(message)
67 | }
68 | }
69 | }
70 |
71 | func (o *Occupant) SendMessage(message *Message) error {
72 | return o.conn.WriteJSON(message)
73 | }
74 |
75 | func (o *Occupant) SendError(code int, err string) error {
76 | return o.conn.WriteJSON(NewError(code, err))
77 | }
78 |
79 | func (o *Occupant) GetMessage(timeout time.Duration) (*Message, error) {
80 | if o.recv == nil {
81 | return nil, errors.New("channel closed")
82 | }
83 | if timeout <= 0 {
84 | m := <-o.recv
85 | return m, nil
86 | }
87 |
88 | timer := time.NewTimer(timeout)
89 | select {
90 | case m := <-o.recv:
91 | return m, nil
92 | case <-timer.C:
93 | return nil, errors.New("timeout")
94 | }
95 | }
96 |
97 | func (o *Occupant) Betting(n int) (raised bool) {
98 | room := o.Room
99 | if room == nil {
100 | return
101 | }
102 |
103 | if n < 0 {
104 | o.Action = ActFold
105 | o.Cards = nil
106 | o.Hand = 0
107 | n = 0
108 | } else if n == 0 {
109 | o.Action = ActCheck
110 | } else if n+o.Bet <= room.Bet {
111 | o.Action = ActCall
112 | o.Chips -= n
113 | o.Bet += n
114 | } else {
115 | o.Action = ActRaise
116 | o.Chips -= n
117 | o.Bet += n
118 | room.Bet = o.Bet
119 | raised = true
120 | }
121 | if o.Chips == 0 {
122 | o.Action = ActAllin
123 | }
124 | room.Chips[o.Pos-1] += n
125 |
126 | return
127 | }
128 |
129 | func (o *Occupant) GetAction(timeout time.Duration) (*Message, error) {
130 | o.timer = time.NewTimer(timeout)
131 |
132 | select {
133 | case m := <-o.Actions:
134 | return m, nil
135 | case <-o.Room.EndChan:
136 | return nil, nil
137 | case <-o.timer.C:
138 | return nil, errors.New("timeout")
139 | }
140 | }
141 |
142 | func (o *Occupant) Join(rid string) (room *Room) {
143 | room = GetRoom(rid)
144 | if room == nil {
145 | return
146 | }
147 |
148 | o.Bet = 0
149 | o.Cards = nil
150 | o.Hand = 0
151 | o.Action = ""
152 | o.Pos = 0
153 | o.Room = nil
154 |
155 | room.AddOccupant(o)
156 |
157 | o.Broadcast(&Message{
158 | From: room.Id,
159 | Type: MsgPresence,
160 | Action: ActJoin,
161 | Occupant: o,
162 | })
163 | o.SendMessage(&Message{
164 | From: room.Id,
165 | Type: MsgPresence,
166 | Action: ActState,
167 | Room: room,
168 | })
169 |
170 | return
171 | }
172 |
173 | func (o *Occupant) Leave() (room *Room) {
174 | room = o.Room
175 | if room == nil {
176 | return
177 | }
178 |
179 | room.Broadcast(&Message{
180 | From: room.Id,
181 | Type: MsgPresence,
182 | Action: ActLeave,
183 | Occupant: o,
184 | })
185 | room.DelOccupant(o)
186 |
187 | o.Bet = 0
188 | o.Cards = nil
189 | o.Hand = 0
190 | o.Action = ""
191 | o.Pos = 0
192 | o.Room = nil
193 | if o.timer != nil {
194 | o.timer.Reset(0)
195 | }
196 |
197 | return
198 | }
199 |
200 | func (o *Occupant) Next() *Occupant {
201 | room := o.Room
202 | if room == nil {
203 | return nil
204 | }
205 |
206 | for i := (o.Pos) % room.Cap(); i != o.Pos-1; i = (i + 1) % room.Cap() {
207 | if room.Occupants[i] != nil {
208 | return room.Occupants[i]
209 | }
210 | }
211 |
212 | return nil
213 | }
214 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker.xcodeproj/xcuserdata/zhengying.xcuserdatad/xcschemes/Pocker.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
29 |
35 |
36 |
37 |
38 |
39 |
44 |
45 |
47 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
65 |
66 |
75 |
76 |
82 |
83 |
84 |
85 |
86 |
87 |
93 |
94 |
100 |
101 |
102 |
103 |
105 |
106 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/server/eva/pokerlib.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "arrays.h"
3 | #include "poker.h"
4 |
5 | // Poker hand evaluator
6 | //
7 | // Kevin L. Suffecool
8 | // suffecool@bigfoot.com
9 | //
10 |
11 | void srand48();
12 | double drand48();
13 |
14 | // perform a binary search on a pre-sorted array
15 | //
16 | int findit( int key )
17 | {
18 | int low = 0, high = 4887, mid;
19 |
20 | while ( low <= high )
21 | {
22 | mid = (high+low) >> 1; // divide by two
23 | if ( key < products[mid] )
24 | high = mid - 1;
25 | else if ( key > products[mid] )
26 | low = mid + 1;
27 | else
28 | return( mid );
29 | }
30 | fprintf( stderr, "ERROR: no match found; key = %d\n", key );
31 | return( -1 );
32 | }
33 |
34 | //
35 | // This routine initializes the deck. A deck of cards is
36 | // simply an integer array of length 52 (no jokers). This
37 | // array is populated with each card, using the following
38 | // scheme:
39 | //
40 | // An integer is made up of four bytes. The high-order
41 | // bytes are used to hold the rank bit pattern, whereas
42 | // the low-order bytes hold the suit/rank/prime value
43 | // of the card.
44 | //
45 | // +--------+--------+--------+--------+
46 | // |xxxbbbbb|bbbbbbbb|cdhsrrrr|xxpppppp|
47 | // +--------+--------+--------+--------+
48 | //
49 | // p = prime number of rank (deuce=2,trey=3,four=5,five=7,...,ace=41)
50 | // r = rank of card (deuce=0,trey=1,four=2,five=3,...,ace=12)
51 | // cdhs = suit of card
52 | // b = bit turned on depending on rank of card
53 | //
54 | init_deck( int *deck )
55 | {
56 | int i, j, n = 0, suit = 0x8000;
57 |
58 | for ( i = 0; i < 4; i++, suit >>= 1 )
59 | for ( j = 0; j < 13; j++, n++ )
60 | deck[n] = primes[j] | (j << 8) | suit | (1 << (16+j));
61 | }
62 |
63 |
64 | // This routine will search a deck for a specific card
65 | // (specified by rank/suit), and return the INDEX giving
66 | // the position of the found card. If it is not found,
67 | // then it returns -1
68 | //
69 | int
70 | find_card( int rank, int suit, int *deck )
71 | {
72 | int i, c;
73 |
74 | for ( i = 0; i < 52; i++ )
75 | {
76 | c = deck[i];
77 | if ( (c & suit) && (RANK(c) == rank) )
78 | return( i );
79 | }
80 | return( -1 );
81 | }
82 |
83 |
84 | //
85 | // This routine takes a deck and randomly mixes up
86 | // the order of the cards.
87 | //
88 | shuffle_deck( int *deck )
89 | {
90 | int i, n, temp[52];
91 |
92 | for ( i = 0; i < 52; i++ )
93 | temp[i] = deck[i];
94 |
95 | for ( i = 0; i < 52; i++ )
96 | {
97 | do {
98 | n = (int)(51.9999999 * drand48());
99 | } while ( temp[n] == 0 );
100 | deck[i] = temp[n];
101 | temp[n] = 0;
102 | }
103 | }
104 |
105 |
106 | print_hand( int *hand, int n )
107 | {
108 | int i, r;
109 | char suit;
110 | static char *rank = "23456789TJQKA";
111 |
112 | for ( i = 0; i < n; i++ )
113 | {
114 | r = (*hand >> 8) & 0xF;
115 | if ( *hand & 0x8000 )
116 | suit = 'c';
117 | else if ( *hand & 0x4000 )
118 | suit = 'd';
119 | else if ( *hand & 0x2000 )
120 | suit = 'h';
121 | else
122 | suit = 's';
123 |
124 | printf( "%c%c ", rank[r], suit );
125 | hand++;
126 | }
127 | }
128 |
129 |
130 | int
131 | hand_rank( short val )
132 | {
133 | if (val > 6185) return(HIGH_CARD); // 1277 high card
134 | if (val > 3325) return(ONE_PAIR); // 2860 one pair
135 | if (val > 2467) return(TWO_PAIR); // 858 two pair
136 | if (val > 1609) return(THREE_OF_A_KIND); // 858 three-kind
137 | if (val > 1599) return(STRAIGHT); // 10 straights
138 | if (val > 322) return(FLUSH); // 1277 flushes
139 | if (val > 166) return(FULL_HOUSE); // 156 full house
140 | if (val > 10) return(FOUR_OF_A_KIND); // 156 four-kind
141 | return(STRAIGHT_FLUSH); // 10 straight-flushes
142 | }
143 |
144 |
145 | short
146 | eval_5cards( int c1, int c2, int c3, int c4, int c5 )
147 | {
148 | int q;
149 | short s;
150 |
151 | q = (c1|c2|c3|c4|c5) >> 16;
152 |
153 | /* check for Flushes and StraightFlushes
154 | */
155 | if ( c1 & c2 & c3 & c4 & c5 & 0xF000 )
156 | return( flushes[q] );
157 |
158 | /* check for Straights and HighCard hands
159 | */
160 | s = unique5[q];
161 | if ( s ) return ( s );
162 |
163 | /* let's do it the hard way
164 | */
165 | q = (c1&0xFF) * (c2&0xFF) * (c3&0xFF) * (c4&0xFF) * (c5&0xFF);
166 | q = findit( q );
167 |
168 |
169 | return( values[q] );
170 | }
171 |
172 |
173 | short
174 | eval_5hand( int *hand )
175 | {
176 | int c1, c2, c3, c4, c5;
177 |
178 | c1 = *hand++;
179 | c2 = *hand++;
180 | c3 = *hand++;
181 | c4 = *hand++;
182 | c5 = *hand;
183 |
184 | return( eval_5cards(c1,c2,c3,c4,c5) );
185 | }
186 |
187 |
188 | // This is a non-optimized method of determining the
189 | // best five-card hand possible out of seven cards.
190 | // I am working on a faster algorithm.
191 | //
192 | short
193 | eval_7hand( int *hand )
194 | {
195 | int i, j, q, best = 9999, subhand[5];
196 |
197 | for ( i = 0; i < 21; i++ )
198 | {
199 | for ( j = 0; j < 5; j++ )
200 | subhand[j] = hand[ perm7[i][j] ];
201 | q = eval_5hand( subhand );
202 | if ( q < best )
203 | best = q;
204 | }
205 | return( best );
206 | }
--------------------------------------------------------------------------------
/server/examples/client/client.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "bufio"
5 | "fmt"
6 | "log"
7 | "math/rand"
8 | "net"
9 | "net/url"
10 | "os"
11 | "strconv"
12 | "strings"
13 | "time"
14 |
15 | "github.com/ginuerzh/poker/server"
16 | "github.com/gorilla/websocket"
17 | )
18 |
19 | const (
20 | readWait = 10 * time.Second
21 | version = "1.0"
22 | )
23 |
24 | func randName() string {
25 | rand.Seed(time.Now().Unix())
26 | var b []byte
27 | for i := 0; i < 5; i++ {
28 | b = append(b, byte(rand.Intn(26)+97))
29 | }
30 | b[0] -= 32
31 | return string(b)
32 | }
33 |
34 | func main() {
35 | c, err := net.Dial("tcp", "localhost:8989")
36 | if err != nil {
37 | log.Fatal(err)
38 | }
39 | u, err := url.Parse("ws://localhost:8989/ws")
40 | if err != nil {
41 | log.Fatal(err)
42 | }
43 |
44 | ws, _, err := websocket.NewClient(c, u, nil, 1024, 1024)
45 | if err != nil {
46 | log.Fatal(err)
47 | }
48 | conn := poker.NewConn(ws, 10)
49 |
50 | ver := &poker.Version{
51 | Ver: version,
52 | }
53 |
54 | if err := conn.WriteJSON(ver); err != nil {
55 | log.Fatal(err)
56 | }
57 |
58 | if err := conn.ReadJSON(ver); err != nil {
59 | log.Fatal(err)
60 | }
61 |
62 | auth := poker.Auth{Mechanism: "plain", Text: randName()}
63 | if err := conn.WriteJSON(auth); err != nil {
64 | log.Fatal(err)
65 | }
66 |
67 | resp := &poker.AuthResp{}
68 | if err := conn.ReadJSON(resp); err != nil {
69 | log.Fatal(err)
70 | }
71 |
72 | o := poker.NewOccupant(resp.Id, conn)
73 | o.Name = resp.Name
74 | o.Chips = resp.Chips
75 |
76 | fmt.Printf("%s(%s) %d\n", o.Id, o.Name, o.Chips)
77 |
78 | go handleMessage(o)
79 |
80 | cmdLoop(o)
81 |
82 | }
83 |
84 | func handleMessage(o *poker.Occupant) {
85 | for {
86 | message, _ := o.GetMessage(0)
87 | if message == nil {
88 | break
89 | }
90 |
91 | switch message.Type {
92 | case poker.MsgPresence:
93 | handlePresence(o, message)
94 | }
95 | }
96 | }
97 |
98 | func handlePresence(o *poker.Occupant, message *poker.Message) {
99 | switch message.Action {
100 | case poker.ActState:
101 | o.Room = message.Room
102 | fmt.Printf("Enter room, %d Occupants\n", o.Room.N)
103 | case poker.ActJoin:
104 | occupant := message.Occupant
105 | o.Room.Occupants[occupant.Pos-1] = occupant
106 | o.Room.N++
107 | fmt.Printf("%s(%s) Join.\n", occupant.Id, occupant.Name)
108 | case poker.ActLeave:
109 | occupant := message.Occupant
110 | o.Room.Occupants[occupant.Pos-1] = nil
111 | o.Room.N--
112 | if occupant.Id == o.Id {
113 | o.Room = nil
114 | o.Pos = 0
115 | fmt.Println("You are kicked.")
116 | } else {
117 | fmt.Printf("%s(%s) Leave.\n", occupant.Id, occupant.Name)
118 | }
119 | case poker.ActButton:
120 | pos, _ := strconv.Atoi(message.Class)
121 |
122 | o.Room.Button = pos
123 | o.Room.Bet = 0
124 | o.Room.Cards = nil
125 | o.Room.Pot = make([]int, 1)
126 | o.Room.Each(0, func(o *poker.Occupant) bool {
127 | if o != nil {
128 | o.Bet = 0
129 | o.Action = ""
130 | o.Cards = nil
131 | o.Hand = 0
132 | }
133 | return true
134 | })
135 |
136 | dealer := o.Room.Occupants[pos-1]
137 | fmt.Printf("Button: %s(%s).\n", dealer.Id, dealer.Name)
138 | case poker.ActPreflop:
139 | fmt.Println("Preflop:", message.Class)
140 | cards := strings.Split(message.Class, ",")
141 | o.Cards = append(o.Cards, poker.ParseCard(cards[0]))
142 | o.Cards = append(o.Cards, poker.ParseCard(cards[1]))
143 | case poker.ActFlop:
144 | o.Room.Each(0, func(o *poker.Occupant) bool {
145 | if o != nil {
146 | o.Bet = 0
147 | o.Action = ""
148 | }
149 | return true
150 | })
151 | fmt.Println("Flop:", message.Class)
152 | cards := strings.Split(message.Class, ",")
153 | o.Room.Cards = append(o.Room.Cards, poker.ParseCard(cards[0]))
154 | o.Room.Cards = append(o.Room.Cards, poker.ParseCard(cards[1]))
155 | o.Room.Cards = append(o.Room.Cards, poker.ParseCard(cards[2]))
156 | o.Hand, _ = strconv.Atoi(cards[3])
157 | case poker.ActTurn:
158 | o.Room.Each(0, func(o *poker.Occupant) bool {
159 | if o != nil {
160 | o.Bet = 0
161 | o.Action = ""
162 | }
163 | return true
164 | })
165 | fmt.Println("Turn:", message.Class)
166 | cards := strings.Split(message.Class, ",")
167 | o.Room.Cards = append(o.Room.Cards, poker.ParseCard(cards[0]))
168 | o.Hand, _ = strconv.Atoi(cards[1])
169 | case poker.ActRiver:
170 | o.Room.Each(0, func(o *poker.Occupant) bool {
171 | if o != nil {
172 | o.Bet = 0
173 | o.Action = ""
174 | }
175 | return true
176 | })
177 | fmt.Println("River:", message.Class)
178 | cards := strings.Split(message.Class, ",")
179 | o.Room.Cards = append(o.Room.Cards, poker.ParseCard(cards[0]))
180 | o.Hand, _ = strconv.Atoi(cards[1])
181 | case poker.ActShowdown:
182 | fmt.Println("pot:", o.Room.Pot)
183 | case poker.ActAction:
184 | a := strings.Split(message.Class, ",")
185 | pos, _ := strconv.Atoi(a[0])
186 | o.Room.Bet, _ = strconv.Atoi(a[1])
187 | if o.Room.Occupants[pos-1].Id == o.Id {
188 | log.Printf("Your bet turn (%d/%d/%d):\n",
189 | o.Room.Occupants[pos-1].Bet, o.Room.Bet, o.Room.Occupants[pos-1].Chips)
190 | }
191 | case poker.ActPot:
192 | pots := strings.Split(message.Class, ",")
193 | o.Room.Pot = nil
194 | for i, _ := range pots {
195 | pot, _ := strconv.Atoi(pots[i])
196 | o.Room.Pot = append(o.Room.Pot, pot)
197 | }
198 | case poker.ActBet:
199 | occupant := o.Room.Occupant(message.From)
200 | occupant.Room = o.Room
201 | bets := strings.Split(message.Class, ",")
202 | occupant.Action = bets[0]
203 | occupant.Bet, _ = strconv.Atoi(bets[1])
204 | occupant.Chips, _ = strconv.Atoi(bets[2])
205 |
206 | if occupant.Id == o.Id {
207 | fmt.Printf("You %s: %d\n", occupant.Action, occupant.Bet)
208 | } else {
209 | fmt.Printf("%s(%s) %s: %d\n", occupant.Id, occupant.Name, occupant.Action, occupant.Bet)
210 | }
211 | }
212 | }
213 |
214 | func cmdLoop(o *poker.Occupant) {
215 | reader := bufio.NewReader(os.Stdin)
216 |
217 | for {
218 | fmt.Print("poker> ")
219 | cmd, _ := reader.ReadString('\n')
220 | cmd = strings.ToLower(strings.Trim(cmd, " \n"))
221 |
222 | if len(cmd) == 0 {
223 | continue
224 | }
225 | switch cmd[0] {
226 | case 'j':
227 | if o.Room == nil {
228 | o.SendMessage(&poker.Message{
229 | Type: poker.MsgPresence,
230 | Action: poker.ActJoin,
231 | To: "0",
232 | })
233 | }
234 |
235 | case 'l':
236 | if o.Room != nil {
237 | o.SendMessage(&poker.Message{
238 | Type: poker.MsgPresence,
239 | Action: poker.ActLeave,
240 | To: "0",
241 | })
242 | }
243 | o.Pos = 0
244 | o.Room = nil
245 | case 'c':
246 | if o.Room != nil {
247 | cards := []poker.Card{}
248 | cards = append(cards, o.Cards...)
249 |
250 | cards = append(cards, o.Room.Cards...)
251 | fmt.Println(cards)
252 | }
253 | case 'q':
254 | return
255 | default:
256 | bet, _ := strconv.ParseInt(cmd, 10, 32)
257 | o.SendMessage(&poker.Message{
258 | Type: poker.MsgPresence,
259 | Action: poker.ActBet,
260 | Class: strconv.FormatInt(bet, 10),
261 | })
262 | }
263 | }
264 | }
265 |
--------------------------------------------------------------------------------
/Poker/animations.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Animations = function() {
4 |
5 | this.offsetX = 0;
6 | this.offsetY = 0;
7 | this.widthBK = 0;
8 | this.heightBK = 0;
9 |
10 | this.publicCards = [];
11 | this.light;
12 | this.stopShake = true;
13 | }
14 |
15 | Animations.prototype = {
16 |
17 | setPosParam:function(width, height, offsetX, offsetY) {
18 | this.widthBK = width;
19 | this.heightBK = height;
20 | this.offsetX = offsetX;
21 | this.offsetY = offsetY;
22 | },
23 |
24 | setPublicCard:function(lstPublicCard) {
25 | this.publicCards = lstPublicCard;
26 | },
27 |
28 | showPublicCard:function(lstIndex, lstKey, showBK, callback) {
29 | if(lstIndex.length > this.publicCards.length)
30 | {
31 | return;
32 | }
33 |
34 | var nIndex = 0;
35 | var animationTime = 100;
36 | var that = this;
37 | var showAnimation = function (index, key, showBK) {
38 | var cardWidth = that.publicCards[index].width;
39 | if(showBK)
40 | {
41 | that.publicCards[index].loadTexture("cardBK", that.publicCards[index].frame);
42 | var tween = game.add.tween(that.publicCards[index]);
43 | tween.to({ width:0 }, animationTime, Phaser.Easing.Linear.None, true);
44 | tween.onComplete.add(function() {
45 | that.publicCards[index].loadTexture(key, that.publicCards[index].frame);
46 | var tween2 = game.add.tween(that.publicCards[index]);
47 | tween2.to({ width:cardWidth }, animationTime, Phaser.Easing.Linear.None, true);
48 | nIndex++;
49 | if(nIndex < lstIndex.length)
50 | {
51 | tween2.onComplete.add(function() {
52 | showAnimation(lstIndex[nIndex], lstKey[nIndex], showBK);
53 | }, that);
54 | }
55 | }, that);
56 | }
57 | else
58 | {
59 | that.publicCards[index].width = 0;
60 | that.publicCards[index].loadTexture(key, that.publicCards[index].frame);
61 | var tween = game.add.tween(that.publicCards[index]);
62 | tween.to({ width:cardWidth }, animationTime, Phaser.Easing.Linear.None, true);
63 | nIndex++;
64 | if(nIndex < lstIndex.length)
65 | {
66 | tween.onComplete.add(function() {
67 | showAnimation(lstIndex[nIndex], lstKey[nIndex], showBK);
68 | }, that);
69 | }
70 | }
71 | };
72 |
73 | if(callback != undefined) {
74 | callback();
75 | }
76 |
77 | showAnimation(lstIndex[nIndex], lstKey[nIndex], showBK);
78 | },
79 |
80 | //this.animation.showShake(this.selfCards[0]);
81 | //this.animation.showShake(this.selfCards[1]);
82 | //this.animation.stopShake = true;
83 |
84 | showShake:function(target, time, frequency, offset) {
85 | var shakeTime = 20000;
86 | if(time)
87 | {
88 | shakeTime = time;
89 | }
90 | var shakeFrequency = 10;
91 | if(frequency)
92 | {
93 | shakeFrequency = frequency;
94 | }
95 | var shakeOffset = Math.min(target.width, target.height) / 50;
96 | if(offset)
97 | {
98 | shakeOffset = offset;
99 | }
100 |
101 | this.stopShake = false;
102 | var that = this;
103 | var targetX = target.x;
104 | var targetY = target.y;
105 | var pt = [{x:targetX - shakeOffset, y:targetY - shakeOffset}
106 | , {x:targetX, y:targetY - shakeOffset}
107 | , {x:targetX + shakeOffset, y:targetY - shakeOffset}
108 | , {x:targetX - shakeOffset, y:targetY}
109 | , {x:targetX + shakeOffset, y:targetY}
110 | , {x:targetX - shakeOffset, y:targetY + shakeOffset}
111 | , {x:targetX, y:targetY + shakeOffset}
112 | , {x:targetX + shakeOffset, y:targetY + shakeOffset}];
113 |
114 | var nCount = 0;
115 | var showAnimation = function () {
116 | var tween = game.add.tween(target);
117 | var nextPt = pt[Math.floor(Math.random() * pt.length)];
118 | tween.to({ x:nextPt.x, y: nextPt.y }, shakeFrequency, Phaser.Easing.Linear.None, true);
119 | nCount++;
120 | tween.onComplete.add(function() {
121 |
122 |
123 |
124 | if(nCount * shakeFrequency <= shakeTime && !that.stopShake)
125 | {
126 | showAnimation();
127 | }
128 | else
129 | {
130 | target.x = targetX;
131 | target.y = targetY;
132 | }
133 | }, this);
134 | };
135 |
136 | showAnimation(nCount);
137 | },
138 |
139 | setLight:function(light) {
140 | this.light = light;
141 | },
142 |
143 | showLight:function(targetX, targetY)
144 | {
145 | var animationTime = 500;
146 | var xOffset = this.offsetX;
147 | var yOffset = this.offsetY;
148 | var length = Math.sqrt((this.light.x - targetX) * (this.light.x - targetX) + (this.light.y - targetY) * (this.light.y - targetY));
149 | var angleFinal = Math.atan2((targetY - this.light.y), (targetX - this.light.x)) * 180 / 3.1415926;
150 |
151 | while(angleFinal < this.light.angle)
152 | {
153 | angleFinal += 360;
154 | }
155 | if(angleFinal - this.light.angle > 180)
156 | {
157 | angleFinal -= 360;
158 | }
159 | if(!this.light.visible)
160 | {
161 | this.light.visible = true;
162 | this.light.width = length;
163 | this.light.angle = angleFinal;
164 | }
165 | else
166 | {
167 | var tween = game.add.tween(this.light);
168 | tween.to({ width:length, angle: angleFinal }, animationTime, Phaser.Easing.Linear.None, true);
169 | }
170 | },
171 |
172 | showChipMove:function(target, targetX, targetY, time)
173 | {
174 | var animationTime = 100;
175 | if(time != undefined && time != null) {
176 | animationTime = time
177 | }
178 |
179 | var tween = game.add.tween(target);
180 | tween.to({ x:targetX, y: targetY }, animationTime, Phaser.Easing.Linear.None, true);
181 | },
182 |
183 | //this.chipPoolCoins = this.animation.showCollectChip(this.userList, this.chipPoolBK.x + this.chipPoolBK.width * 0.14, this.chipPoolBK.y + this.chipPoolBK.height * 0.5, this.chipPoolCoins);
184 |
185 | showCollectChip:function(userList, targetX, targetY, existCoin)
186 | {
187 | var animationTime = 50;
188 | var coinSpace = 0.1111;
189 | var totalCoins = [];
190 | for(var i = 0; i < userList.length; i++)
191 | {
192 | var user = userList[i];
193 | for(var j = 0; j < user.imageCoin.length; j++)
194 | {
195 | var coin = user.imageCoin[user.imageCoin.length - 1 - j];
196 | totalCoins.push(coin);
197 | }
198 | user.imageCoin = [];
199 | }
200 |
201 |
202 | var nIndex = 0;
203 | var showAnimation = function (index) {
204 | if (totalCoins.length <= index) {
205 | return
206 | };
207 |
208 | totalCoins[index].bringToTop();
209 |
210 | var tween = game.add.tween(totalCoins[index]);
211 | tween.to({ x:targetX, y: targetY - (index + existCoin.length) * totalCoins[index].height * coinSpace }, animationTime, Phaser.Easing.Linear.None, true);
212 | nIndex++;
213 | if(nIndex < totalCoins.length)
214 | {
215 | tween.onComplete.add(function() {
216 | showAnimation(nIndex);
217 | }, this);
218 | }
219 | };
220 |
221 | showAnimation(nIndex);
222 |
223 | return existCoin.concat(totalCoins);
224 | },
225 |
226 | //Demo
227 | demoShowPublicCard:function() {
228 | var publicCards = ["SA", "H2", "C3"];
229 | var lstCardID = [];
230 | var lstCardImage = [];
231 | for (var i = 0; i < publicCards.length; i++) {
232 | this.publicCards[i].visible = true;
233 | lstCardID.push(i);
234 | lstCardImage.push(publicCards[i]);
235 | }
236 | this.showPublicCard(lstCardID, lstCardImage, true);
237 | }
238 | }
239 |
--------------------------------------------------------------------------------
/Poker/main.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var game = null
4 | var gParam = {ws_server:"localhost:8989/ws", user_name:"", joinroom:null, platform:"PC", app_token:null}
5 | //var gParam = {ws_server:"172.24.222.54:8989/ws", user_name:"", joinroom:null, platform:"PC", app_token:null}
6 |
7 |
8 | var gImageDir = "assets/2x/"
9 | var gFontScale = 1.0;
10 | var Native
11 |
12 | function bindNative() {
13 | if(PLAT == "IOS") {
14 | Native = {}
15 |
16 | enableNativeLog();
17 |
18 | try {
19 |
20 |
21 | connectWebViewJavascriptBridge(function(bridge) {
22 | bridge.init(function(message, responseCallback) {
23 | console.log("WebViewJavascriptBridge init OK");
24 | });
25 | bridge.registerHandler("quitApp", function(){
26 | game.Native.yesOrNoPopupWindow("退出游戏","你确定要退出游戏吗?","取消","确定",function(data){
27 | if(data.sender == "popButton2") {
28 | game.Native.quitToApp();
29 | }
30 |
31 | });
32 |
33 | });
34 |
35 | bridge.callHandler("getNativeConfig",null,function(data){
36 |
37 | console.log(data.ws_server);
38 | data.platform = PLAT
39 | startGame(data);
40 | });
41 |
42 | Native.quitToApp = function() {
43 | game.betApi.leaveRoom();
44 | bridge.callHandler("quitToApp");
45 | console.log("quitToApp")
46 | };
47 |
48 | Native.showProfile = function(userid) {
49 | bridge.callHandler("showProfile", {userid:userid});
50 | console.log("showProfile");
51 | },
52 |
53 | Native.confrimPopupWindow = function(title, text, buttonText, callback) {
54 | if(buttonText == undefined || buttonText == null) {
55 | buttonText = "确定";
56 | }
57 | bridge.callHandler("confrimPopupWindow", {pop_title:title, pop_text:text,pop_btn1_text:buttonText}, function(data){
58 | callback(data);
59 | });
60 | console.log("confrimPopupWindow")
61 | };
62 |
63 | Native.yesOrNoPopupWindow = function(title, text, button1Text, button2Text, callback) {
64 | if(button1Text == undefined || button1Text == null) {
65 | button1Text = "取消";
66 | }
67 |
68 | if(button2Text == undefined || button2Text == null) {
69 | button2Text = "确定";
70 | }
71 |
72 | bridge.callHandler("yesOrNoPopupWindow", {pop_title:title, pop_text:text,pop_btn1_text:button1Text, pop_btn2_text:button2Text}, function(data){
73 | callback(data);
74 | });
75 | console.log("yesOrNoPopupWindow")
76 | };
77 | });
78 |
79 |
80 | }catch(e) {
81 | console.log(e);
82 | }
83 |
84 |
85 | } else {
86 | startGame({platform:PLAT});
87 | }
88 |
89 | }
90 |
91 | function enableNativeLog() {
92 | console = new Object();
93 | console.log = function(log, other) {
94 | var iframe = document.createElement("IFRAME");
95 | var otherstring = ""
96 | if(other != undefined) {
97 | otherstring = other;
98 | }
99 |
100 | iframe.setAttribute("src", "ios-log:#iOS#" + log + " "+ otherstring);
101 | document.documentElement.appendChild(iframe);
102 | iframe.parentNode.removeChild(iframe);
103 | iframe = null;
104 | };
105 | console.debug = console.log;
106 | console.info = console.log;
107 | console.warn = console.log;
108 | console.error = console.log;
109 | }
110 |
111 |
112 |
113 | function connectWebViewJavascriptBridge(callback) {
114 | if (window.WebViewJavascriptBridge) {
115 | callback(WebViewJavascriptBridge)
116 | } else {
117 | document.addEventListener('WebViewJavascriptBridgeReady', function() {
118 | callback(WebViewJavascriptBridge)
119 | }, false)
120 | }
121 | }
122 |
123 |
124 | function _fontString(size, fontname) {
125 | if (fontname == undefined) {
126 | //fontname = "Impact"
127 | fontname = "Apple LiSung Light"
128 | };
129 |
130 | return (size * gFontScale)+"px " + fontname
131 | }
132 |
133 | function startGame(gameParam) {
134 | try {
135 | // merge property
136 |
137 | for(var p in gParam) {
138 | var value = gameParam[p];
139 | if(value != undefined && value != null) {
140 | gParam[p] = gameParam[p];
141 | }
142 | }
143 | if (gParam["platform"] == "IOS") {
144 | var deviceWidth = 1136;
145 | var deviceHeight = 640;
146 | document.body.setAttribute("orient", "landscape");
147 | gImageDir = "assets/1x/"
148 | gFontScale = 0.6;
149 | // 使用 1x的图片效果更差,算了,直接用2x的
150 |
151 | gImageDir = "assets/2x/"
152 | gFontScale = 1.2;
153 |
154 | game = new Phaser.Game(deviceWidth, deviceHeight, Phaser.CANVAS, "gamediv");
155 | } else {
156 | game = new Phaser.Game("100", "100", Phaser.CANVAS, "gamediv");
157 | }
158 |
159 | game.Native = Native;
160 |
161 | game.betApi = new BetApi();
162 | if(gParam["app_token"] == undefined || gParam["app_token"] == null) {
163 | game.state.add("LoginState", LoginState);
164 | }
165 |
166 | game.state.add("MainState", MainState);
167 | //gParam["app_token"] = "testUSer"
168 |
169 | if(gParam["app_token"] != undefined && gParam["app_token"] != null) {
170 | game.state.start("MainState");
171 | } else {
172 | //gParam["app_token"] = "testUSer"
173 | game.state.start("LoginState");
174 | //game.state.start("MainState");
175 | }
176 | } catch(e) {
177 | console.log("error ! ", e);
178 | }
179 | }
180 |
181 | function gameQuit(cause) {
182 | if(gParam["platform"] == "IOS") {
183 | //game.Native.quitToApp(cause);
184 |
185 | game.Native.confrimPopupWindow("你的钱输光了!!","你的积分为0, 即将被踢出游戏", "确认", function(data){
186 | console.log("Good lllll");
187 | });
188 |
189 |
190 | /*
191 | game.Native.yesOrNoPopupWindow("你的钱输光了!!","你的积分为0, 即将被踢出游戏", "放弃", "确认",function(data){
192 | console.log("you click:", data.sender);
193 | });
194 | */
195 | } else {
196 | game.state.states["MainState"].actionOnExit();
197 | }
198 | }
199 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/DQAlertView/DQAlertView.h:
--------------------------------------------------------------------------------
1 | //
2 | // DQAlertView.h
3 | //
4 | // Version 0.1
5 | //
6 | // Created by Dinh Quan on 1/27/14.
7 | // Copyright (c) 2014 Dinh Quan. All rights reserved.
8 | //
9 | // This code is distributed under the terms and conditions of the MIT license.
10 | //
11 | // Permission is hereby granted, free of charge, to any person obtaining a copy
12 | // of this software and associated documentation files (the "Software"), to deal
13 | // in the Software without restriction, including without limitation the rights
14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | // copies of the Software, and to permit persons to whom the Software is
16 | // furnished to do so, subject to the following conditions:
17 | //
18 | // The above copyright notice and this permission notice shall be included in
19 | // all copies or substantial portions of the Software.
20 | //
21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 | // THE SOFTWARE.
28 |
29 |
30 | #import
31 |
32 |
33 | @protocol DQAlertViewDelegate;
34 |
35 | typedef enum
36 | {
37 | DQAlertViewAnimationTypeNone = 0,
38 | DQAlertViewAnimationTypeDefault = 1,
39 | DQAlertViewAnimationTypeFadeIn = 2,
40 | DQAlertViewAnimationTypeFaceOut = 3,
41 | DQAlertViewAnimationTypeFlyTop = 4,
42 | DQAlertViewAnimationTypeFlyBottom = 5,
43 | DQAlertViewAnimationTypeFlyLeft = 6,
44 | DQAlertViewAnimationTypeFlyRight = 7,
45 | DQAlertViewAnimationTypeZoomIn = 8,
46 | DQAlertViewAnimationTypeZoomOut = 9
47 |
48 | } DQAlertViewAnimationType;
49 |
50 | typedef void (^DQAlertViewBlock)(void);
51 |
52 | @interface DQAlertView : UIView
53 |
54 | #pragma mark - Public Properties
55 |
56 | // Set the custom frame for the Alert View, if this property has not been set the Alert will be shown at center of the view. Don't use the default method [UIView setFrame:]
57 | @property (nonatomic, assign) CGRect customFrame; // Default is same as UIAlertView
58 |
59 |
60 | // Set the content view for the Alert View
61 | // The frame of alert view will be resized based on the frame of content view, so you don't have to set the custom frame. If you want the alert view not shown at center, just set the center of the Alert View
62 | @property (nonatomic, strong) UIView *contentView;
63 |
64 |
65 | // You can get buttons and labels for customizing their appearance
66 | @property (nonatomic, strong) UIButton * cancelButton; // Default is in blue color and system font 16
67 | @property (nonatomic, strong) UIButton * otherButton; // Default is in blue color and system font 16
68 | @property (nonatomic, strong) UILabel * titleLabel; // Default is in black color and system bold font 16
69 | @property (nonatomic, strong) UILabel * messageLabel; // Default is in gray color and system font 14
70 |
71 |
72 | // Set the height of title and button; and the padding of elements. The message label height is calculated based on its text and font.
73 | @property (nonatomic, assign) CGFloat buttonHeight; // Default is 44
74 | @property (nonatomic, assign) CGFloat titleHeight; // Default is 30
75 |
76 | @property (nonatomic, assign) CGFloat titleTopPadding; //Default is 5
77 | @property (nonatomic, assign) CGFloat titleBottomPadding; // Default is 0
78 | @property (nonatomic, assign) CGFloat messageBottomPadding; // Default is 10
79 | @property (nonatomic, assign) CGFloat messageLeftRightPadding; // Default is 10
80 |
81 |
82 | // Customize the background and border
83 | @property (nonatomic, strong) UIColor * borderColor; // Default is no border
84 | @property (nonatomic, assign) CGFloat borderWidth; // Default is 0
85 | @property (nonatomic, assign) CGFloat cornerRadius; // Default is 4
86 | // inherits from UIView @property (nonatomic, strong) UIColor * backgroundColor; // Default is white color with alpha 1
87 | @property (nonatomic, strong) UIImage * backgroundImage; // Default is nil
88 |
89 |
90 | // Customize the seperator
91 | @property (nonatomic, assign) BOOL hideSeperator; // Default is NO
92 | @property (nonatomic, strong) UIColor * seperatorColor; // Default is light gray color
93 |
94 |
95 | // Customize the appearing and disappearing animations
96 | @property (nonatomic, assign) DQAlertViewAnimationType appearAnimationType;
97 | @property (nonatomic, assign) DQAlertViewAnimationType disappearAnimationType;
98 | @property (nonatomic, assign) NSTimeInterval appearTime; // Default is 0.5
99 | @property (nonatomic, assign) NSTimeInterval disappearTime; // Default is 0.3
100 |
101 |
102 | // Make the cancel button appear on the right by setting this to YES
103 | @property (nonatomic, assign) BOOL cancelButtonPositionRight; // Default is NO
104 |
105 | // Disable the button highlight by setting this property to NO
106 | @property (nonatomic, assign) BOOL buttonClickedHighlight; //Default is YES
107 |
108 | // By default the alert will not dismiss if clicked to other button, set this property to YES to change the behaviour
109 | @property (nonatomic, assign) BOOL shouldDismissOnActionButtonClicked; //Default is NO
110 |
111 | // If this property is YES, the alert will dismiss when you click on outside (only when dim background is enable)
112 | @property (nonatomic, assign) BOOL shouldDismissOnOutsideTapped; //Default is NO
113 |
114 | // When shown in window, the dim background is always enable
115 | @property (nonatomic, assign) BOOL shouldDimBackgroundWhenShowInWindow; //Default is YES
116 |
117 | // When shown in view, the dim background is always disable
118 | @property (nonatomic, assign) BOOL shouldDimBackgroundWhenShowInView; //Default is NO
119 |
120 | // The default color of dim background is black color with alpha 0.2
121 | @property (nonatomic, assign) CGFloat dimAlpha; //Default is 0.2
122 |
123 | // Delegate
124 | @property (nonatomic, strong) id delegate;
125 |
126 | // Handle the button touching event
127 | @property (readwrite, copy) DQAlertViewBlock cancelButtonAction;
128 | @property (readwrite, copy) DQAlertViewBlock otherButtonAction;
129 |
130 |
131 | #pragma mark - Public Methods
132 |
133 | // Initialize method, same as UIAlertView
134 | // On the current version, the alert does not support more than one other buttons
135 | // If you pass the title by nil, the alert will be no title. If you pass the otherButtonTitle by nil, the alert will only have cancel button. You can remove all buttons by set all buton titles to nil.
136 | - (instancetype)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id /**/)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...;
137 |
138 | // Initialize convenience method
139 | // If you pass the title by nil, the alert will be no title. If you pass the otherButtonTitle by nil, the alert will only have cancel button. You can remove all buttons by set all buton titles to nil.
140 | - (instancetype)initWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitle:(NSString *)otherButtonTitle;
141 |
142 |
143 | // You can use this methods instead of calling these properties:
144 | // @property (readwrite, copy) DQAlertViewBlock cancelButtonAction;
145 | // @property (readwrite, copy) DQAlertViewBlock otherButtonAction;
146 | - (void)actionWithBlocksCancelButtonHandler:(void (^)(void))cancelHandler otherButtonHandler:(void (^)(void))otherHandler;
147 |
148 |
149 | // Show in specified view
150 | // If the custom frame has not been set, the alert will be shown at the center of the view
151 | - (void)showInView:(UIView *)view;
152 |
153 |
154 | // Show in window
155 | // If the custom frame has not been set, the alert will be shown at the center of the window
156 | - (void)show;
157 |
158 |
159 | // Dismiss the alert
160 | - (void)dismiss;
161 |
162 | @end
163 |
164 | // DQAlertViewDelegate
165 | @protocol DQAlertViewDelegate
166 |
167 | @optional
168 | - (void)willAppearAlertView:(DQAlertView *)alertView;
169 | - (void)didAppearAlertView:(DQAlertView *)alertView;
170 |
171 | - (void)cancelButtonClickedOnAlertView:(DQAlertView *)alertView;
172 | - (void)otherButtonClickedOnAlertView:(DQAlertView *)alertView;
173 |
174 | @end
175 |
--------------------------------------------------------------------------------
/server/card.go:
--------------------------------------------------------------------------------
1 | package poker
2 |
3 | import (
4 | "fmt"
5 | "math/rand"
6 | "os"
7 | "strings"
8 | "time"
9 | )
10 |
11 | const (
12 | HgihCard = iota + 1
13 | OnePair
14 | TwoPair
15 | ThreeOfAKind
16 | Straight
17 | Flush
18 | FullHouse
19 | FourOfAKind
20 | StraightFlush
21 | RoyalFlush
22 | )
23 |
24 | // rank
25 | const (
26 | Deuce = iota
27 | Trey
28 | Four
29 | Five
30 | Six
31 | Seven
32 | Eight
33 | Nine
34 | Ten
35 | Jack
36 | Queen
37 | King
38 | Ace
39 |
40 | RankMask = 0xF
41 | )
42 |
43 | // suit
44 | const (
45 | Club = 0x8000
46 | Diamond = 0x4000
47 | Heart = 0x2000
48 | Spade = 0x1000
49 |
50 | SuitMask = 0xF000
51 | )
52 |
53 | const (
54 | NumCard = 52
55 | )
56 |
57 | type Card uint32
58 |
59 | const NilCard = Card(0)
60 |
61 | func ParseCard(c string) Card {
62 | if len(c) != 2 {
63 | return NilCard
64 | }
65 | b := []byte(c)
66 |
67 | rank := 0
68 | suit := 0
69 |
70 | switch b[0] {
71 | case 'c', 'C':
72 | suit = Club
73 | case 'd', 'D':
74 | suit = Diamond
75 | case 'h', 'H':
76 | suit = Heart
77 | case 's', 'S':
78 | suit = Spade
79 | }
80 |
81 | switch b[1] {
82 | case '2':
83 | rank = Deuce
84 | case '3':
85 | rank = Trey
86 | case '4':
87 | rank = Four
88 | case '5':
89 | rank = Five
90 | case '6':
91 | rank = Six
92 | case '7':
93 | rank = Seven
94 | case '8':
95 | rank = Eight
96 | case '9':
97 | rank = Nine
98 | case 't', 'T':
99 | rank = Ten
100 | case 'j', 'J':
101 | rank = Jack
102 | case 'q', 'Q':
103 | rank = Queen
104 | case 'k', 'K':
105 | rank = King
106 | case 'a', 'A':
107 | rank = Ace
108 | default:
109 | rank = -1
110 | }
111 |
112 | if suit == 0 || rank < 0 {
113 | return NilCard
114 | }
115 |
116 | card := (1 << uint32(16+rank)) | suit | (rank << 8) | primes[rank]
117 |
118 | return Card(card)
119 | }
120 |
121 | func (card Card) Rank() int {
122 | return int((card >> 8) & RankMask)
123 | }
124 |
125 | func (card Card) Suit() int {
126 | return int(card & SuitMask)
127 | }
128 |
129 | func (card Card) prime() int {
130 | return int(card & 0xFF)
131 | }
132 |
133 | func (card Card) MarshalJSON() ([]byte, error) {
134 | return []byte("\"" + card.String() + "\""), nil
135 | }
136 |
137 | func (card *Card) UnmarshalJSON(b []byte) error {
138 | *card = ParseCard(strings.Trim(string(b), "\""))
139 | return nil
140 | }
141 |
142 | func (card Card) String() string {
143 | b := make([]byte, 2)
144 |
145 | switch card.Suit() {
146 | case Club:
147 | b[0] = 'C'
148 | case Diamond:
149 | b[0] = 'D'
150 | case Heart:
151 | b[0] = 'H'
152 | case Spade:
153 | b[0] = 'S'
154 | default:
155 | return ""
156 | }
157 |
158 | switch card.Rank() {
159 | case Deuce:
160 | b[1] = '2'
161 | case Trey:
162 | b[1] = '3'
163 | case Four:
164 | b[1] = '4'
165 | case Five:
166 | b[1] = '5'
167 | case Six:
168 | b[1] = '6'
169 | case Seven:
170 | b[1] = '7'
171 | case Eight:
172 | b[1] = '8'
173 | case Nine:
174 | b[1] = '9'
175 | case Ten:
176 | b[1] = 'T'
177 | case Jack:
178 | b[1] = 'J'
179 | case Queen:
180 | b[1] = 'Q'
181 | case King:
182 | b[1] = 'K'
183 | case Ace:
184 | b[1] = 'A'
185 | default:
186 | return ""
187 | }
188 |
189 | return string(b)
190 | }
191 |
192 | type Deck struct {
193 | cards [NumCard]Card
194 | pos int
195 | }
196 |
197 | func NewDeck() *Deck {
198 | deck := new(Deck)
199 | deck.Init()
200 | return deck
201 | }
202 |
203 | //
204 | // This routine initializes the deck. A deck of cards is
205 | // simply an integer array of length 52 (no jokers). This
206 | // array is populated with each card, using the following
207 | // scheme:
208 | //
209 | // An integer is made up of four bytes. The high-order
210 | // bytes are used to hold the rank bit pattern, whereas
211 | // the low-order bytes hold the suit/rank/prime value
212 | // of the card.
213 | //
214 | // +--------+--------+--------+--------+
215 | // |xxxbbbbb|bbbbbbbb|cdhsrrrr|xxpppppp|
216 | // +--------+--------+--------+--------+
217 | //
218 | // p = prime number of rank (deuce=2,trey=3,four=5,five=7,...,ace=41)
219 | // r = rank of card (deuce=0,trey=1,four=2,five=3,...,ace=12)
220 | // cdhs = suit of card
221 | // b = bit turned on depending on rank of card
222 | //
223 | func (deck *Deck) Init() {
224 | n := 0
225 | suit := 0x8000
226 |
227 | for i := 0; i < 4; i++ {
228 | for j := 0; j < 13; j++ {
229 | deck.cards[n] = Card(primes[j] | (j << 8) | suit | (1 << uint32(16+j)))
230 | n++
231 | }
232 | suit >>= 1
233 | }
234 |
235 | deck.pos = 0
236 | }
237 |
238 | func (deck *Deck) Find(rank, suit int) Card {
239 | for _, card := range deck.cards {
240 | if card.Rank() == rank && card.Suit() == suit {
241 | return card
242 | }
243 | }
244 |
245 | return NilCard
246 | }
247 |
248 | func (deck *Deck) Shuffle() {
249 | deck.pos = 0
250 | r := rand.New(rand.NewSource(time.Now().UnixNano()))
251 | a := r.Perm(52)
252 | for i, v := range a {
253 | deck.cards[i], deck.cards[v] = deck.cards[v], deck.cards[i]
254 | }
255 | }
256 |
257 | func (deck *Deck) Take() Card {
258 | if deck.pos >= NumCard {
259 | return NilCard
260 | }
261 |
262 | card := deck.cards[deck.pos]
263 | deck.pos++
264 | return card
265 | }
266 |
267 | func handRank(val int) int {
268 | if val > 6185 { // 1277 high card
269 | return HgihCard
270 | }
271 | if val > 3325 { // 2860 one pair
272 | return OnePair
273 | }
274 | if val > 2467 { // 858 two pair
275 | return TwoPair
276 | }
277 | if val > 1609 { // 858 three-kind
278 | return ThreeOfAKind
279 | }
280 | if val > 1599 { // 10 straights
281 | return Straight
282 | }
283 | if val > 322 { // 1277 flushes
284 | return Flush
285 | }
286 | if val > 166 { // 156 full house
287 | return FullHouse
288 | }
289 | if val > 10 { // 156 four-kind
290 | return FourOfAKind
291 | }
292 | if val > 1 {
293 | return StraightFlush // 10 straight-flushes
294 | }
295 |
296 | return RoyalFlush
297 | }
298 |
299 | func eva5cards(cards [5]Card) int {
300 | q := int(cards[0]|cards[1]|cards[2]|cards[3]|cards[4]) >> 16
301 |
302 | // check for Flushes and StraightFlushes
303 | if cards[0]&cards[1]&cards[2]&cards[3]&cards[4]&SuitMask != 0 {
304 | return flushes[q]
305 | }
306 |
307 | // check for Straights and HighCard hands
308 | s := unique5[q]
309 | if s != 0 {
310 | return (s)
311 | }
312 |
313 | // let's do it the hard way
314 | q = cards[0].prime() * cards[1].prime() * cards[2].prime() * cards[3].prime() * cards[4].prime()
315 | q = find(q)
316 |
317 | return values[q]
318 | }
319 |
320 | // perform a binary search on a pre-sorted array
321 | func find(key int) int {
322 | var low, high, mid int
323 | high = 4887
324 |
325 | for low <= high {
326 | mid = (high + low) >> 1 // divide by two
327 | if key < products[mid] {
328 | high = mid - 1
329 | } else if key > products[mid] {
330 | low = mid + 1
331 | } else {
332 | return mid
333 | }
334 | }
335 |
336 | fmt.Fprintf(os.Stderr, "ERROR: no match found; key = %d\n", key)
337 | return -1
338 | }
339 |
340 | func Eva5Hand(cards [5]Card) int {
341 | val := eva5cards(cards)
342 | hand := handRank(val)
343 | return hand<<16 | 0xffff&^val
344 | }
345 |
346 | var perm6 = [][5]int{
347 | {0, 1, 2, 3, 4},
348 | {0, 1, 2, 3, 5},
349 | {0, 1, 2, 4, 5},
350 | {0, 1, 3, 4, 5},
351 | {0, 2, 3, 4, 5},
352 | {1, 2, 3, 4, 5},
353 | }
354 |
355 | func Eva6Hand(cards [6]Card) int {
356 | var hand [5]Card
357 |
358 | best := 0xFFFF
359 |
360 | for i, _ := range perm6 {
361 | for j, _ := range hand {
362 | hand[j] = cards[perm6[i][j]]
363 | }
364 | v := eva5cards(hand)
365 | if v < best {
366 | best = v
367 | }
368 | }
369 |
370 | rank := handRank(best)
371 | return rank<<16 | 0xffff&^best
372 | }
373 |
374 | var perm7 = [][5]int{
375 | {0, 1, 2, 3, 4},
376 | {0, 1, 2, 3, 5},
377 | {0, 1, 2, 3, 6},
378 | {0, 1, 2, 4, 5},
379 | {0, 1, 2, 4, 6},
380 | {0, 1, 2, 5, 6},
381 | {0, 1, 3, 4, 5},
382 | {0, 1, 3, 4, 6},
383 | {0, 1, 3, 5, 6},
384 | {0, 1, 4, 5, 6},
385 | {0, 2, 3, 4, 5},
386 | {0, 2, 3, 4, 6},
387 | {0, 2, 3, 5, 6},
388 | {0, 2, 4, 5, 6},
389 | {0, 3, 4, 5, 6},
390 | {1, 2, 3, 4, 5},
391 | {1, 2, 3, 4, 6},
392 | {1, 2, 3, 5, 6},
393 | {1, 2, 4, 5, 6},
394 | {1, 3, 4, 5, 6},
395 | {2, 3, 4, 5, 6},
396 | }
397 |
398 | func Eva7Hand(cards [7]Card) int {
399 | var hand [5]Card
400 |
401 | best := 0xFFFF
402 |
403 | for i, _ := range perm7 {
404 | for j, _ := range hand {
405 | hand[j] = cards[perm7[i][j]]
406 | }
407 | v := eva5cards(hand)
408 | if v < best {
409 | best = v
410 | }
411 | }
412 |
413 | rank := handRank(best)
414 | return rank<<16 | 0x00ff&^best
415 | }
416 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/PokerViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // PokerViewController.m
3 | // Pocker
4 | //
5 | // Created by zhengying on 3/13/15.
6 | // Copyright (c) 2015 zhengying. All rights reserved.
7 | //
8 |
9 | #import "PokerViewController.h"
10 | #import "WebViewJavascriptBridge.h"
11 | #import "SettingViewController.h"
12 | #import "DQAlertView.h"
13 |
14 | #define STRING_IS_EMPTY(str) ((str) == nil || [(str) isEqualToString:@""])
15 | #define IOSVersionAbove(version) (([[[UIDevice currentDevice] systemVersion] intValue] >= version)? 1 : 0 )
16 |
17 |
18 | static const NSString* kUserName = @"user_name";
19 | static const NSString* kServer = @"ws_server";
20 | static const NSString* kToken = @"app_token";
21 | static const NSString* kJoinRoom = @"joinroom";
22 |
23 | @interface PokerViewController ()
24 |
25 | @end
26 |
27 | @implementation PokerViewController {
28 | WebViewJavascriptBridge* _bridge;
29 | NSMutableDictionary* _dictConfig;
30 |
31 | }
32 |
33 | -(void)awakeFromNib {
34 | //[self.view setTranslatesAutoresizingMaskIntoConstraints:NO];
35 | //[self.webView setTranslatesAutoresizingMaskIntoConstraints:NO];
36 | //[self.view updateConstraintsIfNeeded];
37 | }
38 |
39 |
40 | - (void)didReceiveMemoryWarning {
41 | [super didReceiveMemoryWarning];
42 | // Dispose of any resources that can be recreated.
43 | }
44 |
45 | /*
46 | -(void)startWithCreateByToken:(NSString*)token FinishedBlock:(void(^)(NSString* rootID))finishBlock {
47 | NSAssert(STRING_IS_EMPTY(token) == false, @"token is empty");
48 | _token = token;
49 | }
50 |
51 | -(void)startWithJoinRoot:(NSString*)roomID ByToken:(NSString*)token FinishedBlock:(void(^)())finishBlock {
52 | NSAssert(STRING_IS_EMPTY(token) == false, @"token is empty");
53 | NSAssert(STRING_IS_EMPTY(roomID), @"token is empty");
54 | _token = token;
55 | _joinroom = roomID;
56 | }
57 | */
58 |
59 | -(void)loadNativeSetting {
60 | BOOL linodeEnable = [[NSUserDefaults standardUserDefaults]boolForKey:@"linode_enable"];
61 | NSString* userName = [[NSUserDefaults standardUserDefaults]stringForKey:@"user_name"];
62 |
63 | if (!userName || [userName isEqualToString:@""]) {
64 | userName = @"TestUSER";
65 | [[NSUserDefaults standardUserDefaults]setObject:userName forKey:@"user_name"];
66 | }
67 |
68 | if(!_token) {
69 | _token = userName;
70 | }
71 |
72 |
73 | NSString* server = @"172.24.222.54:8989/ws";
74 |
75 | if (linodeEnable) {
76 | server = @"106.187.48.51:8989/ws";
77 | }
78 |
79 | if (userName) {
80 | _dictConfig[kUserName] = userName;
81 | }
82 |
83 | if (server) {
84 | _dictConfig[kServer] = server;
85 | }
86 |
87 | if (_token) {
88 | _dictConfig[kToken] = _token;
89 | }
90 |
91 | if (_joinroom) {
92 | _dictConfig[kJoinRoom] = _joinroom;
93 | }
94 | }
95 |
96 | -(UIView*)addMaskLayerToSelfView {
97 | UIView* viewMask = [[UIView alloc]initWithFrame:CGRectMake(100, 0, self.view.frame.size.height, self.view.frame.size.width)];
98 | viewMask.backgroundColor = [UIColor colorWithRed:200 green:100 blue:100 alpha:0.0];
99 | [self.view addSubview:viewMask];
100 | [viewMask setTranslatesAutoresizingMaskIntoConstraints:NO];
101 | NSDictionary *views = @{@"selfView":self.view, @"maskView":viewMask};
102 |
103 | [self.view addConstraints:[NSLayoutConstraint
104 | constraintsWithVisualFormat:@"H:|[maskView(selfView)]"
105 | options:0
106 | metrics:nil
107 | views:views]];
108 |
109 |
110 | [self.view addConstraints:[NSLayoutConstraint
111 | constraintsWithVisualFormat:@"V:|[maskView(selfView)]"
112 | options:0
113 | metrics:nil
114 | views:views]];
115 | [self.view layoutIfNeeded];
116 | return viewMask;
117 | }
118 |
119 | -(void)registerWebHandle {
120 |
121 | [WebViewJavascriptBridge enableLogging];
122 |
123 | _bridge = [WebViewJavascriptBridge bridgeForWebView:_webView webViewDelegate:self handler:^(id data, WVJBResponseCallback responseCallback) {
124 | NSLog(@"ObjC received message from JS: %@", data);
125 | responseCallback(@"Response for message from ObjC");
126 | }];
127 |
128 |
129 | __weak __typeof(self) weakSelf = self;
130 |
131 | // getNativeConfig
132 | [_bridge registerHandler:@"getNativeConfig" handler:^(id data, WVJBResponseCallback responseCallback) {
133 | __typeof(self) strongSelf = weakSelf;
134 | [weakSelf loadNativeSetting];
135 | responseCallback(strongSelf->_dictConfig);
136 | }];
137 |
138 | // quitToApp
139 | [_bridge registerHandler:@"quitToApp" handler:^(id data, WVJBResponseCallback responseCallback) {
140 | [weakSelf dismissViewControllerAnimated:YES completion:nil];
141 | }];
142 |
143 | // pop user detail
144 | [_bridge registerHandler:@"showProfile" handler:^(id data, WVJBResponseCallback responseCallback) {
145 | // NSString* userID = data[@"userid"];
146 | // TODO: pop user profile window;
147 | //try pop a window
148 | UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
149 | SettingViewController *settings = (SettingViewController*)[storyboard instantiateViewControllerWithIdentifier:@"Settings"];
150 |
151 |
152 | [weakSelf presentViewController:settings animated:YES completion:nil];
153 | }];
154 |
155 |
156 | // show common popup window
157 | [_bridge registerHandler:@"confrimPopupWindow" handler:^(id data, WVJBResponseCallback responseCallback) {
158 | NSString* popMessageID = data[@"id"];
159 | NSString* popTitle = data[@"pop_title"];
160 | NSString* popText = data[@"pop_text"];
161 | NSString* popButton1Text = data[@"pop_btn1_text"];
162 | DQAlertView* alertView = [[DQAlertView alloc]initWithTitle:popTitle message:popText delegate:self cancelButtonTitle:popButton1Text otherButtonTitles:nil];
163 |
164 | UIView* maskView = [self addMaskLayerToSelfView];
165 |
166 | __weak DQAlertView* alertViewSelf = alertView;
167 |
168 | alertView.cancelButtonAction = ^{
169 | responseCallback(@{@"buttonclick":@"popButton1"});
170 | [alertViewSelf.superview removeFromSuperview];
171 |
172 | };
173 | [alertView showInView:maskView];
174 | }];
175 |
176 | // show yesorno popup window
177 | [_bridge registerHandler:@"yesOrNoPopupWindow" handler:^(id data, WVJBResponseCallback responseCallback) {
178 | NSString* popMessageID = data[@"id"];
179 | NSString* popTitle = data[@"pop_title"];
180 | NSString* popText = data[@"pop_text"];
181 | NSString* popButton1Text = data[@"pop_btn1_text"];
182 | NSString* popButton2Text = data[@"pop_btn2_text"];
183 | //UIView* viewMask = [[UIView alloc]initWithFrame:CGRectMake(100, 0, self.view.frame.size.height, self.view.frame.size.width)];
184 | //viewMask.center = self.view.center;
185 |
186 | UIView* maskView = [self addMaskLayerToSelfView];
187 |
188 | DQAlertView* alertView = [[DQAlertView alloc]initWithTitle:popTitle message:popText delegate:self cancelButtonTitle:popButton1Text otherButtonTitles:popButton2Text];
189 |
190 | __weak DQAlertView* alertViewSelf = alertView;
191 |
192 | alertView.cancelButtonAction = ^{
193 | NSLog(@"Cancel Clicked");
194 | responseCallback(@{@"sender":@"popButton1"});
195 | [alertViewSelf.superview removeFromSuperview];
196 | };
197 | alertView.otherButtonAction = ^{
198 | NSLog(@"OK Clicked");
199 | responseCallback(@{@"sender":@"popButton2"});
200 | [alertViewSelf dismiss];
201 | [alertViewSelf.superview removeFromSuperview];
202 | };
203 | [alertView showInView:maskView];
204 | }];
205 | }
206 |
207 | - (void)viewDidLoad {
208 | [super viewDidLoad];
209 |
210 |
211 | _dictConfig = [[NSMutableDictionary alloc]init];
212 | [self registerWebHandle];
213 | [self loadHTMLToWebKit];
214 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionSettingUpdated:) name:@"SettingUpdate" object:nil];
215 | }
216 |
217 | -(void)viewWillAppear:(BOOL)animated {
218 | self.navigationController.navigationBarHidden = YES;
219 | [super viewWillAppear:animated];
220 | }
221 |
222 |
223 | -(void)loadHTMLToWebKit {
224 | [_webView stopLoading];
225 | NSString* PokerPath = [[[NSBundle mainBundle] resourcePath]stringByAppendingPathComponent:@"Poker"];
226 | NSString* pokerIndex = [PokerPath stringByAppendingPathComponent:@"index.html"];
227 | NSString* indexPageContent = [NSString stringWithContentsOfURL:[NSURL fileURLWithPath:pokerIndex]
228 | encoding:NSUTF8StringEncoding error:nil];
229 |
230 | indexPageContent = [indexPageContent stringByReplacingOccurrencesOfString:@"__PLAT__" withString:@"IOS"];
231 |
232 | [_webView loadHTMLString:indexPageContent baseURL:[NSURL fileURLWithPath:PokerPath]];
233 | }
234 |
235 |
236 | -(void)loadGame {
237 | //[self registerWebHandle];
238 | [self loadHTMLToWebKit];
239 | }
240 |
241 |
242 | -(void)actionSettingUpdated:(NSNotification* )notification {
243 | //[_bridge callHandler:@"reload"];
244 | [self loadGame];
245 | }
246 |
247 | -(IBAction)actionQuit:(id)sender {
248 | [_bridge callHandler:@"quitApp"];
249 | }
250 |
251 |
252 | - (UIStatusBarStyle)preferredStatusBarStyle
253 | {
254 | return UIStatusBarStyleLightContent;
255 | }
256 |
257 |
258 | -(IBAction)actionReload:(id)sender {
259 | //[_bridge callHandler:@"reload"];
260 | [self loadGame];
261 | }
262 |
263 | - (BOOL)prefersStatusBarHidden
264 | {
265 | return YES;
266 | }
267 |
268 | -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
269 | {
270 | return UIInterfaceOrientationLandscapeLeft;
271 | }
272 |
273 | - (NSUInteger)supportedInterfaceOrientations
274 | {
275 | return UIInterfaceOrientationMaskLandscape;
276 | }
277 |
278 | - (BOOL)shouldAutorotate {
279 | return NO;
280 | }
281 |
282 | - (BOOL)webView:(UIWebView *)webView2
283 | shouldStartLoadWithRequest:(NSURLRequest *)request
284 | navigationType:(UIWebViewNavigationType)navigationType {
285 |
286 | NSString *requestString = [[[request URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
287 | //NSLog(requestString);
288 |
289 | if ([requestString hasPrefix:@"ios-log:"]) {
290 | NSString* logString = [[requestString componentsSeparatedByString:@":#iOS#"] objectAtIndex:1];
291 | NSLog(@"UIWebView console: %@", logString);
292 | return NO;
293 | }
294 |
295 | return YES;
296 | }
297 |
298 | /*
299 | #pragma mark - Navigation
300 |
301 | // In a storyboard-based application, you will often want to do a little preparation before navigation
302 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
303 | // Get the new view controller using [segue destinationViewController].
304 | // Pass the selected object to the new view controller.
305 | }
306 | */
307 |
308 | @end
309 |
--------------------------------------------------------------------------------
/server/room.go:
--------------------------------------------------------------------------------
1 | package poker
2 |
3 | import (
4 | "fmt"
5 | "sort"
6 | "strconv"
7 | "strings"
8 | "sync"
9 | "time"
10 | )
11 |
12 | const (
13 | actionWait = 20 * time.Second
14 | MaxN = 10
15 | )
16 |
17 | type Room struct {
18 | Id string `json:"id"`
19 | SB int `json:"sb"`
20 | BB int `json:"bb"`
21 | Cards []Card `json:"cards,omitempty"`
22 | Pot []int `json:"pot,omitempty"`
23 | Timeout int `json:"timeout,omitempty"`
24 | Button int `json:"button,omitempty"`
25 | Occupants []*Occupant `json:"occupants,omitempty"`
26 | Chips []int `json:"chips,omitempty"`
27 | Bet int `json:"bet,omitempty"`
28 | N int `json:"n"`
29 | Max int `json:"max"`
30 | MaxChips int `json:"maxchips"`
31 | MinChips int `json:"minchips"`
32 | remain int
33 | allin int
34 | EndChan chan int `json:"-"`
35 | exitChan chan interface{}
36 | lock sync.Mutex
37 | deck *Deck
38 | }
39 |
40 | func NewRoom(id string, max int, sb, bb int) *Room {
41 | if max <= 0 || max > MaxN {
42 | max = 9 // default 9 occupants
43 | }
44 |
45 | room := &Room{
46 | Id: id,
47 | Occupants: make([]*Occupant, max, MaxN),
48 | Chips: make([]int, max, MaxN),
49 | SB: sb,
50 | BB: bb,
51 | Pot: make([]int, 1),
52 | Timeout: 30,
53 | Max: max,
54 | lock: sync.Mutex{},
55 | deck: NewDeck(),
56 | EndChan: make(chan int),
57 | exitChan: make(chan interface{}, 1),
58 | }
59 | go func() {
60 | timer := time.NewTimer(time.Second * 6)
61 | for {
62 | select {
63 | case <-timer.C:
64 | room.start()
65 | timer.Reset(time.Second * 6)
66 | case <-room.exitChan:
67 | return
68 | }
69 | }
70 | }()
71 |
72 | return room
73 | }
74 |
75 | func (room *Room) Cap() int {
76 | return len(room.Occupants)
77 | }
78 |
79 | func (room *Room) Occupant(id string) *Occupant {
80 | for _, o := range room.Occupants {
81 | if o != nil && o.Id == id {
82 | return o
83 | }
84 | }
85 |
86 | return nil
87 | }
88 |
89 | func (room *Room) AddOccupant(o *Occupant) int {
90 | room.lock.Lock()
91 | defer room.lock.Unlock()
92 |
93 | // room not exists
94 | if len(room.Id) == 0 {
95 | return 0
96 | }
97 |
98 | for pos, _ := range room.Occupants {
99 | if room.Occupants[pos] == nil {
100 | room.Occupants[pos] = o
101 | room.N++
102 | o.Room = room
103 | o.Pos = pos + 1
104 | break
105 | }
106 | }
107 |
108 | return o.Pos
109 | }
110 |
111 | func (room *Room) DelOccupant(o *Occupant) {
112 | if o == nil || o.Pos == 0 {
113 | return
114 | }
115 |
116 | room.lock.Lock()
117 | defer room.lock.Unlock()
118 |
119 | room.Occupants[o.Pos-1] = nil
120 | room.N--
121 | if len(o.Cards) > 0 {
122 | room.remain--
123 | }
124 | /*
125 | if o.Action == ActAllin {
126 | room.allin--
127 | }
128 | */
129 |
130 | if room.N == 0 {
131 | DelRoom(room)
132 | select {
133 | case room.exitChan <- 0:
134 | default:
135 | }
136 | }
137 |
138 | if room.remain <= 1 {
139 | select {
140 | case room.EndChan <- 0:
141 | default:
142 | }
143 | }
144 | }
145 |
146 | func (room *Room) Broadcast(message *Message) {
147 | for _, o := range room.Occupants {
148 | if o != nil {
149 | o.SendMessage(message)
150 | }
151 | }
152 | }
153 |
154 | // start starts from 0
155 | func (room *Room) Each(start int, f func(o *Occupant) bool) {
156 | end := (room.Cap() + start - 1) % room.Cap()
157 | i := start
158 | for ; i != end; i = (i + 1) % room.Cap() {
159 | if room.Occupants[i] != nil && !f(room.Occupants[i]) {
160 | return
161 | }
162 | }
163 |
164 | // end
165 | if room.Occupants[i] != nil {
166 | f(room.Occupants[i])
167 | }
168 | }
169 |
170 | func (room *Room) start() {
171 | var dealer *Occupant
172 |
173 | room.Each(0, func(o *Occupant) bool {
174 | if o.Chips < room.BB {
175 | o.Leave()
176 | }
177 | return true
178 | })
179 |
180 | // Select Dealer
181 | button := room.Button - 1
182 | room.Each((button+1)%room.Cap(), func(o *Occupant) bool {
183 | room.Button = o.Pos
184 | dealer = o
185 | return false
186 | })
187 |
188 | if dealer == nil {
189 | return
190 | }
191 |
192 | room.lock.Lock()
193 | if room.N < 2 {
194 | room.lock.Unlock()
195 | return
196 | }
197 |
198 | room.deck.Shuffle()
199 |
200 | // Small Blind
201 | sb := dealer.Next()
202 | if room.N == 2 { // one-to-one
203 | sb = dealer
204 | }
205 | // Big Blind
206 | bb := sb.Next()
207 | bbPos := bb.Pos
208 |
209 | room.Pot = nil
210 | room.Chips = make([]int, room.Max)
211 | room.Bet = 0
212 | room.Cards = nil
213 | room.remain = 0
214 | room.allin = 0
215 | room.Each(0, func(o *Occupant) bool {
216 | o.Bet = 0
217 | o.Cards = []Card{room.deck.Take(), room.deck.Take()}
218 | o.Hand = 0
219 | //o.Action = ActReady
220 | o.Action = ""
221 | room.remain++
222 |
223 | return true
224 | })
225 | room.lock.Unlock()
226 |
227 | room.Broadcast(&Message{
228 | From: room.Id,
229 | Type: MsgPresence,
230 | Action: ActButton,
231 | Class: strconv.Itoa(room.Button),
232 | })
233 |
234 | room.betting(sb.Pos, room.SB)
235 | room.betting(bb.Pos, room.BB)
236 |
237 | // Round 1 : preflop
238 | room.Each(sb.Pos-1, func(o *Occupant) bool {
239 | o.SendMessage(&Message{
240 | From: room.Id,
241 | Type: MsgPresence,
242 | Action: ActPreflop,
243 | Class: o.Cards[0].String() + "," + o.Cards[1].String(),
244 | })
245 | return true
246 | })
247 |
248 | room.action(bbPos%room.Cap() + 1)
249 | if room.remain <= 1 {
250 | goto showdown
251 | }
252 | room.calc()
253 |
254 | // Round 2 : Flop
255 | room.ready()
256 | room.Cards = []Card{
257 | room.deck.Take(),
258 | room.deck.Take(),
259 | room.deck.Take(),
260 | }
261 | room.Each(0, func(o *Occupant) bool {
262 | var hand [5]Card
263 | if len(o.Cards) > 0 {
264 | cards := hand[0:0]
265 | cards = append(cards, o.Cards...)
266 | cards = append(cards, room.Cards...)
267 | o.Hand = Eva5Hand(hand)
268 | }
269 | o.SendMessage(&Message{
270 | From: room.Id,
271 | Type: MsgPresence,
272 | Action: ActFlop,
273 | Class: fmt.Sprintf("%s,%s,%s,%d", room.Cards[0], room.Cards[1], room.Cards[2], o.Hand>>16),
274 | })
275 |
276 | return true
277 | })
278 |
279 | room.action(0)
280 |
281 | if room.remain <= 1 {
282 | goto showdown
283 | }
284 | room.calc()
285 |
286 | // Round 3 : Turn
287 | room.ready()
288 | room.Cards = append(room.Cards, room.deck.Take())
289 | room.Each(0, func(o *Occupant) bool {
290 | var hand [6]Card
291 | if len(o.Cards) > 0 {
292 | cards := hand[0:0]
293 | cards = append(cards, o.Cards...)
294 | cards = append(cards, room.Cards...)
295 | o.Hand = Eva6Hand(hand)
296 | }
297 | o.SendMessage(&Message{
298 | From: room.Id,
299 | Type: MsgPresence,
300 | Action: ActTurn,
301 | Class: fmt.Sprintf("%s,%d", room.Cards[3], o.Hand>>16),
302 | })
303 |
304 | return true
305 | })
306 | room.action(0)
307 | if room.remain <= 1 {
308 | goto showdown
309 | }
310 | room.calc()
311 |
312 | // Round 4 : River
313 | room.ready()
314 | room.Cards = append(room.Cards, room.deck.Take())
315 | room.Each(0, func(o *Occupant) bool {
316 | var hand [7]Card
317 | if len(o.Cards) > 0 {
318 | cards := hand[0:0]
319 | cards = append(cards, o.Cards...)
320 | cards = append(cards, room.Cards...)
321 | o.Hand = Eva7Hand(hand)
322 | }
323 | o.SendMessage(&Message{
324 | From: room.Id,
325 | Type: MsgPresence,
326 | Action: ActRiver,
327 | Class: fmt.Sprintf("%s,%d", room.Cards[4], o.Hand>>16),
328 | })
329 |
330 | return true
331 | })
332 | room.action(0)
333 |
334 | showdown:
335 | room.showdown()
336 | // Final : Showdown
337 | room.Broadcast(&Message{
338 | From: room.Id,
339 | Type: MsgPresence,
340 | Action: ActShowdown,
341 | Room: room,
342 | })
343 | }
344 |
345 | func (room *Room) action(pos int) {
346 | if room.allin+1 >= room.remain {
347 | return
348 | }
349 |
350 | skip := 0
351 | if pos == 0 { // start from left hand of button
352 | pos = (room.Button)%room.Cap() + 1
353 | }
354 |
355 | for {
356 | raised := 0
357 |
358 | room.Each(pos-1, func(o *Occupant) bool {
359 | if room.remain <= 1 {
360 | return false
361 | }
362 |
363 | if o.Pos == skip || o.Chips == 0 || len(o.Cards) == 0 {
364 | return true
365 | }
366 |
367 | room.Broadcast(&Message{
368 | From: room.Id,
369 | Type: MsgPresence,
370 | Action: ActAction,
371 | Class: fmt.Sprintf("%d,%d", o.Pos, room.Bet),
372 | })
373 |
374 | msg, _ := o.GetAction(time.Duration(room.Timeout) * time.Second)
375 | if room.remain <= 1 {
376 | return false
377 | }
378 |
379 | n := 0
380 | // timeout or leave
381 | if msg == nil || len(msg.Class) == 0 {
382 | n = -1
383 | } else {
384 | n, _ = strconv.Atoi(msg.Class)
385 | }
386 |
387 | if room.betting(o.Pos, n) {
388 | raised = o.Pos
389 | return false
390 | }
391 |
392 | return true
393 | })
394 |
395 | if raised == 0 {
396 | break
397 | }
398 |
399 | pos = raised
400 | skip = pos
401 | }
402 | }
403 |
404 | func (room *Room) calc() (pots []handPot) {
405 | pots = calcPot(room.Chips)
406 | room.Pot = nil
407 | var ps []string
408 | for _, pot := range pots {
409 | room.Pot = append(room.Pot, pot.Pot)
410 | ps = append(ps, strconv.Itoa(pot.Pot))
411 | }
412 |
413 | room.Broadcast(&Message{
414 | From: room.Id,
415 | Type: MsgPresence,
416 | Action: ActPot,
417 | Class: strings.Join(ps, ","),
418 | })
419 |
420 | return
421 | }
422 |
423 | func (room *Room) showdown() {
424 | pots := room.calc()
425 |
426 | for i, _ := range room.Chips {
427 | room.Chips[i] = 0
428 | }
429 |
430 | room.lock.Lock()
431 | defer room.lock.Unlock()
432 |
433 | for _, pot := range pots {
434 | maxHand := 0
435 | for _, pos := range pot.OPos {
436 | o := room.Occupants[pos-1]
437 | if o != nil && o.Hand > maxHand {
438 | maxHand = o.Hand
439 | }
440 | }
441 |
442 | var winners []int
443 |
444 | for _, pos := range pot.OPos {
445 | o := room.Occupants[pos-1]
446 | if o != nil && o.Hand == maxHand && len(o.Cards) > 0 {
447 | winners = append(winners, pos)
448 | }
449 | }
450 |
451 | if len(winners) == 0 {
452 | fmt.Println("!!!no winners!!!")
453 | return
454 | }
455 |
456 | for _, winner := range winners {
457 | room.Chips[winner-1] += pot.Pot / len(winners)
458 | }
459 | room.Chips[winners[0]-1] += pot.Pot % len(winners) // odd chips
460 | }
461 |
462 | for i, _ := range room.Chips {
463 | if room.Occupants[i] != nil {
464 | room.Occupants[i].Chips += room.Chips[i]
465 | }
466 | }
467 | }
468 |
469 | func (room *Room) ready() {
470 | room.Bet = 0
471 | room.lock.Lock()
472 | defer room.lock.Unlock()
473 |
474 | room.Each(0, func(o *Occupant) bool {
475 | o.Bet = 0
476 | /*
477 | if o.Action == ActAllin || o.Action == ActFold || o.Action == "" {
478 | return true
479 | }
480 | o.Action = ActReady
481 | */
482 | return true
483 | })
484 |
485 | }
486 |
487 | func (room *Room) betting(pos, n int) (raised bool) {
488 | if pos <= 0 {
489 | return
490 | }
491 |
492 | room.lock.Lock()
493 | defer room.lock.Unlock()
494 |
495 | o := room.Occupants[pos-1]
496 | if o == nil {
497 | return
498 | }
499 | raised = o.Betting(n)
500 | if o.Action == ActFold {
501 | room.remain--
502 | }
503 | if o.Action == ActAllin {
504 | room.allin++
505 | }
506 |
507 | room.Broadcast(&Message{
508 | Id: room.Id,
509 | Type: MsgPresence,
510 | From: o.Id,
511 | Action: ActBet,
512 | Class: o.Action + "," + strconv.Itoa(o.Bet) + "," + strconv.Itoa(o.Chips),
513 | })
514 |
515 | return
516 | }
517 |
518 | type roomlist struct {
519 | M map[int]*Room
520 | counter int
521 | lock sync.Mutex
522 | }
523 |
524 | func NewRoomList() *roomlist {
525 | return &roomlist{
526 | M: make(map[int]*Room),
527 | counter: 1000,
528 | lock: sync.Mutex{},
529 | }
530 | }
531 |
532 | var (
533 | rooms = NewRoomList()
534 | )
535 |
536 | func SetRoom(room *Room) {
537 | rooms.lock.Lock()
538 | defer rooms.lock.Unlock()
539 |
540 | setRoom(room)
541 | }
542 |
543 | func setRoom(room *Room) {
544 | id, _ := strconv.Atoi(room.Id)
545 | if id == 0 {
546 | rooms.counter++
547 | id = rooms.counter
548 | room.Id = strconv.Itoa(id)
549 | }
550 | rooms.M[id] = room
551 | }
552 |
553 | func GetRoom(id string) *Room {
554 | rooms.lock.Lock()
555 | defer rooms.lock.Unlock()
556 |
557 | nid, _ := strconv.Atoi(id)
558 | room := rooms.M[nid]
559 | if room == nil {
560 | for _, v := range rooms.M {
561 | if v.N < v.Max {
562 | return v
563 | }
564 | }
565 | room = NewRoom("", 9, 5, 10)
566 | setRoom(room)
567 | }
568 |
569 | return room
570 | }
571 |
572 | func DelRoom(room *Room) {
573 | rooms.lock.Lock()
574 | defer rooms.lock.Unlock()
575 |
576 | id, _ := strconv.Atoi(room.Id)
577 | delete(rooms.M, id)
578 | room.Id = ""
579 | }
580 |
581 | func Rooms() (r []*Room) {
582 | rooms.lock.Lock()
583 | defer rooms.lock.Unlock()
584 |
585 | r = make([]*Room, 0, len(rooms.M))
586 |
587 | ids := make([]int, 0, len(rooms.M))
588 | for k := range rooms.M {
589 | ids = append(ids, k)
590 | }
591 |
592 | sort.Sort(sort.Reverse(sort.IntSlice(ids)))
593 | for _, id := range ids {
594 | r = append(r, rooms.M[id])
595 | }
596 |
597 | return
598 | }
599 |
--------------------------------------------------------------------------------
/iOS/Pocker/Pocker/PokerViewControllerEx.m:
--------------------------------------------------------------------------------
1 | //
2 | // PokerViewController.m
3 | // Pocker
4 | //
5 | // Created by zhengying on 3/13/15.
6 | // Copyright (c) 2015 zhengying. All rights reserved.
7 | //
8 |
9 | #import "PokerViewControllerEx.h"
10 | #import "WebViewJavascriptBridge.h"
11 | #import "SettingViewController.h"
12 | #import "DQAlertView.h"
13 |
14 | #define STRING_IS_EMPTY(str) ((str) == nil || [(str) isEqualToString:@""])
15 | #define IOSVersionAbove(version) (([[[UIDevice currentDevice] systemVersion] intValue] >= version)? 1 : 0 )
16 |
17 |
18 | static const NSString* kUserName = @"user_name";
19 | static const NSString* kServer = @"ws_server";
20 | static const NSString* kToken = @"app_token";
21 | static const NSString* kJoinRoom = @"joinroom";
22 |
23 | @interface PokerViewControllerEx ()
24 |
25 | @end
26 |
27 | @implementation PokerViewControllerEx {
28 | WebViewJavascriptBridge* _bridge;
29 | NSMutableDictionary* _dictConfig;
30 | UIButton* _buttonQuit;
31 |
32 | }
33 |
34 | -(void)loadView {
35 | self.view = [[UIView alloc]init];
36 |
37 | _webView = [[UIWebView alloc]init];
38 | [_webView setTranslatesAutoresizingMaskIntoConstraints:NO];
39 | _webView.backgroundColor = [UIColor blackColor];
40 |
41 | _buttonQuit = [[UIButton alloc]init];
42 | [_buttonQuit setTitle:@"退出" forState:UIControlStateNormal];
43 | [_buttonQuit addTarget:self action:@selector(actionQuit:) forControlEvents:UIControlEventTouchUpInside];
44 | [_buttonQuit setTranslatesAutoresizingMaskIntoConstraints:NO];
45 |
46 | [self.view addSubview:_webView];
47 | [self.view addSubview:_buttonQuit];
48 |
49 | NSDictionary *views = @{@"selfView":self.view, @"webView":_webView, @"quitButton":_buttonQuit};
50 |
51 |
52 | [self.view addConstraints:[NSLayoutConstraint
53 | constraintsWithVisualFormat:@"H:|[webView(selfView)]"
54 | options:0
55 | metrics:nil
56 | views:views]];
57 |
58 |
59 | [self.view addConstraints:[NSLayoutConstraint
60 | constraintsWithVisualFormat:@"V:|[webView(selfView)]"
61 | options:0
62 | metrics:nil
63 | views:views]];
64 |
65 | [self.view addConstraints:[NSLayoutConstraint
66 | constraintsWithVisualFormat:@"V:|-10-[quitButton]"
67 | options:0
68 | metrics:nil
69 | views:views]];
70 |
71 | [self.view addConstraints:[NSLayoutConstraint
72 | constraintsWithVisualFormat:@"H:|-10-[quitButton]"
73 | options:0
74 | metrics:nil
75 | views:views]];
76 |
77 | }
78 |
79 |
80 | - (void)didReceiveMemoryWarning {
81 | [super didReceiveMemoryWarning];
82 | // Dispose of any resources that can be recreated.
83 | }
84 |
85 | /*
86 | -(void)startWithCreateByToken:(NSString*)token FinishedBlock:(void(^)(NSString* rootID))finishBlock {
87 | NSAssert(STRING_IS_EMPTY(token) == false, @"token is empty");
88 | _token = token;
89 | }
90 |
91 | -(void)startWithJoinRoot:(NSString*)roomID ByToken:(NSString*)token FinishedBlock:(void(^)())finishBlock {
92 | NSAssert(STRING_IS_EMPTY(token) == false, @"token is empty");
93 | NSAssert(STRING_IS_EMPTY(roomID), @"token is empty");
94 | _token = token;
95 | _joinroom = roomID;
96 | }
97 | */
98 |
99 | -(void)loadNativeSetting {
100 | BOOL linodeEnable = [[NSUserDefaults standardUserDefaults]boolForKey:@"linode_enable"];
101 | NSString* userName = [[NSUserDefaults standardUserDefaults]stringForKey:@"user_name"];
102 |
103 | if (!userName || [userName isEqualToString:@""]) {
104 | userName = @"TestUSER";
105 | [[NSUserDefaults standardUserDefaults]setObject:userName forKey:@"user_name"];
106 | }
107 |
108 | if(!_token) {
109 | _token = userName;
110 | }
111 |
112 |
113 | NSString* server = @"172.24.222.54:8989/ws";
114 |
115 | if (linodeEnable) {
116 | server = @"106.187.48.51:8989/ws";
117 | }
118 |
119 | if (userName) {
120 | _dictConfig[kUserName] = userName;
121 | }
122 |
123 | if (server) {
124 | _dictConfig[kServer] = server;
125 | }
126 |
127 | if (_token) {
128 | _dictConfig[kToken] = _token;
129 | }
130 |
131 | if (_joinroom) {
132 | _dictConfig[kJoinRoom] = _joinroom;
133 | }
134 | }
135 |
136 | -(UIView*)addMaskLayerToSelfView {
137 | UIView* viewMask = [[UIView alloc]initWithFrame:CGRectMake(100, 0, self.view.frame.size.height, self.view.frame.size.width)];
138 | viewMask.backgroundColor = [UIColor colorWithRed:200 green:100 blue:100 alpha:0.0];
139 | [self.view addSubview:viewMask];
140 | [viewMask setTranslatesAutoresizingMaskIntoConstraints:NO];
141 | NSDictionary *views = @{@"selfView":self.view, @"maskView":viewMask};
142 |
143 | [self.view addConstraints:[NSLayoutConstraint
144 | constraintsWithVisualFormat:@"H:|[maskView(selfView)]"
145 | options:0
146 | metrics:nil
147 | views:views]];
148 |
149 |
150 | [self.view addConstraints:[NSLayoutConstraint
151 | constraintsWithVisualFormat:@"V:|[maskView(selfView)]"
152 | options:0
153 | metrics:nil
154 | views:views]];
155 | [self.view layoutIfNeeded];
156 | return viewMask;
157 | }
158 |
159 | -(void)registerWebHandle {
160 |
161 | [WebViewJavascriptBridge enableLogging];
162 |
163 | _bridge = [WebViewJavascriptBridge bridgeForWebView:_webView webViewDelegate:self handler:^(id data, WVJBResponseCallback responseCallback) {
164 | NSLog(@"ObjC received message from JS: %@", data);
165 | responseCallback(@"Response for message from ObjC");
166 | }];
167 |
168 |
169 | __weak __typeof(self) weakSelf = self;
170 |
171 | // getNativeConfig
172 | [_bridge registerHandler:@"getNativeConfig" handler:^(id data, WVJBResponseCallback responseCallback) {
173 | __typeof(self) strongSelf = weakSelf;
174 | [weakSelf loadNativeSetting];
175 | responseCallback(strongSelf->_dictConfig);
176 | }];
177 |
178 | // quitToApp
179 | [_bridge registerHandler:@"quitToApp" handler:^(id data, WVJBResponseCallback responseCallback) {
180 | [weakSelf dismissViewControllerAnimated:YES completion:nil];
181 | }];
182 |
183 | // pop user detail
184 | [_bridge registerHandler:@"showProfile" handler:^(id data, WVJBResponseCallback responseCallback) {
185 | // NSString* userID = data[@"userid"];
186 | // TODO: pop user profile window;
187 | //try pop a window
188 | /*
189 | UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
190 | SettingViewController *settings = (SettingViewController*)[storyboard instantiateViewControllerWithIdentifier:@"Settings"];
191 |
192 |
193 | [weakSelf presentViewController:settings animated:YES completion:nil];
194 | */
195 |
196 | if (_profileShowBlock) {
197 | NSString* userID = data[@"userid"];
198 | _profileShowBlock(userID);
199 | }
200 | }];
201 |
202 |
203 | // show common popup window
204 | [_bridge registerHandler:@"confrimPopupWindow" handler:^(id data, WVJBResponseCallback responseCallback) {
205 | NSString* popMessageID = data[@"id"];
206 | NSString* popTitle = data[@"pop_title"];
207 | NSString* popText = data[@"pop_text"];
208 | NSString* popButton1Text = data[@"pop_btn1_text"];
209 | DQAlertView* alertView = [[DQAlertView alloc]initWithTitle:popTitle message:popText delegate:self cancelButtonTitle:popButton1Text otherButtonTitles:nil];
210 |
211 | UIView* maskView = [self addMaskLayerToSelfView];
212 |
213 | __weak DQAlertView* alertViewSelf = alertView;
214 |
215 | alertView.cancelButtonAction = ^{
216 | responseCallback(@{@"buttonclick":@"popButton1"});
217 | [alertViewSelf.superview removeFromSuperview];
218 |
219 | };
220 | [alertView showInView:maskView];
221 | }];
222 |
223 | // show yesorno popup window
224 | [_bridge registerHandler:@"yesOrNoPopupWindow" handler:^(id data, WVJBResponseCallback responseCallback) {
225 | NSString* popMessageID = data[@"id"];
226 | NSString* popTitle = data[@"pop_title"];
227 | NSString* popText = data[@"pop_text"];
228 | NSString* popButton1Text = data[@"pop_btn1_text"];
229 | NSString* popButton2Text = data[@"pop_btn2_text"];
230 | //UIView* viewMask = [[UIView alloc]initWithFrame:CGRectMake(100, 0, self.view.frame.size.height, self.view.frame.size.width)];
231 | //viewMask.center = self.view.center;
232 |
233 | UIView* maskView = [self addMaskLayerToSelfView];
234 |
235 | DQAlertView* alertView = [[DQAlertView alloc]initWithTitle:popTitle message:popText delegate:self cancelButtonTitle:popButton1Text otherButtonTitles:popButton2Text];
236 |
237 | __weak DQAlertView* alertViewSelf = alertView;
238 |
239 | alertView.cancelButtonAction = ^{
240 | NSLog(@"Cancel Clicked");
241 | responseCallback(@{@"sender":@"popButton1"});
242 | [alertViewSelf.superview removeFromSuperview];
243 | };
244 | alertView.otherButtonAction = ^{
245 | NSLog(@"OK Clicked");
246 | responseCallback(@{@"sender":@"popButton2"});
247 | [alertViewSelf dismiss];
248 | [alertViewSelf.superview removeFromSuperview];
249 | };
250 | [alertView showInView:maskView];
251 | }];
252 | }
253 |
254 | - (void)viewDidLoad {
255 | [super viewDidLoad];
256 |
257 |
258 | _dictConfig = [[NSMutableDictionary alloc]init];
259 | [self registerWebHandle];
260 | [self loadHTMLToWebKit];
261 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(actionSettingUpdated:) name:@"SettingUpdate" object:nil];
262 | }
263 |
264 | -(void)viewWillAppear:(BOOL)animated {
265 | self.navigationController.navigationBarHidden = YES;
266 | [super viewWillAppear:animated];
267 | }
268 |
269 |
270 | -(void)loadHTMLToWebKit {
271 | [_webView stopLoading];
272 | NSString* PokerPath = [[[NSBundle mainBundle] resourcePath]stringByAppendingPathComponent:@"Poker"];
273 | NSString* pokerIndex = [PokerPath stringByAppendingPathComponent:@"index.html"];
274 | NSString* indexPageContent = [NSString stringWithContentsOfURL:[NSURL fileURLWithPath:pokerIndex]
275 | encoding:NSUTF8StringEncoding error:nil];
276 |
277 | indexPageContent = [indexPageContent stringByReplacingOccurrencesOfString:@"__PLAT__" withString:@"IOS"];
278 |
279 | [_webView loadHTMLString:indexPageContent baseURL:[NSURL fileURLWithPath:PokerPath]];
280 | }
281 |
282 |
283 | -(void)loadGame {
284 | //[self registerWebHandle];
285 | [self loadHTMLToWebKit];
286 | }
287 |
288 |
289 | -(void)actionSettingUpdated:(NSNotification* )notification {
290 | //[_bridge callHandler:@"reload"];
291 | [self loadGame];
292 | }
293 |
294 | -(IBAction)actionQuit:(id)sender {
295 | [_bridge callHandler:@"quitApp"];
296 | }
297 |
298 |
299 | - (UIStatusBarStyle)preferredStatusBarStyle
300 | {
301 | return UIStatusBarStyleLightContent;
302 | }
303 |
304 |
305 | -(IBAction)actionReload:(id)sender {
306 | //[_bridge callHandler:@"reload"];
307 | [self loadGame];
308 | }
309 |
310 | - (BOOL)prefersStatusBarHidden
311 | {
312 | return YES;
313 | }
314 |
315 | -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
316 | {
317 | return UIInterfaceOrientationLandscapeLeft;
318 | }
319 |
320 | - (NSUInteger)supportedInterfaceOrientations
321 | {
322 | return UIInterfaceOrientationMaskLandscape;
323 | }
324 |
325 | - (BOOL)shouldAutorotate {
326 | return NO;
327 | }
328 |
329 | - (BOOL)webView:(UIWebView *)webView2
330 | shouldStartLoadWithRequest:(NSURLRequest *)request
331 | navigationType:(UIWebViewNavigationType)navigationType {
332 |
333 | NSString *requestString = [[[request URL] absoluteString] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
334 | //NSLog(requestString);
335 |
336 | if ([requestString hasPrefix:@"ios-log:"]) {
337 | NSString* logString = [[requestString componentsSeparatedByString:@":#iOS#"] objectAtIndex:1];
338 | NSLog(@"UIWebView console: %@", logString);
339 | return NO;
340 | }
341 |
342 | return YES;
343 | }
344 |
345 | /*
346 | #pragma mark - Navigation
347 |
348 | // In a storyboard-based application, you will often want to do a little preparation before navigation
349 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
350 | // Get the new view controller using [segue destinationViewController].
351 | // Pass the selected object to the new view controller.
352 | }
353 | */
354 |
355 | @end
356 |
--------------------------------------------------------------------------------
/Poker/loginState.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var strVersion = "1.0";
4 | var userName = "cmdTest";
5 | var userID = "";
6 | var loginCertification = false;
7 |
8 | function getCookie(name)
9 | {
10 | var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
11 |
12 | if(arr = document.cookie.match(reg))
13 | return (decodeURI(arr[2]));
14 | else
15 | return null;
16 | }
17 |
18 | function setCookie(name, value)
19 | {
20 | var Days = 30;
21 | var exp = new Date();
22 | exp.setTime(exp.getTime() + Days*24*60*60*1000);
23 | var str = name + "="+ encodeURI(value) + "; expires=" + exp.toGMTString();
24 | document.cookie = str;
25 | }
26 |
27 | var callbackOpen = function(data)
28 | {
29 | console.log("callbackOpen " + data);
30 |
31 | game.betApi.checkVersion(strVersion, function(isOK){
32 | console.log("checkVersion " + isOK);
33 | });
34 | };
35 |
36 | var callbackClose = function(data)
37 | {
38 | console.log("callbackClose " + data);
39 | loginCertification = false;
40 |
41 | game.state.states["MainState"]._disconnectReset();
42 | };
43 |
44 | var callbackMessage = function(data)
45 | {
46 | console.log("callbackMessage " + data);
47 | if(data.version && data.version == strVersion) // checkVersion result
48 | {
49 | game.state.states["LoginState"].initUserName();
50 | }
51 | else if(!loginCertification) // loginCertification result
52 | {
53 | if(data.id)
54 | {
55 | userID = data.id;
56 | game.state.states["MainState"].userID = userID
57 | game.betApi.setUserID(userID);
58 | loginCertification = true;
59 |
60 | var LoginState = game.state.states["LoginState"];
61 | LoginState.hanldeInitUserName();
62 | }
63 | }
64 | else if(data.type == "iq")
65 | {
66 | if(data.class == "room") //查询游戏房间列表
67 | {
68 | game.state.states["LoginState"].handleCreateRoom(data);
69 | }
70 | else if(data.class == "roomlist") //查询游戏房间列表
71 | {
72 | game.state.states["LoginState"].handleGetRoomList(data);
73 | }
74 | else if(data.class == "room") //查询游戏房间信息
75 | {
76 |
77 | }
78 | else if(data.class == "occupant") //查询玩家信息
79 | {
80 |
81 | }
82 | }
83 | else if(data.type == "message")
84 | {
85 | }
86 | else if(data.type == "presence")
87 | {
88 | if(data.action == "active") //服务器广播进入房间的玩家
89 | {
90 | }
91 | else if(data.action == "gone") //服务器广播离开房间的玩家
92 | {
93 | game.state.states["MainState"].handleGone(data);
94 | }
95 | else if(data.action == "join") //服务器通报加入游戏的玩家
96 | {
97 | game.state.states["MainState"].handleJoin(data);
98 | }
99 | else if(data.action == "button") //服务器通报本局庄家
100 | {
101 | game.state.states["MainState"].handleButton(data);
102 | }
103 | else if(data.action == "preflop") //服务器通报发牌
104 | {
105 | game.state.states["MainState"].handlePreflop(data);
106 | }
107 | else if(data.action == "flop") //发牌
108 | {
109 | game.state.states["MainState"].handleFlop(data);
110 | }
111 | else if(data.action == "turn") //发牌
112 | {
113 | game.state.states["MainState"].handleTurn(data);
114 | }
115 | else if(data.action == "river") //发牌
116 | {
117 | game.state.states["MainState"].handleRiver(data);
118 | }
119 | else if(data.action == "pot") //服务器通报奖池
120 | {
121 | game.state.states["MainState"].handlePot(data);
122 | }
123 | else if(data.action == "action") //服务器通报当前下注玩家
124 | {
125 | game.state.states["MainState"].handleAction(data);
126 |
127 | }
128 | else if(data.action == "bet") //服务器通报玩家下注结果
129 | {
130 | game.state.states["MainState"].handleBet(data);
131 |
132 | }
133 | else if(data.action == "showdown") //服务器通报摊牌和比牌
134 | {
135 | game.state.states["MainState"].handleShowDown(data);
136 | }
137 | else if(data.action == "state") //服务器通报房间信息
138 | {
139 | game.state.states["MainState"].handleState(data);
140 | }
141 | }
142 | };
143 |
144 | var callbackError = function(data)
145 | {
146 | console.log("callbackError" + data);
147 | };
148 |
149 | var LoginState = function() {
150 |
151 | this.scale; //全局缩放比
152 | this.group;
153 | this.currentPage = 0;
154 | this.CountPerPage = 10;
155 | this.currentSelectRoomID = -1;
156 | this.roomInfoList;
157 |
158 | this.roomList;
159 | this.roomTextList;
160 | this.btnPrev;
161 | this.btnNext;
162 | this.leName;
163 | this.leRoomName;
164 | this.leChangeName;
165 | this.btnChangeName;
166 | this.btnLogin;
167 | this.btnCreate;
168 |
169 | this.textPrev;
170 | this.tectNext;
171 | this.textLogin;
172 | this.tectCreate;
173 | };
174 |
175 | LoginState.prototype = {
176 |
177 | preload: function () {
178 | game.load.image("gamecenterbackground", gImageDir+'background.png');
179 | game.load.image('buttonblue', gImageDir+'btn-blue.png');
180 | game.load.image('buttongrey', gImageDir+'btn-grey.png');
181 | game.load.image('buttonyellow', gImageDir+'btn-yellow.png');
182 | },
183 |
184 | create: function () {
185 |
186 | game.betApi.connect();
187 | game.betApi.registerCallback(callbackOpen, callbackClose, callbackMessage, callbackError);
188 |
189 | var imageBK = game.add.image(0, 0, "gamecenterbackground");
190 | imageBK.visible = false;
191 | var xScale = game.width / imageBK.width;
192 | var yScale = game.height / imageBK.height;
193 | this.scale = xScale < yScale ? xScale : yScale;
194 | loginCertification = false;
195 |
196 | this.roomInfoList = [];
197 | this.roomList = [];
198 | this.roomTextList = [];
199 | this.group = game.add.group();
200 | var listWidth = game.width / 2;
201 | var listItemHeight = game.height / 12;
202 | var style = { font: _fontString(16), fill: "#0069B2", wordWrapWidth: listWidth * 0.9, align: "left"};
203 | for(var i = 0; i < 10; i++)
204 | {
205 | var listItem = game.add.button(0, i * listItemHeight, 'buttonblue', this.selectRoom);
206 | listItem.width = listWidth;
207 | listItem.height = listItemHeight;
208 | listItem.roomID = "";
209 | listItem.visible = false;
210 | this.roomList.push(listItem);
211 | var roomInfo = game.add.text(listItem.x + 0.05 * listItem.width, listItem.y + 0.45 * listItem.height, "", style);
212 | roomInfo.scale.setTo(this.scale);
213 | roomInfo.anchor.set(0, 0.5);
214 | roomInfo.visible = false;
215 | this.roomTextList.push(roomInfo);
216 | this.group.add(listItem);
217 | this.group.add(roomInfo);
218 | }
219 |
220 | this.btnPrev = game.add.button(0, 10 * listItemHeight, 'buttonyellow', this.clickPrev, this);
221 | this.btnPrev.width = listWidth / 2;
222 | this.btnPrev.height = listItemHeight;
223 | this.btnNext = game.add.button(listWidth / 2, 10 * listItemHeight, 'buttonyellow', this.clickNext, this);
224 | this.btnNext.width = listWidth / 2;
225 | this.btnNext.height = listItemHeight;
226 | style = { font: _fontString(28), fill: "#CE8D00"};
227 | this.textPrev = game.add.text(this.btnPrev.x + 0.5 * this.btnPrev.width, this.btnPrev.y + 0.5 * this.btnPrev.height, "上一页", style);
228 | this.textPrev.anchor.set(0.5);
229 | this.textPrev.scale.setTo(this.scale);
230 | this.tectNext = game.add.text(this.btnNext.x + 0.5 * this.btnNext.width, this.btnNext.y + 0.5 * this.btnNext.height, "下一页", style);
231 | this.tectNext.anchor.set(0.5);
232 | this.tectNext.scale.setTo(this.scale);
233 | this.group.add(this.btnPrev);
234 | this.group.add(this.btnNext);
235 | this.group.add(this.textPrev);
236 | this.group.add(this.tectNext);
237 |
238 | this.leName = game.add.text(listWidth * 1.2, game.height * 0.1, "用户名: " + userName, style);
239 | this.leName.scale.setTo(this.scale);
240 | this.leRoomName = game.add.text(listWidth * 1.2, game.height * 0.3, "房间名: ", style);
241 | this.leRoomName.scale.setTo(this.scale);
242 | this.group.add(this.leName);
243 | this.group.add(this.leRoomName);
244 |
245 | this.btnChangeName = game.add.button(listWidth * 1.2, game.height * 0.2, 'buttonyellow', this.clickRename, this);
246 | this.btnChangeName.width = listWidth / 2;
247 | this.btnChangeName.height = listItemHeight;
248 | this.leChangeName = game.add.text(this.btnChangeName.x + this.btnChangeName.width / 2, this.btnChangeName.y + this.btnChangeName.height / 2, "重命名", style);
249 | this.leChangeName.anchor.setTo(0.5);
250 | this.leChangeName.scale.setTo(this.scale);
251 | this.group.add(this.btnChangeName);
252 | this.group.add(this.leChangeName);
253 |
254 | this.btnLogin = game.add.button(listWidth * 1.2, game.height * 0.4, 'buttonyellow', this.clickLogin, this);
255 | this.btnLogin.width = listWidth / 2;
256 | this.btnLogin.height = listItemHeight;
257 | this.btnCreate = game.add.button(listWidth * 1.2, game.height * 0.5, 'buttonyellow', this.clickCreate, this);
258 | this.btnCreate.width = listWidth / 2;
259 | this.btnCreate.height = listItemHeight;
260 | this.textLogin = game.add.text(this.btnLogin.x + 0.5 * this.btnLogin.width, this.btnLogin.y + 0.5 * this.btnLogin.height, "进入房间", style);
261 | this.textLogin.anchor.set(0.5);
262 | this.textLogin.scale.setTo(this.scale);
263 | this.tectCreate = game.add.text(this.btnCreate.x + 0.5 * this.btnCreate.width, this.btnCreate.y + 0.5 * this.btnCreate.height, "建立房间", style);
264 | this.tectCreate.anchor.set(0.5);
265 | this.tectCreate.scale.setTo(this.scale);
266 | this.group.add(this.btnLogin);
267 | this.group.add(this.btnCreate);
268 | this.group.add(this.textLogin);
269 | this.group.add(this.tectCreate);
270 | this.group.visible = false;
271 | },
272 |
273 | initUserName:function()
274 | {
275 | var name = ""
276 |
277 | if (gParam.user_name != null && gParam.user_name != "") {
278 | name = gParam.user_name;
279 | } else {
280 | name = getCookie("name");
281 | }
282 |
283 | if(!name || name.length == 0)
284 | {
285 | name = prompt("请输入您的名字","");
286 | }
287 | if(name)
288 | {
289 | userName = name;
290 | setCookie("name", userName);
291 | game.betApi.loginCertification(userName, function(isOK){
292 | console.log("loginCertification is " + isOK);
293 | if(!isOK)
294 | {
295 | userName = "";
296 | }
297 | });
298 | }
299 | else
300 | {
301 | this.initUserName();
302 | }
303 | },
304 |
305 | hanldeInitUserName:function()
306 | {
307 | var text = "用户名: " + userName;
308 | this.leName.setText(text);
309 | this.group.visible = true;
310 | game.betApi.getRoomList();
311 | },
312 |
313 | handleCreateRoom:function(data)
314 | {
315 | this.currentSelectRoomID = data.room.id;
316 | this.clickLogin();
317 | },
318 |
319 | handleGetRoomList:function(data)
320 | {
321 | this.roomInfoList = data.rooms;
322 | if(!this.roomInfoList)
323 | {
324 | this.roomInfoList = [];
325 | }
326 |
327 | while(this.CountPerPage * this.currentPage > this.roomInfoList.length)
328 | {
329 | this.currentPage--;
330 | }
331 |
332 | for(var i = 0; i < this.CountPerPage; i++)
333 | {
334 | if(i + this.CountPerPage * this.currentPage < this.roomInfoList.length)
335 | {
336 | this.roomList[i].visible = true;
337 | this.roomTextList[i].visible = true;
338 | var index = i + this.CountPerPage * this.currentPage;
339 | this.roomList[i].roomID = this.roomInfoList[index].id;
340 | var strTitle = "房间ID: " + this.roomInfoList[index].id + "\n小盲注: " + this.roomInfoList[index].sb + "; 大盲注: " + this.roomInfoList[index].bb + "; 当前人数: " + this.roomInfoList[index].n + "; 最大人数: " + this.roomInfoList[index].max;
341 | this.roomTextList[i].setText(strTitle);
342 | }
343 | else
344 | {
345 | this.roomList[i].visible = false;
346 | this.roomTextList[i].visible = false;
347 | }
348 | }
349 | },
350 |
351 | selectRoom:function()
352 | {
353 | var text = "房间名: " + this.roomID;
354 | game.state.states["LoginState"].leRoomName.setText(text);
355 | game.state.states["LoginState"].currentSelectRoomID = this.roomID;
356 | },
357 |
358 | clickPrev:function()
359 | {
360 | if(this.currentPage == 0)
361 | {
362 | return;
363 | }
364 |
365 | this.currentPage--;
366 | game.betApi.getRoomList();
367 | },
368 |
369 | clickNext:function()
370 | {
371 | this.currentPage++;
372 | game.betApi.getRoomList();
373 | },
374 |
375 | clickRename:function()
376 | {
377 | setCookie("name", "");
378 | location.reload();
379 | },
380 |
381 | clickLogin:function()
382 | {
383 | if(this.currentSelectRoomID < 0)
384 | {
385 | alert("请选择一个房间!");
386 | return;
387 | }
388 |
389 | game.betApi.setRoomID(this.currentSelectRoomID);
390 | game.state.start("MainState");
391 | },
392 |
393 | clickCreate:function()
394 | {
395 | game.betApi.createRoom("", 5, 10, 30, 9);
396 | }
397 | };
--------------------------------------------------------------------------------