Skip to content

Commit

Permalink
Merge pull request #12 from nekooftheabyss/dev
Browse files Browse the repository at this point in the history
fix stuff
  • Loading branch information
retraigo authored Aug 5, 2022
2 parents 1e32ee5 + 3329ccb commit 9c56f05
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ class GachaMachine {
static roll(choices, totalChance) {
let total = totalChance || 0;
let i = 0;
while(i < choices.length){
total += choices[i].chance;
i += 1;
if (!total) {
while(i < choices.length){
total += choices[i].chance;
i += 1;
}
}
const result = Math.random() * total;
let going = 0.0;
Expand Down
8 changes: 5 additions & 3 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,11 @@ export class GachaMachine<ItemType> {
): GachaChoice<ItemType> {
let total = totalChance || 0;
let i = 0;
while (i < choices.length) {
total += choices[i].chance;
i += 1;
if (!total) {
while (i < choices.length) {
total += choices[i].chance;
i += 1;
}
}
const result = Math.random() * total;
let going = 0.0;
Expand Down

0 comments on commit 9c56f05

Please sign in to comment.