Skip to content

Commit

Permalink
[Irisbane] 年齢チャート(p27)を実装
Browse files Browse the repository at this point in the history
  • Loading branch information
ViVi committed Jun 25, 2021
1 parent b1318fd commit 6323f62
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/bcdice/game_system/Irisbane.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class Irisbane < Base
例) ATTACK2,3,5[+10]
例) ATK10,2,4[-8]
例) AT8,3,2[-8+5]
■表
CAge 年齢(p27)
HELP

ATTACK_ROLL_REG = %r{^AT(TACK|K)?([+\-*/()\d]+),([+\-*/()\d]+),([+\-*/()\d]+)(\[([+\-])([+\-*/()\d]+)\])?}i.freeze
Expand All @@ -47,6 +50,8 @@ def initialize(command)
def eval_game_system_specific_command(command)
if (m = ATTACK_ROLL_REG.match(command))
roll_attack(m[2], m[3], m[4], m[6], m[7])
else
roll_tables(command, TABLES)
end
end

Expand Down Expand Up @@ -111,6 +116,23 @@ def parse_operator(operator)
lambda { |x, y| x - y }
end
end

TABLES = {
"CAGE" => DiceTable::Table.new(
"年齢",
"1D6",
[
"【幼年】誕生から一桁代。",
"【少年】十代真っ盛り。",
"【青年】二十代から三十代。",
"【壮年】三十代から五十代。",
"【老年】六十代からそれ以上。",
"【晩年】百歳またはそれ以上。",
]
),
}.freeze

register_prefix(TABLES.keys)
end
end
end
8 changes: 8 additions & 0 deletions test/data/Irisbane.toml
Original file line number Diff line number Diff line change
Expand Up @@ -412,3 +412,11 @@ rands = [
{ sides = 6, value = 5 },
]
success = true

[[ test ]]
game_system = "Irisbane"
input = "CAge"
output = "年齢(1) > 【幼年】誕生から一桁代。"
rands = [
{ sides = 6, value = 1 },
]

0 comments on commit 6323f62

Please sign in to comment.