Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
b463ea1
Update stage.js
ClemenceBuche Jun 8, 2016
27b6b11
Update 42.json
ClemenceBuche Jun 8, 2016
847a1f5
Update board.js
ClemenceBuche Jun 8, 2016
c3138ee
Type pokemon + Pages
nathanpecqueux Jun 9, 2016
366c9b4
Update board.js
ClemenceBuche Jun 9, 2016
bdae3c9
Update 42.json
ClemenceBuche Jun 9, 2016
6e844fc
Inscription
ben62200 Jun 9, 2016
0cf56a8
Fix register failed
eramat Jun 9, 2016
c0b6580
10062016
nathanpecqueux Jun 10, 2016
0ab3e3a
Suppression
ben62200 Jun 10, 2016
92234ce
Login 10/06/16
ben62200 Jun 10, 2016
4929017
Log et déconnection
ben62200 Jun 10, 2016
592411c
Ajout de fonctions node.js 1006 11h
nathanpecqueux Jun 10, 2016
c7230a5
ajout de la page combat
PierrePreuss Jun 10, 2016
edb6292
12/06/16
ben62200 Jun 12, 2016
690ed44
13/06/16 modif Lucas
ben62200 Jun 13, 2016
09234ec
ajout de fonction node.js
nathanpecqueux Jun 13, 2016
f721307
Ajout de pokemon
nathanpecqueux Jun 13, 2016
d3eb98c
Ajout de 2 fonctions dans player
nathanpecqueux Jun 13, 2016
e12ddff
ajout du fond du combat
nathanpecqueux Jun 13, 2016
56d2a10
page combat
ben62200 Jun 13, 2016
84216bf
modif combat
ben62200 Jun 13, 2016
6aa1ac4
Création du deck
nathanpecqueux Jun 13, 2016
5693199
creation du deck 2
nathanpecqueux Jun 13, 2016
bda725d
modif combat
ben62200 Jun 13, 2016
a611315
correction erreur
nathanpecqueux Jun 13, 2016
1cba39a
1306 15h30
nathanpecqueux Jun 13, 2016
2506c8a
1306 15h35
nathanpecqueux Jun 13, 2016
ecea9b9
suppresion
nathanpecqueux Jun 13, 2016
b6f994a
Correction
nathanpecqueux Jun 13, 2016
2607f6b
css page combat
ben62200 Jun 13, 2016
3e2aee2
François 13062016
nathanpecqueux Jun 14, 2016
07804d1
Suppresion pokemon json inutiles
nathanpecqueux Jun 14, 2016
f9bfead
amélioration creationDeck, combat + fonction node.js
nathanpecqueux Jun 14, 2016
237a40c
Page GestionDeck, onglets finis
nathanpecqueux Jun 14, 2016
efc8602
13/06/16 21h30
ben62200 Jun 14, 2016
3449c1e
Apercu carte creationDeck finis
nathanpecqueux Jun 15, 2016
6383594
Ajout dossier zip image
nathanpecqueux Jun 15, 2016
594ad19
Sockets 15/06/16
ben62200 Jun 15, 2016
8db8eae
Modification des images dossier public.zip à dézipper
nathanpecqueux Jun 15, 2016
9beefab
suppression socket.js
nathanpecqueux Jun 15, 2016
26bddc7
Json 15/06/16
ben62200 Jun 15, 2016
72d7f60
1506 16h
nathanpecqueux Jun 15, 2016
d63574b
MAJ JSON
ben62200 Jun 15, 2016
11a39e6
bbd + debut page admin
nathanpecqueux Jun 17, 2016
11c21b1
Delete public.zip
ClemenceBuche Jun 17, 2016
c65d643
MAJ 17/06/16 Admin
ben62200 Jun 17, 2016
399c4da
SUPP models
ben62200 Jun 17, 2016
272d4cb
MAJ Image et JSON fonctionne !
ben62200 Jun 17, 2016
b5654a6
MAJ 20/06/16
ben62200 Jun 20, 2016
3aed375
Revert "MAJ 20/06/16"
ben62200 Jun 20, 2016
088df0c
MAJ 20/06/16 valide
ben62200 Jun 20, 2016
06fb36c
page admin
nathanpecqueux Jun 21, 2016
2d9d887
Gestion des extension dans creationdeck + maj combat
nathanpecqueux Jun 22, 2016
fff2754
MAJ Gestion
ben62200 Jun 23, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
public/images/cards
node_modules/
.idea/
17 changes: 17 additions & 0 deletions BDD/Account.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Created by Nathan on 08/06/2016.
*/

//Création d'un schéma pour nos Accounts

exports = module.exports = function(app,mongoose){

var Account = new mongoose.Schema({
username: String,
password: String

});

// Modele du schéma
app.db.model('Account',Account);
};
8 changes: 8 additions & 0 deletions BDD/BDD.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Created by Nathan on 08/06/2016.
*/

// url de la bdd
module.exports = {
'url' : 'mongodb://localhost:27017/bdd'
};
44 changes: 41 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,64 @@ var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;

/* Nos routes : */
var routes = require('./routes/index');


var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(require('express-session')({
secret: 'keyboard cat',
resave: false,
saveUninitialized: false
}));

app.use('/', routes);

// passport config
app.use(passport.initialize());
app.use(passport.session());
app.use(express.static(path.join(__dirname, 'public')));

// BDD mongoose
mongoose.connect('mongodb://localhost/OpenPokemon');
var ConfigBDD = require('./BDD/BDD.js');
app.db = mongoose.createConnection(ConfigBDD.url);
require('./bdd')(app, mongoose);
var collection = app.db.collection('accounts');

app.db.models.Account.findOne({'username':'admin'}, function (req,account) {
//si on ne trouve pas de username admin
if (account == null){
//on en créé un
console.log('pas admin , on en fait un');
app.db.models.Account.create({'username':'admin','password':'admin'});
}else {
//il y en a déjà, donc on les supprime, et on en refait un
console.log('un admin, on le delete, et on en refait un ');
collection.remove({'username':'admin'});
app.db.models.Account.create({'username':'admin','password':'admin'});
}
});





// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
Expand Down Expand Up @@ -54,5 +93,4 @@ app.use(function(err, req, res, next) {
});
});


module.exports = app;
7 changes: 7 additions & 0 deletions bdd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Created by Nathan on 08/06/2016.
*/

exports = module.exports = function (app, mongoose){
require('./BDD/Account')(app,mongoose);
};
147 changes: 110 additions & 37 deletions bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
var app = require('../app');
var debug = require('debug')('OpenPokemon:server');
var http = require('http');
var core = require('../core');
var fs = require('fs');
var path = require('path');

/**
* Get port from environment and store in Express.
Expand All @@ -20,71 +23,141 @@ app.set('port', port);
*/

var server = http.createServer(app);
var io = require('socket.io').listen(server);


/**
* Listen on provided port, on all network interfaces.
*/
var pokemon_cards=[];
var energy_cards=[];
var filesXY=fs.readdirSync('../data/XY/XY');
var filesXYOriginesAntique=fs.readdirSync('../data/XY/XY - Origines Antiques');
var filesXYImpactdesDestins=fs.readdirSync('../data/XY/XY - Impact des Destins');
var filesXYGeneration=fs.readdirSync('../data/XY/Generations');
var filesXYPoingFurieux=fs.readdirSync('../data/XY/Poings Furieux');

filesXY.forEach(function(file){
if(path.extname(file)==='.json') {
pokemon_cards.push(new core.Builder().createFromJSON(fs.readFileSync('../data/XY/XY/' + file, 'utf8')));
}

});
filesXYOriginesAntique.forEach(function(file){
if(path.extname(file)==='.json') {
pokemon_cards.push(new core.Builder().createFromJSON(fs.readFileSync('../data/XY/XY - Origines Antiques/' + file, 'utf8')));
}

});
filesXYImpactdesDestins.forEach(function(file){
if(path.extname(file)==='.json') {
pokemon_cards.push(new core.Builder().createFromJSON(fs.readFileSync('../data/XY/XY - Impact des Destins/' + file, 'utf8')));
}

});
filesXYGeneration.forEach(function(file){
if(path.extname(file)==='.json') {
pokemon_cards.push(new core.Builder().createFromJSON(fs.readFileSync('../data/XY/Generations/' + file, 'utf8')));
}

});
filesXYPoingFurieux.forEach(function(file){
if(path.extname(file)==='.json') {
pokemon_cards.push(new core.Builder().createFromJSON(fs.readFileSync('../data/XY/Poings Furieux/' + file, 'utf8')));
}

});
var deck= new core.Deck(pokemon_cards,energy_cards,[]);
var player= new core.Player(deck);
player.selectInitialHand();

io.sockets.on('connection', function (socket) {
socket.on('message', function (message) {
console.log(message);
socket.message = message;
socket.broadcast.emit('message', message);
});
socket.emit("bench",player.bench());
socket.emit("hand",player.hand());
socket.emit("ennemyhand",player.hand().length);
socket.on("toBench",function(id) {
if(player.bench().length < 5) {
player.addBench(id);
player.takeCardInHand(id);
socket.emit("bench", player.bench());
socket.emit("hand", player.hand());
}

});
socket.on("toActive",function(id) {
player.putBenchToActive(id);
socket.emit("bench", player.bench());
socket.emit("pokemonActive",player.activePokemon());
socket.emit("life_point",player.activePokemon().life_point);
});
});

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);


/**
* Normalize a port into a number, string, or false.
*/

function normalizePort(val) {
var port = parseInt(val, 10);
var port = parseInt(val, 10);

if (isNaN(port)) {
// named pipe
return val;
}
if (isNaN(port)) {
// named pipe
return val;
}

if (port >= 0) {
// port number
return port;
}
if (port >= 0) {
// port number
return port;
}

return false;
return false;
}

/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}

var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
if (error.syscall !== 'listen') {
throw error;
}

var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}

/**
* Event listener for HTTP server "listening" event.
*/

function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
5 changes: 5 additions & 0 deletions core/attack.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ module.exports = ( function (self) {
return value;
};

this.doAttack = function(){


}

this.to_object = function () {
return {
energies: energies.map(function (energy) { return core.EnergyType.key(energy); }),
Expand Down
12 changes: 9 additions & 3 deletions core/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ module.exports = ( function (self) {

this.turn = function () {
players[attacker_index].attacks()[0].action().run(this);
changeAttackerDefenser();
changeAttackerDefender();
};

var changeAttackerDefenser = function () {
this.winner = function(){
if(player.price_card.length===0){

}
};

var changeAttackerDefender = function () {
var index = attacker_index;

attacker_index = defender_index;
Expand All @@ -59,4 +65,4 @@ module.exports = ( function (self) {
};

return self;
}(OpenPokemon || {}));
}(OpenPokemon || {}));
2 changes: 1 addition & 1 deletion core/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = ( function (self) {
new core.Value(data.weakness.value.operator, data.weakness.value.value, data.weakness.value.supplement)) : null;
var resistance = data.resistance ? new core.Resistance(core.EnergyType[data.resistance.type],
new core.Value(data.resistance.value.operator, data.resistance.value.value, data.resistance.value.supplement)) : null;
var expansion = new core.Expansion(data.expansion.name, data.expansion.card_number);
var expansion = new core.Expansion(data.expansion.name, data.expansion.card_number);
var attacks = [];

data.attacks.forEach(function (attack) {
Expand Down
6 changes: 6 additions & 0 deletions core/deck.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ module.exports = ( function (self) {
return trainer_cards;
};




this.mix = function () {
var list = [];

Expand Down Expand Up @@ -68,6 +71,9 @@ module.exports = ( function (self) {
});
};




this.valid = function () {
return pokemon_cards.length + energy_cards.length + trainer_cards.length === 60;
};
Expand Down
Loading