+// Nothing to do if challenge is refused (just removal)
+router.put("/challenges", access.logged, access.ajax, (req,res) => {
+ switch (req.body.action)
+ {
+ case "withdraw":
+ // turn WillPlay to false (TODO?)
+ break;
+ case "accept":
+ // turn WillPlay to true; if then challenge is full, launch game
+ ChallengeModel.getSeatCount(req.body.id, (scount) => {
+ if (scount == 1)
+ launchGame(req.body.id, req.userId);
+ else
+ ChallengeModel.setSeat(req.body.id, req.userId);
+ })
+ break;
+ }
+ res.json({});
+});
+
+function launchGame(cid, uid)
+{
+ // TODO: gather challenge infos + WillPlay
+ // Then create game, and remove challenge + WillPlay
+}
+