Skip to content

Commit

Permalink
add all files of lordofpomelo
Browse files Browse the repository at this point in the history
  • Loading branch information
xiecc committed Nov 21, 2012
0 parents commit f6c0468
Show file tree
Hide file tree
Showing 481 changed files with 57,078 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.project
logs/*
logs/tmp
*.log
logs/*
*/node-log.log
/game-server/logs/*
!.gitignore
/web-server/logs/*
!.gitignore
/node_modules/*
/game-server/node_modules/*
/web-server/node_modules/*
/shared/node_modules/*
.project
.settings/
**/*.svn
*.svn
*.sublime-project
*.sublime-workspace
*.swp
.DS_Store
.idea
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2012 Netease, Inc. and other pomelo contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
## Lordofpomelo

Lordofpomelo is a browser-based MMORPG(massively multiplayer online role-playing game).
The backend is written in node.js based on [pomelo](https://github.com/NetEase/pomelo/wiki/Introduction-to-pomelo),
which is a fast, scalable, distributed game server framework for node.js. The frontend uses the HTML5 Canvas to draw
the map and renders the animations by colorbox, which is a client side game engine written in JavaScript based on HTML5.
In this game, the client communicates via websockets with the server.

## How to install

You can install lordofpomelo with the guiding of the document
[Installation guide of lordofpomelo](https://github.com/NetEase/pomelo/wiki/Installation-guide-of-lordofpomelo).
This document provides details on how to install and configure lordofpomelo quickly. Also you can find solutions
for some problem like port conflicts.

## How to play

Like other MMORPG, you should clone a hero with the given username. All of the heros will clone hp, mp, attack and
defense etc from the hero ontology. There are three scenes in the game, where you can roam casually, kill monsters for experiences,
treasures and equipments. If one monster is killed, more monsters will be cloned, which forces you to improve the hero
level and get more powerful equipments. For a better understanding of the game plot, you should visit npc and
communicate with it. Task system is very important, which will let you get more equipments and enjoy the game enough.

## Requirements

* [nodejs](http://nodejs.org/)
* Linux or Mac os
* MySQL

## Open source projects

Lordofpomelo requires the following npm libraries:

* pomelo(http://pomelo.netease.com/)
* colorbox
* express(http://expressjs.com/)
* socket.io(http://socket.io/)

.................

#### pomelo

Pomelo is made by our team. It is a fast, scalable, distributed game server framework for node.js. It provides the basic
development framework and a lot of related components, including libraries and tools. Pomelo is also suitable for realtime
web application, its distributed architecture makes pomelo scales better than other realtime web framework.

####colorbox
Colorbox is our team's another open source project. It is a client side game engine written in JavaScript based on HTML5 and
soon to be open source.

## Viewing

* Visit the [lordofpomelo](http://nodejs.netease.com/lordofpomelo)
* or you can visit [github:lordofpomelo](http://github.com/node-pomelo/lordofpomelo)to download the source and install it on your local machine.

## Screenshot

![scene three](http://pomelo.netease.com/image/demo4.png)

This is a screenshot in scene three. There are many monsters and one hero named Traxex who is killing the monster for experiences, treasures and equipments.


## License

(The MIT License)

Copyright (c) 2012 Netease, Inc. and other contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 changes: 15 additions & 0 deletions game-server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.project
*.log
*/node-log.log
logs/*.log
!.gitignore
node_modules/*
.project
.settings/
**/*.svn
*.svn
*.sublime-project
*.sublime-workspace
*.swp
.DS_Store
.idea
21 changes: 21 additions & 0 deletions game-server/.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"predef": [
"describe",
"it",
"before",
"after",
"window",
"__resources__"
],
"es5": true,
"node": true,
"eqeqeq": true,
"undef": true,
"curly": true,
"bitwise": true,
"immed": false,
"newcap": true,
"nonew": true,
"white": false,
"smarttabs": true
}
97 changes: 97 additions & 0 deletions game-server/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
var pomelo = require('pomelo');
var world = require('./app/domain/world');
var area = require('./app/domain/area/area');
var dataApi = require('./app/util/dataApi');
var routeUtil = require('./app/util/routeUtil');
var playerFilter = require('./app/servers/area/filter/playerFilter');
var ChatService = require('./app/services/chatService');

/**
* Init app for client
*/
var app = pomelo.createApp();
app.set('name', 'lord of pomelo');

// Configure for production enviroment
app.configure('production', function() {
// enable the system monitor modules
app.enable('systemMonitor');
});

// configure for global
app.configure('production|development', function() {
var sceneInfo = require('./app/modules/sceneInfo');
var onlineUser = require('./app/modules/onlineUser');
if(typeof app.registerAdmin === 'function'){
app.registerAdmin(sceneInfo, {app: app});
app.registerAdmin(onlineUser, {app: app});
}
//Set areasIdMap, a map from area id to serverId.
if (app.serverType !== 'master') {
var areas = app.get('servers').area;
var areaIdMap = {};
for(var id in areas){
areaIdMap[areas[id].area] = areas[id].id;
}
app.set('areaIdMap', areaIdMap);
}
// proxy configures
app.set('proxyConfig', {
cacheMsg: true,
interval: 30,
lazyConnection: true,
enableRpcLog: true
});

// remote configures
app.set('remoteConfig', {
cacheMsg: true,
interval: 30
});

// route configures
app.route('area', routeUtil.area);
app.route('connector', routeUtil.connector);

app.loadConfig('mysql', app.getBase() + '/../shared/config/mysql.json');
app.filter(pomelo.timeout());
});

// Configure for auth server
app.configure('production|development', 'auth', function() {
// load session congfigures
app.set('session', require('./config/session.json'));
});

// Configure for area server
app.configure('production|development', 'area', function(){
app.filter(pomelo.filters.serial());
app.before(playerFilter());

var areaId = app.get('curServer').area;
if(!areaId || areaId < 0) {
throw new Error('load area config failed');
}
world.init(dataApi.area.all());
area.init(dataApi.area.findById(areaId));
});

// Configure database
app.configure('production|development', 'area|auth|connector|master', function() {
var dbclient = require('./app/dao/mysql/mysql').init(app);
app.set('dbclient', dbclient);
app.load(pomelo.sync, {path:__dirname + '/app/dao/mapping', dbclient: dbclient});
});

// Configure for chat server
app.configure('production|development', 'chat', function() {
app.set('chatService', new ChatService(app));
});

//start
app.start();

// Uncaught exception handler
process.on('uncaughtException', function(err) {
console.error(' Caught exception: ' + err.stack);
});
38 changes: 38 additions & 0 deletions game-server/app/ai/action/findNearbyPlayer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
var bt = require('pomelo-bt');

var Action = function(opts) {
this.blackboard = opts.blackboard;
};

module.exports = Action;

var pro = Action.prototype;

/**
* Find the near by player and hates the player.
*
* @return {Number} bt.RES_SUCCESS if find a player and hates him;
* bt.RES_FAIL if no player nearby.
*/
pro.doAction = function() {
var character = this.blackboard.curCharacter;
if(character.target || character.haters.length) {
//have a target already
return bt.RES_SUCCESS;
}

var area = this.blackboard.area;
//TODO: remove magic range: 300
var players = area.getEntitiesByPos({x: character.x, y: character.y}, ['player'], 300);
if(players && players.length) {
//TODO: remove magic hate point: 5
character.increaseHateFor(players[0].enitityId, 5);
return bt.RES_SUCCESS;
}
//TODO: implements reset logic
return bt.RES_FAIL;
};

module.exports.create = function() {
return Action;
};
Loading

0 comments on commit f6c0468

Please sign in to comment.