GitHub PullRequestReviewCommentEvent at 2014-03-14 05:55:17
Repository: nightBird
Actor: Zhigalov
Payload: {"comment":{"url":"https://api.github.com/repos/urfu-code/nightBird/pulls/comments/10597150","id":10597150,"diff_hunk":"@@ -1,19 +1,80 @@\n-﻿\n-public interface Wood {\n-\t/**\n-\t * Создает нового лесного жителя.\n-\t * \n-\t * @param name имя лесного жителя\n-\t * @param start место появления\n-\t */\n-\tvoid createWoodman(String name, Point start);\n+\n+import java.util.HashMap;\n+\n+\n+public class Wood implements IWood {\n+\tprivate HashMap<Point, Character> labyrinth; // инфа по стенам и тропинкам\n+\tprivate int labLength = 0;\n+\tprivate int labWidth = 0;\n+\tprivate HashMap<String, Woodman> listOfWoodmen = new HashMap<String, Woodman>(); // список игроков\n \t\n-\t/**\n-\t * Перемещает лесного жителя.\n-\t * \n-\t * @param name имя лесного жителя\n-\t * @param direction направление перемещения\n-\t * @return результат перемещения\n-\t */\n-\tAction move(String name, Direction direction);\n+\tWood(HashMap<Point, Character> lab, int length, int width) {\n+\t\tthis.labyrinth = lab;\n+\t\tthis.labLength = length;\n+\t\tthis.labWidth = width;\n+\t}\n+\t\n+\tpublic Character getChar(Point location) {\n+\t\treturn labyrinth.get(location);\n+\t}\n+\t\n+\tpublic Woodman getWoodman(String name) {\n+\t\treturn listOfWoodmen.get(name);\n+\t}\n+\n+\t@Override\n+\tpublic void createWoodman(String name, Point start) {\n+\t\tif (!listOfWoodmen.containsKey(name)) // имя уникально\n+\t\t\tlistOfWoodmen.put(name, new Woodman(name, start));\n+\t\telse throw new RuntimeException(\"Такой вудмен уже есть в лесу!\");\n+\t}\n+\n+\tpublic Action result(Character symbol, String name) {\n+\t\tswitch (symbol) {  // символ лабиринта, на котором мы стоим\n+\t\tcase '0' : return Action.Ok;\n+\t\tcase '1' : return Action.Fail;\n+\t\tcase 'L' : getWoodman(name).AddLife(); return Action.Life;\n+\t\tcase 'K' : \n+\t\t\tif (getWoodman(name).Kill()) {\n+\t\t\t\tgetWoodman(name).MoveToStart();\n+\t\t\t}\n+\t\t\telse {\n+\t\t\t\t\tlistOfWoodmen.remove(name);\n+\t\t\t\t}\n+\t\t\treturn Action.Dead;\n+\t\t}\n+\t\treturn Action.Ok;\n+\t}\n+\t@Override\n+\tpublic Action move(String name, Direction direction) throws RuntimeException, WoodmanNotFound {\n+\t\tif (!listOfWoodmen.containsKey(name))\n+\t\t\tthrow new WoodmanNotFound(\"Нет такого вудмена в лесу!\");","path":"01.wood/src/Wood.java","position":68,"original_position":68,"commit_id":"5b1ca95d682e60f34879715db0a5dce8095a9dfc","original_commit_id":"5b1ca95d682e60f34879715db0a5dce8095a9dfc","user":{"login":"Zhigalov","id":1654243,"avatar_url":"https://gravatar.com/avatar/c8c3c2a864f24f9f1261bd9e8c107583?d=https%3A%2F%2Fidenticons.github.com%2F03227d3a5a775d17b7f8a327d2401d80.png&r=x","gravatar_id":"c8c3c2a864f24f9f1261bd9e8c107583","url":"https://api.github.com/users/Zhigalov","html_url":"https://github.com/Zhigalov","followers_url":"https://api.github.com/users/Zhigalov/followers","following_url":"https://api.github.com/users/Zhigalov/following{/other_user}","gists_url":"https://api.github.com/users/Zhigalov/gists{/gist_id}","starred_url":"https://api.github.com/users/Zhigalov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zhigalov/subscriptions","organizations_url":"https://api.github.com/users/Zhigalov/orgs","repos_url":"https://api.github.com/users/Zhigalov/repos","events_url":"https://api.github.com/users/Zhigalov/events{/privacy}","received_events_url":"https://api.github.com/users/Zhigalov/received_events","type":"User","site_admin":false},"body":"Не исключение - а статус!","created_at":"2014-03-14T05:55:17Z","updated_at":"2014-03-14T05:55:17Z","html_url":"https://github.com/urfu-code/nightBird/pull/5#discussion_r10597150","pull_request_url":"https://api.github.com/repos/urfu-code/nightBird/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/urfu-code/nightBird/pulls/comments/10597150"},"html":{"href":"https://github.com/urfu-code/nightBird/pull/5#discussion_r10597150"},"pull_request":{"href":"https://api.github.com/repos/urfu-code/nightBird/pulls/5"}}}}