Advertisement
Guest User

Untitled

a guest
Mar 28th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. HashMap<String,HashMap<String,Integer>> rules = new HashMap<String,HashMap<String,Integer>>(){{
  2. put("scissors",new HashMap<String,Integer>(){{
  3. put("scissors",DRAW);
  4. put("rock",SECOND_WON);
  5. put("paper",FIRST_WON);
  6. }});
  7. put("rock",new HashMap<String,Integer>(){{
  8. put("scissors",FIRST_WON);
  9. put("rock",DRAW);
  10. put("paper",SECOND_WON);
  11. }});
  12. put("paper",new HashMap<String,Integer>(){{
  13. put("scissors",SECOND_WON);
  14. put("rock",FIRST_WON);
  15. put("paper",DRAW);
  16. }});
  17. }};
  18. try {
  19. int result = rules.get(firstPlayerAction).get(secondPlayerAction);
  20. webSocketService.notifyGameOver(firstPlayer, secondPlayer, result);
  21. } catch (Exception e) {
  22. LogFactory.getInstance().getGameLogger().error("GameMechanics.GameSession/gameActionReveal: Wrong game_action from json! ",e);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement