Skip to content

Commit

Permalink
CS Case Sim
Browse files Browse the repository at this point in the history
  • Loading branch information
stdcall0 committed Apr 16, 2024
1 parent e70b703 commit d13e87d
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions apps/cs_casesim.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Plugin, Common, Lottery } from '#gc';
import lodash from 'lodash';

const RarityLot = new Lottery(
['金', '红', '粉', '紫', '蓝'],
[0.26, 0.64, 3.2, 15.98, 79.92]
);
const FloatLot = new Lottery(
[
function fn() {
// random value 0.00-0.07
return "Factory New " + lodash.random(0.00, 0.07, true).toFixed(3);
},
function mw() {
// 0.07-0.15
return "Minimal Wear " + lodash.random(0.07, 0.15, true).toFixed(3);
},
function ft() {
// 0.15-0.38
return "Field-Tested " + lodash.random(0.15, 0.38, true).toFixed(3);
},
function ww() {
// 0.38-0.45
return "Well-Worn " + lodash.random(0.38, 0.45, true).toFixed(3);
},
function bs() {
// 0.45-1.00
return "Battle-Scarred " + lodash.random(0.45, 1.00, true).toFixed(3);
}
],
[3,24,33,24,16]
);
const PaintLot = new Lottery(
// a list containing 0 - 999
lodash.range(0, 1000),
);

export class CSCaseSimPlugin extends Plugin {
constructor() {
super({
name: 'CSCaseSimPlugin',
dsc: 'CS2 Case Opening Simulation (gacha_plugin)',
event: 'message',
priority: '98',
rule: [
{
reg: '^!开箱.*$',
fnc: 'single'
}
]
});
}

async single() {
const rarity = RarityLot.choice();
const float = FloatLot.choice()();
const paint = PaintLot.choice();
const result = `\n稀有度:${rarity}\n磨损:${float}\n图案模版:${paint}`;
await this.reply(result, true);
}
};

0 comments on commit d13e87d

Please sign in to comment.