/** Return the user's data after updating his stats */ @RequestMapping("/users/{name}/deletedeteUser") @ResponseBody public Partie deletedeteUser(@PathVariable final String name) throws IOException { Logger.getLogger(LOGGER_NAME).info("deletedeteUser(): " + name); User user = gameHandler.findUser(name); gameHandler.deleteUserdete(user); Partie partie = gameHandler.findPartie(name); return partie; }
/** Return the user's data after updating his stats */ @RequestMapping("/users/{name}/logout") @ResponseBody public Partie logout(@PathVariable final String name) throws IOException { Logger.getLogger(LOGGER_NAME).info("LogOutUser(): " + name); User user = gameHandler.findUser(name); Partie partie = gameHandler.deleteUserwithpartie(user); partie.user = user; return partie; }
/** Return the user's data after updating his stats */ @RequestMapping("/users/{name}/listuser") @ResponseBody public List<User> listuser(@PathVariable final String name) throws IOException { Logger.getLogger(LOGGER_NAME).info("user(): " + name); User user = gameHandler.findUser(name); // gameHandler.updateUserStatsAndSave(user); List<User> listusong = gameHandler.findlistusers(); return listusong; }
/** ajouter le nombre de line */ @RequestMapping("/users/{name}/{detes}/addline") @ResponseBody public Partie addline(@PathVariable final String name, @PathVariable final int detes) throws IOException { Logger.getLogger(LOGGER_NAME).info("detes(): " + detes); Logger.getLogger(LOGGER_NAME).info("user(): " + name); User user = gameHandler.findUser(name); gameHandler.addlinesforuserwithpartie(user, detes, 2); /* List<User> users = gameHandler.findlistusers(); ListUser userlist = new ListUser(); for (User usercurrr:users) { userlist.listUser.add(usercurrr); }*/ Partie partie = gameHandler.findPartie(name); return partie; }
@RequestMapping("/users/{name}/fight") @ResponseBody public FightResult userFight(@PathVariable final String name) throws IOException { Logger.getLogger(LOGGER_NAME).info("userFight(): " + name); User user = gameHandler.findUser(name); // Retrieve user User opponent = gameHandler.findOpponent(user); // Match-making algorithm if (opponent == null) { // return no opponent found gameHandler.updateUserStatsAndSave(user); return new FightResult(FightResult.NO_OPPONENT_FOUND, user); } Logger.getLogger(LOGGER_NAME).info("userFight(): " + name + " vs " + opponent.name); boolean wonFight = gameHandler.resolveFight(user, opponent); // Resolve fight gameHandler.save(); Logger.getLogger(LOGGER_NAME).info("userFight(): won " + wonFight); return new FightResult(wonFight ? FightResult.VICTORY : FightResult.DEFEAT, user); }