├── .editorconfig
├── .gitignore
├── README.md
├── bin
└── player3.app
│ └── Contents
│ ├── Info.plist
│ ├── MacOS
│ └── player3
│ ├── PkgInfo
│ └── Resources
│ ├── ConsoleWindow.nib
│ ├── Icon.icns
│ └── en.lproj
│ └── MainMenu.nib
├── ddz
├── .gitignore
├── .project
├── config.json
├── res
│ ├── README.txt
│ ├── fonts
│ │ ├── STFONT.ttf
│ │ └── arial.ttf
│ ├── textures
│ │ ├── Common_BG1_2x.png
│ │ ├── Common_ContinueWin_2x.png
│ │ ├── ContinueWinProp_2x.png
│ │ ├── HLDDZ_Activity_Center_2x.png
│ │ ├── HLDDZ_Anim_2x.png
│ │ ├── HLDDZ_Avatar_2x.png
│ │ ├── HLDDZ_BF_Game_2x.png
│ │ ├── HLDDZ_Balance_2x.png
│ │ ├── HLDDZ_ChartsAndMsg_2x.png
│ │ ├── HLDDZ_Common2_2x.png
│ │ ├── HLDDZ_Common2_IOS_2x.png
│ │ ├── HLDDZ_Common3_2x.png
│ │ ├── HLDDZ_Common_2x.png
│ │ ├── HLDDZ_DailyReward_2x.png
│ │ ├── HLDDZ_FriendBesides_2x.png
│ │ ├── HLDDZ_FriendInviteView_1x.png
│ │ ├── HLDDZ_FriendInviteView_2x.png
│ │ ├── HLDDZ_FriendScore_2x.png
│ │ ├── HLDDZ_Gift_Loading_2x.png
│ │ ├── HLDDZ_Help_2x.png
│ │ ├── HLDDZ_Load_Failed_2x.png
│ │ ├── HLDDZ_Loading_2x.png
│ │ ├── HLDDZ_Lord_2x.png
│ │ ├── HLDDZ_MainGame0_2x.png
│ │ ├── HLDDZ_MainGame1_2x.png
│ │ ├── HLDDZ_Match_Reward_2x.png
│ │ ├── HLDDZ_NewCharts_2x.png
│ │ ├── HLDDZ_None_Message_2x.png
│ │ ├── HLDDZ_PlayViewBtn_2x.png
│ │ ├── HLDDZ_PlayerInfo_2x.png
│ │ ├── HLDDZ_SendBeanSuccessful_2x.png
│ │ ├── HLDDZ_ShareAni_2x.png
│ │ ├── HLDDZ_ShareBtn_2x.png
│ │ ├── HLDDZ_Share_2x.png
│ │ ├── HLDDZ_TaskImg_2x.png
│ │ ├── HLDDZ_TaskInGame_2x.png
│ │ ├── HLDDZ_TitleImg_2x.png
│ │ ├── jiesuan_moban_2x.png
│ │ ├── jiesuan_moban_vic_2x.png
│ │ ├── loadingBG_2x.png
│ │ ├── loading_2x.png
│ │ ├── multiple_bg.png
│ │ ├── num.png
│ │ ├── win_bg.png
│ │ └── xiaoxi_2x.png
│ └── ui
│ │ ├── Common_Render.json
│ │ ├── Loading.json
│ │ └── MainGame.json
├── src
│ ├── app
│ │ ├── CameraTestLayer.lua
│ │ ├── DdzApp.lua
│ │ ├── commands
│ │ │ ├── AreaCommand.lua
│ │ │ ├── JoinedCommand.lua
│ │ │ ├── ReadyCommand.lua
│ │ │ ├── StartCommand.lua
│ │ │ └── UpdateCommand.lua
│ │ ├── consts.lua
│ │ ├── controllers
│ │ │ ├── UILoadingBarController.lua
│ │ │ └── UILoadingMaskController.lua
│ │ ├── formula
│ │ │ └── cardFormula.lua
│ │ ├── locales
│ │ │ ├── en.lua
│ │ │ └── zh.lua
│ │ ├── mediators
│ │ │ ├── LoadingSceneMediator.lua
│ │ │ ├── MainSceneChoosingLordMediator.lua
│ │ │ ├── MainSceneCommonMediator.lua
│ │ │ ├── MainScenePlayingMediator.lua
│ │ │ └── MainScenePreparingMediator.lua
│ │ ├── models
│ │ │ ├── Area.lua
│ │ │ ├── AreaPlayer.lua
│ │ │ ├── ModelBase.lua
│ │ │ └── Player.lua
│ │ ├── network
│ │ │ ├── Http.lua
│ │ │ └── rpc.lua
│ │ ├── proxies
│ │ │ ├── AreaProxy.lua
│ │ │ ├── AuthProxy.lua
│ │ │ └── UpdateProxy.lua
│ │ ├── scenes
│ │ │ ├── LoadingScene.lua
│ │ │ └── MainScene.lua
│ │ ├── ui
│ │ │ ├── UIBMFontLabel.lua
│ │ │ ├── UIBackCards.lua
│ │ │ ├── UICardButton.lua
│ │ │ ├── UIClock.lua
│ │ │ ├── UILittleCards.lua
│ │ │ ├── UILoadingBar.lua
│ │ │ ├── UIMyCards.lua
│ │ │ ├── UIPushButtonEx.lua
│ │ │ └── init.lua
│ │ └── viewloader
│ │ │ └── viewloader.lua
│ ├── cocos
│ │ ├── cocos2d
│ │ │ ├── Cocos2d.lua
│ │ │ ├── Cocos2dConstants.lua
│ │ │ ├── DeprecatedCocos2dClass.lua
│ │ │ ├── DeprecatedCocos2dEnum.lua
│ │ │ ├── DeprecatedCocos2dFunc.lua
│ │ │ ├── DeprecatedOpenglEnum.lua
│ │ │ ├── DrawPrimitives.lua
│ │ │ ├── Opengl.lua
│ │ │ ├── OpenglConstants.lua
│ │ │ ├── bitExtend.lua
│ │ │ ├── extern.lua
│ │ │ ├── json.lua
│ │ │ ├── luaj.lua
│ │ │ └── luaoc.lua
│ │ ├── cocosbuilder
│ │ │ ├── CCBReaderLoad.lua
│ │ │ └── DeprecatedCocosBuilderClass.lua
│ │ ├── cocosdenshion
│ │ │ ├── AudioEngine.lua
│ │ │ ├── DeprecatedCocosDenshionClass.lua
│ │ │ └── DeprecatedCocosDenshionFunc.lua
│ │ ├── cocostudio
│ │ │ ├── CocoStudio.lua
│ │ │ ├── DeprecatedCocoStudioClass.lua
│ │ │ ├── DeprecatedCocoStudioFunc.lua
│ │ │ └── StudioConstants.lua
│ │ ├── controller
│ │ │ └── ControllerConstants.lua
│ │ ├── extension
│ │ │ ├── DeprecatedExtensionClass.lua
│ │ │ ├── DeprecatedExtensionEnum.lua
│ │ │ ├── DeprecatedExtensionFunc.lua
│ │ │ └── ExtensionConstants.lua
│ │ ├── init.lua
│ │ ├── network
│ │ │ ├── DeprecatedNetworkClass.lua
│ │ │ ├── DeprecatedNetworkEnum.lua
│ │ │ ├── DeprecatedNetworkFunc.lua
│ │ │ └── NetworkConstants.lua
│ │ ├── spine
│ │ │ └── SpineConstants.lua
│ │ └── ui
│ │ │ ├── DeprecatedUIEnum.lua
│ │ │ ├── DeprecatedUIFunc.lua
│ │ │ ├── GuiConstants.lua
│ │ │ └── experimentalUIConstants.lua
│ ├── config.lua
│ ├── framework
│ │ ├── anysdkConst.lua
│ │ ├── audio.lua
│ │ ├── cc
│ │ │ ├── EventProxy.lua
│ │ │ ├── GameObject.lua
│ │ │ ├── Registry.lua
│ │ │ ├── components
│ │ │ │ ├── Component.lua
│ │ │ │ ├── behavior
│ │ │ │ │ ├── EventProtocol.lua
│ │ │ │ │ └── StateMachine.lua
│ │ │ │ └── ui
│ │ │ │ │ ├── BasicLayoutProtocol.lua
│ │ │ │ │ ├── DraggableProtocol.lua
│ │ │ │ │ └── LayoutProtocol.lua
│ │ │ ├── init.lua
│ │ │ ├── mvc
│ │ │ │ ├── AppBase.lua
│ │ │ │ ├── ModelBase.lua
│ │ │ │ └── init.lua
│ │ │ ├── net
│ │ │ │ ├── SocketTCP.lua
│ │ │ │ └── init.lua
│ │ │ ├── sdk
│ │ │ │ └── Store.lua
│ │ │ ├── ui
│ │ │ │ ├── UIBoxLayout.lua
│ │ │ │ ├── UIButton.lua
│ │ │ │ ├── UICheckBoxButton.lua
│ │ │ │ ├── UICheckBoxButtonGroup.lua
│ │ │ │ ├── UIGroup.lua
│ │ │ │ ├── UIImage.lua
│ │ │ │ ├── UIInput.lua
│ │ │ │ ├── UILabel.lua
│ │ │ │ ├── UILayout.lua
│ │ │ │ ├── UIListView.lua
│ │ │ │ ├── UIListViewItem.lua
│ │ │ │ ├── UILoadingBar.lua
│ │ │ │ ├── UIPageView.lua
│ │ │ │ ├── UIPageViewItem.lua
│ │ │ │ ├── UIPushButton.lua
│ │ │ │ ├── UIScrollView.lua
│ │ │ │ ├── UISlider.lua
│ │ │ │ ├── UIStretch.lua
│ │ │ │ └── init.lua
│ │ │ ├── uiloader
│ │ │ │ ├── CCSSceneLoader.lua
│ │ │ │ ├── CCSUILoader.lua
│ │ │ │ ├── UILoaderUtilitys.lua
│ │ │ │ ├── init.lua
│ │ │ │ └── uiloader.lua
│ │ │ └── utils
│ │ │ │ ├── ByteArray.lua
│ │ │ │ ├── ByteArrayVarint.lua
│ │ │ │ ├── GameState.lua
│ │ │ │ ├── Gettext.lua
│ │ │ │ ├── Localize.lua
│ │ │ │ ├── Timer.lua
│ │ │ │ ├── bit.lua
│ │ │ │ └── init.lua
│ │ ├── cocos2dx.lua
│ │ ├── cocos2dx
│ │ │ ├── ActionEx.lua
│ │ │ ├── Cocos2d.lua
│ │ │ ├── Cocos2dConstants.lua
│ │ │ ├── DrawNodeEx.lua
│ │ │ ├── Event.lua
│ │ │ ├── NodeEx.lua
│ │ │ ├── OpenglConstants.lua
│ │ │ ├── SceneEx.lua
│ │ │ ├── SpriteEx.lua
│ │ │ └── StudioConstants.lua
│ │ ├── crypto.lua
│ │ ├── debug.lua
│ │ ├── deprecated
│ │ │ └── deprecated_functions.lua
│ │ ├── device.lua
│ │ ├── display.lua
│ │ ├── filter.lua
│ │ ├── functions.lua
│ │ ├── global.lua
│ │ ├── init.lua
│ │ ├── json.lua
│ │ ├── luaj.lua
│ │ ├── luaoc.lua
│ │ ├── network.lua
│ │ ├── platform
│ │ │ ├── android.lua
│ │ │ ├── ios.lua
│ │ │ └── mac.lua
│ │ ├── scheduler.lua
│ │ ├── shortcodes.lua
│ │ ├── toluaEx.lua
│ │ ├── transition.lua
│ │ └── ui.lua
│ ├── main.lua
│ └── puremvc
│ │ ├── init.lua
│ │ └── org
│ │ └── puremvc
│ │ └── lua
│ │ └── multicore
│ │ ├── core
│ │ ├── Controller.lua
│ │ ├── Model.lua
│ │ └── View.lua
│ │ ├── help
│ │ └── oop.lua
│ │ └── patterns
│ │ ├── command
│ │ ├── MacroCommand.lua
│ │ └── SimpleCommand.lua
│ │ ├── facade
│ │ └── Facade.lua
│ │ ├── mediator
│ │ └── Mediator.lua
│ │ ├── observer
│ │ ├── Notification.lua
│ │ ├── Notifier.lua
│ │ └── Observer.lua
│ │ └── proxy
│ │ └── Proxy.lua
└── tests
│ ├── TestCardFormula.lua
│ ├── all.lua
│ ├── luaunit.lua
│ ├── mock.lua
│ ├── proxies
│ └── TestAuthProxy.lua
│ └── testtimer.lua
├── ddz1
├── res
│ ├── fonts
│ ├── textures
│ └── ui
└── src
├── ddz2
├── res
│ ├── fonts
│ ├── textures
│ └── ui
└── src
├── doc
└── api.md
├── game-server
├── .gitignore
├── .jshintrc
├── app.js
├── app
│ ├── components
│ │ └── areaSearcher.js
│ ├── consts.js
│ ├── controllers
│ │ ├── area.js
│ │ ├── game.js
│ │ ├── player.js
│ │ ├── push.js
│ │ ├── robot.js
│ │ └── team.js
│ ├── formula
│ │ ├── cardFormula.js
│ │ └── formula.js
│ ├── models
│ │ ├── area.js
│ │ ├── areaPlayer.js
│ │ ├── binding.js
│ │ ├── player.js
│ │ ├── push.js
│ │ └── team.js
│ ├── resp.js
│ ├── routes
│ │ ├── area.js
│ │ ├── player.js
│ │ └── team.js
│ └── servers
│ │ ├── area
│ │ └── handler
│ │ │ └── areaHandler.js
│ │ ├── connector
│ │ ├── handler
│ │ │ └── entryHandler.js
│ │ └── remote
│ │ │ └── entryRemote.js
│ │ ├── gate
│ │ └── handler
│ │ │ └── gateHandler.js
│ │ ├── player
│ │ ├── handler
│ │ │ └── playerHandler.js
│ │ └── remote
│ │ │ └── entryRemote.js
│ │ └── team
│ │ └── handler
│ │ └── teamHandler.js
├── config
│ ├── clientProtos.json
│ ├── development
│ │ ├── adminUser.json
│ │ ├── master.json
│ │ ├── memdb.conf.js
│ │ ├── memdb.json
│ │ ├── redisIdGenerator.json
│ │ └── servers.json
│ ├── dictionary.json
│ ├── log4js.json
│ ├── memdb.index.js
│ └── serverProtos.json
├── gruntfile.js
├── package.json
└── test
│ ├── blanket.js
│ ├── client
│ ├── e2e.js
│ └── login.js
│ ├── controllers
│ ├── area.js
│ ├── player.js
│ └── team.js
│ ├── env.js
│ ├── formula
│ └── cardFormula.js
│ ├── memdb.conf.js
│ └── testTimer.js
├── quick
└── framework
│ ├── anysdkConst.lua
│ ├── audio.lua
│ ├── cc
│ ├── EventProxy.lua
│ ├── GameObject.lua
│ ├── Registry.lua
│ ├── components
│ │ ├── Component.lua
│ │ ├── behavior
│ │ │ ├── EventProtocol.lua
│ │ │ └── StateMachine.lua
│ │ └── ui
│ │ │ ├── BasicLayoutProtocol.lua
│ │ │ ├── DraggableProtocol.lua
│ │ │ └── LayoutProtocol.lua
│ ├── init.lua
│ ├── mvc
│ │ ├── AppBase.lua
│ │ ├── ModelBase.lua
│ │ └── init.lua
│ ├── net
│ │ ├── SocketTCP.lua
│ │ └── init.lua
│ ├── sdk
│ │ └── Store.lua
│ ├── ui
│ │ ├── UIBoxLayout.lua
│ │ ├── UIButton.lua
│ │ ├── UICheckBoxButton.lua
│ │ ├── UICheckBoxButtonGroup.lua
│ │ ├── UIGroup.lua
│ │ ├── UIImage.lua
│ │ ├── UIInput.lua
│ │ ├── UILabel.lua
│ │ ├── UILayout.lua
│ │ ├── UIListView.lua
│ │ ├── UIListViewItem.lua
│ │ ├── UILoadingBar.lua
│ │ ├── UIPageView.lua
│ │ ├── UIPageViewItem.lua
│ │ ├── UIPushButton.lua
│ │ ├── UIScrollView.lua
│ │ ├── UISlider.lua
│ │ ├── UIStretch.lua
│ │ └── init.lua
│ ├── uiloader
│ │ ├── CCSSceneLoader.lua
│ │ ├── CCSUILoader.lua
│ │ ├── UILoaderUtilitys.lua
│ │ ├── init.lua
│ │ └── uiloader.lua
│ └── utils
│ │ ├── ByteArray.lua
│ │ ├── ByteArrayVarint.lua
│ │ ├── GameState.lua
│ │ ├── Gettext.lua
│ │ ├── Localize.lua
│ │ ├── Timer.lua
│ │ ├── bit.lua
│ │ └── init.lua
│ ├── cocos2dx.lua
│ ├── cocos2dx
│ ├── ActionEx.lua
│ ├── Cocos2d.lua
│ ├── Cocos2dConstants.lua
│ ├── DrawNodeEx.lua
│ ├── Event.lua
│ ├── NodeEx.lua
│ ├── OpenglConstants.lua
│ ├── SceneEx.lua
│ ├── SpriteEx.lua
│ └── StudioConstants.lua
│ ├── crypto.lua
│ ├── debug.lua
│ ├── deprecated
│ └── deprecated_functions.lua
│ ├── device.lua
│ ├── display.lua
│ ├── filter.lua
│ ├── functions.lua
│ ├── global.lua
│ ├── init.lua
│ ├── json.lua
│ ├── luaj.lua
│ ├── luaoc.lua
│ ├── network.lua
│ ├── platform
│ ├── android.lua
│ ├── ios.lua
│ └── mac.lua
│ ├── scheduler.lua
│ ├── shortcodes.lua
│ ├── toluaEx.lua
│ ├── transition.lua
│ └── ui.lua
├── robot
├── .gitignore
├── .jshintrc
├── app.js
├── app
│ ├── ai.js
│ ├── cardArranger.js
│ ├── cardPredictor.js
│ ├── config
│ │ ├── dev
│ │ │ └── config.json
│ │ └── env.json
│ ├── modelStore.js
│ ├── robot.js
│ └── start.js
├── gruntfile.js
├── package.json
└── test
│ └── cardArranger.js
└── start_clients.sh
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: http://EditorConfig.org
2 |
3 | # Howto with your editor:
4 | # Sublime: https://github.com/sindresorhus/editorconfig-sublime
5 |
6 | # top-most EditorConfig file
7 | root = true
8 |
9 | # Unix-style newlines with a newline ending every file
10 | [**]
11 | indent_style = space
12 | end_of_line = lf
13 | charset = utf-8
14 | trim_trailing_whitespace = true
15 | insert_final_newline = true
16 |
17 | # Standard at: https://github.com/felixge/node-style-guide
18 | [**.js, **.json]
19 | trim_trailing_whitespace = true
20 | indent_style = space
21 | quote_type = single
22 | curly_bracket_next_line = false
23 | spaces_around_operators = true
24 | space_after_control_statements = true
25 | space_after_anonymous_functions = false
26 | spaces_in_brackets = false
27 |
28 | # No Standard. Please document a standard if different from .js
29 | [**.yml, **.html, **.css]
30 | trim_trailing_whitespace = true
31 | indent_style = space
32 |
33 | # No standard. Please document a standard if different from .js
34 | [**.md]
35 | indent_style = space
36 | trim_trailing_whitespace = false
37 |
38 | # Standard at:
39 | [Makefile]
40 | indent_style = space
41 |
42 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ddz1/debug.log
2 | ddz1/ddzstate
3 | ddz2/debug.log
4 | ddz2/ddzstate
5 | ddz/debug.log
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # quick-pomelo-demo
2 |
3 | __Demo of [quick-pomelo](http://github.com/rain1017/quick-pomelo)__
4 |
5 | ## Server Quick Start
6 |
7 | #### Install MemDB
8 | [Guide](https://github.com/rain1017/memdb#install-dependencies)
9 |
10 | #### Start MemDB
11 | ```
12 | memdbcluster start --conf=./game-server/config/development/memdb.conf.js
13 | // WARN: remember to add --conf on every command, or copy it to ~/.memdb
14 | ```
15 |
16 | #### Install pomelo
17 | ```
18 | sudo apt-get install -g rain1017/pomelo
19 | ```
20 |
21 | #### Start server
22 | ```
23 | cd game-server
24 | npm install
25 |
26 | pomelo start --harmony
27 | ```
28 |
29 | ## Client Quick Start
30 | You don't need to compile the client yourself since it requires lots of dependencies,
31 | There is precompiled client binary for OSX. To start the client, just run
32 | ```
33 | ./start_clients.sh
34 | ```
35 | This will start 3 client instances, each player will join a random area-server and pick a random free room in the server.
36 |
--------------------------------------------------------------------------------
/bin/player3.app/Contents/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | BuildMachineOSBuild
5 | 13F34
6 | CFBundleDevelopmentRegion
7 | en
8 | CFBundleExecutable
9 | player3
10 | CFBundleIconFile
11 | Icon
12 | CFBundleIdentifier
13 | com.cocos.quick.apps.player
14 | CFBundleInfoDictionaryVersion
15 | 6.0
16 | CFBundleName
17 | player3
18 | CFBundlePackageType
19 | APPL
20 | CFBundleShortVersionString
21 | 2.0
22 | CFBundleSignature
23 | ????
24 | CFBundleVersion
25 | 20141112
26 | DTCompiler
27 | com.apple.compilers.llvm.clang.1_0
28 | DTPlatformBuild
29 | 6A1052d
30 | DTPlatformVersion
31 | GM
32 | DTSDKBuild
33 | 14A382
34 | DTSDKName
35 | macosx10.10
36 | DTXcode
37 | 0610
38 | DTXcodeBuild
39 | 6A1052d
40 | LSApplicationCategoryType
41 | public.app-category.developer-tools
42 | LSMinimumSystemVersion
43 | 10.8
44 | NSHumanReadableCopyright
45 | Copyright 2012-2014 Chukong Technologies, Inc. Licensed under MIT License.
46 | NSMainNibFile
47 | MainMenu
48 | NSPrincipalClass
49 | NSApplication
50 |
51 |
52 |
--------------------------------------------------------------------------------
/bin/player3.app/Contents/MacOS/player3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/bin/player3.app/Contents/MacOS/player3
--------------------------------------------------------------------------------
/bin/player3.app/Contents/PkgInfo:
--------------------------------------------------------------------------------
1 | APPL????
--------------------------------------------------------------------------------
/bin/player3.app/Contents/Resources/ConsoleWindow.nib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/bin/player3.app/Contents/Resources/ConsoleWindow.nib
--------------------------------------------------------------------------------
/bin/player3.app/Contents/Resources/Icon.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/bin/player3.app/Contents/Resources/Icon.icns
--------------------------------------------------------------------------------
/bin/player3.app/Contents/Resources/en.lproj/MainMenu.nib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/bin/player3.app/Contents/Resources/en.lproj/MainMenu.nib
--------------------------------------------------------------------------------
/ddz/.gitignore:
--------------------------------------------------------------------------------
1 | ccb_res/
2 | dependency/
3 | frameworks/
4 | ddz.ccbproj
5 | debug.log
6 | ddzstate
7 |
--------------------------------------------------------------------------------
/ddz/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ddz
4 |
5 |
6 |
7 |
8 |
9 |
10 | org.ccdt.cocosproject
11 | org.ccdt.cocosquickproject
12 | org.eclipse.koneki.ldt.nature
13 |
14 |
15 |
--------------------------------------------------------------------------------
/ddz/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "init_cfg":{
3 | "isLandscape": true,
4 | "isWindowTop": false,
5 | "name": "ddz",
6 | "width": 480,
7 | "height": 320,
8 | "entry": "src/main.lua",
9 | "consolePort": 6010,
10 | "uploadPort": 6020
11 | },
12 | "simulator_screen_size": [
13 | {
14 | "title": "iPhone 3Gs (480x320)",
15 | "width": 480,
16 | "height": 320
17 | },
18 | {
19 | "title": "iPhone 4 (960x640)",
20 | "width": 960,
21 | "height": 640
22 | },
23 | {
24 | "title": "iPhone 5 (1136x640)",
25 | "width": 1136,
26 | "height": 640
27 | },
28 | {
29 | "title": "iPad (1024x768)",
30 | "width": 1024,
31 | "height": 768
32 | },
33 | {
34 | "title": "iPad Retina (2048x1536)",
35 | "width": 2048,
36 | "height": 1536
37 | },
38 | {
39 | "title": "Android (800x480)",
40 | "width": 800,
41 | "height": 480
42 | },
43 | {
44 | "title": "Android (854x480)",
45 | "width": 854,
46 | "height": 480
47 | },
48 | {
49 | "title": "Android (1280x720)",
50 | "width": 1280,
51 | "height": 720
52 | },
53 | {
54 | "title": "Android (1920x1080)",
55 | "width": 1920,
56 | "height": 1080
57 | }
58 | ]
59 | }
60 |
--------------------------------------------------------------------------------
/ddz/res/README.txt:
--------------------------------------------------------------------------------
1 |
2 | The file "fonts/arial.ttf" is used only in project of wp8. You can delete it in other projects.
3 |
4 |
--------------------------------------------------------------------------------
/ddz/res/fonts/STFONT.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/fonts/STFONT.ttf
--------------------------------------------------------------------------------
/ddz/res/fonts/arial.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/fonts/arial.ttf
--------------------------------------------------------------------------------
/ddz/res/textures/Common_BG1_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/Common_BG1_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/Common_ContinueWin_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/Common_ContinueWin_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/ContinueWinProp_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/ContinueWinProp_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Activity_Center_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Activity_Center_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Anim_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Anim_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Avatar_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Avatar_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_BF_Game_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_BF_Game_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Balance_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Balance_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_ChartsAndMsg_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_ChartsAndMsg_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Common2_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Common2_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Common2_IOS_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Common2_IOS_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Common3_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Common3_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Common_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Common_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_DailyReward_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_DailyReward_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_FriendBesides_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_FriendBesides_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_FriendInviteView_1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_FriendInviteView_1x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_FriendInviteView_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_FriendInviteView_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_FriendScore_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_FriendScore_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Gift_Loading_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Gift_Loading_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Help_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Help_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Load_Failed_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Load_Failed_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Loading_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Loading_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Lord_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Lord_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_MainGame0_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_MainGame0_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_MainGame1_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_MainGame1_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Match_Reward_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Match_Reward_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_NewCharts_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_NewCharts_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_None_Message_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_None_Message_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_PlayViewBtn_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_PlayViewBtn_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_PlayerInfo_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_PlayerInfo_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_SendBeanSuccessful_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_SendBeanSuccessful_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_ShareAni_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_ShareAni_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_ShareBtn_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_ShareBtn_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_Share_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_Share_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_TaskImg_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_TaskImg_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_TaskInGame_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_TaskInGame_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/HLDDZ_TitleImg_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/HLDDZ_TitleImg_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/jiesuan_moban_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/jiesuan_moban_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/jiesuan_moban_vic_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/jiesuan_moban_vic_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/loadingBG_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/loadingBG_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/loading_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/loading_2x.png
--------------------------------------------------------------------------------
/ddz/res/textures/multiple_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/multiple_bg.png
--------------------------------------------------------------------------------
/ddz/res/textures/num.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/num.png
--------------------------------------------------------------------------------
/ddz/res/textures/win_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/win_bg.png
--------------------------------------------------------------------------------
/ddz/res/textures/xiaoxi_2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rain1017/quick-pomelo-demo/3b3b6db249ae6e65cb739be0ad9c7fd9f997ba85/ddz/res/textures/xiaoxi_2x.png
--------------------------------------------------------------------------------
/ddz/src/app/CameraTestLayer.lua:
--------------------------------------------------------------------------------
1 | local CameraTestLayer = class("CameraTestLayer", function()
2 | return display.newLayer()
3 | end)
4 |
5 | function CameraTestLayer:ctor()
6 |
7 | local spr = display.newSprite("num.png")
8 | spr:setPosition(cc.p(100, 100))
9 | local move = cc.MoveTo:create(100, cc.p(10000, 100))
10 | spr:runAction(move)
11 | self:addChild(spr)
12 | self.spr = spr
13 |
14 | local camera = cc.Camera:createOrthographic(display.width, display.height, 0, 1)
15 | camera:setCameraFlag(2)
16 | self:addChild(camera)
17 | -- camera:setPosition3D({x = 0, y = 0, z = 0})
18 | self.camera = camera
19 | self:setCameraMask(2)
20 |
21 | self:addNodeEventListener(cc.NODE_ENTER_FRAME_EVENT, handler(self, self.update))
22 | self:scheduleUpdate()
23 | end
24 |
25 | function CameraTestLayer:update()
26 | -- local scene = cc.Director:getInstance():getRunningScene()
27 | -- local camera = scene:getDefaultCamera()
28 | -- camera:setPositionX(self.spr:getPositionX())
29 | self.camera:setPositionX(self.spr:getPositionX())
30 | -- print("self.cameraX = ", self.camera:getPositionX())
31 | end
32 |
33 | return CameraTestLayer
--------------------------------------------------------------------------------
/ddz/src/app/commands/AreaCommand.lua:
--------------------------------------------------------------------------------
1 | local consts = require('app.consts')
2 |
3 |
4 | local AreaCommand = class('AreaCommand', pm.SimpleCommand)
5 |
6 | function AreaCommand:ctor()
7 | AreaCommand.super.ctor(self)
8 | end
9 |
10 | function AreaCommand:execute(note)
11 | local facade = ddz.facade
12 | local mainMediator = facade:retrieveMediator('MainSceneMediator')
13 | local noteName = note:getName()
14 | if noteName == consts.msgs.ON_JOIN then
15 | local player = note:getBody().player
16 | local me = ddz.models.me
17 | mainMediator:onAddPlayer(me:isLeft(ddz.models.area, player), player.sex == consts.sex.MALE)
18 | mainMediator:hideStatus()
19 | elseif noteName == consts.msgs.ON_READY then
20 | elseif noteName == consts.msgs.ON_START then
21 | elseif noteName == consts.msgs.ON_QUIT then
22 | elseif noteName == consts.msgs.ON_LORD_CHOOSED then
23 | elseif noteName == consts.msgs.ON_CHOOSE_LORD then
24 | elseif noteName == consts.msgs.ON_PLAY then
25 | elseif noteName == consts.msgs.ON_GAME_OVER then
26 | end
27 | end
28 |
29 | return AreaCommand
30 |
--------------------------------------------------------------------------------
/ddz/src/app/commands/JoinedCommand.lua:
--------------------------------------------------------------------------------
1 | local consts = require('app.consts')
2 |
3 |
4 | local JoinedCommand = class('JoinedCommand', pm.SimpleCommand)
5 |
6 | function JoinedCommand:ctor()
7 | JoinedCommand.super.ctor(self)
8 | end
9 |
10 | function JoinedCommand:execute(note)
11 | local facade = ddz.facade
12 | local mainMediator = facade:retrieveMediator('MainSceneMediator')
13 | if note:getName() == consts.msgs.JOINED then
14 | end
15 | end
16 |
17 | return JoinedCommand
18 |
--------------------------------------------------------------------------------
/ddz/src/app/commands/ReadyCommand.lua:
--------------------------------------------------------------------------------
1 | local consts = require('app.consts')
2 |
3 |
4 | local ReadyCommand = class('ReadyCommand', pm.SimpleCommand)
5 |
6 | function ReadyCommand:ctor()
7 | ReadyCommand.super.ctor(self)
8 | self.loadingParts = {
9 | update = 90,
10 | login = 10
11 | }
12 | end
13 |
14 | function ReadyCommand:execute(note)
15 | local facade = ddz.facade
16 | local mainMediator = facade:retrieveMediator('MainSceneMediator')
17 | if note:getName() == consts.msgs.JOIN_GAME then
18 | local areaProxy = facade:retrieveProxy('AreaProxy')
19 | areaProxy:searchAndJoin()
20 | end
21 | end
22 |
23 | return ReadyCommand
24 |
--------------------------------------------------------------------------------
/ddz/src/app/commands/StartCommand.lua:
--------------------------------------------------------------------------------
1 | local consts = require('app.consts')
2 |
3 |
4 | local StartCommand = class('StartCommand', pm.SimpleCommand)
5 |
6 | function StartCommand:ctor()
7 | StartCommand.super.ctor(self)
8 | self.executed = false
9 | end
10 |
11 | function StartCommand:execute(note)
12 |
13 | math.randomseed(os.time())
14 |
15 | cc.FileUtils:getInstance():setPopupNotify(false)
16 | cc.FileUtils:getInstance():addSearchPath("res/")
17 | cc.FileUtils:getInstance():addSearchPath("res/textures")
18 |
19 | ddz.ui.viewloader:loadCommonView('ui/Common_Render.json')
20 |
21 | self:initLocale()
22 |
23 | local facade = ddz.facade
24 |
25 | facade:retrieveMediator('LoadingSceneMediator'):show()
26 |
27 | local State = cc.utils.State
28 | State.init(function(opts)
29 | printInfo('state event: name=%s, opts=%s', opts.name, json.encode(opts))
30 | if opts.name == 'load' and not opts.errorCode then
31 | printInfo('state loaded: values=%s', opts.name, json.encode(opts.values))
32 | return opts.values
33 | elseif opts.name == 'load' then
34 | if opts.errorCode ~= State.ERROR_STATE_FILE_NOT_FOUND then
35 | display.getRunningScene():showErrorStatus('Load data error: ' .. opts.errorCode)
36 | end
37 | return {}
38 | elseif opts.name == 'save' then
39 | return opts.values
40 | end
41 | end, 'ddzstate', 'ddzstate')
42 | ddz.state = State.load()
43 |
44 | facade:retrieveProxy('UpdateProxy'):update()
45 | end
46 |
47 | function StartCommand:initLocale()
48 | local localeModule = 'app.locales.en'
49 | ddz.locale = function(fmt, ...)
50 | local locale = require(localeModule)
51 | return string.format(locale[fmt] or fmt, ...)
52 | end
53 | end
54 |
55 | return StartCommand
56 |
--------------------------------------------------------------------------------
/ddz/src/app/commands/UpdateCommand.lua:
--------------------------------------------------------------------------------
1 | local consts = require('app.consts')
2 |
3 |
4 | local UpdateCommand = class('UpdateCommand', pm.SimpleCommand)
5 |
6 | function UpdateCommand:ctor()
7 | UpdateCommand.super.ctor(self)
8 | self.loadingParts = {
9 | update = 90,
10 | login = 10
11 | }
12 | end
13 |
14 | function UpdateCommand:execute(note)
15 | local facade = ddz.facade
16 | local loadingMediator = facade:retrieveMediator('LoadingSceneMediator')
17 | if note:getType() == 'update' then
18 | local progress = note:getBody()
19 | loadingMediator:setProgress("Updating Resource...", progress * 0.9)
20 | if progress == 100 then
21 | facade:retrieveProxy('AuthProxy'):login()
22 | loadingMediator:setStatus("Login...")
23 | end
24 | elseif note:getType() == 'login' then
25 | loadingMediator:setProgress("Login complete", 100)
26 | local mainMediator = facade:retrieveMediator('MainScenePreparingMediator')
27 | local playerInfo = note:getBody()
28 | local scene = mainMediator:onLoggedIn(playerInfo)
29 | local mediators = {'MainScenePreparingMediator', 'MainScenePlayingMediator', 'MainSceneChoosingLordMediator', 'MainSceneCommonMediator'}
30 | for k,v in pairs(mediators) do
31 | local md = facade:retrieveMediator(v)
32 | md:setViewComponent(scene)
33 | md:addListeners(scene)
34 | end
35 | end
36 | end
37 |
38 | return UpdateCommand
39 |
--------------------------------------------------------------------------------
/ddz/src/app/controllers/UILoadingBarController.lua:
--------------------------------------------------------------------------------
1 | local UILoadingBarController = class("UILoadingBarController", function()
2 | return {}
3 | end)
4 |
5 | function UILoadingBarController:ctor(renderedNode)
6 | self.renderedNode = renderedNode
7 | self.spriteLeft = renderedNode:getChildById('FANOBJ_Render_Loading_bar_Left')
8 | self.spriteCenter = renderedNode:getChildById('FANOBJ_Render_Loading_bar_center')
9 | self.spriteRight = self:_createSpriteRight(self.spriteLeft)
10 | local slSize = self.spriteLeft:getContentSize()
11 | local scSize = self.spriteCenter:getContentSize()
12 | local viewConfig = renderedNode:getViewConfig()
13 | local parentViewConfig = renderedNode:getParent():getViewConfig()
14 | local width = parentViewConfig.rect[3] - 2 * viewConfig.rect[1]
15 | self.centerScaleTotal = (width - slSize.width * self.spriteLeft:getScaleX() * 2) / (scSize.width * self.spriteCenter:getScaleX())
16 | self.centerScaleTotal = self.centerScaleTotal * self.spriteLeft:getScaleX() + 0.3
17 | self.width = width
18 | renderedNode:setContentSize(width, viewConfig.rect[4])
19 | self.spriteRight:addTo(self.renderedNode)
20 | self.spriteLeft:hide()
21 | self.spriteCenter:hide()
22 | self.spriteRight:hide()
23 | self:setPercent(0)
24 | end
25 |
26 | function UILoadingBarController:_createSpriteRight(sprite)
27 | local rs = sprite:clone()
28 | rs:setFlippedX(true)
29 | return rs
30 | end
31 |
32 | function UILoadingBarController:setPercent(percent)
33 | if percent > 0 and percent <= 1 then
34 | self.spriteLeft:align(display.LEFT_BOTTOM, 0, 0)
35 | self.spriteLeft:show()
36 | self.spriteCenter:hide()
37 | self.spriteRight:hide()
38 | elseif percent > 1 and percent < 100 then
39 | self.spriteLeft:align(display.LEFT_BOTTOM, 0, 0)
40 | self.spriteCenter:setScaleX(self.centerScaleTotal * (percent - 2) / 100)
41 | self.spriteCenter:align(display.LEFT_BOTTOM, self.spriteLeft:getContentSize().width * self.spriteLeft:getScaleX(), 0)
42 | self.spriteLeft:show()
43 | self.spriteCenter:show()
44 | self.spriteRight:hide()
45 | elseif percent >= 100 then
46 | self.spriteLeft:align(display.LEFT_BOTTOM, 0, 0)
47 | self.spriteCenter:setScaleX(self.centerScaleTotal)
48 | self.spriteCenter:align(display.LEFT_BOTTOM, self.spriteLeft:getContentSize().width * self.spriteLeft:getScaleX(), 0)
49 | self.spriteRight:align(display.LEFT_BOTTOM, self.width - self.spriteLeft:getContentSize().width * self.spriteLeft:getScaleX(), 0)
50 | self.spriteLeft:show()
51 | self.spriteCenter:show()
52 | self.spriteRight:show()
53 | end
54 | end
55 |
56 | return UILoadingBarController
--------------------------------------------------------------------------------
/ddz/src/app/controllers/UILoadingMaskController.lua:
--------------------------------------------------------------------------------
1 | local viewloader = import('..viewloader.viewloader')
2 |
3 | local UILoadingMaskController = class("UILoadingMaskController")
4 |
5 | function UILoadingMaskController:create()
6 | return UILoadingMaskController.new(
7 | viewloader:spriteById("2000002", "85"),
8 | viewloader:spriteById("2000002", "86"),
9 | {
10 | viewloader:spriteFrameById("2000002", "86"), viewloader:spriteFrameById("2000002", "87"),
11 | viewloader:spriteFrameById("2000002", "88"), viewloader:spriteFrameById("2000002", "89"),
12 | viewloader:spriteFrameById("2000002", "90"), viewloader:spriteFrameById("2000002", "91"),
13 | })
14 | end
15 |
16 | function UILoadingMaskController:ctor(point, bean, beanFrames)
17 | self.root = display.newNode()
18 | self.root:setContentSize(display.width, display.height)
19 |
20 | self:_initPoints(point)
21 | self:_initBeans(bean, beanFrames)
22 | end
23 |
24 | function UILoadingMaskController:_initPoints(point)
25 | self.pointNode = display.newNode()
26 | self.pointNode:align(display.CENTER, display.cx, display.cy)
27 | self.pointNode:setContentSize(display.width, display.height)
28 | self.pointNode:addTo(self.root)
29 |
30 | local r, opacityStart, opacityStep = 40, 255 * 0.2, 255 * 0.8 / 7
31 | local i = 1
32 | for i=1,8 do
33 | local rad = math.pi * 2 * i / 8
34 | local p = point:clone():opacity(math.floor(opacityStart + (i - 1) * opacityStep))
35 | :align(display.CENTER, display.cx + r * math.sin(rad), display.cy + r * math.cos(rad))
36 | :addTo(self.pointNode)
37 | end
38 | end
39 |
40 | function UILoadingMaskController:_initBeans(bean, beanFrames)
41 | bean:align(display.CENTER, display.cx, display.cy):addTo(self.root)
42 | self.bean = bean
43 | self.beanFrames = beanFrames
44 | end
45 |
46 | function UILoadingMaskController:node()
47 | return self.root
48 | end
49 |
50 | function UILoadingMaskController:start()
51 | local action = cc.RepeatForever:create(cc.RotateBy:create(0.4, 360/8))
52 | self.pointNode:runAction(action)
53 |
54 | local ani = display.newAnimation(self.beanFrames, 1.5 / 8)
55 | self.bean:playAnimationForever(ani, 0)
56 | end
57 |
58 | function UILoadingMaskController:stop()
59 | self.pointNode:stopAllActions()
60 | self.bean:stopAllActions()
61 | end
62 |
63 | return UILoadingMaskController
--------------------------------------------------------------------------------
/ddz/src/app/locales/en.lua:
--------------------------------------------------------------------------------
1 | local strings = {}
2 |
3 |
4 | return strings
--------------------------------------------------------------------------------
/ddz/src/app/locales/zh.lua:
--------------------------------------------------------------------------------
1 | local strings = {}
2 |
3 | return strings
--------------------------------------------------------------------------------
/ddz/src/app/mediators/LoadingSceneMediator.lua:
--------------------------------------------------------------------------------
1 | local consts = require('app.consts')
2 | local LoadingScene = require('app.scenes.LoadingScene')
3 |
4 | local LoadingSceneMediator = class('LoadingSceneMediator', pm.Mediator)
5 |
6 | LoadingSceneMediator.NAME = 'LoadingSceneMediator'
7 |
8 | function LoadingSceneMediator:ctor(...)
9 | LoadingSceneMediator.super.ctor(self, ...)
10 | end
11 |
12 | function LoadingSceneMediator:show()
13 | ddz.app:enterScene("LoadingScene")
14 | end
15 |
16 | function LoadingSceneMediator:listNotificationInterests()
17 | --return {consts.msgs.LOADING_PROGRESS, consts.msgs.LOADING_SUCCESS, consts.msgs.LOADING_FAIL}
18 | return {}
19 | end
20 |
21 | function LoadingSceneMediator:handleNotification(notification)
22 | --[[
23 | if notification.getName() == consts.msgs.LOADING_PROGRESS then
24 | local data = notification:getBody()
25 | scene:setProgress(data.status, data.progress)
26 | elseif notification.getName() == consts.msgs.LOADING_SUCCESS then
27 |
28 | elseif notification.getName() == consts.msgs.LOADING_FAIL then
29 | scene:setStatus('Sorry, load game failed.')
30 | end
31 | --]]
32 | end
33 |
34 | function LoadingSceneMediator:_checkScene()
35 | local scene = display.getRunningScene()
36 | if scene.NAME ~= LoadingScene.NAME then
37 | printError('current scene is not LoadingScene!')
38 | end
39 | return scene
40 | end
41 |
42 | function LoadingSceneMediator:setProgress(status, progress)
43 | self:_checkScene():setProgress(status, progress)
44 | end
45 |
46 | function LoadingSceneMediator:setStatus(status)
47 | self:_checkScene():setStatus(status)
48 | end
49 |
50 | return LoadingSceneMediator
--------------------------------------------------------------------------------
/ddz/src/app/mediators/MainSceneCommonMediator.lua:
--------------------------------------------------------------------------------
1 | local consts = require('app.consts')
2 | local MainScene = require('app.scenes.MainScene')
3 |
4 | local MainSceneCommonMediator = class('MainSceneCommonMediator', pm.Mediator)
5 |
6 | MainSceneCommonMediator.NAME = 'MainSceneCommonMediator'
7 |
8 | function MainSceneCommonMediator:ctor(...)
9 | MainSceneCommonMediator.super.ctor(self, ...)
10 | end
11 |
12 | function MainSceneCommonMediator:addListeners(scene)
13 | scene:addButtonListener('maingame_float_exit_btn', handler(self, self.onExitBtnClicked))
14 | end
15 |
16 | function MainSceneCommonMediator:onExitBtnClicked()
17 | ddz.facade:retrieveProxy('AreaProxy'):quit(ddz.models.area.id)
18 | end
19 |
20 |
21 | function MainSceneCommonMediator:listNotificationInterests()
22 | return {
23 | consts.msgs.ON_QUIT, consts.msgs.ON_DISCONNECT, consts.msgs.ON_TIMEOUT, consts.msgs.ON_KICK
24 | }
25 | end
26 |
27 | function MainSceneCommonMediator:handleNotification(notification)
28 | local nm = notification:getName()
29 | local body = notification:getBody()
30 | local me = ddz.models.me
31 | local area = ddz.models.area
32 | local scene = self:_checkScene()
33 |
34 | if nm == consts.msgs.ON_QUIT then
35 | if body.quitedPlayer.id == me.id then
36 | -- TODO: show punishment or something
37 | scene:resetSceneLoggedin()
38 | else
39 | scene:resetSceneWaitToStart()
40 | end
41 | elseif nm == consts.msgs.ON_DISCONNECT then
42 | display.getRunningScene():showErrorStatus('Sorry, U\'r disconnected, please restart.')
43 | elseif nm == consts.msgs.ON_TIMEOUT then
44 | display.getRunningScene():showErrorStatus('Sorry, request timeout, please restart.')
45 | elseif nm == consts.msgs.ON_KICK then
46 | display.getRunningScene():showErrorStatus('Sorry, U\'r kicked out, please restart.')
47 | end
48 | end
49 |
50 | function MainSceneCommonMediator:_checkScene()
51 | return self.viewComponent
52 | --[[
53 | local scene = display.getRunningScene()
54 | if scene.NAME ~= MainScene.NAME then
55 | printError('current scene is not MainScene!')
56 | end
57 | return scene
58 | --]]
59 | end
60 |
61 | return MainSceneCommonMediator
--------------------------------------------------------------------------------
/ddz/src/app/models/AreaPlayer.lua:
--------------------------------------------------------------------------------
1 | local ModelBase = require('app.models.ModelBase')
2 | local consts = require('app.consts')
3 |
4 | local AreaPlayer = class('AreaPlayer', ModelBase)
5 |
6 | local props = {
7 | playerId = {type='Number'},
8 | name = {type='String'},
9 | cards = {{type='String'}},
10 | cardsCount = {type='Number', default=17},
11 | online = {type='Boolean', default=true},
12 | show = {type='Boolean', default=false},
13 | ready = {type='Boolean', default=false},
14 | }
15 |
16 | local statics = {}
17 | local methods = {}
18 |
19 | function AreaPlayer:ctor(data)
20 | AreaPlayer.super.ctor(self, props, statics, methods, data)
21 | end
22 |
23 | return AreaPlayer
--------------------------------------------------------------------------------
/ddz/src/app/models/Player.lua:
--------------------------------------------------------------------------------
1 | local ModelBase = require('app.models.ModelBase')
2 | local consts = require('app.consts')
3 |
4 | local Player = class('Player', ModelBase)
5 |
6 | local props = {
7 | id = {type='Number'},
8 | areaId = {type='String'},
9 | teamId = {type='String'},
10 | name = {type='String', random={"天堂在左", "我在右"}},
11 | sex = {type='Number', default=consts.sex.MALE, random={consts.sex.MALE, consts.sex.FEMALE}},
12 | money = {type='Number'}
13 | }
14 |
15 | local statics = {}
16 | local methods = {}
17 |
18 | methods.isLeft = function(self, playerIds, playerId)
19 | if self.id == playerId then return nil end
20 | for i = 1, #playerIds do
21 | playerIds[i] = tonumber(playerIds[i])
22 | end
23 | local thisIdx, otherIdx
24 | for k ,v in pairs(playerIds) do
25 | if v == self.id then
26 | thisIdx = k
27 | elseif v == playerId then
28 | otherIdx = k
29 | end
30 | end
31 | if thisIdx == 1 then
32 | return otherIdx == 3
33 | elseif thisIdx == 2 then
34 | return otherIdx == 1
35 | elseif thisIdx == 3 then
36 | return otherIdx == 2
37 | else
38 | if not thisIdx then
39 | printError('player index not found: playerIds=%s, playerId=%s', json.encode(playerIds), self.id)
40 | else
41 | printError('error player index: %s', thisIdx)
42 | end
43 | end
44 | end
45 |
46 | function Player:ctor(data)
47 | Player.super.ctor(self, props, statics, methods, data)
48 | end
49 |
50 | return Player
--------------------------------------------------------------------------------
/ddz/src/app/network/Http.lua:
--------------------------------------------------------------------------------
1 | Http = {}
2 |
3 | local WAITING = 0
4 | local REQUSTING = 1
5 |
6 |
7 | function Http:new() --私有方法,不要调用这个.请自觉...
8 | local ins = nil
9 |
10 | return function(self)
11 | if ins then return ins end
12 |
13 | local o = {}
14 | setmetatable(o, self)
15 | self.__index = self
16 | ins = o
17 |
18 | self.status = WAITING
19 | return o
20 | end
21 | end
22 |
23 | Http.ins = Http:new() -- 用closure返回getInstance
24 |
25 | function Http:request(url, param, callback)
26 |
27 | if not (url and type(url) == 'string') then
28 | print "***Http: 非法的url地址?!"
29 | return
30 | end
31 |
32 | if self.status == REQUSTING then
33 | print "***Http: 请求服务器中.一次一个请求和response是比较科学的做法."
34 | return
35 | end
36 | print("***Http: 开始请求服务器")
37 | print("***Http: url ", url)
38 | print("***Http: param")
39 | -- print_r(param)
40 |
41 | local request
42 | local responseFunc = function()
43 | print("***Http: call responseFunc .........")
44 | print("***Http: request:getState() = ", request:getState())
45 | if request:getState() == 3 and request:getResponseStatusCode() == 200 then
46 | print("***Http: response is\n" .. request:getResponseString())
47 | local reponseData = json.decode(request:getResponseString())
48 | if reponseData then
49 | if callback and type(callback) == 'function' then
50 | callback(reponseData)
51 | end
52 | end
53 | else
54 | end
55 | end
56 |
57 | request = network.createHTTPRequest(responseFunc, url, "POST")
58 | -- request:addRequestHeader("Content-Type: application/json;charset=UTF-8")
59 | local data = json.encode(param)
60 | request:addRequestHeader("Content-Type: application/json")
61 | print("***Http: the request data is ", data)
62 | print("***Http: length is ",string.len(data))
63 | request:setPOSTData(data)
64 |
65 | -- for k,v in pairs(param) do
66 | -- print("k,v",k,v)
67 | -- request:addPOSTValue(k,v)
68 | -- end
69 |
70 | request:start()
71 | end
72 |
73 | return Http
--------------------------------------------------------------------------------
/ddz/src/app/proxies/AuthProxy.lua:
--------------------------------------------------------------------------------
1 | local consts = require('app.consts')
2 | local Player = require('app.models.Player')
3 |
4 | local AuthProxy = class('AuthProxy', pm.Proxy)
5 |
6 | function AuthProxy:ctor(...)
7 | AuthProxy.super.ctor(self, ...)
8 | end
9 |
10 | function AuthProxy:login()
11 | local rpc = RPC:ins()
12 | rpc:setOnConnected(handler(self, function(self, connected)
13 | printInfo('onConnectedCallback called, connected=%s', tostring(connected))
14 | if not connected then
15 | ddz.facade:sendNotification(consts.msgs.ON_DISCONNECT);
16 | return
17 | end
18 | --local filename = cc.FileUtils:getInstance():fullPathForFilename('conf')
19 | --local config = json.decode(io.readfile(filename))
20 | if not ddz.state.deviceid then
21 | ddz.state.deviceid = tostring(os.time() * 10000 + math.random(1, 1000) * 1000 + math.random(1, 1000))
22 | cc.utils.State.save(ddz.state)
23 | end
24 | local authInfo = {socialId=ddz.state.deviceid, socialType=consts.binding.types.DEVICE};
25 | rpc:request(consts.routes.server.connector.LOGIN, {authInfo=authInfo}, handler(self, self._onLoginResponse))
26 | end))
27 | rpc:connectGate('127.0.0.1', 3010)
28 | end
29 |
30 | function AuthProxy:_onLoginResponse(msg)
31 | printInfo('_onLoginResponse called')
32 | ddz.models.me = Player.new(msg.data.player)
33 | ddz.facade:sendNotification(consts.msgs.UPDATE, ddz.models.me, 'login')
34 | end
35 |
36 | function AuthProxy:test(arg)
37 | printInfo('args: %s', arg)
38 | return arg + 1
39 | end
40 |
41 | return AuthProxy
42 |
--------------------------------------------------------------------------------
/ddz/src/app/proxies/UpdateProxy.lua:
--------------------------------------------------------------------------------
1 | local consts = require('app.consts')
2 |
3 | local UpdateProxy = class('UpdateProxy', pm.Proxy)
4 |
5 | function UpdateProxy:ctor(...)
6 | UpdateProxy.super.ctor(self, ...)
7 | end
8 |
9 | function UpdateProxy:update()
10 | -- update lua files and other resources
11 | -- send notification to report download progress
12 | local scheduler = require(cc.PACKAGE_NAME .. ".scheduler")
13 | local progress = 0
14 | local timer
15 | timer = scheduler.scheduleGlobal(function()
16 | progress = progress + 10
17 | ddz.facade:sendNotification(consts.msgs.UPDATE, progress, 'update')
18 | if progress == 100 then
19 | scheduler.unscheduleGlobal(timer)
20 | end
21 | end, 0.1)
22 | end
23 |
24 | function UpdateProxy:timerFunc()
25 | end
26 |
27 | return UpdateProxy
28 |
--------------------------------------------------------------------------------
/ddz/src/app/scenes/LoadingScene.lua:
--------------------------------------------------------------------------------
1 |
2 | local LoadingScene = class("LoadingScene", function()
3 | return display.newScene("LoadingScene")
4 | end)
5 |
6 | LoadingScene.NAME = 'LoadingScene'
7 |
8 | function LoadingScene:ctor()
9 | local viewloader = ddz.ui.viewloader
10 | local UILoadingBarController, UILoadingMaskController = ddz.ui.UILoadingBarController, ddz.ui.UILoadingMaskController
11 |
12 | local bg = viewloader.sprite('Common_BG1', {0, 0, 480, 320})
13 | bg:align(display.CENTER, display.cx, display.cy)
14 | bg:addTo(self)
15 |
16 | local node, rendered = viewloader:renderView('ui/Loading.json')
17 | node:addTo(self)
18 | self.rendered = rendered
19 |
20 | dump(rendered)
21 |
22 | self.controllers = {}
23 | self.controllers.panel_loading_bar = UILoadingBarController.new(rendered.panel_loading_bar)
24 |
25 | self.controllers.maskController = UILoadingMaskController:create()
26 | self.controllers.maskController:node()
27 | :align(display.CENTER, display.cx, display.cy + 30)
28 | :addTo(self)
29 | self.rendered.error_status = display.newTTFLabel({color = cc.c3b(230,26,26),dimensions = cc.size(480, 20),
30 | font = "fonts/STFONT.ttf",size=18,align=cc.TEXT_ALIGNMENT_CENTER})
31 | :align(display.CENTER, display.cx, display.cy)
32 | :addTo(self)
33 | :zorder(100)
34 | :hide()
35 |
36 | end
37 |
38 | function LoadingScene:setProgress(status, progress)
39 | self.rendered.hlddz_loading_text:setString(ddz.locale(status))
40 | self.controllers.panel_loading_bar:setPercent(progress)
41 | end
42 |
43 | function LoadingScene:setStatus(status)
44 | self.rendered.hlddz_loading_text:setString(ddz.locale(status))
45 | end
46 |
47 | function LoadingScene:showErrorStatus(status)
48 | printInfo('showErrorStatus: %s', status)
49 | self.rendered.error_status:setString(status)
50 | self.rendered.error_status:show()
51 | end
52 |
53 | function LoadingScene:update( ... )
54 | LoadingScene.super.update(self, ...)
55 | end
56 |
57 | function LoadingScene:onEnter()
58 | self.controllers.panel_loading_bar:setPercent(0)
59 | self.controllers.maskController:start()
60 | end
61 |
62 | function LoadingScene:onExit()
63 | self.controllers.panel_loading_bar:setPercent(0)
64 | self.controllers.maskController:stop()
65 | end
66 |
67 | return LoadingScene
68 |
--------------------------------------------------------------------------------
/ddz/src/app/ui/UIClock.lua:
--------------------------------------------------------------------------------
1 | local viewloader = import('..viewloader.viewloader')
2 | local scheduler = require(cc.PACKAGE_NAME .. ".scheduler")
3 | local consts = import('..consts')
4 |
5 |
6 | local UIClock = class("UIClock", function()
7 | return display.newNode()
8 | end)
9 |
10 | function UIClock:ctor(time, size, callback)
11 | self.time_ = time
12 | self.callback_ = callback
13 | viewloader:spriteByDesc('HLDDZ_MainGame0', 'Module_Clock', 'ui/MainGame.json')
14 | :align(display.LEFT_BOTTOM, 0, 0)
15 | :addTo(self)
16 | self.timeLabel = display.newTTFLabel(
17 | {align=cc.TEXT_ALIGNMENT_CENTER, dimensions=cc.size(22, 16), font='STFONT', color=display.COLOR_RED, text=tostring(time), size=16})
18 | :align(display.CENTER, size.width/2-1, size.height/2-3)
19 | :addTo(self)
20 | self:size(size.width, size.height)
21 | self.scheduled = scheduler.scheduleGlobal(handler(self, self.updateTime), 1)
22 | end
23 |
24 | function UIClock:updateTime()
25 | self.time_ = self.time_ - 1
26 | if self.time_ == 0 then
27 | scheduler.unscheduleGlobal(self.scheduled)
28 | self.callback_()
29 | else
30 | self.timeLabel:setString(tostring(self.time_))
31 | end
32 | end
33 |
34 | function UIClock:stop()
35 | scheduler.unscheduleGlobal(self.scheduled)
36 | end
37 |
38 | return UIClock
--------------------------------------------------------------------------------
/ddz/src/app/ui/UILoadingBar.lua:
--------------------------------------------------------------------------------
1 |
2 |
3 | local UILoadingBar = class("UILoadingBar", function()
4 | return display.newNode()
5 | --return display.newColorLayer(cc.c4b(255,0,0, 255))
6 | end)
7 |
8 | function UILoadingBar:ctor(spriteLeft, spriteCenter, width)
9 | self.spriteLeft = spriteLeft
10 | self.spriteCenter = spriteCenter
11 | self.spriteRight = self:_createSpriteRight(spriteLeft)
12 | local slSize = spriteLeft:getContentSize()
13 | local scSize = spriteCenter:getContentSize()
14 | self.centerScaleTotal = (width - slSize.width * spriteLeft:getScaleX() * 2) / (scSize.width * spriteCenter:getScaleX())
15 | self.centerScaleTotal = self.centerScaleTotal * spriteLeft:getScaleX() + 0.3
16 | self.width = width
17 | self.percent = 0
18 | end
19 |
20 | function UILoadingBar:_createSpriteRight(sprite)
21 | local rs = sprite:clone()
22 | rs:setFlippedX(true)
23 | return rs
24 | end
25 |
26 | function UILoadingBar:setPercent(percent)
27 | self:removeAllChildren()
28 | if percent > 0 and percent <= 1 then
29 | self.spriteLeft:align(display.LEFT_BOTTOM, 0, 0)
30 | self.spriteLeft:addTo(self)
31 | elseif percent > 1 and percent < 100 then
32 | self.spriteLeft:align(display.LEFT_BOTTOM, 0, 0)
33 | self.spriteLeft:addTo(self)
34 | self.spriteCenter:setScaleX(self.centerScaleTotal * (percent - 2) / 100)
35 | self.spriteCenter:align(display.LEFT_BOTTOM, self.spriteLeft:getContentSize().width * self.spriteLeft:getScaleX(), 0)
36 | self.spriteCenter:addTo(self)
37 | elseif percent >= 100 then
38 | self.spriteLeft:align(display.LEFT_BOTTOM, 0, 0)
39 | self.spriteLeft:addTo(self)
40 | self.spriteCenter:setScaleX(self.centerScaleTotal)
41 | self.spriteCenter:align(display.LEFT_BOTTOM, self.spriteLeft:getContentSize().width * self.spriteLeft:getScaleX(), 0)
42 | self.spriteCenter:addTo(self)
43 | self.spriteRight:align(display.LEFT_BOTTOM, self.width - self.spriteLeft:getContentSize().width * self.spriteLeft:getScaleX(), 0)
44 | self.spriteRight:addTo(self)
45 | end
46 | end
47 |
48 | return UILoadingBar
--------------------------------------------------------------------------------
/ddz/src/app/ui/UIPushButtonEx.lua:
--------------------------------------------------------------------------------
1 |
2 | local UIPushButton = cc.ui.UIPushButton
3 | local UIPushButtonEx = class("UIPushButtonEx", UIPushButton)
4 |
5 | local viewloader = import('..viewloader.viewloader')
6 |
7 | function UIPushButtonEx:updateButtonImage_()
8 | local state = self.fsm_:getState()
9 | local image = self.images_[state]
10 |
11 | if not image then
12 | for _, s in pairs(self:getDefaultState_()) do
13 | image = self.images_[s]
14 | if image then break end
15 | end
16 | end
17 | if image then
18 | if self.currentImage_ ~= image then
19 | for i,v in ipairs(self.sprite_) do
20 | v:removeFromParent(true)
21 | end
22 | self.sprite_ = {}
23 | self.currentImage_ = image
24 |
25 | self.sprite_[1] = viewloader['render_' .. image.renderType](viewloader, unpack(image.args))
26 | if self.sprite_[1].setFlippedX then
27 | if self.flipX_ then
28 | self.sprite_[1]:setFlippedX(self.flipX_ or false)
29 | end
30 | if self.flipY_ then
31 | self.sprite_[1]:setFlippedY(self.flipY_ or false)
32 | end
33 | end
34 | self:addChild(self.sprite_[1], UIPushButtonEx.super.super.IMAGE_ZORDER)
35 | end
36 |
37 | for i,v in ipairs(self.sprite_) do
38 | v:align(display.LEFT_BOTTOM, 0, 0)
39 | end
40 | elseif not self.labels_ then
41 | printError("UIPushButtonEx:updateButtonImage_() - not set image for state %s", state)
42 | end
43 | end
44 |
45 | return UIPushButtonEx
46 |
--------------------------------------------------------------------------------
/ddz/src/app/ui/init.lua:
--------------------------------------------------------------------------------
1 |
2 | local ui = {}
3 |
4 | ui.UILoadingBar = import('.UILoadingBar')
5 | ui.UIPushButtonEx = import('.UIPushButtonEx')
6 | ui.UIBMFontLabel = import('.UIBMFontLabel')
7 | ui.UICardButton = import('.UICardButton')
8 | ui.UIMyCards = import('.UIMyCards')
9 | ui.UIBackCards = import('.UIBackCards')
10 | ui.UILittleCards = import('.UILittleCards')
11 | ui.UIClock = import('.UIClock')
12 |
13 | ui.UILoadingBarController = import('..controllers.UILoadingBarController')
14 | ui.UILoadingMaskController = import('..controllers.UILoadingMaskController')
15 |
16 | ui.viewloader = import('..viewloader.viewloader')
17 |
18 | return ui
19 |
--------------------------------------------------------------------------------
/ddz/src/cocos/cocos2d/bitExtend.lua:
--------------------------------------------------------------------------------
1 | -- bit operation
2 |
3 | bit = bit or {}
4 | bit.data32 = {}
5 |
6 | for i=1,32 do
7 | bit.data32[i]=2^(32-i)
8 | end
9 |
10 | function bit._b2d(arg)
11 | local nr=0
12 | for i=1,32 do
13 | if arg[i] ==1 then
14 | nr=nr+bit.data32[i]
15 | end
16 | end
17 | return nr
18 | end
19 |
20 | function bit._d2b(arg)
21 | arg = arg >= 0 and arg or (0xFFFFFFFF + arg + 1)
22 | local tr={}
23 | for i=1,32 do
24 | if arg >= bit.data32[i] then
25 | tr[i]=1
26 | arg=arg-bit.data32[i]
27 | else
28 | tr[i]=0
29 | end
30 | end
31 | return tr
32 | end
33 |
34 | function bit._and(a,b)
35 | local op1=bit._d2b(a)
36 | local op2=bit._d2b(b)
37 | local r={}
38 |
39 | for i=1,32 do
40 | if op1[i]==1 and op2[i]==1 then
41 | r[i]=1
42 | else
43 | r[i]=0
44 | end
45 | end
46 | return bit._b2d(r)
47 |
48 | end
49 |
50 | function bit._rshift(a,n)
51 | local op1=bit._d2b(a)
52 | n = n <= 32 and n or 32
53 | n = n >= 0 and n or 0
54 |
55 | for i=32, n+1, -1 do
56 | op1[i] = op1[i-n]
57 | end
58 | for i=1, n do
59 | op1[i] = 0
60 | end
61 |
62 | return bit._b2d(op1)
63 | end
64 |
65 | function bit._not(a)
66 | local op1=bit._d2b(a)
67 | local r={}
68 |
69 | for i=1,32 do
70 | if op1[i]==1 then
71 | r[i]=0
72 | else
73 | r[i]=1
74 | end
75 | end
76 | return bit._b2d(r)
77 | end
78 |
79 | function bit._or(a,b)
80 | local op1=bit._d2b(a)
81 | local op2=bit._d2b(b)
82 | local r={}
83 |
84 | for i=1,32 do
85 | if op1[i]==1 or op2[i]==1 then
86 | r[i]=1
87 | else
88 | r[i]=0
89 | end
90 | end
91 | return bit._b2d(r)
92 | end
93 |
94 | bit.band = bit.band or bit._and
95 | bit.rshift = bit.rshift or bit._rshift
96 | bit.bnot = bit.bnot or bit._not
97 |
--------------------------------------------------------------------------------
/ddz/src/cocos/cocos2d/luaj.lua:
--------------------------------------------------------------------------------
1 |
2 | local luaj = {}
3 |
4 | local callJavaStaticMethod = LuaJavaBridge.callStaticMethod
5 |
6 | local function checkArguments(args, sig)
7 | if type(args) ~= "table" then args = {} end
8 | if sig then return args, sig end
9 |
10 | sig = {"("}
11 | for i, v in ipairs(args) do
12 | local t = type(v)
13 | if t == "number" then
14 | sig[#sig + 1] = "F"
15 | elseif t == "boolean" then
16 | sig[#sig + 1] = "Z"
17 | elseif t == "function" then
18 | sig[#sig + 1] = "I"
19 | else
20 | sig[#sig + 1] = "Ljava/lang/String;"
21 | end
22 | end
23 | sig[#sig + 1] = ")V"
24 |
25 | return args, table.concat(sig)
26 | end
27 |
28 | function luaj.callStaticMethod(className, methodName, args, sig)
29 | local args, sig = checkArguments(args, sig)
30 | --echoInfo("luaj.callStaticMethod(\"%s\",\n\t\"%s\",\n\targs,\n\t\"%s\"", className, methodName, sig)
31 | return callJavaStaticMethod(className, methodName, args, sig)
32 | end
33 |
34 | return luaj
35 |
--------------------------------------------------------------------------------
/ddz/src/cocos/cocos2d/luaoc.lua:
--------------------------------------------------------------------------------
1 |
2 | local luaoc = {}
3 |
4 | local callStaticMethod = LuaObjcBridge.callStaticMethod
5 |
6 | function luaoc.callStaticMethod(className, methodName, args)
7 | local ok, ret = callStaticMethod(className, methodName, args)
8 | if not ok then
9 | local msg = string.format("luaoc.callStaticMethod(\"%s\", \"%s\", \"%s\") - error: [%s] ",
10 | className, methodName, tostring(args), tostring(ret))
11 | if ret == -1 then
12 | print(msg .. "INVALID PARAMETERS")
13 | elseif ret == -2 then
14 | print(msg .. "CLASS NOT FOUND")
15 | elseif ret == -3 then
16 | print(msg .. "METHOD NOT FOUND")
17 | elseif ret == -4 then
18 | print(msg .. "EXCEPTION OCCURRED")
19 | elseif ret == -5 then
20 | print(msg .. "INVALID METHOD SIGNATURE")
21 | else
22 | print(msg .. "UNKNOWN")
23 | end
24 | end
25 | return ok, ret
26 | end
27 |
28 | return luaoc
29 |
--------------------------------------------------------------------------------
/ddz/src/cocos/cocosbuilder/DeprecatedCocosBuilderClass.lua:
--------------------------------------------------------------------------------
1 | -- This is the DeprecatedCocosBuilderClass
2 |
3 | DeprecatedCocosBuilderClass = {} or DeprecatedCocosBuilderClass
4 |
5 | --tip
6 | local function deprecatedTip(old_name,new_name)
7 | print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********")
8 | end
9 |
10 | --CCBReader class will be Deprecated,begin
11 | function DeprecatedCocosBuilderClass.CCBReader()
12 | deprecatedTip("CCBReader","cc.BReader")
13 | return cc.BReader
14 | end
15 | _G["CCBReader"] = DeprecatedCocosBuilderClass.CCBReader()
16 | --CCBReader class will be Deprecated,end
17 |
18 | --CCBAnimationManager class will be Deprecated,begin
19 | function DeprecatedCocosBuilderClass.CCBAnimationManager()
20 | deprecatedTip("CCBAnimationManager","cc.BAnimationManager")
21 | return cc.BAnimationManager
22 | end
23 | _G["CCBAnimationManager"] = DeprecatedCocosBuilderClass.CCBAnimationManager()
24 | --CCBAnimationManager class will be Deprecated,end
25 |
26 | --CCBProxy class will be Deprecated,begin
27 | function DeprecatedCocosBuilderClass.CCBProxy()
28 | deprecatedTip("CCBProxy","cc.CCBProxy")
29 | return cc.CCBProxy
30 | end
31 | _G["CCBProxy"] = DeprecatedCocosBuilderClass.CCBProxy()
32 | --CCBProxy class will be Deprecated,end
33 |
--------------------------------------------------------------------------------
/ddz/src/cocos/cocosdenshion/DeprecatedCocosDenshionClass.lua:
--------------------------------------------------------------------------------
1 | -- This is the DeprecatedCocosDenshionClass
2 |
3 | DeprecatedCocosDenshionClass = {} or DeprecatedCocosDenshionClass
4 |
5 | --tip
6 | local function deprecatedTip(old_name,new_name)
7 | print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********")
8 | end
9 |
10 | --SimpleAudioEngine class will be Deprecated,begin
11 | function DeprecatedCocosDenshionClass.SimpleAudioEngine()
12 | deprecatedTip("SimpleAudioEngine","cc.SimpleAudioEngine")
13 | return cc.SimpleAudioEngine
14 | end
15 | _G["SimpleAudioEngine"] = DeprecatedCocosDenshionClass.SimpleAudioEngine()
16 | --SimpleAudioEngine class will be Deprecated,end
17 |
--------------------------------------------------------------------------------
/ddz/src/cocos/cocosdenshion/DeprecatedCocosDenshionFunc.lua:
--------------------------------------------------------------------------------
1 | --tip
2 | local function deprecatedTip(old_name,new_name)
3 | print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********")
4 | end
5 |
6 | --functions of SimpleAudioEngine will be deprecated begin
7 | local SimpleAudioEngineDeprecated = { }
8 | function SimpleAudioEngineDeprecated.sharedEngine()
9 | deprecatedTip("SimpleAudioEngine:sharedEngine","SimpleAudioEngine:getInstance")
10 | return cc.SimpleAudioEngine:getInstance()
11 | end
12 | SimpleAudioEngine.sharedEngine = SimpleAudioEngineDeprecated.sharedEngine
13 |
14 | function SimpleAudioEngineDeprecated.playBackgroundMusic(self,...)
15 | deprecatedTip("SimpleAudioEngine:playBackgroundMusic","SimpleAudioEngine:playMusic")
16 | return self:playMusic(...)
17 | end
18 | SimpleAudioEngine.playBackgroundMusic = SimpleAudioEngineDeprecated.playBackgroundMusic
19 | --functions of SimpleAudioEngine will be deprecated end
20 |
--------------------------------------------------------------------------------
/ddz/src/cocos/cocostudio/StudioConstants.lua:
--------------------------------------------------------------------------------
1 |
2 | ccs = ccs or {}
3 |
4 | ccs.MovementEventType = {
5 | start = 0,
6 | complete = 1,
7 | loopComplete = 2,
8 | }
9 |
--------------------------------------------------------------------------------
/ddz/src/cocos/controller/ControllerConstants.lua:
--------------------------------------------------------------------------------
1 |
2 | cc = cc or {}
3 |
4 | cc.ControllerKey =
5 | {
6 | JOYSTICK_LEFT_X = 1000,
7 | JOYSTICK_LEFT_Y = 1001,
8 | JOYSTICK_RIGHT_X = 1002,
9 | JOYSTICK_RIGHT_Y = 1003,
10 |
11 | BUTTON_A = 1004,
12 | BUTTON_B = 1005,
13 | BUTTON_C = 1006,
14 | BUTTON_X = 1007,
15 | BUTTON_Y = 1008,
16 | BUTTON_Z = 1009,
17 |
18 | BUTTON_DPAD_UP = 1010,
19 | BUTTON_DPAD_DOWN = 1011,
20 | BUTTON_DPAD_LEFT = 1012,
21 | BUTTON_DPAD_RIGHT = 1013,
22 | BUTTON_DPAD_CENTER = 1014,
23 |
24 | BUTTON_LEFT_SHOULDER = 1015,
25 | BUTTON_RIGHT_SHOULDER = 1016,
26 |
27 | AXIS_LEFT_TRIGGER = 1017,
28 | AXIS_RIGHT_TRIGGER = 1018,
29 |
30 | BUTTON_LEFT_THUMBSTICK = 1019,
31 | BUTTON_RIGHT_THUMBSTICK = 1020,
32 |
33 | BUTTON_START = 1021,
34 | BUTTON_SELECT = 1022,
35 |
36 | BUTTON_PAUSE = 1023,
37 | KEY_MAX = 1024,
38 | }
39 |
--------------------------------------------------------------------------------
/ddz/src/cocos/extension/DeprecatedExtensionEnum.lua:
--------------------------------------------------------------------------------
1 |
2 | _G.kCCControlStepperPartMinus = cc.CONTROL_STEPPER_PART_MINUS
3 | _G.kCCControlStepperPartPlus = cc.CONTROL_STEPPER_PART_PLUS
4 | _G.kCCControlStepperPartNone = cc.CONTROL_STEPPER_PART_NONE
5 |
6 | _G.CCControlEventTouchDown = cc.CONTROL_EVENTTYPE_TOUCH_DOWN
7 | _G.CCControlEventTouchDragInside = cc.CONTROL_EVENTTYPE_DRAG_INSIDE
8 | _G.CCControlEventTouchDragOutside = cc.CONTROL_EVENTTYPE_DRAG_OUTSIDE
9 | _G.CCControlEventTouchDragEnter = cc.CONTROL_EVENTTYPE_DRAG_ENTER
10 | _G.CCControlEventTouchDragExit = cc.CONTROL_EVENTTYPE_DRAG_EXIT
11 | _G.CCControlEventTouchUpInside = cc.CONTROL_EVENTTYPE_TOUCH_UP_INSIDE
12 | _G.CCControlEventTouchUpOutside = cc.CONTROL_EVENTTYPE_TOUCH_UP_OUTSIDE
13 | _G.CCControlEventTouchCancel = cc.CONTROL_EVENTTYPE_TOUCH_CANCEL
14 | _G.CCControlEventValueChanged = cc.CONTROL_EVENTTYPE_VALUE_CHANGED
15 | _G.CCControlStateNormal = cc.CONTROL_STATE_NORMAL
16 | _G.CCControlStateHighlighted = cc.CONTROL_STATE_HIGH_LIGHTED
17 | _G.CCControlStateDisabled = cc.CONTROL_STATE_DISABLED
18 | _G.CCControlStateSelected = cc.CONTROL_STATE_SELECTED
19 |
20 | _G.kCCScrollViewDirectionHorizontal = cc.SCROLLVIEW_DIRECTION_HORIZONTAL
21 | _G.kCCScrollViewDirectionVertical = cc.SCROLLVIEW_DIRECTION_VERTICAL
22 | _G.kCCTableViewFillTopDown = cc.TABLEVIEW_FILL_TOPDOWN
23 | _G.kCCTableViewFillBottomUp = cc.TABLEVIEW_FILL_BOTTOMUP
24 |
--------------------------------------------------------------------------------
/ddz/src/cocos/extension/DeprecatedExtensionFunc.lua:
--------------------------------------------------------------------------------
1 | --tip
2 | local function deprecatedTip(old_name,new_name)
3 | print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********")
4 | end
5 |
6 | --functions of CCControl will be deprecated end
7 | local CCControlDeprecated = { }
8 | function CCControlDeprecated.addHandleOfControlEvent(self,func,controlEvent)
9 | deprecatedTip("addHandleOfControlEvent","registerControlEventHandler")
10 | print("come in addHandleOfControlEvent")
11 | self:registerControlEventHandler(func,controlEvent)
12 | end
13 | CCControl.addHandleOfControlEvent = CCControlDeprecated.addHandleOfControlEvent
14 | --functions of CCControl will be deprecated end
15 |
16 | --Enums of CCTableView will be deprecated begin
17 | CCTableView.kTableViewScroll = cc.SCROLLVIEW_SCRIPT_SCROLL
18 | CCTableView.kTableViewZoom = cc.SCROLLVIEW_SCRIPT_ZOOM
19 | CCTableView.kTableCellTouched = cc.TABLECELL_TOUCHED
20 | CCTableView.kTableCellSizeForIndex = cc.TABLECELL_SIZE_FOR_INDEX
21 | CCTableView.kTableCellSizeAtIndex = cc.TABLECELL_SIZE_AT_INDEX
22 | CCTableView.kNumberOfCellsInTableView = cc.NUMBER_OF_CELLS_IN_TABLEVIEW
23 | --Enums of CCTableView will be deprecated end
24 |
25 | --Enums of CCScrollView will be deprecated begin
26 | CCScrollView.kScrollViewScroll = cc.SCROLLVIEW_SCRIPT_SCROLL
27 | CCScrollView.kScrollViewZoom = cc.SCROLLVIEW_SCRIPT_ZOOM
28 | --Enums of CCScrollView will be deprecated end
29 |
--------------------------------------------------------------------------------
/ddz/src/cocos/extension/ExtensionConstants.lua:
--------------------------------------------------------------------------------
1 |
2 | cc = cc or {}
3 |
4 | cc.CONTROL_STATE_NORMAL = 1
5 | cc.CONTROL_STATE_HIGH_LIGHTED = 2
6 | cc.CONTROL_STATE_DISABLED = 4
7 | cc.CONTROL_STATE_SELECTED = 8
8 |
9 | cc.CONTROL_STEPPER_PART_MINUS = 0
10 | cc.CONTROL_STEPPER_PART_PLUS = 1
11 | cc.CONTROL_STEPPER_PART_NONE = 2
12 |
13 | cc.TABLEVIEW_FILL_TOPDOWN = 0
14 | cc.TABLEVIEW_FILL_BOTTOMUP = 1
15 |
16 | cc.SCROLLVIEW_SCRIPT_SCROLL = 0
17 | cc.SCROLLVIEW_SCRIPT_ZOOM = 1
18 | cc.TABLECELL_TOUCHED = 2
19 | cc.TABLECELL_HIGH_LIGHT = 3
20 | cc.TABLECELL_UNHIGH_LIGHT = 4
21 | cc.TABLECELL_WILL_RECYCLE = 5
22 | cc.TABLECELL_SIZE_FOR_INDEX = 6
23 | cc.TABLECELL_SIZE_AT_INDEX = 7
24 | cc.NUMBER_OF_CELLS_IN_TABLEVIEW = 8
25 |
26 | cc.SCROLLVIEW_DIRECTION_NONE = -1
27 | cc.SCROLLVIEW_DIRECTION_HORIZONTAL = 0
28 | cc.SCROLLVIEW_DIRECTION_VERTICAL = 1
29 | cc.SCROLLVIEW_DIRECTION_BOTH = 2
30 |
31 | cc.CONTROL_EVENTTYPE_TOUCH_DOWN = 1
32 | cc.CONTROL_EVENTTYPE_DRAG_INSIDE = 2
33 | cc.CONTROL_EVENTTYPE_DRAG_OUTSIDE = 4
34 | cc.CONTROL_EVENTTYPE_DRAG_ENTER = 8
35 | cc.CONTROL_EVENTTYPE_DRAG_EXIT = 16
36 | cc.CONTROL_EVENTTYPE_TOUCH_UP_INSIDE = 32
37 | cc.CONTROL_EVENTTYPE_TOUCH_UP_OUTSIDE = 64
38 | cc.CONTROL_EVENTTYPE_TOUCH_CANCEL = 128
39 | cc.CONTROL_EVENTTYPE_VALUE_CHANGED = 256
40 |
41 | cc.EDITBOX_INPUT_MODE_ANY = 0
42 | cc.EDITBOX_INPUT_MODE_EMAILADDR = 1
43 | cc.EDITBOX_INPUT_MODE_NUMERIC = 2
44 | cc.EDITBOX_INPUT_MODE_PHONENUMBER = 3
45 | cc.EDITBOX_INPUT_MODE_URL = 4
46 | cc.EDITBOX_INPUT_MODE_DECIMAL = 5
47 | cc.EDITBOX_INPUT_MODE_SINGLELINE = 6
48 |
49 | cc.EDITBOX_INPUT_FLAG_PASSWORD = 0
50 | cc.EDITBOX_INPUT_FLAG_SENSITIVE = 1
51 | cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_WORD = 2
52 | cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_SENTENCE = 3
53 | cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS = 4
54 |
55 | cc.KEYBOARD_RETURNTYPE_DEFAULT = 0
56 | cc.KEYBOARD_RETURNTYPE_DONE = 1
57 | cc.KEYBOARD_RETURNTYPE_SEND = 2
58 | cc.KEYBOARD_RETURNTYPE_SEARCH = 3
59 | cc.KEYBOARD_RETURNTYPE_GO = 4
60 |
61 | cc.ASSETSMANAGER_CREATE_FILE = 0
62 | cc.ASSETSMANAGER_NETWORK = 1
63 | cc.ASSETSMANAGER_NO_NEW_VERSION = 2
64 | cc.ASSETSMANAGER_UNCOMPRESS = 3
65 |
66 | cc.ASSETSMANAGER_PROTOCOL_PROGRESS = 0
67 | cc.ASSETSMANAGER_PROTOCOL_SUCCESS = 1
68 | cc.ASSETSMANAGER_PROTOCOL_ERROR = 2
69 |
70 |
--------------------------------------------------------------------------------
/ddz/src/cocos/init.lua:
--------------------------------------------------------------------------------
1 |
2 | require "cocos.cocos2d.Cocos2d"
3 | require "cocos.cocos2d.Cocos2dConstants"
4 | require "cocos.cocos2d.extern"
5 | require "cocos.cocos2d.bitExtend"
6 | require "cocos.cocos2d.DrawPrimitives"
7 |
8 | -- opengl
9 | require "cocos.cocos2d.Opengl"
10 | require "cocos.cocos2d.OpenglConstants"
11 |
12 | -- cocosbuilder
13 | require "cocos.cocosbuilder.CCBReaderLoad"
14 |
15 | -- cocosdenshion
16 | require "cocos.cocosdenshion.AudioEngine"
17 |
18 | -- cocosstudio
19 | require "cocos.cocostudio.CocoStudio"
20 |
21 | -- ui
22 | require "cocos.ui.GuiConstants"
23 | require "cocos.ui.experimentalUIConstants"
24 |
25 | -- extensions
26 | require "cocos.extension.ExtensionConstants"
27 |
28 | -- network
29 | require "cocos.network.NetworkConstants"
30 |
31 | -- Spine
32 | require "cocos.spine.SpineConstants"
33 |
34 | if CC_USE_DEPRECATED_API then
35 | -- CCLuaEngine
36 | require "cocos.cocos2d.DeprecatedCocos2dClass"
37 | require "cocos.cocos2d.DeprecatedCocos2dEnum"
38 | require "cocos.cocos2d.DeprecatedCocos2dFunc"
39 | require "cocos.cocos2d.DeprecatedOpenglEnum"
40 |
41 | -- register_cocostudio_module
42 | require "cocos.cocostudio.DeprecatedCocoStudioClass"
43 | require "cocos.cocostudio.DeprecatedCocoStudioFunc"
44 |
45 | -- register_cocosbuilder_module
46 | require "cocos.cocosbuilder.DeprecatedCocosBuilderClass"
47 |
48 | -- register_cocosdenshion_module
49 | require "cocos.cocosdenshion.DeprecatedCocosDenshionClass"
50 | require "cocos.cocosdenshion.DeprecatedCocosDenshionFunc"
51 |
52 | -- register_extension_module
53 | require "cocos.extension.DeprecatedExtensionClass"
54 | require "cocos.extension.DeprecatedExtensionEnum"
55 | require "cocos.extension.DeprecatedExtensionFunc"
56 |
57 | -- register_network_module
58 | require "cocos.network.DeprecatedNetworkClass"
59 | require "cocos.network.DeprecatedNetworkEnum"
60 | require "cocos.network.DeprecatedNetworkFunc"
61 |
62 | -- register_ui_moudle
63 | require "cocos.ui.DeprecatedUIEnum"
64 | require "cocos.ui.DeprecatedUIFunc"
65 | end
66 |
--------------------------------------------------------------------------------
/ddz/src/cocos/network/DeprecatedNetworkClass.lua:
--------------------------------------------------------------------------------
1 | -- This is the DeprecatedNetworkClass
2 |
3 | DeprecatedNetworkClass = {} or DeprecatedNetworkClass
4 |
5 | --tip
6 | local function deprecatedTip(old_name,new_name)
7 | print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********")
8 | end
9 |
10 | --WebSocket class will be Deprecated,begin
11 | function DeprecatedNetworkClass.WebSocket()
12 | deprecatedTip("WebSocket","cc.WebSocket")
13 | return cc.WebSocket
14 | end
15 | _G["WebSocket"] = DeprecatedNetworkClass.WebSocket()
16 | --WebSocket class will be Deprecated,end
17 |
--------------------------------------------------------------------------------
/ddz/src/cocos/network/DeprecatedNetworkEnum.lua:
--------------------------------------------------------------------------------
1 | _G.kWebSocketScriptHandlerOpen = cc.WEBSOCKET_OPEN
2 | _G.kWebSocketScriptHandlerMessage = cc.WEBSOCKET_MESSAGE
3 | _G.kWebSocketScriptHandlerClose = cc.WEBSOCKET_CLOSE
4 | _G.kWebSocketScriptHandlerError = cc.WEBSOCKET_ERROR
5 |
6 | _G.kStateConnecting = cc.WEBSOCKET_STATE_CONNECTING
7 | _G.kStateOpen = cc.WEBSOCKET_STATE_OPEN
8 | _G.kStateClosing = cc.WEBSOCKET_STATE_CLOSING
9 | _G.kStateClosed = cc.WEBSOCKET_STATE_CLOSED
10 |
--------------------------------------------------------------------------------
/ddz/src/cocos/network/DeprecatedNetworkFunc.lua:
--------------------------------------------------------------------------------
1 | --tip
2 | local function deprecatedTip(old_name,new_name)
3 | print("\n********** \n"..old_name.." was deprecated please use ".. new_name .. " instead.\n**********")
4 | end
5 |
6 | --functions of WebSocket will be deprecated begin
7 | local targetPlatform = CCApplication:getInstance():getTargetPlatform()
8 | if (kTargetIphone == targetPlatform) or (kTargetIpad == targetPlatform) or (kTargetAndroid == targetPlatform) or (kTargetWindows == targetPlatform) then
9 | local WebSocketDeprecated = { }
10 | function WebSocketDeprecated.sendTextMsg(self, string)
11 | deprecatedTip("WebSocket:sendTextMsg","WebSocket:sendString")
12 | return self:sendString(string)
13 | end
14 | WebSocket.sendTextMsg = WebSocketDeprecated.sendTextMsg
15 |
16 | function WebSocketDeprecated.sendBinaryMsg(self, table,tablesize)
17 | deprecatedTip("WebSocket:sendBinaryMsg","WebSocket:sendString")
18 | string.char(unpack(table))
19 | return self:sendString(string.char(unpack(table)))
20 | end
21 | WebSocket.sendBinaryMsg = WebSocketDeprecated.sendBinaryMsg
22 | end
23 | --functions of WebSocket will be deprecated end
24 |
--------------------------------------------------------------------------------
/ddz/src/cocos/network/NetworkConstants.lua:
--------------------------------------------------------------------------------
1 |
2 | cc = cc or {}
3 |
4 | cc.WEBSOCKET_OPEN = 0
5 | cc.WEBSOCKET_MESSAGE = 1
6 | cc.WEBSOCKET_CLOSE = 2
7 | cc.WEBSOCKET_ERROR = 3
8 |
9 | cc.WEBSOCKET_STATE_CONNECTING = 0
10 | cc.WEBSOCKET_STATE_OPEN = 1
11 | cc.WEBSOCKET_STATE_CLOSING = 2
12 | cc.WEBSOCKET_STATE_CLOSED = 3
13 |
14 | cc.XMLHTTPREQUEST_RESPONSE_STRING = 0
15 | cc.XMLHTTPREQUEST_RESPONSE_ARRAY_BUFFER = 1
16 | cc.XMLHTTPREQUEST_RESPONSE_BLOB = 2
17 | cc.XMLHTTPREQUEST_RESPONSE_DOCUMENT = 3
18 | cc.XMLHTTPREQUEST_RESPONSE_JSON = 4
19 |
--------------------------------------------------------------------------------
/ddz/src/cocos/spine/SpineConstants.lua:
--------------------------------------------------------------------------------
1 |
2 | sp = sp or {}
3 |
4 | sp.EventType =
5 | {
6 | ANIMATION_START = 0,
7 | ANIMATION_END = 1,
8 | ANIMATION_COMPLETE = 2,
9 | ANIMATION_EVENT = 3,
10 | }
11 |
--------------------------------------------------------------------------------
/ddz/src/cocos/ui/experimentalUIConstants.lua:
--------------------------------------------------------------------------------
1 | ccexp = ccexp or {}
2 |
3 |
4 | ccexp.VideoPlayerEvent = {
5 | PLAYING = 0,
6 | PAUSED = 1,
7 | STOPPED= 2,
8 | COMPLETED =3,
9 | }
10 |
--------------------------------------------------------------------------------
/ddz/src/config.lua:
--------------------------------------------------------------------------------
1 |
2 | -- 0 - disable debug info, 1 - less debug info, 2 - verbose debug info
3 | DEBUG = 2
4 |
5 | DEBUG_SHOW_FILE = true
6 | DEBUG_FILE_TRIMMED_PREFIX = 'ddz/'
7 |
8 | -- display FPS stats on screen
9 | DEBUG_FPS = true
10 |
11 | -- dump memory info every 10 seconds
12 | DEBUG_MEM = false
13 |
14 | -- load deprecated API
15 | LOAD_DEPRECATED_API = false
16 |
17 | -- load shortcodes API
18 | LOAD_SHORTCODES_API = true
19 |
20 | -- screen orientation
21 | CONFIG_SCREEN_ORIENTATION = "lanscape"
22 |
23 | -- design resolution
24 | CONFIG_SCREEN_WIDTH = 480
25 | CONFIG_SCREEN_HEIGHT = 320
26 |
27 | -- auto scale mode
28 | CONFIG_SCREEN_AUTOSCALE = "FIXED_WIDTH"
29 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/EventProxy.lua:
--------------------------------------------------------------------------------
1 |
2 | local EventProxy = class("EventProxy")
3 |
4 | function EventProxy:ctor(eventDispatcher, view)
5 | self.eventDispatcher_ = eventDispatcher
6 | self.handles_ = {}
7 |
8 | if view then
9 | cc(view):addNodeEventListener(cc.NODE_EVENT, function(event)
10 | if event.name == "exit" then
11 | self:removeAllEventListeners()
12 | end
13 | end)
14 | end
15 | end
16 |
17 | function EventProxy:addEventListener(eventName, listener, data)
18 | local handle = self.eventDispatcher_:addEventListener(eventName, listener, data)
19 | self.handles_[#self.handles_ + 1] = {eventName, handle}
20 | return self, handle
21 | end
22 |
23 | function EventProxy:removeEventListener(eventHandle)
24 | self.eventDispatcher_:removeEventListener(eventHandle)
25 | for index, handle in pairs(self.handles_) do
26 | if handle[2] == eventHandle then
27 | table.remove(self.handles_, index)
28 | break
29 | end
30 | end
31 | return self
32 | end
33 |
34 | function EventProxy:removeAllEventListenersForEvent(eventName)
35 | for key, handle in pairs(self.handles_) do
36 | if handle[1] == eventName then
37 | self.eventDispatcher_:removeEventListenersByEvent(eventName)
38 | self.handles_[key] = nil
39 | end
40 | end
41 | return self
42 | end
43 |
44 | function EventProxy:getEventHandle(eventName)
45 | for key, handle in pairs(self.handles_) do
46 | if handle[1] == eventName then
47 | return handle[2]
48 | end
49 | end
50 | end
51 |
52 | function EventProxy:removeAllEventListeners()
53 | for _, handle in pairs(self.handles_) do
54 | self.eventDispatcher_:removeEventListener(handle[2])
55 | end
56 | self.handles_ = {}
57 | return self
58 | end
59 |
60 | return EventProxy
61 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/GameObject.lua:
--------------------------------------------------------------------------------
1 |
2 | local Registry = import(".Registry")
3 |
4 | local GameObject = {}
5 |
6 | function GameObject.extend(target)
7 | target.components_ = {}
8 |
9 | function target:checkComponent(name)
10 | return self.components_[name] ~= nil
11 | end
12 |
13 | function target:addComponent(name)
14 | local component = Registry.newObject(name)
15 | self.components_[name] = component
16 | component:bind_(self)
17 | return component
18 | end
19 |
20 | function target:removeComponent(name)
21 | local component = self.components_[name]
22 | if component then component:unbind_() end
23 | self.components_[name] = nil
24 | end
25 |
26 | function target:getComponent(name)
27 | return self.components_[name]
28 | end
29 |
30 | return target
31 | end
32 |
33 | return GameObject
34 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/Registry.lua:
--------------------------------------------------------------------------------
1 |
2 | local Registry = class("Registry")
3 |
4 | Registry.classes_ = {}
5 | Registry.objects_ = {}
6 |
7 | function Registry.add(cls, name)
8 | assert(type(cls) == "table" and cls.__cname ~= nil, "Registry.add() - invalid class")
9 | if not name then name = cls.__cname end
10 | assert(Registry.classes_[name] == nil, string.format("Registry.add() - class \"%s\" already exists", tostring(name)))
11 | Registry.classes_[name] = cls
12 | end
13 |
14 | function Registry.remove(name)
15 | assert(Registry.classes_[name] ~= nil, string.format("Registry.remove() - class \"%s\" not found", name))
16 | Registry.classes_[name] = nil
17 | end
18 |
19 | function Registry.exists(name)
20 | return Registry.classes_[name] ~= nil
21 | end
22 |
23 | function Registry.newObject(name, ...)
24 | local cls = Registry.classes_[name]
25 | if not cls then
26 | -- auto load
27 | pcall(function()
28 | cls = require(name)
29 | Registry.add(cls, name)
30 | end)
31 | end
32 | assert(cls ~= nil, string.format("Registry.newObject() - invalid class \"%s\"", tostring(name)))
33 | return cls.new(...)
34 | end
35 |
36 | function Registry.setObject(object, name)
37 | assert(Registry.objects_[name] == nil, string.format("Registry.setObject() - object \"%s\" already exists", tostring(name)))
38 | assert(object ~= nil, "Registry.setObject() - object \"%s\" is nil", tostring(name))
39 | Registry.objects_[name] = object
40 | end
41 |
42 | function Registry.getObject(name)
43 | assert(Registry.objects_[name] ~= nil, string.format("Registry.getObject() - object \"%s\" not exists", tostring(name)))
44 | return Registry.objects_[name]
45 | end
46 |
47 | function Registry.removeObject(name)
48 | assert(Registry.objects_[name] ~= nil, string.format("Registry.removeObject() - object \"%s\" not exists", tostring(name)))
49 | Registry.objects_[name] = nil
50 | end
51 |
52 | function Registry.isObjectExists(name)
53 | return Registry.objects_[name] ~= nil
54 | end
55 |
56 | return Registry
57 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/components/Component.lua:
--------------------------------------------------------------------------------
1 |
2 | local Component = class("Component")
3 |
4 | function Component:ctor(name, depends)
5 | self.name_ = name
6 | self.depends_ = checktable(depends)
7 | end
8 |
9 | function Component:getName()
10 | return self.name_
11 | end
12 |
13 | function Component:getDepends()
14 | return self.depends_
15 | end
16 |
17 | function Component:getTarget()
18 | return self.target_
19 | end
20 |
21 | function Component:exportMethods_(methods)
22 | self.exportedMethods_ = methods
23 | local target = self.target_
24 | local com = self
25 | for _, key in ipairs(methods) do
26 | if not target[key] then
27 | local m = com[key]
28 | target[key] = function(__, ...)
29 | return m(com, ...)
30 | end
31 | end
32 | end
33 | return self
34 | end
35 |
36 | function Component:bind_(target)
37 | self.target_ = target
38 | for _, name in ipairs(self.depends_) do
39 | if not target:checkComponent(name) then
40 | target:addComponent(name)
41 | end
42 | end
43 | self:onBind_(target)
44 | end
45 |
46 | function Component:unbind_()
47 | if self.exportedMethods_ then
48 | local target = self.target_
49 | for _, key in ipairs(self.exportedMethods_) do
50 | target[key] = nil
51 | end
52 | end
53 | self:onUnbind_()
54 | end
55 |
56 | function Component:onBind_()
57 | end
58 |
59 | function Component:onUnbind_()
60 | end
61 |
62 | return Component
63 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/components/ui/DraggableProtocol.lua:
--------------------------------------------------------------------------------
1 |
2 | local Component = cc.Component
3 | local DraggableProtocol = class("DraggableProtocol", Component)
4 |
5 | function DraggableProtocol:ctor()
6 | DraggableProtocol.super.ctor(self, "DraggableProtocol")
7 | end
8 |
9 | function DraggableProtocol:setDraggableEnable(bEnable)
10 | if bEnable then
11 | self.target_:setTouchEnabled(true)
12 | self.target_:addNodeEventListener(cc.NODE_TOUCH_EVENT, function (event)
13 | return self:dragOnTouch_(event)
14 | end)
15 | else
16 | self.target_:setTouchEnabled(false)
17 | end
18 |
19 | return self.target_
20 | end
21 |
22 | function DraggableProtocol:exportMethods()
23 | self:exportMethods_({
24 | "setDraggableEnable",
25 | })
26 |
27 | return self.target_
28 | end
29 |
30 | function DraggableProtocol:dragOnTouch_(event)
31 | local boundingBox = self.target_:getCascadeBoundingBox()
32 |
33 | if "began" == event.name and not cc.rectContainsPoint(boundingBox, cc.p(event.x, event.y)) then
34 | printInfo("DraggableProtocol - touch didn't in viewRect")
35 | return false
36 | end
37 |
38 | if "began" == event.name then
39 | return true
40 | elseif "moved" == event.name then
41 | local posX, posY = self.target_:getPosition()
42 | self.target_:setPosition(
43 | posX + event.x - event.prevX,
44 | posY + event.y - event.prevY)
45 | elseif "ended" == event.name then
46 | end
47 | end
48 |
49 | return DraggableProtocol
50 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/components/ui/LayoutProtocol.lua:
--------------------------------------------------------------------------------
1 |
2 | local BasicLayoutProtocol = import(".BasicLayoutProtocol")
3 | local LayoutProtocol = class("LayoutProtocol", BasicLayoutProtocol)
4 |
5 | function LayoutProtocol:ctor()
6 | LayoutProtocol.super.ctor(self, "LayoutProtocol")
7 | end
8 |
9 | function LayoutProtocol:setLayoutSize(width, height)
10 | LayoutProtocol.super.setLayoutSize(self, width, height)
11 | self:setLayout(self.layout_)
12 | return self.target_
13 | end
14 |
15 | function LayoutProtocol:setLayout(layout)
16 | self.layout_ = layout
17 | if layout then
18 | layout:apply(self.target_)
19 | end
20 | return self.target_
21 | end
22 |
23 | function LayoutProtocol:getLayout()
24 | return self.layout_
25 | end
26 |
27 | function LayoutProtocol:exportMethods()
28 | LayoutProtocol.super.exportMethods(self)
29 | self:exportMethods_({
30 | "setLayout",
31 | "getLayout",
32 | })
33 | return self.target_
34 | end
35 |
36 | return LayoutProtocol
37 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/init.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | --[[--
26 |
27 | 初始化 cc 扩展
28 |
29 | cc 扩展在 cocos2dx C++ API 和 quick 基本模块的基础上,提供了符合脚本风格的事件接口、组件架构等扩展。
30 |
31 | ]]
32 |
33 | local CURRENT_MODULE_NAME = ...
34 |
35 | -- init base classes
36 | cc.Registry = import(".Registry")
37 | cc.GameObject = import(".GameObject")
38 | cc.EventProxy = import(".EventProxy")
39 | cc.Component = import(".components.Component")
40 |
41 | -- init components
42 | local components = {
43 | "components.behavior.StateMachine",
44 | "components.behavior.EventProtocol",
45 | "components.ui.BasicLayoutProtocol",
46 | "components.ui.LayoutProtocol",
47 | "components.ui.DraggableProtocol",
48 | }
49 | for _, packageName in ipairs(components) do
50 | cc.Registry.add(import("." .. packageName, CURRENT_MODULE_NAME), packageName)
51 | end
52 |
53 | -- cc = cc.GameObject.extend()
54 | local GameObject = cc.GameObject
55 | local ccmt = {}
56 | ccmt.__call = function(self, target)
57 | if target then
58 | return GameObject.extend(target)
59 | end
60 | printError("cc() - invalid target")
61 | end
62 | setmetatable(cc, ccmt)
63 |
64 | -- load MVC
65 | cc.mvc = import(".mvc.init")
66 |
67 | -- load more library
68 | cc.ui = import(".ui.init")
69 |
70 | -- load extensions
71 | cc.uiloader = import(".uiloader.init")
72 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/mvc/AppBase.lua:
--------------------------------------------------------------------------------
1 |
2 | local AppBase = class("AppBase")
3 |
4 | AppBase.APP_ENTER_BACKGROUND_EVENT = "APP_ENTER_BACKGROUND_EVENT"
5 | AppBase.APP_ENTER_FOREGROUND_EVENT = "APP_ENTER_FOREGROUND_EVENT"
6 |
7 | function AppBase:ctor(appName, packageRoot)
8 | cc(self):addComponent("components.behavior.EventProtocol"):exportMethods()
9 |
10 | self.name = appName
11 | self.packageRoot = packageRoot or "app"
12 |
13 | local eventDispatcher = cc.Director:getInstance():getEventDispatcher()
14 | local customListenerBg = cc.EventListenerCustom:create(AppBase.APP_ENTER_BACKGROUND_EVENT,
15 | handler(self, self.onEnterBackground))
16 | eventDispatcher:addEventListenerWithFixedPriority(customListenerBg, 1)
17 | local customListenerFg = cc.EventListenerCustom:create(AppBase.APP_ENTER_FOREGROUND_EVENT,
18 | handler(self, self.onEnterForeground))
19 | eventDispatcher:addEventListenerWithFixedPriority(customListenerFg, 1)
20 |
21 | self.snapshots_ = {}
22 |
23 | -- set global app
24 | app = self
25 | end
26 |
27 | function AppBase:run()
28 | end
29 |
30 | function AppBase:exit()
31 | cc.Director:getInstance():endToLua()
32 | if device.platform == "windows" or device.platform == "mac" then
33 | os.exit()
34 | end
35 | end
36 |
37 | function AppBase:enterScene(sceneName, args, transitionType, time, more)
38 | local scenePackageName = self.packageRoot .. ".scenes." .. sceneName
39 | local sceneClass = require(scenePackageName)
40 | local scene = sceneClass.new(unpack(checktable(args)))
41 | display.replaceScene(scene, transitionType, time, more)
42 | end
43 |
44 | function AppBase:createView(viewName, ...)
45 | local viewPackageName = self.packageRoot .. ".views." .. viewName
46 | local viewClass = require(viewPackageName)
47 | return viewClass.new(...)
48 | end
49 |
50 | function AppBase:onEnterBackground()
51 | self:dispatchEvent({name = AppBase.APP_ENTER_BACKGROUND_EVENT})
52 | end
53 |
54 | function AppBase:onEnterForeground()
55 | self:dispatchEvent({name = AppBase.APP_ENTER_FOREGROUND_EVENT})
56 | end
57 |
58 | return AppBase
59 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/mvc/ModelBase.lua:
--------------------------------------------------------------------------------
1 | local ModelBase = class("ModelBase")
2 | ModelBase.idkey = "id"
3 | ModelBase.schema = {
4 | id = {"string"}
5 | }
6 | ModelBase.fields = {"id"}
7 |
8 | local function filterProperties(properties, filter)
9 | for i, field in ipairs(filter) do
10 | properties[field] = nil
11 | end
12 | end
13 |
14 | function ModelBase:ctor(properties)
15 | cc(self):addComponent("components.behavior.EventProtocol"):exportMethods()
16 |
17 | self.isModelBase_ = true
18 | if type(properties) ~= "table" then properties = {} end
19 | self:setProperties(properties)
20 | end
21 |
22 | function ModelBase:getId()
23 | local id = self[self.class.idkey .. "_"]
24 | assert(id ~= nil, string.format("%s:getId() - invalid id", self.class.__cname))
25 | return id
26 | end
27 |
28 | function ModelBase:isValidId()
29 | local propname = self.class.idkey .. "_"
30 | local id = self[propname]
31 | return type(id) == "string" and id ~= ""
32 | end
33 |
34 | function ModelBase:setProperties(properties)
35 | assert(type(properties) == "table", string.format("%s:setProperties() - invalid properties", self.class.__cname))
36 |
37 | for field, schema in pairs(self.class.schema) do
38 | local typ, def = schema[1], schema[2]
39 | local propname = field .. "_"
40 |
41 | local val = properties[field]
42 | if val ~= nil then
43 | if typ == "number" then val = tonumber(val) end
44 | assert(type(val) == typ, string.format("%s:setProperties() - type mismatch, %s expected %s, actual is %s", self.class.__cname, field, typ, type(val)))
45 | self[propname] = val
46 | elseif self[propname] == nil and def ~= nil then
47 | if type(def) == "table" then
48 | val = clone(def)
49 | elseif type(def) == "function" then
50 | val = def()
51 | else
52 | val = def
53 | end
54 | self[propname] = val
55 | end
56 | end
57 |
58 | return self
59 | end
60 |
61 | function ModelBase:getProperties(fields, filter)
62 | local schema = self.class.schema
63 | if type(fields) ~= "table" then fields = self.class.fields end
64 |
65 | local properties = {}
66 | for i, field in ipairs(fields) do
67 | local propname = field .. "_"
68 | local typ = schema[field][1]
69 | local val = self[propname]
70 | assert(type(val) == typ, string.format("%s:getProperties() - type mismatch, %s expected %s, actual is %s", self.class.__cname, field, typ, type(val)))
71 | properties[field] = val
72 | end
73 |
74 | if type(filter) == "table" then
75 | filterProperties(properties, filter)
76 | end
77 |
78 | return properties
79 | end
80 |
81 | return ModelBase
82 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/mvc/init.lua:
--------------------------------------------------------------------------------
1 |
2 | -- init MVC
3 | local mvc = {}
4 |
5 | mvc.AppBase = import(".AppBase")
6 | mvc.ModelBase = import(".ModelBase")
7 |
8 | return mvc
9 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/net/init.lua:
--------------------------------------------------------------------------------
1 | --- init net package
2 | -- @author zrong(zengrong.net)
3 | -- Creation 2014-01-02
4 | local net = {}
5 |
6 | net.SocketTCP = import(".SocketTCP")
7 |
8 | return net
9 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/ui/UIPageViewItem.lua:
--------------------------------------------------------------------------------
1 |
2 | --[[
3 |
4 | Copyright (c) 2011-2014 chukong-inc.com
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
24 | ]]
25 |
26 | --------------------------------
27 | -- @module UIPageViewItem
28 |
29 | --[[--
30 |
31 | quick 页面控件项
32 |
33 | ]]
34 |
35 | local UIPageViewItem = class("UIPageViewItem", function()
36 | return display.newNode()
37 | end)
38 |
39 | function UIPageViewItem:ctor()
40 | end
41 |
42 | return UIPageViewItem
43 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/uiloader/UILoaderUtilitys.lua:
--------------------------------------------------------------------------------
1 |
2 | local UILoaderUtilitys = {}
3 |
4 | function UILoaderUtilitys.loadTexture(plist, png)
5 | if UILoaderUtilitys.isNil(plist) then
6 | return
7 | end
8 |
9 | local fileUtil
10 | fileUtil = cc.FileUtils:getInstance()
11 | local fullPath = fileUtil:fullPathForFilename(plist)
12 | local fullPng = fileUtil:fullPathForFilename(png)
13 | -- UILoaderUtilitys.addSearchPathIf(io.pathinfo(fullPath).dirname, fileUtil)
14 | local spCache
15 | spCache = cc.SpriteFrameCache:getInstance()
16 | -- print("UILoaderUtilitys - loadTexture plist:" .. plist)
17 | if png then
18 | spCache:addSpriteFrames(fullPath, fullPng)
19 | else
20 | spCache:addSpriteFrames(fullPath)
21 | end
22 | end
23 |
24 | function UILoaderUtilitys.isNil(str)
25 | if not str or 0 == string.utf8len(str) then
26 | return true
27 | else
28 | return false
29 | end
30 | end
31 |
32 | function UILoaderUtilitys.addSearchPathIf(dir, fileUtil)
33 | if not fileUtil then
34 | fileUtil = cc.FileUtils:getInstance()
35 | end
36 | -- 判断是不是已经存在的默认路径
37 | local paths = fileUtil:getSearchPaths()
38 | for i=1, #(paths) do
39 | if paths[i] == dir then
40 | return
41 | end
42 | end
43 |
44 | if not UILoaderUtilitys.searchDirs then
45 | UILoaderUtilitys.searchDirs = {}
46 | end
47 |
48 | if not UILoaderUtilitys.isSearchExist(dir) then
49 | table.insert(UILoaderUtilitys.searchDirs, dir)
50 | if not fileUtil then
51 | fileUtil = cc.FileUtils:getInstance()
52 | end
53 | fileUtil:addSearchPath(dir)
54 | end
55 | end
56 |
57 | function UILoaderUtilitys.isSearchExist(dir)
58 | local bExist = false
59 | for i,v in ipairs(UILoaderUtilitys.searchDirs) do
60 | if v == dir then
61 | bExist = true
62 | break
63 | end
64 | end
65 |
66 | return bExist
67 | end
68 |
69 | function UILoaderUtilitys.clearPath(fileUtil)
70 | if not UILoaderUtilitys.searchDirs then
71 | return
72 | end
73 |
74 | fileUtil = fileUtil or cc.FileUtils:getInstance()
75 | local paths = fileUtil:getSearchPaths()
76 | local removeIdxTabel
77 |
78 | local luaSearchCount = #UILoaderUtilitys.searchDirs
79 |
80 | for i=luaSearchCount, 1, -1 do
81 | for key, path in ipairs(paths) do
82 | if path == UILoaderUtilitys.searchDirs[i] then
83 | table.remove(paths, key)
84 | break
85 | end
86 | end
87 | table.remove(UILoaderUtilitys.searchDirs, i)
88 | end
89 |
90 | paths = table.unique(paths, true)
91 |
92 | fileUtil:setSearchPaths(paths)
93 | end
94 |
95 | function UILoaderUtilitys.getFileFullName(filename)
96 | local fileUtil = fileUtil or cc.FileUtils:getInstance()
97 |
98 | return fileUtil:fullPathForFilename(filename)
99 | end
100 |
101 | return UILoaderUtilitys
102 |
103 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/uiloader/init.lua:
--------------------------------------------------------------------------------
1 |
2 | return import(".uiloader").new()
3 |
4 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/utils/Localize.lua:
--------------------------------------------------------------------------------
1 |
2 | local Localize = {}
3 |
4 | Localize.strings = {}
5 |
6 | function Localize.loadStrings(strings)
7 | Localize.strings = strings
8 | end
9 |
10 | function Localize.query(key, default)
11 | if not default then default = key end
12 | local lang = device.language
13 | if not Localize.strings[lang] or not Localize.strings[lang][key] then return default end
14 | return Localize.strings[lang][key]
15 | end
16 |
17 | function Localize.filename(filenameOrigin)
18 | local fi = io.pathinfo(filenameOrigin)
19 | return fi.dirname .. fi.basename .. "_" .. device.language .. fi.extname
20 | end
21 |
22 | cc = cc or {}
23 | cc.utils = cc.utils or {}
24 | cc.utils.Localize = Localize
25 |
26 | return Localize
27 |
--------------------------------------------------------------------------------
/ddz/src/framework/cc/utils/init.lua:
--------------------------------------------------------------------------------
1 | --- init utils package
2 | -- @author zrong(zengrong.net)
3 | -- Creation 2014-01-02
4 | local utils = {}
5 |
6 | utils.ByteArray = import(".ByteArray")
7 | utils.ByteArrayVarint = import(".ByteArrayVarint")
8 | utils.Gettext = import(".Gettext")
9 |
10 | return utils
11 |
--------------------------------------------------------------------------------
/ddz/src/framework/cocos2dx.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | --------------------------------
26 | -- @module cocos2dx
27 |
28 | --[[--
29 |
30 | 针对 cocos2d-x 的一些封装和扩展
31 |
32 | 预定义的节点事件:
33 |
34 | - cc.NODE_EVENT - enter, exit 等事件
35 | - cc.NODE_ENTER_FRAME_EVENT - 帧事件
36 | - cc.NODE_TOUCH_EVENT - 触摸事件
37 | - cc.NODE_TOUCH_CAPTURE_EVENT - 捕获触摸事件
38 |
39 | 预定义的层事件:
40 |
41 | - cc.ACCELERATE_EVENT - 重力感应事件
42 | - cc.KEYPAD_EVENT - 硬件按键事件
43 |
44 | 预定义的触摸模式:
45 |
46 | - cc.TOUCH_MODE_ALL_AT_ONCE - 多点触摸
47 | - cc.TOUCH_MODE_ONE_BY_ONE - 单点触摸
48 |
49 | ]]
50 |
51 | local p = cc.PACKAGE_NAME .. ".cocos2dx."
52 |
53 | if not cc.p then
54 | -- cc.p exist, so the cocos.init have loaded
55 | require(p .. "Cocos2dConstants")
56 | require(p .. "OpenglConstants")
57 | require(p .. "Cocos2d")
58 | require(p .. "StudioConstants")
59 | end
60 |
61 | require(p .. "Event")
62 | require(p .. "ActionEx")
63 | require(p .. "NodeEx")
64 | require(p .. "SceneEx")
65 | require(p .. "SpriteEx")
66 | require(p .. "DrawNodeEx")
67 |
--------------------------------------------------------------------------------
/ddz/src/framework/cocos2dx/DrawNodeEx.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | --[[--
26 |
27 | ]]
28 |
29 | local c = cc
30 | local DrawNode = c.DrawNode
31 |
32 | local drawPolygon = DrawNode.drawPolygon
33 | function DrawNode:drawPolygon(points, params)
34 | local segments = #points
35 | fillColor = cc.c4f(1,1,1,1)
36 | borderWidth = 0
37 | borderColor = cc.c4f(0,0,0,1)
38 | if params then
39 | if params.fillColor then fillColor = params.fillColor end
40 | if params.borderWidth then borderWidth = params.borderWidth end
41 | if params.borderColor then borderColor = params.borderColor end
42 | end
43 | drawPolygon(self, points, #points, fillColor, borderWidth, borderColor)
44 | return self
45 | end
46 |
47 | local drawDot = DrawNode.drawDot
48 | function DrawNode:drawDot(point, radius, color)
49 | drawDot(self, point, radius, color)
50 | return self
51 | end
52 |
--------------------------------------------------------------------------------
/ddz/src/framework/cocos2dx/Event.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | --[[--
26 |
27 | 定义 cocos2dx 中的事件
28 |
29 | ]]
30 |
31 | local c = cc
32 |
33 | -- cocos2dx 引擎级事件
34 | c.NODE_EVENT = 0
35 | c.NODE_ENTER_FRAME_EVENT = 1
36 | c.NODE_TOUCH_EVENT = 2
37 | c.NODE_TOUCH_CAPTURE_EVENT = 3
38 | c.MENU_ITEM_CLICKED_EVENT = 4
39 | c.ACCELERATE_EVENT = 5
40 | c.KEYPAD_EVENT = 6
41 |
42 | c.NODE_TOUCH_CAPTURING_PHASE = 0
43 | c.NODE_TOUCH_TARGETING_PHASE = 1
44 |
--------------------------------------------------------------------------------
/ddz/src/framework/cocos2dx/SceneEx.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | local c = cc
26 | local Scene = c.Scene
27 |
28 | function Scene:setAutoCleanupEnabled()
29 | self:addNodeEventListener(c.NODE_EVENT, function(event)
30 | if event.name == "exit" then
31 | if self.autoCleanupImages_ then
32 | for imageName, v in pairs(self.autoCleanupImages_) do
33 | display.removeSpriteFrameByImageName(imageName)
34 | end
35 | self.autoCleanupImages_ = nil
36 | end
37 | end
38 | end)
39 | end
40 |
41 | function Scene:markAutoCleanupImage(imageName)
42 | if not self.autoCleanupImages_ then self.autoCleanupImages_ = {} end
43 | self.autoCleanupImages_[imageName] = true
44 | return self
45 | end
46 |
--------------------------------------------------------------------------------
/ddz/src/framework/cocos2dx/SpriteEx.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | local c = cc
26 | local Sprite = c.Sprite
27 |
28 | function Sprite:playAnimationOnce(animation, removeWhenFinished, onComplete, delay)
29 | return transition.playAnimationOnce(self, animation, removeWhenFinished, onComplete, delay)
30 | end
31 |
32 | function Sprite:playAnimationForever(animation, delay)
33 | return transition.playAnimationForever(self, animation, delay)
34 | end
35 |
36 |
--------------------------------------------------------------------------------
/ddz/src/framework/cocos2dx/StudioConstants.lua:
--------------------------------------------------------------------------------
1 | ccs = ccs or {}
2 |
3 |
4 | ccs.MovementEventType = {
5 | start = 0,
6 | complete = 1,
7 | loopComplete = 2,
8 | }
9 |
--------------------------------------------------------------------------------
/ddz/src/framework/deprecated/deprecated_functions.lua:
--------------------------------------------------------------------------------
1 |
2 | display.addSpriteFramesWithFile = DEPRECATED(display.addSpriteFrames, "display.addSpriteFramesWithFile", "display.addSpriteFrames")
3 |
--------------------------------------------------------------------------------
/ddz/src/framework/luaj.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | --------------------------------
26 | -- @module luaj
27 |
28 | --[[--
29 |
30 | Lua 与 Java 的交互接口
31 |
32 | ]]
33 | local luaj = {}
34 |
35 | local callJavaStaticMethod = LuaJavaBridge.callStaticMethod
36 |
37 | --[[--
38 |
39 | 私有方法
40 |
41 | ]]
42 | local function checkArguments(args, sig)
43 | if type(args) ~= "table" then args = {} end
44 | if sig then return args, sig end
45 |
46 | sig = {"("}
47 | for i, v in ipairs(args) do
48 | local t = type(v)
49 | if t == "number" then
50 | sig[#sig + 1] = "F"
51 | elseif t == "boolean" then
52 | sig[#sig + 1] = "Z"
53 | elseif t == "function" then
54 | sig[#sig + 1] = "I"
55 | else
56 | sig[#sig + 1] = "Ljava/lang/String;"
57 | end
58 | end
59 | sig[#sig + 1] = ")V"
60 |
61 | return args, table.concat(sig)
62 | end
63 |
64 | -- start --
65 |
66 | --------------------------------
67 | -- 调用java类的接口。
68 | -- @function [parent=#luaj] callStaticMethod
69 | -- @param string className java类名
70 | -- @param string methodName java类静态方法名
71 | -- @param table args java类静态方法所需要的各种参数 数组
72 | -- @param string sig java类方法的签名
73 | -- @return boolean#boolean ret (return value: bool) ok, mixed ret ok为是否调用成功, ok为true时,ret为java方法的返回值,ok为false时,ret为出错原因
74 |
75 | -- end --
76 |
77 | function luaj.callStaticMethod(className, methodName, args, sig)
78 | local args, sig = checkArguments(args, sig)
79 | printInfo("luaj.callStaticMethod(\"%s\",\n\t\"%s\",\n\targs,\n\t\"%s\"", className, methodName, sig)
80 | return callJavaStaticMethod(className, methodName, args, sig)
81 | end
82 |
83 | return luaj
84 |
--------------------------------------------------------------------------------
/ddz/src/framework/luaoc.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | --------------------------------
26 | -- @module luaoc
27 |
28 | --[[--
29 |
30 | Lua 与 Objective-C 的交互接口
31 |
32 | ]]
33 | local luaoc = {}
34 |
35 | local callStaticMethod = LuaObjcBridge.callStaticMethod
36 |
37 | -- start --
38 |
39 | --------------------------------
40 | -- 调用Objective-C类的接口。
41 | -- @function [parent=#luaoc] callStaticMethod
42 | -- @param string className Objective-C类名
43 | -- @param string methodName Objective-C类方法名
44 | -- @param table args Objective-C类方法所需要的各种参数字典,key值为方法的参数名
45 | -- @return boolean#boolean ret (return value: bool) ok, mixed ret ok为是否调用成功, ok为true时,ret为Objective-C方法的返回值,ok为false时,ret为出错原因
46 |
47 | -- end --
48 |
49 | function luaoc.callStaticMethod(className, methodName, args)
50 | local ok, ret = callStaticMethod(className, methodName, args)
51 | if not ok then
52 | local msg = string.format("luaoc.callStaticMethod(\"%s\", \"%s\", \"%s\") - error: [%s] ",
53 | className, methodName, tostring(args), tostring(ret))
54 | if ret == -1 then
55 | printError(msg .. "INVALID PARAMETERS")
56 | elseif ret == -2 then
57 | printError(msg .. "CLASS NOT FOUND")
58 | elseif ret == -3 then
59 | printError(msg .. "METHOD NOT FOUND")
60 | elseif ret == -4 then
61 | printError(msg .. "EXCEPTION OCCURRED")
62 | elseif ret == -5 then
63 | printError(msg .. "INVALID METHOD SIGNATURE")
64 | else
65 | printError(msg .. "UNKNOWN")
66 | end
67 | end
68 | return ok, ret
69 | end
70 |
71 | return luaoc
72 |
--------------------------------------------------------------------------------
/ddz/src/framework/platform/android.lua:
--------------------------------------------------------------------------------
1 |
2 | if cc.bPlugin_ then
3 | luaj = require("cocos.cocos2d.luaj")
4 | else
5 | luaj = require(cc.PACKAGE_NAME .. ".luaj")
6 | end
7 |
8 | function io.exists(path)
9 | return cc.FileUtils:getInstance():isFileExist(path)
10 | end
11 |
12 | function io.readfile(path)
13 | return cc.HelperFunc:getFileData(path)
14 | end
15 |
16 | function device.showAlertAndroid(title, message, buttonLabels, listener)
17 | end
18 |
--------------------------------------------------------------------------------
/ddz/src/framework/platform/ios.lua:
--------------------------------------------------------------------------------
1 |
2 | if cc.bPlugin_ then
3 | luaoc = require("cocos.cocos2d.luaoc")
4 | else
5 | luaoc = require(cc.PACKAGE_NAME .. ".luaoc")
6 | end
7 |
8 | function device.showAlertIOS(title, message, buttonLabels, listener)
9 | end
10 |
--------------------------------------------------------------------------------
/ddz/src/framework/platform/mac.lua:
--------------------------------------------------------------------------------
1 |
2 | if cc.bPlugin_ then
3 | luaoc = require("cocos.cocos2d.luaoc")
4 | else
5 | -- luaoc = require(cc.PACKAGE_NAME .. ".luaoc")
6 | end
7 |
--------------------------------------------------------------------------------
/ddz/src/framework/toluaEx.lua:
--------------------------------------------------------------------------------
1 |
2 | function tolua.cloneTable(src)
3 | if type(src)~="table" then
4 | return nil
5 | end
6 |
7 | local dest = {}
8 | for k, v in pairs(src) do
9 | dest[k] = v
10 | end
11 |
12 | local mt = getmetatable(src)
13 | if mt then
14 | setmetatable(dest, mt)
15 | end
16 |
17 | return dest
18 | end
19 |
20 | if CCPoint then
21 | tolua.default_gc_classes__ = {
22 | -- "CCAtlasNode",
23 | -- "ccBezierConfig",
24 | -- "ccBlendFunc",
25 | -- "CCBool",
26 | -- "CCCamera",
27 | "ccColor3B",
28 | "ccColor4B",
29 | "ccColor4F",
30 | -- "CCDouble",
31 | -- "CCFloat",
32 | -- "ccFontDefinition",
33 | -- "CCImage",
34 | -- "CCInteger",
35 | -- "CCLabelBMFont",
36 | -- "CCLabelTTF",
37 | -- "CCParticleSystemQuad",
38 | "CCPoint",
39 | "CCRect",
40 | -- "CCScrollView",
41 | "CCSize",
42 | -- "CCTableView",
43 | -- "ccTexParams",
44 | -- "CCTileMapAtlas",
45 | -- "CCTMXLayer",
46 | -- "CCTMXLayerInfo",
47 | -- "CCTMXMapInfo",
48 | -- "CCTMXTilesetInfo",
49 | -- "cc_timeval",
50 | -- "HSV",
51 | -- "RGBA",
52 | }
53 | else
54 | tolua.default_gc_classes__ = {
55 | }
56 | end
57 |
58 | function tolua.fullgc(classes)
59 | collectgarbage("collect")
60 |
61 | if classes == nil then
62 | classes = tolua.default_gc_classes__
63 | elseif type(classes) == "string" then
64 | classes = {classes}
65 | elseif type(classes) ~= "table" then
66 | classes = tolua.default_gc_classes__
67 | end
68 |
69 | local o = tolua.getregval("tolua_gc")
70 | local t = tolua.cloneTable(o)
71 | if t then
72 | tolua.setregval("tolua_gc", t)
73 | end
74 |
75 | for i,v in ipairs(classes) do
76 | o = tolua.getubox(v)
77 | t = tolua.cloneTable(o)
78 | if o then
79 | tolua.setubox(v, t)
80 | end
81 | end
82 |
83 | o = nil
84 | t = nil
85 |
86 | collectgarbage("collect")
87 | end
--------------------------------------------------------------------------------
/ddz/src/main.lua:
--------------------------------------------------------------------------------
1 |
2 | function __G__TRACKBACK__(errorMessage)
3 | print("----------------------------------------")
4 | print("LUA ERROR: " .. tostring(errorMessage) .. "\n")
5 | print(debug.traceback("", 2))
6 | print("----------------------------------------")
7 | end
8 |
9 | package.path = package.path .. ";src/"
10 | require("app/DdzApp")
11 | ddz.app:run()
12 |
--------------------------------------------------------------------------------
/ddz/src/puremvc/init.lua:
--------------------------------------------------------------------------------
1 |
2 | local CURRENT_MODULE_NAME = ...
3 |
4 | pm = pm or {}
5 | pm.VERSION = '1.0.0'
6 | pm.FRAMEWORK_NAME = 'puremvc lua'
7 | pm.PACKAGE_NAME = string.sub(CURRENT_MODULE_NAME, 1, -6) .. '.org.puremvc.lua.multicore'
8 |
9 | require(pm.PACKAGE_NAME .. '.help.oop')
10 |
11 |
12 | pm.Facade = import(pm.PACKAGE_NAME .. '.patterns.facade.Facade')
13 | pm.Mediator = import(pm.PACKAGE_NAME .. '.patterns.mediator.Mediator')
14 | pm.Proxy = import(pm.PACKAGE_NAME .. '.patterns.proxy.Proxy')
15 | pm.SimpleCommand = import(pm.PACKAGE_NAME .. '.patterns.command.SimpleCommand')
16 | pm.MacroCommand = import(pm.PACKAGE_NAME .. '.patterns.command.MacroCommand')
17 | pm.Notifier = import(pm.PACKAGE_NAME .. '.patterns.observer.Notifier')
18 | pm.Notification = import(pm.PACKAGE_NAME .. '.patterns.observer.Notification')
19 | print("")
20 | print("# FRAMEWORK_NAME = " .. pm.FRAMEWORK_NAME)
21 | print("# VERSION = " .. pm.VERSION)
22 | print("")
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ddz/src/puremvc/org/puremvc/lua/multicore/patterns/command/SimpleCommand.lua:
--------------------------------------------------------------------------------
1 | --[[
2 | * @author PureMVC Lua Native Port by Sean
3 | * @author Copyright(c) 2006-2012 Futurescale, Inc., Some rights reserved.
4 | *
5 | * @class puremvc.SimpleCommand
6 | * @extends puremvc.Notifier
7 | *
8 | * SimpleCommands encapsulate the business logic of your application. Your
9 | * subclass should override the #execute method where your business logic will
10 | * handle the
11 | * {@link puremvc.Notification Notification}
12 | *
13 | * Take a look at
14 | * {@link puremvc.Facade#registerCommand Facade's registerCommand}
15 | * or {@link puremvc.Controller#registerCommand Controllers registerCommand}
16 | * methods to see how to add commands to your application.
17 | *
18 | * @constructor
19 | ]]
20 | local Notifier = import('..observer.Notifier')
21 |
22 | local SimpleCommand = class('SimpleCommand', Notifier)
23 |
24 | function SimpleCommand:ctor()
25 | SimpleCommand.super.ctor(self)
26 | end
27 | --[[
28 | * Fulfill the use-case initiated by the given Notification
29 | *
30 | * In the Command Pattern, an application use-case typically begins with some
31 | * user action, which results in a Notification is handled by the business logic
32 | * in the #execute method of a command.
33 | *
34 | * @param {puremvc.Notification} notification
35 | * The notification to handle.
36 | * @return {void}
37 | ]]
38 | function SimpleCommand:execute(notification)
39 | end
40 |
41 | return SimpleCommand
42 |
43 |
44 |
--------------------------------------------------------------------------------
/ddz/src/puremvc/org/puremvc/lua/multicore/patterns/proxy/Proxy.lua:
--------------------------------------------------------------------------------
1 | --[[
2 | * @author PureMVC Lua Native Port by Sean
3 | * @author Copyright(c) 2006-2012 Futurescale, Inc., Some rights reserved.
4 | *
5 | * @class puremvc.Proxy
6 | * @extends puremvc.Notifier
7 | *
8 | * A base Proxy implementation.
9 | *
10 | * In PureMVC, Proxy classes are used to manage parts of the application's data
11 | * model.
12 | *
13 | * A Proxy might simply manage a reference to a local data object, in which case
14 | * interacting with it might involve setting and getting of its data in
15 | * synchronous fashion.
16 | *
17 | * Proxy classes are also used to encapsulate the application's interaction with
18 | * remote services to save or retrieve data, in which case, we adopt an
19 | * asyncronous idiom; setting data (or calling a method) on the Proxy and
20 | * listening for a
21 | * {@link puremvc.Notification Notification}
22 | * to be sent when the Proxy has retrieved the data from the service.
23 | *
24 | *
25 | * @param {string} [proxyName]
26 | * The Proxy's name. If none is provided, the Proxy will use its constructors
27 | * NAME property.
28 | * @param {Object} [data]
29 | * The Proxy's data object
30 | * @constructor
31 | ]]
32 | local Notifier = import('..observer.Notifier')
33 | local Proxy = class('Proxy', Notifier)
34 |
35 | function Proxy:ctor(proxyName, data)
36 | self.proxyName = proxyName or Proxy.NAME
37 | if data ~= nil then
38 | self:setData(data)
39 | end
40 | end
41 |
42 | Proxy.NAME = "Proxy"
43 | --[[
44 | * Get the Proxy's name.
45 | *
46 | * @return {string}
47 | ]]
48 | function Proxy:getProxyName()
49 | return self.proxyName
50 | end
51 | --[[
52 | * Set the Proxy's data object
53 | *
54 | * @param {Object} data
55 | * @return {void}
56 | ]]
57 | function Proxy:setData(data)
58 | self.data = data
59 | end
60 | --[[
61 | * Get the Proxy's data object
62 | *
63 | * @return {Object}
64 | ]]
65 | function Proxy:getData()
66 | return self.data
67 | end
68 | --[[
69 | * Called by the {@link puremvc.Model Model} when
70 | * the Proxy is registered.
71 | *
72 | * @return {void}
73 | ]]
74 | function Proxy:onRegister()
75 | end
76 | --[[
77 | * Called by the {@link puremvc.Model Model} when
78 | * the Proxy is removed.
79 | *
80 | * @return {void}
81 | ]]
82 | function Proxy:onRemove()
83 | end
84 |
85 | return Proxy
--------------------------------------------------------------------------------
/ddz/tests/all.lua:
--------------------------------------------------------------------------------
1 | EXPORT_ASSERT_TO_GLOBALS = true
2 | package.path = package.path .. ';../src/?.lua'
3 |
4 | require('puremvc.init')
5 | require("framework.functions")
6 | require("framework.debug")
7 | require("cocos.cocos2d.json")
8 |
9 | local copas_loop_time = tonumber(arg[#arg])
10 | if not copas_loop_time then
11 | copas_loop_time = 0
12 | else
13 | table.remove(arg, #arg)
14 | end
15 |
16 |
17 | local luaunit = require('luaunit')
18 |
19 | require('mock')
20 |
21 | ddz = {}
22 | ddz.models = {me=nil, area=nil, areaPlayers=nil}
23 | ddz.facade = pm.Facade.getInstance('AppFacade')
24 |
25 | -- add test case requirement here
26 | --require('proxies.TestAuthProxy')
27 | require('TestCardFormula')
28 |
29 |
30 |
31 | luaunit.LuaUnit.run()
32 |
33 | local copas = require("copas.timer")
34 |
35 | copas.delayedexecutioner(copas_loop_time, function()
36 | copas.exitloop()
37 | end)
38 |
39 | copas.loop()
40 |
--------------------------------------------------------------------------------
/ddz/tests/mock.lua:
--------------------------------------------------------------------------------
1 | require('app.network.rpc')
2 |
3 | local copas = require("copas.timer")
4 | local consts = require("app.consts")
5 |
6 | PomeloClient = {}
7 | function PomeloClient:new()
8 | local instance = nil
9 | return function()
10 | if instance then return instance end
11 | local o = {}
12 | setmetatable(o, self)
13 | self.__index = self
14 | instance = o
15 |
16 | self.handler = nil
17 |
18 | self.responses = {}
19 | self.responses[consts.routes.server.gate.GET_CONNECTOR] = {code = 0, data = {host = '127.0.0.1', port = 3010}}
20 |
21 | return o
22 | end
23 | end
24 | PomeloClient.getInstance = PomeloClient:new()
25 |
26 | function PomeloClient:connect(ip, port)
27 | printInfo('PomeloClient.connect: ip=%s, port=%s', ip, port)
28 | return 0
29 | end
30 |
31 | function PomeloClient:disconnect()
32 | printInfo('PomeloClient.disconnect')
33 | end
34 |
35 | function PomeloClient:unregisterScriptHandler()
36 | end
37 |
38 | function PomeloClient:registerScriptHandler(handler)
39 | self.handler = handler
40 | end
41 |
42 | function PomeloClient:request(route, params)
43 | copas.delayedexecutioner(0, handler(self, function()
44 | if self.responses[route] then
45 | self.handler(route, json.encode(self.responses[route]))
46 | else
47 | printError("no response to request: route=%s, params=%s", route, params)
48 | end
49 | end))
50 | end
51 |
52 | function PomeloClient:addResponseMsg(route, response)
53 | self.responses[route] = response
54 | end
55 |
--------------------------------------------------------------------------------
/ddz/tests/proxies/TestAuthProxy.lua:
--------------------------------------------------------------------------------
1 |
2 | local consts = require('app.consts')
3 |
4 | AuthProxy = require('app.proxies.AuthProxy')
5 |
6 | TestAuthProxy = {}
7 |
8 | function TestAuthProxy:test_test()
9 |
10 | PomeloClient.getInstance():addResponseMsg(consts.routes.server.connector.LOGIN, {
11 | code = 0,
12 | data = {player={name='asdf', id=1}}
13 | })
14 |
15 | local p = AuthProxy.new()
16 | p:login()
17 |
18 | local Area = require('app.models.Area')
19 | local area = Area.new({id='asdf', lordCards={'3A'}})
20 | local AreaPlayer = require('app.models.AreaPlayer')
21 | local ap = AreaPlayer.new({id='asdf', name='xx', cards={'3A'}})
22 | end
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ddz/tests/testtimer.lua:
--------------------------------------------------------------------------------
1 | local copas = require("copas.timer")
2 |
3 | -- define timer callbacks
4 | local arm_cb = nil
5 | local expire_cb = function()
6 | print("executing the timer")
7 | copas.exitloop()
8 | end
9 | local cancel_cb = nil
10 | -- define timer parameters
11 | local recurring = false
12 | local interval = 1 --> in seconds
13 |
14 | local t = copas.newtimer(arm_cb, expire_cb, cancel_cb, recurring):arm(interval)
15 |
16 | copas.loop() --> start the scheduler and execute the timers
17 |
--------------------------------------------------------------------------------
/ddz1/res/fonts:
--------------------------------------------------------------------------------
1 | ../../ddz/res/fonts/
--------------------------------------------------------------------------------
/ddz1/res/textures:
--------------------------------------------------------------------------------
1 | ../../ddz/res/textures/
--------------------------------------------------------------------------------
/ddz1/res/ui:
--------------------------------------------------------------------------------
1 | ../../ddz/res/ui
--------------------------------------------------------------------------------
/ddz1/src:
--------------------------------------------------------------------------------
1 | ../ddz/src
--------------------------------------------------------------------------------
/ddz2/res/fonts:
--------------------------------------------------------------------------------
1 | ../../ddz/res/fonts/
--------------------------------------------------------------------------------
/ddz2/res/textures:
--------------------------------------------------------------------------------
1 | ../../ddz/res/textures/
--------------------------------------------------------------------------------
/ddz2/res/ui:
--------------------------------------------------------------------------------
1 | ../../ddz/res/ui
--------------------------------------------------------------------------------
/ddz2/src:
--------------------------------------------------------------------------------
1 | ../ddz/src
--------------------------------------------------------------------------------
/doc/api.md:
--------------------------------------------------------------------------------
1 | 连接服务器:
2 | gate.gateHandler.getConnector
3 | connector.entryHandler.login
4 | player.playerHandler.update
5 |
6 | 开始游戏:
7 | waitToStart: area.join, area.ready, *area.start, area.quit
8 | choosingLord: *area.lordChoosed, area.chooseLord, *area.start, *area.quit
9 | playing: area.play, *area.gameOver, *area.quit
10 |
11 | waitToStart: area.areaHandler.join, **area.areaHandler.ready, area.areaHandler.quit
12 | choosingLord: **area.areaHandler.chooseLord, *area.quit
13 | playing: **area.areaHandler.play, *area.quit
14 |
15 | area.areaHandler.connect/disconnect
16 |
17 | area.areaHandler.join -> [area.join]
18 | area.areaHandler.ready -> [area.ready, area.start]
19 | area.areaHandler.chooseLord -> [area.lordChoosed, area.chooseLord, area.start]
20 | area.areaHandler.play -> [area.win]
21 |
22 | area.areaHandler.quit -> [area.quit]
23 | create or join area -> loading -> show player who joined in
24 | 发牌:
25 | choose landlord -> add left 3 cards to landlord
26 | 出牌:
27 | 出牌超时 -> 机器人自动出牌
28 | 掉线:
29 | 机器人自动出牌
30 | 判断胜负:
31 | 继续或者退出:
32 |
33 |
34 | TODO:
35 | 1. robot with AI
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/game-server/.gitignore:
--------------------------------------------------------------------------------
1 | !.gitignore
2 | *~
3 | *.swp
4 | *.log
5 | *.tmp
6 | *.pyc
7 | *.svn
8 | *.sublime-project
9 | *.sublime-workspace
10 | coverage.html
11 | .DS_Store
12 | .project
13 | .nodemonignore
14 | .settings/
15 | .sass-cache/
16 | .bower-*/
17 | .idea/
18 | .svn/
19 | node_modules/
20 | tmp/
21 | log/
22 | logs/
23 |
24 |
--------------------------------------------------------------------------------
/game-server/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
3 | "browser": true, // Standard browser globals e.g. `window`, `document`.
4 | "esnext": true, // Allow ES.next specific features such as `const` and `let`.
5 | "bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.).
6 | "camelcase": false, // Permit only camelcase for `var` and `object indexes`.
7 | "curly": false, // Require {} for every new block or scope.
8 | "eqeqeq": true, // Require triple equals i.e. `===`.
9 | "immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
10 | "latedef": true, // Prohibit variable use before definition.
11 | "newcap": true, // Require capitalization of all constructor functions e.g. `new F()`.
12 | "noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`.
13 | "quotmark": "single", // Define quotes to string values.
14 | "regexp": true, // Prohibit `.` and `[^...]` in regular expressions.
15 | "undef": true, // Require all non-global variables be declared before they are used.
16 | "unused": false, // Warn unused variables.
17 | "strict": true, // Require `use strict` pragma in every file.
18 | "trailing": true, // Prohibit trailing whitespaces.
19 | "smarttabs": false, // Suppresses warnings about mixed tabs and spaces
20 | "globals": { // Globals variables.
21 | "jasmine": true,
22 | "angular": true,
23 | "ApplicationConfiguration": true
24 | },
25 | "predef": [ // Extra globals.
26 | "define",
27 | "require",
28 | "exports",
29 | "module",
30 | "describe",
31 | "before",
32 | "beforeEach",
33 | "after",
34 | "afterEach",
35 | "it",
36 | "inject",
37 | "expect"
38 | ],
39 | "indent": 4, // Specify indentation spacing
40 | "devel": true, // Allow development statements e.g. `console.log();`.
41 | "noempty": true, // Prohibit use of empty blocks.
42 | "expr": true
43 | }
44 |
--------------------------------------------------------------------------------
/game-server/app/components/areaSearcher.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var logger = require('quick-pomelo').logger.getLogger('area', __filename);
5 |
6 | var AreaSearcher = function(app, opts){
7 | opts = opts || {};
8 | this._app = app;
9 | this.areaIds = new Map();
10 | };
11 |
12 | var proto = AreaSearcher.prototype;
13 |
14 | proto.name = 'areaSearcher';
15 |
16 | proto.start = function(cb){
17 | cb();
18 | };
19 |
20 | proto.stop = function(force, cb){
21 | cb();
22 | };
23 |
24 | proto._ensureServer = function() {
25 | if(this._app.getServerType() !== 'area') {
26 | throw new Error('must be area server to enable AreaSearcher: current=' + this._app.getServerType());
27 | }
28 | };
29 |
30 | proto.setAreaAvail = function(areaId) {
31 | logger.debug('areaSearcher.setAreaAvail: areaId=%s', areaId);
32 | this._ensureServer();
33 | this.areaIds.set(areaId, true);
34 | };
35 |
36 | proto.deleteAvailArea = function(areaId) {
37 | logger.debug('areaSearcher.deleteAvailArea: areaId=%s', areaId);
38 | this._ensureServer();
39 | return this.areaIds.delete(areaId);
40 | };
41 |
42 | proto.getAvailAreaIds = function() {
43 | var areaIds = [];
44 | for(let id of this.areaIds.keys()){
45 | areaIds.push(id);
46 | }
47 | logger.debug('areaSearcher.getAvailAreaIds: areaIds=%j', areaIds);
48 | this._ensureServer();
49 | return this.areaIds.keys();
50 | };
51 |
52 | module.exports = function(app, opts){
53 | var areaSearcher = new AreaSearcher(app, opts);
54 | app.set(areaSearcher.name, areaSearcher, true);
55 | return areaSearcher;
56 | };
57 |
--------------------------------------------------------------------------------
/game-server/app/controllers/push.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = require('quick-pomelo').controllers.push;
--------------------------------------------------------------------------------
/game-server/app/controllers/robot.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var P = require('bluebird');
4 | var uuid = require('node-uuid');
5 | var _ = require('lodash');
6 | var util = require('util');
7 | var formula = require('../formula/formula');
8 | var logger = require('quick-pomelo').logger.getLogger('area', __filename);
9 |
10 | var Controller = function(app){
11 | this.app = app;
12 | };
13 |
14 | var proto = Controller.prototype;
15 |
16 |
17 | proto.dealCardsAsync = P.coroutine(function*(areaId){
18 | // send player cards, arrange choose lord
19 | yield P.resolve();
20 | });
21 |
22 |
23 | module.exports = function(app){
24 | return new Controller(app);
25 | };
26 |
--------------------------------------------------------------------------------
/game-server/app/formula/formula.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var _ = require('lodash');
4 |
5 | var exp = module.exports;
6 |
7 | var punish = exp.punishment = {};
8 | var reward = exp.reward = {};
9 |
10 | var base = 10;
11 |
12 | punish.forceQuitGame = function(odds, isLandlord) {
13 | return base * odds * 2;
14 | };
15 |
16 | reward.otherForceQuitGame = function(odds, isLandlord) {
17 | return base * odds;
18 | };
19 |
20 |
21 | reward.win = function(odds, isLandlord) {
22 | return isLandlord ? base * odds * 2 : base * odds;
23 | };
24 |
25 | punish.lose = function(odds, isLandlord) {
26 | return isLandlord ? base * odds * 2 : base * odds;
27 | };
28 |
29 |
--------------------------------------------------------------------------------
/game-server/app/models/areaPlayer.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var consts = require('../consts');
4 | var _ = require('lodash');
5 |
6 | module.exports = function(app){
7 | var mdbgoose = app.memdb.goose;
8 |
9 | var areaPlayerSchema = new mdbgoose.Schema({
10 | _id: {type : String},
11 | areaId: {type: String, required: true},
12 | playerId: {type: Number, required: true},
13 | cards: [{type : String}],
14 | show: {type : Boolean, default: false},
15 | online: {type: Boolean, default: true},
16 | ready: {type: Boolean, default: false},
17 | }, {collection : 'area_players'});
18 |
19 | areaPlayerSchema.index({areaId : 1, playerId : 1}, {unique : true});
20 |
21 | areaPlayerSchema.statics.findByAreaIdAndPlayerIdReadOnlyAsync = function(areaId, playerId) {
22 | return this.findOneReadOnlyAsync({areaId: areaId, playerId: playerId});
23 | };
24 |
25 | areaPlayerSchema.statics.findByAreaIdAndPlayerIdAsync = function(areaId, playerId) {
26 | return this.findOneAsync({areaId: areaId, playerId: playerId});
27 | };
28 |
29 | areaPlayerSchema.virtual('cardsCount').get(function(){
30 | return this.cards.length;
31 | });
32 |
33 | areaPlayerSchema.methods.isLandlord = function(area){return area.landlord === this.playerId;};
34 |
35 | areaPlayerSchema.methods.toClientData = function(){
36 | return {
37 | cards: this.cards,
38 | cardsCount: this.cards.length,
39 | playerId: this.playerId,
40 | show: this.show,
41 | online: this.online,
42 | ready: this.ready,
43 | };
44 | };
45 |
46 | areaPlayerSchema.methods.toSimpleClientData = function(){
47 | return {
48 | cardsCount: this.cards.length,
49 | playerId: this.playerId,
50 | show: this.show,
51 | online: this.online,
52 | ready: this.ready,
53 | };
54 | };
55 |
56 |
57 | mdbgoose.model('AreaPlayer', areaPlayerSchema);
58 | };
59 |
--------------------------------------------------------------------------------
/game-server/app/models/binding.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var _ = require('lodash');
4 | var consts = require('../consts');
5 |
6 | module.exports = function(app){
7 | var mdbgoose = app.memdb.goose;
8 |
9 | var bindingSchema = new mdbgoose.Schema({
10 | _id : {type : String},
11 | playerId : {type : Number, index : true},
12 | socialId : {type : String},
13 | socialType : {type : Number, validate: function(val){
14 | return _.indexOf(_.values(consts.binding.types), val) !== -1;
15 | }},
16 | }, {collection : 'bindings'});
17 |
18 | bindingSchema.index({socialId : 1, socialType : 1}, {unique : true});
19 |
20 | mdbgoose.model('Binding', bindingSchema);
21 | };
22 |
--------------------------------------------------------------------------------
/game-server/app/models/player.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var consts = require('../consts');
4 | var _ = require('lodash');
5 |
6 | module.exports = function(app){
7 | var mdbgoose = app.memdb.goose;
8 |
9 | var playerSchema = new mdbgoose.Schema({
10 | _id : {type : Number},
11 | areaId : {type : String},
12 | teamId : {type : String},
13 | connectorId : {type : String},
14 | name : {type : String, default: ''},
15 | sex : {type : Number, default: consts.sex.MALE, validate: function(val){
16 | return _.indexOf(_.values(consts.sex), val) !== -1;
17 | }},
18 | money : {type : Number, min : 0},
19 | }, {collection : 'players'});
20 |
21 | playerSchema.statics.getUpdatableKeys = function() {
22 | return ['name', 'sex'];
23 | };
24 |
25 | playerSchema.methods.toClientData = function(){
26 | return {
27 | name: this.name,
28 | sex: this.sex,
29 | money: this.money,
30 | areaId: this.areaId,
31 | teamId: this.teamId,
32 | id: this._id
33 | };
34 | };
35 |
36 | mdbgoose.model('Player', playerSchema);
37 | };
38 |
--------------------------------------------------------------------------------
/game-server/app/models/push.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = require('quick-pomelo').models.push;
--------------------------------------------------------------------------------
/game-server/app/models/team.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = function(app){
4 | var mdbgoose = app.memdb.goose;
5 |
6 | var teamSchema = new mdbgoose.Schema({
7 | _id : {type : String},
8 | name : {type : String},
9 | hostId: {type: Number, required: true},
10 | playerIds: [{type: Number}],
11 | }, {collection : 'teams'});
12 |
13 | teamSchema.methods.chooseHost = function(idx){
14 | for (var i = 0; i < this.playerIds.length; i++) {
15 | var j = idx + i + 1;
16 | j = j >= this.playerIds.length ? j - this.playerIds.length : j;
17 | if(this.playerIds[j] !== null) {
18 | return this.playerIds[j];
19 | }
20 | }
21 | return null;
22 | };
23 |
24 | mdbgoose.model('Team', teamSchema);
25 | };
26 |
--------------------------------------------------------------------------------
/game-server/app/resp.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var consts = require('./consts');
4 | var _ = require('lodash');
5 |
6 | var exp = module.exports;
7 |
8 | exp.errorResp = function(code, data) {
9 | return {code: code, data: data};
10 | };
11 |
12 | exp.successResp = function(data) {
13 | return {code: consts.resp.codes.SUCCESS, data: data};
14 | };
15 |
--------------------------------------------------------------------------------
/game-server/app/routes/area.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var route = {};
4 |
5 | route.handler = function(session, method, msg){
6 | return msg.areaId;
7 | };
8 |
9 | route.remote = function(routeParam, method, args){
10 | return routeParam;
11 | };
12 |
13 | module.exports = route;
14 |
--------------------------------------------------------------------------------
/game-server/app/routes/player.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var route = {};
4 |
5 | route.handler = function(session, method, msg){
6 | return session.uid || msg.playerId;
7 | };
8 |
9 | route.remote = function(routeParam, method, args){
10 | return routeParam;
11 | };
12 |
13 | module.exports = route;
14 |
--------------------------------------------------------------------------------
/game-server/app/routes/team.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var route = {};
4 |
5 | route.handler = function(session, method, msg){
6 | return msg.teamId;
7 | };
8 |
9 | route.remote = function(routeParam, method, args){
10 | return routeParam;
11 | };
12 |
13 | module.exports = route;
14 |
--------------------------------------------------------------------------------
/game-server/app/servers/connector/handler/entryHandler.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var P = require('bluebird');
4 | var util = require('util');
5 | var resp = require('../../../resp');
6 | var logger = require('quick-pomelo').logger.getLogger('connector', __filename);
7 |
8 | var Handler = function(app){
9 | this.app = app;
10 | };
11 |
12 | var proto = Handler.prototype;
13 |
14 | /**
15 | * msg.auth - authentication data
16 | */
17 | proto.login = function(msg, session, next){
18 | if(!!session.uid){
19 | return next(new Error('session already logged in with playerId ' + session.uid));
20 | }
21 |
22 | var authInfo = msg.authInfo;
23 | if(!authInfo){
24 | return next(new Error('authInfo is missing'));
25 | }
26 |
27 | var self = this;
28 | P.coroutine(function*(){
29 | var playerEntryRemote = self.app.rpc.player.entryRemote;
30 | var data = yield P.promisify(playerEntryRemote.login, playerEntryRemote)(session, msg, session.frontendId);
31 | yield P.promisify(session.bind, session)(data.playerId);
32 |
33 | // OnDisconnect
34 | session.on('closed', function(session, reason){
35 | if(reason === 'kick' || !session.uid){
36 | return;
37 | }
38 | // auto logout on disconnect
39 | P.promisify(self.logout, self)({closed : true}, session)
40 | .catch(function(e){
41 | logger.warn(e.stack);
42 | });
43 | });
44 |
45 | return resp.successResp(data.data);
46 | })().nodeify(next);
47 | };
48 |
49 | proto.logout = function(msg, session, next){
50 | var playerId = session.uid;
51 | if(!playerId){
52 | return next(new Error('playerId is missing'));
53 | }
54 |
55 | var self = this;
56 | P.coroutine(function*(){
57 | var playerEntryRemote = self.app.rpc.player.entryRemote;
58 | var data = yield P.promisify(playerEntryRemote.logout, playerEntryRemote)(session, playerId);
59 | if(!msg.closed) {
60 | yield P.promisify(session.unbind, session)(playerId);
61 | }
62 | })().nodeify(next);
63 | };
64 |
65 | module.exports = function(app){
66 | return new Handler(app);
67 | };
68 |
--------------------------------------------------------------------------------
/game-server/app/servers/connector/remote/entryRemote.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var logger = require('quick-pomelo').logger.getLogger('connector', __filename);
3 |
4 | var Remote = function(app){
5 | this.app = app;
6 | };
7 |
8 | Remote.prototype.kick = function(playerId, cb){
9 | logger.warn('kicking %s', playerId);
10 |
11 | //TODO: unbind instead of kick
12 | this.app.get('sessionService').kick(playerId, cb);
13 | };
14 |
15 | module.exports = function(app){
16 | return new Remote(app);
17 | };
18 |
--------------------------------------------------------------------------------
/game-server/app/servers/gate/handler/gateHandler.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var _ = require('lodash');
4 | var resp = require('../../../resp');
5 |
6 | var Handler = function(app){
7 | this.app = app;
8 | };
9 |
10 | var proto = Handler.prototype;
11 |
12 | proto.getConnector = function(msg, session, next){
13 | var servers = this.app.getServersByType('connector');
14 | var server = _.sample(servers);
15 | if(!server){
16 | return next(new Error('No connector server available'));
17 | }
18 | var data = {host : server.clientHost, port : server.clientPort};
19 | next(null, resp.successResp(data));
20 | };
21 |
22 | module.exports = function(app){
23 | return new Handler(app);
24 | };
25 |
--------------------------------------------------------------------------------
/game-server/app/servers/player/handler/playerHandler.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var P = require('bluebird');
4 |
5 | var Handler = function(app){
6 | this.app = app;
7 | };
8 |
9 | var proto = Handler.prototype;
10 |
11 | proto.create = function(msg, session, next){
12 | var opts = msg.opts;
13 |
14 | P.bind(this)
15 | .then(function(){
16 | return this.app.controllers.player.createAsync(opts);
17 | })
18 | .nodeify(next);
19 | };
20 |
21 | proto.update = function(msg, session, next) {
22 | var opts = msg.opts;
23 | var playerId = session.uid;
24 | if(!playerId){
25 | return next(new Error('player is not logged in'));
26 | }
27 | P.bind(this)
28 | .then(function(){
29 | return this.app.controllers.player.updateAsync(playerId, opts);
30 | })
31 | .nodeify(next);
32 | };
33 |
34 | proto.remove = function(msg, session, next){
35 | var playerId = session.uid;
36 | if(!playerId){
37 | return next(new Error('player is not logged in'));
38 | }
39 |
40 | P.bind(this)
41 | .then(function(){
42 | return this.app.controllers.player.removeAsync(playerId);
43 | })
44 | .then(function(){
45 | return P.promisify(session.unbind, session)(playerId);
46 | })
47 | .nodeify(next);
48 | };
49 |
50 | module.exports = function(app){
51 | return new Handler(app);
52 | };
53 |
--------------------------------------------------------------------------------
/game-server/app/servers/player/remote/entryRemote.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 | var P = require('bluebird');
3 | var logger = require('quick-pomelo').logger.getLogger('player', __filename);
4 |
5 | var Remote = function(app){
6 | this.app = app;
7 | };
8 |
9 | Remote.prototype.login = function(msg, frontendId, cb){
10 | var self = this;
11 | var controllers = this.app.controllers;
12 | var rpc = this.app.rpc;
13 | var authInfo = msg.authInfo;
14 | self.app.memdb.goose.transaction(P.coroutine(function*(){
15 | logger.info('login.msg: %j', msg);
16 | var playerId = yield controllers.player.authAsync(authInfo);
17 | if(!playerId){
18 | playerId = yield controllers.player.createAsync({authInfo: authInfo});
19 | }
20 |
21 | var data = yield controllers.player.connectAsync(playerId, frontendId);
22 | data.playerId = playerId;
23 | if(data.oldConnectorId){
24 | logger.warn('player %s already connected on %s, will kick', playerId, data.oldConnectorId);
25 | // kick original connector
26 | var entryRemote = rpc.connector.entryRemote;
27 | yield P.promisify(entryRemote.kick, entryRemote)({frontendId : data.oldConnectorId}, playerId);
28 | }
29 |
30 | logger.info('player %s login', playerId);
31 | return data;
32 | }), self.app.getServerId()).nodeify(cb);
33 | };
34 |
35 | Remote.prototype.logout = function(playerId, cb) {
36 | var self = this;
37 | var controllers = this.app.controllers;
38 | self.app.memdb.goose.transaction(P.coroutine(function*(){
39 | yield controllers.player.disconnectAsync(playerId);
40 | logger.info('player %s logout', playerId);
41 | }), self.app.getServerId()).nodeify(cb);
42 | };
43 |
44 |
45 | module.exports = function(app){
46 | return new Remote(app);
47 | };
48 |
--------------------------------------------------------------------------------
/game-server/app/servers/team/handler/teamHandler.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var P = require('bluebird');
4 |
5 | var Handler = function(app){
6 | this.app = app;
7 | };
8 |
9 | var proto = Handler.prototype;
10 |
11 | proto.create = function(msg, session, next){
12 | var opts = msg.opts;
13 |
14 | P.bind(this)
15 | .then(function(){
16 | return this.app.controllers.team.createAsync(opts);
17 | })
18 | .nodeify(next);
19 | };
20 |
21 | proto.remove = function(msg, session, next){
22 | var teamId = msg.teamId || session.uid;
23 | if(!teamId){
24 | return next(new Error('teamId is missing'));
25 | }
26 |
27 | P.bind(this)
28 | .then(function(){
29 | return this.app.controllers.team.removeAsync(teamId);
30 | })
31 | .nodeify(next);
32 | };
33 |
34 | proto.join = function(msg, session, next){
35 | var playerId = session.uid;
36 | var teamId = msg.teamId;
37 | if(!playerId || !teamId){
38 | return next(new Error('playerId or teamId is missing'));
39 | }
40 |
41 | P.bind(this)
42 | .then(function(){
43 | return this.app.controllers.team.joinAsync(teamId, playerId);
44 | })
45 | .nodeify(next);
46 | };
47 |
48 | proto.quit = function(msg, session, next){
49 | var playerId = session.uid;
50 | var teamId = msg.teamId;
51 | if(!playerId || !teamId){
52 | return next(new Error('playerId or teamId is missing'));
53 | }
54 |
55 | P.bind(this)
56 | .then(function(){
57 | return this.app.controllers.team.quitAsync(teamId, playerId);
58 | })
59 | .nodeify(next);
60 | };
61 |
62 | module.exports = function(app){
63 | return new Handler(app);
64 | };
65 |
--------------------------------------------------------------------------------
/game-server/config/clientProtos.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/game-server/config/development/adminUser.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "id": "user-1",
4 | "username": "admin",
5 | "password": "admin",
6 | "level": 1
7 | },
8 | {
9 | "id": "user-2",
10 | "username": "monitor",
11 | "password": "monitor",
12 | "level": 2
13 | },
14 | {
15 | "id": "user-3",
16 | "username": "test",
17 | "password": "test",
18 | "level": 2
19 | }
20 | ]
21 |
--------------------------------------------------------------------------------
/game-server/config/development/master.json:
--------------------------------------------------------------------------------
1 | {
2 | "id": "master-server-1", "host": "127.0.0.1", "port": 3005
3 | }
4 |
--------------------------------------------------------------------------------
/game-server/config/development/memdb.json:
--------------------------------------------------------------------------------
1 | {
2 | "shards" : {
3 | "player-server-1" : {
4 | "host" : "127.0.0.1",
5 | "port" : 31017
6 | },
7 | "area-server-1" : {
8 | "host" : "127.0.0.1",
9 | "port" : 31019
10 | },
11 | "team-server-1" : {
12 | "host" : "127.0.0.1",
13 | "port" : 31021
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/game-server/config/development/redisIdGenerator.json:
--------------------------------------------------------------------------------
1 | {
2 | "redis" : {
3 | "host" : "127.0.0.1",
4 | "port" : 6379,
5 | "db" : 1,
6 | "options" : {}
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/game-server/config/development/servers.json:
--------------------------------------------------------------------------------
1 | {
2 | "gate": [
3 | {"id": "gate-server", "host": "127.0.0.1", "port": 13010, "clientPort": 3010, "frontend": true, "args": ["--debug=5860", "--harmony" ]}
4 | ],
5 | "connector": [
6 | {"id": "connector-server-1", "host": "127.0.0.1", "clientHost":"127.0.0.1", "port": 13100, "clientPort": 3100, "frontend": true, "args": ["--debug=5870", "--harmony" ]},
7 | {"id": "connector-server-2", "host": "127.0.0.1", "clientHost":"127.0.0.1", "port": 13101, "clientPort": 3101, "frontend": true, "args": ["--debug=5871", "--harmony" ]}
8 | ],
9 | "player": [
10 | {"id": "player-server-1", "host": "127.0.0.1", "port": 13200, "args": ["--debug=5880", "--harmony" ]}
11 | ],
12 | "area": [
13 | {"id": "area-server-1", "host": "127.0.0.1", "port": 13300, "args": ["--debug=5890", "--harmony" ]}
14 | ],
15 | "team": [
16 | {"id": "team-server-1", "host": "127.0.0.1", "port": 13400, "args": ["--debug=5900", "--harmony" ]}
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/game-server/config/dictionary.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/game-server/config/memdb.index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | // Index definitions
4 |
5 | module.exports = {
6 | // Collection name
7 | area_players : {
8 | indexes : [
9 | {
10 | keys : ['areaId', 'playerId'],
11 | unique : true,
12 | },
13 | ]
14 | },
15 |
16 | bindings : {
17 | indexes : [
18 | {
19 | keys : ['playerId'],
20 | },
21 | {
22 | keys : ['socialId', 'socialType'],
23 | unique : true,
24 | },
25 | ]
26 | },
27 |
28 | players : {
29 | indexes : [
30 | ]
31 | },
32 | };
33 |
--------------------------------------------------------------------------------
/game-server/config/serverProtos.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/game-server/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "quick-pomelo-demo",
3 | "description": "quick pomelo demo",
4 | "version": "0.1.0",
5 | "author": "gmlove",
6 | "private": false,
7 | "homepage": "https://github.com/rain1017/quick-pomelo-demo",
8 | "repository": {
9 | "type": "git",
10 | "url": "https://github.com/rain1017/quick-pomelo-demo.git"
11 | },
12 | "bugs": {
13 | "url": "https://github.com/rain1017/quick-pomelo-demo/issues"
14 | },
15 | "keywords": [],
16 | "engines": {
17 | "node": ">=0.12.5"
18 | },
19 | "scripts": {
20 | "start": "grunt",
21 | "test": "grunt test",
22 | "postinstall": ""
23 | },
24 | "dependencies": {
25 | "quick-pomelo": "rain1017/quick-pomelo",
26 | "pomelo": "rain1017/pomelo",
27 | "redis-id-generator": "~0.1.0",
28 | "bluebird": "~2.9.34",
29 | "grunt-cli": "~0.1.13",
30 | "heapdump": "~0.3.7",
31 | "lodash": "~3.2.0",
32 | "node-uuid": "^1.4.3"
33 | },
34 | "devDependencies": {
35 | "blanket": "~1.1.6",
36 | "grunt-concurrent": "~1.0.0",
37 | "grunt-contrib-clean": "~0.6.0",
38 | "grunt-contrib-jshint": "~0.10.0",
39 | "grunt-contrib-watch": "~0.6.1",
40 | "grunt-env": "~0.4.2",
41 | "grunt-mocha-cli": "^1.13.0",
42 | "grunt-mocha-cov": "^0.4.0",
43 | "grunt-mocha-test": "~0.12.6",
44 | "grunt-nodemon": "~0.3.0",
45 | "load-grunt-tasks": "~2.0.0",
46 | "should": "~4.5.0",
47 | "mongodb": "~2.0.28",
48 | "redis": "~0.12.1"
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/game-server/test/blanket.js:
--------------------------------------------------------------------------------
1 | 'user strict';
2 |
3 | var blanket = require('blanket');
4 | var path = require('path');
5 | var srcDir = path.join(__dirname, '../app');
6 |
7 | blanket({
8 | pattern: srcDir
9 | });
10 |
--------------------------------------------------------------------------------
/game-server/test/client/e2e.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var P = require('bluebird');
4 | var quick = require('quick-pomelo');
5 | var should = require('should');
6 | var consts = require('../../app/consts');
7 | var logger = quick.logger.getLogger('test', __filename);
8 |
9 | P.longStackTraces();
10 |
11 | var main = function(){
12 | var gateServer = {host : '127.0.0.1', port : 3010};
13 | var playerId, areaId;
14 |
15 | P.coroutine(function*(){
16 | var client = quick.mocks.client(gateServer);
17 | yield client.connect();
18 | var connectorServer = yield client.request('gate.gateHandler.getConnector', null);
19 | client.disconnect();
20 |
21 | // Connect to connector
22 | client = quick.mocks.client(connectorServer.data);
23 | yield client.connect();
24 |
25 | var authInfo = {socialId : '1234', socialType: consts.binding.types.DEVICE};
26 | yield client.request('connector.entryHandler.login', {authInfo : authInfo});
27 | yield client.request('player.playerHandler.update', {opts : {name : 'rain'}});
28 |
29 | areaId = yield client.request('area.areaHandler.create', {opts : {name : 'area1'}});
30 | areaId = areaId.data.area.id;
31 | client.on('notify', function(msg){
32 | logger.info('on notify %j', msg);
33 | });
34 | yield client.request('area.areaHandler.push', {areaId : areaId, route : 'notify', msg : 'hello', persistent : true});
35 | var msgs = yield client.request('area.areaHandler.getMsgs', {areaId : areaId, seq : 0});
36 | logger.info('%j', msgs);
37 | yield client.request('area.areaHandler.quit', {areaId : areaId});
38 | yield client.request('player.playerHandler.remove', {});
39 | client.disconnect();
40 | })()
41 | .finally(function(){
42 | process.exit();
43 | });
44 | };
45 |
46 | if (require.main === module) {
47 | main();
48 | }
49 |
--------------------------------------------------------------------------------
/game-server/test/client/login.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var P = require('bluebird');
4 | var quick = require('quick-pomelo');
5 | var should = require('should');
6 | var consts = require('../../app/consts');
7 | var logger = quick.logger.getLogger('test', __filename);
8 |
9 | var main = function(){
10 | var connector1 = {host : '127.0.0.1', port : 3100};
11 | var connector2 = {host : '127.0.0.1', port : 3101};
12 |
13 | var client1 = quick.mocks.client(connector1);
14 | var client2 = quick.mocks.client(connector2);
15 | var client3 = quick.mocks.client(connector1);
16 | var client4 = quick.mocks.client(connector2);
17 |
18 | var playerId = 'p1';
19 |
20 | P.coroutine(function*(){
21 | var authInfo = {socialId : '1234', socialType: consts.binding.types.DEVICE};
22 | yield client1.connect();
23 | yield client1.request('connector.entryHandler.login', {authInfo : authInfo});
24 | yield client1.request('player.playerHandler.update', {opts : {name : 'rain'}});
25 | yield client2.connect();
26 | // Client1 should be kicked out
27 | yield client2.request('connector.entryHandler.login', {authInfo : authInfo});
28 | // Explicitly call logout
29 | yield client2.request('connector.entryHandler.logout');
30 | yield client3.connect();
31 | yield client3.request('connector.entryHandler.login', {authInfo : authInfo});
32 | // Auto logout on disconnect
33 | client3.disconnect();
34 | yield P.delay(100);
35 | yield client4.connect();
36 | yield client4.request('connector.entryHandler.login', {authInfo : authInfo});
37 | // Remove and logout
38 | yield client4.request('player.playerHandler.remove');
39 | client4.disconnect();
40 | })()
41 | .catch(function(e){
42 | logger.error('error raised: ', e);
43 | })
44 | .finally(function(){
45 | process.exit();
46 | });
47 | };
48 |
49 | if (require.main === module) {
50 | main();
51 | }
52 |
--------------------------------------------------------------------------------
/game-server/test/controllers/player.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var P = require('bluebird');
4 | var env = require('../env');
5 | var consts = require('../../app/consts');
6 | var logger = require('quick-pomelo').logger.getLogger('test', __filename);
7 |
8 | describe('player test', function(){
9 | beforeEach(env.initMemdbSync);
10 | afterEach(env.closeMemdbSync);
11 |
12 | it('create/remove/connect/disconnect', function(cb){
13 | var app = env.createApp('player-server-1', 'player');
14 |
15 | P.coroutine(function*(){
16 | yield P.promisify(app.start, app)();
17 |
18 | var playerController = app.controllers.player;
19 |
20 | yield app.memdb.goose.transaction(P.coroutine(function*(){
21 | var playerId = yield playerController.createAsync({
22 | authInfo: {socialId : '123', socialType: consts.binding.types.DEVICE},
23 | name : 'rain'
24 | });
25 | yield playerController.connectAsync(playerId, 'c1');
26 |
27 | yield playerController.pushAsync(playerId, 'notify', 'content', true);
28 | var ret = yield playerController.getMsgsAsync(playerId, 0);
29 | ret.length.should.eql(1);
30 | ret[0].msg.should.eql('content');
31 |
32 | yield playerController.disconnectAsync(playerId);
33 | yield playerController.removeAsync(playerId);
34 | }), app.getServerId());
35 |
36 | yield P.promisify(app.stop, app)();
37 | })()
38 | .nodeify(cb);
39 | });
40 | });
41 |
--------------------------------------------------------------------------------
/game-server/test/controllers/team.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var P = require('bluebird');
4 | var env = require('../env');
5 | var should = require('should');
6 | var consts = require('../../app/consts');
7 | var logger = require('quick-pomelo').logger.getLogger('test', __filename);
8 |
9 | describe('team test', function(){
10 | beforeEach(env.initMemdbSync);
11 | afterEach(env.closeMemdbSync);
12 |
13 | it('team test', function(cb){
14 | var app = env.createApp('team-server-1', 'team');
15 |
16 | P.coroutine(function*(){
17 | yield P.promisify(app.start, app)();
18 |
19 | var teamController = app.controllers.team;
20 | var playerController = app.controllers.player;
21 | yield app.memdb.goose.transaction(P.coroutine(function*(){
22 | var playerId = yield playerController.createAsync({
23 | authInfo: {socialId : '123', socialType: consts.binding.types.DEVICE},
24 | name : 'rain'
25 | });
26 | var teamId = yield teamController.createAsync(playerId, {name : 'area1'});
27 | var players = yield teamController.getPlayersAsync(teamId);
28 | players.length.should.eql(1);
29 | players[0]._id.should.eql(playerId);
30 |
31 | yield playerController.connectAsync(playerId, 'c1');
32 | yield teamController.pushAsync(teamId, null, 'chat', 'hello', true);
33 | var msgs = yield teamController.getMsgsAsync(teamId, 0);
34 | msgs.length.should.eql(1);
35 | msgs[0].msg.should.eql('hello');
36 |
37 | var playerId1 = yield playerController.createAsync({
38 | authInfo: {socialId : '1234', socialType: consts.binding.types.DEVICE},
39 | name : 'rain1'
40 | });
41 | yield teamController.joinAsync(teamId, playerId1);
42 |
43 | var team = yield app.models.Team.findByIdAsync(teamId);
44 | team.playerIds.toObject().should.eql([playerId, playerId1]);
45 |
46 | yield teamController.quitAsync(teamId, playerId);
47 | yield playerController.removeAsync(playerId);
48 |
49 | players = yield teamController.getPlayersAsync(teamId);
50 | players.length.should.eql(1);
51 |
52 | }), app.getServerId());
53 |
54 | yield P.promisify(app.stop, app)();
55 | })()
56 | .nodeify(cb);
57 | });
58 | });
59 |
--------------------------------------------------------------------------------
/game-server/test/env.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var P = require('bluebird');
4 | P.longStackTraces();
5 | var should = require('should');
6 | var path = require('path');
7 | var quick = require('quick-pomelo');
8 | var RedisIDGenerator = require('redis-id-generator');
9 | var redis = require('redis');
10 | var child_process = require('child_process');
11 | var logger = quick.logger.getLogger('test', __filename);
12 |
13 | var execMemdbClusterSync = function(cmd){
14 | var configPath = path.join(__dirname, 'memdb.conf.js');
15 | var output = child_process.execFileSync('memdbcluster', [cmd, '--conf=' + configPath]);
16 | logger.info(output.toString());
17 | };
18 |
19 | exports.initMemdbSync = function(){
20 | execMemdbClusterSync('drop');
21 | execMemdbClusterSync('start');
22 | };
23 |
24 | exports.closeMemdbSync = function(){
25 | execMemdbClusterSync('stop');
26 | };
27 |
28 |
29 | var memdbClientConfig = {
30 | shards : {
31 | 'player-server-1' : {
32 | host : '127.0.0.1',
33 | port : 32017,
34 | },
35 | 'area-server-1' : {
36 | host : '127.0.0.1',
37 | port : 32017,
38 | },
39 | 'team-server-1' : {
40 | host : '127.0.0.1',
41 | port : 32017,
42 | },
43 | },
44 | };
45 |
46 | exports.redisIdGeneratorConfig = {
47 | redis : {host : '127.0.0.1', port : 6379, db : 2},
48 | };
49 |
50 | exports.createApp = function(serverId, serverType){
51 | var app = quick.mocks.app({serverId : serverId, serverType : serverType});
52 |
53 | app.setBase(path.join(__dirname, '..'));
54 | app.set('memdbConfig', memdbClientConfig);
55 |
56 | var idgen = new RedisIDGenerator(exports.redisIdGeneratorConfig.redis);
57 | idgen.initKey('player__id', 0, 1);
58 | app.set('redisIdGenerator', idgen);
59 |
60 | app.load(quick.components.memdb);
61 | app.load(quick.components.controllers);
62 | app.load(quick.components.timer);
63 | app.load(require('../app/components/areaSearcher'));
64 |
65 | return app;
66 | };
67 |
--------------------------------------------------------------------------------
/game-server/test/memdb.conf.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | // memdb-server config for unit test
4 |
5 | module.exports = {
6 | backend : {
7 | engine : 'mongodb',
8 | url : 'mongodb://localhost/ddz-test',
9 | options : {},
10 | },
11 |
12 | locking : {
13 | host : '127.0.0.1',
14 | port : 6379,
15 | db : 2,
16 | },
17 |
18 | slave : {
19 | host : '127.0.0.1',
20 | port : 6379,
21 | db : 2,
22 | },
23 |
24 | log : {
25 | //path : process.env.HOME + '/.memdb/log',
26 | level : 'WARN',
27 | },
28 |
29 | promise : {
30 | longStackTraces : false,
31 | },
32 |
33 | collections : require('../config/memdb.index'),
34 |
35 | shards : {
36 | s1 : {
37 | host : '127.0.0.1',
38 | port : 32017,
39 | },
40 | }
41 | };
42 |
--------------------------------------------------------------------------------
/game-server/test/testTimer.js:
--------------------------------------------------------------------------------
1 | var P = require('bluebird');
2 | var domain = require('domain');
3 |
4 |
5 | var timers = new Map();
6 |
7 | var wrap = function(id, f) {
8 | return function() {
9 | var d = domain.create();
10 | d.id = Math.random();
11 | console.log('[%s] created domain: %s', id, d.id);
12 | d.run(function(){
13 | P.delay(1).then(f);
14 | })
15 | }
16 | };
17 |
18 | var inter = setInterval(function(){
19 | for(let k of timers.keys()) {
20 | var cb = timers.get(k);
21 | setTimeout(wrap(k, cb), 3);
22 | timers.delete(k);
23 | clearInterval(inter);
24 | }
25 | }, 1);
26 |
27 | timers.set(1, function(){
28 | console.log('[1] domain: ' + (process.domain ? process.domain.id : null));
29 | });
30 |
31 |
32 | timers.set(2, function(){
33 | console.log('[2] domain: ' + (process.domain ? process.domain.id : null));
34 | });
35 |
36 |
37 | timers.set(3, function(){
38 | console.log('[3] domain: ' + (process.domain ? process.domain.id : null));
39 | });
40 |
--------------------------------------------------------------------------------
/quick/framework/cc/EventProxy.lua:
--------------------------------------------------------------------------------
1 |
2 | local EventProxy = class("EventProxy")
3 |
4 | function EventProxy:ctor(eventDispatcher, view)
5 | self.eventDispatcher_ = eventDispatcher
6 | self.handles_ = {}
7 |
8 | if view then
9 | cc(view):addNodeEventListener(cc.NODE_EVENT, function(event)
10 | if event.name == "exit" then
11 | self:removeAllEventListeners()
12 | end
13 | end)
14 | end
15 | end
16 |
17 | function EventProxy:addEventListener(eventName, listener, data)
18 | local handle = self.eventDispatcher_:addEventListener(eventName, listener, data)
19 | self.handles_[#self.handles_ + 1] = {eventName, handle}
20 | return self, handle
21 | end
22 |
23 | function EventProxy:removeEventListener(eventHandle)
24 | self.eventDispatcher_:removeEventListener(eventHandle)
25 | for index, handle in pairs(self.handles_) do
26 | if handle[2] == eventHandle then
27 | table.remove(self.handles_, index)
28 | break
29 | end
30 | end
31 | return self
32 | end
33 |
34 | function EventProxy:removeAllEventListenersForEvent(eventName)
35 | for key, handle in pairs(self.handles_) do
36 | if handle[1] == eventName then
37 | self.eventDispatcher_:removeEventListenersByEvent(eventName)
38 | self.handles_[key] = nil
39 | end
40 | end
41 | return self
42 | end
43 |
44 | function EventProxy:getEventHandle(eventName)
45 | for key, handle in pairs(self.handles_) do
46 | if handle[1] == eventName then
47 | return handle[2]
48 | end
49 | end
50 | end
51 |
52 | function EventProxy:removeAllEventListeners()
53 | for _, handle in pairs(self.handles_) do
54 | self.eventDispatcher_:removeEventListener(handle[2])
55 | end
56 | self.handles_ = {}
57 | return self
58 | end
59 |
60 | return EventProxy
61 |
--------------------------------------------------------------------------------
/quick/framework/cc/GameObject.lua:
--------------------------------------------------------------------------------
1 |
2 | local Registry = import(".Registry")
3 |
4 | local GameObject = {}
5 |
6 | function GameObject.extend(target)
7 | target.components_ = {}
8 |
9 | function target:checkComponent(name)
10 | return self.components_[name] ~= nil
11 | end
12 |
13 | function target:addComponent(name)
14 | local component = Registry.newObject(name)
15 | self.components_[name] = component
16 | component:bind_(self)
17 | return component
18 | end
19 |
20 | function target:removeComponent(name)
21 | local component = self.components_[name]
22 | if component then component:unbind_() end
23 | self.components_[name] = nil
24 | end
25 |
26 | function target:getComponent(name)
27 | return self.components_[name]
28 | end
29 |
30 | return target
31 | end
32 |
33 | return GameObject
34 |
--------------------------------------------------------------------------------
/quick/framework/cc/Registry.lua:
--------------------------------------------------------------------------------
1 |
2 | local Registry = class("Registry")
3 |
4 | Registry.classes_ = {}
5 | Registry.objects_ = {}
6 |
7 | function Registry.add(cls, name)
8 | assert(type(cls) == "table" and cls.__cname ~= nil, "Registry.add() - invalid class")
9 | if not name then name = cls.__cname end
10 | assert(Registry.classes_[name] == nil, string.format("Registry.add() - class \"%s\" already exists", tostring(name)))
11 | Registry.classes_[name] = cls
12 | end
13 |
14 | function Registry.remove(name)
15 | assert(Registry.classes_[name] ~= nil, string.format("Registry.remove() - class \"%s\" not found", name))
16 | Registry.classes_[name] = nil
17 | end
18 |
19 | function Registry.exists(name)
20 | return Registry.classes_[name] ~= nil
21 | end
22 |
23 | function Registry.newObject(name, ...)
24 | local cls = Registry.classes_[name]
25 | if not cls then
26 | -- auto load
27 | pcall(function()
28 | cls = require(name)
29 | Registry.add(cls, name)
30 | end)
31 | end
32 | assert(cls ~= nil, string.format("Registry.newObject() - invalid class \"%s\"", tostring(name)))
33 | return cls.new(...)
34 | end
35 |
36 | function Registry.setObject(object, name)
37 | assert(Registry.objects_[name] == nil, string.format("Registry.setObject() - object \"%s\" already exists", tostring(name)))
38 | assert(object ~= nil, "Registry.setObject() - object \"%s\" is nil", tostring(name))
39 | Registry.objects_[name] = object
40 | end
41 |
42 | function Registry.getObject(name)
43 | assert(Registry.objects_[name] ~= nil, string.format("Registry.getObject() - object \"%s\" not exists", tostring(name)))
44 | return Registry.objects_[name]
45 | end
46 |
47 | function Registry.removeObject(name)
48 | assert(Registry.objects_[name] ~= nil, string.format("Registry.removeObject() - object \"%s\" not exists", tostring(name)))
49 | Registry.objects_[name] = nil
50 | end
51 |
52 | function Registry.isObjectExists(name)
53 | return Registry.objects_[name] ~= nil
54 | end
55 |
56 | return Registry
57 |
--------------------------------------------------------------------------------
/quick/framework/cc/components/Component.lua:
--------------------------------------------------------------------------------
1 |
2 | local Component = class("Component")
3 |
4 | function Component:ctor(name, depends)
5 | self.name_ = name
6 | self.depends_ = checktable(depends)
7 | end
8 |
9 | function Component:getName()
10 | return self.name_
11 | end
12 |
13 | function Component:getDepends()
14 | return self.depends_
15 | end
16 |
17 | function Component:getTarget()
18 | return self.target_
19 | end
20 |
21 | function Component:exportMethods_(methods)
22 | self.exportedMethods_ = methods
23 | local target = self.target_
24 | local com = self
25 | for _, key in ipairs(methods) do
26 | if not target[key] then
27 | local m = com[key]
28 | target[key] = function(__, ...)
29 | return m(com, ...)
30 | end
31 | end
32 | end
33 | return self
34 | end
35 |
36 | function Component:bind_(target)
37 | self.target_ = target
38 | for _, name in ipairs(self.depends_) do
39 | if not target:checkComponent(name) then
40 | target:addComponent(name)
41 | end
42 | end
43 | self:onBind_(target)
44 | end
45 |
46 | function Component:unbind_()
47 | if self.exportedMethods_ then
48 | local target = self.target_
49 | for _, key in ipairs(self.exportedMethods_) do
50 | target[key] = nil
51 | end
52 | end
53 | self:onUnbind_()
54 | end
55 |
56 | function Component:onBind_()
57 | end
58 |
59 | function Component:onUnbind_()
60 | end
61 |
62 | return Component
63 |
--------------------------------------------------------------------------------
/quick/framework/cc/components/ui/DraggableProtocol.lua:
--------------------------------------------------------------------------------
1 |
2 | local Component = cc.Component
3 | local DraggableProtocol = class("DraggableProtocol", Component)
4 |
5 | function DraggableProtocol:ctor()
6 | DraggableProtocol.super.ctor(self, "DraggableProtocol")
7 | end
8 |
9 | function DraggableProtocol:setDraggableEnable(bEnable)
10 | if bEnable then
11 | self.target_:setTouchEnabled(true)
12 | self.target_:addNodeEventListener(cc.NODE_TOUCH_EVENT, function (event)
13 | return self:dragOnTouch_(event)
14 | end)
15 | else
16 | self.target_:setTouchEnabled(false)
17 | end
18 |
19 | return self.target_
20 | end
21 |
22 | function DraggableProtocol:exportMethods()
23 | self:exportMethods_({
24 | "setDraggableEnable",
25 | })
26 |
27 | return self.target_
28 | end
29 |
30 | function DraggableProtocol:dragOnTouch_(event)
31 | local boundingBox = self.target_:getCascadeBoundingBox()
32 |
33 | if "began" == event.name and not cc.rectContainsPoint(boundingBox, cc.p(event.x, event.y)) then
34 | printInfo("DraggableProtocol - touch didn't in viewRect")
35 | return false
36 | end
37 |
38 | if "began" == event.name then
39 | return true
40 | elseif "moved" == event.name then
41 | local posX, posY = self.target_:getPosition()
42 | self.target_:setPosition(
43 | posX + event.x - event.prevX,
44 | posY + event.y - event.prevY)
45 | elseif "ended" == event.name then
46 | end
47 | end
48 |
49 | return DraggableProtocol
50 |
--------------------------------------------------------------------------------
/quick/framework/cc/components/ui/LayoutProtocol.lua:
--------------------------------------------------------------------------------
1 |
2 | local BasicLayoutProtocol = import(".BasicLayoutProtocol")
3 | local LayoutProtocol = class("LayoutProtocol", BasicLayoutProtocol)
4 |
5 | function LayoutProtocol:ctor()
6 | LayoutProtocol.super.ctor(self, "LayoutProtocol")
7 | end
8 |
9 | function LayoutProtocol:setLayoutSize(width, height)
10 | LayoutProtocol.super.setLayoutSize(self, width, height)
11 | self:setLayout(self.layout_)
12 | return self.target_
13 | end
14 |
15 | function LayoutProtocol:setLayout(layout)
16 | self.layout_ = layout
17 | if layout then
18 | layout:apply(self.target_)
19 | end
20 | return self.target_
21 | end
22 |
23 | function LayoutProtocol:getLayout()
24 | return self.layout_
25 | end
26 |
27 | function LayoutProtocol:exportMethods()
28 | LayoutProtocol.super.exportMethods(self)
29 | self:exportMethods_({
30 | "setLayout",
31 | "getLayout",
32 | })
33 | return self.target_
34 | end
35 |
36 | return LayoutProtocol
37 |
--------------------------------------------------------------------------------
/quick/framework/cc/init.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | --[[--
26 |
27 | 初始化 cc 扩展
28 |
29 | cc 扩展在 cocos2dx C++ API 和 quick 基本模块的基础上,提供了符合脚本风格的事件接口、组件架构等扩展。
30 |
31 | ]]
32 |
33 | local CURRENT_MODULE_NAME = ...
34 |
35 | -- init base classes
36 | cc.Registry = import(".Registry")
37 | cc.GameObject = import(".GameObject")
38 | cc.EventProxy = import(".EventProxy")
39 | cc.Component = import(".components.Component")
40 |
41 | -- init components
42 | local components = {
43 | "components.behavior.StateMachine",
44 | "components.behavior.EventProtocol",
45 | "components.ui.BasicLayoutProtocol",
46 | "components.ui.LayoutProtocol",
47 | "components.ui.DraggableProtocol",
48 | }
49 | for _, packageName in ipairs(components) do
50 | cc.Registry.add(import("." .. packageName, CURRENT_MODULE_NAME), packageName)
51 | end
52 |
53 | -- cc = cc.GameObject.extend()
54 | local GameObject = cc.GameObject
55 | local ccmt = {}
56 | ccmt.__call = function(self, target)
57 | if target then
58 | return GameObject.extend(target)
59 | end
60 | printError("cc() - invalid target")
61 | end
62 | setmetatable(cc, ccmt)
63 |
64 | -- load MVC
65 | cc.mvc = import(".mvc.init")
66 |
67 | -- load more library
68 | cc.ui = import(".ui.init")
69 |
70 | -- load extensions
71 | cc.uiloader = import(".uiloader.init")
72 |
--------------------------------------------------------------------------------
/quick/framework/cc/mvc/AppBase.lua:
--------------------------------------------------------------------------------
1 |
2 | local AppBase = class("AppBase")
3 |
4 | AppBase.APP_ENTER_BACKGROUND_EVENT = "APP_ENTER_BACKGROUND_EVENT"
5 | AppBase.APP_ENTER_FOREGROUND_EVENT = "APP_ENTER_FOREGROUND_EVENT"
6 |
7 | function AppBase:ctor(appName, packageRoot)
8 | cc(self):addComponent("components.behavior.EventProtocol"):exportMethods()
9 |
10 | self.name = appName
11 | self.packageRoot = packageRoot or "app"
12 |
13 | local eventDispatcher = cc.Director:getInstance():getEventDispatcher()
14 | local customListenerBg = cc.EventListenerCustom:create(AppBase.APP_ENTER_BACKGROUND_EVENT,
15 | handler(self, self.onEnterBackground))
16 | eventDispatcher:addEventListenerWithFixedPriority(customListenerBg, 1)
17 | local customListenerFg = cc.EventListenerCustom:create(AppBase.APP_ENTER_FOREGROUND_EVENT,
18 | handler(self, self.onEnterForeground))
19 | eventDispatcher:addEventListenerWithFixedPriority(customListenerFg, 1)
20 |
21 | self.snapshots_ = {}
22 |
23 | -- set global app
24 | app = self
25 | end
26 |
27 | function AppBase:run()
28 | end
29 |
30 | function AppBase:exit()
31 | cc.Director:getInstance():endToLua()
32 | if device.platform == "windows" or device.platform == "mac" then
33 | os.exit()
34 | end
35 | end
36 |
37 | function AppBase:enterScene(sceneName, args, transitionType, time, more)
38 | local scenePackageName = self.packageRoot .. ".scenes." .. sceneName
39 | local sceneClass = require(scenePackageName)
40 | local scene = sceneClass.new(unpack(checktable(args)))
41 | display.replaceScene(scene, transitionType, time, more)
42 | end
43 |
44 | function AppBase:createView(viewName, ...)
45 | local viewPackageName = self.packageRoot .. ".views." .. viewName
46 | local viewClass = require(viewPackageName)
47 | return viewClass.new(...)
48 | end
49 |
50 | function AppBase:onEnterBackground()
51 | self:dispatchEvent({name = AppBase.APP_ENTER_BACKGROUND_EVENT})
52 | end
53 |
54 | function AppBase:onEnterForeground()
55 | self:dispatchEvent({name = AppBase.APP_ENTER_FOREGROUND_EVENT})
56 | end
57 |
58 | return AppBase
59 |
--------------------------------------------------------------------------------
/quick/framework/cc/mvc/ModelBase.lua:
--------------------------------------------------------------------------------
1 | local ModelBase = class("ModelBase")
2 | ModelBase.idkey = "id"
3 | ModelBase.schema = {
4 | id = {"string"}
5 | }
6 | ModelBase.fields = {"id"}
7 |
8 | local function filterProperties(properties, filter)
9 | for i, field in ipairs(filter) do
10 | properties[field] = nil
11 | end
12 | end
13 |
14 | function ModelBase:ctor(properties)
15 | cc(self):addComponent("components.behavior.EventProtocol"):exportMethods()
16 |
17 | self.isModelBase_ = true
18 | if type(properties) ~= "table" then properties = {} end
19 | self:setProperties(properties)
20 | end
21 |
22 | function ModelBase:getId()
23 | local id = self[self.class.idkey .. "_"]
24 | assert(id ~= nil, string.format("%s:getId() - invalid id", self.class.__cname))
25 | return id
26 | end
27 |
28 | function ModelBase:isValidId()
29 | local propname = self.class.idkey .. "_"
30 | local id = self[propname]
31 | return type(id) == "string" and id ~= ""
32 | end
33 |
34 | function ModelBase:setProperties(properties)
35 | assert(type(properties) == "table", string.format("%s:setProperties() - invalid properties", self.class.__cname))
36 |
37 | for field, schema in pairs(self.class.schema) do
38 | local typ, def = schema[1], schema[2]
39 | local propname = field .. "_"
40 |
41 | local val = properties[field]
42 | if val ~= nil then
43 | if typ == "number" then val = tonumber(val) end
44 | assert(type(val) == typ, string.format("%s:setProperties() - type mismatch, %s expected %s, actual is %s", self.class.__cname, field, typ, type(val)))
45 | self[propname] = val
46 | elseif self[propname] == nil and def ~= nil then
47 | if type(def) == "table" then
48 | val = clone(def)
49 | elseif type(def) == "function" then
50 | val = def()
51 | else
52 | val = def
53 | end
54 | self[propname] = val
55 | end
56 | end
57 |
58 | return self
59 | end
60 |
61 | function ModelBase:getProperties(fields, filter)
62 | local schema = self.class.schema
63 | if type(fields) ~= "table" then fields = self.class.fields end
64 |
65 | local properties = {}
66 | for i, field in ipairs(fields) do
67 | local propname = field .. "_"
68 | local typ = schema[field][1]
69 | local val = self[propname]
70 | assert(type(val) == typ, string.format("%s:getProperties() - type mismatch, %s expected %s, actual is %s", self.class.__cname, field, typ, type(val)))
71 | properties[field] = val
72 | end
73 |
74 | if type(filter) == "table" then
75 | filterProperties(properties, filter)
76 | end
77 |
78 | return properties
79 | end
80 |
81 | return ModelBase
82 |
--------------------------------------------------------------------------------
/quick/framework/cc/mvc/init.lua:
--------------------------------------------------------------------------------
1 |
2 | -- init MVC
3 | local mvc = {}
4 |
5 | mvc.AppBase = import(".AppBase")
6 | mvc.ModelBase = import(".ModelBase")
7 |
8 | return mvc
9 |
--------------------------------------------------------------------------------
/quick/framework/cc/net/init.lua:
--------------------------------------------------------------------------------
1 | --- init net package
2 | -- @author zrong(zengrong.net)
3 | -- Creation 2014-01-02
4 | local net = {}
5 |
6 | net.SocketTCP = import(".SocketTCP")
7 |
8 | return net
9 |
--------------------------------------------------------------------------------
/quick/framework/cc/ui/UIPageViewItem.lua:
--------------------------------------------------------------------------------
1 |
2 | --[[
3 |
4 | Copyright (c) 2011-2014 chukong-inc.com
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
24 | ]]
25 |
26 | --------------------------------
27 | -- @module UIPageViewItem
28 |
29 | --[[--
30 |
31 | quick 页面控件项
32 |
33 | ]]
34 |
35 | local UIPageViewItem = class("UIPageViewItem", function()
36 | return display.newNode()
37 | end)
38 |
39 | function UIPageViewItem:ctor()
40 | end
41 |
42 | return UIPageViewItem
43 |
--------------------------------------------------------------------------------
/quick/framework/cc/uiloader/UILoaderUtilitys.lua:
--------------------------------------------------------------------------------
1 |
2 | local UILoaderUtilitys = {}
3 |
4 | function UILoaderUtilitys.loadTexture(plist, png)
5 | if UILoaderUtilitys.isNil(plist) then
6 | return
7 | end
8 |
9 | local fileUtil
10 | fileUtil = cc.FileUtils:getInstance()
11 | local fullPath = fileUtil:fullPathForFilename(plist)
12 | local fullPng = fileUtil:fullPathForFilename(png)
13 | -- UILoaderUtilitys.addSearchPathIf(io.pathinfo(fullPath).dirname, fileUtil)
14 | local spCache
15 | spCache = cc.SpriteFrameCache:getInstance()
16 | -- print("UILoaderUtilitys - loadTexture plist:" .. plist)
17 | if png then
18 | spCache:addSpriteFrames(fullPath, fullPng)
19 | else
20 | spCache:addSpriteFrames(fullPath)
21 | end
22 | end
23 |
24 | function UILoaderUtilitys.isNil(str)
25 | if not str or 0 == string.utf8len(str) then
26 | return true
27 | else
28 | return false
29 | end
30 | end
31 |
32 | function UILoaderUtilitys.addSearchPathIf(dir, fileUtil)
33 | if not fileUtil then
34 | fileUtil = cc.FileUtils:getInstance()
35 | end
36 | -- 判断是不是已经存在的默认路径
37 | local paths = fileUtil:getSearchPaths()
38 | for i=1, #(paths) do
39 | if paths[i] == dir then
40 | return
41 | end
42 | end
43 |
44 | if not UILoaderUtilitys.searchDirs then
45 | UILoaderUtilitys.searchDirs = {}
46 | end
47 |
48 | if not UILoaderUtilitys.isSearchExist(dir) then
49 | table.insert(UILoaderUtilitys.searchDirs, dir)
50 | if not fileUtil then
51 | fileUtil = cc.FileUtils:getInstance()
52 | end
53 | fileUtil:addSearchPath(dir)
54 | end
55 | end
56 |
57 | function UILoaderUtilitys.isSearchExist(dir)
58 | local bExist = false
59 | for i,v in ipairs(UILoaderUtilitys.searchDirs) do
60 | if v == dir then
61 | bExist = true
62 | break
63 | end
64 | end
65 |
66 | return bExist
67 | end
68 |
69 | function UILoaderUtilitys.clearPath(fileUtil)
70 | if not UILoaderUtilitys.searchDirs then
71 | return
72 | end
73 |
74 | fileUtil = fileUtil or cc.FileUtils:getInstance()
75 | local paths = fileUtil:getSearchPaths()
76 | local removeIdxTabel
77 |
78 | local luaSearchCount = #UILoaderUtilitys.searchDirs
79 |
80 | for i=luaSearchCount, 1, -1 do
81 | for key, path in ipairs(paths) do
82 | if path == UILoaderUtilitys.searchDirs[i] then
83 | table.remove(paths, key)
84 | break
85 | end
86 | end
87 | table.remove(UILoaderUtilitys.searchDirs, i)
88 | end
89 |
90 | paths = table.unique(paths, true)
91 |
92 | fileUtil:setSearchPaths(paths)
93 | end
94 |
95 | function UILoaderUtilitys.getFileFullName(filename)
96 | local fileUtil = fileUtil or cc.FileUtils:getInstance()
97 |
98 | return fileUtil:fullPathForFilename(filename)
99 | end
100 |
101 | return UILoaderUtilitys
102 |
103 |
--------------------------------------------------------------------------------
/quick/framework/cc/uiloader/init.lua:
--------------------------------------------------------------------------------
1 |
2 | return import(".uiloader").new()
3 |
4 |
--------------------------------------------------------------------------------
/quick/framework/cc/utils/Localize.lua:
--------------------------------------------------------------------------------
1 |
2 | local Localize = {}
3 |
4 | Localize.strings = {}
5 |
6 | function Localize.loadStrings(strings)
7 | Localize.strings = strings
8 | end
9 |
10 | function Localize.query(key, default)
11 | if not default then default = key end
12 | local lang = device.language
13 | if not Localize.strings[lang] or not Localize.strings[lang][key] then return default end
14 | return Localize.strings[lang][key]
15 | end
16 |
17 | function Localize.filename(filenameOrigin)
18 | local fi = io.pathinfo(filenameOrigin)
19 | return fi.dirname .. fi.basename .. "_" .. device.language .. fi.extname
20 | end
21 |
22 | cc = cc or {}
23 | cc.utils = cc.utils or {}
24 | cc.utils.Localize = Localize
25 |
26 | return Localize
27 |
--------------------------------------------------------------------------------
/quick/framework/cc/utils/init.lua:
--------------------------------------------------------------------------------
1 | --- init utils package
2 | -- @author zrong(zengrong.net)
3 | -- Creation 2014-01-02
4 | local utils = {}
5 |
6 | utils.ByteArray = import(".ByteArray")
7 | utils.ByteArrayVarint = import(".ByteArrayVarint")
8 | utils.Gettext = import(".Gettext")
9 |
10 | return utils
11 |
--------------------------------------------------------------------------------
/quick/framework/cocos2dx.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | --------------------------------
26 | -- @module cocos2dx
27 |
28 | --[[--
29 |
30 | 针对 cocos2d-x 的一些封装和扩展
31 |
32 | 预定义的节点事件:
33 |
34 | - cc.NODE_EVENT - enter, exit 等事件
35 | - cc.NODE_ENTER_FRAME_EVENT - 帧事件
36 | - cc.NODE_TOUCH_EVENT - 触摸事件
37 | - cc.NODE_TOUCH_CAPTURE_EVENT - 捕获触摸事件
38 |
39 | 预定义的层事件:
40 |
41 | - cc.ACCELERATE_EVENT - 重力感应事件
42 | - cc.KEYPAD_EVENT - 硬件按键事件
43 |
44 | 预定义的触摸模式:
45 |
46 | - cc.TOUCH_MODE_ALL_AT_ONCE - 多点触摸
47 | - cc.TOUCH_MODE_ONE_BY_ONE - 单点触摸
48 |
49 | ]]
50 |
51 | local p = cc.PACKAGE_NAME .. ".cocos2dx."
52 |
53 | if not cc.p then
54 | -- cc.p exist, so the cocos.init have loaded
55 | require(p .. "Cocos2dConstants")
56 | require(p .. "OpenglConstants")
57 | require(p .. "Cocos2d")
58 | require(p .. "StudioConstants")
59 | end
60 |
61 | require(p .. "Event")
62 | require(p .. "ActionEx")
63 | require(p .. "NodeEx")
64 | require(p .. "SceneEx")
65 | require(p .. "SpriteEx")
66 | require(p .. "DrawNodeEx")
67 |
--------------------------------------------------------------------------------
/quick/framework/cocos2dx/DrawNodeEx.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | --[[--
26 |
27 | ]]
28 |
29 | local c = cc
30 | local DrawNode = c.DrawNode
31 |
32 | local drawPolygon = DrawNode.drawPolygon
33 | function DrawNode:drawPolygon(points, params)
34 | local segments = #points
35 | fillColor = cc.c4f(1,1,1,1)
36 | borderWidth = 0
37 | borderColor = cc.c4f(0,0,0,1)
38 | if params then
39 | if params.fillColor then fillColor = params.fillColor end
40 | if params.borderWidth then borderWidth = params.borderWidth end
41 | if params.borderColor then borderColor = params.borderColor end
42 | end
43 | drawPolygon(self, points, #points, fillColor, borderWidth, borderColor)
44 | return self
45 | end
46 |
47 | local drawDot = DrawNode.drawDot
48 | function DrawNode:drawDot(point, radius, color)
49 | drawDot(self, point, radius, color)
50 | return self
51 | end
52 |
--------------------------------------------------------------------------------
/quick/framework/cocos2dx/Event.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | --[[--
26 |
27 | 定义 cocos2dx 中的事件
28 |
29 | ]]
30 |
31 | local c = cc
32 |
33 | -- cocos2dx 引擎级事件
34 | c.NODE_EVENT = 0
35 | c.NODE_ENTER_FRAME_EVENT = 1
36 | c.NODE_TOUCH_EVENT = 2
37 | c.NODE_TOUCH_CAPTURE_EVENT = 3
38 | c.MENU_ITEM_CLICKED_EVENT = 4
39 | c.ACCELERATE_EVENT = 5
40 | c.KEYPAD_EVENT = 6
41 |
42 | c.NODE_TOUCH_CAPTURING_PHASE = 0
43 | c.NODE_TOUCH_TARGETING_PHASE = 1
44 |
--------------------------------------------------------------------------------
/quick/framework/cocos2dx/SceneEx.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | local c = cc
26 | local Scene = c.Scene
27 |
28 | function Scene:setAutoCleanupEnabled()
29 | self:addNodeEventListener(c.NODE_EVENT, function(event)
30 | if event.name == "exit" then
31 | if self.autoCleanupImages_ then
32 | for imageName, v in pairs(self.autoCleanupImages_) do
33 | display.removeSpriteFrameByImageName(imageName)
34 | end
35 | self.autoCleanupImages_ = nil
36 | end
37 | end
38 | end)
39 | end
40 |
41 | function Scene:markAutoCleanupImage(imageName)
42 | if not self.autoCleanupImages_ then self.autoCleanupImages_ = {} end
43 | self.autoCleanupImages_[imageName] = true
44 | return self
45 | end
46 |
--------------------------------------------------------------------------------
/quick/framework/cocos2dx/SpriteEx.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | local c = cc
26 | local Sprite = c.Sprite
27 |
28 | function Sprite:playAnimationOnce(animation, removeWhenFinished, onComplete, delay)
29 | return transition.playAnimationOnce(self, animation, removeWhenFinished, onComplete, delay)
30 | end
31 |
32 | function Sprite:playAnimationForever(animation, delay)
33 | return transition.playAnimationForever(self, animation, delay)
34 | end
35 |
36 |
--------------------------------------------------------------------------------
/quick/framework/cocos2dx/StudioConstants.lua:
--------------------------------------------------------------------------------
1 | ccs = ccs or {}
2 |
3 |
4 | ccs.MovementEventType = {
5 | start = 0,
6 | complete = 1,
7 | loopComplete = 2,
8 | }
9 |
--------------------------------------------------------------------------------
/quick/framework/deprecated/deprecated_functions.lua:
--------------------------------------------------------------------------------
1 |
2 | display.addSpriteFramesWithFile = DEPRECATED(display.addSpriteFrames, "display.addSpriteFramesWithFile", "display.addSpriteFrames")
3 |
--------------------------------------------------------------------------------
/quick/framework/luaj.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | --------------------------------
26 | -- @module luaj
27 |
28 | --[[--
29 |
30 | Lua 与 Java 的交互接口
31 |
32 | ]]
33 | local luaj = {}
34 |
35 | local callJavaStaticMethod = LuaJavaBridge.callStaticMethod
36 |
37 | --[[--
38 |
39 | 私有方法
40 |
41 | ]]
42 | local function checkArguments(args, sig)
43 | if type(args) ~= "table" then args = {} end
44 | if sig then return args, sig end
45 |
46 | sig = {"("}
47 | for i, v in ipairs(args) do
48 | local t = type(v)
49 | if t == "number" then
50 | sig[#sig + 1] = "F"
51 | elseif t == "boolean" then
52 | sig[#sig + 1] = "Z"
53 | elseif t == "function" then
54 | sig[#sig + 1] = "I"
55 | else
56 | sig[#sig + 1] = "Ljava/lang/String;"
57 | end
58 | end
59 | sig[#sig + 1] = ")V"
60 |
61 | return args, table.concat(sig)
62 | end
63 |
64 | -- start --
65 |
66 | --------------------------------
67 | -- 调用java类的接口。
68 | -- @function [parent=#luaj] callStaticMethod
69 | -- @param string className java类名
70 | -- @param string methodName java类静态方法名
71 | -- @param table args java类静态方法所需要的各种参数 数组
72 | -- @param string sig java类方法的签名
73 | -- @return boolean#boolean ret (return value: bool) ok, mixed ret ok为是否调用成功, ok为true时,ret为java方法的返回值,ok为false时,ret为出错原因
74 |
75 | -- end --
76 |
77 | function luaj.callStaticMethod(className, methodName, args, sig)
78 | local args, sig = checkArguments(args, sig)
79 | printInfo("luaj.callStaticMethod(\"%s\",\n\t\"%s\",\n\targs,\n\t\"%s\"", className, methodName, sig)
80 | return callJavaStaticMethod(className, methodName, args, sig)
81 | end
82 |
83 | return luaj
84 |
--------------------------------------------------------------------------------
/quick/framework/luaoc.lua:
--------------------------------------------------------------------------------
1 | --[[
2 |
3 | Copyright (c) 2011-2014 chukong-inc.com
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
13 | all 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
21 | THE SOFTWARE.
22 |
23 | ]]
24 |
25 | --------------------------------
26 | -- @module luaoc
27 |
28 | --[[--
29 |
30 | Lua 与 Objective-C 的交互接口
31 |
32 | ]]
33 | local luaoc = {}
34 |
35 | local callStaticMethod = LuaObjcBridge.callStaticMethod
36 |
37 | -- start --
38 |
39 | --------------------------------
40 | -- 调用Objective-C类的接口。
41 | -- @function [parent=#luaoc] callStaticMethod
42 | -- @param string className Objective-C类名
43 | -- @param string methodName Objective-C类方法名
44 | -- @param table args Objective-C类方法所需要的各种参数字典,key值为方法的参数名
45 | -- @return boolean#boolean ret (return value: bool) ok, mixed ret ok为是否调用成功, ok为true时,ret为Objective-C方法的返回值,ok为false时,ret为出错原因
46 |
47 | -- end --
48 |
49 | function luaoc.callStaticMethod(className, methodName, args)
50 | local ok, ret = callStaticMethod(className, methodName, args)
51 | if not ok then
52 | local msg = string.format("luaoc.callStaticMethod(\"%s\", \"%s\", \"%s\") - error: [%s] ",
53 | className, methodName, tostring(args), tostring(ret))
54 | if ret == -1 then
55 | printError(msg .. "INVALID PARAMETERS")
56 | elseif ret == -2 then
57 | printError(msg .. "CLASS NOT FOUND")
58 | elseif ret == -3 then
59 | printError(msg .. "METHOD NOT FOUND")
60 | elseif ret == -4 then
61 | printError(msg .. "EXCEPTION OCCURRED")
62 | elseif ret == -5 then
63 | printError(msg .. "INVALID METHOD SIGNATURE")
64 | else
65 | printError(msg .. "UNKNOWN")
66 | end
67 | end
68 | return ok, ret
69 | end
70 |
71 | return luaoc
72 |
--------------------------------------------------------------------------------
/quick/framework/platform/android.lua:
--------------------------------------------------------------------------------
1 |
2 | if cc.bPlugin_ then
3 | luaj = require("cocos.cocos2d.luaj")
4 | else
5 | luaj = require(cc.PACKAGE_NAME .. ".luaj")
6 | end
7 |
8 | function io.exists(path)
9 | return cc.FileUtils:getInstance():isFileExist(path)
10 | end
11 |
12 | function io.readfile(path)
13 | return cc.HelperFunc:getFileData(path)
14 | end
15 |
16 | function device.showAlertAndroid(title, message, buttonLabels, listener)
17 | end
18 |
--------------------------------------------------------------------------------
/quick/framework/platform/ios.lua:
--------------------------------------------------------------------------------
1 |
2 | if cc.bPlugin_ then
3 | luaoc = require("cocos.cocos2d.luaoc")
4 | else
5 | luaoc = require(cc.PACKAGE_NAME .. ".luaoc")
6 | end
7 |
8 | function device.showAlertIOS(title, message, buttonLabels, listener)
9 | end
10 |
--------------------------------------------------------------------------------
/quick/framework/platform/mac.lua:
--------------------------------------------------------------------------------
1 |
2 | if cc.bPlugin_ then
3 | luaoc = require("cocos.cocos2d.luaoc")
4 | else
5 | -- luaoc = require(cc.PACKAGE_NAME .. ".luaoc")
6 | end
7 |
--------------------------------------------------------------------------------
/quick/framework/toluaEx.lua:
--------------------------------------------------------------------------------
1 |
2 | function tolua.cloneTable(src)
3 | if type(src)~="table" then
4 | return nil
5 | end
6 |
7 | local dest = {}
8 | for k, v in pairs(src) do
9 | dest[k] = v
10 | end
11 |
12 | local mt = getmetatable(src)
13 | if mt then
14 | setmetatable(dest, mt)
15 | end
16 |
17 | return dest
18 | end
19 |
20 | if CCPoint then
21 | tolua.default_gc_classes__ = {
22 | -- "CCAtlasNode",
23 | -- "ccBezierConfig",
24 | -- "ccBlendFunc",
25 | -- "CCBool",
26 | -- "CCCamera",
27 | "ccColor3B",
28 | "ccColor4B",
29 | "ccColor4F",
30 | -- "CCDouble",
31 | -- "CCFloat",
32 | -- "ccFontDefinition",
33 | -- "CCImage",
34 | -- "CCInteger",
35 | -- "CCLabelBMFont",
36 | -- "CCLabelTTF",
37 | -- "CCParticleSystemQuad",
38 | "CCPoint",
39 | "CCRect",
40 | -- "CCScrollView",
41 | "CCSize",
42 | -- "CCTableView",
43 | -- "ccTexParams",
44 | -- "CCTileMapAtlas",
45 | -- "CCTMXLayer",
46 | -- "CCTMXLayerInfo",
47 | -- "CCTMXMapInfo",
48 | -- "CCTMXTilesetInfo",
49 | -- "cc_timeval",
50 | -- "HSV",
51 | -- "RGBA",
52 | }
53 | else
54 | tolua.default_gc_classes__ = {
55 | }
56 | end
57 |
58 | function tolua.fullgc(classes)
59 | collectgarbage("collect")
60 |
61 | if classes == nil then
62 | classes = tolua.default_gc_classes__
63 | elseif type(classes) == "string" then
64 | classes = {classes}
65 | elseif type(classes) ~= "table" then
66 | classes = tolua.default_gc_classes__
67 | end
68 |
69 | local o = tolua.getregval("tolua_gc")
70 | local t = tolua.cloneTable(o)
71 | if t then
72 | tolua.setregval("tolua_gc", t)
73 | end
74 |
75 | for i,v in ipairs(classes) do
76 | o = tolua.getubox(v)
77 | t = tolua.cloneTable(o)
78 | if o then
79 | tolua.setubox(v, t)
80 | end
81 | end
82 |
83 | o = nil
84 | t = nil
85 |
86 | collectgarbage("collect")
87 | end
--------------------------------------------------------------------------------
/robot/.gitignore:
--------------------------------------------------------------------------------
1 | !.gitignore
2 | *~
3 | *.swp
4 | *.log
5 | *.tmp
6 | *.pyc
7 | *.svn
8 | *.sublime-project
9 | *.sublime-workspace
10 | coverage.html
11 | .DS_Store
12 | .project
13 | .nodemonignore
14 | .settings/
15 | .sass-cache/
16 | .bower-*/
17 | .idea/
18 | .svn/
19 | node_modules/
20 | tmp/
21 | log/
22 | logs/
23 |
24 |
--------------------------------------------------------------------------------
/robot/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
3 | "browser": true, // Standard browser globals e.g. `window`, `document`.
4 | "esnext": true, // Allow ES.next specific features such as `const` and `let`.
5 | "bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.).
6 | "camelcase": false, // Permit only camelcase for `var` and `object indexes`.
7 | "curly": false, // Require {} for every new block or scope.
8 | "eqeqeq": true, // Require triple equals i.e. `===`.
9 | "immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
10 | "latedef": true, // Prohibit variable use before definition.
11 | "newcap": true, // Require capitalization of all constructor functions e.g. `new F()`.
12 | "noarg": true, // Prohibit use of `arguments.caller` and `arguments.callee`.
13 | "quotmark": "single", // Define quotes to string values.
14 | "regexp": true, // Prohibit `.` and `[^...]` in regular expressions.
15 | "undef": true, // Require all non-global variables be declared before they are used.
16 | "unused": false, // Warn unused variables.
17 | "strict": true, // Require `use strict` pragma in every file.
18 | "trailing": true, // Prohibit trailing whitespaces.
19 | "smarttabs": false, // Suppresses warnings about mixed tabs and spaces
20 | "globals": { // Globals variables.
21 | "jasmine": true,
22 | "angular": true,
23 | "ApplicationConfiguration": true
24 | },
25 | "predef": [ // Extra globals.
26 | "define",
27 | "require",
28 | "exports",
29 | "module",
30 | "describe",
31 | "before",
32 | "beforeEach",
33 | "after",
34 | "afterEach",
35 | "it",
36 | "inject",
37 | "expect"
38 | ],
39 | "indent": 4, // Specify indentation spacing
40 | "devel": true, // Allow development statements e.g. `console.log();`.
41 | "noempty": false, // Prohibit use of empty blocks.
42 | "expr": true
43 | }
44 |
--------------------------------------------------------------------------------
/robot/app.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var path = require('path');
4 | var P = require('bluebird');
5 | var EventEmitter = require('events').EventEmitter;
6 | var quick = require('quick-pomelo');
7 | var logger = quick.logger.getLogger('robot', __filename);
8 | var Getopt = require('node-getopt');
9 | var envConfig = require('./app/config/env.json');
10 |
11 | //P.longStackTraces();
12 | quick.logger.setGlobalLogLevel(quick.logger.levels.WARN);
13 |
14 | var getopt = new Getopt([
15 | ['e', 'env=ARG', 'Environment: dev | prod'],
16 | ['m', 'mode=ARG', 'Mode: master | client'],
17 | ['h', 'help', 'Display this help'],
18 | ]).bindHelp();
19 |
20 | var opt = getopt.parseSystem();
21 |
22 | var mode = opt.options.mode || opt.argv[0];
23 | var env = opt.options.env || envConfig.env;
24 | envConfig.env = env;
25 |
26 | if (mode !== 'master' && mode !== 'client'){
27 | getopt.showHelp();
28 | process.exit(1);
29 | }
30 |
31 | var config = require('./app/config/' + env + '/config');
32 | var Robot = require('pomelo-robot').Robot;
33 | var robot = new Robot(config);
34 |
35 | if (mode === 'master') {
36 | robot.runMaster(__filename);
37 | }
38 | else if (mode === 'client') {
39 | global.config = config.robot;
40 | global.basedir = __dirname;
41 | var scriptPath = path.join(__dirname, envConfig.script);
42 | robot.runAgent(scriptPath);
43 | }
44 |
45 | process.on('uncaughtException', function(err) {
46 | logger.error(err.stack);
47 | });
48 |
--------------------------------------------------------------------------------
/robot/app/cardPredictor.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var util = require('util');
4 | var _ = require('lodash');
5 | var consts = require('../../game-server/app/consts');
6 | var cardFormula = require('../../game-server/app/formula/cardFormula');
7 | var logger = require('quick-pomelo').logger.getLogger('robot', __filename);
8 |
9 |
10 | var exp = module.exports;
11 |
12 | exp.hasGreaterCards = function(played, left, cards) {
13 | var handType = cardFormula.getHandType(cards);
14 | };
15 |
16 |
--------------------------------------------------------------------------------
/robot/app/config/dev/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "master": {
3 | "host": "127.0.0.1",
4 | "port": 8888,
5 | "webport": 8889,
6 | "interval": 100
7 | },
8 | "robot": {
9 | "host": "127.0.0.1",
10 | "port": 3010
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/robot/app/config/env.json:
--------------------------------------------------------------------------------
1 | {
2 | "env":"dev",
3 | "script":"/app/start.js"
4 | }
5 |
--------------------------------------------------------------------------------
/robot/app/start.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var domain = require('domain');
4 | var path = require('path');
5 | var Robot = require(path.join(global.basedir, 'app/robot'));
6 | var logger = require('quick-pomelo').logger.getLogger('robot', path.join(global.basedir, 'app/start.js'));
7 |
8 | global.actor = actor;
9 | if(!global.actor){
10 | throw new Error('must run in pomelo robot context');
11 | }
12 |
13 | var d = domain.create();
14 | d.on('error', function(e){
15 | logger.error(e.stack);
16 | });
17 |
18 | d.run(function(){
19 | logger.warn('start actor %s', global.actor.id);
20 |
21 | var start = function(){
22 | var robot = new Robot({
23 | host : global.config.host,
24 | port : global.config.port,
25 | deviceid : global.actor.id,
26 | });
27 | d.add(robot);
28 |
29 | robot.on('stopped', function(){
30 | logger.warn('restart actor %s', global.actor.id);
31 | start();
32 | });
33 | robot.emit('run');
34 | };
35 |
36 | start();
37 | });
38 |
--------------------------------------------------------------------------------
/robot/gruntfile.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = function(grunt) {
4 | // Unified Watch Object
5 | var watchFiles = {
6 | serverJS: ['gruntfile.js', 'app.js', 'app/**/*.js'],
7 | testJS: ['test/*/*.js'],
8 | };
9 |
10 | // Project Configuration
11 | grunt.initConfig({
12 | pkg: grunt.file.readJSON('package.json'),
13 | watch: {
14 | serverJS: {
15 | files: watchFiles.serverJS,
16 | tasks: ['jshint'],
17 | options: {
18 | livereload: true
19 | }
20 | }
21 | },
22 | jshint: {
23 | all: {
24 | src: watchFiles.serverJS.concat(watchFiles.testJS),
25 | options: {
26 | jshintrc: true
27 | }
28 | }
29 | },
30 | env: {
31 | test: {
32 | NODE_ENV: 'test'
33 | }
34 | },
35 | mochacli: {
36 | options: {
37 | harmony: true
38 | },
39 | test : {
40 | src: watchFiles.testJS,
41 | options : {
42 | reporter: 'spec',
43 | timeout: 5 * 1000
44 | }
45 | },
46 | }
47 | });
48 |
49 | // Load NPM tasks
50 | require('load-grunt-tasks')(grunt);
51 |
52 | // Making grunt default to force in order not to break the project.
53 | grunt.option('force', true);
54 |
55 | // Lint task(s).
56 | grunt.registerTask('lint', ['jshint']);
57 |
58 | // Test task.
59 | grunt.registerTask('test', ['env:test', 'lint', 'mochacli']);
60 | };
61 |
--------------------------------------------------------------------------------
/robot/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ddz-robot",
3 | "version": "0.1.0",
4 | "dependencies": {
5 | "quick-pomelo": "memdb/quick-pomelo",
6 | "bluebird": "~2.9.34",
7 | "lodash": "~3.2.0",
8 | "node-getopt": "~0.2.3",
9 | "node-uuid": "~1.4.3",
10 | "pomelo-robot": "~0.1.4"
11 | },
12 | "devDependencies": {
13 | "grunt-contrib-clean": "~0.6.0",
14 | "grunt-contrib-jshint": "~0.10.0",
15 | "grunt-env": "~0.4.2",
16 | "grunt-mocha-cli": "^1.13.0",
17 | "load-grunt-tasks": "~2.0.0",
18 | "should": "~4.5.0"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/start_clients.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | ./bin/player3.app/Contents/MacOS/player3 -quick `pwd` -workdir `pwd`/ddz -file src/main.lua -size 480x320 &
3 | ./bin/player3.app/Contents/MacOS/player3 -quick `pwd` -workdir `pwd`/ddz1 -file src/main.lua -size 480x320 &
4 | ./bin/player3.app/Contents/MacOS/player3 -quick `pwd` -workdir `pwd`/ddz2 -file src/main.lua -size 480x320 &
5 |
--------------------------------------------------------------------------------