Skip to content

Instantly share code, notes, and snippets.

# frozen_string_literal: true
require "bcdice/base"
module BCDice
module GameSystem
class Template < Base
# ゲームシステムの識別子
ID = "Template"
# シンタックスハイライトのために .rb にしていますが、このままでは動きません。raccを通す必要があります。
class AddDice
token NUMBER D K H L U R PLUS MINUS ASTERISK SLASH PARENL PARENR LESS GREATER EQUAL NOT
rule
expr: add
| add cmp_op add
{ result = val }
cmp_op: LESS EQUAL
@ysakasin
ysakasin / game_system.rb
Last active October 31, 2020 17:45
BCDice v3でevalの戻り値を結果用インスタンスにする案
require_relative "rands"
require_relative "result"
module BCDice
class Evaluator
class << self
def eval(command)
new(command).eval
end
end
// This code based on http://blog.graviness.com/?eid=795859
/*
A C-program for MT19937, with initialization improved 2002/1/26.
Coded by Takuji Nishimura and Makoto Matsumoto.
Before using, initialize the state by using init_genrand(seed)
or init_by_array(init_key, key_length).
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
@ysakasin
ysakasin / README.md
Last active October 3, 2020 10:16
OpelのMT19937の検定をしてみる
require "strscan"
p ARGV
files = Dir[ARGV[0]]
p files
def dump(class_name, data)
ret = ""
ret += "[[ test ]]\n"
ret += "game_system = #{class_name.inspect}\n"
@ysakasin
ysakasin / coc7th.md
Last active May 22, 2023 14:53
新クトゥルフ神話TRPG ボーナスダイス/ペナルティダイス 成功確率早見表

新クトゥルフ神話TRPG

ボーナスダイス/ペナルティダイス 成功確率早見表

全て%表記

# -2 -1 0 +1 +2
1 0.01 0.1 1 1.9 2.71
2 0.02 0.2 2 3.8 5.42
3 0.03 0.3 3 5.7 8.13
module BCDice
VERSION = "3.0.0b"
# @return [Class]
def self.game_system_class(id)
# ...
end
end
class BCDice::GameSystem::Base
$ bundle exec rake
/Users/ysakasin/.rbenv/versions/2.6.1/bin/ruby -I/Users/ysakasin/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rspec-core-3.9.0/lib:/Users/ysakasin/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rspec-support-3.9.0/lib /Users/ysakasin/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rspec-core-3.9.0/exe/rspec --pattern spec/lib/\*\*/\*_spec.rb
/Users/ysakasin/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/parser-2.6.4.1/lib/parser/lexer.rb:10922: warning: assigned but unused variable - testEof
/Users/ysakasin/src/opal/spec/support/source_map_helper.rb:61: warning: assigned but unused variable - next_section
Randomized with seed 11358
.......................................................................................................................................................................................................................warning: Removed semicolon ending x-string expression, interpreted as unintentional -- (file):3
warning: Removed semicolon ending x-string expressio