From 32573f3e8e187f030a5d25fc912af0d05cc8c869 Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 10 Feb 2021 22:39:13 +0200 Subject: [PATCH 01/28] =?UTF-8?q?=D0=9F=D0=BB=D0=B5=D0=B9=D1=81=D1=85?= =?UTF-8?q?=D0=BE=D0=BB=D0=B4=D0=B5=D1=80=D1=8B=20=D1=81=D0=BA=D0=BB=D0=BE?= =?UTF-8?q?=D0=BD=D0=BD=D0=BE=D1=81=D1=82=D0=B5=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i/align_0.gif | Bin 53 -> 0 bytes i/align_0.png | Bin 0 -> 139 bytes i/align_1.1.gif | Bin 79 -> 0 bytes i/align_1.2.gif | Bin 79 -> 0 bytes i/align_1.3.gif | Bin 79 -> 0 bytes i/align_1.4.gif | Bin 79 -> 0 bytes i/align_1.5.gif | Bin 79 -> 0 bytes i/align_1.6.gif | Bin 433 -> 0 bytes i/align_1.gif | Bin 93 -> 0 bytes i/align_1.png | Bin 0 -> 520 bytes i/align_2.1.gif | Bin 345 -> 0 bytes i/align_2.7.gif | Bin 139 -> 0 bytes i/align_2.8.gif | Bin 166 -> 0 bytes i/align_2.9.gif | Bin 616 -> 0 bytes i/align_2.gif | Bin 126 -> 0 bytes i/align_2.png | Bin 0 -> 518 bytes i/align_3.1.gif | Bin 333 -> 0 bytes i/align_3.gif | Bin 91 -> 0 bytes i/align_3.png | Bin 0 -> 526 bytes i/align_4.png | Bin 0 -> 519 bytes i/align_5.gif | Bin 977 -> 0 bytes i/align_5.png | Bin 0 -> 532 bytes i/align_6.gif | Bin 578 -> 0 bytes i/align_6.png | Bin 0 -> 507 bytes i/align_7.gif | Bin 969 -> 0 bytes i/align_7.png | Bin 0 -> 520 bytes 26 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 i/align_0.gif create mode 100644 i/align_0.png delete mode 100644 i/align_1.1.gif delete mode 100644 i/align_1.2.gif delete mode 100644 i/align_1.3.gif delete mode 100644 i/align_1.4.gif delete mode 100644 i/align_1.5.gif delete mode 100644 i/align_1.6.gif delete mode 100644 i/align_1.gif create mode 100644 i/align_1.png delete mode 100644 i/align_2.1.gif delete mode 100644 i/align_2.7.gif delete mode 100644 i/align_2.8.gif delete mode 100644 i/align_2.9.gif delete mode 100644 i/align_2.gif create mode 100644 i/align_2.png delete mode 100644 i/align_3.1.gif delete mode 100644 i/align_3.gif create mode 100644 i/align_3.png create mode 100644 i/align_4.png delete mode 100644 i/align_5.gif create mode 100644 i/align_5.png delete mode 100644 i/align_6.gif create mode 100644 i/align_6.png delete mode 100644 i/align_7.gif create mode 100644 i/align_7.png diff --git a/i/align_0.gif b/i/align_0.gif deleted file mode 100644 index b237e44625015758c6cfdfa0e2709a0a2fd0d193..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 53 zcmZ?wbhEHb+aC%MVb>o#VWncl4 d70eP649T;YWo@pm+Y407;OXk;vd$@?2>@2iA?yGE literal 0 HcmV?d00001 diff --git a/i/align_1.1.gif b/i/align_1.1.gif deleted file mode 100644 index 8dd8ee623589cf380df615c44fa3b6fdf859acc3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 79 zcmZ?wbhEHbG0Hq9Az&CWSfumIoHFwG`<4 eU72wv>eu;5nQgY-kqf&rHog2Bl-(@CU=0A!n;UEZ diff --git a/i/align_1.2.gif b/i/align_1.2.gif deleted file mode 100644 index 3c843de4c8c34eb6f83a823b5d3e2e51024ff12b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 79 zcmZ?wbhEHb1^@s6 diff --git a/i/align_1.3.gif b/i/align_1.3.gif deleted file mode 100644 index f1f80eb8f86c4bf725e2186f2fc66c5c3ce6ceba..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 79 zcmZ?wbhEHb aqJEu^l-XwM9l5Y8W7Es8LD|hB4AuaKX&Ivc diff --git a/i/align_1.4.gif b/i/align_1.4.gif deleted file mode 100644 index 4c5e234cb2c1371d30cc22faae18d4b6530c1b56..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 79 zcmZ?wbhEHbY_s)_T-cSd>E+j;>}C-LYXIO68$JL4 diff --git a/i/align_1.6.gif b/i/align_1.6.gif deleted file mode 100644 index c92732f509e15102ccf666ed8078164244849bdf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 433 zcmZ?wbhEHbv03d13bf!{AQS&hfK!N}jZq-!Vd;&#vR#ddZIk&X><)}@VN-C_&XDnJID8?% z*2}UzbW_7gw%hH#3q3NO)I?t7Sg$y2cHW8!ns+$#SM=@gls(exlr-ZPuN9M{0&9wim_b_iK?9fcmZQrqAI`FzC$f42?|H6S z9N5e@|8R19TvU$V;>}OG7n{x#Wtp{EV(GJe1vaLNi#VB28!%g0?)L0968YOD)w9}2 zl4s_m1#QZ6T)=_BiWV4lAND$BWg6`lEzz9SoWV3v^yCaxPR6VPo%0{svpPQ5o?V+b j!?Q{4ihxv4u=-;!DGjE_N}ekvxKBDBozkhM%wP=w6KR~V diff --git a/i/align_1.gif b/i/align_1.gif deleted file mode 100644 index c46243f20c928418a708babe42b63a98e17c30b6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 93 zcmZ?wbhEHb=s~?e{=I;Vz34Py+j<| diff --git a/i/align_1.png b/i/align_1.png new file mode 100644 index 0000000000000000000000000000000000000000..57961aea83a0035c56bab530325ff19934948939 GIT binary patch literal 520 zcmV+j0{8uiP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0i8)iK~y+Tg_FBV z15pr$ch|(bV1y7A#S77(Vyp#Q3&Fz5!qx{dweMhIYbADC1O!10!BUAA1RH~xh(r`` zS-=0dtGmg910VCxo^$4$nM^F#bt9SFuxx?$edNBT4{Ubu?T|!|z$iKeouIYQev>(1 z@l4K6;-_F52EZxh+Q)!yZXWB+<8@7x2MB z55X!6Ys3@iZfzjey5uX|5bqLiqp#3)zZTWELcMvYp?{6oQ%1kQ3345Jz>1Mg=@T#u z889~o&3l1NC5=NC4&hl(_Y(|48~kUjkODQ^j(Ih<5U8Pcpk`wcu}!SKX1^I2YDvQ; zlpAUe^*}~k#cjcy&gumkgbG~31N3o&e$puWgevRTc+G>W9>{8N3P(_e4`?(U)&&JP zhDZ3DM6!0_7RahOm`C@6-=i_#}|n8 z;yN__7j&C$?L`hlN(u1lkw&?~TBy9H1Od}QhXm3t2hELPv#f8@i9HhcwG!L_0000< KMNUMnLSTaCqTDI~ literal 0 HcmV?d00001 diff --git a/i/align_2.1.gif b/i/align_2.1.gif deleted file mode 100644 index aa9c991cec3300945eb2b085f9546988fc8cb570..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 345 zcmZ?wbhEHbz|Ao}y?+n+yw{{8s$>D~YT|DHTL^Yqq^|3BaS zeYyYH!|RVOtUrHb!?TAsUSHq7pfTw0t!0a<-4-?kFKP^Vf2{xUnKi#2?%O;m`_|4$ zZ_g}#aP@d$fX@8J_+>qLXEskivUc*@`xmb4UHbFW>u+Dbyu5bg$Ghi0p5Oic?c2An zUx5w)JA@oU@h1x-1A`6_0s+WR3~XfwxU)TUxYUJu(_dcnP;)tVT=`Xn-JHbK$()sb z%KjRgHyTV|ajEiTfC`VA=%SAWYiwB$Nx68j+AuN6F>0zPICHbhF*D1tbGu3l$Z2cI u2}rxd=*VTt>7+PI1;i)n2um%}2@Va{St+tePD0SvS;T2hwzIe+gEauXNs)H| diff --git a/i/align_2.7.gif b/i/align_2.7.gif deleted file mode 100644 index 79778612ec36e99bafa34eea4e103e055a826f73..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 139 zcmZ?wbhEHb$N+-Z3~PXl>s+D)!d742|`*du~!kJp8h&a3x`yj*g{mt9Hm!Niy@3%PlZRaZ63yxVfp z^JUvDH?2A6oB|_#oVXXO?DTH5auj2o@w-;WED!STH@Dy5L3lwAf|2O4CCb=HxG&aZ~5ciNMcWY$k`~89iAN z=C1YuyGg1SJl$6B`I5Eg^R+YA8yAUpML!OCC1tjj* zE(_BIS5#q02s=W2p1J%=DZ5hVmE|3e9~M4tmC@N@nX$6vmRi-^O?RdoRoNoo)g>dk z^6*Z^@GTP0J~z7h3qLdIx{#CrwTu Y(-{<=LUZ~W0}Oqf*l>lX5G*{c0fuhQCIA2c diff --git a/i/align_2.gif b/i/align_2.gif deleted file mode 100644 index a677fd5d8a47a35fbc79750af6a52b619ca19f3e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 126 zcmZ?wbhEHbT*^KETyg@l9-95|r(lZBCift^7IqynUt zf!VoY*BxgTi9_=Qmbn;T5je;oz{DVOSe#{c;=ChL``)Xtv+DAi``z9# b!*QlHF%5pNETnbi<~uT8eNnZalffDQPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0h>ugK~y+Tg_F-N z15p%*=Z?~b_!E`1iBw`kYiVsu>}(`93syNBl^E-3qoVoYhTQ3NLu55dr0Uzy4cjhB(!nL9?J;fjxL}t;WctiYvufZd< zAU3ywffPkk_&Jz?G4N?{kH3IZ@@M#Gp4mcQKcS^y7S>@CR$vhpU^#rY0ct(~*6a$j zY;*zE=)6RnLnrkDvGS7da7%nZyoWBKThTCvV3lE&pn;B!I8;_Qp@Q6kG_XHo45T4X z*Kx34c1E6NL}R&&$P`t`do$hOX3FJ z7P<|rg$4ac9n~lq*wq5@1L8O=jh<5tgPbe=O+&|0*K}16B85V z<>jTMrS0wPB_$=iy}eRWQ$<8XJ32bb%F6r${Ijz_&_GY$!^0ywCc3`9UQ|R>T1F-( zC%d4aKwDeO$k5Qy(NS4Nsj#5H&d$z2-ykzH!_D2jwyur=2`K(#VPs&iWzYeMf&9e4 zmUUoWz=_Aa{Z8H&Tiz_lX?yg*!HOezi^H-G#hjQ!5sN&Y@jC4dbUC6e%4pM@E~a~% z^=ZR9CavwKL^)E;Et%BIY=q@mZ4I<-3MSaF@H^>nGm5yH%J6A9aR~@nyXx~;7BppwmZL`hQUs57IPkGDSOWmZ&K=?a diff --git a/i/align_3.png b/i/align_3.png new file mode 100644 index 0000000000000000000000000000000000000000..61f092596d03fd2dfb332f4061fbd3fa7545f08e GIT binary patch literal 526 zcmV+p0`dKcP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0i#JoK~y+Tg_FHX z13?hScjHH*;0H!XKqA0EK7()ILs%v|@^+Mf5T(!7L;waF6!kl=vC?rL&`GfiWmCVI92!IT!)MWUYD&C&c&AWxhQt zfRRAVoBk)WGn%F(@6#fy`iFQ;bEb>K&|NFF^9A=N9%A9O3WdSJ7Iu?w|idk6XlzR+EX7wCx+wJX_w{LaRF1NMCcHNKda Qx&QzG07*qoM6N<$g1r^u;s5{u literal 0 HcmV?d00001 diff --git a/i/align_4.png b/i/align_4.png new file mode 100644 index 0000000000000000000000000000000000000000..9027989a566bb0c96b4ee726ac305126c3380773 GIT binary patch literal 519 zcmV+i0{H!jP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0h~!hK~y+Tg_FBV z13?sqXE$o1-~}TjAQ5b0Vwqa7vbM4npTRfqAuN3a!CD)IXcbaPFojr%nm`oATa23V z`-k0ivj+U(%Q_s`( zfWZ`g8Ma8Q6RS9_3B<}vpKwQfNW6z%bB)yireKr9szDb&5^*H_9yD;bA*&&uZXRTz zMAvz6E61fT5J+3ffucNkzJ5Tbt^*r`|1<)+of+_S!jew1@0?)IAwfP;kne+4-aQ!h zvH&}9o7nTf8A!w(%r2Bvt1r;%y5|O5!F#y+5PiTkxdyaUt22<^pbkginm|&n7*3!H z&+z+@=$OHj>8f|IhQA2uV9!1L8#pFDAg*Jz=-^W(p(`wqtYGz&bBt-59sCOwVlRoi zSXUTt;1m>0;OeTTiFM8T+w literal 0 HcmV?d00001 diff --git a/i/align_5.gif b/i/align_5.gif deleted file mode 100644 index dcb9782a472f4015470f1405f2ec2344cba09ef6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 977 zcmZ?wbhEHbk znd6d~fBk3p`J3VIf1Y1|1fyd)e*V?__n+n8AA$e><^TUz{q+pC4Yb4kdC18zwI{sxzB83D&PN|`oDJ?-&<<R{Zhi0);N(pQc#+U*?%(D-@{D zA88`AHCyA;M9T&jAs;PXPYqrhMefH9DB)nl4+5|iu42TjbZ zs^KT@L?%CDP~hfMTCv06#Q7NpY%K3K2BvaOw9nk4aUqyFu+gb$mxNRCG2W^2%z`pr h7utMftlT67R2)3c$>=i$D7ainIL6D#!py{A4FHI%8nOTY diff --git a/i/align_5.png b/i/align_5.png new file mode 100644 index 0000000000000000000000000000000000000000..8ba4a55668276b7c0871ac0a35f050d29eb3e63d GIT binary patch literal 532 zcmV+v0_**WP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0jWtuK~y+TZIjDN z!%z^0&q-CV;-%h;2!eH?g6?&#sQ3Va>nbE~Aovh2y7DmuK@eT&%7qIR?)Go6z;(-Y;o?*G_ILjpg6wPJZ6EsuyCU88bt3tlgN7giHLV{brg z5kggNprL`H5$psEL&{svxv$uB*do7&ePhilwB+F{31hGb^DqVD{@NtW!GiBMfhW^} zw5`-AWZ8L!xEsG#en2dF@k;PSyiL4{zl&cChLM6S!#aX*{IYCG`?6ILF7cM26F7pS zHMGG1yS9UQbETvM(}i@}3jL49$1FksxwDtAhOjX&lSi>t#lx-c!5JWgM9e*xIW>E+yUH6ZEz0?un+5S z0ePsF6ko$8?7#<9+(bv$@$6&QY5ZCI4AgrwaP$|xT;&boHR4mOtW|vrj+TF+gXAD~ z2-2*{F(2?x@Q<-~#PU6Oh0zT}ra-!Bge0*HL)w3b0=ZvosQ3nDnJEUt^go`cl==hK WW)+;iu<~XA0000)W3_yz%MYp8p^3JU+AL^oB{_|NT9(cJk>hvrliH_3i7|O*5+=U0A)hJ5zc2S6SwDF}Tk_98KfitbvUyVW`(yo!s@-nwob>DAzB8Mr|Gl+r zMp;B*fX@8J_?}#wn_KISENOXre#4Y}`-fMLF$@l%_>%?f5FHQ+iW3I*`3)|9zTN?f zA_3mMelD(_49;E(GG5LMp00sRj6VL#;{HC2Oo0Y&?jEX={3;&qZp^k0_SQiH+(GQD zELIkFW?K4AqHH=w8rr7n#+HsIx;A>|nubCg(tNx;JiL6;971yP62eMcTuQPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0gy>VK~y+Tg_Fxl z!%z^0li1?DT3ZA+6%j>UiU^`BL0$KKd?9fs;zoBa+__Nd1w|3Twz#O^-PXkKpQI(N z5eL5hGiT1sX>ulR5Cl$=xftS+4{#-k8-F!mbDFg*?ihXsZ4f`ARd@v-S{84h6EhUe zqf0OeL!bsKK7m8>cf_CgX7L8vyv~Lqx(FkX0=5KS=nWi@-$E~K`0BITxf1{Y002ovPDHLkV1m4!(b@n2 literal 0 HcmV?d00001 diff --git a/i/align_7.gif b/i/align_7.gif deleted file mode 100644 index cdf15d2960ca5ebcbebc567c3bbd9c18acb0b710..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 969 zcmW+#OGuSb5T5Fan$^Yby`jamM6pGt$pl(L5|yH2cT-A9LW>3iqfDhB4HYsl0|NsO z7SX~WdT4={3 zpn-*DOq1hr&sZzgvbE%BQ5j>6Si{zkQ-P)!D`JJMkQ0SjHkQRQTPA44swHDdEU_i9 zLN&l38Y&?RJrDyM(7?hnIYX|-6JyvIa{fSzO2h~oA!ipV&}1>ph6(N=3bTg95F3I$ z*~pb3WI5UK$N(b$A6=m0UW0Zr~iZW?XWc!Y}~NcaOSDkk@F zxLmz^yQX(S7qfR2H|quMQunfRt6m)L2%bZS%J;HGfW zq0+Lb6;Vx%&Ba9}si_&ueMzyQ-D^|Jre|h{?T2vjg=@W|(XnwG>Yp9HGaVlc`u%J2 z@^($X=skVx;H7hw>jQCpo%II_a<_!z_io$xvpH+9zb_EutF1oOez~n@d$?^~FfAn| zF(Ki0clXxxbbR{Be|*bel+vMr+&@7vw@8<2ChsQ=oc%sn_jL2uk56hB7axqLovi4u zTBX%9&m-m8C*Dqf8=HuH%0C}_Z?xufW>=_bA!mMSGSW5NuvoOSqwrPQ{_9H*>wZjR zw1i6M#$N|2_l1WW-qGFmfy}9uO}}&g?&&CbfAh@bNY-p;N!QiToB2n9f06wDD@ilQ qdFPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0i8)iK~y+Tg_65U z13?sqcUKZGC`t%uqYzvh?X(qq2n`l#w6GF<4Bx@ZC$O})a4lnFp=_*zBmol)UP#ce ze*ZYLZeqX#-_Cz_=A1cmX1pXx#uCS|4*@!m9-ViXiLBLXwIB?`8Ds%H&*iC!V=jc21z%^qQ_GwlGAL!KZtund?x5#5y052e$4{Dgo zPj}9mDiGKtEQ8iAfv?ilJat{l9-0NGdt{jYIfdL?wJR}SxRsU zjgd1C^+1N-W;lZl#i|0`ryhy!`3d@N_c8VfE#@AesaW?8^unre1$EGsjhccR5Wx*} z;rAtyQQhAn>mGUst#0S+nZM92i107)uNmL)ho7=dvc}{#qpqsRKOM7!R@vHF4@ec8 zz-$6zESg}!98&kJ_n{klfhKgBQ#GmmNsuuG{#+Hi5jbX{=Y0co5=;Z~UrTiW0000< KMNUMnLSTY{3E0;F literal 0 HcmV?d00001 From d78b2eda3490b7f8c8d1bcbe1c4ce730dc1850fe Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 10 Mar 2021 23:03:59 +0200 Subject: [PATCH 02/28] =?UTF-8?q?=D0=94=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD?= =?UTF-8?q?=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=BE=D0=B2?= =?UTF-8?q?.=20=D0=A0=D0=B0=D0=B7=D0=BD=D0=B5=D1=81=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B8=D0=B3=D1=80=D0=BE=D0=B2=D1=8B=D0=B5=20?= =?UTF-8?q?=D0=B8=20=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D0=BD=D1=8B=D0=B5?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/admin.php | 9 +- admin/test_stats.php | 8 +- bank.php | 3 +- cave.php | 14 +- clan_create.php | 7 +- classes/Battles/Bank.php | 2 +- classes/Battles/Database/DBPDO.php | 13 +- classes/Battles/GameConfigs.php | 21 +++ classes/Battles/GameLogs.php | 6 +- classes/Battles/User.php | 4 +- classes/Cave/lose.php | 6 +- classes/Cave/win.php | 2 +- classes/Database/db.php | 14 +- classes/battle_new.class.php | 4 +- config.php | 233 +++++++------------------- cronjobs/cron_bots_battle.php | 6 +- enter_cave.php | 8 +- functions.php | 12 +- library.php | 8 +- magic/attack.php | 4 +- magic/attack_blood.php | 4 +- magic/attack_t.php | 4 +- magic/attackbot.php | 4 +- magic/attackk.php | 4 +- magic/attackk_close.php | 4 +- magic/attackk_open.php | 4 +- magic/cpattack.php | 4 +- magic/eattack.php | 4 +- magic/ebattack.php | 4 +- magic/usability_klan/attack.php | 4 +- magic/usability_klan/attack_blood.php | 4 +- magic/usability_user/attack.php | 4 +- magic/usability_user/attack_blood.php | 4 +- user_anketa.php | 20 +-- 34 files changed, 181 insertions(+), 275 deletions(-) create mode 100644 classes/Battles/GameConfigs.php diff --git a/admin/admin.php b/admin/admin.php index de52d9b..e99b2fa 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -9,23 +9,24 @@ require_once '../functions.php'; use Battles\Bank; use Battles\Database\DBPDO; +use Battles\GameConfigs; use Battles\Moderation; use Battles\Nick; use Battles\Template; use Battles\User; -$user = $user ?? new User($_SESSION['uid']); if (!$user->getAdmin()) { header("HTTP/1.0 404 Not Found"); exit; } - if (isset($_GET['sleep'])) { Moderation::muteChat($user->getId(), strtotime('15min')); } if (isset($_POST['ldnick']) && isset($_POST['ldtext'])) { - Moderation::addToUserLog($_POST['ldnick'], $_POST['ldtext'], $user->getId()); + $u = new User($_POST['ldnick']); + Moderation::addToUserLog($u->getId(), $_POST['ldtext'], $user->getId()); + unset($u); } if (isset($_POST['syschatmsg'])) { @@ -72,7 +73,7 @@ UNREGCLANLIST; { $bank = new Bank($id); $this->db->execute('DELETE FROM clans WHERE status = 0 AND owner_id = ?', $id); - $bank::setBankMoney($bank->getMoney() + Config::$clan_register_cost, $id); + $bank::setBankMoney($bank->getMoney() + GameConfigs::CLAN_REGISTER_COST, $id); } }; $unregisteredClans->db = new DBPDO(); diff --git a/admin/test_stats.php b/admin/test_stats.php index 60cbd9d..e5e83f6 100644 --- a/admin/test_stats.php +++ b/admin/test_stats.php @@ -38,7 +38,7 @@ } if(!$kompl_har) $kompl_har=0; $explim=0; - foreach(array_keys(Config::$exptable) as $k) + foreach(array_keys(EXPTABLE) as $k) { if($k>=$ku['exp']) { @@ -47,14 +47,14 @@ } } $sum_stat=15; - foreach(array_keys(Config::$exptable) as $k) + foreach(array_keys(EXPTABLE) as $k) { if($k==$explim) break; else { - $sum_stat+=Config::$exptable[$k][0]; - $sum_stat+=Config::$exptable[$k][2]; + $sum_stat+=EXPTABLE[$k][0]; + $sum_stat+=EXPTABLE[$k][2]; } } $res=mysql_fetch_array( diff --git a/bank.php b/bank.php index b68583a..a672e5f 100644 --- a/bank.php +++ b/bank.php @@ -1,6 +1,7 @@ - Комиссия: % от переводимой суммы, но не менее 1 кр. + Комиссия: % от переводимой суммы, но не менее 1 кр. diff --git a/cave.php b/cave.php index f9c5986..bfba725 100644 --- a/cave.php +++ b/cave.php @@ -5,7 +5,7 @@ use Battles\Template; session_start(); require_once 'functions.php'; //require_once 'cave/cave_bots.php'; - +$userslots = ['sergi', 'kulon', 'perchi', 'weap', 'bron', 'r1', 'r2', 'r3', 'helm', 'shit', 'boots', 'rybax', 'plaw', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm10']; function cancarry($m, $u) { global $user; @@ -204,7 +204,7 @@ function gotoroom($r, $redir = 1) function redirectbyroom($r) { - if (in_array($r, Config::$canalenters)) { + if (in_array($r, CANAL_ENTERS)) { header("location: enter_cave.php"); exit; } @@ -286,7 +286,7 @@ function takeusage($x, $y) function makedeath() { global $user, $floor, $loses, $x, $y, $dir; - $cavedata = Config::$cavedata ?? []; + $cavedata = CAVE_DATA ?? []; if (!isset($cavedata[$user->getRoom()]['x' . $floor])) { $floor = 1; loadmap(); @@ -430,11 +430,11 @@ function loadmap() function getslot($i, $user1 = 0) { - global $user; + global $user, $userslots; if (!$user1) { $user1 = $user; } - foreach (Config::$userslots as $k => $v) { + foreach ($userslots as $k => $v) { if ($user1[$v] == $i) { return $v; } @@ -482,7 +482,7 @@ if (@$_GET['kill'] && $user['id'] == $user['caveleader'] && $_GET['kill'] != $us mysql_query("UPDATE `users` SET `room` = (`room`-1), `caveleader` = 0 WHERE `id` = '$v[user]' LIMIT 1"); $r = mysql_query("SELECT `id`, `dressed` FROM `inventory` WHERE `owner` = '$v[user]' AND `dressed` = 1 AND `foronetrip` = 1"); if (mysql_num_rows($r) > 0) { - $usr = mysql_fetch_array(mysql_query("SELECT " . implode(",", Config::$userslots) . " FROM `users` WHERE `id` = '$v[user]'")); + $usr = mysql_fetch_array(mysql_query("SELECT " . implode(",", $userslots) . " FROM `users` WHERE `id` = '$v[user]'")); } while ($rec = mysql_fetch_assoc($r)) { $slot = getslot($rec['id'], $usr); @@ -737,7 +737,7 @@ if ($ambushes[$y * 2][$x * 2 - 2] && $map[$y * 2][$x * 2 - 1] == 0) { } if ($ax && $ay && $user['hp'] > 0) { - $cavedata = Config::$cavedata ?? []; + $cavedata = CAVE_DATA ?? []; if (!($cavedata[$user->getRoom()]['x' . $floor] == $x && $cavedata[$user->getRoom()]['y' . $floor] == $y)) { if ($ax < $x) { $dir1 = 0; diff --git a/clan_create.php b/clan_create.php index 4ef2d6e..2b927c7 100644 --- a/clan_create.php +++ b/clan_create.php @@ -1,6 +1,7 @@ query('SELECT 1 FROM users_effects WHERE type = 20 AND owner_id = ?i', $user->getId()); $name_check = db::c()->query('SELECT owner_id FROM clans WHERE full_name = "?s" OR short_name = "?s"', $clanFullName, $clanShortName); $errorMessage = []; - if (Config::$clan_register_lock) { + if (GameConfigs::CLAN_REGISTER_LOCK) { $errorMessage[10] = 'Регистрация кланов закрыта!
'; } if ($user->getAlign()) { @@ -27,7 +28,7 @@ if ($clanFullName && $clanShortName && $clanInfo && !$userClan) { if ($user->getClan()) { $errorMessage[1] = 'Вы уже состоите в клане!.
'; } - if (Config::$clan_register_cost >= $userBank->getMoney()) { + if (GameConfigs::CLAN_REGISTER_COST >= $userBank->getMoney()) { $errorMessage[2] = 'Не хватает денег на регистрацию клана.
'; } if (!$eff) { @@ -39,7 +40,7 @@ if ($clanFullName && $clanShortName && $clanInfo && !$userClan) { if (!$errorMessage || $user->getAdmin()) { try { db::c()->query('INSERT INTO clans (owner_id, full_name, short_name, info) VALUES (?i,"?s","?s","?s")', $user->getId(), $clanFullName, $clanShortName, $clanInfo); - $userBank->setMoney($userBank->getMoney() - Config::$clan_register_cost); + $userBank->setMoney($userBank->getMoney() - GameConfigs::CLAN_REGISTER_COST); Battles\Bank::setBankMoney($userBank->getMoney(), $user->getId(), 'clanRegister'); // Заглушка для отображения данных по только что зарегистрированному клану, когда запрос в базу в начале файла ещё не проходит. $userClan = new stdClass(); diff --git a/classes/Battles/Bank.php b/classes/Battles/Bank.php index aed703a..c01504f 100644 --- a/classes/Battles/Bank.php +++ b/classes/Battles/Bank.php @@ -52,7 +52,7 @@ class Bank */ private function bankCommission(int $amount): int { - $bankCommission = round($amount * Config::$bank_commission); + $bankCommission = round($amount * GameConfigs::BANK_COMISSION); if ($bankCommission < 1) { return 1; } else { diff --git a/classes/Battles/Database/DBPDO.php b/classes/Battles/Database/DBPDO.php index 9ec2236..d9f148e 100644 --- a/classes/Battles/Database/DBPDO.php +++ b/classes/Battles/Database/DBPDO.php @@ -2,11 +2,7 @@ namespace Battles\Database; -const DATABASE_HOST = '192.168.20.5'; -const DATABASE_NAME = 'battles'; -const DATABASE_USER = 'battles'; -const DATABASE_PASS = 'bottle-neck-horse'; -const DATABASE_PORT = '32101'; +use Battles\GameConfigs; use PDO, PDOException; class DBPDO { @@ -37,9 +33,9 @@ class DBPDO { if (!$this->pdo) { - $dsn = 'mysql:dbname=' . DATABASE_NAME . ';host=' . DATABASE_HOST . ';port=' . DATABASE_PORT . ';charset=utf8;'; - $user = DATABASE_USER; - $password = DATABASE_PASS; + $dsn = 'mysql:dbname=' . GameConfigs::DATABASE_NAME . ';host=' . GameConfigs::DATABASE_HOST . ';port=' . GameConfigs::DATABASE_PORT . ';charset=utf8;'; + $user = GameConfigs::DATABASE_USER; + $password = GameConfigs::DATABASE_PASS; try { $this->pdo = new PDO($dsn, $user, $password, array(PDO::ATTR_PERSISTENT => true)); @@ -144,5 +140,4 @@ class DBPDO { return $this->pdo->lastInsertId(); } - } \ No newline at end of file diff --git a/classes/Battles/GameConfigs.php b/classes/Battles/GameConfigs.php new file mode 100644 index 0000000..2f8e38d --- /dev/null +++ b/classes/Battles/GameConfigs.php @@ -0,0 +1,21 @@ +prepare("INSERT INTO bank_logs (sender_id, receiver_id, amount, type, text) VALUES (?, ?, ?, ?, ?)"); $row->bindParam(1, $senderId, SQLITE3_INTEGER); $row->bindParam(2, $receiverId, SQLITE3_INTEGER); @@ -45,7 +45,7 @@ class GameLogs if (empty($type)) { $type = "system"; } - $db = new SQLite3(Config::$db_sqlite); + $db = new SQLite3(GameConfigs::DB_SQLITE); $row = $db->prepare("INSERT INTO users_logs (user_id, author_id, type, text) VALUES (?,?,?,?)"); $row->bindParam(1, $userId, SQLITE3_INTEGER); $row->bindParam(2, $authorId, SQLITE3_INTEGER); @@ -57,7 +57,7 @@ class GameLogs public static function getUserLogs($userId = null, $type = null): SQLite3Result { - $db = new SQLite3(Config::$db_sqlite); + $db = new SQLite3(GameConfigs::DB_SQLITE); if ($userId && $type) { $query = "SELECT * FROM users_logs WHERE user_id = ? AND type = ?"; diff --git a/classes/Battles/User.php b/classes/Battles/User.php index afdd29a..bb5a208 100644 --- a/classes/Battles/User.php +++ b/classes/Battles/User.php @@ -55,7 +55,9 @@ class User protected $maxMana = 5; protected static $db; - public function __construct(int $user) + public const INFO_CHAR_LIMIT = 1500; + + public function __construct($user) { self::$db = DBPDO::INIT(); $user_query = self::$db->fetch('SELECT * FROM users WHERE id = ? OR login = ?', [$user, $user]); diff --git a/classes/Cave/lose.php b/classes/Cave/lose.php index b7afe84..1ae80ea 100644 --- a/classes/Cave/lose.php +++ b/classes/Cave/lose.php @@ -1,6 +1,6 @@ getRoom(), Config::$caverooms)) { - $cavedata = Config::$cavedata ?? []; +if (in_array($user->getRoom(), CAVE_ROOMS)) { + $cavedata = CAVE_DATA ?? []; $floor = mysql_fetch_row(mysql_query("SELECT `floor` FROM `caveparties` WHERE `user` = '$user[id]' LIMIT 1")); if (!isset($cavedata[$user->getRoom()]['x' . $floor])) { $floor = 1; @@ -11,7 +11,7 @@ $lomka1 = $lomka; foreach ($lomka1 as $k => $v) { if ($v < _BOTSEPARATOR_) { - if (in_array($user->getRoom(), Config::$caverooms)) { + if (in_array($user->getRoom(), CAVE_ROOMS)) { mysql_query("UPDATE `caveparties` SET `floor` = $floor, `x` = '" . $cavedata[$user->getRoom()]['x' . $floor] . "', `y` = '" . $cavedata[$user->getRoom()]['y' . $floor] . "', `dir` = '" . $cavedata[$user->getRoom()]['dir' . $floor] . "', `loses` = (`loses`+1) WHERE `user` = '$v' LIMIT 1"); } if ($user['laba'] > 0) { diff --git a/classes/Cave/win.php b/classes/Cave/win.php index 8211ad3..6bacaef 100644 --- a/classes/Cave/win.php +++ b/classes/Cave/win.php @@ -21,7 +21,7 @@ function cavesys($text) } } -if (in_array($user->getRoom(), Config::$caverooms)) { +if (in_array($user->getRoom(), CAVE_ROOMS)) { include("CaveItems.php"); mysql_query('LOCK TABLES `cavebots` WRITE, `caveitems` WRITE, `shop` WRITE, `caveparties` WRITE'); $location = mysql_fetch_array(mysql_query("SELECT `x`, `y`, `dir`, `floor` FROM `caveparties` WHERE `user` = '$user[id]' LIMIT 1")); diff --git a/classes/Database/db.php b/classes/Database/db.php index 5104942..8a7d4bc 100644 --- a/classes/Database/db.php +++ b/classes/Database/db.php @@ -1,4 +1,7 @@ setDatabaseName("battles") + ->setDatabaseName(GameConfigs::DATABASE_NAME) // Выбор кодировки - ->setCharset("utf8"); + ->setCharset(GameConfigs::DATABASE_CHARSET); } return self::$_instance; } diff --git a/classes/battle_new.class.php b/classes/battle_new.class.php index 55b453f..bec76a5 100644 --- a/classes/battle_new.class.php +++ b/classes/battle_new.class.php @@ -1700,7 +1700,7 @@ class fbattle } - if (in_array($user->getRoom(), Config::$caverooms)) { + if (in_array($user->getRoom(), CAVE_ROOMS)) { $location = mysql_fetch_array(mysql_query("SELECT `x`, `y`, `dir` FROM `caveparties` WHERE `user` = '" . $this->user['id'] . "' LIMIT 1")); if ($location['dir'] == 0) { @@ -1805,7 +1805,7 @@ class fbattle function addAction($time, $vars, $vls, $uid) { - $ins = mysql_query('INSERT INTO `actions` (`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`) VALUES ("' . $uid . '", "' . $time . '", "capitalcity", "0", "' . mysql_real_escape_string($vars) . '", "' . mysql_real_escape_string($_SERVER['HTTP_X_REAL_IP']) . '", "' . mysql_real_escape_string($vls) . '")'); + $ins = mysql_query('INSERT INTO `actions` (`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`) VALUES ("' . $uid . '", "' . $time . '", "capitalcity", "0", "' . mysql_real_escape_string($vars) . '", "' . $_SERVER['REMOTE_ADDR'] . '", "' . mysql_real_escape_string($vls) . '")'); if ($ins) { return true; } else { diff --git a/config.php b/config.php index 231ee33..1474720 100644 --- a/config.php +++ b/config.php @@ -1,5 +1,6 @@ * Project name: Battles-Game @@ -35,184 +36,66 @@ spl_autoload_register(function ($className) { } }); -trait Config -{ - public static $db_sqlite = '/volume2/web/battles/databases/logs.sqlite'; - // Для нападалок. Сперва комнаты в которых нельзя напасть, потом персонажи на которых нельзя напасть. - public static $unkilable = [ - 'rooms' => [620, 621, 1051, 1052], - 'users' => [10962, 10964, 10965], - ]; - // Неизвестная херня. - public static $canalenters = [620]; - public static $caverooms = [621]; - public static $userslots = ['sergi', 'kulon', 'perchi', 'weap', 'bron', 'r1', 'r2', 'r3', 'helm', 'shit', 'boots', 'rybax', 'plaw', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm10']; - // Что-то связанное с магией. - public static $elem_align = [ - "a" => ["a" => "1", "e" => "0", "f" => "0.5", "w" => "0.5"], - "e" => ["a" => "0", "e" => "1", "f" => "0.5", "w" => "0.5"], - "f" => ["a" => "0.5", "e" => "0.5", "f" => "1", "w" => "0"], - "w" => ["a" => "0.5", "e" => "0.5", "f" => "0", "w" => "1"], - ]; - public static $elem_bonus = [ - "a" => ["a" => "1", "e" => "0.75", "f" => "1.25", "w" => "1"], - "e" => ["a" => "1.25", "e" => "1", "f" => "1", "w" => "0.75"], - "f" => ["a" => "0.75", "e" => "1", "f" => "1", "w" => "1.25"], - "w" => ["a" => "1", "e" => "1.25", "f" => "0.75", "w" => "1"], - ]; - //Для кланов - public static $clan_register_cost = 10000; //стоимость - public static $clan_register_lock = 1; //запрет на регистрацию - //Банк - public static $bank_commission = 0.05; //5% - // Старая таблица опыта - public static $exptable = [ - 0 => [0, 0, 0, 0, 0, 20], - 20 => [1, 0, 0, 0, 0, 45], - 45 => [1, 0, 0, 2, 0, 75], - 75 => [1, 0, 0, 4, 0, 110], - 110 => [3, 1, 1, 8, 1, 160], # Это первый уровень +// Для нападалок. Сперва комнаты в которых нельзя напасть, потом персонажи на которых нельзя напасть. +const UNKILABLE = [ + 'rooms' => [620, 621, 1051, 1052], + 'users' => [10962, 10964, 10965], +]; - 160 => [1, 0, 0, 2, 0, 215], - 215 => [1, 0, 0, 2, 0, 280], - 280 => [1, 0, 0, 4, 0, 350], - 350 => [1, 0, 0, 8, 0, 410], - 410 => [3, 1, 1, 16, 1, 530], # Это второй уровень +// Кажется, для пещер. +const CANAL_ENTERS = [620]; +const CAVE_ROOMS = [621]; +const CAVE_DATA = [ + 621 => [ + 'x1' => 6, + 'y1' => 11, + 'dir1' => 1, + 'x2' => 10, + 'y2' => 8, + 'dir2' => 1, + 'x3' => 20, + 'y3' => 4, + 'dir3' => 1, + 'x4' => 10, + 'y4' => 10, + 'dir4' => 1, + 'delay' => 360, + 'name1' => 'Проклятый Рудник', + 'name2' => 'Проклятого Рудника' + ], +]; - 530 => [1, 0, 0, 8, 0, 670], - 670 => [1, 0, 0, 12, 0, 830], - 830 => [1, 0, 0, 16, 0, 950], - 950 => [1, 0, 0, 24, 0, 1100], - 1100 => [1, 0, 0, 32, 0, 1300], - 1300 => [3, 1, 1, 40, 1, 1450], # Это третий уровень +const EXPTABLE = [ + 0 => [0, 0, 0, 0, 0, 20], + 20 => [1, 0, 0, 0, 0, 45], + 45 => [1, 0, 0, 2, 0, 75], + 75 => [1, 0, 0, 4, 0, 110], + 110 => [3, 1, 1, 8, 1, 160], # Это первый уровень - 1450 => [1, 0, 0, 10, 0, 1650], - 1650 => [1, 0, 0, 20, 0, 1850], - 1850 => [1, 0, 0, 30, 0, 2050], - 2050 => [1, 0, 0, 40, 0, 2200], - 2200 => [1, 0, 0, 50, 0, 2500], - 2500 => [5, 1, 1, 70, 1, 2900], # Это четвёртый уровень + 160 => [1, 0, 0, 2, 0, 215], + 215 => [1, 0, 0, 2, 0, 280], + 280 => [1, 0, 0, 4, 0, 350], + 350 => [1, 0, 0, 8, 0, 410], + 410 => [3, 1, 1, 16, 1, 530], # Это второй уровень - 2900 => [1, 0, 0, 10, 0, 3350], - 3350 => [1, 0, 0, 20, 0, 3800], - 3800 => [1, 0, 0, 30, 0, 4200], - 4200 => [1, 0, 0, 40, 0, 4600], - 4600 => [1, 0, 0, 50, 0, 5000], - 5000 => [3, 1, 1, 80, 1, 6000], # Это пятый уровень + 530 => [1, 0, 0, 8, 0, 670], + 670 => [1, 0, 0, 12, 0, 830], + 830 => [1, 0, 0, 16, 0, 950], + 950 => [1, 0, 0, 24, 0, 1100], + 1100 => [1, 0, 0, 32, 0, 1300], + 1300 => [3, 1, 1, 40, 1, 1450], # Это третий уровень - 6000 => [1, 0, 0, 15, 0, 7000], - 7000 => [1, 0, 0, 30, 0, 8000], - 8000 => [1, 0, 0, 40, 0, 9000], - 9000 => [1, 0, 0, 50, 0, 10000], - 10000 => [1, 0, 0, 40, 0, 11000], - 11000 => [1, 0, 0, 50, 0, 12000], - 12000 => [1, 0, 0, 60, 0, 12500], - 12500 => [3, 1, 1, 90, 1, 14000], # Это шестой уровень + 1450 => [1, 0, 0, 10, 0, 1650], + 1650 => [1, 0, 0, 20, 0, 1850], + 1850 => [1, 0, 0, 30, 0, 2050], + 2050 => [1, 0, 0, 40, 0, 2200], + 2200 => [1, 0, 0, 50, 0, 2500], + 2500 => [5, 1, 1, 70, 1, 2900], # Это четвёртый уровень - 14000 => [1, 0, 0, 20, 0, 15500], - 15500 => [1, 0, 0, 30, 0, 17000], - 17000 => [1, 0, 0, 50, 0, 19000], - 19000 => [1, 0, 0, 55, 0, 21000], - 21000 => [1, 0, 0, 50, 0, 23000], - 23000 => [1, 0, 0, 55, 0, 27000], - 27000 => [1, 0, 0, 50, 0, 30000], - 30000 => [5, 1, 1, 100, 1, 60000], # Это седьмой уровень - - 60000 => [1, 0, 0, 100, 0, 75000], - 75000 => [1, 0, 0, 100, 0, 150000], - 150000 => [1, 0, 0, 150, 0, 175000], - 175000 => [1, 0, 0, 50, 0, 200000], - 200000 => [1, 0, 0, 100, 0, 225000], - 225000 => [1, 0, 0, 50, 0, 250000], - 250000 => [1, 0, 0, 100, 0, 260000], - 260000 => [1, 0, 0, 50, 0, 280000], - 280000 => [1, 0, 0, 100, 0, 300000], - 300000 => [5, 1, 1, 700, 1, 1500000], # Это восьмой уровень - - 1500000 => [1, 0, 0, 500, 0, 1750000], - 1750000 => [1, 0, 0, 200, 0, 2000000], - 2000000 => [1, 0, 0, 300, 0, 2175000], - 2175000 => [1, 0, 0, 100, 0, 2300000], - 2300000 => [1, 0, 0, 100, 0, 2400000], - 2400000 => [1, 0, 0, 100, 0, 2500000], - 2500000 => [1, 0, 0, 200, 0, 2600000], - 2600000 => [1, 0, 0, 100, 0, 2800000], - 2800000 => [1, 0, 0, 200, 0, 3000000], - 3000000 => [5, 1, 2, 1000, 1, 6000000], # Это девятый уровень - - 6000000 => [1, 0, 0, 200, 0, 6500000], - 6500000 => [1, 0, 0, 250, 0, 7500000], - 7500000 => [1, 0, 0, 200, 0, 8500000], - 8500000 => [1, 0, 0, 250, 0, 9000000], - 9000000 => [1, 0, 0, 400, 0, 9250000], - 9250000 => [1, 0, 0, 250, 0, 9500000], - 9500000 => [1, 0, 0, 400, 0, 9750000], - 9750000 => [1, 0, 0, 350, 0, 9900000], - 9900000 => [1, 0, 0, 500, 0, 10000000], - 10000000 => [9, 1, 3, 2000, 1, 13000000], # Это десятый уровень - - 13000000 => [2, 0, 0, 200, 0, 14000000], - 14000000 => [2, 0, 0, 200, 0, 15000000], - 15000000 => [2, 0, 0, 200, 0, 16000000], - 16000000 => [2, 0, 0, 200, 0, 17000000], - 17000000 => [2, 0, 0, 200, 0, 17500000], - 17500000 => [2, 0, 0, 200, 0, 18000000], - 18000000 => [2, 0, 0, 200, 0, 19000000], - 19000000 => [2, 0, 0, 200, 0, 19500000], - 19500000 => [2, 0, 0, 200, 0, 20000000], - 20000000 => [2, 0, 0, 250, 0, 30000000], - 30000000 => [2, 0, 0, 200, 0, 32000000], - 32000000 => [2, 0, 0, 250, 0, 34000000], - 34000000 => [2, 0, 0, 200, 0, 35000000], - 35000000 => [2, 0, 0, 250, 0, 36000000], - 36000000 => [2, 0, 0, 200, 0, 38000000], - 38000000 => [2, 0, 0, 250, 0, 40000000], - 40000000 => [2, 0, 0, 200, 0, 42000000], - 42000000 => [2, 0, 0, 250, 0, 44000000], - 44000000 => [2, 0, 0, 350, 0, 47000000], - 47000000 => [2, 0, 0, 300, 0, 50000000], - 50000000 => [2, 0, 0, 350, 0, 52000000], - 52000000 => [10, 1, 3, 3000, 1, 58000000], # Это одиннадцатый уровень - - 58000000 => [1, 0, 0, 350, 0, 65000000], - 65000000 => [1, 0, 0, 300, 0, 72000000], - 72000000 => [1, 0, 0, 350, 0, 77000000], - 77000000 => [1, 0, 0, 350, 0, 82000000], - 82000000 => [1, 0, 0, 300, 0, 87000000], - 87000000 => [1, 0, 0, 350, 0, 92000000], - 92000000 => [1, 0, 0, 350, 0, 100000000], - 100000000 => [1, 0, 0, 350, 0, 120000000], - 120000000 => [2, 0, 0, 400, 0, 140000000], - 140000000 => [2, 0, 0, 400, 0, 160000000], - 160000000 => [2, 0, 0, 600, 0, 180000000], - 180000000 => [2, 0, 0, 400, 0, 210000000], - 210000000 => [2, 0, 0, 400, 0, 240000000], - 240000000 => [10, 2, 4, 5000, 1, 260000000], # Это двеннадцатый уровень - - 260000000 => [2, 0, 0, 400, 0, 320000000], - 320000000 => [2, 0, 0, 400, 0, 400000000], - 400000000 => [3, 0, 0, 600, 0, 455000000], - 455000000 => [2, 0, 0, 150, 0, 510000000], - 510000000 => [2, 0, 0, 100, 0, 600000000], - 600000000 => [2, 0, 0, 300, 0, 750000000], - 750000000 => [5, 0, 0, 700, 0, 770000000], - 770000000 => [1, 0, 0, 400, 0, 815000000], - 815000000 => [1, 0, 0, 200, 0, 860000000], - 860000000 => [1, 0, 0, 600, 0, 1000000000], - 1000000000 => [1, 0, 0, 300, 0, 1100000000], - 1100000000 => [1, 0, 0, 450, 0, 1250000000], - 1250000000 => [1, 0, 0, 450, 0, 1500000000], - 1500000000 => [10, 1, 5, 8000, 1, 9999999999], # Это тринадцатый уровень - ]; - public static $cavedata = [621 => ['x1' => 6, 'y1' => 11, 'dir1' => 1, 'x2' => 10, 'y2' => 8, 'dir2' => 1, 'x3' => 20, 'y3' => 4, 'dir3' => 1, 'x4' => 10, 'y4' => 10, 'dir4' => 1, 'delay' => 360, 'name1' => 'Проклятый Рудник', 'name2' => 'Проклятого Рудника']]; - - //DB - protected static $db = [ - 'host' => '192.168.20.5', - 'name' => 'battles', - 'user' => 'battles', - 'password' => 'bottle-neck-horse', - 'port' => 32101, - 'charset' => 'utf8', - ]; -} \ No newline at end of file + 2900 => [1, 0, 0, 10, 0, 3350], + 3350 => [1, 0, 0, 20, 0, 3800], + 3800 => [1, 0, 0, 30, 0, 4200], + 4200 => [1, 0, 0, 40, 0, 4600], + 4600 => [1, 0, 0, 50, 0, 5000], + 5000 => [3, 1, 1, 80, 1, 6000], # Это пятый уровень +]; \ No newline at end of file diff --git a/cronjobs/cron_bots_battle.php b/cronjobs/cron_bots_battle.php index d1d4986..ad49089 100644 --- a/cronjobs/cron_bots_battle.php +++ b/cronjobs/cron_bots_battle.php @@ -421,7 +421,7 @@ class fbattle addActions(time(), 'win_fiz', 0, $this->user['id']); } - if (in_array($user->getRoom(), Config::$caverooms)) { + if (in_array($user->getRoom(), CAVE_ROOMS)) { $location = mysql_fetch_array(mysql_query("SELECT `x`, `y`, `dir` FROM `caveparties` WHERE `user` = '" . $this->user['id'] . "' LIMIT 1")); if ($location['dir'] == 0) { $y = $location['y'] * 2; @@ -451,7 +451,7 @@ class fbattle $winers .= implode(", ", $this->t2); $lomka = $this->t1; } else { - if (in_array($user->getRoom(), Config::$caverooms)) { + if (in_array($user->getRoom(), CAVE_ROOMS)) { $location = mysql_fetch_array(mysql_query("SELECT `x`, `y`, `dir` FROM `caveparties` WHERE `user` = '" . $this->user['id'] . "' LIMIT 1")); if ($location['dir'] == 0) { $y = $location['y'] * 2; @@ -1063,7 +1063,7 @@ class fbattle if ($uid == NULL) { $uid = $this->user['id']; } - $ins = mysql_query('INSERT INTO `actions` (`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`) VALUES ("' . $uid . '", "' . $time . '", "capitalcity", "0", "' . mysql_real_escape_string($vars) . '", "' . mysql_real_escape_string($_SERVER['HTTP_X_REAL_IP']) . '", "' . mysql_real_escape_string($vls) . '")'); + $ins = mysql_query('INSERT INTO `actions` (`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`) VALUES ("' . $uid . '", "' . $time . '", "capitalcity", "0", "' . mysql_real_escape_string($vars) . '", "' . $_SERVER['REMOTE_ADDR'] . '", "' . mysql_real_escape_string($vls) . '")'); return $ins; } diff --git a/enter_cave.php b/enter_cave.php index 92d97c9..5206583 100644 --- a/enter_cave.php +++ b/enter_cave.php @@ -65,7 +65,7 @@ if ($_GET['ext'] == 1) { } -if (in_array($user->getRoom(), Config::$canalenters)) { +if (in_array($user->getRoom(), CANAL_ENTERS)) { $podzemroom = $user->getRoom() + 1; $cavedata = [620 => ['x1' => 3, 'y1' => 2, 'dir1' => 2]]; $podzemdata = [621 => ['name1' => 'Проклятый Рудник', 'name2' => 'Проклятого Рудника']]; @@ -308,7 +308,7 @@ if (in_array($user->getRoom(), Config::$canalenters)) { } $den = mysql_query("SELECT `id` FROM `vxodd` WHERE `glav_id` = '" . $_GET['naw_id'] . "'"); - if (mysql_num_rows($den) >= (in_array($user->getRoom() + 1, Config::$caverooms) ? 5 : 4)) { + if (mysql_num_rows($den) >= (in_array($user->getRoom() + 1, CAVE_ROOMS) ? 5 : 4)) { echo ""; exit(); } @@ -356,7 +356,7 @@ if (in_array($user->getRoom(), Config::$canalenters)) { } if ($_GET['start']) { - if (in_array($user->getRoom() + 1, Config::$caverooms)) { + if (in_array($user->getRoom() + 1, CAVE_ROOMS)) { $nc = 1; $locs = []; } @@ -391,7 +391,7 @@ if (in_array($user->getRoom(), Config::$canalenters)) { mysql_query('INSERT INTO `visit_podzem` (`login`, `time`, `room`) VALUES ("' . $n_login . '", "' . $vremya . '", \'' . $podzemroom . '\')'); $vrem = 30 * 60 + time(); - $cavedata = Config::$cavedata ?? []; + $cavedata = CAVE_DATA ?? []; mysql_query("INSERT INTO `caveparties` SET `user` = '$esth[id]', `leader` = '$user[id]', `login` = '$esth[login]', `shadow` = '0.png', `x` = '" . $cavedata[$user->getRoom() + 1]['x1'] . "', `y` = '" . $cavedata[$user->getRoom() + 1]['y1'] . "', `dir` = '" . $cavedata[$user->getRoom() + 1]['dir1'] . "', `floor` = 1"); mysql_query("UPDATE `users`, `online` SET " . ($nc ? "`users`.`caveleader` = '$user[id]', " : "") . " `users`.`room` = '" . ($user->getRoom() + 1) . "', `online`.`room` = '" . ($user->getRoom() + 1) . "' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '" . $esth['id'] . "'"); } diff --git a/functions.php b/functions.php index 3c9a77d..674020e 100644 --- a/functions.php +++ b/functions.php @@ -16,11 +16,11 @@ if (empty($_SESSION['uid'])) { } else { $user = new User($_SESSION['uid']); } - if ($user->getId() && $user->getBlock()) { exit('user blocked!'); } + /* * Проверки на соответствие скрипта и комнаты, которые были натыканы по всем файлам. */ @@ -209,13 +209,13 @@ function level_up($uid) { $us = db::c()->query('SELECT `id`, `login`, `level`, `money`, `exp`, `nextup`, `stats`, `master`, `ip`, `in_tower` FROM `users` WHERE `id` =?i', $uid)->fetch_assoc(); if (isset($us['id']) && $us['exp'] >= $us['nextup'] && !$us['in_tower']) { - if (Config::$exptable[$us['nextup']][4] == 1) { + if (EXPTABLE[$us['nextup']][4] == 1) { addch("Персонаж {$us['login']} перешел на " . ($us['level'] + 1) . " уровень."); - addchp('Внимание! Вы перешли на новый уровень. За это Вы получаете: ' . Config::$exptable[$us['nextup']][3] . ' кр.', '{[]}' . $us['login'] . '{[]}'); + addchp('Внимание! Вы перешли на новый уровень. За это Вы получаете: ' . EXPTABLE[$us['nextup']][3] . ' кр.', '{[]}' . $us['login'] . '{[]}'); } - $us['nextup'] = Config::$exptable[$us['nextup']][5]; - $us['stats'] += Config::$exptable[$us['nextup']][0]; - $us['master'] += Config::$exptable[$us['nextup']][1]; + $us['nextup'] = EXPTABLE[$us['nextup']][5]; + $us['stats'] += EXPTABLE[$us['nextup']][0]; + $us['master'] += EXPTABLE[$us['nextup']][1]; db::c()->query('UPDATE `users` SET `nextup` = ?i, `stats` = ?i, `master` = ?i, `level` = ?i WHERE `id` = ?i', $us['nextup'], $us['stats'], $us['master'], $us['level'], $us['id']); } diff --git a/library.php b/library.php index 307c681..ae2a08f 100644 --- a/library.php +++ b/library.php @@ -234,7 +234,13 @@ if ($_GET['lib_room'] == 'hall' || !$_GET['lib_room']) { break; } echo "
Эффективность магии:"; - foreach (Config::$elem_align as $k => $ea) { + $elem_align = [ + 'a' => ['a' => '1', 'e' => '0', 'f' => '0.5', 'w' => '0.5'], + 'e' => ['a' => '0', 'e' => '1', 'f' => '0.5', 'w' => '0.5'], + 'f' => ['a' => '0.5', 'e' => '0.5', 'f' => '1', 'w' => '0'], + 'w' => ['a' => '0.5', 'e' => '0.5', 'f' => '0', 'w' => '1'], + ]; + foreach ($elem_align as $k => $ea) { switch ($k) { case 'a': echo "
Воздух"; diff --git a/magic/attack.php b/magic/attack.php index 9dc94f6..048279f 100644 --- a/magic/attack.php +++ b/magic/attack.php @@ -24,9 +24,9 @@ if ($user['battle'] > 0) { echo "Бой закрыт для вмешательства!"; } elseif (!$us['online']) { echo "Персонаж не в игре!"; -} elseif(in_array($us['room'], Config::$unkilable['rooms'])) { +} elseif(in_array($us['room'], UNKILABLE['rooms'])) { echo "В данной комнате запрещены нападения ..."; -} elseif(in_array($us['id'], Config::$unkilable['users'])) { +} elseif(in_array($us['id'], UNKILABLE['users'])) { echo "Персонаж под защитой от нападений ..."; } elseif(isset($effect['id'])) { echo "Персонаж под защитой от нападений ..."; diff --git a/magic/attack_blood.php b/magic/attack_blood.php index 8742215..8f64472 100644 --- a/magic/attack_blood.php +++ b/magic/attack_blood.php @@ -16,9 +16,9 @@ if($vip['bloodattack'] <= 0) { echo "Запрещено входить в хаотический бой!"; } elseif($us['battle'] > 0 && $us_b['open'] == 0) { echo "Бой закрыт для вмешательства!"; -} elseif(in_array($us['room'], Config::$unkilable['rooms'])) { +} elseif(in_array($us['room'], UNKILABLE['rooms'])) { echo "В данной комнате запрещены нападения ..."; -} elseif(in_array($us['id'], Config::$unkilable['users'])) { +} elseif(in_array($us['id'], UNKILABLE['users'])) { echo "Персонаж под защитой от нападений ..."; } elseif(isset($effect['id'])) { echo "Персонаж под защитой от нападений ..."; diff --git a/magic/attack_t.php b/magic/attack_t.php index 52b0377..ca684b0 100644 --- a/magic/attack_t.php +++ b/magic/attack_t.php @@ -21,9 +21,9 @@ elseif (!$us['online']) { echo "Запрещено входить в хаотический бой!"; } elseif ($us['battle']>0 && $us_b['open']==0) { echo "Бой закрыт для вмешательства!"; -} elseif(in_array($us['room'], Config::$unkilable['rooms'])) { +} elseif(in_array($us['room'], UNKILABLE['rooms'])) { echo "В данной комнате запрещены нападения ..."; -} elseif(in_array($us['id'], Config::$unkilable['users'])) { +} elseif(in_array($us['id'], UNKILABLE['users'])) { echo "Персонаж под защитой от нападений ..."; } elseif(isset($effect['id'])) { echo "Персонаж под защитой от нападений ..."; diff --git a/magic/attackbot.php b/magic/attackbot.php index 2273213..2d85843 100644 --- a/magic/attackbot.php +++ b/magic/attackbot.php @@ -17,9 +17,9 @@ if ($user['battle'] > 0) { echo "Бой закрыт для вмешательства!"; } elseif ($user['zayavka'] > 0) { echo "Вы ожидаете поединка..."; -} elseif(in_array($jert['room'], Config::$unkilable['rooms'])) { +} elseif(in_array($jert['room'], UNKILABLE['rooms'])) { echo "В данной комнате запрещены нападения ..."; -} elseif(in_array($jert['id'], Config::$unkilable['users'])) { +} elseif(in_array($jert['id'], UNKILABLE['users'])) { echo "Персонаж под защитой от нападений ..."; } elseif(isset($effect['id'])) { echo "Персонаж под защитой от нападений ..."; diff --git a/magic/attackk.php b/magic/attackk.php index a4ac153..d75171d 100644 --- a/magic/attackk.php +++ b/magic/attackk.php @@ -24,9 +24,9 @@ if ($user['battle'] > 0) { echo "Бой закрыт для вмешательства!"; } elseif ($user['zayavka'] > 0) { echo "Вы ожидаете поединка..."; -} elseif (in_array($us['room'], Config::$unkilable['rooms'])) { +} elseif (in_array($us['room'], UNKILABLE['rooms'])) { echo "В данной комнате запрещены нападения ..."; -} elseif (in_array($us['id'], Config::$unkilable['users'])) { +} elseif (in_array($us['id'], UNKILABLE['users'])) { echo "Персонаж под защитой от нападений ..."; } elseif (isset($effect['id'])) { echo "Персонаж под защитой от нападений ..."; diff --git a/magic/attackk_close.php b/magic/attackk_close.php index 4211c78..32c66cd 100644 --- a/magic/attackk_close.php +++ b/magic/attackk_close.php @@ -31,9 +31,9 @@ elseif (!$us['online']) { echo "Не атакуйте Администратора!"; } elseif ($user['zayavka'] > 0) { echo "Вы ожидаете поединка..."; -} elseif(in_array($us['room'], Config::$unkilable['rooms'])) { +} elseif(in_array($us['room'], UNKILABLE['rooms'])) { echo "В данной комнате запрещены нападения ..."; -} elseif(in_array($us['id'], Config::$unkilable['users'])) { +} elseif(in_array($us['id'], UNKILABLE['users'])) { echo "Персонаж под защитой от нападений ..."; } elseif(isset($effect['id'])) { echo "Персонаж под защитой от нападений ..."; diff --git a/magic/attackk_open.php b/magic/attackk_open.php index 4fee63f..829370a 100644 --- a/magic/attackk_open.php +++ b/magic/attackk_open.php @@ -29,9 +29,9 @@ if ($user['battle'] > 0) { echo "Персонаж защищен от кулачного нападения!"; } elseif ($us['align']==2.99) { echo "Не атакуйте Администратора!"; -} elseif(in_array($us['room'], Config::$unkilable['rooms'])) { +} elseif(in_array($us['room'], UNKILABLE['rooms'])) { echo "В данной комнате запрещены нападения ..."; -} elseif(in_array($us['id'], Config::$unkilable['users'])) { +} elseif(in_array($us['id'], UNKILABLE['users'])) { echo "Персонаж под защитой от нападений ..."; } elseif(isset($effect['id'])) { echo "Персонаж под защитой от нападений ..."; diff --git a/magic/cpattack.php b/magic/cpattack.php index 9059c4d..60d2f9f 100644 --- a/magic/cpattack.php +++ b/magic/cpattack.php @@ -31,9 +31,9 @@ elseif (!$us['online']) { echo "Бой закрыт для вмешательства!"; } elseif ($us['align']==2.99) { echo "Не атакуйте Администратора!"; -} elseif(in_array($us['room'], Config::$unkilable['rooms'])) { +} elseif(in_array($us['room'], UNKILABLE['rooms'])) { echo "В данной комнате запрещены нападения ..."; -} elseif(in_array($us['id'], Config::$unkilable['users'])) { +} elseif(in_array($us['id'], UNKILABLE['users'])) { echo "Персонаж под защитой от нападений ..."; } elseif(isset($effect['id'])) { echo "Персонаж под защитой от нападений ..."; diff --git a/magic/eattack.php b/magic/eattack.php index e055bba..7f4d144 100644 --- a/magic/eattack.php +++ b/magic/eattack.php @@ -36,9 +36,9 @@ elseif ($user['zayavka'] > 0) { echo "Вы ожидаете поединка..."; } elseif ($owntravma['id'] && !$us['battle']) { echo "Персонаж тяжело травмирован..."; -} elseif(in_array($us['room'], Config::$unkilable['rooms'])) { +} elseif(in_array($us['room'], UNKILABLE['rooms'])) { echo "В данной комнате запрещены нападения ..."; -} elseif(in_array($us['id'], Config::$unkilable['users'])) { +} elseif(in_array($us['id'], UNKILABLE['users'])) { echo "Персонаж под защитой от нападений ..."; } elseif(isset($effect['id'])) { echo "Персонаж под защитой от нападений ..."; diff --git a/magic/ebattack.php b/magic/ebattack.php index 0ff0873..91fbc96 100644 --- a/magic/ebattack.php +++ b/magic/ebattack.php @@ -36,9 +36,9 @@ elseif ($user['zayavka'] > 0) { echo "Вы ожидаете поединка..."; } elseif ($owntravma['id'] && !$us['battle']) { echo "Персонаж тяжело травмирован..."; -} elseif(in_array($us['room'], Config::$unkilable['rooms'])) { +} elseif(in_array($us['room'], UNKILABLE['rooms'])) { echo "В данной комнате запрещены нападения ..."; -} elseif(in_array($us['id'], Config::$unkilable['users'])) { +} elseif(in_array($us['id'], UNKILABLE['users'])) { echo "Персонаж под защитой от нападений ..."; } elseif(isset($effect['id'])) { echo "Персонаж под защитой от нападений ..."; diff --git a/magic/usability_klan/attack.php b/magic/usability_klan/attack.php index ae1ed9e..55cba51 100644 --- a/magic/usability_klan/attack.php +++ b/magic/usability_klan/attack.php @@ -16,9 +16,9 @@ if($vip['attack'] <= 0) { echo "Запрещено входить в хаотический бой!"; } elseif($us['battle'] > 0 && $us_b['open'] == 0) { echo "Бой закрыт для вмешательства!"; -} elseif(in_array($us['room'], Config::$unkilable['rooms'])) { +} elseif(in_array($us['room'], UNKILABLE['rooms'])) { echo "В данной комнате запрещены нападения ..."; -} elseif(in_array($us['id'], Config::$unkilable['users'])) { +} elseif(in_array($us['id'], UNKILABLE['users'])) { echo "Персонаж под защитой от нападений ..."; } elseif(isset($effect['id'])) { echo "Персонаж под защитой от нападений ..."; diff --git a/magic/usability_klan/attack_blood.php b/magic/usability_klan/attack_blood.php index 4e2b1a6..b143fef 100644 --- a/magic/usability_klan/attack_blood.php +++ b/magic/usability_klan/attack_blood.php @@ -16,9 +16,9 @@ if($vip['bloodattack'] <= 0) { echo "Запрещено входить в хаотический бой!"; } elseif($us['battle'] > 0 && $us_b['open'] == 0) { echo "Бой закрыт для вмешательства!"; -} elseif(in_array($us['room'], Config::$unkilable['rooms'])) { +} elseif(in_array($us['room'], UNKILABLE['rooms'])) { echo "В данной комнате запрещены нападения ..."; -} elseif(in_array($us['id'], Config::$unkilable['users'])) { +} elseif(in_array($us['id'], UNKILABLE['users'])) { echo "Персонаж под защитой от нападений ..."; } elseif(isset($effect['id'])) { echo "Персонаж под защитой от нападений ..."; diff --git a/magic/usability_user/attack.php b/magic/usability_user/attack.php index f2f17f5..058eeeb 100644 --- a/magic/usability_user/attack.php +++ b/magic/usability_user/attack.php @@ -14,9 +14,9 @@ if($vip['attack'] <= 0) { echo "Не в бою..."; } elseif($us_b['type'] == 3 || $us_b['type'] == 5) { echo "Запрещено входить в хаотический бой!"; -} elseif(in_array($us['room'], Config::$unkilable['rooms'])) { +} elseif(in_array($us['room'], UNKILABLE['rooms'])) { echo "В данной комнате запрещены нападения ..."; -} elseif(in_array($us['id'], Config::$unkilable['users'])) { +} elseif(in_array($us['id'], UNKILABLE['users'])) { echo "Персонаж под защитой от нападений ..."; } elseif(isset($effect['id'])) { echo "Персонаж под защитой от нападений ..."; diff --git a/magic/usability_user/attack_blood.php b/magic/usability_user/attack_blood.php index ff73615..e2c248c 100644 --- a/magic/usability_user/attack_blood.php +++ b/magic/usability_user/attack_blood.php @@ -16,9 +16,9 @@ if($vip['bloodattack'] <= 0) { echo "Запрещено входить в хаотический бой!"; } elseif($us['battle'] > 0 && $us_b['open'] == 0) { echo "Бой закрыт для вмешательства!"; -} elseif(in_array($us['room'], Config::$unkilable['rooms'])) { +} elseif(in_array($us['room'], UNKILABLE['rooms'])) { echo "В данной комнате запрещены нападения ..."; -} elseif(in_array($us['id'], Config::$unkilable['users'])) { +} elseif(in_array($us['id'], UNKILABLE['users'])) { echo "Персонаж под защитой от нападений ..."; } elseif(isset($effect['id'])) { echo "Персонаж под защитой от нападений ..."; diff --git a/user_anketa.php b/user_anketa.php index 282c1ad..cf9b035 100644 --- a/user_anketa.php +++ b/user_anketa.php @@ -1,10 +1,10 @@ ", $hobbie); $hobbie = str_replace("\\r", "", $hobbie); $hobbie = str_replace("<br />", "
", $hobbie); -if ($name || $color || $hobbie) { - switch ($color) { - case 1: - $color = 'blue'; - break; - case 2: - $color = 'green'; - break; - default: - $color = 'black'; - break; - } - - if (strlen($hobbie) > INFO_CHAR_LIMIT) { - err('Максимальная длинна поля Хобби: ' . INFO_CHAR_LIMIT . ' символов!'); +if ($name || $hobbie) { + if (strlen($hobbie) > User::INFO_CHAR_LIMIT) { + err('Максимальная длинна поля Хобби: ' . User::INFO_CHAR_LIMIT . ' символов!'); } else { $values = ['realname' => $name, 'color' => $color, 'info' => $hobbie]; db::c()->query('UPDATE users SET ?As WHERE id = ?i', $values, $user->getId()); From fec38574354a2949c80720fba84c0fe2d5ac3fe0 Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 10 Mar 2021 23:05:38 +0200 Subject: [PATCH 03/28] Code clean --- js/ch.js | 18 ++-- js/sl2.js | 262 +++++++++++++++++++++++++++++++----------------------- 2 files changed, 159 insertions(+), 121 deletions(-) diff --git a/js/ch.js b/js/ch.js index 01675b9..897eb02 100644 --- a/js/ch.js +++ b/js/ch.js @@ -1,7 +1,8 @@ -//------------------------------------------------------------- +"use strict" // Функция для определения координат указателя мыши function defPosition(event) { - var x = y = 0; + let x = 0; + let y = 0; if (document.attachEvent != null) { // Internet Explorer & Opera x = window.event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); y = window.event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); @@ -16,7 +17,6 @@ function defPosition(event) { return {x:x, y:y}; } -var flagpop=0; var clip = new ZeroClipboard.Client(); clip.setHandCursor( true ); clip.setCSSEffects(true); @@ -30,12 +30,14 @@ var flagpop=0; * @return {boolean} */ function OpenMenu(evt,level){ + let flagpop = 0 + let login + let menu = document.getElementById("oMenu") + let html; evt = evt || window.event; evt.cancelBubble = true; // Показываем собственное контекстное меню - var menu = document.getElementById("oMenu"); - var html = ""; - login=(evt.target || evt.srcElement).innerHTML; + login = (evt.target || evt.srcElement).innerHTML; clip.setText(login); @@ -60,8 +62,8 @@ function OpenMenu(evt,level){ menu.style.left = defPosition(evt).x + "px"; menu.style.display = ""; } - if (flagpop==0){ - flagpop=1; + if (flagpop === 0){ + flagpop = 1; clip.glue( 'd_clip_button' ) } else diff --git a/js/sl2.js b/js/sl2.js index 5d637b5..e359cea 100644 --- a/js/sl2.js +++ b/js/sl2.js @@ -1,147 +1,183 @@ var Hint3Name = ''; -step=0; -function errmess(s) -{ - messid.innerHTML=''+s+''; - highlight(); -} -function highlight() -{ - if (step) return(0); - step=10; - setTimeout(dohi,50); +step = 0; + +function errmess(s) { + messid.innerHTML = '' + s + ''; + highlight(); } -function dohi() -{ - var hx=new Array(0,1,2,3,4,5,6,7,8,9,"A","B","C","D","E","F"); - - step--; - messid.style.color="#"+hx[Math.floor(15-step/2)]+((step&1)?"F":"8")+"0000"; - if (step>0) setTimeout(dohi,50); +function highlight() { + if (step) return (0); + step = 10; + setTimeout(dohi, 50); } -function fixspaces(s) -{ - while (s.substr(s.length-1,s.length)==" ") s=s.substr(0,s.length-1); - while (s.substr(0,1)==" ") s=s.substr(1,s.length); - return(s); +function dohi() { + let hx = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "A", "B", "C", "D", "E", "F"]; + + step--; + messid.style.color = "#" + hx[Math.floor(15 - step / 2)] + ((step & 1) ? "F" : "8") + "0000"; + if (step > 0) setTimeout(dohi, 50); +} + +function fixspaces(s) { + while (s.substr(s.length - 1, s.length) == " ") s = s.substr(0, s.length - 1); + while (s.substr(0, 1) == " ") s = s.substr(1, s.length); + return (s); } // Заголовок, название скрипта, имя поля с логином -function findlogin(title, script, name, defaultlogin) -{ - document.all("hint3").innerHTML = '
'+title+'x
'+ - '
'+ - 'Укажите логин персонажа:
(можно щелкнуть по логину в чате)
'; - document.all("hint3").style.visibility = "visible"; - document.all("hint3").style.left = 100; - document.all("hint3").style.top = 60; - document.all(name).focus(); - Hint3Name = name; +function findlogin(title, script, name1, defaultlogin) { + let hint3 = document.getElementById("hint3"); + hint3.innerHTML = ` + + + + + + + + +
+ ${title} + + + x +
+ + + + + + + + + + +
Укажите логин персонажа: + +
(можно щелкнуть по логину в чате) +
+ + + +
+
+ `; + /*document.all("hint3").innerHTML = '
' + title + 'x
' + + '
' + + 'Укажите логин персонажа:
(можно щелкнуть по логину в чате)
'; + */ + hint3.style.visibility = "visible"; + hint3.style.left = "100"; + hint3.style.top = "60"; + document.all(name1).focus(); + Hint3Name = name1; } // Для магии. Заголовок, название скрипта, название магии, номер вещицы в рюкзаке, логин по умолчанию, описание доп. поля -function magicklogin(title, script, magickname, n, defaultlogin, extparam) -{ - var s = '
'+title+'x
'+ - ''; - if (extparam != null && extparam != '') { - s = s + ''; - } - s = s + '
'+ - 'Укажите логин персонажа:
(можно щелкнуть по логину в чате)
'+extparam+'
'; - document.all("hint3").innerHTML = s; - document.all("hint3").style.visibility = "visible"; - document.all("hint3").style.left = 100; - document.all("hint3").style.top = document.body.scrollTop+50; - document.all("param").focus(); - Hint3Name = 'param'; +function magicklogin(title, script, magickname, n, defaultlogin, extparam) { + var s = '
' + title + 'x
' + + ''; + if (extparam != null && extparam != '') { + s = s + ''; + } + s = s + '
' + + 'Укажите логин персонажа:
(можно щелкнуть по логину в чате)
' + extparam + '
'; + document.all("hint3").innerHTML = s; + document.all("hint3").style.visibility = "visible"; + document.all("hint3").style.left = 100; + document.all("hint3").style.top = document.body.scrollTop + 50; + document.all("param").focus(); + Hint3Name = 'param'; } // Магия function UseMagick(title, script, name, extparam, n, extparam2) { - if ((extparam != null)&&(extparam != '')) { + if ((extparam != null) && (extparam != '')) { - var t1='text',t2='text'; + var t1 = 'text', t2 = 'text'; - if (extparam.substr(0,1) == "!") - { - t1='password'; - extparam=extparam.substr(1,extparam.length); - } - var s = '
'+title+'x
'+ - ''; - if (extparam2 != null && extparam2 != '') { - if (extparam2.substr(0,1) == "!") - { - t2='password'; - extparam2=extparam2.substr(1,extparam2.length); - } - s = s + ''; - } - s = s + '
'+ - extparam + ':
  
'+extparam2+':
  
'; - document.all("hint3").innerHTML = s; - document.all("hint3").style.visibility = "visible"; - document.all("hint3").style.left = 100; - document.all("hint3").style.top = document.body.scrollTop+50; - document.all("param").focus(); - Hint3Name = 'param'; - } else { - if (confirm('Использовать сейчас?')) { location=script+'?use='+name+'&n='+n; } - } + if (extparam.substr(0, 1) == "!") { + t1 = 'password'; + extparam = extparam.substr(1, extparam.length); + } + var s = '
' + title + 'x
' + + ''; + if (extparam2 != null && extparam2 != '') { + if (extparam2.substr(0, 1) == "!") { + t2 = 'password'; + extparam2 = extparam2.substr(1, extparam2.length); + } + s = s + ''; + } + s = s + '
' + + extparam + ':
  
' + extparam2 + ':
  
'; + document.all("hint3").innerHTML = s; + document.all("hint3").style.visibility = "visible"; + document.all("hint3").style.left = 100; + document.all("hint3").style.top = document.body.scrollTop + 50; + document.all("param").focus(); + Hint3Name = 'param'; + } else { + if (confirm('Использовать сейчас?')) { + location = script + '?use=' + name + '&n=' + n; + } + } } // Закрывает окно ввода логина -function closehint3() -{ - document.all("hint3").style.visibility="hidden"; - Hint3Name=''; +function closehint3() { + document.all("hint3").style.visibility = "hidden"; + Hint3Name = ''; } // Для боевой магии. Заголовок, название магии, номер вещицы в рюкзаке -function Bmagicklogin(title, magickname, n) -{ - if (defend==false) - { - errmess("Блок не выбран."); - return false; - } +function Bmagicklogin(title, magickname, n) { + if (defend == false) { + errmess("Блок не выбран."); + return false; + } - document.all("hint3").innerHTML = '
'+title+'x
'+ - '
'+ - 'Укажите логин персонажа:
(можно щелкнуть по логину в чате)
'; - document.all("hint3").style.visibility = "visible"; - document.all("hint3").style.left = 100; - document.all("hint3").style.top = 60; - document.all("param").focus(); - Hint3Name = 'param'; + document.all("hint3").innerHTML = '
' + title + 'x
' + + '
' + + 'Укажите логин персонажа:
(можно щелкнуть по логину в чате)
'; + document.all("hint3").style.visibility = "visible"; + document.all("hint3").style.left = 100; + document.all("hint3").style.top = 60; + document.all("param").focus(); + Hint3Name = 'param'; } // Магия function BUseMagick(name, extparam, n) { - if (defend==false) - { - errmess("Блок не выбран."); - return false; - } + if (defend == false) { + errmess("Блок не выбран."); + return false; + } - if ((extparam != null)&&(extparam != '')) { - var s = prompt(extparam+':', ''); - if ((s != null)&&(s != '')) { - re = /\%/g; s=s.replace(re, "%25"); - re = /\+/g; s=s.replace(re, "%2B"); - re = /\#/g; s=s.replace(re, "%23"); - re = /\?/g; s=s.replace(re, "%3F"); - re = /\&/g; s=s.replace(re, "%26"); - window.location.href='/battle.pl?use='+name+'¶m='+s+'&n='+n+'&mdefend='+defend+'&enemy='+enemy+'&myid='+myid; + if ((extparam != null) && (extparam != '')) { + var s = prompt(extparam + ':', ''); + if ((s != null) && (s != '')) { + re = /\%/g; + s = s.replace(re, "%25"); + re = /\+/g; + s = s.replace(re, "%2B"); + re = /\#/g; + s = s.replace(re, "%23"); + re = /\?/g; + s = s.replace(re, "%3F"); + re = /\&/g; + s = s.replace(re, "%26"); + window.location.href = '/battle.pl?use=' + name + '¶m=' + s + '&n=' + n + '&mdefend=' + defend + '&enemy=' + enemy + '&myid=' + myid; - } - } else { - if (confirm('Использовать сейчас?')) { location='/battle.pl?use='+name+'&n='+n+'&mdefend='+defend+'&enemy='+enemy+'&myid='+myid;} - } + } + } else { + if (confirm('Использовать сейчас?')) { + location = '/battle.pl?use=' + name + '&n=' + n + '&mdefend=' + defend + '&enemy=' + enemy + '&myid=' + myid; + } + } } From 904667008170ea84af4cbefc579279b5db09f45e Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 10 Mar 2021 23:06:07 +0200 Subject: [PATCH 04/28] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D1=8B=D0=B9=20=D1=81?= =?UTF-8?q?=D0=BF=D0=BE=D1=81=D0=BE=D0=B1=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80?= =?UTF-8?q?=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=83=D0=B2=D0=B5=D0=B4?= =?UTF-8?q?=D0=BE=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/main.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/js/main.js b/js/main.js index 2906a53..8dca01b 100644 --- a/js/main.js +++ b/js/main.js @@ -1,3 +1,39 @@ function hrefToFrame(link) { top.frames['gameframe'].location = link +} + +/** + * Отображаем уведомление на 5 секунд. + * @top Отступ сверху. + * @right Отступ справа. + * @className Тип уведомления. + * @html Текст уведомления в HTML формате. + */ +function showNotification({top = 0, right = 0, className, html}) { + + let notification = document.createElement('div'); + notification.style.cssText = ` + position: fixed; + z-index: 1000; + padding: 5px; + border: 1px solid black; + font-size: 20px; + background: white; + text-align: center; + `; + + if (className === "danger") { + notification.style.cssText += ` + background: #b80000; + color: yellow; + `; + } + + notification.style.top = top + 'px'; + notification.style.right = right + 'px'; + + notification.innerHTML = html; + document.body.append(notification); + + setTimeout(() => notification.remove(), 5000); } \ No newline at end of file From 279422ee9e3b42be362063095f95b2136b195b35 Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 10 Mar 2021 23:20:56 +0200 Subject: [PATCH 05/28] =?UTF-8?q?=D0=9E=D1=82=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B5=D0=B4=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D0=BE=D0=B2=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20std?= =?UTF-8?q?Class=20=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=BE=20=D0=BC=D0=B0?= =?UTF-8?q?=D1=81=D1=81=D0=B8=D0=B2=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/DressedItems.php | 14 +++++++------- classes/Battles/Item.php | 14 +++++++++++--- classes/Battles/UserInfo.php | 10 +++++----- main.php | 9 ++++----- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/classes/Battles/DressedItems.php b/classes/Battles/DressedItems.php index d1b170f..5fcb770 100644 --- a/classes/Battles/DressedItems.php +++ b/classes/Battles/DressedItems.php @@ -27,16 +27,16 @@ class DressedItems public static function getDressedItemBySlot($itemSlot, $ownerId) { - return self::$db->fetch('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = ?', [$ownerId, $itemSlot]); + return self::$db->fetch('SELECT *, COUNT(1) AS count FROM inventory WHERE owner_id = ? AND dressed_slot = ?', [$ownerId, $itemSlot]); } - public function getItemsInSlots() + public function getItemsInSlots(): \stdClass { $items = self::$db->ofetchALL('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot > 0', $this->USERID); - $i = 0; - while ($i < count($items)) { - $this->dressedItem[$items[$i]->dressed_slot] = $items; - $i++; + $this->dressedItem = new \stdClass(); + foreach ($items as $item) { + $i = $item->dressed_slot; + $this->dressedItem->$i = $item; } return $this->dressedItem; } @@ -123,7 +123,7 @@ SQL; { self::getItemsInSlots(); // Проверяем, что используется один из 12 слотов и наличие предмета в слоте. - if (in_array($slot_id, Item::ITEM_TYPES_ALLOWED_IN_SLOTS) && $this->dressedItem[$slot_id]) { + if (in_array($slot_id, Item::ITEM_TYPES_ALLOWED_IN_SLOTS) && $this->dressedItem->$slot_id) { self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ? AND owner_id = ?', [$slot_id, $this->USERID]); } } diff --git a/classes/Battles/Item.php b/classes/Battles/Item.php index 39a22ae..a60cfa0 100644 --- a/classes/Battles/Item.php +++ b/classes/Battles/Item.php @@ -49,9 +49,17 @@ abstract class Item */ public function __construct($row) { - foreach ($this as $key => $value) { - if (isset($row[$key])) { - $this->$key = $row[$key]; + if (is_array($row)) { + foreach ($this as $key => $value) { + if (isset($row[$key])) { + $this->$key = $row[$key]; + } + } + } elseif (is_object($row)) { + foreach ($this as $name => $value) { + if (isset($row->$name)) { + $this->$name = $row->$name; + } } } diff --git a/classes/Battles/UserInfo.php b/classes/Battles/UserInfo.php index ab978cd..4892f7e 100644 --- a/classes/Battles/UserInfo.php +++ b/classes/Battles/UserInfo.php @@ -25,13 +25,13 @@ class UserInfo extends User $dressedItems = $di->getItemsInSlots(); for ($i = 1; $i <= 12; $i++) { echo sprintf('
', $i); - if (!empty($dressedItems[$i])) { + if (!empty($dressedItems->$i)) { if (!$isBattle && $isMain) { - $itemString = '%s'; - echo sprintf($itemString, mt_rand(), $i, $dressedItems[$i]['image'], $dressedItems[$i]['name'], $dressedItems[$i]['name']); + echo sprintf('%s', + mt_rand(), $i, $dressedItems->$i->image, $dressedItems->$i->name, $dressedItems->$i->name); } else { - $itemString = '%s%s'; - echo sprintf($itemString, $dressedItems[$i]['image'], $dressedItems[$i]['name'], $dressedItems[$i]['name']); + echo sprintf('%s%s', + $dressedItems->$i->image, $dressedItems->$i->name, $dressedItems->$i->name); } } else { echo sprintf('Пустой слот [%s]', $i, $i); diff --git a/main.php b/main.php index 91173ed..9721a0b 100644 --- a/main.php +++ b/main.php @@ -36,10 +36,9 @@ $edit = $_GET['edit'] ?? null; // Подготавливаем отображение инфы и предметов. $userInfo = new UserInfo($user->getId()); $getItemsBonuses = new DressedItems($_SESSION['uid']); -$data_query = 'SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot = 0 AND on_sale = 0'; -$data = db::c()->query($data_query, $_SESSION['uid']); +$data = \Battles\Database\DBPDO::INIT()->ofetchAll('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND on_sale = 0', $user->getId()); $iteminfo = []; -while ($row = $data->fetch_assoc()) { +foreach ($data as $row) { $iteminfo[] = new InventoryItem($row); } @@ -456,8 +455,8 @@ Template::header('Игра'); echo ""; $ii->printInfo(); } - if ($data->getNumRows() == 0) { - echo "Пусто"; + if (!$data) { + echo "Пусто"; } ?> From 8b42d961639f57668721a7ee8ec1e5f1c00856fb Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 10 Mar 2021 23:22:35 +0200 Subject: [PATCH 06/28] =?UTF-8?q?=D0=9E=D0=B1=D1=80=D0=B0=D0=B7=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D1=83=D0=BC=D0=BE=D0=BB=D1=87=D0=B0=D0=BD=D0=B8=D1=8E?= =?UTF-8?q?=20=D0=BF=D0=B8c=D0=B0=D0=BB=20=D0=B2=20=D0=B1=D0=B0=D0=B7?= =?UTF-8?q?=D1=83=20gif,=20=D0=B0=20=D0=BD=D0=B5=20png.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- register.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/register.php b/register.php index 4af4e7a..7cc4bcb 100644 --- a/register.php +++ b/register.php @@ -25,7 +25,7 @@ if ($_COOKIE[GAMEDOMAIN] ?? null) { return false; } $db->execute('INSERT INTO users (login,pass,email,borndate,ip,session_id,shadow) - VALUES (?,?,?,?,?,?,?)', [$login, $password, $email, $birthday, $_SERVER['REMOTE_ADDR'], session_id(), '0.gif']); + VALUES (?,?,?,?,?,?,?)', [$login, $password, $email, $birthday, $_SERVER['REMOTE_ADDR'], session_id(), '0.png']); $userId = $db->lastInsertId(); $db->execute('INSERT INTO online (user_id, date, room, real_time) VALUES (?,?,1,?)', [$userId, time(), time()]); $db->execute('INSERT INTO bank (user_id) VALUES ?', $userId); From eacde765432b86fb79efad15789e1f65c68293e2 Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 10 Mar 2021 23:26:53 +0200 Subject: [PATCH 07/28] HTTP_X_REAL_IP => REMOTE_ADDR --- classes/quests_class.php | 2 +- functions.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/quests_class.php b/classes/quests_class.php index 7a9ec69..a246ce4 100644 --- a/classes/quests_class.php +++ b/classes/quests_class.php @@ -76,7 +76,7 @@ class Quests if (db::c()->getAffectedRows()) { $tms = (time() + 60 * 60 * $pl['time']); db::c()->query('INSERT INTO `actions` (`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES (?i,?i,"?s",?i,"?s","?s","?s","?s")', - $uid, time(), 'capitalcity', 0, 'start_quest' . $id, $_SERVER['HTTP_X_REAL_IP'], 'go', $tms); + $uid, time(), 'capitalcity', 0, 'start_quest' . $id, $_SERVER['REMOTE_ADDR'], 'go', $tms); return 'Вы успешно получили задание "' . $pl['name'] . '"'; } else { return 'Не удалось получить данное задание ...'; diff --git a/functions.php b/functions.php index 674020e..b07cb06 100644 --- a/functions.php +++ b/functions.php @@ -444,7 +444,7 @@ HTML; function addActions($time, $vars, $vls, $uid) { db::c()->query('LOCK TABLES `actions` WRITE'); - $ins = db::c()->query('INSERT INTO `actions` (`uid`,`time`,`city`,`room`,`vars`,`ip`,`vals`) VALUES (?i, ?i, "?s", ?i, "?s", "?s", "?s")', $uid, $time, "capitalcity", 0, $vars, $_SERVER['HTTP_X_REAL_IP'], $vls); + $ins = db::c()->query('INSERT INTO `actions` (`uid`,`time`,`city`,`room`,`vars`,`ip`,`vals`) VALUES (?i, ?i, "?s", ?i, "?s", "?s", "?s")', $uid, $time, "capitalcity", 0, $vars, $_SERVER['REMOTE_ADDR'], $vls); db::c()->query('UNLOCK TABLES'); return $ins; } From 0a07d53be75d571d5d55978226b527af97b60e9a Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 10 Mar 2021 23:38:14 +0200 Subject: [PATCH 08/28] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D1=8B=D0=B9=20=D0=BA?= =?UTF-8?q?=D0=BB=D0=B0=D1=81=D1=81=20UserStats=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D1=81=D0=BE=D0=BD=D0=B0=D0=B6=D0=B0.=20?= =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=BE=D1=81=20=D0=BD=D0=B5=D0=BA?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D1=80=D1=8B=D1=85=20=D0=BF=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=BE=D0=BA=20=D0=B2=20=D0=B3=D0=B5=D1=82=D1=82?= =?UTF-8?q?=D0=B5=D1=80=D1=8B.=20=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BD=D0=B5=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=B7=D1=83=D0=B5=D0=BC=D1=8B=D1=85=20=D1=81=D0=B5=D1=82=D1=82?= =?UTF-8?q?=D0=B5=D1=80=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/User.php | 343 +++------------------------------- classes/Battles/UserInfo.php | 2 +- classes/Battles/UserStats.php | 221 ++++++++++++++++++++++ inf.php | 19 +- main.php | 91 +++------ user_anketa.php | 14 +- 6 files changed, 285 insertions(+), 405 deletions(-) create mode 100644 classes/Battles/UserStats.php diff --git a/classes/Battles/User.php b/classes/Battles/User.php index bb5a208..9f7f34c 100644 --- a/classes/Battles/User.php +++ b/classes/Battles/User.php @@ -14,45 +14,23 @@ class User protected $realname; protected $borndate; protected $info; - protected $level = 0; - protected $align = 0; + protected $level; + protected $align; protected $clan; - protected $money = 0; - protected $strength = 0; - protected $dexterity = 0; - protected $intuition = 0; - protected $endurance = 0; - protected $intelligence = 0; - protected $wisdom = 0; - protected $health; - protected $mana; - protected $ip; - protected $session_id; + protected $money; + protected $ip = 0; + protected $admin = 0; protected $enter_game; protected $room; protected $block; protected $shadow; - // Удар кулаком всегда 1-2. - protected $minDamage = 1; - protected $maxDamage = 2; - //Броня без предметов не существует. - protected $headArmor = 0; - protected $chestArmor = 0; - protected $legArmor = 0; - protected $free_stat_points = 0; - private const STAT_MAXIMUM_AMOUNT = 40; - private const ERROR_STAT_IS_MAXIMUM = 'Ошибка: Параметр достиг своего лимита!'; - private const ERROR_STAT_UNKNOWN = 'Ошибка: Неизвестный параметр!'; + // Пока несуществующие, для совместимости. - protected $married = 'Someone или нет.'; protected $experience = 200; protected $battle = 0; protected $in_tower = 0; // Скорее башню похороним чем запустим... protected $zayavka = 0; - // Динамически рассчитываемые - protected $maxHealth = 5; - protected $maxMana = 5; protected static $db; public const INFO_CHAR_LIMIT = 1500; @@ -66,51 +44,8 @@ class User $this->$key = $user_query[$key]; } } - $this->maxHealth = round(($this->endurance * 3) + ($this->endurance / 2) * ($this->level - 1) + ($this->endurance / 5) * (($this->level - 1) * ($this->level - 2) / 2)); - $this->maxMana = round(($this->wisdom * 3) + ($this->wisdom / 2) * ($this->level - 1) + ($this->wisdom / 5) * (($this->level - 1) * ($this->level - 2) / 2)); } - /** - * Отдаёт информацию о базовом(!) стате. - * @param $stat_name - имя стата. Может принимать значения 'strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'. - * @param int $isMainWindow - переключатель "главного окна". Если включить, дополнительно будет показывать ссылку на повышение стата на 1, при условии наличия свободных очков статов. - * @return string - * @throws GameException - */ - public function getStat($stat_name, $isMainWindow = 0):string - { - $allowed = ['strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom']; - if (in_array($stat_name, $allowed)) { - if ($this->free_stat_points && $isMainWindow && $this->$stat_name < self::STAT_MAXIMUM_AMOUNT) { - return sprintf('%s [+]', $this->$stat_name, mt_rand(), $stat_name); - } else { - return $this->$stat_name; - } - } else { - throw new GameException(self::ERROR_STAT_UNKNOWN); - } - } - - /** - * Повышает один из выбранных статов на 1, но не выше self::STAT_MAXIMUM_AMOUNT при условии наличия свободных очков статов. - * @param string $stat_name - имя стата. Может принимать значения 'strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'. - * @throws GameException - */ - public function addOnePointToStat(string $stat_name) - { - $allowed = ['strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom']; - if (in_array($stat_name, $allowed)) { - if ($this->free_stat_points > 0 && $this->$stat_name <= self::STAT_MAXIMUM_AMOUNT) { - $query = "UPDATE users SET {$stat_name} = {$stat_name} + 1, free_stat_points = free_stat_points - 1 WHERE id = ?"; - self::$db->execute($query,$this->id); - } else { - throw new GameException(self::ERROR_STAT_IS_MAXIMUM); - } - } else { - throw new GameException(self::ERROR_STAT_UNKNOWN); - } - - } protected function showStarSign(): ?string { @@ -156,22 +91,13 @@ class User return $sign ?? null; } - public function getHealth(): string + + public static function setUserEffect(int $userId, int $type, string $name, int $time): bool { - return $this->health . '/' . $this->maxHealth; + return self::$db->execute('INSERT INTO users_effects (owner_id, type, name, remaining_time) VALUES (?,?,?,?)', [$userId, $type, $name, $time]); } - public function getMana(): string - { - return $this->mana . '/' . $this->maxMana; - } - - public static function setUserEffect(int $userId, int $type, string $name, int $time):bool - { - return self::$db->execute('INSERT INTO users_effects (owner_id, type, name, remaining_time) VALUES (?,?,?,?)',[$userId, $type, $name, $time]); - } - - public static function removeUserEffect(int $userId, int $type):bool + public static function removeUserEffect(int $userId, int $type): bool { if (self::$db->fetch('SELECT 1 FROM users_effects WHERE owner_id = ? AND type = ?', [$userId, $type])) { self::$db->execute('DELETE FROM users_effects WHERE owner_id = ? AND type = ?', [$userId, $type]); @@ -187,14 +113,6 @@ class User return $this->id; } - /** - * @param int $id - */ - public function setId(int $id): void - { - $this->id = $id; - } - /** * @return string */ @@ -227,6 +145,11 @@ class User $this->pass = $pass; } + public function savePass() + { + self::$db->execute('UPDATE users SET pass = ? WHERE id = ?', [$this->pass, $this->id]); + } + /** * @return string */ @@ -355,101 +278,6 @@ class User $this->money = $money; } - /** - * @return int - */ - public function getStrength(): int - { - return $this->strength; - } - - /** - * @param int $strength - */ - public function setStrength(int $strength): void - { - $this->strength = $strength; - } - - /** - * @return int - */ - public function getDexterity(): int - { - return $this->dexterity; - } - - /** - * @param int $dexterity - */ - public function setDexterity(int $dexterity): void - { - $this->dexterity = $dexterity; - } - - /** - * @return int - */ - public function getIntuition(): int - { - return $this->intuition; - } - - /** - * @param int $intuition - */ - public function setIntuition(int $intuition): void - { - $this->intuition = $intuition; - } - - /** - * @return int - */ - public function getEndurance(): int - { - return $this->endurance; - } - - /** - * @param int $endurance - */ - public function setEndurance(int $endurance): void - { - $this->endurance = $endurance; - } - - /** - * @return int - */ - public function getIntelligence(): int - { - return $this->intelligence; - } - - /** - * @param int $intelligence - */ - public function setIntelligence(int $intelligence): void - { - $this->intelligence = $intelligence; - } - - /** - * @return int - */ - public function getWisdom(): int - { - return $this->wisdom; - } - - /** - * @param int $wisdom - */ - public function setWisdom(int $wisdom): void - { - $this->wisdom = $wisdom; - } /** * @return mixed @@ -467,21 +295,6 @@ class User $this->ip = $ip; } - /** - * @return mixed - */ - public function getSessionId() - { - return $this->session_id; - } - - /** - * @param mixed $session_id - */ - public function setSessionId($session_id): void - { - $this->session_id = $session_id; - } /** * @return int @@ -491,14 +304,6 @@ class User return $this->admin; } - /** - * @param int $admin - */ - public function setAdmin(int $admin): void - { - $this->admin = $admin; - } - /** * @return mixed */ @@ -560,103 +365,18 @@ class User */ public function setShadow($shadow): void { - $this->shadow = $shadow; + $shadows = [ + 'm01', 'm02', 'm03', 'm04', 'm05', 'm06', 'm07', 'm08', 'm09', 'm10', + 'f01', 'f02', 'f03', 'f04', 'f05', 'f06', 'f07', 'f08', 'f09', 'f10', + ]; + if (in_array($shadow, $shadows) && $this->getShadow() == '0.png') { + $this->shadow = $shadow . '.png'; + } } - /** - * @return int - */ - public function getMinDamage(): int + public function saveShadow() { - return $this->minDamage; - } - - /** - * @return int - */ - public function getMaxDamage(): int - { - return $this->maxDamage; - } - - /** - * @return int - */ - public function getHeadArmor(): int - { - return $this->headArmor; - } - - /** - * @param int $headArmor - */ - public function setHeadArmor(int $headArmor): void - { - $this->headArmor = $headArmor; - } - - /** - * @return int - */ - public function getChestArmor(): int - { - return $this->chestArmor; - } - - /** - * @param int $chestArmor - */ - public function setChestArmor(int $chestArmor): void - { - $this->chestArmor = $chestArmor; - } - - /** - * @return int - */ - public function getLegArmor(): int - { - return $this->legArmor; - } - - /** - * @param int $legArmor - */ - public function setLegArmor(int $legArmor): void - { - $this->legArmor = $legArmor; - } - - /** - * @return int - */ - public function getFreeStatPoints(): int - { - return $this->free_stat_points; - } - - /** - * @param int $free_stat_points - */ - public function setFreeStatPoints(int $free_stat_points): void - { - $this->free_stat_points = $free_stat_points; - } - - /** - * @return string - */ - public function getMarried(): string - { - return $this->married; - } - - /** - * @param string $married - */ - public function setMarried(string $married): void - { - $this->married = $married; + self::$db->execute('UPDATE users SET shadow = ? WHERE id = ?', [$this->getShadow(), $this->getId()]); } /** @@ -723,20 +443,9 @@ class User $this->zayavka = $zayavka; } - /** - * @return float|int - */ - public function getMaxHealth() + public function saveAnketa() { - return $this->maxHealth; - } - - /** - * @return float|int - */ - public function getMaxMana() - { - return $this->maxMana; + self::$db->execute('UPDATE users SET realname = ?, info = ? WHERE id = ?', [$this->realname, $this->info, $this->id]); } } \ No newline at end of file diff --git a/classes/Battles/UserInfo.php b/classes/Battles/UserInfo.php index 4892f7e..53229a9 100644 --- a/classes/Battles/UserInfo.php +++ b/classes/Battles/UserInfo.php @@ -3,7 +3,7 @@ namespace Battles; use Battles\Models\EffectsModel; use Exceptions\GameException; -class UserInfo extends User +class UserInfo extends UserStats { use Rooms; //Статусы того, кто смотрит на информацию. diff --git a/classes/Battles/UserStats.php b/classes/Battles/UserStats.php new file mode 100644 index 0000000..3c1079c --- /dev/null +++ b/classes/Battles/UserStats.php @@ -0,0 +1,221 @@ +maxHealth = round(($this->endurance * 3) + ($this->endurance / 2) * ($this->level - 1) + ($this->endurance / 5) * (($this->level - 1) * ($this->level - 2) / 2)); + $this->maxMana = round(($this->wisdom * 3) + ($this->wisdom / 2) * ($this->level - 1) + ($this->wisdom / 5) * (($this->level - 1) * ($this->level - 2) / 2)); + } + + /** + * Отдаёт информацию о базовом(!) стате. + * + * @param $stat_name - имя стата. Может принимать значения 'strength', 'dexterity', 'intuition', + * 'endurance', 'intelligence', 'wisdom'. + * @param int $isMainWindow - переключатель "главного окна". Если включить, дополнительно будет показывать ссылку + * на повышение стата на 1, при условии наличия свободных очков статов. + * + * @return string + */ + public function getStat($stat_name, $isMainWindow = 0): string + { + if (!in_array($stat_name, ['strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'])) { + return self::ERROR_STAT_UNKNOWN; + } + if ($this->free_stat_points && $isMainWindow && $this->$stat_name < self::STAT_MAXIMUM_AMOUNT) { + $this->$stat_name .= " [+]"; + } + return $this->$stat_name; + + } + + /** + * Повышает один из выбранных статов на 1, но не выше self::STAT_MAXIMUM_AMOUNT при условии наличия свободных очков + * статов. + * + * @param string $stat_name - имя стата. Может принимать значения 'strength', 'dexterity', 'intuition', + * 'endurance', 'intelligence', 'wisdom'. + * + * @throws GameException + */ + public function addOnePointToStat(string $stat_name) + { + if (!in_array($stat_name, ['strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'])) { + throw new GameException(self::ERROR_STAT_UNKNOWN); + } + if ($this->free_stat_points <= 0 || $this->$stat_name >= self::STAT_MAXIMUM_AMOUNT) { + throw new GameException(self::ERROR_STAT_IS_MAXIMUM); + } else { + $query = "UPDATE users SET {$stat_name} = {$stat_name} + 1, free_stat_points = free_stat_points - 1 WHERE id = ?"; + self::$db->execute($query, $this->id); + } + } + + /** + * @return mixed + */ + public function getStrength() + { + return $this->strength; + } + + /** + * @return mixed + */ + public function getDexterity() + { + return $this->dexterity; + } + + /** + * @return mixed + */ + public function getIntuition() + { + return $this->intuition; + } + + /** + * @return mixed + */ + public function getEndurance() + { + return $this->endurance; + } + + /** + * @return mixed + */ + public function getIntelligence() + { + return $this->intelligence; + } + + /** + * @return mixed + */ + public function getWisdom() + { + return $this->wisdom; + } + + /** + * @return mixed + */ + public function getHealth() + { + return $this->health; + } + + /** + * @return mixed + */ + public function getMana() + { + return $this->mana; + } + + /** + * @return mixed + */ + public function getFreeStatPoints() + { + return $this->free_stat_points; + } + + /** + * @return float + */ + public function getMaxHealth(): float + { + return $this->maxHealth; + } + + /** + * @return float + */ + public function getMaxMana(): float + { + return $this->maxMana; + } + + /** + * @return int + */ + public function getMinDamage(): int + { + return $this->minDamage; + } + + /** + * @return int + */ + public function getMaxDamage(): int + { + return $this->maxDamage; + } + + /** + * @return int + */ + public function getHeadArmor(): int + { + return $this->headArmor; + } + + /** + * @return int + */ + public function getChestArmor(): int + { + return $this->chestArmor; + } + + /** + * @return int + */ + public function getLegArmor(): int + { + return $this->legArmor; + } + + +} \ No newline at end of file diff --git a/inf.php b/inf.php index 05509f6..2f92f1b 100644 --- a/inf.php +++ b/inf.php @@ -1,21 +1,14 @@ id); +$userInfo = new \Battles\UserInfo(urldecode($_SERVER['QUERY_STRING'])); +$presentsModel = new \Battles\Models\PresentsModel($userInfo->getId()); $presentsList = $presentsModel->getAllPresents(); $userInfo->watcher_id = $_SESSION['uid'] ?? null; -\Battles\Template::header('Информация о ' . $userInfo->login); -if (!$userInfo->id) { - echo sprintf('Ошибка: персонаж %s не найден...

←назад

', $login); +\Battles\Template::header('Информация о ' . $userInfo->getLogin()); +if (!$userInfo->getId()) { + echo sprintf('Ошибка: персонаж %s не найден...

←назад

', urldecode($_SERVER['QUERY_STRING'])); exit; } -try { - $userInfo->showUserInfo(); - -} catch (Exception $e_showUserInfo) { - echo "
Ошибка генератора showUserInfo() в User.php: {$e_showUserInfo}
"; -} - +$userInfo->showUserInfo(); include_once 'views/presents-list.php'; \ No newline at end of file diff --git a/main.php b/main.php index 9721a0b..9878606 100644 --- a/main.php +++ b/main.php @@ -6,6 +6,7 @@ use Battles\InventoryItem; use Battles\Template; use Battles\Travel; use Battles\UserInfo; +use Battles\UserStats; ob_start("ob_gzhandler"); session_start(); @@ -35,6 +36,7 @@ $setShadow = $_POST['setshadow'] ?? null; $edit = $_GET['edit'] ?? null; // Подготавливаем отображение инфы и предметов. $userInfo = new UserInfo($user->getId()); +$userStats = new UserStats($user->getId()); $getItemsBonuses = new DressedItems($_SESSION['uid']); $data = \Battles\Database\DBPDO::INIT()->ofetchAll('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND on_sale = 0', $user->getId()); $iteminfo = []; @@ -173,7 +175,7 @@ if ($goto) { $eff = db::c()->query('SELECT 1 FROM `users_effects` WHERE `owner_id` = ?i AND (`type` = 14 OR `type` = 13)', $user->getId()); //(масса: getItemsWeight() . '/' . $user->strength * 4 - if ($d['sum_weight'] > $user->getStrength() * 4 && $goto) { + if ($d['sum_weight'] > $userStats->getStrength() * 4 && $goto) { err('У вас переполнен рюкзак, вы не можете передвигаться...'); $imove = false; } @@ -199,60 +201,11 @@ if (isset($_GET['use'])) { usemagic($_GET['use'], $_POST['target']); } -function setShadow($image) -{ - global $user; - $shadows = [ - 'm01', 'm02', 'm03', 'm04', 'm05', 'm06', 'm07', 'm08', 'm09', 'm10', - 'f01', 'f02', 'f03', 'f04', 'f05', 'f06', 'f07', 'f08', 'f09', 'f10', - 'person', - ]; - if (in_array($image, $shadows)) { - $i = $image . '.png'; - db::c()->query('UPDATE `users` SET `shadow` = "?s" WHERE `id` = ?i', $i, $user->getId()); - } else { - err('Ошибка!'); - } +if ($obraz) { + $user->setShadow($obraz); + $user->saveShadow(); } -if ($obraz && ($user->getShadow() == 'g0.gif' || $user->getShadow() == 'man0.gif')) { - setShadow($obraz); -} - -if ($del == 1 && $effectId > 0) { - $pl = db::c()->query('SELECT type FROM users_effects WHERE owner_id = ?i AND effect_id = ?i', $user->getId(), $effectId)->fetch_assoc(); - if (isset($pl['type'])) { - echo del_efs($effectId, $pl['type']); - } else { - echo "Эффект не найден!"; - } -} - -if ($brons && $ids) { - try { - $cur = db::c()->query('SELECT free_bron, bron1, bron2, bron3, bron4 FROM inventory WHERE owner = ?i AND id = ?i', $user->getId(), $ids)->fetch_assoc(); - } catch (\Krugozor\Database\Mysql\Exception $e) { - echo "
Ошибка: " . $e->getMessage() . "
В файле: " . $e->getFile() . " (" . $e->getLine() . ")
"; - } - if ($cur['free_bron'] > 0 && $cur[$brons] > 0) { - db::c()->query('UPDATE inventory SET free_bron = free_bron - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $brons, $brons, $user->getId(), $ids); - echo "Параметр брони увеличен!"; - } -} -if ($stats && $ids) { - $cur = db::c()->query('SELECT free_stat, gsila, glovk, ginta, gintel FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->getId(), $ids); - if ($cur['free_stat'] > 0 && $cur[$stats] > 0) { - db::c()->query('UPDATE inventory SET free_stat = free_stat - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $stats, $stats, $user->getId(), $ids); - echo "Параметр увеличен!"; - } -} -if ($mfs && $ids) { - $cur = db::c()->query('SELECT free_mf, mfkrit, mfuvorot, mfakrit, mfauvorot FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->getId(), $ids); - if (isset($cur['id']) && $cur['free_mf'] > 0 && $cur[$mfs] > 0) { - db::c()->query('UPDATE inventory SET free_mf = free_mf - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $mfs, $mfs, $user->getId(), $ids); - echo "Параметр увеличен!"; - } -} if ($setShadow) { Template::header('Образ персонажа'); ?> @@ -388,39 +341,39 @@ Template::header('Игра');
- Сила: getFreeStatPoints() ? $user->getStat('strength', 1) . '(' . strval($user->getStrength() + $getItemsBonuses->getStrengthBonus()) . ')' : $user->getStrength() + $getItemsBonuses->getStrengthBonus()) ?> + Сила: getFreeStatPoints() ? $userStats->getStat('strength', 1) . '(' . strval($userStats->getStrength() + $getItemsBonuses->getStrengthBonus()) . ')' : $userStats->getStrength() + $getItemsBonuses->getStrengthBonus()) ?>
- Ловкость: getFreeStatPoints() ? $user->getStat('dexterity', 1) . '(' . strval($user->getDexterity() + $getItemsBonuses->getDexterityBonus()) . ')' : $user->getDexterity() + $getItemsBonuses->getDexterityBonus()) ?> + Ловкость: getFreeStatPoints() ? $userStats->getStat('dexterity', 1) . '(' . strval($userStats->getDexterity() + $getItemsBonuses->getDexterityBonus()) . ')' : $userStats->getDexterity() + $getItemsBonuses->getDexterityBonus()) ?>
- Интуиция: getFreeStatPoints() ? $user->getStat('intuition', 1) . '(' . strval($user->getIntuition() + $getItemsBonuses->getIntuitionBonus()) . ')' : $user->getIntuition() + $getItemsBonuses->getIntuitionBonus()) ?> + Интуиция: getFreeStatPoints() ? $userStats->getStat('intuition', 1) . '(' . strval($userStats->getIntuition() + $getItemsBonuses->getIntuitionBonus()) . ')' : $userStats->getIntuition() + $getItemsBonuses->getIntuitionBonus()) ?>
- Выносливость: getFreeStatPoints() ? $user->getStat('endurance', 1) . '(' . strval($user->getEndurance() + $getItemsBonuses->getEnduranceBonus()) . ')' : $user->getEndurance() + $getItemsBonuses->getEnduranceBonus()) ?> + Выносливость: getFreeStatPoints() ? $userStats->getStat('endurance', 1) . '(' . strval($userStats->getEndurance() + $getItemsBonuses->getEnduranceBonus()) . ')' : $userStats->getEndurance() + $getItemsBonuses->getEnduranceBonus()) ?>
- Интеллект: getFreeStatPoints() ? $user->getStat('intelligence', 1) . '(' . strval($user->getIntelligence() + $getItemsBonuses->getIntelliganceBonus()) . ')' : $user->getIntelligence() + $getItemsBonuses->getIntelliganceBonus()) ?> + Интеллект: getFreeStatPoints() ? $userStats->getStat('intelligence', 1) . '(' . strval($userStats->getIntelligence() + $getItemsBonuses->getIntelliganceBonus()) . ')' : $userStats->getIntelligence() + $getItemsBonuses->getIntelliganceBonus()) ?>
- Мудрость: getFreeStatPoints() ? $user->getStat('wisdom', 1) . '(' . strval($user->getWisdom() + $getItemsBonuses->getWisdomBonus()) . ')' : $user->getWisdom() + $getItemsBonuses->getWisdomBonus()) ?> + Мудрость: getFreeStatPoints() ? $userStats->getStat('wisdom', 1) . '(' . strval($userStats->getWisdom() + $getItemsBonuses->getWisdomBonus()) . ')' : $userStats->getWisdom() + $getItemsBonuses->getWisdomBonus()) ?>
- getFreeStatPoints()): ?> + getFreeStatPoints()): ?> Возможных - увеличений: getFreeStatPoints() ?>
+ увеличений: getFreeStatPoints() ?>

- Здоровье: getHealth() ?>
- Пыль: getMana() ?>
+ Здоровье: getHealth() ?>
+ Пыль: getMana() ?>
Уворот: getEvasionBonus() ?>
Точность: getAccuracyBonus() ?>
Шанс крита: getCriticalsBonus() ?>
- Урон: getMinDamage() + $getItemsBonuses->getMinPhysDamage() ?> - - getMaxDamage() + $getItemsBonuses->getMaxPhysDamage() ?>
+ Урон: getMinDamage() + $getItemsBonuses->getMinPhysDamage() ?> + - getMaxDamage() + $getItemsBonuses->getMaxPhysDamage() ?>

Защита от огня: ??
Защита от воды: ??
Защита от вохдуха: ??
Защита от земли: ??
Защита от яда: ??
- Броня головы: getHeadArmor() ?>
- Броня корпуса: getChestArmor() ?>
- Броня ног: getLegArmor() ?>
+ Броня головы: getHeadArmor() ?>
+ Броня корпуса: getChestArmor() ?>
+ Броня ног: getLegArmor() ?>
@@ -445,7 +398,7 @@ Template::header('Игра');
", $hobbie); $hobbie = str_replace("\\r", "", $hobbie); @@ -18,14 +17,19 @@ if ($name || $hobbie) { if (strlen($hobbie) > User::INFO_CHAR_LIMIT) { err('Максимальная длинна поля Хобби: ' . User::INFO_CHAR_LIMIT . ' символов!'); } else { - $values = ['realname' => $name, 'color' => $color, 'info' => $hobbie]; - db::c()->query('UPDATE users SET ?As WHERE id = ?i', $values, $user->getId()); + if ($name) { + $user->setRealname($name); + } + if ($hobbie) { + $user->setInfo($hobbie); + } + $user->saveAnketa(); } } - if ($oldpsw && $newpsw) { if (password_verify($oldpsw, $user->getPass())) { - db::c()->query('UPDATE `users` SET `pass` = "?s" WHERE `id` = ?i', password_hash($newpsw, PASSWORD_DEFAULT), $user->getId()); + $user->setPass(password_hash($newpsw, PASSWORD_DEFAULT)); + $user->savePass(); } else { err('Неверный текущий пароль!'); } From c99e54af1a1cf0e8db53ed5ed3af92c4bfd6fa12 Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 10 Mar 2021 23:43:48 +0200 Subject: [PATCH 09/28] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=20=D1=81=D0=BF=D0=B5=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=B2=20=D0=B8=D0=B7=20=D0=B3?= =?UTF-8?q?=D0=BB=D0=BE=D0=B1=D0=B0=D0=BB=D1=8C=D0=BD=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20=D0=B2=20=D0=B1=D0=BE?= =?UTF-8?q?=D0=BB=D0=B5=D0=B5=20=D1=83=D0=B7=D0=BA=D0=B8=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/InventoryItem.php | 14 ++-- classes/Battles/Item.php | 9 +-- classes/Battles/UserInfo.php | 107 +++++++++++++++++------------- 3 files changed, 72 insertions(+), 58 deletions(-) diff --git a/classes/Battles/InventoryItem.php b/classes/Battles/InventoryItem.php index 561d3be..9e5d193 100644 --- a/classes/Battles/InventoryItem.php +++ b/classes/Battles/InventoryItem.php @@ -22,12 +22,16 @@ class InventoryItem extends Item public function printImage() { - if (in_array($this->item_type, range(1,12))) { - echo "item_id} title='Надеть'>"; - parent::printImage(); - echo ""; + if (in_array($this->item_type, range(1, 12))) { + echo <<item_id} title='Надеть'> + + +HTML; } else { - parent::printImage(); + echo << +IMG; } } diff --git a/classes/Battles/Item.php b/classes/Battles/Item.php index a60cfa0..c2105e4 100644 --- a/classes/Battles/Item.php +++ b/classes/Battles/Item.php @@ -1,6 +1,6 @@ image}" class="item-wrap-normal" alt=""> -IMG; - } protected function wrap(int $number):string { diff --git a/classes/Battles/UserInfo.php b/classes/Battles/UserInfo.php index 53229a9..ed26067 100644 --- a/classes/Battles/UserInfo.php +++ b/classes/Battles/UserInfo.php @@ -78,31 +78,68 @@ class UserInfo extends UserStats $this->money . '
' . $this->Bank->getMoney(); } - $nameString = ''; - if ($this->align) { - $nameString = sprintf('Склонность', $this->align); + $nameString = null; + $nameString .= $this->align ? "Склонность" : ""; + $nameString .= $this->block ? "$this->login" : "$this->login"; + $nameString .= $this->clan ? "Клан" : ""; + + echo << +
$nameString
+
+
$captions
+
$variables
+
+ +HTML; + } + + /** + * О персонаже для модераторов. + * @return string|null + */ + private function showPrivateData(): ?string + { + if (!$this->watcherIsAdmin || !$this->watcherIsModerator) { + return null; } - if ($this->block) { - $nameString .= '' . $this->login . ''; - } else { - $nameString .= ' ' . $this->login . ' '; + $birthday = date('d.m.Y', strtotime($this->borndate)); + $userLogs = GameLogs::getUserLogs($this->id); + $log = null; + while ($userLogRow = $userLogs->fetchArray(SQLITE3_ASSOC)) { + $log .= sprintf('%s
', date('d.m.Y H:i ', strtotime($userLogRow['date'])) . $userLogRow['text']); } - if ($this->clan) { - $nameString .= sprintf('Клан', $this->clan); - } - echo ''; + $adminData = $this->watcherIsAdmin ? $this->showAdminOnlyData() : null; + return << + E-Mail: $this->email
+ ДР Игрока: $birthday
+ IP Регистрации: $this->ip
+ $adminData
+
Личное дело
+ $log +
+ +INFO; + } + + /** + * О персонаже для администраторов. + * @return string|null + */ + private function showAdminOnlyData(): ?string + { + $this->Bank = new Bank($this->id); + $bankMoney = $this->Bank->getMoney(); + return <<id
+ИД Комнаты: $this->room
+Деньги: $this->money
+Деньги в банке: $bankMoney
+Опыт: $this->experience
+Нераспределённые очки: $this->free_stat_points
+INFO; + } private function Info() @@ -110,10 +147,7 @@ class UserInfo extends UserStats echo '
Рюкзак - (масса: getStrength() * 4 ?>) + (масса: getStrength() * 4 ?>)
' + title + 'x
' + - '
' + - errkom + 'введите название предмета
'; + document.getElementById("hint3").innerHTML = ` + + + + + + + + +
+ ${title} + + x +
+
+ + + + + + + + + +
+ ${errkom} введите название предмета +
+ + + +
+
+
+ `; document.getElementById("hint3").style.visibility = "visible"; document.getElementById("hint3").style.left = '100'; document.getElementById("hint3").style.top = '100'; @@ -314,13 +345,12 @@ Template::header('Игра'); }
-
- +
-
showUserDoll(0, 1); ?> -
+
Снять все
getId()) ?> @@ -377,7 +407,7 @@ Template::header('Игра');
+
getShadow() == '0.gif' || $user->getAdmin() == 1): ?> @@ -396,16 +426,16 @@ Template::header('Игра');
- +
Рюкзак (масса: getStrength() * 4 ?>)
"; + echo "
"; $ii->printImage(); $ii->printControls(); - echo ""; + echo ""; $ii->printInfo(); } if (!$data) { diff --git a/user_anketa.php b/user_anketa.php index a6b48af..9c946cf 100644 --- a/user_anketa.php +++ b/user_anketa.php @@ -39,12 +39,10 @@ Template::header('Анкета'); ← на главную

Анкета персонажа getLogin() ?>

-
-
+

From cbccdd754fb62c761fc620fa2ae469ace1e81a8e Mon Sep 17 00:00:00 2001 From: lopar Date: Thu, 11 Mar 2021 00:55:08 +0200 Subject: [PATCH 12/28] fix #21 --- classes/Battles/User.php | 5 +- classes/Battles/UserInfo.php | 1 - main.php | 104 +++++++++++++++++------------------ 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/classes/Battles/User.php b/classes/Battles/User.php index 9f7f34c..7ff517e 100644 --- a/classes/Battles/User.php +++ b/classes/Battles/User.php @@ -3,7 +3,6 @@ namespace Battles; use Battles\Database\DBPDO; -use Exceptions\GameException; class User { @@ -448,4 +447,8 @@ class User self::$db->execute('UPDATE users SET realname = ?, info = ? WHERE id = ?', [$this->realname, $this->info, $this->id]); } + public function setOnline() + { + self::$db->execute('update online set real_time = ? where user_id = ?', [time(), $this->getId()]); + } } \ No newline at end of file diff --git a/classes/Battles/UserInfo.php b/classes/Battles/UserInfo.php index 8a0d999..26a8c0f 100644 --- a/classes/Battles/UserInfo.php +++ b/classes/Battles/UserInfo.php @@ -1,7 +1,6 @@ query('UPDATE `online` SET `real_time` = ?i WHERE `user_id` = ?i', time(), $user->getId()); -} catch (\Krugozor\Database\Mysql\Exception $e) { - echo "
Ошибка: " . $e->getMessage() . "
Стек: " . $e->getTraceAsString() . "
"; -} +$user->setOnline(); // Инициализируем входящие GET\POST переменные. $goto = $_GET['goto'] ?? null; @@ -34,10 +30,59 @@ $mfs = $_GET['modif_mf'] ?? null; $ids = $_GET['ids'] ?? null; $setShadow = $_POST['setshadow'] ?? null; $edit = $_GET['edit'] ?? null; + +if ($edit) { + $ups = $_GET['ups'] ?? null; + $upm = $_GET['upm'] ?? null; + $use = $_GET['use'] ?? null; + $useTarget = $_POST['target'] ?? null; + $drop = $_GET['drop'] ?? null; + $dress = $_GET['dress'] ?? null; + $undress = $_GET['undress'] ?? null; + $destruct = $_GET['destruct'] ?? null; + + if ($ups) { + $user->addOnePointToStat($ups); + } + if ($upm) { + addOnePoint($upm, 'mastery'); + } + if ($drop) { + $items = new DressedItems($_SESSION['uid']); + $items->undressItem($drop); + } + //Пока что одеваем предмет отсюда. + if ($dress) { + echo dressitem($dress); + } + if ($destruct) { + $q = db::c()->query('SELECT `id`, `dressed`, `name`, `duration`, `maxdur` FROM `inventory` WHERE `owner` = ?i AND `id` = ?i', $_SESSION['uid'], $destruct); + if ($q->getNumRows()) { + $q = $q->fetch_assoc(); + if (empty($q['dressed'])) { + destructitem($q['id']); + GameLogs::addUserLog($user->getId(), $user->getLogin() . ' выбросил предмет ' . $q['name'] . ' id:(cap' . $q['id'] . ')'); + err('Предмет ' . $q['name'] . ' выброшен.'); + } else { + err('Ошибка: нельзя выбросить одетый предмет!'); + } + } else { + err('Ошибка: предмет не найден!'); + } + } + if ($use) { + usemagic($use, $useTarget); + } + if ($undress) { + undressall($_SESSION['uid']); + } +} + + // Подготавливаем отображение инфы и предметов. $userInfo = new UserInfo($user->getId()); $userStats = new UserStats($user->getId()); -$getItemsBonuses = new DressedItems($_SESSION['uid']); +$getItemsBonuses = new DressedItems($user->getId()); $data = \Battles\Database\DBPDO::INIT()->ofetchAll('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND on_sale = 0', $user->getId()); $iteminfo = []; foreach ($data as $row) { @@ -240,53 +285,6 @@ if ($setShadow) { addOnePointToStat($ups); - } - if ($upm) { - addOnePoint($upm, 'mastery'); - } - if ($drop) { - $items = new DressedItems($_SESSION['uid']); - $items->undressItem($drop); - } - //Пока что одеваем предмет отсюда. - if ($dress) { - echo dressitem($dress); - } - if ($destruct) { - $q = db::c()->query('SELECT `id`, `dressed`, `name`, `duration`, `maxdur` FROM `inventory` WHERE `owner` = ?i AND `id` = ?i', $_SESSION['uid'], $destruct); - if ($q->getNumRows()) { - $q = $q->fetch_assoc(); - if (empty($q['dressed'])) { - destructitem($q['id']); - GameLogs::addUserLog($user->getId(), $user->getLogin() . " выбросил предмет " . $q['name'] . " id:(cap" . $q['id'] . ")"); - err('Предмет ' . $q['name'] . ' выброшен.'); - } else { - err('Ошибка: нельзя выбросить одетый предмет!'); - } - } else { - err('Ошибка: предмет не найден!'); - } - } - if ($use) { - usemagic($use, $useTarget); - } - if ($undress) { - undressall($_SESSION['uid']); - } -} Template::header('Игра'); ?> From f5b2b23582ff6e137d63c3cc326f576325f798ee Mon Sep 17 00:00:00 2001 From: lopar Date: Thu, 11 Mar 2021 19:43:20 +0200 Subject: [PATCH 13/28] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BF=D1=80=D0=B8=20=D0=BE=D0=B4=D0=B5=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B8=20=D0=BF=D1=80=D0=B5=D0=B4=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D0=BE=D0=B2.=20fix=20#8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/UserStats.php | 13 ++++ main.php | 108 +++++++++++++++++++--------------- 2 files changed, 73 insertions(+), 48 deletions(-) diff --git a/classes/Battles/UserStats.php b/classes/Battles/UserStats.php index 3c1079c..74a5055 100644 --- a/classes/Battles/UserStats.php +++ b/classes/Battles/UserStats.php @@ -217,5 +217,18 @@ class UserStats extends User return $this->legArmor; } + public function getFullStats() + { + $query = " + select + sum(greatest(strength + (ifnull((select sum(add_strength) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allStrength, + sum(greatest(dexterity + (ifnull((select sum(add_dexterity) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allDexterity, + sum(greatest(intuition + (ifnull((select sum(add_intuition) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allIntuition, + sum(greatest(endurance + (ifnull((select sum(add_endurance) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allEndurance, + sum(greatest(intelligence + (ifnull((select sum(add_intelligence) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allIntelligence, + sum(greatest(wisdom + (ifnull((select sum(add_wisdom) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allWisdom + from users where id = $this->id"; + return self::$db->ofetch($query); + } } \ No newline at end of file diff --git a/main.php b/main.php index 1625c5b..4d115b5 100644 --- a/main.php +++ b/main.php @@ -138,7 +138,6 @@ function del_efs($id, $type) // одеть предмет function dressitem($id) { - //bug #7 define('HELMET', 1); define('ARMOR', 2); define('LEGS', 3); @@ -153,57 +152,70 @@ function dressitem($id) 'TOO_MANY_ITEMS_IN_SLOTS' => 'Критическая ошибка: Переполнение слота!', 'UNKNOWN_ITEM_TYPE' => 'Неизвестный тип предмета!', 'ITEM_NOT_FOUND' => 'Предмет не найден!', + 'REQUIREMENTS_NOT_MET' => 'Персонаж не соответствует требованиям!', ]); + $userStats = new UserStats($_SESSION['uid']); $itemInSlot = []; - $selectedItemRow = db::c()->query('SELECT item_type FROM `inventory` WHERE item_id = ?i AND owner_id = ?i AND `dressed_slot` = 0', $id, $_SESSION['uid']); - if ($selectedItemRow->getNumRows()) { - $selectedItem = $selectedItemRow->fetch_object(); - $itemInSlotRow = db::c()->query('SELECT dressed_slot FROM inventory WHERE owner_id = ?i AND dressed_slot > 0 AND item_type = ?i', $_SESSION['uid'], $selectedItem->item_type); - $itemInSlotQuantity = $itemInSlotRow->getNumRows(); - if ($itemInSlotQuantity) { - while ($row = $itemInSlotRow->fetch_object()) { - $itemInSlot[] = $row->dressed_slot; - } - } - if (in_array($selectedItem->item_type, [HELMET, ARMOR, LEGS, BOOTS, GLOVES, WEAPON, SHIELD, BELT, AMULET])) { - //работаем с нормальными слотами - if (!$itemInSlotQuantity) { - // просто одеваем предмет - db::c()->query('UPDATE inventory SET dressed_slot = item_type WHERE item_id = ?i', $id); - } elseif ($itemInSlotQuantity == 1) { - // снимаем предмет и одеваем вместо - db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ?i', $itemInSlot[0]); - db::c()->query('UPDATE inventory SET dressed_slot = item_type WHERE item_id = ?i', $id); - } else { - // невозможная ситуация - два предмета в одиночном слоте. критическая ошибка, запись в лог, раздевание. - $error = DRESSITEM_ERROR['TOO_MANY_ITEMS_IN_SLOTS']; - db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?i', $_SESSION['uid']); - } - } elseif ($selectedItem->item_type == RING) { - // работаем с кольцами - if ($itemInSlotQuantity < 3) { - // Сравниваем массив колец и массив слотов для колец. - $emptyRingSlots = array_diff([9, 10, 11], $itemInSlot); - // Сортируем массив свободных слотов по возрастанию. - sort($emptyRingSlots); - // Одеваем предмет в первый свободный слот. - db::c()->query('UPDATE inventory SET dressed_slot = ?i WHERE item_id = ?i', $emptyRingSlots[0], $id); - } elseif ($itemInSlotQuantity == 3) { - db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = 11'); - db::c()->query('UPDATE inventory SET dressed_slot = 11 WHERE item_id = ?i', $id); - // снимаем предмет из слота 11 и одеваем вместо - } else { - // невозможная ситуация - больше трёх предметов на три слота. критическая ошибка, запись в лог, раздевание. - $error = DRESSITEM_ERROR['TOO_MANY_ITEMS_IN_SLOTS']; - db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?i', $_SESSION['uid']); - } - } else { - //предмет вообще не должен одеваться, ошибка - $error = DRESSITEM_ERROR['UNKNOWN_ITEM_TYPE']; - } - } else { + $selectedItemRow = db::c()->query('SELECT item_type,need_strength,need_dexterity,need_intuition,need_endurance,need_intelligence,need_wisdom FROM `inventory` WHERE item_id = ?i AND owner_id = ?i AND `dressed_slot` = 0 AND `durability` != 0', $id, $_SESSION['uid']); + + //$userStats->getStrength() + if (!$selectedItemRow->getNumRows()) { //с предметом что-то сильно не ок, ошибка. $error = DRESSITEM_ERROR['ITEM_NOT_FOUND']; + } else { + $selectedItem = $selectedItemRow->fetch_object(); + if ($selectedItem->need_strength > $userStats->getFullStats()->allStrength + || $selectedItem->need_dexterity > $userStats->getFullStats()->allDexterity + || $selectedItem->need_intuition > $userStats->getFullStats()->allIntuition + || $selectedItem->need_endurance > $userStats->getFullStats()->allEndurance + || $selectedItem->need_intelligence > $userStats->getFullStats()->allIntelligence + || $selectedItem->need_wisdom > $userStats->getFullStats()->allWisdom) { + $error = DRESSITEM_ERROR['REQUIREMENTS_NOT_MET']; + } else { + $itemInSlotRow = db::c()->query('SELECT dressed_slot FROM inventory WHERE owner_id = ?i AND dressed_slot > 0 AND item_type = ?i', $_SESSION['uid'], $selectedItem->item_type); + $itemInSlotQuantity = $itemInSlotRow->getNumRows(); + if ($itemInSlotQuantity) { + while ($row = $itemInSlotRow->fetch_object()) { + $itemInSlot[] = $row->dressed_slot; + } + } + if (in_array($selectedItem->item_type, [HELMET, ARMOR, LEGS, BOOTS, GLOVES, WEAPON, SHIELD, BELT, AMULET])) { + //работаем с нормальными слотами + if (!$itemInSlotQuantity) { + // просто одеваем предмет + db::c()->query('UPDATE inventory SET dressed_slot = item_type WHERE item_id = ?i', $id); + } elseif ($itemInSlotQuantity == 1) { + // снимаем предмет и одеваем вместо + db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ?i', $itemInSlot[0]); + db::c()->query('UPDATE inventory SET dressed_slot = item_type WHERE item_id = ?i', $id); + } else { + // невозможная ситуация - два предмета в одиночном слоте. критическая ошибка, запись в лог, раздевание. + $error = DRESSITEM_ERROR['TOO_MANY_ITEMS_IN_SLOTS']; + db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?i', $_SESSION['uid']); + } + } elseif ($selectedItem->item_type == RING) { + // работаем с кольцами + if ($itemInSlotQuantity < 3) { + // Сравниваем массив колец и массив слотов для колец. + $emptyRingSlots = array_diff([9, 10, 11], $itemInSlot); + // Сортируем массив свободных слотов по возрастанию. + sort($emptyRingSlots); + // Одеваем предмет в первый свободный слот. + db::c()->query('UPDATE inventory SET dressed_slot = ?i WHERE item_id = ?i', $emptyRingSlots[0], $id); + } elseif ($itemInSlotQuantity == 3) { + db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = 11'); + db::c()->query('UPDATE inventory SET dressed_slot = 11 WHERE item_id = ?i', $id); + // снимаем предмет из слота 11 и одеваем вместо + } else { + // невозможная ситуация - больше трёх предметов на три слота. критическая ошибка, запись в лог, раздевание. + $error = DRESSITEM_ERROR['TOO_MANY_ITEMS_IN_SLOTS']; + db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?i', $_SESSION['uid']); + } + } else { + //предмет вообще не должен одеваться, ошибка + $error = DRESSITEM_ERROR['UNKNOWN_ITEM_TYPE']; + } + } } if (isset($error)) { From 26ed4cd286e7e7c16d8a5015f806e4a22945a1c8 Mon Sep 17 00:00:00 2001 From: lopar Date: Thu, 11 Mar 2021 20:14:41 +0200 Subject: [PATCH 14/28] =?UTF-8?q?=D0=9E=D1=82=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D0=B0=D1=82+?= =?UTF-8?q?=D0=B1=D0=BE=D0=BD=D1=83=D1=81=20=D0=B2=D0=BC=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=BE=20=D1=87=D0=B8=D1=81=D1=82=D0=BE=D0=B3=D0=BE=20=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D1=82=D0=B0=20=D1=82=D0=B0=D0=BC,=20=D0=B3=D0=B4?= =?UTF-8?q?=D0=B5=20=D1=8D=D1=82=D0=BE=20=D0=BD=D0=B5=D0=BE=D0=B1=D1=85?= =?UTF-8?q?=D0=BE=D0=B4=D0=B8=D0=BC=D0=BE.=20=D0=A3=D0=BD=D0=B8=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B7=D0=B0=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=81=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D0=BE=D0=B9.=20#18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/DressedItems.php | 30 ------------------------------ classes/Battles/UserInfo.php | 12 ++++++------ main.php | 14 +++++++------- 3 files changed, 13 insertions(+), 43 deletions(-) diff --git a/classes/Battles/DressedItems.php b/classes/Battles/DressedItems.php index 5fcb770..b429f08 100644 --- a/classes/Battles/DressedItems.php +++ b/classes/Battles/DressedItems.php @@ -60,36 +60,6 @@ SQL; return self::$db->fetch($query, $this->USERID); } - public function getStrengthBonus(): ?int - { - return self::getBonuses()['sum_strength']; - } - - public function getDexterityBonus(): ?int - { - return self::getBonuses()['sum_dexterity']; - } - - public function getIntuitionBonus(): ?int - { - return self::getBonuses()['sum_intuition']; - } - - public function getEnduranceBonus(): ?int - { - return self::getBonuses()['sum_endurance']; - } - - public function getIntelliganceBonus(): ?int - { - return self::getBonuses()['sum_intelligence']; - } - - public function getWisdomBonus(): ?int - { - return self::getBonuses()['sum_wisdom']; - } - public function getAccuracyBonus(): ?int { return self::getBonuses()['sum_accuracy'] ?? 0; diff --git a/classes/Battles/UserInfo.php b/classes/Battles/UserInfo.php index 26a8c0f..617c066 100644 --- a/classes/Battles/UserInfo.php +++ b/classes/Battles/UserInfo.php @@ -53,12 +53,12 @@ class UserInfo extends UserStats $captions = 'Уровень:
Сила:
Ловкость:
Интуиция:
Выносливость:
Интеллект:
Мудрость:
Местонахождение:'; $variables = $this->level . '
' . - parent::getStat('strength') . '
' . - parent::getStat('dexterity') . '
' . - parent::getStat('intuition') . '
' . - parent::getStat('endurance') . '
' . - parent::getStat('intelligence') . '
' . - parent::getStat('wisdom') . '
' . + parent::getFullStats()->allStrength . '
' . + parent::getFullStats()->allDexterity . '
' . + parent::getFullStats()->allIntuition . '
' . + parent::getFullStats()->allEndurance . '
' . + parent::getFullStats()->allIntelligence . '
' . + parent::getFullStats()->allWisdom . '
' . Rooms::$roomNames[$this->room]; if ($isMainWindow) { $this->Bank = new Bank($this->id); diff --git a/main.php b/main.php index 4d115b5..9683a07 100644 --- a/main.php +++ b/main.php @@ -381,17 +381,17 @@ Template::header('Игра');
- Сила: getFreeStatPoints() ? $userStats->getStat('strength', 1) . '(' . strval($userStats->getStrength() + $getItemsBonuses->getStrengthBonus()) . ')' : $userStats->getStrength() + $getItemsBonuses->getStrengthBonus()) ?> + Сила: getFreeStatPoints() ? $userStats->getStat('strength', 1) . '(' . strval($userStats->getFullStats()->allStrength) . ')' : $userStats->getFullStats()->allStrength) ?>
- Ловкость: getFreeStatPoints() ? $userStats->getStat('dexterity', 1) . '(' . strval($userStats->getDexterity() + $getItemsBonuses->getDexterityBonus()) . ')' : $userStats->getDexterity() + $getItemsBonuses->getDexterityBonus()) ?> + Ловкость: getFreeStatPoints() ? $userStats->getStat('dexterity', 1) . '(' . strval($userStats->getFullStats()->allDexterity) . ')' : $userStats->getFullStats()->allDexterity) ?>
- Интуиция: getFreeStatPoints() ? $userStats->getStat('intuition', 1) . '(' . strval($userStats->getIntuition() + $getItemsBonuses->getIntuitionBonus()) . ')' : $userStats->getIntuition() + $getItemsBonuses->getIntuitionBonus()) ?> + Интуиция: getFreeStatPoints() ? $userStats->getStat('intuition', 1) . '(' . strval($userStats->getFullStats()->allIntuition) . ')' : $userStats->getFullStats()->allIntuition) ?>
- Выносливость: getFreeStatPoints() ? $userStats->getStat('endurance', 1) . '(' . strval($userStats->getEndurance() + $getItemsBonuses->getEnduranceBonus()) . ')' : $userStats->getEndurance() + $getItemsBonuses->getEnduranceBonus()) ?> + Выносливость: getFreeStatPoints() ? $userStats->getStat('endurance', 1) . '(' . strval($userStats->getFullStats()->allEndurance) . ')' : $userStats->getFullStats()->allEndurance) ?>
- Интеллект: getFreeStatPoints() ? $userStats->getStat('intelligence', 1) . '(' . strval($userStats->getIntelligence() + $getItemsBonuses->getIntelliganceBonus()) . ')' : $userStats->getIntelligence() + $getItemsBonuses->getIntelliganceBonus()) ?> + Интеллект: getFreeStatPoints() ? $userStats->getStat('intelligence', 1) . '(' . strval($userStats->getFullStats()->allIntelligence) . ')' : $userStats->getFullStats()->allIntelligence) ?>
- Мудрость: getFreeStatPoints() ? $userStats->getStat('wisdom', 1) . '(' . strval($userStats->getWisdom() + $getItemsBonuses->getWisdomBonus()) . ')' : $userStats->getWisdom() + $getItemsBonuses->getWisdomBonus()) ?> + Мудрость: getFreeStatPoints() ? $userStats->getStat('wisdom', 1) . '(' . strval($userStats->getFullStats()->allWisdom) . ')' : $userStats->getFullStats()->allWisdom) ?>
getFreeStatPoints()): ?> Возможных @@ -438,7 +438,7 @@ Template::header('Игра');
Date: Thu, 11 Mar 2021 20:14:41 +0200 Subject: [PATCH 15/28] =?UTF-8?q?=D0=9E=D1=82=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D0=B0=D1=82+?= =?UTF-8?q?=D0=B1=D0=BE=D0=BD=D1=83=D1=81=20=D0=B2=D0=BC=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=BE=20=D1=87=D0=B8=D1=81=D1=82=D0=BE=D0=B3=D0=BE=20=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D1=82=D0=B0=20=D1=82=D0=B0=D0=BC,=20=D0=B3=D0=B4?= =?UTF-8?q?=D0=B5=20=D1=8D=D1=82=D0=BE=20=D0=BD=D0=B5=D0=BE=D0=B1=D1=85?= =?UTF-8?q?=D0=BE=D0=B4=D0=B8=D0=BC=D0=BE.=20=D0=A3=D0=BD=D0=B8=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B7=D0=B0=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=81=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D0=BE=D0=B9.=20#18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/DressedItems.php | 30 ------------------------------ classes/Battles/UserInfo.php | 12 ++++++------ classes/Battles/UserStats.php | 12 ++++++------ main.php | 26 +++++++++++++------------- 4 files changed, 25 insertions(+), 55 deletions(-) diff --git a/classes/Battles/DressedItems.php b/classes/Battles/DressedItems.php index 5fcb770..b429f08 100644 --- a/classes/Battles/DressedItems.php +++ b/classes/Battles/DressedItems.php @@ -60,36 +60,6 @@ SQL; return self::$db->fetch($query, $this->USERID); } - public function getStrengthBonus(): ?int - { - return self::getBonuses()['sum_strength']; - } - - public function getDexterityBonus(): ?int - { - return self::getBonuses()['sum_dexterity']; - } - - public function getIntuitionBonus(): ?int - { - return self::getBonuses()['sum_intuition']; - } - - public function getEnduranceBonus(): ?int - { - return self::getBonuses()['sum_endurance']; - } - - public function getIntelliganceBonus(): ?int - { - return self::getBonuses()['sum_intelligence']; - } - - public function getWisdomBonus(): ?int - { - return self::getBonuses()['sum_wisdom']; - } - public function getAccuracyBonus(): ?int { return self::getBonuses()['sum_accuracy'] ?? 0; diff --git a/classes/Battles/UserInfo.php b/classes/Battles/UserInfo.php index 26a8c0f..0794276 100644 --- a/classes/Battles/UserInfo.php +++ b/classes/Battles/UserInfo.php @@ -53,12 +53,12 @@ class UserInfo extends UserStats $captions = 'Уровень:
Сила:
Ловкость:
Интуиция:
Выносливость:
Интеллект:
Мудрость:
Местонахождение:'; $variables = $this->level . '
' . - parent::getStat('strength') . '
' . - parent::getStat('dexterity') . '
' . - parent::getStat('intuition') . '
' . - parent::getStat('endurance') . '
' . - parent::getStat('intelligence') . '
' . - parent::getStat('wisdom') . '
' . + parent::getFullStats()->strength . '
' . + parent::getFullStats()->dexterity . '
' . + parent::getFullStats()->intuition . '
' . + parent::getFullStats()->endurance . '
' . + parent::getFullStats()->intelligence . '
' . + parent::getFullStats()->wisdom . '
' . Rooms::$roomNames[$this->room]; if ($isMainWindow) { $this->Bank = new Bank($this->id); diff --git a/classes/Battles/UserStats.php b/classes/Battles/UserStats.php index 74a5055..09ce3d9 100644 --- a/classes/Battles/UserStats.php +++ b/classes/Battles/UserStats.php @@ -221,12 +221,12 @@ class UserStats extends User { $query = " select - sum(greatest(strength + (ifnull((select sum(add_strength) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allStrength, - sum(greatest(dexterity + (ifnull((select sum(add_dexterity) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allDexterity, - sum(greatest(intuition + (ifnull((select sum(add_intuition) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allIntuition, - sum(greatest(endurance + (ifnull((select sum(add_endurance) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allEndurance, - sum(greatest(intelligence + (ifnull((select sum(add_intelligence) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allIntelligence, - sum(greatest(wisdom + (ifnull((select sum(add_wisdom) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as allWisdom + sum(greatest(strength + (ifnull((select sum(add_strength) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as strength, + sum(greatest(dexterity + (ifnull((select sum(add_dexterity) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as dexterity, + sum(greatest(intuition + (ifnull((select sum(add_intuition) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as intuition, + sum(greatest(endurance + (ifnull((select sum(add_endurance) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as endurance, + sum(greatest(intelligence + (ifnull((select sum(add_intelligence) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as intelligence, + sum(greatest(wisdom + (ifnull((select sum(add_wisdom) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as wisdom from users where id = $this->id"; return self::$db->ofetch($query); } diff --git a/main.php b/main.php index 4d115b5..04e240b 100644 --- a/main.php +++ b/main.php @@ -164,12 +164,12 @@ function dressitem($id) $error = DRESSITEM_ERROR['ITEM_NOT_FOUND']; } else { $selectedItem = $selectedItemRow->fetch_object(); - if ($selectedItem->need_strength > $userStats->getFullStats()->allStrength - || $selectedItem->need_dexterity > $userStats->getFullStats()->allDexterity - || $selectedItem->need_intuition > $userStats->getFullStats()->allIntuition - || $selectedItem->need_endurance > $userStats->getFullStats()->allEndurance - || $selectedItem->need_intelligence > $userStats->getFullStats()->allIntelligence - || $selectedItem->need_wisdom > $userStats->getFullStats()->allWisdom) { + if ($selectedItem->need_strength > $userStats->getFullStats()->strength + || $selectedItem->need_dexterity > $userStats->getFullStats()->dexterity + || $selectedItem->need_intuition > $userStats->getFullStats()->intuition + || $selectedItem->need_endurance > $userStats->getFullStats()->endurance + || $selectedItem->need_intelligence > $userStats->getFullStats()->intelligence + || $selectedItem->need_wisdom > $userStats->getFullStats()->wisdom) { $error = DRESSITEM_ERROR['REQUIREMENTS_NOT_MET']; } else { $itemInSlotRow = db::c()->query('SELECT dressed_slot FROM inventory WHERE owner_id = ?i AND dressed_slot > 0 AND item_type = ?i', $_SESSION['uid'], $selectedItem->item_type); @@ -381,17 +381,17 @@ Template::header('Игра');
- Сила: getFreeStatPoints() ? $userStats->getStat('strength', 1) . '(' . strval($userStats->getStrength() + $getItemsBonuses->getStrengthBonus()) . ')' : $userStats->getStrength() + $getItemsBonuses->getStrengthBonus()) ?> + Сила: getFreeStatPoints() ? $userStats->getStat('strength', 1) . '(' . strval($userStats->getFullStats()->strength) . ')' : $userStats->getFullStats()->strength) ?>
- Ловкость: getFreeStatPoints() ? $userStats->getStat('dexterity', 1) . '(' . strval($userStats->getDexterity() + $getItemsBonuses->getDexterityBonus()) . ')' : $userStats->getDexterity() + $getItemsBonuses->getDexterityBonus()) ?> + Ловкость: getFreeStatPoints() ? $userStats->getStat('dexterity', 1) . '(' . strval($userStats->getFullStats()->dexterity) . ')' : $userStats->getFullStats()->dexterity) ?>
- Интуиция: getFreeStatPoints() ? $userStats->getStat('intuition', 1) . '(' . strval($userStats->getIntuition() + $getItemsBonuses->getIntuitionBonus()) . ')' : $userStats->getIntuition() + $getItemsBonuses->getIntuitionBonus()) ?> + Интуиция: getFreeStatPoints() ? $userStats->getStat('intuition', 1) . '(' . strval($userStats->getFullStats()->intuition) . ')' : $userStats->getFullStats()->intuition) ?>
- Выносливость: getFreeStatPoints() ? $userStats->getStat('endurance', 1) . '(' . strval($userStats->getEndurance() + $getItemsBonuses->getEnduranceBonus()) . ')' : $userStats->getEndurance() + $getItemsBonuses->getEnduranceBonus()) ?> + Выносливость: getFreeStatPoints() ? $userStats->getStat('endurance', 1) . '(' . strval($userStats->getFullStats()->endurance) . ')' : $userStats->getFullStats()->endurance) ?>
- Интеллект: getFreeStatPoints() ? $userStats->getStat('intelligence', 1) . '(' . strval($userStats->getIntelligence() + $getItemsBonuses->getIntelliganceBonus()) . ')' : $userStats->getIntelligence() + $getItemsBonuses->getIntelliganceBonus()) ?> + Интеллект: getFreeStatPoints() ? $userStats->getStat('intelligence', 1) . '(' . strval($userStats->getFullStats()->intelligence) . ')' : $userStats->getFullStats()->intelligence) ?>
- Мудрость: getFreeStatPoints() ? $userStats->getStat('wisdom', 1) . '(' . strval($userStats->getWisdom() + $getItemsBonuses->getWisdomBonus()) . ')' : $userStats->getWisdom() + $getItemsBonuses->getWisdomBonus()) ?> + Мудрость: getFreeStatPoints() ? $userStats->getStat('wisdom', 1) . '(' . strval($userStats->getFullStats()->wisdom) . ')' : $userStats->getFullStats()->wisdom) ?>
getFreeStatPoints()): ?> Возможных @@ -438,7 +438,7 @@ Template::header('Игра');
Рюкзак - (масса: getStrength() * 4 ?>) + (масса: getStrength() * 4 ?>)
Date: Thu, 11 Mar 2021 20:42:36 +0200 Subject: [PATCH 16/28] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=20=D0=B8=20=D1=83=D0=BD=D0=B8=D1=84=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8?= =?UTF-8?q?=20=D1=81=D0=BD=D1=8F=D1=82=D0=B8=D1=8F=20=D0=BF=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=BC=D0=B5=D1=82=D0=BE=D0=B2=20=D0=B2=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D1=81=20DressedItems.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/edit_user.php | 7 +- cave.php | 6 +- classes/Battles/DressedItems.php | 5 +- cronjobs/cron_bots_battle.php | 6 +- functions.php | 266 ------------------------------- labirint.php | 6 +- 6 files changed, 19 insertions(+), 277 deletions(-) diff --git a/admin/edit_user.php b/admin/edit_user.php index 280e8eb..b9720fa 100644 --- a/admin/edit_user.php +++ b/admin/edit_user.php @@ -37,10 +37,11 @@ if (isset($_SESSION['player_id'])) { if ($del) { $itemdel = db::c()->query('SELECT item_type, dressed_slot FROM inventory WHERE id=?i', $del)->fetch_assoc(); if ($itemdel['dressed_slot'] == 1) { - dropitem($itemdel['item_type']); + $item = new \Battles\DressedItems($del); + $item->undressItem($itemdel['item_type']); if ($itemdel['item_type'] == 5) { - dropitem(6); - dropitem(7); + $item->undressItem(6); + $item->undressItem(7); } } db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $del); diff --git a/cave.php b/cave.php index bfba725..f684eb0 100644 --- a/cave.php +++ b/cave.php @@ -487,7 +487,8 @@ if (@$_GET['kill'] && $user['id'] == $user['caveleader'] && $_GET['kill'] != $us while ($rec = mysql_fetch_assoc($r)) { $slot = getslot($rec['id'], $usr); if ($slot) { - dropitemid(0, $v['user'], $slot); + $item = new \Battles\DressedItems($v['user']); + $item->undressItem($slot); } } mysql_query("DELETE FROM `inventory` WHERE `owner` = '$v[user]' AND `foronetrip` = 1"); @@ -898,7 +899,8 @@ if (@$_GET['exit']) { while ($rec = mysql_fetch_assoc($r)) { $slot = getslot($rec['id']); if ($slot) { - dropitemid(0, $user['id'], $slot); + $item = new \Battles\DressedItems($user['id']); + $item->undressItem($slot); } } mysql_query("DELETE FROM `inventory` WHERE `owner` = '$user[id]' AND `foronetrip` = 1"); diff --git a/classes/Battles/DressedItems.php b/classes/Battles/DressedItems.php index b429f08..b8a8644 100644 --- a/classes/Battles/DressedItems.php +++ b/classes/Battles/DressedItems.php @@ -8,6 +8,7 @@ namespace Battles; use Battles\Database\DBPDO; +use stdClass; class DressedItems { @@ -30,10 +31,10 @@ class DressedItems return self::$db->fetch('SELECT *, COUNT(1) AS count FROM inventory WHERE owner_id = ? AND dressed_slot = ?', [$ownerId, $itemSlot]); } - public function getItemsInSlots(): \stdClass + public function getItemsInSlots(): stdClass { $items = self::$db->ofetchALL('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot > 0', $this->USERID); - $this->dressedItem = new \stdClass(); + $this->dressedItem = new stdClass(); foreach ($items as $item) { $i = $item->dressed_slot; $this->dressedItem->$i = $item; diff --git a/cronjobs/cron_bots_battle.php b/cronjobs/cron_bots_battle.php index ad49089..5dede9b 100644 --- a/cronjobs/cron_bots_battle.php +++ b/cronjobs/cron_bots_battle.php @@ -486,7 +486,8 @@ class fbattle $inv_broken = mysql_query("SELECT * FROM `inventory` WHERE `type` != 12 AND `dressed` = 1 AND ((`maxdur` <= `duration`) OR (`dategoden` > 0 AND `dategoden` <= '" . time() . "')) AND `owner` = '{$v}'"); while ($br = mysql_fetch_array($inv_broken)) { - dropitemid($br['type'], $v); + $item = new \Battles\DressedItems($v); + $item->undressItem($br['type']); } $its = mysql_query("SELECT `id` FROM `inventory` WHERE `dressed` = 0 AND ((`maxdur` <= `duration`) OR (`dategoden` > 0 AND `dategoden` <= '" . time() . "')) AND `owner` = '{$v}'"); @@ -573,7 +574,8 @@ class fbattle $this->AddToLog('' . date("H:i") . ' ' . Nick::id($v)->short() . ' получил повреждение: ' . $tr . '
'); $inv_broken = mysql_query("SELECT `id`, `type`, `dressed`, `duration`, `maxdur`, `dategoden`, `owner` FROM `inventory` WHERE `type` != 12 AND `dressed` = 1 AND ((`maxdur` <= `duration`) OR (`dategoden` > 0 AND `dategoden` <= '" . time() . "')) AND `owner` = '{$v}'"); while ($br = mysql_fetch_array($inv_broken)) { - dropitemid($br['type'], $v); + $item = new \Battles\DressedItems($v); + $item->undressItem($br['type']); } } } diff --git a/functions.php b/functions.php index b07cb06..f43d8bd 100644 --- a/functions.php +++ b/functions.php @@ -454,272 +454,6 @@ function undressall($user_id) db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?i', $user_id); } -function dropitemid($slot, $id) -{ - global $user; - switch ($slot) { - case 1: - $slot1 = 'sergi'; - break; - case 2: - $slot1 = 'kulon'; - break; - case 3: - $slot1 = 'weap'; - break; - case 4: - $slot1 = 'bron'; - break; - case 5: - $slot1 = 'r1'; - break; - case 6: - $slot1 = 'r2'; - break; - case 7: - $slot1 = 'r3'; - break; - case 8: - $slot1 = 'helm'; - break; - case 9: - $slot1 = 'perchi'; - break; - case 10: - $slot1 = 'shit'; - break; - case 11: - $slot1 = 'boots'; - break; - case 12: - $slot1 = 'm1'; - break; - case 13: - $slot1 = 'm2'; - break; - case 14: - $slot1 = 'm3'; - break; - case 15: - $slot1 = 'm4'; - break; - case 16: - $slot1 = 'm5'; - break; - case 17: - $slot1 = 'm6'; - break; - case 18: - $slot1 = 'm7'; - break; - case 19: - $slot1 = 'm8'; - break; - case 20: - $slot1 = 'm9'; - break; - case 21: - $slot1 = 'm10'; - break; - case 22: - $slot1 = 'rybax'; - break; - case 23: - $slot1 = 'plaw'; - break; - default: - $slot1 = ''; - break; - } - $checkid = db::c()->query('SELECT 1 FROM `users` WHERE `id` = ?i', $id); - if ($checkid->getNumRows()) { - if (mysql_query('UPDATE `users`, `inventory` SET `users`.`' . $slot1 . '` = 0, `inventory`.`dressed` = 0, `users`.`sila` = `users`.`sila` - `inventory`.`gsila`, `users`.`lovk` = `users`.`lovk` - `inventory`.`glovk`, `users`.`inta` = `users`.`inta` - `inventory`.`ginta`, `users`.`intel` = `users`.`intel` - `inventory`.`gintel`, `users`.`maxhp` = `users`.`maxhp` - `inventory`.`ghp`, `users`.`noj` = `users`.`noj` - `inventory`.`gnoj`, `users`.`topor` = `users`.`topor` - `inventory`.`gtopor`, `users`.`dubina` = `users`.`dubina` - `inventory`.`gdubina`, `users`.`mec` = `users`.`mec` - `inventory`.`gmech`, `users`.`mfire` = `users`.`mfire` - `inventory`.`gfire`, `users`.`mwater` = `users`.`mwater` - `inventory`.`gwater`, `users`.`mair` = `users`.`mair` - `inventory`.`gair`, `users`.`mearth` = `users`.`mearth` - `inventory`.`gearth`, `users`.`mlight` = `users`.`mlight` - `inventory`.`glight`, `users`.`mgray` = `users`.`mgray` - `inventory`.`ggray`, `users`.`mdark` = `users`.`mdark` - `inventory`.`gdark`, `users`.`fkrit` = `users`.`fkrit` - `inventory`.`mfkrit`, `users`.`fakrit` = `users`.`fakrit` - `inventory`.`mfakrit`, `users`.`fuvorot` = `users`.`fuvorot` - `inventory`.`mfuvorot`, `users`.`fauvorot` = `users`.`fauvorot` - `inventory`.`mfauvorot`, `users`.`ubron1` = `users`.`ubron1` - `inventory`.`bron1`, `users`.`ubron2` = `users`.`ubron2` - `inventory`.`bron2`, `users`.`ubron3` = `users`.`ubron3` - `inventory`.`bron3`, `users`.`ubron4` = `users`.`ubron4` - `inventory`.`bron4`, `users`.`uminu` = `users`.`uminu` - `inventory`.`minu`, `users`.`umaxu` = `users`.`umaxu` - `inventory`.`maxu` WHERE `inventory`.`id` = `users`.`' . $slot1 . '` AND `inventory`.`dressed` = 1 AND `inventory`.`owner` = "' . $id . '" AND `users`.`id` = "' . $id . '"')) { - db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $id); - $user->$slot1 = 0; - } - return true; - } else { - return false; - } -} - -// снять предмет -function dropitem($slot) -{ - global $user; - $wear_arr = []; - switch ($slot) { - case 1: - $slot1 = 'sergi'; - break; - case 2: - $slot1 = 'kulon'; - break; - case 3: - $slot1 = 'weap'; - break; - case 4: - $slot1 = 'bron'; - break; - case 5: - $slot1 = 'r1'; - break; - case 6: - $slot1 = 'r2'; - break; - case 7: - $slot1 = 'r3'; - break; - case 8: - $slot1 = 'helm'; - break; - case 9: - $slot1 = 'perchi'; - break; - case 10: - $slot1 = 'shit'; - break; - case 11: - $slot1 = 'boots'; - break; - case 12: - $slot1 = 'm1'; - break; - case 13: - $slot1 = 'm2'; - break; - case 14: - $slot1 = 'm3'; - break; - case 15: - $slot1 = 'm4'; - break; - case 16: - $slot1 = 'm5'; - break; - case 17: - $slot1 = 'm6'; - break; - case 18: - $slot1 = 'm7'; - break; - case 19: - $slot1 = 'm8'; - break; - case 20: - $slot1 = 'm9'; - break; - case 21: - $slot1 = 'm10'; - break; - case 22: - $slot1 = 'rybax'; - break; - case 23: - $slot1 = 'plaw'; - break; - default: - $slot1 = ''; - break; - } - - if (db::c()->query('UPDATE `users` as `u`, `inventory` as `i` SET `u`.?f = 0, `i`.`dressed` = 0, - `u`.`sila` = `u`.`sila` - `i`.`gsila`, - `u`.`lovk` = `u`.`lovk` - `i`.`glovk`, - `u`.`inta` = `u`.`inta` - `i`.`ginta`, - `u`.`intel` = `u`.`intel` - `i`.`gintel`, - `u`.`maxhp` = `u`.`maxhp` - `i`.`ghp`, - `u`.`noj` = `u`.`noj` - `i`.`gnoj`, - `u`.`topor` = `u`.`topor` - `i`.`gtopor`, - `u`.`dubina` = `u`.`dubina` - `i`.`gdubina`, - `u`.`mec` = `u`.`mec` - `i`.`gmech`, - `u`.`mfire` = `u`.`mfire` - `i`.`gfire`, - `u`.`mwater` = `u`.`mwater` - `i`.`gwater`, - `u`.`mair` = `u`.`mair` - `i`.`gair`, - `u`.`mearth` = `u`.`mearth` - `i`.`gearth`, - `u`.`mlight` = `u`.`mlight` - `i`.`glight`, - `u`.`mgray` = `u`.`mgray` - `i`.`ggray`, - `u`.`mdark` = `u`.`mdark` - `i`.`gdark`, - `u`.`ubron1` = `u`.`ubron1` - `i`.`bron1`, - `u`.`ubron2` = `u`.`ubron2` - `i`.`bron2`, - `u`.`ubron3` = `u`.`ubron3` - `i`.`bron3`, - `u`.`ubron4` = `u`.`ubron4` - `i`.`bron4`, - `u`.`fkrit` = `u`.`fkrit` - `i`.`mfkrit`, - `u`.`fakrit` = `u`.`fakrit` - `i`.`mfakrit`, - `u`.`fuvorot` = `u`.`fuvorot` - `i`.`mfuvorot`, - `u`.`fauvorot` = `u`.`fauvorot` - `i`.`mfauvorot`, - `u`.`uminu` = `u`.`uminu` - `i`.`minu`, - `u`.`umaxu` = `u`.`umaxu` - `i`.`maxu` - WHERE `i`.`id` = `u`.?f AND `i`.`dressed` = 1 AND `i`.`owner` = ?i AND u.id = ?i', $slot1, $slot1, $user->getId(), $user->getId())) { - db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $user->getId()); - } - - $wear_raw = db::c()->query('SELECT * FROM `inventory` where `owner` = ?i AND `dressed` = 1', $user->getId()); - while ($wear_list = $wear_raw->fetch_assoc()) { - $wear_arr[] = $wear_list['prototype']; - } - - $item['id'] = $user->$slot1; - - $get_pro = db::c()->query('SELECT * FROM `inventory` where `id` = ?i', $item['id'])->fetch_assoc(); - ///////////////////// - $sets_items = db::c()->query('SELECT * FROM `item_sets`'); - - //для каждого комплекта - while ($items_in_set = $sets_items->fetch_assoc()) { - $checker = 0; - $temp_is = explode(",", $items_in_set['prot_id']); - $set_id = $items_in_set['set_id']; - - //если прото в комплекте и не одет - if (in_array($get_pro['prototype'], $temp_is) && (!in_array($get_pro['prototype'], $wear_arr))) { - $checker = 1; - - //для каждого одетого предмета - foreach ($temp_is as $check_proto) { - if ($check_proto != $get_pro['prototype'] && !in_array($check_proto, $wear_arr)) { - $checker = 0; - } - } - } - - - // - if (($checker == 1) && (!in_array($get_pro['prototype'], $wear_arr))) { - db::c()->query('UPDATE `users` as `u`, `item_sets` as `s` SET - `u`.`uminu` = `u`.`uminu` - `s`.`minu`, - `u`.`umaxu` = `u`.`umaxu` - `s`.`maxu`, - `u`.`sila = `u`.`sila - `s`.`gsila`, - `u`.`lovk = `u`.`lovk - `s`.`glovk`, - `u`.`inta = `u`.`inta - `s`.`ginta`, - `u`.`intel = `u`.`intel - `s`.`gintel`, - `u`.`maxhp = `u`.`maxhp - `s`.`ghp`, - `u`.`maxmana = `u`.`maxmana - `s`.`gmana`, - `u`.`fkrit = `u`.`fkrit - `s`.`mfkrit`, - `u`.`fakrit = `u`.`fakrit - `s`.`mfakrit`, - `u`.`fuvorot = `u`.`fuvorot - `s`.`mfuvorot`, - `u`.`fauvorot = `u`.`fauvorot - `s`.`mfauvorot`, - `u`.`noj = `u`.`noj - `s`.`gnoj`, - `u`.`topor = `u`.`topor - `s`.`gtopor`, - `u`.`dubina = `u`.`dubina - `s`.`gdubina`, - `u`.`mec = `u`.`mec - `s`.`gmech`, - `u`.`ubron1 = `u`.`ubron1 - `s`.`bron1`, - `u`.`ubron2 = `u`.`ubron2 - `s`.`bron2`, - `u`.`ubron3 = `u`.`ubron3 - `s`.`bron3`, - `u`.`ubron4 = `u`.`ubron4 - `s`.`bron4`, - `u`.`mfire = `u`.`mfire - `s`.`gfire`, - `u`.`mwater = `u`.`mwater - `s`.`gwater`, - `u`.`mair = `u`.`mair - `s`.`gair`, - `u`.`mearth = `u`.`mearth - `s`.`gearth`, - `u`.`mlight = `u`.`mlight - `s`.`glight`, - `u`.`mgray = `u`.`mgray - `s`.`ggray` - WHERE - `u`.`id` = ?i AND `s`.`set_id`= ?i', $user->getId(), $set_id); - } - } - return true; -} - #15 function ref_drop() { diff --git a/labirint.php b/labirint.php index 2448400..6825a00 100644 --- a/labirint.php +++ b/labirint.php @@ -142,7 +142,8 @@ if (isset($_POST['exit'])) { } $dresed = mysql_query('SELECT `id`, `type` FROM `inventory` WHERE `dressed` = 1 AND `laba` = 2 AND `owner` = "' . $user['id'] . '"'); while ($pl = mysql_fetch_array($dresed)) { - dropitemid($pl['type'], $user['id']); + $item = new \Battles\DressedItems($user['id']); + $item->undressItem($pl['type']); } mysql_query('DELETE FROM `inventory` WHERE `laba` > 0 AND `owner` = "' . $user['id'] . '"'); mysql_query("UPDATE `users`, `online` SET `users`.`room` = '1051', `online`.`room` = '1051', `users`.`x` = '0', `users`.`y` = '0', `users`.`laba` = '0' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '" . $user['id'] . "'"); @@ -291,7 +292,8 @@ if ($user['y'] >= count($map_d) - 2) { } $dresed = mysql_query('SELECT `id`, `type` FROM `inventory` WHERE `dressed` = 1 AND `laba` = 2 AND `owner` = "' . $user['id'] . '"'); while ($pl = mysql_fetch_array($dresed)) { - dropitemid($pl['type'], $user['id']); + $item = new \Battles\DressedItems($user['id']); + $item->undressItem($pl['type']); } mysql_query('UPDATE `inventory` SET `laba` = 0 WHERE `laba` = 1 AND `owner` = "' . $user['id'] . '"'); mysql_query('DELETE FROM `inventory` WHERE `laba` = 2 AND `owner` = "' . $user['id'] . '"'); From ac3a6ab4d2dd4cda7190ff2b551afe594b2cea32 Mon Sep 17 00:00:00 2001 From: lopar Date: Thu, 11 Mar 2021 20:42:36 +0200 Subject: [PATCH 17/28] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=20=D0=B8=20=D1=83=D0=BD=D0=B8=D1=84=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8?= =?UTF-8?q?=20=D1=81=D0=BD=D1=8F=D1=82=D0=B8=D1=8F=20=D0=BF=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=BC=D0=B5=D1=82=D0=BE=D0=B2=20=D0=B2=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D1=81=20DressedItems.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/edit_user.php | 7 +- cave.php | 6 +- classes/Battles/DressedItems.php | 5 +- cronjobs/cron_bots_battle.php | 6 +- functions.php | 269 +------------------------------ labirint.php | 6 +- 6 files changed, 21 insertions(+), 278 deletions(-) diff --git a/admin/edit_user.php b/admin/edit_user.php index 280e8eb..b9720fa 100644 --- a/admin/edit_user.php +++ b/admin/edit_user.php @@ -37,10 +37,11 @@ if (isset($_SESSION['player_id'])) { if ($del) { $itemdel = db::c()->query('SELECT item_type, dressed_slot FROM inventory WHERE id=?i', $del)->fetch_assoc(); if ($itemdel['dressed_slot'] == 1) { - dropitem($itemdel['item_type']); + $item = new \Battles\DressedItems($del); + $item->undressItem($itemdel['item_type']); if ($itemdel['item_type'] == 5) { - dropitem(6); - dropitem(7); + $item->undressItem(6); + $item->undressItem(7); } } db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $del); diff --git a/cave.php b/cave.php index bfba725..f684eb0 100644 --- a/cave.php +++ b/cave.php @@ -487,7 +487,8 @@ if (@$_GET['kill'] && $user['id'] == $user['caveleader'] && $_GET['kill'] != $us while ($rec = mysql_fetch_assoc($r)) { $slot = getslot($rec['id'], $usr); if ($slot) { - dropitemid(0, $v['user'], $slot); + $item = new \Battles\DressedItems($v['user']); + $item->undressItem($slot); } } mysql_query("DELETE FROM `inventory` WHERE `owner` = '$v[user]' AND `foronetrip` = 1"); @@ -898,7 +899,8 @@ if (@$_GET['exit']) { while ($rec = mysql_fetch_assoc($r)) { $slot = getslot($rec['id']); if ($slot) { - dropitemid(0, $user['id'], $slot); + $item = new \Battles\DressedItems($user['id']); + $item->undressItem($slot); } } mysql_query("DELETE FROM `inventory` WHERE `owner` = '$user[id]' AND `foronetrip` = 1"); diff --git a/classes/Battles/DressedItems.php b/classes/Battles/DressedItems.php index b429f08..b8a8644 100644 --- a/classes/Battles/DressedItems.php +++ b/classes/Battles/DressedItems.php @@ -8,6 +8,7 @@ namespace Battles; use Battles\Database\DBPDO; +use stdClass; class DressedItems { @@ -30,10 +31,10 @@ class DressedItems return self::$db->fetch('SELECT *, COUNT(1) AS count FROM inventory WHERE owner_id = ? AND dressed_slot = ?', [$ownerId, $itemSlot]); } - public function getItemsInSlots(): \stdClass + public function getItemsInSlots(): stdClass { $items = self::$db->ofetchALL('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot > 0', $this->USERID); - $this->dressedItem = new \stdClass(); + $this->dressedItem = new stdClass(); foreach ($items as $item) { $i = $item->dressed_slot; $this->dressedItem->$i = $item; diff --git a/cronjobs/cron_bots_battle.php b/cronjobs/cron_bots_battle.php index ad49089..5dede9b 100644 --- a/cronjobs/cron_bots_battle.php +++ b/cronjobs/cron_bots_battle.php @@ -486,7 +486,8 @@ class fbattle $inv_broken = mysql_query("SELECT * FROM `inventory` WHERE `type` != 12 AND `dressed` = 1 AND ((`maxdur` <= `duration`) OR (`dategoden` > 0 AND `dategoden` <= '" . time() . "')) AND `owner` = '{$v}'"); while ($br = mysql_fetch_array($inv_broken)) { - dropitemid($br['type'], $v); + $item = new \Battles\DressedItems($v); + $item->undressItem($br['type']); } $its = mysql_query("SELECT `id` FROM `inventory` WHERE `dressed` = 0 AND ((`maxdur` <= `duration`) OR (`dategoden` > 0 AND `dategoden` <= '" . time() . "')) AND `owner` = '{$v}'"); @@ -573,7 +574,8 @@ class fbattle $this->AddToLog('' . date("H:i") . ' ' . Nick::id($v)->short() . ' получил повреждение: ' . $tr . '
'); $inv_broken = mysql_query("SELECT `id`, `type`, `dressed`, `duration`, `maxdur`, `dategoden`, `owner` FROM `inventory` WHERE `type` != 12 AND `dressed` = 1 AND ((`maxdur` <= `duration`) OR (`dategoden` > 0 AND `dategoden` <= '" . time() . "')) AND `owner` = '{$v}'"); while ($br = mysql_fetch_array($inv_broken)) { - dropitemid($br['type'], $v); + $item = new \Battles\DressedItems($v); + $item->undressItem($br['type']); } } } diff --git a/functions.php b/functions.php index b07cb06..8dbccff 100644 --- a/functions.php +++ b/functions.php @@ -454,272 +454,6 @@ function undressall($user_id) db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?i', $user_id); } -function dropitemid($slot, $id) -{ - global $user; - switch ($slot) { - case 1: - $slot1 = 'sergi'; - break; - case 2: - $slot1 = 'kulon'; - break; - case 3: - $slot1 = 'weap'; - break; - case 4: - $slot1 = 'bron'; - break; - case 5: - $slot1 = 'r1'; - break; - case 6: - $slot1 = 'r2'; - break; - case 7: - $slot1 = 'r3'; - break; - case 8: - $slot1 = 'helm'; - break; - case 9: - $slot1 = 'perchi'; - break; - case 10: - $slot1 = 'shit'; - break; - case 11: - $slot1 = 'boots'; - break; - case 12: - $slot1 = 'm1'; - break; - case 13: - $slot1 = 'm2'; - break; - case 14: - $slot1 = 'm3'; - break; - case 15: - $slot1 = 'm4'; - break; - case 16: - $slot1 = 'm5'; - break; - case 17: - $slot1 = 'm6'; - break; - case 18: - $slot1 = 'm7'; - break; - case 19: - $slot1 = 'm8'; - break; - case 20: - $slot1 = 'm9'; - break; - case 21: - $slot1 = 'm10'; - break; - case 22: - $slot1 = 'rybax'; - break; - case 23: - $slot1 = 'plaw'; - break; - default: - $slot1 = ''; - break; - } - $checkid = db::c()->query('SELECT 1 FROM `users` WHERE `id` = ?i', $id); - if ($checkid->getNumRows()) { - if (mysql_query('UPDATE `users`, `inventory` SET `users`.`' . $slot1 . '` = 0, `inventory`.`dressed` = 0, `users`.`sila` = `users`.`sila` - `inventory`.`gsila`, `users`.`lovk` = `users`.`lovk` - `inventory`.`glovk`, `users`.`inta` = `users`.`inta` - `inventory`.`ginta`, `users`.`intel` = `users`.`intel` - `inventory`.`gintel`, `users`.`maxhp` = `users`.`maxhp` - `inventory`.`ghp`, `users`.`noj` = `users`.`noj` - `inventory`.`gnoj`, `users`.`topor` = `users`.`topor` - `inventory`.`gtopor`, `users`.`dubina` = `users`.`dubina` - `inventory`.`gdubina`, `users`.`mec` = `users`.`mec` - `inventory`.`gmech`, `users`.`mfire` = `users`.`mfire` - `inventory`.`gfire`, `users`.`mwater` = `users`.`mwater` - `inventory`.`gwater`, `users`.`mair` = `users`.`mair` - `inventory`.`gair`, `users`.`mearth` = `users`.`mearth` - `inventory`.`gearth`, `users`.`mlight` = `users`.`mlight` - `inventory`.`glight`, `users`.`mgray` = `users`.`mgray` - `inventory`.`ggray`, `users`.`mdark` = `users`.`mdark` - `inventory`.`gdark`, `users`.`fkrit` = `users`.`fkrit` - `inventory`.`mfkrit`, `users`.`fakrit` = `users`.`fakrit` - `inventory`.`mfakrit`, `users`.`fuvorot` = `users`.`fuvorot` - `inventory`.`mfuvorot`, `users`.`fauvorot` = `users`.`fauvorot` - `inventory`.`mfauvorot`, `users`.`ubron1` = `users`.`ubron1` - `inventory`.`bron1`, `users`.`ubron2` = `users`.`ubron2` - `inventory`.`bron2`, `users`.`ubron3` = `users`.`ubron3` - `inventory`.`bron3`, `users`.`ubron4` = `users`.`ubron4` - `inventory`.`bron4`, `users`.`uminu` = `users`.`uminu` - `inventory`.`minu`, `users`.`umaxu` = `users`.`umaxu` - `inventory`.`maxu` WHERE `inventory`.`id` = `users`.`' . $slot1 . '` AND `inventory`.`dressed` = 1 AND `inventory`.`owner` = "' . $id . '" AND `users`.`id` = "' . $id . '"')) { - db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $id); - $user->$slot1 = 0; - } - return true; - } else { - return false; - } -} - -// снять предмет -function dropitem($slot) -{ - global $user; - $wear_arr = []; - switch ($slot) { - case 1: - $slot1 = 'sergi'; - break; - case 2: - $slot1 = 'kulon'; - break; - case 3: - $slot1 = 'weap'; - break; - case 4: - $slot1 = 'bron'; - break; - case 5: - $slot1 = 'r1'; - break; - case 6: - $slot1 = 'r2'; - break; - case 7: - $slot1 = 'r3'; - break; - case 8: - $slot1 = 'helm'; - break; - case 9: - $slot1 = 'perchi'; - break; - case 10: - $slot1 = 'shit'; - break; - case 11: - $slot1 = 'boots'; - break; - case 12: - $slot1 = 'm1'; - break; - case 13: - $slot1 = 'm2'; - break; - case 14: - $slot1 = 'm3'; - break; - case 15: - $slot1 = 'm4'; - break; - case 16: - $slot1 = 'm5'; - break; - case 17: - $slot1 = 'm6'; - break; - case 18: - $slot1 = 'm7'; - break; - case 19: - $slot1 = 'm8'; - break; - case 20: - $slot1 = 'm9'; - break; - case 21: - $slot1 = 'm10'; - break; - case 22: - $slot1 = 'rybax'; - break; - case 23: - $slot1 = 'plaw'; - break; - default: - $slot1 = ''; - break; - } - - if (db::c()->query('UPDATE `users` as `u`, `inventory` as `i` SET `u`.?f = 0, `i`.`dressed` = 0, - `u`.`sila` = `u`.`sila` - `i`.`gsila`, - `u`.`lovk` = `u`.`lovk` - `i`.`glovk`, - `u`.`inta` = `u`.`inta` - `i`.`ginta`, - `u`.`intel` = `u`.`intel` - `i`.`gintel`, - `u`.`maxhp` = `u`.`maxhp` - `i`.`ghp`, - `u`.`noj` = `u`.`noj` - `i`.`gnoj`, - `u`.`topor` = `u`.`topor` - `i`.`gtopor`, - `u`.`dubina` = `u`.`dubina` - `i`.`gdubina`, - `u`.`mec` = `u`.`mec` - `i`.`gmech`, - `u`.`mfire` = `u`.`mfire` - `i`.`gfire`, - `u`.`mwater` = `u`.`mwater` - `i`.`gwater`, - `u`.`mair` = `u`.`mair` - `i`.`gair`, - `u`.`mearth` = `u`.`mearth` - `i`.`gearth`, - `u`.`mlight` = `u`.`mlight` - `i`.`glight`, - `u`.`mgray` = `u`.`mgray` - `i`.`ggray`, - `u`.`mdark` = `u`.`mdark` - `i`.`gdark`, - `u`.`ubron1` = `u`.`ubron1` - `i`.`bron1`, - `u`.`ubron2` = `u`.`ubron2` - `i`.`bron2`, - `u`.`ubron3` = `u`.`ubron3` - `i`.`bron3`, - `u`.`ubron4` = `u`.`ubron4` - `i`.`bron4`, - `u`.`fkrit` = `u`.`fkrit` - `i`.`mfkrit`, - `u`.`fakrit` = `u`.`fakrit` - `i`.`mfakrit`, - `u`.`fuvorot` = `u`.`fuvorot` - `i`.`mfuvorot`, - `u`.`fauvorot` = `u`.`fauvorot` - `i`.`mfauvorot`, - `u`.`uminu` = `u`.`uminu` - `i`.`minu`, - `u`.`umaxu` = `u`.`umaxu` - `i`.`maxu` - WHERE `i`.`id` = `u`.?f AND `i`.`dressed` = 1 AND `i`.`owner` = ?i AND u.id = ?i', $slot1, $slot1, $user->getId(), $user->getId())) { - db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $user->getId()); - } - - $wear_raw = db::c()->query('SELECT * FROM `inventory` where `owner` = ?i AND `dressed` = 1', $user->getId()); - while ($wear_list = $wear_raw->fetch_assoc()) { - $wear_arr[] = $wear_list['prototype']; - } - - $item['id'] = $user->$slot1; - - $get_pro = db::c()->query('SELECT * FROM `inventory` where `id` = ?i', $item['id'])->fetch_assoc(); - ///////////////////// - $sets_items = db::c()->query('SELECT * FROM `item_sets`'); - - //для каждого комплекта - while ($items_in_set = $sets_items->fetch_assoc()) { - $checker = 0; - $temp_is = explode(",", $items_in_set['prot_id']); - $set_id = $items_in_set['set_id']; - - //если прото в комплекте и не одет - if (in_array($get_pro['prototype'], $temp_is) && (!in_array($get_pro['prototype'], $wear_arr))) { - $checker = 1; - - //для каждого одетого предмета - foreach ($temp_is as $check_proto) { - if ($check_proto != $get_pro['prototype'] && !in_array($check_proto, $wear_arr)) { - $checker = 0; - } - } - } - - - // - if (($checker == 1) && (!in_array($get_pro['prototype'], $wear_arr))) { - db::c()->query('UPDATE `users` as `u`, `item_sets` as `s` SET - `u`.`uminu` = `u`.`uminu` - `s`.`minu`, - `u`.`umaxu` = `u`.`umaxu` - `s`.`maxu`, - `u`.`sila = `u`.`sila - `s`.`gsila`, - `u`.`lovk = `u`.`lovk - `s`.`glovk`, - `u`.`inta = `u`.`inta - `s`.`ginta`, - `u`.`intel = `u`.`intel - `s`.`gintel`, - `u`.`maxhp = `u`.`maxhp - `s`.`ghp`, - `u`.`maxmana = `u`.`maxmana - `s`.`gmana`, - `u`.`fkrit = `u`.`fkrit - `s`.`mfkrit`, - `u`.`fakrit = `u`.`fakrit - `s`.`mfakrit`, - `u`.`fuvorot = `u`.`fuvorot - `s`.`mfuvorot`, - `u`.`fauvorot = `u`.`fauvorot - `s`.`mfauvorot`, - `u`.`noj = `u`.`noj - `s`.`gnoj`, - `u`.`topor = `u`.`topor - `s`.`gtopor`, - `u`.`dubina = `u`.`dubina - `s`.`gdubina`, - `u`.`mec = `u`.`mec - `s`.`gmech`, - `u`.`ubron1 = `u`.`ubron1 - `s`.`bron1`, - `u`.`ubron2 = `u`.`ubron2 - `s`.`bron2`, - `u`.`ubron3 = `u`.`ubron3 - `s`.`bron3`, - `u`.`ubron4 = `u`.`ubron4 - `s`.`bron4`, - `u`.`mfire = `u`.`mfire - `s`.`gfire`, - `u`.`mwater = `u`.`mwater - `s`.`gwater`, - `u`.`mair = `u`.`mair - `s`.`gair`, - `u`.`mearth = `u`.`mearth - `s`.`gearth`, - `u`.`mlight = `u`.`mlight - `s`.`glight`, - `u`.`mgray = `u`.`mgray - `s`.`ggray` - WHERE - `u`.`id` = ?i AND `s`.`set_id`= ?i', $user->getId(), $set_id); - } - } - return true; -} - #15 function ref_drop() { @@ -766,7 +500,8 @@ function ref_drop() $user = db::c()->query('SELECT `sergi`,`kulon`,`weap`,`bron`,`r1`,`r2`,`r3`,`helm`,`perchi`,`shit`,`boots`,`m1`,`m2`,`m3`,`m4`,`m5`,`m6`,`m7`,`m8`,`m9`,`m10` FROM `users` WHERE id = ?i', $_SESSION['uid'])->fetch_assoc(); for ($i = 0; $i <= 20; $i++) { if ($user[$slot[$i]] && !derj($user[$slot[$i]])) { - dropitem($i + 1); + $item = new \Battles\DressedItems($_SESSION['uid']); + $item->undressItem($i + 1); $user[$slot[$i]] = null; } } diff --git a/labirint.php b/labirint.php index 2448400..6825a00 100644 --- a/labirint.php +++ b/labirint.php @@ -142,7 +142,8 @@ if (isset($_POST['exit'])) { } $dresed = mysql_query('SELECT `id`, `type` FROM `inventory` WHERE `dressed` = 1 AND `laba` = 2 AND `owner` = "' . $user['id'] . '"'); while ($pl = mysql_fetch_array($dresed)) { - dropitemid($pl['type'], $user['id']); + $item = new \Battles\DressedItems($user['id']); + $item->undressItem($pl['type']); } mysql_query('DELETE FROM `inventory` WHERE `laba` > 0 AND `owner` = "' . $user['id'] . '"'); mysql_query("UPDATE `users`, `online` SET `users`.`room` = '1051', `online`.`room` = '1051', `users`.`x` = '0', `users`.`y` = '0', `users`.`laba` = '0' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '" . $user['id'] . "'"); @@ -291,7 +292,8 @@ if ($user['y'] >= count($map_d) - 2) { } $dresed = mysql_query('SELECT `id`, `type` FROM `inventory` WHERE `dressed` = 1 AND `laba` = 2 AND `owner` = "' . $user['id'] . '"'); while ($pl = mysql_fetch_array($dresed)) { - dropitemid($pl['type'], $user['id']); + $item = new \Battles\DressedItems($user['id']); + $item->undressItem($pl['type']); } mysql_query('UPDATE `inventory` SET `laba` = 0 WHERE `laba` = 1 AND `owner` = "' . $user['id'] . '"'); mysql_query('DELETE FROM `inventory` WHERE `laba` = 2 AND `owner` = "' . $user['id'] . '"'); From c54b97681b422ea2360f98aca621f40eb9e411ec Mon Sep 17 00:00:00 2001 From: lopar Date: Thu, 11 Mar 2021 20:58:38 +0200 Subject: [PATCH 18/28] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=20=D0=B8=20=D1=83=D0=BD=D0=B8=D1=84=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8?= =?UTF-8?q?=20=D1=81=D0=BD=D1=8F=D1=82=D0=B8=D1=8F=20=D0=B2=D1=81=D0=B5?= =?UTF-8?q?=D1=85=20=D0=BF=D1=80=D0=B5=D0=B4=D0=BC=D0=B5=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=B2=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20DressedItems.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/edit_user.php | 2 +- classes/Battles/DressedItems.php | 4 ++++ cronjobs/cron_tower.php | 10 +++++----- functions.php | 7 +------ magic/attackk.php | 4 ++-- magic/attackk_close.php | 4 ++-- magic/attackk_open.php | 4 ++-- magic/down.php | 2 +- main.php | 2 +- towerin.php | 4 ++-- towerstamp.php | 2 +- zayavka.php | 4 ++-- 12 files changed, 24 insertions(+), 25 deletions(-) diff --git a/admin/edit_user.php b/admin/edit_user.php index b9720fa..e36414e 100644 --- a/admin/edit_user.php +++ b/admin/edit_user.php @@ -25,7 +25,7 @@ if ($player) { unset($row); } if ($undress_char) { - undressall($_SESSION['player_id']); + \Battles\DressedItems::undressAllItems($_SESSION['player_id']); } if ($end) { unset($_SESSION['player_id']); diff --git a/classes/Battles/DressedItems.php b/classes/Battles/DressedItems.php index b8a8644..692d0b1 100644 --- a/classes/Battles/DressedItems.php +++ b/classes/Battles/DressedItems.php @@ -98,4 +98,8 @@ SQL; self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ? AND owner_id = ?', [$slot_id, $this->USERID]); } } + public static function undressAllItems($user_id) + { + return self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?', $user_id); + } } \ No newline at end of file diff --git a/cronjobs/cron_tower.php b/cronjobs/cron_tower.php index bbf4a34..02d3c37 100644 --- a/cronjobs/cron_tower.php +++ b/cronjobs/cron_tower.php @@ -17,7 +17,7 @@ if (!$tr && $turnirstart[0] <= time() && $dd[0] >= 2) { while ($row = mysql_fetch_array($data)) { $pers = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $row[0] . '" LIMIT 1')); - undressall($pers['id']); + \Battles\DressedItems::undressAllItems($pers['id']); ### mysql_query('UPDATE `inventory` SET `owner` = "' . ($pers['id'] + _BOTSEPARATOR_) . '" WHERE `owner` = "' . $pers['id'] . '"'); ### @@ -88,9 +88,9 @@ if (!$tr && $turnirstart[0] <= time() && $dd[0] >= 2) { } // Боты: Архивариус и два помощника. - undressall(233); - undressall(234); - undressall(235); + \Battles\DressedItems::undressAllItems(233); + \Battles\DressedItems::undressAllItems(234); + \Battles\DressedItems::undressAllItems(235); mysql_query("DELETE FROM `inventory` WHERE `owner` = 233"); mysql_query("DELETE FROM `inventory` WHERE `owner` = 234"); @@ -158,7 +158,7 @@ if ($tur_data['endtime'] < time() && $tur_data['id']) { $list = mysql_query("SELECT * FROM `users` WHERE `in_tower` = 1"); while ($u = mysql_fetch_array($list)) { - undressall($u['id']); + \Battles\DressedItems::undressAllItems($u['id']); $rep = mysql_query("SELECT * FROM `inventory` WHERE `owner` = '" . $u['id'] . "' AND `bs` = 1"); while ($r = mysql_fetch_array($rep)) { mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('" . $r['prototype'] . "', '" . $r['name'] . "', '" . $r['img'] . "', '" . $u['room'] . "')"); diff --git a/functions.php b/functions.php index 8dbccff..6ae36aa 100644 --- a/functions.php +++ b/functions.php @@ -109,7 +109,7 @@ $var_map = [ function get_out($u) { $pers = db::c()->query('SELECT * FROM users WHERE id = ?i', $u)->fetch_assoc_array(); - undressall($pers['id']); + \Battles\DressedItems::undressAllItems($pers['id']); db::c()->query('UPDATE inventory SET owner = ?i WHERE owner = ?i', $pers['id'], $pers['id'] + _BOTSEPARATOR_); ### $row = db::c()->query('SELECT * FROM `effects` WHERE `owner` = ?i', $pers['id'] + _BOTSEPARATOR_); @@ -449,11 +449,6 @@ function addActions($time, $vars, $vls, $uid) return $ins; } -function undressall($user_id) -{ - db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?i', $user_id); -} - #15 function ref_drop() { diff --git a/magic/attackk.php b/magic/attackk.php index d75171d..0624b9e 100644 --- a/magic/attackk.php +++ b/magic/attackk.php @@ -117,8 +117,8 @@ if ($user['battle'] > 0) { mysql_query("INSERT INTO `bots` (`name`,`prototype`,`battle`,`hp`) values ('Архивариус','83','','" . $jert['hp'] . "');"); $jert['id'] = mysql_insert_id(); } - undressall($jert['id']); - undressall($user['id']); + \Battles\DressedItems::undressAllItems($jert['id']); + \Battles\DressedItems::undressAllItems($user['id']); $teams = []; $teams[$user['id']][$jert['id']] = [0, 0, time()]; $teams[$jert['id']][$user['id']] = [0, 0, time()]; diff --git a/magic/attackk_close.php b/magic/attackk_close.php index 32c66cd..983e5d2 100644 --- a/magic/attackk_close.php +++ b/magic/attackk_close.php @@ -104,8 +104,8 @@ elseif (!$us['online']) { } if(rand(0,100)<80) - undressall($jert['id']); - undressall($user['id']); + \Battles\DressedItems::undressAllItems($jert['id']); + \Battles\DressedItems::undressAllItems($user['id']); $teams = array(); $teams[$user['id']][$jert['id']] = array(0,0,time()); $teams[$jert['id']][$user['id']] = array(0,0,time()); diff --git a/magic/attackk_open.php b/magic/attackk_open.php index 829370a..d5638fa 100644 --- a/magic/attackk_open.php +++ b/magic/attackk_open.php @@ -104,8 +104,8 @@ if ($user['battle'] > 0) { } if(rand(0,100)<80) - undressall($jert['id']); - undressall($user['id']); + \Battles\DressedItems::undressAllItems($jert['id']); + \Battles\DressedItems::undressAllItems($user['id']); $teams = array(); $teams[$user['id']][$jert['id']] = array(0,0,time()); $teams[$jert['id']][$user['id']] = array(0,0,time()); diff --git a/magic/down.php b/magic/down.php index edcc5e3..3b5b218 100644 --- a/magic/down.php +++ b/magic/down.php @@ -3,7 +3,7 @@ if ($user['battle'] > 0) { echo "Не в бою..."; } elseif (rand(1, 100) != 1) { - undressall($user['id']); + \Battles\DressedItems::undressAllItems($user['id']); $user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1;")); if (empty($_SESSION['uid'])) { header("Location: index.php"); diff --git a/main.php b/main.php index 04e240b..3da9ecf 100644 --- a/main.php +++ b/main.php @@ -74,7 +74,7 @@ if ($edit) { usemagic($use, $useTarget); } if ($undress) { - undressall($_SESSION['uid']); + \Battles\DressedItems::undressAllItems($_SESSION['uid']); } } diff --git a/towerin.php b/towerin.php index a358828..998619e 100644 --- a/towerin.php +++ b/towerin.php @@ -192,7 +192,7 @@ if ($rhar[$user->getRoom()][$_GET['path']] > 0 && $_GET['path'] < 5 && $_GET['pa $list = mysql_query("SELECT * FROM `users` WHERE `in_tower` = 1 AND `battle` = 0"); while ($u = mysql_fetch_array($list)) { if ($u['hp'] <= 0) { - undressall($u['id']); + \Battles\DressedItems::undressAllItems($u['id']); $rep = mysql_query("SELECT * FROM `inventory` WHERE `owner` = '" . $u['id'] . "' AND `bs` = 1"); while ($r = mysql_fetch_array($rep)) { mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('" . $r['prototype'] . "', '" . $r['name'] . "', '" . $r['img'] . "', '" . $u['room'] . "')"); @@ -226,7 +226,7 @@ while ($u = mysql_fetch_array($list)) { if (($kol_pl + $ls) < 2 && ($tur_data['start_time'] + 60) <= time()) { $tur = mysql_fetch_array(mysql_query("SELECT * FROM `deztow_turnir` WHERE `active` = TRUE LIMIT 1")); - undressall($user['id']); + \Battles\DressedItems::undressAllItems($user['id']); $rep = mysql_query("SELECT * FROM `inventory` WHERE `owner` = '" . $user['id'] . "' AND `bs` = 1"); while ($r = mysql_fetch_array($rep)) { mysql_query("INSERT `deztow_items` (`iteam_id`, `name`, `img`, `room`) VALUES ('" . $r['prototype'] . "', '" . $r['name'] . "', '" . $r['img'] . "', '" . $user->getRoom() . "');"); diff --git a/towerstamp.php b/towerstamp.php index 1eac2cb..3eaf2f9 100644 --- a/towerstamp.php +++ b/towerstamp.php @@ -8,7 +8,7 @@ if ($user->getRoom() != 31) { if (isset($effect['id'])) { exit('Для распределения статов на Вас не дожно быть никаких эффектов'); } -undressall($user['id']); +\Battles\DressedItems::undressAllItems($user['id']); if ((int)$_GET['delsn'] > 0) { mysql_query("DELETE FROM `deztow_charstams` WHERE `id` = '" . (int)$_GET['delsn'] . "' AND `name` = '" . $_GET['ddname'] . "' AND `owner` = '" . (int)$user['id'] . "' LIMIT 1"); diff --git a/zayavka.php b/zayavka.php index 88bad11..73a8d50 100644 --- a/zayavka.php +++ b/zayavka.php @@ -421,11 +421,11 @@ class Zayavka if ($z['type'] == 4 || $z['type'] == 5) { foreach ($z['team1'] as $k => $v) { - undressall($v); + \Battles\DressedItems::undressAllItems($v); } foreach ($z['team2'] as $k => $v) { - undressall($v); + \Battles\DressedItems::undressAllItems($v); } } From 4164046edbfbdb11300938e746a2db1fa0004282 Mon Sep 17 00:00:00 2001 From: lopar Date: Thu, 11 Mar 2021 21:20:36 +0200 Subject: [PATCH 19/28] =?UTF-8?q?=D0=9E=D1=82=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D1=83=D0=BC=D0=BC=D0=B0?= =?UTF-8?q?=D1=80=D0=BD=D1=8B=D1=85=20=D1=81=D1=82=D0=B0=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=20=D1=83=D0=B5=D1=85=D0=B0=D0=BB=D0=BE=20=D0=B8=D0=B7=20Dresse?= =?UTF-8?q?dItems=20=D0=B2=20UserStats.=20#18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/DressedItems.php | 44 -------------------------------- classes/Battles/UserStats.php | 23 +++++------------ main.php | 11 ++++---- 3 files changed, 11 insertions(+), 67 deletions(-) diff --git a/classes/Battles/DressedItems.php b/classes/Battles/DressedItems.php index 692d0b1..34dd8f3 100644 --- a/classes/Battles/DressedItems.php +++ b/classes/Battles/DressedItems.php @@ -42,50 +42,6 @@ class DressedItems return $this->dressedItem; } - private function getBonuses(): array - { - $query = << 0 -SQL; - return self::$db->fetch($query, $this->USERID); - } - - public function getAccuracyBonus(): ?int - { - return self::getBonuses()['sum_accuracy'] ?? 0; - } - - public function getEvasionBonus(): ?int - { - return self::getBonuses()['sum_evasion'] ?? 0; - } - - public function getCriticalsBonus(): ?int - { - return self::getBonuses()['sum_criticals'] ?? 0; - } - - public function getMinPhysDamage(): ?int - { - return self::getBonuses()['sum_min_phys_damage']; - } - - public function getMaxPhysDamage(): ?int - { - return self::getBonuses()['sum_max_phys_damage']; - } - /** * Снимает с предмета статус одетого на персонажа в определённом слоте персонажа. * @param $slot_id - номер слота. diff --git a/classes/Battles/UserStats.php b/classes/Battles/UserStats.php index 09ce3d9..b1105e3 100644 --- a/classes/Battles/UserStats.php +++ b/classes/Battles/UserStats.php @@ -177,22 +177,6 @@ class UserStats extends User return $this->maxMana; } - /** - * @return int - */ - public function getMinDamage(): int - { - return $this->minDamage; - } - - /** - * @return int - */ - public function getMaxDamage(): int - { - return $this->maxDamage; - } - /** * @return int */ @@ -226,7 +210,12 @@ class UserStats extends User sum(greatest(intuition + (ifnull((select sum(add_intuition) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as intuition, sum(greatest(endurance + (ifnull((select sum(add_endurance) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as endurance, sum(greatest(intelligence + (ifnull((select sum(add_intelligence) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as intelligence, - sum(greatest(wisdom + (ifnull((select sum(add_wisdom) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as wisdom + sum(greatest(wisdom + (ifnull((select sum(add_wisdom) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as wisdom, + ifnull((select sum(add_accuracy) from inventory where dressed_slot != 0 and owner_id = $this->id), 0) as accuracy, + ifnull((select sum(add_evasion) from inventory where dressed_slot != 0 and owner_id = $this->id), 0) as evasion, + ifnull((select sum(add_criticals) from inventory where dressed_slot != 0 and owner_id = $this->id), 0) as criticals, + sum(greatest($this->minDamage + (ifnull((select sum(add_min_physical_damage) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as min_physical_damage, + sum(greatest($this->maxDamage + (ifnull((select sum(add_max_physical_damage) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as max_physical_damage from users where id = $this->id"; return self::$db->ofetch($query); } diff --git a/main.php b/main.php index 3da9ecf..157033f 100644 --- a/main.php +++ b/main.php @@ -82,7 +82,6 @@ if ($edit) { // Подготавливаем отображение инфы и предметов. $userInfo = new UserInfo($user->getId()); $userStats = new UserStats($user->getId()); -$getItemsBonuses = new DressedItems($user->getId()); $data = \Battles\Database\DBPDO::INIT()->ofetchAll('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND on_sale = 0', $user->getId()); $iteminfo = []; foreach ($data as $row) { @@ -400,11 +399,11 @@ Template::header('Игра');
Здоровье: getHealth() ?>
Пыль: getMana() ?>
- Уворот: getEvasionBonus() ?>
- Точность: getAccuracyBonus() ?>
- Шанс крита: getCriticalsBonus() ?>
- Урон: getMinDamage() + $getItemsBonuses->getMinPhysDamage() ?> - - getMaxDamage() + $getItemsBonuses->getMaxPhysDamage() ?>
+ Уворот: getFullStats()->evasion ?>
+ Точность: getFullStats()->accuracy ?>
+ Шанс крита: getFullStats()->criticals ?>
+ Урон: getFullStats()->min_physical_damage ?> + - getFullStats()->max_physical_damage ?>

Защита от огня: ??
Защита от воды: ??
From 591e896968781b4ac749f55a85e3c6adc150a502 Mon Sep 17 00:00:00 2001 From: lopar Date: Thu, 11 Mar 2021 21:47:52 +0200 Subject: [PATCH 20/28] =?UTF-8?q?=D0=9E=D1=82=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=8D=D1=84=D1=84=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D0=B2=20=D1=83=D0=B5=D1=85=D0=B0=D0=BB=D0=BE=20?= =?UTF-8?q?=D0=B2=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20UserInfo.=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/UserEffects.php | 36 +++++++++++++++++++++++++++++++++ classes/Battles/UserInfo.php | 19 +++++++++++++++++ functions.php | 34 ------------------------------- main.php | 2 +- 4 files changed, 56 insertions(+), 35 deletions(-) diff --git a/classes/Battles/UserEffects.php b/classes/Battles/UserEffects.php index 41ee6fc..1b864d3 100644 --- a/classes/Battles/UserEffects.php +++ b/classes/Battles/UserEffects.php @@ -49,4 +49,40 @@ trait UserEffects 1022 => 'невидимость', 9994 => 'Антидот/Путы (Эликсир?)', ]; + + public static $effectImage = [ + 1 => 'travma.gif', + 2 => 'magic/sleep.gif', + 3 => 'magic/sleepf.gif', + 4 => 'magic/haos.gif', + 5 => 'magic/obezl.gif', + 6 => 'expx15.gif', + 7 => 'euphoria.png', + 8 => 'sleep_obj.gif', + 10 => 'magic/chains.gif', + 11 => 'travma.gif', + 12 => 'travma.gif', + 13 => 'travma.gif', + 14 => 'travma.gif', + 20 => 'check.gif', + 21 => 'magic/al_neut_power.gif', + 22 => 'magic/fist_def.gif', + 201 => 'magic/defence.gif', + 202 => 'magic/devastate.gif', + 203 => 'magic/spell_luck.gif', + 215 => 'magic/wis_air_def1.gif', + 216 => 'magic/wis_air_def2.gif', + 217 => 'magic/wis_air_def3.gif', + 218 => 'magic/wis_earth_def1.gif', + 219 => 'magic/wis_earth_def2.gif', + 220 => 'magic/wis_earth_def3.gif', + 221 => 'magic/wis_fire_def1.gif', + 222 => 'magic/wis_fire_def2.gif', + 223 => 'magic/wis_fire_def3.gif', + 224 => 'magic/wis_water_def1.gif', + 225 => 'magic/wis_water_def2.gif', + 226 => 'magic/wis_water_def3.gif', + 227 => 'magic/attack_defence.gif', + 1022 => 'sh/hidden.gif', + ]; } \ No newline at end of file diff --git a/classes/Battles/UserInfo.php b/classes/Battles/UserInfo.php index 0794276..d097bce 100644 --- a/classes/Battles/UserInfo.php +++ b/classes/Battles/UserInfo.php @@ -1,5 +1,6 @@ '; } + public function showUserEffects(): string + { + $effs = DBPDO::INIT()->ofetchAll('SELECT * FROM users_effects WHERE owner_id = ?', $this->id); + $img = UserEffects::$effectImage; + $r = ''; + foreach ($effs as $effect) { + $timeleft = timeOut($effect->remaining_time - time()); + $r .= " +
+ {$effect->name} + {$effect->name} +
$timeleft
+
+ "; + } + return $r; + } + } \ No newline at end of file diff --git a/functions.php b/functions.php index 6ae36aa..1692a61 100644 --- a/functions.php +++ b/functions.php @@ -399,40 +399,6 @@ function timeOut($ttm) return $out; } -function show_eff_inf(int $u): string -{ - $img = [ - 1 => "travma.gif", 2 => "magic/sleep.gif", 3 => "magic/sleepf.gif", 4 => "magic/haos.gif", - 5 => "magic/obezl.gif", 6 => "expx15.gif", 7 => "euphoria.png", 8 => "sleep_obj.gif", - 10 => "magic/chains.gif", 11 => "travma.gif", 12 => "travma.gif", 13 => "travma.gif", - 14 => "travma.gif", 20 => "check.gif", 21 => "magic/al_neut_power.gif", 22 => "magic/fist_def.gif", - 201 => "magic/defence.gif", 202 => "magic/devastate.gif", 203 => "magic/spell_luck.gif", 215 => "magic/wis_air_def1.gif", - 216 => "magic/wis_air_def2.gif", 217 => "magic/wis_air_def3.gif", 218 => "magic/wis_earth_def1.gif", 219 => "magic/wis_earth_def2.gif", - 220 => "magic/wis_earth_def3.gif", 221 => "magic/wis_fire_def1.gif", 222 => "magic/wis_fire_def2.gif", 223 => "magic/wis_fire_def3.gif", - 224 => "magic/wis_water_def1.gif", 225 => "magic/wis_water_def2.gif", 226 => "magic/wis_water_def3.gif", 227 => "magic/attack_defence.gif", - 1022 => "sh/hidden.gif", - ]; - $r = ''; - - - $effs = DBPDO::INIT()->ofetchAll('SELECT * FROM users_effects WHERE owner_id = ?', $u); - - $i = 0; - while ($i < count($effs)) { - $timeleft = timeOut($effs[$i]->remaining_time - time()); - $r .= << - - {$effs[$i]->name} -
$timeleft
- -HTML; - $i++; - } - unset($i); - return $r; -} - /** * @param $time * @param $vars diff --git a/main.php b/main.php index 157033f..f74d294 100644 --- a/main.php +++ b/main.php @@ -362,7 +362,7 @@ Template::header('Игра');
Снять все
- getId()) ?> + showUserEffects() ?>

From 75a7b4125ec8345d8be6977f5e9f4fdc44d879b1 Mon Sep 17 00:00:00 2001 From: lopar Date: Sun, 14 Mar 2021 19:54:13 +0200 Subject: [PATCH 21/28] =?UTF-8?q?=D0=9E=D0=B4=D0=B5=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B5=D0=B4=D0=BC=D0=B5=D1=82=D0=B0?= =?UTF-8?q?=20=D1=83=D0=B5=D1=85=D0=B0=D0=BB=D0=BE=20=D0=B2=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D1=81.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/InventoryItem.php | 99 +++++++++++++++++++++++++++++-- main.php | 98 ++---------------------------- 2 files changed, 101 insertions(+), 96 deletions(-) diff --git a/classes/Battles/InventoryItem.php b/classes/Battles/InventoryItem.php index 9e5d193..6548988 100644 --- a/classes/Battles/InventoryItem.php +++ b/classes/Battles/InventoryItem.php @@ -1,15 +1,25 @@ present = $row['present']; - } + $this->owner_id = $row->owner_id; } public function printInfo() @@ -35,5 +45,86 @@ IMG; } } - public function printControls() {} + public function printControls() + { + /* Тут будут кнопки под картинкой. */ + } + + private function dressStatsChecks(): ?string + { + $checkStats = new UserStats($this->owner_id); + return + $this->need_strength > $checkStats->getFullStats()->strength + || $this->need_dexterity > $checkStats->getFullStats()->dexterity + || $this->need_intuition > $checkStats->getFullStats()->intuition + || $this->need_endurance > $checkStats->getFullStats()->endurance + || $this->need_intelligence > $checkStats->getFullStats()->intelligence + || $this->need_wisdom > $checkStats->getFullStats()->wisdom + ? true : null; + } + + /** + * Одевание предмета из инвентаря в слот. + * @return bool|string + */ + public function dressItem() + { + $db = new DBPDO(); + $itemInSlot = []; + if ($this->dressStatsChecks()) { + return self::REQUIREMENTS_NOT_MET; + } + // считаем сколько ОДЕТЫХ предметов в слоте в который мы хотим одеть предмет. 1=просто вещь 1-3=шашни с кольцами + // Count добавленный в первый запрос возвращает одну строку в любом случае. + // fetch возвращает одну строку в любом случае. + $weared = $db->ofetchAll('SELECT dressed_slot FROM inventory WHERE dressed_slot != 0 AND item_type = ? AND owner_id = ?', [$this->item_type, $this->owner_id]); + $wearedCount = $db->ofetch('select count(dressed_slot) as c from inventory where dressed_slot !=0 and item_type = ? and owner_id = ?', [$this->item_type, $this->owner_id]); + // Если в слоте есть предмет(ы), забиваем их массив одетых в слот предметов. + if ($wearedCount) { + foreach ($weared as $item) { + $itemInSlot[] = $item->dressed_slot; + } + } + if (in_array($this->item_type, [ + self::ITEM_TYPE_HELMET, self::ITEM_TYPE_ARMOR, self::ITEM_TYPE_LEGS, self::ITEM_TYPE_BOOTS, + self::ITEM_TYPE_GLOVES, self::ITEM_TYPE_WEAPON, self::ITEM_TYPE_SHIELD, self::ITEM_TYPE_BELT, + self::ITEM_TYPE_AMULET, + ])) { + //работаем с нормальными слотами + if ($wearedCount->c == 1) { + //если слот занят, снимаем старый предмет и одеваем новый предмет + DBPDO::INIT()->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ? AND owner_id = ?', [$itemInSlot[0], $this->owner_id]); + DBPDO::INIT()->execute('UPDATE inventory SET dressed_slot = item_type WHERE item_id = ? AND owner_id = ?', [$this->item_id, $this->owner_id]); + } elseif (!$wearedCount->c) { + //если слот пуст, одеваем новый предмет + DBPDO::INIT()->execute('UPDATE inventory SET dressed_slot = item_type WHERE item_id = ? AND owner_id = ?', [$this->item_id, $this->owner_id]); + } else { + /* проверка на переполнение слотов */ + $error = self::TOO_MANY_ITEMS_IN_SLOTS; + DressedItems::undressAllItems($this->owner_id); + } + } elseif ($this->item_type == self::ITEM_TYPE_RING) { + // работаем с кольцами + if ($wearedCount->c < 3) { + // Сравниваем массив колец и массив слотов для колец. + $emptyRingSlots = array_diff([9, 10, 11], $itemInSlot); + // Сортируем массив свободных слотов по возрастанию. + sort($emptyRingSlots); + // Одеваем предмет в первый свободный слот. + DBPDO::INIT()->execute('update inventory set dressed_slot = ? where item_id = ?', [$emptyRingSlots[0], $this->item_id]); + } elseif ($wearedCount->c == 3) { + // Cнимаем предмет из последнего слота 11 и одеваем новый предмет + DBPDO::INIT()->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = 11'); + DBPDO::INIT()->execute('UPDATE inventory SET dressed_slot = 11 WHERE item_id = ?', $this->item_id); + } else { + /* проверка на переполнение слотов */ + $error = self::TOO_MANY_ITEMS_IN_SLOTS; + DressedItems::undressAllItems($this->owner_id); + } + } else { + $error = self::UNKNOWN_ITEM_TYPE; + } + + return isset($error) ? $error : true; + } } \ No newline at end of file diff --git a/main.php b/main.php index f74d294..0602c58 100644 --- a/main.php +++ b/main.php @@ -1,5 +1,6 @@ undressItem($drop); + unset($items); } //Пока что одеваем предмет отсюда. if ($dress) { - echo dressitem($dress); + $dressing = new InventoryItem(DBPDO::INIT()->ofetch('select * from inventory where item_id = ? ', $dress)); + $dressing->dressItem(); + unset($dressing); } if ($destruct) { $q = db::c()->query('SELECT `id`, `dressed`, `name`, `duration`, `maxdur` FROM `inventory` WHERE `owner` = ?i AND `id` = ?i', $_SESSION['uid'], $destruct); @@ -82,7 +86,7 @@ if ($edit) { // Подготавливаем отображение инфы и предметов. $userInfo = new UserInfo($user->getId()); $userStats = new UserStats($user->getId()); -$data = \Battles\Database\DBPDO::INIT()->ofetchAll('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND on_sale = 0', $user->getId()); +$data = DBPDO::INIT()->ofetchAll('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND on_sale = 0', $user->getId()); $iteminfo = []; foreach ($data as $row) { $iteminfo[] = new InventoryItem($row); @@ -134,96 +138,6 @@ function del_efs($id, $type) } } -// одеть предмет -function dressitem($id) -{ - define('HELMET', 1); - define('ARMOR', 2); - define('LEGS', 3); - define('BOOTS', 4); - define('GLOVES', 5); - define('WEAPON', 6); - define('SHIELD', 7); - define('BELT', 8); - define('RING', 9); - define('AMULET', 10); - define('DRESSITEM_ERROR', [ - 'TOO_MANY_ITEMS_IN_SLOTS' => 'Критическая ошибка: Переполнение слота!', - 'UNKNOWN_ITEM_TYPE' => 'Неизвестный тип предмета!', - 'ITEM_NOT_FOUND' => 'Предмет не найден!', - 'REQUIREMENTS_NOT_MET' => 'Персонаж не соответствует требованиям!', - ]); - $userStats = new UserStats($_SESSION['uid']); - $itemInSlot = []; - $selectedItemRow = db::c()->query('SELECT item_type,need_strength,need_dexterity,need_intuition,need_endurance,need_intelligence,need_wisdom FROM `inventory` WHERE item_id = ?i AND owner_id = ?i AND `dressed_slot` = 0 AND `durability` != 0', $id, $_SESSION['uid']); - - //$userStats->getStrength() - if (!$selectedItemRow->getNumRows()) { - //с предметом что-то сильно не ок, ошибка. - $error = DRESSITEM_ERROR['ITEM_NOT_FOUND']; - } else { - $selectedItem = $selectedItemRow->fetch_object(); - if ($selectedItem->need_strength > $userStats->getFullStats()->strength - || $selectedItem->need_dexterity > $userStats->getFullStats()->dexterity - || $selectedItem->need_intuition > $userStats->getFullStats()->intuition - || $selectedItem->need_endurance > $userStats->getFullStats()->endurance - || $selectedItem->need_intelligence > $userStats->getFullStats()->intelligence - || $selectedItem->need_wisdom > $userStats->getFullStats()->wisdom) { - $error = DRESSITEM_ERROR['REQUIREMENTS_NOT_MET']; - } else { - $itemInSlotRow = db::c()->query('SELECT dressed_slot FROM inventory WHERE owner_id = ?i AND dressed_slot > 0 AND item_type = ?i', $_SESSION['uid'], $selectedItem->item_type); - $itemInSlotQuantity = $itemInSlotRow->getNumRows(); - if ($itemInSlotQuantity) { - while ($row = $itemInSlotRow->fetch_object()) { - $itemInSlot[] = $row->dressed_slot; - } - } - if (in_array($selectedItem->item_type, [HELMET, ARMOR, LEGS, BOOTS, GLOVES, WEAPON, SHIELD, BELT, AMULET])) { - //работаем с нормальными слотами - if (!$itemInSlotQuantity) { - // просто одеваем предмет - db::c()->query('UPDATE inventory SET dressed_slot = item_type WHERE item_id = ?i', $id); - } elseif ($itemInSlotQuantity == 1) { - // снимаем предмет и одеваем вместо - db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ?i', $itemInSlot[0]); - db::c()->query('UPDATE inventory SET dressed_slot = item_type WHERE item_id = ?i', $id); - } else { - // невозможная ситуация - два предмета в одиночном слоте. критическая ошибка, запись в лог, раздевание. - $error = DRESSITEM_ERROR['TOO_MANY_ITEMS_IN_SLOTS']; - db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?i', $_SESSION['uid']); - } - } elseif ($selectedItem->item_type == RING) { - // работаем с кольцами - if ($itemInSlotQuantity < 3) { - // Сравниваем массив колец и массив слотов для колец. - $emptyRingSlots = array_diff([9, 10, 11], $itemInSlot); - // Сортируем массив свободных слотов по возрастанию. - sort($emptyRingSlots); - // Одеваем предмет в первый свободный слот. - db::c()->query('UPDATE inventory SET dressed_slot = ?i WHERE item_id = ?i', $emptyRingSlots[0], $id); - } elseif ($itemInSlotQuantity == 3) { - db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = 11'); - db::c()->query('UPDATE inventory SET dressed_slot = 11 WHERE item_id = ?i', $id); - // снимаем предмет из слота 11 и одеваем вместо - } else { - // невозможная ситуация - больше трёх предметов на три слота. критическая ошибка, запись в лог, раздевание. - $error = DRESSITEM_ERROR['TOO_MANY_ITEMS_IN_SLOTS']; - db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?i', $_SESSION['uid']); - } - } else { - //предмет вообще не должен одеваться, ошибка - $error = DRESSITEM_ERROR['UNKNOWN_ITEM_TYPE']; - } - } - } - - if (isset($error)) { - return $error; - } else { - return null; - } -} - // Входим и выходим если можем. if ($goto) { $imove = true; From 73b1f134b2cdda8feb291ecd9ce832ac8bb932d9 Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 12 May 2021 21:51:37 +0300 Subject: [PATCH 22/28] =?UTF-8?q?=D0=92=20=D0=B1=D0=B0=D0=B7=D1=83=20?= =?UTF-8?q?=D1=8D=D1=84=D1=84=D0=B5=D0=BA=D1=82=D0=BE=D0=B2=20=D0=BF=D0=B8?= =?UTF-8?q?=D1=88=D0=B5=D1=82=D1=81=D1=8F=20=D0=BF=D0=B8=D1=88=D0=B5=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D0=BC=D0=BE=D0=B4=D0=B8=D1=84=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=D1=82=D0=BE=D1=80=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D1=80=D0=B0=20=D0=BF=D0=B5=D1=80=D1=81=D0=BE=D0=BD=D0=B0=D0=B6?= =?UTF-8?q?=D0=B0.=20#1=20#22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/User.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/classes/Battles/User.php b/classes/Battles/User.php index 7ff517e..49d51b2 100644 --- a/classes/Battles/User.php +++ b/classes/Battles/User.php @@ -91,9 +91,18 @@ class User } - public static function setUserEffect(int $userId, int $type, string $name, int $time): bool + /** + * @param int $userId + * @param int $type + * @param string $name + * @param int $time + * @param string|null $json_modifiers_list (str, dex, int, end, intel, wis). + * @return bool + */ + public static function setUserEffect(int $userId, int $type, string $name, int $time, string $json_modifiers_list = null): bool { - return self::$db->execute('INSERT INTO users_effects (owner_id, type, name, remaining_time) VALUES (?,?,?,?)', [$userId, $type, $name, $time]); + $mods = json_decode($json_modifiers_list); + return self::$db->execute('INSERT INTO users_effects (owner_id, type, name, remaining_time, mod_strength, mod_dexterity, mod_intuition, mod_endurance, mod_intellect, mod_wisdom) VALUES (?,?,?,?,?,?,?,?,?,?)', [$userId, $type, $name, $time, $mods->str ?? null, $mods->dex ?? null, $mods->int ?? null, $mods->end ?? null, $mods->intel ?? null, $mods->wis ?? null]); } public static function removeUserEffect(int $userId, int $type): bool From cb3887b77340a8b7eb44fa18978231f2df7b7c1b Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 12 May 2021 21:58:52 +0300 Subject: [PATCH 23/28] =?UTF-8?q?=D0=A3=D0=B5=D0=B7=D0=B4=20=D0=B7=D0=BD?= =?UTF-8?q?=D0=B0=D0=BA=D0=BE=D0=B2=20=D0=B7=D0=BE=D0=B4=D0=B8=D0=B0=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B2=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/UserInfo.php | 4 ++++ functions.php | 41 ------------------------------------ library.php | 11 +++++----- 3 files changed, 9 insertions(+), 47 deletions(-) diff --git a/classes/Battles/UserInfo.php b/classes/Battles/UserInfo.php index d097bce..e356a25 100644 --- a/classes/Battles/UserInfo.php +++ b/classes/Battles/UserInfo.php @@ -224,5 +224,9 @@ INFO; } return $r; } + public function showStarSign(): ?string + { + return parent::showStarSign(); + } } \ No newline at end of file diff --git a/functions.php b/functions.php index 1692a61..7734440 100644 --- a/functions.php +++ b/functions.php @@ -667,47 +667,6 @@ function addlog($id, $log) unset($id, $log); } -function star_sign($date) -{ - /* - * 1 aries - * 2 taurus - * 3 gemini - * 4 cancer - * 5 leo - * 6 virgo - * 7 libra - * 8 scorpio - * 9 sagittarios - * 10 capricorn - * 11 aquarius - * 12 pisches - */ - $zodiac[356] = "10"; - $zodiac[326] = "09"; - $zodiac[296] = "08"; - $zodiac[266] = "07"; - $zodiac[235] = "06"; - $zodiac[203] = "05"; - $zodiac[172] = "04"; - $zodiac[140] = "03"; - $zodiac[111] = "02"; - $zodiac[78] = "01"; - $zodiac[51] = "12"; - $zodiac[20] = "11"; - $zodiac[0] = "10"; - $dayOfYear = date("z", strtotime($date)); - $isLeapYear = date("L", strtotime($date)); //Высокосный? - if ($isLeapYear && $dayOfYear > 59) { - --$dayOfYear; - } - foreach ($zodiac as $day => $sign) { - if ($dayOfYear > $day) { - break; - } - } - return $sign; -} function SolveExp($at_id, $def_id, $damage) { diff --git a/library.php b/library.php index ae2a08f..fb52f31 100644 --- a/library.php +++ b/library.php @@ -211,14 +211,13 @@ if ($_GET['lib_room'] == 'hall' || !$_GET['lib_room']) { addchp('Вы успешно создали свиток ' . $dress['name'] . '!', '{[]}' . Nick::id($user['id'])->short() . '{[]}'); } } - echo '
Рюкзак - (масса: getStrength() * 4 ?>) + (масса: getStrength() * 4 ?>)
Вы стоите в небольшой комнате, от пола до потолка забтиой банками, пробирками, ингредиентами и прочими полезными вещами. - Здесь Вы можете собрать предметы по имеющимся у Вас рецептам.

Знак зодиака'; + $a = new \Battles\UserInfo($user['id']); + echo "
Вы стоите в небольшой комнате, от пола до потолка забтиой банками, пробирками, ингредиентами и прочими полезными вещами. + Здесь Вы можете собрать предметы по имеющимся у Вас рецептам.

Родовой знакshowStarSign()); switch ($el) { case 'a': echo "Воздух"; From 2f4dfd84cfe28392aa169e3397a6f0e5ddbe01b5 Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 12 May 2021 22:02:05 +0300 Subject: [PATCH 24/28] =?UTF-8?q?=D0=9E=D1=82=D0=BA=D0=B0=D0=B7=20=D0=BE?= =?UTF-8?q?=D1=82=20=D1=81=D1=82=D0=B0=D1=80=D0=BE=D0=B9=20=D0=B4=D1=83?= =?UTF-8?q?=D0=B1=D0=BB=D0=B8=D1=80=D1=83=D1=8E=D1=89=D0=B5=D0=B9=20destru?= =?UTF-8?q?ctitem()=20=D0=B2=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D1=83=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=BE=D0=B2=D0=BE=D0=B9=20Invent?= =?UTF-8?q?oryItem::destroyItem().?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/InventoryItem.php | 13 +++++++++++++ functions.php | 17 +---------------- hostel_room.php | 2 +- magic/incmagic.php | 2 +- main.php | 13 ++++++------- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/classes/Battles/InventoryItem.php b/classes/Battles/InventoryItem.php index 6548988..0cd1c14 100644 --- a/classes/Battles/InventoryItem.php +++ b/classes/Battles/InventoryItem.php @@ -7,6 +7,7 @@ class InventoryItem extends Item { private $present; private $owner_id; + private $db; private const TOO_MANY_ITEMS_IN_SLOTS = 'Критическая ошибка: Переполнение слота!'; private const UNKNOWN_ITEM_TYPE = 'Неизвестный тип предмета!'; private const REQUIREMENTS_NOT_MET = 'Персонаж не соответствует требованиям!'; @@ -20,6 +21,7 @@ class InventoryItem extends Item { parent::__construct($row); $this->owner_id = $row->owner_id; + $this->db = DBPDO::INIT(); } public function printInfo() @@ -127,4 +129,15 @@ IMG; return isset($error) ? $error : true; } + + /** + * @param $itemId + * + * @return bool + */ + public static function destroyItem($itemId): bool + { + $db = new DBPDO(); + return $db->execute('delete from inventory where dressed_slot = 0 and owner_id = ? and item_id = ?', [$_SESSION['uid'], $itemId]); + } } \ No newline at end of file diff --git a/functions.php b/functions.php index 7734440..2633c8a 100644 --- a/functions.php +++ b/functions.php @@ -468,21 +468,6 @@ function ref_drop() } } - -/** - * Уничтожить предмет, принадлежащий игроку, вызывающего функцию. - * @param $id - ID предмета игрока. - * @throws \Krugozor\Database\Mysql\Exception - */ -function destructitem($id) -{ - global $user; - $item = db::c()->query('SELECT 1 FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->getId(), $id); - if ($item->getNumRows()) { - db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $id); - } -} - // использовать магию function usemagic($id, $target) { @@ -543,7 +528,7 @@ function usemagic($id, $target) } if ($bat) { if ($row['maxdur'] <= ($row['duration'] + 1)) { - destructitem($row['id']); + \Battles\InventoryItem::destroyItem($row['id']); } else { if (!$row['magic']) { db::c()->query('UPDATE `inventory` SET `includemagicdex` =`includemagicdex` - ?i WHERE id = ?i', $bat, $row['id']); diff --git a/hostel_room.php b/hostel_room.php index 8ead626..2f2464d 100644 --- a/hostel_room.php +++ b/hostel_room.php @@ -12,7 +12,7 @@ $vips = [1 => 0.15, 2 => 0.30, 3 => 0.45]; function show_item($row, $txt, $place) { if (($row['maxdur'] <= $row['duration']) || ($row['dategoden'] && $row['dategoden'] <= time())) { - destructitem($row['id']); + \Battles\InventoryItem::destroyItem($row['id']); } $r = ''; diff --git a/magic/incmagic.php b/magic/incmagic.php index f84bc75..ae5e016 100644 --- a/magic/incmagic.php +++ b/magic/incmagic.php @@ -43,7 +43,7 @@ if ($user['battle'] > 0) { echo "Этот свиток нельзя встраивать в предметы!"; } else { // встраиваем - destructitem($svitok['id']); + \Battles\InventoryItem::destroyItem($svitok['id']); echo "Свиток \"" . $svitok['name'] . "\" удачно встроен в \"" . $dress['name'] . "\""; mysql_query("UPDATE `inventory` SET " . ($dress['nintel'] < $svitok['nintel'] ? "`nintel`='" . $svitok['nintel'] . "'," : "") . " diff --git a/main.php b/main.php index 0602c58..ba8ee78 100644 --- a/main.php +++ b/main.php @@ -60,13 +60,12 @@ if ($edit) { unset($dressing); } if ($destruct) { - $q = db::c()->query('SELECT `id`, `dressed`, `name`, `duration`, `maxdur` FROM `inventory` WHERE `owner` = ?i AND `id` = ?i', $_SESSION['uid'], $destruct); - if ($q->getNumRows()) { - $q = $q->fetch_assoc(); - if (empty($q['dressed'])) { - destructitem($q['id']); - GameLogs::addUserLog($user->getId(), $user->getLogin() . ' выбросил предмет ' . $q['name'] . ' id:(cap' . $q['id'] . ')'); - err('Предмет ' . $q['name'] . ' выброшен.'); + $q = DBPDO::INIT()->ofetch('select name,dressed_slot from inventory where owner_id = ? and item_id = ?', [$user->getId(), $destruct]); + if ($q) { + if (empty($q->dressed_slot)) { + InventoryItem::destroyItem($destruct); + GameLogs::addUserLog($user->getId(), $user->getLogin() . ' выбросил предмет ' . $q->name . ' id:(cap' . $destruct . ')'); + err('Предмет ' . $q->name . ' выброшен.'); } else { err('Ошибка: нельзя выбросить одетый предмет!'); } From 582cce3c1797494c5751b6e2dcdfa28042d766fe Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 12 May 2021 22:04:33 +0300 Subject: [PATCH 25/28] =?UTF-8?q?=D0=9E=D0=B1=D1=80=D0=B0=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BA=20=D0=B7=D0=B0=D1=89=D0=B8=D1=89?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D0=BE=D0=B9=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=BD=D0=BE=D0=B9=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7?= =?UTF-8?q?=20=D0=B3=D0=B5=D1=82=D1=82=D0=B5=D1=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Battles/Magic/CureInjury.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Battles/Magic/CureInjury.php b/classes/Battles/Magic/CureInjury.php index 100b69f..a1677b7 100644 --- a/classes/Battles/Magic/CureInjury.php +++ b/classes/Battles/Magic/CureInjury.php @@ -52,7 +52,7 @@ class CureInjury extends Magic } else { $this->target = new User($this->target); } - $this->login = $this->target->login; + $this->login = $this->target->getLogin(); return ($this->isVisible($caster, $this->target) && $this->isNotDead($caster) && $this->enoughMana($caster) && $this->isNotInBattle($caster)); } } \ No newline at end of file From 4fd822e6441fed56636c52144017e75a01c34fee Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 12 May 2021 22:07:02 +0300 Subject: [PATCH 26/28] =?UTF-8?q?=D0=9E=D1=82=D0=BA=D0=B0=D0=B7=20=D0=BE?= =?UTF-8?q?=D1=82=20=D1=81=D1=82=D0=B0=D1=80=D0=BE=D0=B9=20=D0=B4=D1=83?= =?UTF-8?q?=D0=B1=D0=BB=D0=B8=D1=80=D1=83=D1=8E=D1=89=D0=B5=D0=B9=20addOne?= =?UTF-8?q?Point()=20=D0=B2=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D1=83=20?= =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=BE=D0=B2=D0=BE=D0=B9=20User::?= =?UTF-8?q?addOnePointToStat().?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 52 --------------------------------------------------- main.php | 4 ---- 2 files changed, 56 deletions(-) diff --git a/functions.php b/functions.php index 2633c8a..8ff7715 100644 --- a/functions.php +++ b/functions.php @@ -747,55 +747,3 @@ function SolveExp($at_id, $def_id, $damage) return round((($baseexp[$def['level']]) * ($def_cost[0] / (($at_cost[0] + $def_cost[0]) / 2)) * ($damage / $def['maxhp']) * $expmf * $mfit * $mfbot * $mfbot2) / 3); } - -/** - * Апаем стат или мастерство на единицу. - * - * @param $name - техническое имя параметра, как в базе. - * @param null $param - выбор что повышать. - * - * @return void - */ -function addOnePoint($name, $param = null) -{ - $allowed_stats = ['sila', 'lovk', 'inta', 'vinos', 'intel', 'mudra']; - $allowed_mastery = ['noj', 'mec', 'dubina', 'topor', 'mfire', 'mwater', 'mair', 'mearth', 'mlight', 'mgray', 'mdark']; - $naming = [ - 'sila' => 'Сила', - 'lovk' => 'Ловкость', - 'inta' => 'Интуиция', - 'vinos' => 'Выносливость', - 'intel' => 'Интеллект', - 'mudra' => 'Мудрость', - 'noj' => 'Владение кинжалами', - 'mec' => 'Владение мечами', - 'dubina' => 'Владение дубинами', - 'topor' => 'Владение топорами', - 'mfire' => 'Магия огня', - 'mwater' => 'Магия воды', - 'mair' => 'Магия воздуха', - 'mearth' => 'Магия земли', - 'mlight' => 'Магия света', - 'mgray' => 'Магия серости', - 'mdark' => 'Магия тьмы', - ]; - if ($param == 'stat' && in_array($name, $allowed_stats)) { - db::c()->query('UPDATE `users` SET ?f = ?f + 1, `stats` = `stats` - 1 WHERE `id` = ?i', $name, $name, $_SESSION['uid']); - echo "Параметр {$naming[$name]} увеличен на 1 ед."; - } elseif ($param == 'mastery' && in_array($name, $allowed_mastery)) { - $mastery_level = db::c()->query('SELECT ?f FROM `users` WHERE `id` = ?i', $name, $_SESSION['uid'])->fetch_assoc(); - if ($mastery_level[$name] < 10) { - db::c()->query('UPDATE `users` SET ?f = ?f + 1, `master` = `master` - 1 WHERE `id` = ?i', $name, $name, $_SESSION['uid']); - echo "Параметр {$naming[$name]} увеличен на 1 ед."; - } else { - echo "Ошибка: параметр достиг максимального значения!"; - } - } else { - return null; - } -} - -function checkIntInRange($int, $min = 1, $max = PHP_INT_MAX) -{ - return (int)filter_var($int, FILTER_VALIDATE_INT, ['options' => ['min_range' => $min, 'max_range' => $max]]); -} \ No newline at end of file diff --git a/main.php b/main.php index ba8ee78..12a17ed 100644 --- a/main.php +++ b/main.php @@ -34,7 +34,6 @@ $edit = $_GET['edit'] ?? null; if ($edit) { $ups = $_GET['ups'] ?? null; - $upm = $_GET['upm'] ?? null; $use = $_GET['use'] ?? null; $useTarget = $_POST['target'] ?? null; $drop = $_GET['drop'] ?? null; @@ -45,9 +44,6 @@ if ($edit) { if ($ups) { $user->addOnePointToStat($ups); } - if ($upm) { - addOnePoint($upm, 'mastery'); - } if ($drop) { $items = new DressedItems($_SESSION['uid']); $items->undressItem($drop); From 63e8dc36f84c8993b228464658cfc3cc605bbba4 Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 12 May 2021 23:34:54 +0300 Subject: [PATCH 27/28] Closes #1 #22. --- classes/Battles/User.php | 36 ++++++++++++++++++++++++++++++++- classes/Battles/UserEffects.php | 8 ++++---- classes/Battles/UserStats.php | 12 +++++------ 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/classes/Battles/User.php b/classes/Battles/User.php index 49d51b2..851c20b 100644 --- a/classes/Battles/User.php +++ b/classes/Battles/User.php @@ -102,7 +102,7 @@ class User public static function setUserEffect(int $userId, int $type, string $name, int $time, string $json_modifiers_list = null): bool { $mods = json_decode($json_modifiers_list); - return self::$db->execute('INSERT INTO users_effects (owner_id, type, name, remaining_time, mod_strength, mod_dexterity, mod_intuition, mod_endurance, mod_intellect, mod_wisdom) VALUES (?,?,?,?,?,?,?,?,?,?)', [$userId, $type, $name, $time, $mods->str ?? null, $mods->dex ?? null, $mods->int ?? null, $mods->end ?? null, $mods->intel ?? null, $mods->wis ?? null]); + return self::$db->execute('INSERT INTO users_effects (owner_id, type, name, remaining_time, mod_strength, mod_dexterity, mod_intuition, mod_endurance, mod_intelligence, mod_wisdom) VALUES (?,?,?,?,?,?,?,?,?,?)', [$userId, $type, $name, $time, $mods->str ?? null, $mods->dex ?? null, $mods->int ?? null, $mods->end ?? null, $mods->intel ?? null, $mods->wis ?? null]); } public static function removeUserEffect(int $userId, int $type): bool @@ -460,4 +460,38 @@ class User { self::$db->execute('update online set real_time = ? where user_id = ?', [time(), $this->getId()]); } + + public function setInjury(int $type): bool + { + if (!in_array($type,[11,12,13,14])) { + return false; + } + $names1 = ['разбитый нос', 'сотрясение первой степени', 'потрепанные уши', 'прикушенный язык', 'перелом переносицы', 'растяжение ноги', 'растяжение руки', 'подбитый глаз', 'синяк под глазом', 'кровоточащее рассечение', 'отбитая «пятая точка»', 'заклинившая челюсть', 'выбитый зуб «мудрости»', 'косоглазие']; + $names2 = ['отбитые почки', 'вывих «вырезано цензурой»', 'сотрясение второй степени', 'оторванное ухо', 'вывих руки', 'оторванные уши', 'поврежденный позвоночник', 'поврежденный копчик', 'разрыв сухожилия', 'перелом ребра', 'перелом двух ребер', 'вывих ноги', 'сломанная челюсть']; + $names3 = ['пробитый череп', 'разрыв селезенки', 'смещение позвонков', 'открытый перелом руки', 'открытый перелом «вырезано цензурой»', 'излом носоглотки', 'непонятные, но множественные травмы', 'сильное внутреннее кровотечение', 'раздробленная коленная чашечка', 'перелом шеи', 'смещение позвонков', 'открытый перелом ключицы', 'перелом позвоночника', 'вывих позвоночника', 'сотрясение третьей степени']; + $param_names = ['str','dex','int','end','intel','wis',]; + shuffle($param_names); + switch ($type) { + case 11: + shuffle($names1); + $name = UserEffects::$effectName[$type] . ': ' . $names1(0); + self::setUserEffect($this->id, $type, $name, strtotime('30min'), json_encode([$param_names(0) => -1])); + break; + case 12: + shuffle($names2); + $name = UserEffects::$effectName[$type] . ': ' . $names2(0); + self::setUserEffect($this->id, $type, $name, strtotime('3hours'), json_encode([$param_names(0) => mt_rand(-3,-1), $param_names(1) => mt_rand(-3,-1)])); + break; + case 13: + shuffle($names3); + $name = UserEffects::$effectName[$type] . ': ' . $names3(0); + self::setUserEffect($this->id, $type, $name, strtotime('12hours'), json_encode([$param_names(0) => mt_rand(-5,-1), $param_names(1) => mt_rand(-5,-1), $param_names(2) => mt_rand(-5,-1)])); + break; + default: //type 14 + self::setUserEffect($this->id, $type, UserEffects::$effectName[$type], strtotime('1day'), json_encode([$param_names(0) => -10])); + break; + } + + return true; + } } \ No newline at end of file diff --git a/classes/Battles/UserEffects.php b/classes/Battles/UserEffects.php index 1b864d3..4182357 100644 --- a/classes/Battles/UserEffects.php +++ b/classes/Battles/UserEffects.php @@ -10,10 +10,10 @@ trait UserEffects 4 => 'Заклятие хаоса', 5 => 'Заклятие обезличивания', 10 => 'паралич', - 11 => 'легкая травма', - 12 => 'средняя травма', - 13 => 'тяжёлая травма', - 14 => 'неизлечимая травма', + 11 => 'Легкая травма', + 12 => 'Средняя травма', + 13 => 'Тяжёлая травма', + 14 => 'Неизлечимая травма', 20 => 'Проверка Паладинов', 21 => 'Сила нейтралитета', 22 => 'Защита от кулачного нападения', diff --git a/classes/Battles/UserStats.php b/classes/Battles/UserStats.php index b1105e3..f514869 100644 --- a/classes/Battles/UserStats.php +++ b/classes/Battles/UserStats.php @@ -205,12 +205,12 @@ class UserStats extends User { $query = " select - sum(greatest(strength + (ifnull((select sum(add_strength) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as strength, - sum(greatest(dexterity + (ifnull((select sum(add_dexterity) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as dexterity, - sum(greatest(intuition + (ifnull((select sum(add_intuition) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as intuition, - sum(greatest(endurance + (ifnull((select sum(add_endurance) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as endurance, - sum(greatest(intelligence + (ifnull((select sum(add_intelligence) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as intelligence, - sum(greatest(wisdom + (ifnull((select sum(add_wisdom) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)), 0)) as wisdom, + sum(greatest(strength + (ifnull((select sum(add_strength) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)) + (ifnull((select sum(mod_strength) from users_effects where owner_id = $this->id), 0)), 0)) as strength, + sum(greatest(dexterity + (ifnull((select sum(add_dexterity) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)) + (ifnull((select sum(mod_dexterity) from users_effects where owner_id = $this->id), 0)), 0)) as dexterity, + sum(greatest(intuition + (ifnull((select sum(add_intuition) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)) + (ifnull((select sum(mod_intuition) from users_effects where owner_id = $this->id), 0)), 0)) as intuition, + sum(greatest(endurance + (ifnull((select sum(add_endurance) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)) + (ifnull((select sum(mod_endurance) from users_effects where owner_id = $this->id), 0)), 0)) as endurance, + sum(greatest(intelligence + (ifnull((select sum(add_intelligence) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)) + (ifnull((select sum(mod_intelligence) from users_effects where owner_id = $this->id), 0)), 0)) as intelligence, + sum(greatest(wisdom + (ifnull((select sum(add_wisdom) from inventory where dressed_slot != 0 and owner_id = $this->id), 0)) + (ifnull((select sum(mod_wisdom) from users_effects where owner_id = $this->id), 0)), 0)) as wisdom, ifnull((select sum(add_accuracy) from inventory where dressed_slot != 0 and owner_id = $this->id), 0) as accuracy, ifnull((select sum(add_evasion) from inventory where dressed_slot != 0 and owner_id = $this->id), 0) as evasion, ifnull((select sum(add_criticals) from inventory where dressed_slot != 0 and owner_id = $this->id), 0) as criticals, From db3855cbd5901739e5783bd37fbf983057ab8e69 Mon Sep 17 00:00:00 2001 From: "Igor Barkov (iwork)" Date: Tue, 25 May 2021 18:15:51 +0300 Subject: [PATCH 28/28] Fatal error: Uncaught Error: Call to undefined method Battles\User::getStrength() in /volume2/web/battles/functions.php:626 Stack trace: #0 /volume2/web/battles/classes/Battles/Travel.php(70): get_meshok() #1 /volume2/web/battles/city.php(23): Battles\Travel::toRoom(21, 29) #2 {main} thrown in /volume2/web/battles/functions.php on line 626 --- classes/Battles/Travel.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/classes/Battles/Travel.php b/classes/Battles/Travel.php index 86b519e..4d148a8 100644 --- a/classes/Battles/Travel.php +++ b/classes/Battles/Travel.php @@ -1,6 +1,7 @@ fetch('SELECT SUM(weight) AS all_weight FROM inventory WHERE owner_id = ? AND on_sale = 0', $_SESSION['uid']); + $itemsWeight = $db->fetch('SELECT SUM(weight) - (select strength * 5 from users where id = ?) AS weight_overflow FROM inventory WHERE owner_id = ? AND on_sale = 0', [$_SESSION['uid'], $_SESSION['uid']]); $eff = $db->fetch('SELECT type FROM users_effects WHERE owner_id = ? AND (`type` = 10 OR `type` = 13 OR `type` = 14)', $_SESSION['uid']); $errors = []; - if ($itemsWeight['all_weight'] > get_meshok()) { + if ($itemsWeight['weight_overflow'] > 0) { $errors[0] = 'У вас переполнен рюкзак, вы не можете передвигаться...'; } if ($eff['type'] == 10) {