Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koishi-plugin-dicey-dungeons

Package Overview
Dependencies
Maintainers
2
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koishi-plugin-dicey-dungeons - npm Package Compare versions

Comparing version 1.3.9 to 1.4.0

15

lib/index.js

@@ -41,3 +41,3 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.apply=exports.Config=exports.usage=exports.inject=exports.name=void 0;const koishi_1=require("koishi"),path_1=require("path"),url_1=require("url"),random=(exports.name="dicey-dungeons",new koishi_1.Random(()=>Math.random())),Introduction=(exports.inject={required:["canvas"]},exports.usage=`# <center>【骰子地下城】</center><center>全新版本!!</center><center>炒鸡好玩的回合对战游戏</center>

- [麦佬](mqqapi://card/show_pslcard?src_type=internal&source=sharecard&version=1&uin=1207108696) - 1207108696
- [塑梦](mqqapi://card/show_pslcard?src_type=internal&source=sharecard&version=1&uin=3523335883) - 3523335883`,exports.Config=koishi_1.Schema.object({"管理员":koishi_1.Schema.array(String).required().role("table").description("填写QQ,用与重置对战")}),{"剑":{descriptions:"造成□伤害",trigge:0,austerity:3,dice:"",quantities:1,harm:"□",Category:["造成"]},"匕首":{descriptions:"[1-3]造成□伤害",trigge:0,austerity:1,dice:"1-3",quantities:9,harm:"□",Category:["造成"]},"回旋镖":{descriptions:"造成□*2伤害,自身受到□伤害",trigge:0,austerity:3,quantities:1,harm:"□*2",Category:["造成","自身"]},"火球":{descriptions:"[偶数]造成□伤害,燃烧1个骰子",trigge:0,austerity:2,dice:"偶数",quantities:1,harm:"□",Category:["造成","燃烧"]},"雪球":{descriptions:"[奇数]造成□伤害,冰冻1个骰子",trigge:0,austerity:2,dice:"奇数",quantities:1,harm:"□",Category:["造成","冰冻"]},"诅咒":{descriptions:"[1]造成□+1伤害,施加1层诅咒",trigge:0,austerity:0,dice:1,quantities:1,harm:"□+1",Category:["造成","诅咒"]},"毒药咒语":{descriptions:"[3]施加4层中毒",trigge:0,austerity:0,dice:3,quantities:1,harm:"□+1",Category:["中毒"]},"治愈水晶":{descriptions:"[1-3]回复□生命值",trigge:0,austerity:1,dice:"1-3",quantities:1,harm:"□",Category:["回复"]},"木质盾牌":{descriptions:"[1-4]获得□点护盾",trigge:0,austerity:1,dice:"1-4",quantities:1,harm:"□",Category:["护盾"]},"复制":{descriptions:"[4-6]复制1个骰子",trigge:0,austerity:1,dice:"4-6",quantities:1,harm:"□",Category:["复制"]},"铲":{descriptions:"颠倒1个骰子",trigge:0,austerity:3,dice:"",quantities:1,harm:"□",Category:["颠倒"]},"绝佳手气":{descriptions:"[1-5]重投1个点数更大的骰子",trigge:0,austerity:1,dice:"1-5",quantities:1,harm:"□",Category:["重投更大"]},"战斗翻滚":{descriptions:"重投1个骰子",trigge:0,austerity:3,dice:"",quantities:3,harm:"□",Category:["重投"]},"轻顶":{descriptions:"[1-5]□+1",trigge:0,austerity:1,dice:"1-5",quantities:1,harm:"□+1",Category:["轻顶"]},"干草叉":{descriptions:"[1-4]造成□伤害,燃烧&震慑骰子",trigge:0,austerity:1,dice:"1-4",quantities:1,harm:"□",Category:["造成","燃烧","震慑"]},"渔网":{descriptions:"[1-3]造成□伤害,点数3时锁定1个骰子",trigge:3,trigge_skill:["造成","锁定"],austerity:1,dice:"1-3",quantities:1,harm:"□",Category:["造成"]},"吸血":{descriptions:"[1-4]造成□伤害,回复□生命值",trigge:0,austerity:1,dice:"1-4",quantities:1,harm:"□",Category:["造成","回复"]}});async function apply(q,r){q.model.extend("dice_player",{userId:"string",username:"string",HP:{type:"unsigned",initial:0},dice:"list",skills:"list",skill:"json",burn:{type:"unsigned",initial:0},freeze:{type:"unsigned",initial:0},poison:{type:"unsigned",initial:0},curse:{type:"unsigned",initial:0},shield:{type:"unsigned",initial:0},awe:{type:"unsigned",initial:0},lock:{type:"unsigned",initial:0},counterparties:"string"},{primary:"userId"}),q.model.extend("dice_group",{guildId:"string",Play_1_userId:"string",Play_1_username:"string",Play_2_userId:"string",Play_2_username:"string",bout:"string",game_status:"unsigned",Round:"unsigned"},{primary:"guildId"}),q.model.extend("dice_data",{userId:"string",username:"string",usergender:"string",usersuite:"list"},{primary:"userId"});let v;try{v="file://",await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","dice_1.png"))}catch(e){v=""}const x=[null,await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","dice_1.png")),await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","dice_2.png")),await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","dice_3.png")),await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","dice_4.png")),await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","dice_5.png")),await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","dice_6.png"))],k={"男":await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","nan.png")),"女":await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","nv.png"))};q.middleware(async(e,a)=>{var t=/^[1-6]$/.test(e.content.split(" ")[0]),i=/^[1-6]$/.test(e.content.split(" ")[1]),{userId:r,guildId:s,content:d}=e,n=await q.database.get("dice_group",{guildId:s}),s=n?.[0]?.Play_1_userId.replace(s,"")===r||n?.[0]?.Play_2_userId.replace(s,"")===r;if(1!=t||1!=i||2!=n?.[0]?.game_status||1!=s)return a();e.execute(`点数 ${d.split("-")[0]} `+e.content.split("-")[1])}),q.command("骰子地下城").action(async({session:e})=>{var{}=e;return""+koishi_1.h.image((0,url_1.pathToFileURL)((0,path_1.resolve)(__dirname,"./img/caid.png")).href)}),q.command("骰子地下城").subcommand("创建角色 <name> <genders>").action(async({session:e},a,t)=>{var{userId:e,platform:i}=e,i="qq"==i?"​\n":"",r=await q.database.get("dice_data",{userId:e});return a||t?0!=r.length?i+`══骰子地下城══
- [塑梦](mqqapi://card/show_pslcard?src_type=internal&source=sharecard&version=1&uin=3523335883) - 3523335883`,exports.Config=koishi_1.Schema.object({"管理员":koishi_1.Schema.array(String).required().role("table").description("填写QQ,用与重置对战")}),{"剑":{descriptions:"造成□伤害",trigge:0,austerity:3,dice:"",quantities:1,harm:"□",Category:["造成"]},"匕首":{descriptions:"[1-3]造成□伤害",trigge:0,austerity:1,dice:"1-3",quantities:9,harm:"□",Category:["造成"]},"回旋镖":{descriptions:"造成□*2伤害,自身受到□伤害",trigge:0,austerity:3,quantities:1,harm:"□*2",Category:["造成","自身"]},"火球":{descriptions:"[偶数]造成□伤害,燃烧1个骰子",trigge:0,austerity:2,dice:"偶数",quantities:1,harm:"□",Category:["造成","燃烧"]},"雪球":{descriptions:"[奇数]造成□伤害,冰冻1个骰子",trigge:0,austerity:2,dice:"奇数",quantities:1,harm:"□",Category:["造成","冰冻"]},"诅咒":{descriptions:"[1]造成□+1伤害,施加1层诅咒",trigge:0,austerity:0,dice:1,quantities:1,harm:"□+1",Category:["造成","诅咒"]},"毒药咒语":{descriptions:"[3]施加4层中毒",trigge:0,austerity:0,dice:3,quantities:1,harm:"□+1",Category:["中毒"]},"治愈水晶":{descriptions:"[1-3]回复□生命值",trigge:0,austerity:1,dice:"1-3",quantities:1,harm:"□",Category:["回复"]},"木质盾牌":{descriptions:"[1-4]获得□点护盾",trigge:0,austerity:1,dice:"1-4",quantities:1,harm:"□",Category:["护盾"]},"复制":{descriptions:"[4-6]复制1个骰子",trigge:0,austerity:1,dice:"4-6",quantities:1,harm:"□",Category:["复制"]},"铲":{descriptions:"颠倒1个骰子",trigge:0,austerity:3,dice:"",quantities:1,harm:"□",Category:["颠倒"]},"绝佳手气":{descriptions:"[1-5]重投1个点数更大的骰子",trigge:0,austerity:1,dice:"1-5",quantities:1,harm:"□",Category:["重投更大"]},"战斗翻滚":{descriptions:"重投1个骰子",trigge:0,austerity:3,dice:"",quantities:3,harm:"□",Category:["重投"]},"轻顶":{descriptions:"[1-5]□+1",trigge:0,austerity:1,dice:"1-5",quantities:1,harm:"□+1",Category:["轻顶"]},"干草叉":{descriptions:"[1-4]造成□伤害,燃烧&震慑骰子",trigge:0,austerity:1,dice:"1-4",quantities:1,harm:"□",Category:["造成","燃烧","震慑"]},"渔网":{descriptions:"[1-3]造成□伤害,[3]锁定1个骰子",trigge:3,trigge_skill:["造成","锁定"],austerity:1,dice:"1-3",quantities:1,harm:"□",Category:["造成"]},"吸血":{descriptions:"[1-4]造成□伤害,回复□生命值",trigge:0,austerity:1,dice:"1-4",quantities:1,harm:"□",Category:["造成","回复"]}});async function apply(q,r){q.model.extend("dice_player",{userId:"string",username:"string",HP:{type:"unsigned",initial:0},dice:"list",skills:"list",skill:"json",burn:{type:"unsigned",initial:0},freeze:{type:"unsigned",initial:0},poison:{type:"unsigned",initial:0},curse:{type:"unsigned",initial:0},shield:{type:"unsigned",initial:0},awe:{type:"unsigned",initial:0},lock:{type:"unsigned",initial:0},counterparties:"string"},{primary:"userId"}),q.model.extend("dice_group",{guildId:"string",Play_1_userId:"string",Play_1_username:"string",Play_2_userId:"string",Play_2_username:"string",bout:"string",game_status:"unsigned",Round:"unsigned"},{primary:"guildId"}),q.model.extend("dice_data",{userId:"string",username:"string",usergender:"string",usersuite:"list"},{primary:"userId"});let v;try{v="file://",await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","dice_1.png"))}catch(e){v=""}const x=[null,await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","dice_1.png")),await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","dice_2.png")),await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","dice_3.png")),await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","dice_4.png")),await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","dice_5.png")),await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","dice_6.png"))],k={"男":await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","nan.png")),"女":await q.canvas.loadImage(""+v+(0,path_1.resolve)(__dirname,"./img","nv.png"))};q.middleware(async(e,a)=>{var t=/^[1-6]$/.test(e.content.split(" ")[0]),i=/^[1-6]$/.test(e.content.split(" ")[1]),{userId:r,guildId:s,content:d}=e,n=await q.database.get("dice_group",{guildId:s}),s=n?.[0]?.Play_1_userId.replace(s,"")===r||n?.[0]?.Play_2_userId.replace(s,"")===r;if(1!=t||1!=i||2!=n?.[0]?.game_status||1!=s)return a();e.execute(`点数 ${d.split("-")[0]} `+e.content.split("-")[1])}),q.command("骰子地下城").action(async({session:e})=>{var{}=e;return""+koishi_1.h.image((0,url_1.pathToFileURL)((0,path_1.resolve)(__dirname,"./img/caid.png")).href)}),q.command("骰子地下城").subcommand("创建角色 <name> <genders>").action(async({session:e},a,t)=>{var{userId:e,platform:i}=e,i="qq"==i?"​\n":"",r=await q.database.get("dice_data",{userId:e});return a||t?0!=r.length?i+`══骰子地下城══
创建角色失败

@@ -48,3 +48,4 @@ 你已经创建过角色了`:/^[\u4e00-\u9fa5]{2,6}$/.test(a)&&/^(男|女)$/.test(t)?(await q.database.create("dice_data",{userId:e,username:a,usergender:t}),i+`══骰子地下城══

角色性别:${t}
Tips:性别可以在对战中显示图像`):i+`══骰子地下城══
Tips:输入‘角色信息’查看角色状态
性别可以在对战中显示图像`):i+`══骰子地下城══
姓名暂支持2-6长度的汉字

@@ -55,3 +56,5 @@ 性别暂支持(男|女)

格式错误
正确示例:创建角色 小明 男`}),q.command("骰子地下城").subcommand("角色信息").action(async({session:e})=>{var{userId:e,platform:a}=e,t="qq"==a?"​\n":"",e=await q.database.get("dice_data",{userId:e});return e?.length,koishi_1.h.image(k[a])+t+`══骰子地下城══
正确示例:创建角色 小明 男`}),q.command("骰子地下城").subcommand("角色信息").action(async({session:e})=>{var{userId:e,platform:a}=e,a="qq"==a?"​\n":"",e=await q.database.get("dice_data",{userId:e});return 0==e?.length?a+`══骰子地下城══
角色信息失败
你还没有创建角色`:a+`══骰子地下城══
角色ID:${e?.[0]?.userId}

@@ -125,8 +128,8 @@ 角色昵称:${e?.[0]?.username}

血量清零
${t!=r?.[0]?.Play_1_username?r?.[0]?.Play_1_username:r?.[0]?.Play_2_username}获胜`):""}async function 对战判定(a,t,i,r,e){var s=await a.database.get("dice_player",{userId:i});const d=s?.[0]?.skills[Number(e)-1];var n,c=s?.[0]?.skill,u=s?.[0]?.dice;return 0<s?.[0]?.curse&&1==koishi_1.Random.bool(.5)?(await a.database.set("dice_player",{userId:i},{curse:s?.[0]?.curse-1}),u.splice(u.indexOf(r),1),--c[d],await a.database.set("dice_player",{userId:i},{skill:c,dice:u}),{statu:!0,msg:`══骰子地下城══
${t!=r?.[0]?.Play_1_username?r?.[0]?.Play_1_username:r?.[0]?.Play_2_username}获胜`):""}async function 对战判定(a,t,i,r,e){var s=await a.database.get("dice_player",{userId:i});const d=s?.[0]?.skills[Number(e)-1];var n,c=s?.[0]?.skill,u=s?.[0]?.dice;return 0<s?.[0]?.curse&&1==koishi_1.Random.bool(.5)?(u.splice(u.indexOf(r),1),--c[d],await a.database.set("dice_player",{userId:i},{skill:c,dice:u,curse:s?.[0]?.curse-1}),{statu:!0,msg:`══骰子地下城══
诅咒生效!骰子使用失败
此次使用的骰子和装备照样减少`}):0<s?.[0]?.awe&&e==s?.[0]?.awe?(u.splice(u.indexOf(r),1),await a.database.set("dice_player",{userId:i},{skill:c,dice:u}),{statu:!0,msg:`══骰子地下城══
此次使用的骰子和装备照样减少`}):0<s?.[0]?.awe&&e==s?.[0]?.awe?(u.splice(u.indexOf(r),1),await a.database.set("dice_player",{userId:i},{skill:c,dice:u,awe:s?.[0]?.awe-1}),{statu:!0,msg:`══骰子地下城══
震慑生效!使用骰子解禁装备`}):0<s?.[0]?.burn&&u.indexOf(r)==s?.[0]?.burn-1?(e=r==Introduction[d].trigge?"trigge_skill":"Category",u.splice(u.indexOf(r),1),--c[d],n="",await a.database.set("dice_player",{userId:i},{HP:s?.[0]?.HP-2,burn:s?.[0]?.burn-1,skill:c,dice:u}),{statu:!0,msg:`══骰子地下城══
燃烧生效!血量-2
`+(n+=(await Promise.all(Introduction[d][e].map(async e=>effect[e](a,""+(t+i),r,Introduction[d].harm)))).join("\n"))}):{statu:!1,msg:""}}async function drawHPBar(e,a,t){var e=await e.canvas.createCanvas(300,60),i=e.getContext("2d"),r=(i.clearRect(0,0,300,60),Math.floor(a/t*100)),r=Math.floor(r/100*300),r=(i.fillStyle="white",i.fillRect(0,0,300,60),i.fillStyle="red",i.fillRect(0,0,r,60),i.fillStyle="black",i.font="50px Unifont-JP","HP: "+a+"/"+t);return i.fillText(r,0,43),e.toBuffer()}async function 状态判定(e,a){const t=await e.database.get("dice_player",{userId:a});var i=t?.[0]?.dice;return 1<=t?.[0]?.freeze?(i=i.map((e,a)=>a<t?.[0]?.freeze?1:e),await e.database.set("dice_player",{userId:a},{dice:i,freeze:t?.[0]?.freeze-1}),`冰冻${t?.[0]?.freeze}骰子`):1<=t?.[0]?.poison?(await e.database.set("dice_player",{userId:a},{HP:t?.[0]?.HP-t?.[0]?.poison,poison:t?.[0]?.poison-1}),"中毒 血量-"+t?.[0]?.poison):""}async function 护盾判定(e,a,t){var i=await e.database.get("dice_player",{userId:a});return i?.[0]?.shield>t?(await e.database.set("dice_player",{userId:a},{shield:i?.[0]?.shield-t}),`护盾抵挡${t}伤害`):(await e.database.set("dice_player",{userId:a},{HP:i?.[0]?.HP-(t-i?.[0]?.shield),shield:0}),`护盾抵挡${i?.[0]?.shield}伤害,承受了${t-i?.[0]?.shield}伤害`)}function HP(e,a){e<0?e=0:a<e&&(e=a);a=Math.floor(e/a*100),a=Math.floor(a/10);return"["+"=".repeat(a)+" ".repeat(10-a)+"]"+e}async function Display_Status(e,a){e=await e.database.get("dice_player",{userId:a});const t=["燃烧","冰冻","中毒","诅咒","护盾","震撼","锁定"],i={0:e?.[0]?.burn,1:e?.[0]?.freeze,2:e?.[0]?.poison,3:e?.[0]?.curse,4:e?.[0]?.shield,5:e?.[0]?.awe,6:e?.[0]?.lock};return Object.keys(i).filter(e=>0<=parseInt(e)&&parseInt(e)<t.length&&0<i[e]).map(e=>t[parseInt(e)]+"x"+i[e]).join(" ")||"暂无"}function Show_Dice(e){let a="";const t=["0","⚀","⚁","⚂","⚃","⚄","⚅"];return e.filter(e=>{a+=t[e]+" "}),a}async function Show_equipment(e,a){let t="",i=0;return e.forEach(e=>{i++,0<a[e]&&(t+=`${i}.${Introduction[e].descriptions} \n`)}),t}async function Generating_equipment(e,a){var t=[random.pick(["剑","匕首","回旋镖","干草叉"]),random.pick(["毒药咒语","火球","吸血","雪球","诅咒","渔网"]),random.pick(["治愈水晶","木质盾牌"]),random.pick(["绝佳手气","复制","铲","轻顶"]),random.pick(["战斗翻滚"])],i={[t[0]]:Introduction[t[0]].quantities,[t[1]]:Introduction[t[1]].quantities,[t[2]]:Introduction[t[2]].quantities,[t[3]]:Introduction[t[3]].quantities,[t[4]]:Introduction[t[4]].quantities},r=[""+random.int(1,7),""+random.int(1,7),""+random.int(1,7),""+random.int(1,7)];await e.database.create("dice_player",{userId:a,HP:50,skills:t,skill:i,dice:r})}async function Generate_Dice(e,a){var t=new koishi_1.Random(()=>Math.random()),t=[""+t.int(1,7),""+t.int(1,7),""+t.int(1,7),""+t.int(1,7)];await e.database.set("dice_player",{userId:a},{dice:t})}async function Reset_times(e,a){var t=(await e.database.get("dice_player",{userId:a}))?.[0]?.skills,t={[t[0]]:Introduction[t[0]].quantities,[t[1]]:Introduction[t[1]].quantities,[t[2]]:Introduction[t[2]].quantities,[t[3]]:Introduction[t[3]].quantities,[t[4]]:Introduction[t[4]].quantities};await e.database.set("dice_player",{userId:a},{skill:t})}async function Dice_Decision(e,a,t){return 0==e&&a==t||1==e&&Number(a)>=Number(t.split("-")[0])&&Number(a)<=Number(t.split("-")[1])||2==e&&"偶数"==t&&a%2==0||2==e&&"奇数"==t&&a%2==1||3==e}exports.apply=apply;const effect={async"锁定"(e,a,t,i){a=await e.database.get("dice_player",{userId:a});return await e.database.set("dice_player",{userId:a?.[0]?.counterparties},{lock:a?.[0]?.lock+1}),"施加状态:锁定*1"},async"颠倒"(e,a,t,i){var r=await e.database.get("dice_player",{userId:a}),t=7-Number(t),r=r?.[0]?.dice;return r?.push(t),await e.database.set("dice_player",{userId:a},{dice:r}),"骰子点数变为"+t},async"轻顶"(ctx,userId,dice,harm){const dice_player=await ctx.database.get("dice_player",{userId:userId}),new_hanrm=eval(harm.replace("□",Number(dice))),dices=dice_player?.[0]?.dice;return dices?.push(new_hanrm),await ctx.database.set("dice_player",{userId:userId},{dice:dices}),`将骰子转为${new_hanrm}点`},async"重投更大"(e,a,t,i){var r=await e.database.get("dice_player",{userId:a}),t=random.int(Number(t)+1,6),r=r?.[0]?.dice;return r?.push(t),await e.database.set("dice_player",{userId:a},{dice:r}),`重投更大骰子${t}点`},async"重投"(e,a,t,i){var r=await e.database.get("dice_player",{userId:a}),s=random.int(1,6),r=r?.[0]?.dice;return r?.push(s),await e.database.set("dice_player",{userId:a},{dice:r}),`重投骰子${s}点`},async"复制"(ctx,userId,dice,harm){const dice_player=await ctx.database.get("dice_player",{userId:userId}),new_hanrm=eval(harm.replace("□",dice)),dices=dice_player?.[0]?.dice;return dices.push(new_hanrm),await ctx.database.set("dice_player",{userId:userId},{dice:dices}),"复制了一个骰子"},async"诅咒"(e,a,t,i=0){a=await e.database.get("dice_player",{userId:a});return await e.database.set("dice_player",{userId:a?.[0]?.counterparties},{curse:a?.[0]?.curse+1}),"施加状态:诅咒*1"},async"震慑"(e,a,t,i){a=await e.database.get("dice_player",{userId:a});return await e.database.set("dice_player",{userId:a?.[0]?.counterparties},{awe:a?.[0]?.awe+1}),"施加状态:震慑*1"},async"燃烧"(e,a,t,i=0){a=await e.database.get("dice_player",{userId:a});return await e.database.set("dice_player",{userId:a?.[0]?.counterparties},{burn:a?.[0]?.burn+1}),"施加状态:燃烧*1"},async"护盾"(ctx,userId,dice,harm){const dice_player=await ctx.database.get("dice_player",{userId:userId}),new_hanrm=eval(harm.replace("□",dice));return await ctx.database.set("dice_player",{userId:userId},{shield:dice_player?.[0]?.shield+new_hanrm}),"施加状态:护盾*"+new_hanrm},async"冰冻"(e,a,t,i=0){a=await e.database.get("dice_player",{userId:a});return await e.database.set("dice_player",{userId:a?.[0]?.counterparties},{freeze:a?.[0]?.freeze+1}),"施加状态:冰冻*1"},async"中毒"(ctx,userId,dice,harm=""){const dice_player=await ctx.database.get("dice_player",{userId:userId}),dice_player_2=await ctx.database.get("dice_player",{userId:dice_player?.[0]?.counterparties}),new_hanrm=eval(harm.replace("□",dice));return await ctx.database.set("dice_player",{userId:dice_player?.[0]?.counterparties},{poison:dice_player_2?.[0]?.poison+4}),"施加状态:中毒*"+new_hanrm},async"回复"(e,a,t,i=0){var r=await e.database.get("dice_player",{userId:a}),r=Number(t)+r?.[0]?.HP;return await e.database.set("dice_player",{userId:a},{HP:50<=r?50:r}),`回复${t}生命值
`+(n+=(await Promise.all(Introduction[d][e].map(async e=>effect[e](a,""+(t+i),r,Introduction[d].harm)))).join("\n"))}):{statu:!1,msg:""}}async function drawHPBar(e,a,t){var e=await e.canvas.createCanvas(300,60),i=e.getContext("2d"),r=(i.clearRect(0,0,300,60),Math.floor(a/t*100)),r=Math.floor(r/100*300),r=(i.fillStyle="white",i.fillRect(0,0,300,60),i.fillStyle="red",i.fillRect(0,0,r,60),i.fillStyle="black",i.font="50px Unifont-JP","HP: "+a+"/"+t);return i.fillText(r,0,43),e.toBuffer()}async function 状态判定(e,a){const t=await e.database.get("dice_player",{userId:a});var i=t?.[0]?.dice;return 1<=t?.[0]?.freeze?(i=i.map((e,a)=>a<t?.[0]?.freeze?1:e),await e.database.set("dice_player",{userId:a},{dice:i,freeze:t?.[0]?.freeze-1}),`冰冻${t?.[0]?.freeze}骰子`):1<=t?.[0]?.poison?(await e.database.set("dice_player",{userId:a},{HP:t?.[0]?.HP-t?.[0]?.poison,poison:t?.[0]?.poison-1}),"中毒 血量-"+t?.[0]?.poison):""}async function 护盾判定(e,a,t){var i=await e.database.get("dice_player",{userId:a});return i?.[0]?.shield>t?(await e.database.set("dice_player",{userId:a},{shield:i?.[0]?.shield-t}),`护盾抵挡${t}伤害`):(await e.database.set("dice_player",{userId:a},{HP:i?.[0]?.HP-(t-i?.[0]?.shield),shield:0}),`护盾抵挡${i?.[0]?.shield}伤害,承受了${t-i?.[0]?.shield}伤害`)}function HP(e,a){e<0?e=0:a<e&&(e=a);a=Math.floor(e/a*100),a=Math.floor(a/10);return"["+"=".repeat(a)+" ".repeat(10-a)+"]"+e}async function Display_Status(e,a){e=await e.database.get("dice_player",{userId:a});const t=["燃烧","冰冻","中毒","诅咒","护盾","震撼","锁定"],i={0:e?.[0]?.burn,1:e?.[0]?.freeze,2:e?.[0]?.poison,3:e?.[0]?.curse,4:e?.[0]?.shield,5:e?.[0]?.awe,6:e?.[0]?.lock};return Object.keys(i).filter(e=>0<=parseInt(e)&&parseInt(e)<t.length&&0<i[e]).map(e=>t[parseInt(e)]+"x"+i[e]).join(" ")||"暂无"}function Show_Dice(e){let a="";const t=["0","⚀","⚁","⚂","⚃","⚄","⚅"];return e.filter(e=>{a+=t[e]+" "}),a}async function Show_equipment(e,a){let t="",i=0;return e.forEach(e=>{i++,0<a[e]&&(t+=`${i}.${Introduction[e].descriptions} \n`)}),t}async function Generating_equipment(e,a){var t=[random.pick(["剑","匕首","回旋镖","干草叉"]),random.pick(["毒药咒语","火球","吸血","雪球","诅咒"]),random.pick(["治愈水晶","木质盾牌"]),random.pick(["绝佳手气","铲","轻顶"]),random.pick(["战斗翻滚"])],i={[t[0]]:Introduction[t[0]].quantities,[t[1]]:Introduction[t[1]].quantities,[t[2]]:Introduction[t[2]].quantities,[t[3]]:Introduction[t[3]].quantities,[t[4]]:Introduction[t[4]].quantities},r=[""+random.int(1,7),""+random.int(1,7),""+random.int(1,7),""+random.int(1,7)];await e.database.create("dice_player",{userId:a,HP:50,skills:t,skill:i,dice:r})}async function Generate_Dice(e,a){var t=new koishi_1.Random(()=>Math.random()),t=[""+t.int(1,7),""+t.int(1,7),""+t.int(1,7),""+t.int(1,7)];await e.database.set("dice_player",{userId:a},{dice:t})}async function Reset_times(e,a){var t=(await e.database.get("dice_player",{userId:a}))?.[0]?.skills,t={[t[0]]:Introduction[t[0]].quantities,[t[1]]:Introduction[t[1]].quantities,[t[2]]:Introduction[t[2]].quantities,[t[3]]:Introduction[t[3]].quantities,[t[4]]:Introduction[t[4]].quantities};await e.database.set("dice_player",{userId:a},{skill:t})}async function Dice_Decision(e,a,t){return 0==e&&a==t||1==e&&Number(a)>=Number(t.split("-")[0])&&Number(a)<=Number(t.split("-")[1])||2==e&&"偶数"==t&&a%2==0||2==e&&"奇数"==t&&a%2==1||3==e}exports.apply=apply;const effect={async"锁定"(e,a,t,i){a=await e.database.get("dice_player",{userId:a});return await e.database.set("dice_player",{userId:a?.[0]?.counterparties},{lock:a?.[0]?.lock+1}),"施加状态:锁定*1"},async"颠倒"(e,a,t,i){var r=await e.database.get("dice_player",{userId:a}),t=7-Number(t),r=r?.[0]?.dice;return r?.push(t),await e.database.set("dice_player",{userId:a},{dice:r}),"骰子点数变为"+t},async"轻顶"(ctx,userId,dice,harm){const dice_player=await ctx.database.get("dice_player",{userId:userId}),new_hanrm=eval(harm.replace("□",Number(dice))),dices=dice_player?.[0]?.dice;return dices?.push(new_hanrm),await ctx.database.set("dice_player",{userId:userId},{dice:dices}),`将骰子转为${new_hanrm}点`},async"重投更大"(e,a,t,i){var r=await e.database.get("dice_player",{userId:a}),t=random.int(Number(t)+1,6),r=r?.[0]?.dice;return r?.push(t),await e.database.set("dice_player",{userId:a},{dice:r}),`重投更大骰子${t}点`},async"重投"(e,a,t,i){var r=await e.database.get("dice_player",{userId:a}),s=random.int(1,6),r=r?.[0]?.dice;return r?.push(s),await e.database.set("dice_player",{userId:a},{dice:r}),`重投骰子${s}点`},async"复制"(ctx,userId,dice,harm){const dice_player=await ctx.database.get("dice_player",{userId:userId}),new_hanrm=eval(harm.replace("□",dice)),dices=dice_player?.[0]?.dice;return dices.push(new_hanrm),await ctx.database.set("dice_player",{userId:userId},{dice:dices}),"复制了一个骰子"},async"诅咒"(e,a,t,i=0){a=await e.database.get("dice_player",{userId:a});return await e.database.set("dice_player",{userId:a?.[0]?.counterparties},{curse:a?.[0]?.curse+1}),"施加状态:诅咒*1"},async"震慑"(e,a,t,i){a=await e.database.get("dice_player",{userId:a});return await e.database.set("dice_player",{userId:a?.[0]?.counterparties},{awe:a?.[0]?.awe+1}),"施加状态:震慑*1"},async"燃烧"(e,a,t,i=0){a=await e.database.get("dice_player",{userId:a});return await e.database.set("dice_player",{userId:a?.[0]?.counterparties},{burn:a?.[0]?.burn+1}),"施加状态:燃烧*1"},async"护盾"(ctx,userId,dice,harm){const dice_player=await ctx.database.get("dice_player",{userId:userId}),new_hanrm=eval(harm.replace("□",dice));return await ctx.database.set("dice_player",{userId:userId},{shield:dice_player?.[0]?.shield+new_hanrm}),"施加状态:护盾*"+new_hanrm},async"冰冻"(e,a,t,i=0){a=await e.database.get("dice_player",{userId:a});return await e.database.set("dice_player",{userId:a?.[0]?.counterparties},{freeze:a?.[0]?.freeze+1}),"施加状态:冰冻*1"},async"中毒"(ctx,userId,dice,harm=""){const dice_player=await ctx.database.get("dice_player",{userId:userId}),dice_player_2=await ctx.database.get("dice_player",{userId:dice_player?.[0]?.counterparties}),new_hanrm=eval(harm.replace("□",dice));return await ctx.database.set("dice_player",{userId:dice_player?.[0]?.counterparties},{poison:dice_player_2?.[0]?.poison+4}),"施加状态:中毒*"+new_hanrm},async"回复"(e,a,t,i=0){var r=await e.database.get("dice_player",{userId:a}),r=Number(t)+r?.[0]?.HP;return await e.database.set("dice_player",{userId:a},{HP:50<=r?50:r}),`回复${t}生命值
`},async"造成"(ctx,userId,dice,harm){const dice_player=await ctx.database.get("dice_player",{userId:userId}),dice_player_2=await ctx.database.get("dice_player",{userId:dice_player?.[0]?.counterparties}),new_hanrm=eval(harm.replace("□",Number(dice)));return Number(dice_player_2?.[0]?.shield)<=0||!dice_player_2?.[0]?.shield?(await ctx.database.set("dice_player",{userId:dice_player?.[0]?.counterparties},{HP:dice_player_2?.[0]?.HP-new_hanrm}),`造成${new_hanrm}伤害`):护盾判定(ctx,dice_player?.[0]?.counterparties,new_hanrm)},async"自身"(e,a,t,i){var r=await e.database.get("dice_player",{userId:a});return Number(r?.[0]?.shield)<=0||!r?.[0]?.shield?(await e.database.set("dice_player",{userId:a},{HP:r?.[0]?.HP-t}),`自身受到${t}伤害`):护盾判定(e,a,t)}};

6

package.json
{
"name": "koishi-plugin-dicey-dungeons",
"description": "中文名:骰子地下城 双人回合对战",
"version": "1.3.9",
"version": "1.4.0",
"main": "lib/index.js",

@@ -16,3 +16,5 @@ "typings": "lib/index.d.ts",

"service": {
"required": ["canvas"]
"required": [
"canvas"
]
},

@@ -19,0 +21,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc