From 896bf98bae3850a88cb860b10b9f01a16303de18 Mon Sep 17 00:00:00 2001 From: MrZ_26 <1046101471@qq.com> Date: Mon, 13 Jan 2025 01:54:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BF=AE=E6=94=B9=E4=B8=8B?= =?UTF-8?q?=E6=AC=A1=E7=82=B9=E6=95=B0=E5=92=8C=E9=A2=9D=E5=A4=96/?= =?UTF-8?q?=E8=B7=B3=E8=BF=87=E5=9B=9E=E5=90=88=E7=9A=84=E6=A0=BC=E5=AD=90?= =?UTF-8?q?=E6=95=88=E6=9E=9C=20=E6=A1=86=E6=9E=B6=E8=B7=9F=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zenitha | 2 +- assets/game.lua | 44 ++++++++++++++++++++---------------- assets/map/lue_first.luaon | 14 ++++++------ assets/player.lua | 24 ++++++++++++++++++++ assets/prop.lua | 46 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 27 deletions(-) diff --git a/Zenitha b/Zenitha index 5f86f3c..634d97f 160000 --- a/Zenitha +++ b/Zenitha @@ -1 +1 @@ -Subproject commit 5f86f3ceaf8eda24226c5e9b0301052d44a4203c +Subproject commit 634d97fb9bbdeda46f1ec7c30851cf7123fe48e3 diff --git a/assets/game.lua b/assets/game.lua index da6e534..478168c 100644 --- a/assets/game.lua +++ b/assets/game.lua @@ -242,10 +242,16 @@ function Game.new(data) end addQ('deco',cell,prop,QUAD.world.warn) elseif prop[1]=='stop' then - addQ('text',cell,prop,"X") + addQ('text',cell,prop,"停止") addQ('deco',cell,prop,QUAD.world.warn) elseif prop[1]=='reverse' then - addQ('text',cell,prop,"R") + addQ('text',cell,prop,"反转") + addQ('deco',cell,prop,QUAD.world.warn) + elseif prop[1]=='diceMod' then + addQ('text',cell,prop,"下次点数"..prop[2]..prop[3]) -- TODO + addQ('deco',cell,prop,QUAD.world.warn) + elseif prop[1]=='exTurn' then + addQ('text',cell,prop,(prop[2]>0 and "再骰%d次" or "跳过%d回合"):format(math.abs(prop[2]))) addQ('deco',cell,prop,QUAD.world.warn) end @@ -330,27 +336,27 @@ function Game:roll() repeat coroutine.yield() until p.dice.animState=='bounce' p:move(p.dice.value) repeat coroutine.yield() until not p.moving - self.roundIndex=self.roundIndex%#self.players+1 - TEXT:add{ - text="Player "..self.roundIndex.." turn", - r=1,g=1,b=1,a=.4, - duration=1.4, - x=500-4,y=300-4,k=1.5, - fontSize=40, - style='zoomout', - } - TEXT:add{ - text="Player "..self.roundIndex.." turn", - color=self.players[self.roundIndex].color, - duration=1.6, - x=500,y=300,k=1.5, - fontSize=40, - style='zoomout', - } + self:updateTurn() end) end end +function Game:updateTurn() + local p=self.players[self.roundIndex] + if p.extraTurn>0 then + p.extraTurn=p.extraTurn-1 + MSG('other',"玩家"..self.roundIndex.."的额外回合") + else + while true do + self.roundIndex=self.roundIndex%#self.players+1 + p=self.players[self.roundIndex] + if p.extraTurn>=0 then break end + p.extraTurn=p.extraTurn+1 + end + MSG('other',"玩家"..self.roundIndex.."的回合") + end +end + ---@param a {p:ReroChess.Player} local function coSorter(a,b) return a.p.y0 then + local mod=table.remove(self.diceMod,1) + if mod[1]=='+' then + d.value=d.value+mod[2] + elseif mod[1]=='-' then + d.value=d.value-mod[2] + elseif mod[1]=='*' then + d.value=d.value*mod[2] + elseif mod[1]=='/' then + d.value=d.value/mod[2] + elseif mod[1]=='^' then + d.value=d.value^mod[2] + elseif mod[1]=='&' then + d.value=d.value^(1/mod[2]) + end + d.value=math.floor(d.value+.001) + end d.animState='bounce' TWEEN.new(function(t) d.size=1+math.sin(t*26)/(1+62*t) diff --git a/assets/prop.lua b/assets/prop.lua index 7524e6a..ce88c11 100644 --- a/assets/prop.lua +++ b/assets/prop.lua @@ -132,4 +132,50 @@ Prop.reverse={ end, } +local modifiers={ + ['+']=true, + ['-']=true, + ['*']=true, + ['/']=true, + ['^']=true, + ['&']=true, +} +Prop.diceMod={ + parse=function(prop) + prop[3]=tonumber(prop[3]) + assert( + modifiers[prop[2]] and + type(prop[3])=='number', + 'diceMod[1] must be operator and diceMod[2] must be number' + ) + end, + ---@param P ReroChess.Player + code=function(P,op,num) + P:popText{ + text=("下一次点数%s%d"):format(op,num), + duration=2, + } + table.insert(P.diceMod,{op,num}) + end, +} + +Prop.exTurn={ + parse=function(prop) + if prop[2]==nil then prop[2]=1 end + prop[2]=tonumber(prop[2]) + assert( + type(prop[2])=='number' and prop[2]%1==0 and prop[2]~=0, + 'exTurn[1] must be non-zero integer' + ) + end, + ---@param P ReroChess.Player + code=function(P,cnt) + P:popText{ + text=cnt>0 and "额外回合!" or "跳过回合!", + duration=2, + } + P.extraTurn=P.extraTurn+cnt + end, +} + return Prop