From 92e77e4335a03ff2572bedc4da140f8430661bae Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 16 Aug 2019 18:33:47 +0200 Subject: [PATCH] feat(cbs): initial functions to start and finish the battle --- .../assets/gui/strings/battle_completed.png | Bin 0 -> 6688 bytes .../scenes/battlesystem/init.lua | 10 ++++ .../scenes/battlesystem/world.lua | 52 ++++++++++++++---- 3 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 sonic-radiance.love/assets/gui/strings/battle_completed.png diff --git a/sonic-radiance.love/assets/gui/strings/battle_completed.png b/sonic-radiance.love/assets/gui/strings/battle_completed.png new file mode 100644 index 0000000000000000000000000000000000000000..81570426ac25170a49b98e92dee6666312a3c55f GIT binary patch literal 6688 zcmV+*8sFuKP)0004mX+uL$Nkc;* zaB^>EX>4Tx04R}tkv&MmKpe$iQ>8`f2iQT>AwzYtAS&XhRVYG*QY*CTU~=gfG-*gu zTpR`0f`cE6RRnfhEZnSkf`x`&UicTt|@eeTcEt>jDw_(bAarW+RV2J!T! zrE}gV4zr@95T6r|8FWG7N3P2*zi}=&Ebz>*kxtDMhl#~P8_R9XiiS!&MI2F7jq-(z z%L?Z$&T6^Jn)l={4CSdYt8MgxsTHaAWdB*Zh(VB zV6;Hl>mKh8w)gh$nPz`K8>VuEn`>kS00006VoOIv0JH$K0JIWcH1Yrd010qNS#tmY zE+YT{E+YYWr9XB6000McNliru;|LHABQ@UXL7D&n02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{02la4L_t(|+U;FSY@Ah={;mTqClDsiBq1S*-Q9@@!FFue z_aIh1LIM_{H%!lTv+CI(7%{y;fJCD~Vj2Mo5WpK2L+@ad88Opwf&ifjng+$?M;vgK zAtD6gN9??8R~2>6EdKjA_kaIo15M*!isEwp_kEtm%sTj4xfd7gUesTGg6l0M#i^UXqgu)MsS zYB3g>_e%HsqmMqyHTUoG{Qr`8W3|>*E|(*Fb&dRR{P=Nf+qNy<`)2XK_`TxbR~t5L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 znmIsoS6V|%XwS&#XJ#y3UG%_4GcFOK)ZXD8baEe8TZ@Eh>(`Xk1nyV%c=PiYJgZh# z1(ZtheKe_wQmI|kh_YoQ^EAn1SG($lz+zH3bm$P)wXL)CU_1d+gT=(yx^)ZAoH>In zTejHmNLLMnYyVg)BEyW7gDx{IlBT0?Vn#Ry_=P8^Va5O=UQ7M zyUW)U7}aVO)oR7M)ll)ir74ZEHGVdi4yaVCs8lL8xl4I@Wg;%9w38rnqac849fTq# zY`WoZ003LI{H?nkf+a8uEH5vi*$n!+_S$QORcyfxFPBc1kXiJV6Yj>&4nVrnAW^wd zsZ60#nSxRxB|=v+DD8&M&CI&_XxE%Ih*g=YqVieQfn>4Qlq<~6&g9@H^75ysASTRU zOifLpTAgxqVG_bkg0&*44+u1UqBK}s^eSfZl5eR6%fR7;n!S`C)arHHhou*rbLYX{F8NZg{qn_& zxP19iC^f*p*^)#e@Ed>pBksHJAhvAXYHuqw5!E)OFgQ3EQh4m=Fop0k_VVUhS8z!Y zQ^}(;`X}9TYaE0w03>0>_*R*|HPqZ{s*s}!!@p=T*JT0--G`-IIgncq%UhO3g$zZ5 z5#F8jQDx%3@+)HMjfR&d6}7NPlv{`kmf4f2TJsaTjf6s@QN!5i7|xtI69L?SD@U7Ky{ z2RUr9wTRUX4i4hpd+$YisU4d;H+h_7B3)sIa}hTR^-;p+O`U-vGHa!v3|ZN`)!o_{ zz|xf^jGsD%KmXsKqn0(tMSp=4C;k_|`OU9&R2pud6tHE>7T?{owS~gPjJu~z$!pws zMFLAE#X5HNfUw68rGeGMHQinK{jItYF+{SFNs6?hjyY8m!kd1t)1*nU2C>{#U7ueE!i4Q--8*jW3=}Xeb(6M8|UZ%WrY-k9T2)*oWneK;%a-M(a*|T@girVL*&6vJh zY17JlhK{w~kC7)Ie)wSug8SF~= #self.actionlist) then - core.debug:print("cbs/world", "turn finished") - self.turns.current = 1 - self.turns.isFinished = false - self.turns.number = self.turns.number + 1 - self:recalculateTurns() + if (self:countEnnemies()==0) then + self:finishBattle() else - self.turns.current = self.turns.current + 1 - core.debug:print("cbs/world", "switching to action number " .. self.turns.current) - end + if (self.turns.isFinished) or (self.turns.current >= #self.actionlist) then + self:switchToNextTurn() + else + self.turns.current = self.turns.current + 1 + core.debug:print("cbs/world", "switching to action number " .. self.turns.current) + end + self:selectNextAction() + self.turns.changeBattler = false + end +end + +function World:switchToNextTurn() + core.debug:print("cbs/world", "turn finished") + self.turns.current = 1 + self.turns.isFinished = false + self.turns.number = self.turns.number + 1 + self:recalculateTurns() +end + +function World:selectNextAction() if (self.actionlist[self.turns.current].actor.isDestroyed == true) then self:switchActiveBattler() else self.actionlist[self.turns.current].actor:setActive() end - self.turns.changeBattler = false +end + +function World:finishBattle() + self.isBattleActive = false + self.actionlist = {} + self.scene:finishBattle() end function World:sendSignalToCurrentBattler() @@ -273,7 +299,9 @@ function World:drawHUD() end local cursorx = self.BattlerCursor * 20 - 6 - self.assets.images["menucursor"]:draw(cursorx, 26, math.rad(-90), 1, 1, 4, 8) + if #self.actionlist > 0 then + self.assets.images["menucursor"]:draw(cursorx, 26, math.rad(-90), 1, 1, 4, 8) + end for i,v in ipairs(self.battlers) do v:drawHUD()