{"id":252956,"date":"2015-03-12T17:24:02","date_gmt":"2015-03-12T13:24:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=252956"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=252956","title":{"rendered":"\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u0433\u0440 \u0431\u0435\u0437 Canvas"},"content":{"rendered":"<p> \t\t\t\u041e\u0434\u043d\u0430\u0436\u0434\u044b \u043c\u043d\u0435 \u043f\u043e\u043f\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u0433\u043b\u0430\u0437\u0430 \u043a\u0430\u0440\u0442\u043e\u0447\u043d\u0430\u044f \u0438\u0433\u0440\u0430 HeartStone \u043e\u0442 Blizzard. \u0418\u0433\u0440\u0430\u044f \u0432 \u043d\u0435\u0435 \u043f\u0440\u0438\u0448\u043b\u0430 \u043c\u044b\u0441\u043b\u044c, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 html5, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0438\u043c \u0431\u044b\u0442\u044c \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u0441\u0435\u043d\u043d\u044b\u043c\u0438. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u043c\u043e\u0433\u0443\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043b\u044e\u0434\u0438, \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0441\u0430\u0439\u0442\u043e\u0432.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c:  <\/p>\n<ul>\n<li>\u0412\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 LAMP (\u0431\u0435\u0437 phpDaemon);<\/li>\n<li>\u0416\u0435\u043b\u0430\u043d\u0438\u0435 \u043e\u0431\u043a\u0430\u0442\u0430\u0442\u044c WebSockets.<\/li>\n<\/ul>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u0441\u0435. \u042d\u0442\u043e\u0433\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u0435.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0414\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b <a href=\"https:\/\/github.com\/Doncode\/simple_php_websocket_server\">\u0433\u043e\u0442\u043e\u0432\u044b\u0439 WebSockets \u0441\u0435\u0440\u0432\u0435\u0440<\/a>, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 php.<\/p>\n<p>  \u041e\u0431\u043c\u0435\u043d\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 json, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>  \u0421\u0430\u043c\u043e\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u2014 \u044d\u0442\u043e \u043d\u0430\u043b\u0430\u0434\u0438\u0442\u044c \u0432\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0435 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0438 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0433\u0440\u0443) \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c.<\/p>\n<p>  \u0412 \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">\tvar socketInfo = {}; \tsocket = new WebSocket('ws:\/\/localhost:8000');\t\t \tsocket.onopen = function (e){ \t\tsocketInfo.method = &quot;connect&quot;; \t\tsocket.send(JSON.stringify(socketInfo));\t \t\tconsole.log('\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043e \u0441 ws:\/\/localhost:8000');\t\t \t} \tsocket.onclose = function (e){ \t\tconsole.log('\u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0440\u0432\u0430\u043d\u043e!'); \t} \tsocket.onmessage = function (e){ \t\tif (typeof e.data === &quot;string&quot;){ \t\t\tvar request = JSON.parse(e.data); \t\t\tActions[request.function](request.args); \t\t};\t \t} <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 WebSockets. \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043c\u0435\u0442\u043e\u0434\u0435 onmessage.<\/p>\n<p>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u043e\u043d \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 json, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0430\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b \u0441\u0435\u0440\u0432\u0435\u0440. \u0421\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0438\u043c\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043d\u0430 \u043a\u043b\u0438\u0435\u043d\u0442\u0435, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0432 \u043d\u0435\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c.<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u0438\u043c\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0435\u043a\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u0430 (\u043a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2014 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 window). \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 Actions:<\/p>\n<pre><code class=\"javascript\">\tvar Actions = { \t\tmyId: function(id){ \t\t\tlocalStorage.setItem(&quot;myId&quot;, id); \t\t},\t\t\t\t \t\tlog: function(str){ \t\t\tconsole.log(str); \t\t},                 .......          }\t\t\t  <\/code><\/pre>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0442\u043e\u0436\u0435 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 json \u0444\u043e\u0440\u043c\u0430\u0442\u0435. \u0423 \u043c\u0435\u043d\u044f \u043e\u043d\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u043f\u043e\u043b\u044f: \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442.<br \/>  \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443:<\/p>\n<pre><code class=\"php\">function websocket_onmessage($keyINsock, $str){ \tglobal $Users;\t  \t$json = json_decode($str); \t$method = strval($json-&gt;{'method'}); \t$args = $json-&gt;{'args'};  \tif (!isset($args)) $args = $keyINsock; \tif (!empty($method)) $Users-&gt;$method($keyINsock, $args); }  <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f websocket_onmessage \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u043d\u0430\u0448 \u0441\u0435\u0440\u0432\u0435\u0440, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044f ID \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0414\u0430\u043b\u0435\u0435 \u0438\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430 Users.<\/p>\n<p>  \u041f\u043e\u044f\u0441\u043d\u044e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0438\u0433\u0440\u043e\u043a\u043e\u0432:<\/p>\n<pre><code class=\"php\">  public function frAccept($myid, $opId){     $this-&gt;opponents[$myid] = $opId;     $this-&gt;opponents[$opId] = $myid;     $args = array($myid, $opId);     $arrOut = array('function' =&gt; 'frAccept', 'args' =&gt; $args);     $arrOutJSON = json_encode($arrOut);         websock_send($opId, $arrOutJSON);        websock_send($myid, $arrOutJSON);      } <\/code><\/pre>\n<p>  \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0438\u0448\u0435\u043b \u0437\u0430\u043f\u0440\u043e\u0441, \u0438\u043c\u0435\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f $myId. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u043c\u0435\u0442\u043e\u0434 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u0438\u0433\u0440\u043e\u043a\u043e\u0432 (\u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u2014 id \u0438\u0433\u0440\u043e\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u044f\u043b \u043f\u0440\u0438\u0433\u043b\u0430\u0448\u0435\u043d\u0438\u0435 \u0432 \u0441\u0440\u0430\u0436\u0435\u043d\u0438\u0435). \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043d\u043e\u0441\u0438\u043c \u0430\u0439\u0434\u0438\u0448\u043d\u0438\u043a\u0438 \u043e\u043f\u043e\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0438\u043c\u0438 (\u043e\u043d\u0438 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0438 \u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u0435 \u0432 LocalStorage, \u043d\u043e \u0437\u0430\u0447\u0435\u043c \u0433\u043e\u043d\u044f\u0442\u044c \u0438\u0445 \u0442\u0443\u0434\u0430-\u0441\u044e\u0434\u0430).<\/p>\n<p>  \u0412\u0441\u0435, \u043a\u0442\u043e \u0447\u0435\u0439 \u043e\u043f\u043f\u043e\u043d\u0435\u043d\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0438, \u043e\u0442\u0434\u0430\u0435\u043c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431\u043e\u0438\u043c \u0438\u0433\u0440\u043e\u043a\u0430\u043c.<\/p>\n<pre><code class=\"javascript\">\t\tfrAccept: function(id){                        fight_start(id);                        console.log('Fight starting');                                                   \t\t}\t           ....... \t\t\t \tfunction fight_start(ids){ \t\t$('body').load('fight.html'); \t\tcurplayer = ids[0];\t\t \t\tlocalStorage.setItem(&quot;opponent&quot;, ids[0]); \t\tif (ids[0] == localStorage.getItem(&quot;myId&quot;)) localStorage.setItem(&quot;opponent&quot;, ids[1]); \t}  <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f curplayer \u0445\u0440\u0430\u043d\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0442\u043e\u043c, \u0447\u0435\u0439 \u0441\u0435\u0439\u0447\u0430\u0441 \u0445\u043e\u0434.<\/p>\n<p>  \u0412\u0441\u044f \u0438\u0433\u0440\u0430 \u0443 \u043d\u0430\u0441 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043d\u0430 \u043e\u0431\u044b\u0447\u043d\u044b\u0445 \u0431\u043b\u043e\u043a\u0430\u0445 div.<\/p>\n<pre><code class=\"html\">&lt;meta http-equiv=&quot;Cache-Control&quot; content=&quot;no-cache&quot; \/&gt; \t&lt;div id=&quot;to_area&quot;&gt;&lt;\/div&gt; \t&lt;div id=&quot;wrapper&quot;&gt; \t\t&lt;div id=&quot;opHand&quot;&gt;&lt;\/div&gt; \t\t&lt;div id=&quot;area&quot;&gt; \t\t\t&lt;div id=&quot;timer&quot;&gt; \t\t\t\t&lt;div class=&quot;bg&quot;&gt;&lt;\/div&gt; \t\t\t&lt;\/div&gt; \t\t\t&lt;div id=&quot;opUnits&quot;&gt; \t\t\t\t&lt;div class=&quot;nexus card&quot; data-health=&quot;30&quot; id=&quot;&quot; data-attack=&quot;0&quot;&gt; \t\t\t\t\t&lt;div class=&quot;health&quot;&gt; \t\t\t\t\t\t&lt;div class=&quot;inner&quot;&gt;30&lt;\/div&gt; \t\t\t\t\t&lt;\/div&gt;\t\t\t\t\t \t\t\t\t&lt;\/div&gt; \t\t\t\t&lt;div class=&quot;bg&quot;&gt;&lt;\/div&gt; \t\t\t&lt;\/div&gt; \t\t\t&lt;div id=&quot;myUnits&quot;&gt; \t\t\t\t&lt;div class=&quot;nexus card&quot; data-health=&quot;30&quot; data-attack=&quot;0&quot;&gt; \t\t\t\t\t&lt;div class=&quot;health&quot;&gt; \t\t\t\t\t\t&lt;div class=&quot;inner&quot;&gt;30&lt;\/div&gt; \t\t\t\t\t&lt;\/div&gt;\t\t\t\t\t \t\t\t\t&lt;\/div&gt; \t\t\t&lt;div class=&quot;bg&quot;&gt;&lt;\/div&gt; \t\t\t&lt;\/div&gt; \t\t\t&lt;div id=&quot;next&quot;&gt;\u0417\u0430\u043a\u043e\u043d\u0447\u0438\u0442\u044c \u0445\u043e\u0434&lt;\/div&gt;\t\t\t \t\t&lt;\/div&gt; \t\t&lt;div id=&quot;myhand&quot;&gt;&lt;\/div&gt; \t&lt;\/div&gt;\t <\/code><\/pre>\n<p>  \u0418\u043c\u0435\u044f \u0442\u0430\u043a\u043e\u0439 \u043a\u0430\u0440\u043a\u0430\u0441, \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0438\u0433\u0440\u044b.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u043f\u043e 4 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0445 \u043a\u0430\u0440\u0442\u044b. \u041a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c? \u0427\u0435\u0442\u044b\u0440\u0435\u0436\u0434\u044b \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u043c \u0441\u0435\u0440\u0432\u0435\u0440: \u00ab\u0434\u0430\u0439 \u043a\u0430\u0440\u0442\u0443\u00bb. \u042f \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u043b \u044d\u0442\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043a\u0430\u0440\u0442: get_cards(4);<\/p>\n<pre><code class=\"javascript\">\tfunction get_cards(num){ \t\tsocketInfo.method = &quot;get_cards&quot;; \t\tsocketInfo.args = num; \t\tsocket.send(JSON.stringify(socketInfo));\t\t\t \t}\t <\/code><\/pre>\n<p>  \u041c\u044b \u0443\u0436\u0435 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0443\u044e json \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430 \u0438\u043c\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u0437\u0430\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 get_cards:<\/p>\n<pre><code class=\"php\">  public function get_cards($myid, $num){     global $Cards;     for ($i=0; $i &lt; $num; $i++){        $card = $Cards-&gt;getRandom();       $args = array(           &quot;player_id&quot; =&gt; $myid,           &quot;card&quot; =&gt; $card         );       $arrOut = array('function' =&gt; 'player_get_card', 'args' =&gt; $args);       $arrOutJSON = json_encode($arrOut);           websock_send($myid, $arrOutJSON);          websock_send($this-&gt;opponents[$myid], $arrOutJSON);            }   }  <\/code><\/pre>\n<p>  \u0412 \u0446\u0438\u043a\u043b\u0435 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u0443\u044e \u043a\u0430\u0440\u0442\u0443 \u0438\u0437 \u043a\u043e\u043b\u043e\u0434\u044b, ($Cards-&gt;getRandom() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 json \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0440\u0442\u044b: \u0438\u043c\u044f, \u0430\u0442\u0430\u043a\u0430, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0436\u0438\u0437\u043d\u0435\u0439, \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430) \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u043e\u0438\u043c \u0438\u0433\u0440\u043e\u043a\u0430\u043c. \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e \u043e\u043f\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0438\u0434\u0435\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u0432\u0437\u044f\u043b\u0438 \u043a\u0430\u0440\u0442\u0443.<\/p>\n<p>  \u041a\u0442\u043e \u0438\u0437 \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u0432\u0437\u044f\u043b \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u043a\u0430\u0440\u0442\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435\u043c \u0430\u0439\u0434\u0438\u0448\u043d\u0438\u043a\u043e\u0432:<\/p>\n<pre><code class=\"javascript\">\t\tplayer_get_card: function(args){ \t\t\tif (!me(args.player_id)) { \t\t\t\t$('#opHand').append('&lt;div class=&quot;card&quot; id=&quot;'+args.card.id+'&quot; \/&gt;'); \t\t\t\treturn; \t\t\t}else{ \t\t\t\tvar card = card_construct(args.card); \t\t\t\t$('#myhand').append(card); \t\t\t\treturn; \t\t\t} \t\t} <\/code><\/pre>\n<p>  \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e #opHand \u2014 \u0440\u0443\u043a\u0430 \u043e\u043f\u043f\u043e\u043d\u0435\u043d\u0442\u0430, #myhand \u2014 \u043d\u0430\u0448\u0430 \u0440\u0443\u043a\u0430. \u0422\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u0440\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0434\u0435\u0440\u0436\u0438\u043c \u0432 \u0440\u0443\u043a\u0435.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u043a\u0430\u0440\u0442\u044b \u043d\u0430\u0431\u0440\u0430\u043b\u0438, \u043f\u043e\u0440\u0430 \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u043d\u0430 \u0441\u0442\u043e\u043b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u0443\u044e jquery \u0444\u0443\u043d\u043a\u0443\u0438\u044e:<\/p>\n<pre><code class=\"javascript\">\t$('#myhand').on('click',&quot;.card&quot;,function(){ \/\/ \u041a\u043b\u0438\u043a \u043f\u043e \u043a\u0430\u0440\u0442\u0435 \u0432 \u0440\u0443\u043a\u0435 \t\tif (!me(curplayer)) return; \t\tto_area($(this)); \t});\t <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043a\u043b\u0438\u043a\u0435 \u043d\u0430 \u043a\u0430\u0440\u0442\u0443 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0440\u0443\u043a\u0435 \u043a\u0430\u0440\u0442\u0430 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0430\u0440\u0435\u043d\u0443: to_area().<\/p>\n<pre><code class=\"javascript\">\tfunction to_area(card){ \/\/ \u0412\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u043d\u0438\u0435 \u043a\u0430\u0440\u0442\u044b \u043d\u0430 \u0430\u0440\u0435\u043d\u0443                 card.appendTo('#myUnits'); \t\tsocketInfo.method = 'opGetCard'; \t\tsocketInfo.args = card.attr(&quot;id&quot;); \t\tsocket.send(JSON.stringify(socketInfo));\t\t \t}\t <\/code><\/pre>\n<p>  \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u0438\u043a \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0441\u0435 \u044d\u0442\u043e \u0432\u0438\u0434\u0435\u0442\u044c.<\/p>\n<pre><code class=\"php\">  public function opGetCard($myid, $card_id){     global $Cards;         $card = $Cards-&gt;getById($card_id);     $arrOut = array('function' =&gt; 'opGetCard', 'args' =&gt; $card);     $arrOutJSON = json_encode($arrOut);         websock_send($this-&gt;opponents[$myid], $arrOutJSON);            } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0430\u043c\u043e\u0435 \u0432\u0430\u0436\u043d\u043e\u0435 \u2014 \u0430\u0442\u0430\u043a\u0443. \u041e\u0434\u043d\u043e\u0439 \u043a\u0430\u0440\u0442\u043e\u0439 \u043c\u044b \u0430\u0442\u0430\u043a\u0443\u0435\u043c \u043a\u0430\u0440\u0442\u0443 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u0438\u043a\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0430\u0434\u043e:  <\/p>\n<ul>\n<li>\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0443, \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u043c \u0445\u043e\u0434\u0438\u0442\u044c;<\/li>\n<li>\u0412\u044b\u0431\u0440\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0443-\u0436\u0435\u0440\u0442\u0432\u0443.<\/li>\n<\/ul>\n<p>  \u0414\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u043a\u0430\u0440\u0442\u044b-\u0430\u0433\u0440\u0435\u0441\u0441\u043e\u0440\u0430 \u0431\u0443\u0434\u0435\u043c \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u043e\u043c active:<\/p>\n<pre><code class=\"javascript\">\t$('#area').on('click',&quot;#myUnits .card&quot;,function(){ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ \u041a\u043b\u0438\u043a \u043f\u043e \u043a\u0430\u0440\u0442\u0435 \u043d\u0430 \u0430\u0440\u0435\u043d\u0435 \t\tif(!me(curplayer) || $(this).hasClass('nexus'))return; \t\tif ($(this).hasClass('active')) { \t\t\t$(this).removeClass('active'); \t\t}else{ \t\t\t$('#area #myUnits .card.active').removeClass('active'); \t\t\t$(this).addClass('active'); \t\t} \t});\t <\/code><\/pre>\n<p>  \u0410\u0433\u0440\u0435\u0441\u0441\u043e\u0440 \u0438\u043c\u0435\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 active, \u0442\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u0440\u0442\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0436\u0435\u0440\u0442\u0432\u0443.<\/p>\n<pre><code class=\"javascript\">\t$('#area').on('click',&quot;#opUnits .card&quot;,function(){ \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ \u041a\u043b\u0438\u043a \u043f\u043e \u043a\u0430\u0440\u0442\u0435 \u041e\u041f\u041f\u041e\u041d\u0415\u041d\u0422\u0410 \u043d\u0430 \u0430\u0440\u0435\u043d\u0435 \t\t$agressor = $('#area #myUnits .card.active'); \t\tif ($agressor.length &lt; 1) { \t\t\treturn false; \t\t}; \t\tattack_request($agressor,$(this));  \t});\t <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u043f\u0440\u0438 \u043a\u043b\u0438\u043a\u0435 \u043f\u043e \u043a\u0430\u0440\u0442\u0435-\u0436\u0435\u0440\u0442\u0432\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0441 \u0433\u043e\u0432\u043e\u0440\u044f\u0449\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c attack_request \u0434\u0432\u0430 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430: \u0430\u0433\u0440\u0435\u0441\u0441\u043e\u0440\u0430 \u0438 \u0436\u0435\u0440\u0442\u0432\u0443. \u0422\u043e \u0435\u0441\u0442\u044c \u043a\u0442\u043e \u0438 \u043a\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0430\u0442\u0430\u043a\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>  \u0421\u0430\u043c\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0431\u0435\u0440\u0442\u043a\u043e\u0439 \u0438 \u043b\u0438\u0448\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0430\u0442\u0430\u043a\u0430 <\/p>\n<pre><code class=\"javascript\">\tfunction attack_request(agressor, victim){ \/\/\/\/\/\/\/\/\/\/\/\/ \u0417\u0430\u043f\u0440\u043e\u0441 \u0430\u0442\u0430\u043a\u0438 \t\tsocketInfo.method = 'attack_request'; \t\tsocketInfo.args = agressor.attr(&quot;id&quot;)+'-'+victim.attr(&quot;id&quot;); \t\tsocket.send(JSON.stringify(socketInfo));\t\t \t}\t\t <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u044d\u0445\u043e-\u0440\u0435\u0436\u0438\u043c\u0435, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u043c\u043d\u0435 \u0438 \u043c\u043e\u0435\u043c\u0443 \u043e\u043f\u043f\u043e\u043d\u0435\u043d\u0442\u0443. \u0421\u0434\u0435\u043b\u0430\u043d\u043e \u044d\u0442\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u0432\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u0432 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u0434\u0432\u0443\u0445 \u0438\u0433\u0440\u043e\u043a\u043e\u0432 (\u0432\u0435\u0434\u044c \u0443 \u043d\u0430\u0441 \u0432 \u0438\u0433\u0440\u0435 \u0435\u0441\u0442\u044c \u0442\u0430\u0439\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 2 \u043c\u0438\u043d\u0443\u0442\u044b \u043d\u0430 \u0445\u043e\u0434).<\/p>\n<pre><code class=\"php\">  public function attack_request($myid, $args){     $arrOut = array('function' =&gt; 'attack', 'args' =&gt; $args);     $arrOutJSON = json_encode($arrOut);       websock_send($myid, $arrOutJSON);                    websock_send($this-&gt;opponents[$myid], $arrOutJSON);            } <\/code><\/pre>\n<p>  \u041a\u0430\u0440\u0442\u044b \u0443 \u043d\u0430\u0441 \u0447\u0435\u0442\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0430\u0439\u0434\u0438\u0448\u043d\u0438\u043a\u0430\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043c\u0435\u044f id \u0430\u0433\u0440\u0435\u0441\u0441\u043e\u0440\u0430 \u0438 \u0436\u0435\u0440\u0442\u0432\u044b \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u044d\u0442\u0443 \u0430\u0442\u0430\u043a\u0443 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c:<\/p>\n<pre><code class=\"javascript\">\t\tattack: function (args){  \t\t\tid = args.split('-'); \t\t\tvar alias = $('#'+id[0]).data('alias'); \t\t\tonBeforeAttack(alias,id); \t\t}          ..................  \tfunction onBeforeAttack(alias, id){ \/\/ \u0414\u043e \u0430\u0442\u0430\u043a\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \t\tif(Units[alias] == undefined){\t\t \t\t\tvar uFile = 'js\/units\/'+alias+'.unit.js'; \t\t\tvar xmlhttp = getXmlHttp(); \t\t\txmlhttp.open('GET', uFile, false); \t\t\txmlhttp.send(null); \t\t\tif(xmlhttp.status == 200){ \t\t\t\t$('body').append('&lt;script src=&quot;'+uFile+'&quot;&gt;&lt;\/scipt&gt;'); \t\t\t}else{ \t\t\t\tUnits[alias] = new defaultUnit(); \t\t\t} \t\t} \t\tUnits[alias].attack(id[0], id[1]); \t}  <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0434\u043e \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0430\u0442\u0430\u043a\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0435\u0441\u0442\u044c \u043b\u0438 \u0443 \u043d\u0430\u0441 \u043e\u0431\u044a\u0435\u043a\u0442, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0434\u0430\u043d\u043d\u043e\u043c \u0442\u0438\u043f\u0435 \u044e\u043d\u0438\u0442\u0430. \u042f \u043f\u043e\u043f\u044b\u0442\u0430\u043b\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043c\u043e\u043c\u0435\u043d\u0442 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0435\u043c\u043e\u0441\u0442\u0438. \u0412\u0435\u0434\u044c \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u0430\u043a melee \u044e\u043d\u0438\u0442\u044b, \u0442\u0430\u043a \u0438 range, \u0438 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b, \u0447\u0442\u043e\u0431\u044b \u0438\u0445 \u0430\u0442\u0430\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0430 \u043f\u043e-\u0440\u0430\u0437\u043d\u043e\u043c\u0443. \u041d\u043e \u044d\u0442\u043e \u043d\u0430 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u0443. \u041f\u043e\u043a\u0430 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f, \u0435\u0441\u043b\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0444\u0430\u0439\u043b \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u044e\u043d\u0438\u0442\u0430. <\/p>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a \u043e\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442:<\/p>\n<pre><code class=\"javascript\">\tfunction defaultUnit(){} \tdefaultUnit.prototype.attack =  function(agressor_id, victim_id){ \t\tvar victim = $('#'+victim_id); \t\tvar agressor = $('#'+agressor_id); \t\tvictim.css('z-index',5); \t\tagressor.css('z-index',10); \t\tvar $ypos = victim.offset().top - agressor.offset().top; \t\tvar $xpos = victim.offset().left - agressor.offset().left; \t\tagressor.animate({top:$ypos, left:$xpos}, 100).delay(200).animate({top:0, left:0}, 100);  \t\tif (isNaN(victim.data('attack'))) victim.data('attack',0); \t\tif (isNaN(agressor.data('attack'))) agressor.data('attack',0); \t\tvictim.data('health',victim.data('health')-agressor.data('attack')); \t\tagressor.data('health',agressor.data('health')-victim.data('attack')); \t\trefreshCards(); \t} <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438 \u0430\u0442\u0430\u043a\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c refreshCards(), \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0436\u0438\u0437\u043d\u0435\u0439 \u0443 \u0432\u0441\u0435\u0445 \u043a\u0430\u0440\u0442 \u043d\u0430 \u0430\u0440\u0435\u043d\u0435 (\u0438\u043c\u0435\u043d\u043d\u043e \u0432\u0441\u0435\u0445, \u0432\u0435\u0434\u044c \u0431\u044b\u0432\u0430\u044e\u0442 \u0438 \u043c\u0430\u0441\u0441\u043e\u0432\u044b\u0435 \u0437\u0430\u043a\u043b\u0438\u043d\u0430\u043d\u0438\u044f).<\/p>\n<pre><code class=\"javascript\">\trefreshCards = function(){ \/\/\/\/  \u041e\u0431\u0435\u0440\u0442\u043a\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u0440\u0442 \t\t$('#myUnits .card.active').removeClass('active'); \t\tvar rest = setTimeout(function(){ \t\t\t$('#area .card').each(function(){ \t\t\t\trefresh_card($(this)); \t\t\t\tif ($(this).data('health') &lt; 1) { \t\t\t\t\tdeath($(this));\t\t\t\t \t\t\t\t}; \t\t\t}); \t\t\tclearTimeout(rest); \t\t},1000); \t} \tfunction refresh_card(card){ \/\/\/\/\/\/\/\/\/\/ \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0440\u0442\u044b \t\t$('.health .inner',card).html(card.data('health')); \t\t$('.attack .inner',card).html(card.data('attack')); \t}\t <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0436\u0438\u0437\u043d\u0435\u0439 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043c\u0435\u043d\u044c\u0448\u0438\u043c \u0435\u0434\u0438\u043d\u0438\u0446\u044b, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u00ab\u0443\u043c\u0438\u0440\u0430\u043d\u0438\u0435\u00bb \u043a\u0430\u0440\u0442\u044b, \u0430 \u0435\u0441\u043b\u0438 \u0443\u043c\u0438\u0440\u0430\u0435\u0442 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u0437\u0434\u0430\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435, \u043f\u043e \u0441\u0443\u0442\u0438 \u0438\u0433\u0440\u044b, \u043d\u0430\u0434\u043e \u0437\u0430\u0449\u0438\u0449\u0430\u0442\u044c, \u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u0435\u0449\u0435 \u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0448\u0430 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0438\u0433\u0440\u043e\u043a\u043e\u0432:<\/p>\n<pre><code class=\"javascript\">\tfunction death(unit){ \/\/\/\/\/\/\/\/\/\/ \u0423\u043c\u0438\u0440\u0430\u043d\u0438\u0435 \t\tif (unit.hasClass('nexus')) { \t\t\tvar lose = localStorage.getItem(&quot;opponent&quot;); \t\t\tif (!me(curplayer)) lose = localStorage.getItem(&quot;myId&quot;); \t\t\tsocketInfo.method = 'lose'; \t\t\tsocketInfo.args = lose; \t\t\tsocket.send(JSON.stringify(socketInfo));\t\t \t\t}; \t\tunit.addClass('die'); \t\tvar dt = setTimeout(function(){ \t\t\tunit.remove(); \t\t\tclearTimeout(dt); \t\t},2000); \t}\t <\/code><\/pre>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u044f \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u043b\u0441\u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u044f \u0432 \u0438\u0433\u0440\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b, \u043e\u043f\u0438\u0441\u0430\u043b \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0434\u0435\u043c\u043e \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0434\u0432\u0430 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430\/\u0432\u043a\u043b\u0430\u0434\u043a\u0438 (\u043d\u0430 \u043c\u043e\u0431\u0438\u043b\u044c\u043d\u044b\u0445 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0443\u0445\u043b\u043e, \u043d\u0435 \u0441\u043e\u0432\u0435\u0442\u0443\u044e).<\/p>\n<p>  <a href=\"http:\/\/141.8.196.181\/new-cards\/\">141.8.196.181\/new-cards\/<\/a> \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/252897\/\"> http:\/\/habrahabr.ru\/post\/252897\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p> \t\t\t\u041e\u0434\u043d\u0430\u0436\u0434\u044b \u043c\u043d\u0435 \u043f\u043e\u043f\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u0433\u043b\u0430\u0437\u0430 \u043a\u0430\u0440\u0442\u043e\u0447\u043d\u0430\u044f \u0438\u0433\u0440\u0430 HeartStone \u043e\u0442 Blizzard. \u0418\u0433\u0440\u0430\u044f \u0432 \u043d\u0435\u0435 \u043f\u0440\u0438\u0448\u043b\u0430 \u043c\u044b\u0441\u043b\u044c, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 html5, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0438\u043c \u0431\u044b\u0442\u044c \u043a\u0440\u043e\u0441\u0441\u043f\u043b\u0430\u0442\u0444\u043e\u0440\u0441\u0435\u043d\u043d\u044b\u043c\u0438. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u043c\u043e\u0433\u0443\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u043b\u044e\u0434\u0438, \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435\u043c \u0441\u0430\u0439\u0442\u043e\u0432.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0447\u0442\u043e \u043c\u044b \u0438\u043c\u0435\u0435\u043c:  <\/p>\n<ul>\n<li>\u0412\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 LAMP (\u0431\u0435\u0437 phpDaemon);<\/li>\n<li>\u0416\u0435\u043b\u0430\u043d\u0438\u0435 \u043e\u0431\u043a\u0430\u0442\u0430\u0442\u044c WebSockets.<\/li>\n<\/ul>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u0441\u0435. \u042d\u0442\u043e\u0433\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442, \u0447\u0442\u043e\u0431\u044b \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0438\u0442\u044c \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043d\u043e\u0435.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-252956","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/252956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=252956"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/252956\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=252956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=252956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=252956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}