Skip to content

Commit f234d4d

Browse files
committed
Use DiceRoller logs
1 parent 87922ab commit f234d4d

File tree

4 files changed

+7
-18
lines changed

4 files changed

+7
-18
lines changed

lib/rollmaster/dice_engine.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def self.attach_function(ctx)
2727
ctx.eval <<~JS
2828
function roll(...diceRolls) {
2929
const roller = new rpgDiceRoller.DiceRoller;
30-
const rolls = roller.roll(...diceRolls);
31-
return rolls
30+
roller.roll(...diceRolls);
31+
return JSON.parse(JSON.stringify(roller.log))
3232
}
3333
JS
3434
end

scripts/debug.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const { DiceRoller } = require("@dice-roller/rpg-dice-roller");
1111

1212
function roll(...diceRolls) {
1313
const roller = new DiceRoller();
14-
const rolls = roller.roll(...diceRolls);
15-
return rolls;
14+
roller.roll(...diceRolls);
15+
return roller.log;
1616
}
1717

1818
const r = repl.start({ prompt: "> " });

spec/lib/rollmaster/dice_engine_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
result = described_class.roll(*dice_rolls)
1010

1111
expect(result).not_to be_nil
12-
expect(result).to be_a(String) # Assuming the result is serialized as a string
12+
expect(result).to be_a(Hash) # Assuming the result is serialized as a string
1313
end
1414
end
1515

@@ -59,11 +59,11 @@
5959
end
6060

6161
xdescribe ".attach_function" do
62-
xit "attaches the rollmaster_roll function to the context" do
62+
xit "attaches the roll function to the context" do
6363
context = MiniRacer::Context.new
6464
described_class.attach_function(context)
6565

66-
result = context.eval("typeof rollmaster_roll")
66+
result = context.eval("typeof roll")
6767
expect(result).to eq("function")
6868
end
6969
end

tsconfig.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)