bcdice 3.0.0.pre.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.editorconfig +21 -0
- data/.github/.codecov.yaml +10 -0
- data/.github/workflows/coverage.yaml +21 -0
- data/.github/workflows/lint.yaml +13 -0
- data/.github/workflows/test.yml +20 -0
- data/.gitignore +14 -0
- data/.rubocop.yml +96 -0
- data/.rubocop_todo.yml +113 -0
- data/CHANGELOG.md +868 -0
- data/Gemfile +11 -0
- data/LICENSE +29 -0
- data/README.md +38 -0
- data/ROADMAP.md +30 -0
- data/Rakefile +118 -0
- data/bcdice.gemspec +27 -0
- data/bin/repl.rb +21 -0
- data/docs/README.txt +2028 -0
- data/docs/dicebot_sort_key.md +72 -0
- data/docs/how_to_make_dicebot.md +453 -0
- data/lib/bcdice.rb +8 -0
- data/lib/bcdice/arithmetic_evaluator.rb +167 -0
- data/lib/bcdice/base.rb +423 -0
- data/lib/bcdice/command_parser.rb +242 -0
- data/lib/bcdice/common_command.rb +23 -0
- data/lib/bcdice/common_command/add_dice.rb +54 -0
- data/lib/bcdice/common_command/add_dice/node.rb +488 -0
- data/lib/bcdice/common_command/add_dice/parser.rb +282 -0
- data/lib/bcdice/common_command/add_dice/randomizer.rb +48 -0
- data/lib/bcdice/common_command/barabara_dice.rb +57 -0
- data/lib/bcdice/common_command/calc.rb +39 -0
- data/lib/bcdice/common_command/choice.rb +35 -0
- data/lib/bcdice/common_command/d66_dice.rb +63 -0
- data/lib/bcdice/common_command/reroll_dice.rb +190 -0
- data/lib/bcdice/common_command/upper_dice.rb +165 -0
- data/lib/bcdice/common_command/version.rb +26 -0
- data/lib/bcdice/dice_table.rb +8 -0
- data/lib/bcdice/dice_table/chain_table.rb +33 -0
- data/lib/bcdice/dice_table/d66_grid_table.rb +26 -0
- data/lib/bcdice/dice_table/d66_range_table.rb +26 -0
- data/lib/bcdice/dice_table/d66_table.rb +34 -0
- data/lib/bcdice/dice_table/range_table.rb +267 -0
- data/lib/bcdice/dice_table/roll_result.rb +43 -0
- data/lib/bcdice/dice_table/sai_fic_skill_table.rb +32 -0
- data/lib/bcdice/dice_table/table.rb +35 -0
- data/lib/bcdice/enum.rb +15 -0
- data/lib/bcdice/format.rb +36 -0
- data/lib/bcdice/game_system.rb +187 -0
- data/lib/bcdice/game_system/AFF2e.rb +141 -0
- data/lib/bcdice/game_system/AceKillerGene.rb +55 -0
- data/lib/bcdice/game_system/Airgetlamh.rb +117 -0
- data/lib/bcdice/game_system/Alsetto.rb +124 -0
- data/lib/bcdice/game_system/Alshard.rb +27 -0
- data/lib/bcdice/game_system/AlterRaise.rb +282 -0
- data/lib/bcdice/game_system/Amadeus.rb +622 -0
- data/lib/bcdice/game_system/Amadeus_Korean.rb +501 -0
- data/lib/bcdice/game_system/AnimaAnimus.rb +96 -0
- data/lib/bcdice/game_system/Arianrhod.rb +50 -0
- data/lib/bcdice/game_system/ArsMagica.rb +149 -0
- data/lib/bcdice/game_system/Avandner.rb +101 -0
- data/lib/bcdice/game_system/BBN.rb +143 -0
- data/lib/bcdice/game_system/BadLife.rb +435 -0
- data/lib/bcdice/game_system/BarnaKronika.rb +188 -0
- data/lib/bcdice/game_system/BattleTech.rb +530 -0
- data/lib/bcdice/game_system/BeastBindTrinity.rb +348 -0
- data/lib/bcdice/game_system/BeginningIdol.rb +2527 -0
- data/lib/bcdice/game_system/BeginningIdol_Korean.rb +2378 -0
- data/lib/bcdice/game_system/BladeOfArcana.rb +252 -0
- data/lib/bcdice/game_system/BlindMythos.rb +460 -0
- data/lib/bcdice/game_system/BloodCrusade.rb +423 -0
- data/lib/bcdice/game_system/BloodMoon.rb +213 -0
- data/lib/bcdice/game_system/CardRanker.rb +249 -0
- data/lib/bcdice/game_system/ChaosFlare.rb +181 -0
- data/lib/bcdice/game_system/Chill.rb +163 -0
- data/lib/bcdice/game_system/Chill3.rb +52 -0
- data/lib/bcdice/game_system/CodeLayerd.rb +132 -0
- data/lib/bcdice/game_system/ColossalHunter.rb +569 -0
- data/lib/bcdice/game_system/CrashWorld.rb +81 -0
- data/lib/bcdice/game_system/Cthulhu.rb +252 -0
- data/lib/bcdice/game_system/Cthulhu7th.rb +767 -0
- data/lib/bcdice/game_system/Cthulhu7th_ChineseTraditional.rb +386 -0
- data/lib/bcdice/game_system/Cthulhu7th_Korean.rb +383 -0
- data/lib/bcdice/game_system/CthulhuTech.rb +263 -0
- data/lib/bcdice/game_system/Cthulhu_ChineseTraditional.rb +243 -0
- data/lib/bcdice/game_system/Cthulhu_Korean.rb +240 -0
- data/lib/bcdice/game_system/DarkBlaze.rb +207 -0
- data/lib/bcdice/game_system/DarkDaysDrive.rb +425 -0
- data/lib/bcdice/game_system/DarkSouls.rb +91 -0
- data/lib/bcdice/game_system/DeadlineHeroes.rb +583 -0
- data/lib/bcdice/game_system/DemonParasite.rb +524 -0
- data/lib/bcdice/game_system/DetatokoSaga.rb +310 -0
- data/lib/bcdice/game_system/DetatokoSaga_Korean.rb +310 -0
- data/lib/bcdice/game_system/DiceBot.rb +17 -0
- data/lib/bcdice/game_system/DiceOfTheDead.rb +111 -0
- data/lib/bcdice/game_system/DoubleCross.rb +373 -0
- data/lib/bcdice/game_system/DoubleCross_Korean.rb +371 -0
- data/lib/bcdice/game_system/Dracurouge.rb +1856 -0
- data/lib/bcdice/game_system/Dracurouge_Korean.rb +310 -0
- data/lib/bcdice/game_system/DungeonsAndDragons.rb +19 -0
- data/lib/bcdice/game_system/EarthDawn.rb +225 -0
- data/lib/bcdice/game_system/EarthDawn3.rb +275 -0
- data/lib/bcdice/game_system/EarthDawn4.rb +272 -0
- data/lib/bcdice/game_system/EclipsePhase.rb +51 -0
- data/lib/bcdice/game_system/Elric.rb +36 -0
- data/lib/bcdice/game_system/Elysion.rb +1213 -0
- data/lib/bcdice/game_system/EmbryoMachine.rb +227 -0
- data/lib/bcdice/game_system/EndBreaker.rb +132 -0
- data/lib/bcdice/game_system/EtrianOdysseySRS.rb +27 -0
- data/lib/bcdice/game_system/Fiasco.rb +123 -0
- data/lib/bcdice/game_system/Fiasco_Korean.rb +122 -0
- data/lib/bcdice/game_system/FilledWith.rb +1543 -0
- data/lib/bcdice/game_system/FullMetalPanic.rb +27 -0
- data/lib/bcdice/game_system/FutariSousa.rb +994 -0
- data/lib/bcdice/game_system/FutariSousa_Korean.rb +994 -0
- data/lib/bcdice/game_system/Garako.rb +559 -0
- data/lib/bcdice/game_system/GardenOrder.rb +451 -0
- data/lib/bcdice/game_system/GehennaAn.rb +136 -0
- data/lib/bcdice/game_system/GeishaGirlwithKatana.rb +120 -0
- data/lib/bcdice/game_system/GoblinSlayer.rb +168 -0
- data/lib/bcdice/game_system/GoldenSkyStories.rb +77 -0
- data/lib/bcdice/game_system/Gorilla.rb +44 -0
- data/lib/bcdice/game_system/GranCrest.rb +518 -0
- data/lib/bcdice/game_system/Gundog.rb +52 -0
- data/lib/bcdice/game_system/GundogRevised.rb +294 -0
- data/lib/bcdice/game_system/GundogZero.rb +261 -0
- data/lib/bcdice/game_system/Gurps.rb +403 -0
- data/lib/bcdice/game_system/GurpsFW.rb +2330 -0
- data/lib/bcdice/game_system/HarnMaster.rb +208 -0
- data/lib/bcdice/game_system/HatsuneMiku.rb +706 -0
- data/lib/bcdice/game_system/Hieizan.rb +48 -0
- data/lib/bcdice/game_system/HouraiGakuen.rb +270 -0
- data/lib/bcdice/game_system/HuntersMoon.rb +503 -0
- data/lib/bcdice/game_system/Illusio.rb +89 -0
- data/lib/bcdice/game_system/InfiniteFantasia.rb +51 -0
- data/lib/bcdice/game_system/Insane.rb +822 -0
- data/lib/bcdice/game_system/Insane_Korean.rb +773 -0
- data/lib/bcdice/game_system/IthaWenUa.rb +38 -0
- data/lib/bcdice/game_system/JamesBond.rb +45 -0
- data/lib/bcdice/game_system/Kamigakari.rb +394 -0
- data/lib/bcdice/game_system/Kamigakari_Korean.rb +428 -0
- data/lib/bcdice/game_system/KanColle.rb +938 -0
- data/lib/bcdice/game_system/KemonoNoMori.rb +258 -0
- data/lib/bcdice/game_system/KillDeathBusiness.rb +1420 -0
- data/lib/bcdice/game_system/KillDeathBusiness_Korean.rb +1510 -0
- data/lib/bcdice/game_system/KurayamiCrying.rb +49 -0
- data/lib/bcdice/game_system/LiveraDoll.rb +375 -0
- data/lib/bcdice/game_system/LogHorizon.rb +3567 -0
- data/lib/bcdice/game_system/LogHorizon_Korean.rb +1407 -0
- data/lib/bcdice/game_system/LostRecord.rb +30 -0
- data/lib/bcdice/game_system/LostRoyal.rb +242 -0
- data/lib/bcdice/game_system/MagicaLogia.rb +1148 -0
- data/lib/bcdice/game_system/MeikyuDays.rb +415 -0
- data/lib/bcdice/game_system/MeikyuKingdom.rb +466 -0
- data/lib/bcdice/game_system/MeikyuKingdomBasic.rb +269 -0
- data/lib/bcdice/game_system/MetalHead.rb +249 -0
- data/lib/bcdice/game_system/MetalHeadExtream.rb +917 -0
- data/lib/bcdice/game_system/MetallicGuardian.rb +31 -0
- data/lib/bcdice/game_system/MonotoneMuseum.rb +354 -0
- data/lib/bcdice/game_system/MonotoneMuseum_Korean.rb +304 -0
- data/lib/bcdice/game_system/Nechronica.rb +211 -0
- data/lib/bcdice/game_system/Nechronica_Korean.rb +160 -0
- data/lib/bcdice/game_system/NeverCloud.rb +74 -0
- data/lib/bcdice/game_system/NightWizard.rb +231 -0
- data/lib/bcdice/game_system/NightWizard3rd.rb +24 -0
- data/lib/bcdice/game_system/NightmareHunterDeep.rb +117 -0
- data/lib/bcdice/game_system/NinjaSlayer.rb +274 -0
- data/lib/bcdice/game_system/NjslyrBattle.rb +54 -0
- data/lib/bcdice/game_system/Nuekagami.rb +293 -0
- data/lib/bcdice/game_system/OneWayHeroics.rb +134 -0
- data/lib/bcdice/game_system/OracleEngine.rb +265 -0
- data/lib/bcdice/game_system/OrgaRain.rb +77 -0
- data/lib/bcdice/game_system/Oukahoushin3rd.rb +162 -0
- data/lib/bcdice/game_system/Paradiso.rb +323 -0
- data/lib/bcdice/game_system/Paranoia.rb +64 -0
- data/lib/bcdice/game_system/ParanoiaRebooted.rb +109 -0
- data/lib/bcdice/game_system/ParasiteBlood.rb +231 -0
- data/lib/bcdice/game_system/Pathfinder.rb +21 -0
- data/lib/bcdice/game_system/Peekaboo.rb +324 -0
- data/lib/bcdice/game_system/Pendragon.rb +39 -0
- data/lib/bcdice/game_system/PhantasmAdventure.rb +73 -0
- data/lib/bcdice/game_system/Postman.rb +185 -0
- data/lib/bcdice/game_system/PulpCthulhu.rb +184 -0
- data/lib/bcdice/game_system/Raisondetre.rb +171 -0
- data/lib/bcdice/game_system/RecordOfLodossWar.rb +58 -0
- data/lib/bcdice/game_system/RecordOfSteam.rb +149 -0
- data/lib/bcdice/game_system/RokumonSekai2.rb +110 -0
- data/lib/bcdice/game_system/RoleMaster.rb +24 -0
- data/lib/bcdice/game_system/RuneQuest.rb +47 -0
- data/lib/bcdice/game_system/RyuTuber.rb +266 -0
- data/lib/bcdice/game_system/Ryutama.rb +199 -0
- data/lib/bcdice/game_system/SRS.rb +348 -0
- data/lib/bcdice/game_system/SamsaraBallad.rb +111 -0
- data/lib/bcdice/game_system/Satasupe.rb +1173 -0
- data/lib/bcdice/game_system/ScreamHighSchool.rb +128 -0
- data/lib/bcdice/game_system/SevenFortressMobius.rb +34 -0
- data/lib/bcdice/game_system/ShadowRun.rb +26 -0
- data/lib/bcdice/game_system/ShadowRun4.rb +49 -0
- data/lib/bcdice/game_system/ShadowRun5.rb +80 -0
- data/lib/bcdice/game_system/SharedFantasia.rb +69 -0
- data/lib/bcdice/game_system/ShinMegamiTenseiKakuseihen.rb +85 -0
- data/lib/bcdice/game_system/ShinkuuGakuen.rb +506 -0
- data/lib/bcdice/game_system/ShinobiGami.rb +680 -0
- data/lib/bcdice/game_system/ShoujoTenrankai.rb +677 -0
- data/lib/bcdice/game_system/Skynauts.rb +324 -0
- data/lib/bcdice/game_system/SteamPunkers.rb +485 -0
- data/lib/bcdice/game_system/StellarKnights.rb +856 -0
- data/lib/bcdice/game_system/SterileLife.rb +452 -0
- data/lib/bcdice/game_system/StrangerOfSwordCity.rb +103 -0
- data/lib/bcdice/game_system/StratoShout.rb +316 -0
- data/lib/bcdice/game_system/StratoShout_Korean.rb +314 -0
- data/lib/bcdice/game_system/Strave.rb +223 -0
- data/lib/bcdice/game_system/SwordWorld.rb +491 -0
- data/lib/bcdice/game_system/SwordWorld2_0.rb +295 -0
- data/lib/bcdice/game_system/SwordWorld2_5.rb +121 -0
- data/lib/bcdice/game_system/TherapieSein.rb +93 -0
- data/lib/bcdice/game_system/TokumeiTenkousei.rb +96 -0
- data/lib/bcdice/game_system/TokyoGhostResearch.rb +122 -0
- data/lib/bcdice/game_system/TokyoNova.rb +19 -0
- data/lib/bcdice/game_system/Torg.rb +364 -0
- data/lib/bcdice/game_system/Torg1_5.rb +139 -0
- data/lib/bcdice/game_system/TorgEternity.rb +414 -0
- data/lib/bcdice/game_system/TrinitySeven.rb +364 -0
- data/lib/bcdice/game_system/TunnelsAndTrolls.rb +287 -0
- data/lib/bcdice/game_system/TwilightGunsmoke.rb +527 -0
- data/lib/bcdice/game_system/Utakaze.rb +153 -0
- data/lib/bcdice/game_system/VampireTheMasquerade5th.rb +132 -0
- data/lib/bcdice/game_system/Villaciel.rb +555 -0
- data/lib/bcdice/game_system/WARPS.rb +33 -0
- data/lib/bcdice/game_system/WaresBlade.rb +34 -0
- data/lib/bcdice/game_system/Warhammer.rb +336 -0
- data/lib/bcdice/game_system/WitchQuest.rb +275 -0
- data/lib/bcdice/game_system/WorldOfDarkness.rb +135 -0
- data/lib/bcdice/game_system/YankeeYogSothoth.rb +440 -0
- data/lib/bcdice/game_system/YearZeroEngine.rb +134 -0
- data/lib/bcdice/game_system/ZettaiReido.rb +142 -0
- data/lib/bcdice/game_system/meikyu_kingdom/item_table.rb +383 -0
- data/lib/bcdice/game_system/meikyu_kingdom/kingdom_name_table.rb +89 -0
- data/lib/bcdice/game_system/meikyu_kingdom/landscape_table.rb +196 -0
- data/lib/bcdice/game_system/meikyu_kingdom/name_tables.rb +223 -0
- data/lib/bcdice/game_system/meikyu_kingdom/placename_table.rb +214 -0
- data/lib/bcdice/game_system/meikyu_kingdom/tables.rb +610 -0
- data/lib/bcdice/game_system/meikyu_kingdom/word_table.rb +117 -0
- data/lib/bcdice/game_system/meikyu_kingdom_basic/item_table.rb +380 -0
- data/lib/bcdice/game_system/meikyu_kingdom_basic/kingdom_table.rb +184 -0
- data/lib/bcdice/game_system/meikyu_kingdom_basic/name_table.rb +417 -0
- data/lib/bcdice/game_system/meikyu_kingdom_basic/table.rb +912 -0
- data/lib/bcdice/game_system/meikyu_kingdom_basic/word_table.rb +121 -0
- data/lib/bcdice/game_system/one_way_heroics/dungeon_table.rb +67 -0
- data/lib/bcdice/game_system/one_way_heroics/random_event_table.rb +166 -0
- data/lib/bcdice/game_system/one_way_heroics/tables.rb +668 -0
- data/lib/bcdice/loader.rb +37 -0
- data/lib/bcdice/normalize.rb +38 -0
- data/lib/bcdice/preprocessor.rb +87 -0
- data/lib/bcdice/randomizer.rb +137 -0
- data/lib/bcdice/repl.rb +155 -0
- data/lib/bcdice/user_defined_dice_table.rb +153 -0
- data/lib/bcdice/version.rb +3 -0
- metadata +304 -0
@@ -0,0 +1,275 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bcdice/game_system/EarthDawn'
|
4
|
+
|
5
|
+
module BCDice
|
6
|
+
module GameSystem
|
7
|
+
class EarthDawn3 < EarthDawn
|
8
|
+
# ゲームシステムの識別子
|
9
|
+
ID = 'EarthDawn3'
|
10
|
+
|
11
|
+
# ゲームシステム名
|
12
|
+
NAME = 'アースドーン3版'
|
13
|
+
|
14
|
+
# ゲームシステム名の読みがな
|
15
|
+
SORT_KEY = 'ああすとおん3'
|
16
|
+
|
17
|
+
# ダイスボットの使い方
|
18
|
+
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
|
19
|
+
ステップダイス (xEn+k)
|
20
|
+
ステップx、目標値n(省略可能)、カルマダイスk(D2~D20)でステップダイスをロールします。
|
21
|
+
振り足しも自動。
|
22
|
+
例)ステップ10:10E
|
23
|
+
ステップ10、目標値8:10E8
|
24
|
+
ステップ12、目標値8、カルマダイスD12:10E8+1D6
|
25
|
+
INFO_MESSAGE_TEXT
|
26
|
+
|
27
|
+
register_prefix(['\d+e.*'])
|
28
|
+
|
29
|
+
def initialize(command)
|
30
|
+
super(command)
|
31
|
+
|
32
|
+
@sort_add_dice = true
|
33
|
+
end
|
34
|
+
|
35
|
+
def eval_game_system_specific_command(command)
|
36
|
+
return ed_step(command)
|
37
|
+
end
|
38
|
+
|
39
|
+
# アースドーンステップ表
|
40
|
+
def ed_step(str)
|
41
|
+
output = getStepResult(str)
|
42
|
+
|
43
|
+
return output
|
44
|
+
end
|
45
|
+
|
46
|
+
def getStepResult(str)
|
47
|
+
return nil unless /^(\d+)E(\d+)?(\+(\d*)D(\d+))?(\+\d)?/i =~ str
|
48
|
+
|
49
|
+
stepTotal = 0
|
50
|
+
@isFailed = true
|
51
|
+
|
52
|
+
step = Regexp.last_match(1).to_i # ステップ
|
53
|
+
targetNumber = [Regexp.last_match(2).to_i, 20].min # 目標値
|
54
|
+
hasKarmaDice = !Regexp.last_match(3).nil? # カルマダイスの有無
|
55
|
+
karmaDiceCount = [1, Regexp.last_match(4).to_i].max # カルマダイスの個数
|
56
|
+
karmaDiceType = Regexp.last_match(5).to_i # カルマダイスの種類
|
57
|
+
diceModify = Regexp.last_match(6).to_i
|
58
|
+
|
59
|
+
karmaDiceInfo = Hash.new(0)
|
60
|
+
if hasKarmaDice
|
61
|
+
karmaDiceInfo[karmaDiceType] = karmaDiceCount
|
62
|
+
end
|
63
|
+
|
64
|
+
return nil if targetNumber < 0
|
65
|
+
|
66
|
+
stepInfo = getStepInfo(step)
|
67
|
+
debug('stepInfo', stepInfo)
|
68
|
+
|
69
|
+
@string = ""
|
70
|
+
|
71
|
+
diceTypes = [20, 12, 10, 8, 6, 4]
|
72
|
+
diceTypes.each do |type|
|
73
|
+
stepTotal += rollStep(type, stepInfo.shift)
|
74
|
+
end
|
75
|
+
modify = stepInfo.shift
|
76
|
+
|
77
|
+
karmaDiceInfo.each do |diceType, diceCount|
|
78
|
+
stepTotal += rollStep(diceType, diceCount)
|
79
|
+
end
|
80
|
+
|
81
|
+
@string += (getModifyText(modify) + getModifyText(diceModify))
|
82
|
+
stepTotal += (modify + diceModify)
|
83
|
+
|
84
|
+
# ステップ判定終了
|
85
|
+
@string += " > #{stepTotal}"
|
86
|
+
|
87
|
+
output = "ステップ#{step} > #{@string}"
|
88
|
+
return output if targetNumber == 0
|
89
|
+
|
90
|
+
# 結果判定
|
91
|
+
@string += ' > ' + getSuccess(targetNumber, stepTotal)
|
92
|
+
|
93
|
+
output = "ステップ#{step}>=#{targetNumber} > #{@string}"
|
94
|
+
|
95
|
+
return output
|
96
|
+
end
|
97
|
+
|
98
|
+
def getModifyText(modify)
|
99
|
+
@string = ""
|
100
|
+
return @string if modify == 0
|
101
|
+
|
102
|
+
@string += "+" if modify > 0
|
103
|
+
@string += modify.to_s
|
104
|
+
return @string
|
105
|
+
end
|
106
|
+
|
107
|
+
def getBaseStepTable
|
108
|
+
stepTable =
|
109
|
+
[
|
110
|
+
# dice
|
111
|
+
# D20 D12 D10 D8 D6 D4 mod
|
112
|
+
[1, [0, 0, 0, 0, 1, 0, -3]],
|
113
|
+
[2, [0, 0, 0, 0, 1, 0, -2]],
|
114
|
+
[3, [0, 0, 0, 0, 1, 0, -1]],
|
115
|
+
[4, [0, 0, 0, 0, 1, 0, 0]],
|
116
|
+
[5, [0, 0, 0, 1, 0, 0, 0]],
|
117
|
+
[6, [0, 0, 1, 0, 0, 0, 0]],
|
118
|
+
[7, [0, 1, 0, 0, 0, 0, 0]],
|
119
|
+
]
|
120
|
+
|
121
|
+
return stepTable
|
122
|
+
end
|
123
|
+
|
124
|
+
def getStepInfo(step)
|
125
|
+
baseStepTable = getBaseStepTable
|
126
|
+
baseMaxStep = baseStepTable.last.first
|
127
|
+
|
128
|
+
if step <= baseMaxStep
|
129
|
+
return get_table_by_number(step, baseStepTable)
|
130
|
+
end
|
131
|
+
|
132
|
+
baseStepInfo = [0, 1, 0, 0, 0, 0, 0]
|
133
|
+
overStep = step - baseMaxStep - 1
|
134
|
+
|
135
|
+
stepRythm =
|
136
|
+
[
|
137
|
+
# dice
|
138
|
+
# D20 D12 D10 D8 D6 D4 mod
|
139
|
+
[0, 0, 0, 0, 2, 0, 0],
|
140
|
+
[0, 0, 0, 1, 1, 0, 0],
|
141
|
+
[0, 0, 0, 2, 0, 0, 0],
|
142
|
+
[0, 0, 1, 1, 0, 0, 0],
|
143
|
+
[0, 0, 2, 0, 0, 0, 0],
|
144
|
+
[0, 1, 1, 0, 0, 0, 0],
|
145
|
+
[0, 2, 0, 0, 0, 0, 0],
|
146
|
+
]
|
147
|
+
|
148
|
+
result = [0, 0, 0, 0, 0, 0, 0]
|
149
|
+
|
150
|
+
loopCount = (overStep / stepRythm.size)
|
151
|
+
|
152
|
+
loopCount.times do
|
153
|
+
addStepToResult(result, baseStepInfo)
|
154
|
+
end
|
155
|
+
|
156
|
+
index = (overStep % stepRythm.size)
|
157
|
+
restStepInfo = stepRythm[index]
|
158
|
+
|
159
|
+
addStepToResult(result, restStepInfo)
|
160
|
+
|
161
|
+
return result
|
162
|
+
end
|
163
|
+
|
164
|
+
def addStepToResult(result, step)
|
165
|
+
result.size.times do |i|
|
166
|
+
result[i] += step[i]
|
167
|
+
end
|
168
|
+
|
169
|
+
return result
|
170
|
+
end
|
171
|
+
|
172
|
+
def getSuccess(targetNumber, stepTotal)
|
173
|
+
return '自動失敗' if @isFailed
|
174
|
+
|
175
|
+
successTable = getSuccessTable
|
176
|
+
successInfo = get_table_by_number(targetNumber, successTable)
|
177
|
+
|
178
|
+
pathetic, poor, average, good, excelent, extraordinary = successInfo
|
179
|
+
|
180
|
+
return 'Extraordinary(極上)' if stepTotal >= extraordinary
|
181
|
+
return 'Excelent(最高)' if stepTotal >= excelent
|
182
|
+
return 'Good(上出来)' if stepTotal >= good
|
183
|
+
return 'Average(そこそこ)' if stepTotal >= average
|
184
|
+
return 'Poor(お粗末)' if stepTotal >= poor
|
185
|
+
return 'Pathetic(惨め)' if stepTotal >= pathetic
|
186
|
+
end
|
187
|
+
|
188
|
+
def getSuccessTable
|
189
|
+
successTable =
|
190
|
+
[
|
191
|
+
# Pathetic Poor Average Good Excellent Extraordinary
|
192
|
+
[2, [0, 1, 2, 5, 7, 9]],
|
193
|
+
[3, [0, 1, 3, 6, 8, 10]],
|
194
|
+
[4, [0, 1, 4, 7, 10, 12]],
|
195
|
+
[5, [1, 2, 5, 8, 11, 14]],
|
196
|
+
[6, [1, 2, 6, 9, 13, 17]],
|
197
|
+
[7, [1, 3, 7, 11, 15, 19]],
|
198
|
+
[8, [1, 4, 8, 13, 16, 20]],
|
199
|
+
[9, [1, 5, 9, 15, 18, 22]],
|
200
|
+
[10, [1, 6, 10, 16, 20, 24]],
|
201
|
+
[11, [1, 6, 11, 17, 21, 25]],
|
202
|
+
[12, [1, 7, 12, 18, 23, 27]],
|
203
|
+
[13, [1, 7, 13, 20, 25, 29]],
|
204
|
+
[14, [1, 8, 14, 21, 26, 31]],
|
205
|
+
[15, [1, 9, 15, 23, 27, 31]],
|
206
|
+
[16, [1, 10, 16, 24, 28, 33]],
|
207
|
+
[17, [1, 11, 17, 25, 30, 34]],
|
208
|
+
[18, [1, 12, 18, 26, 31, 36]],
|
209
|
+
[19, [1, 12, 19, 28, 33, 37]],
|
210
|
+
[20, [1, 13, 20, 29, 34, 39]],
|
211
|
+
[21, [1, 14, 21, 30, 36, 41]],
|
212
|
+
[22, [1, 15, 22, 31, 37, 42]],
|
213
|
+
[23, [1, 16, 23, 33, 38, 43]],
|
214
|
+
[24, [1, 16, 24, 34, 39, 44]],
|
215
|
+
[25, [1, 17, 25, 35, 41, 46]],
|
216
|
+
[26, [1, 18, 26, 36, 42, 47]],
|
217
|
+
[27, [1, 19, 27, 37, 43, 49]],
|
218
|
+
[28, [1, 19, 28, 39, 45, 50]],
|
219
|
+
[29, [1, 21, 29, 40, 46, 51]],
|
220
|
+
[30, [1, 21, 30, 41, 47, 53]],
|
221
|
+
[31, [1, 22, 31, 42, 48, 54]],
|
222
|
+
[32, [1, 23, 32, 43, 49, 55]],
|
223
|
+
[33, [1, 24, 33, 45, 51, 57]],
|
224
|
+
[34, [1, 24, 34, 46, 52, 58]],
|
225
|
+
[35, [1, 25, 35, 47, 53, 60]],
|
226
|
+
[36, [1, 26, 36, 48, 54, 60]],
|
227
|
+
[37, [1, 27, 37, 49, 56, 62]],
|
228
|
+
[38, [1, 28, 38, 51, 57, 63]],
|
229
|
+
[39, [1, 29, 39, 52, 58, 64]],
|
230
|
+
[40, [1, 30, 40, 53, 59, 66]],
|
231
|
+
]
|
232
|
+
|
233
|
+
return successTable
|
234
|
+
end
|
235
|
+
|
236
|
+
def rollStep(diceType, diceCount)
|
237
|
+
debug('rollStep diceType, diceCount, @string', diceType, diceCount, @string)
|
238
|
+
|
239
|
+
stepTotal = 0
|
240
|
+
return stepTotal unless diceCount > 0
|
241
|
+
|
242
|
+
# diceぶんのステップ判定
|
243
|
+
|
244
|
+
@string += "+" unless @string.empty?
|
245
|
+
@string += "#{diceCount}d#{diceType}["
|
246
|
+
debug('rollStep @string', @string)
|
247
|
+
|
248
|
+
diceCount.times do |i|
|
249
|
+
dice_now = @randomizer.roll_once(diceType)
|
250
|
+
|
251
|
+
if dice_now != 1
|
252
|
+
@isFailed = false
|
253
|
+
end
|
254
|
+
|
255
|
+
dice_in = dice_now
|
256
|
+
|
257
|
+
while dice_now == diceType
|
258
|
+
dice_now = @randomizer.roll_once(diceType)
|
259
|
+
|
260
|
+
dice_in += dice_now
|
261
|
+
end
|
262
|
+
|
263
|
+
stepTotal += dice_in
|
264
|
+
|
265
|
+
@string += ',' if i != 0
|
266
|
+
@string += dice_in.to_s
|
267
|
+
end
|
268
|
+
|
269
|
+
@string += "]"
|
270
|
+
|
271
|
+
return stepTotal
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
@@ -0,0 +1,272 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bcdice/game_system/EarthDawn'
|
4
|
+
|
5
|
+
module BCDice
|
6
|
+
module GameSystem
|
7
|
+
class EarthDawn4 < EarthDawn
|
8
|
+
# ゲームシステムの識別子
|
9
|
+
ID = 'EarthDawn4'
|
10
|
+
|
11
|
+
# ゲームシステム名
|
12
|
+
NAME = 'アースドーン4版'
|
13
|
+
|
14
|
+
# ゲームシステム名の読みがな
|
15
|
+
SORT_KEY = 'ああすとおん4'
|
16
|
+
|
17
|
+
# ダイスボットの使い方
|
18
|
+
HELP_MESSAGE = <<~INFO_MESSAGE_TEXT
|
19
|
+
ステップダイス (xEnK)
|
20
|
+
ステップx、目標値n(省略可能)でステップダイスをロール。
|
21
|
+
カルマダイス使用時は末尾にKを追加(省略可能)
|
22
|
+
例)ステップ10:10E
|
23
|
+
ステップ10、目標値8:10E8
|
24
|
+
ステップ10、目標値8、カルマダイス:10E8K
|
25
|
+
INFO_MESSAGE_TEXT
|
26
|
+
|
27
|
+
register_prefix(['\d+e.*'])
|
28
|
+
|
29
|
+
def initialize(command)
|
30
|
+
super(command)
|
31
|
+
|
32
|
+
@sort_add_dice = true
|
33
|
+
@calcText = ''
|
34
|
+
end
|
35
|
+
|
36
|
+
def eval_game_system_specific_command(command)
|
37
|
+
return ed_step(command)
|
38
|
+
end
|
39
|
+
|
40
|
+
# アースドーンステップ表
|
41
|
+
def ed_step(str)
|
42
|
+
output = getStepResult(str)
|
43
|
+
|
44
|
+
return output
|
45
|
+
end
|
46
|
+
|
47
|
+
def getStepResult(str)
|
48
|
+
stepText, calcText, stepTotal, targetNumber = getStepResultInfos(str)
|
49
|
+
|
50
|
+
return nil if stepText.nil?
|
51
|
+
|
52
|
+
if targetNumber == 0
|
53
|
+
output = "#{stepText} > #{calcText} > #{stepTotal}"
|
54
|
+
return output
|
55
|
+
end
|
56
|
+
|
57
|
+
# 結果判定
|
58
|
+
successText = getSuccess(targetNumber, stepTotal)
|
59
|
+
|
60
|
+
output = "#{stepText}>=#{targetNumber} > #{calcText} > #{stepTotal} > #{successText}"
|
61
|
+
|
62
|
+
return output
|
63
|
+
end
|
64
|
+
|
65
|
+
def getStepResultInfos(str)
|
66
|
+
steps = []
|
67
|
+
calcs = []
|
68
|
+
totals = []
|
69
|
+
target = 0
|
70
|
+
|
71
|
+
while !str.nil? && !str.empty?
|
72
|
+
|
73
|
+
debug("=====>!! str", str)
|
74
|
+
|
75
|
+
step, calc, total, value, nextText = getStepResultInfo(str)
|
76
|
+
debug("=====> step", step)
|
77
|
+
|
78
|
+
return nil if step.nil?
|
79
|
+
|
80
|
+
steps << step
|
81
|
+
calcs << calc
|
82
|
+
totals << total
|
83
|
+
target = value unless value == 0
|
84
|
+
|
85
|
+
debug("=====> nextText", nextText)
|
86
|
+
break if nextText == str
|
87
|
+
|
88
|
+
str = nextText
|
89
|
+
end
|
90
|
+
|
91
|
+
stepText = steps.join("+")
|
92
|
+
calcText = calcs.join(")+(")
|
93
|
+
stepTotal = totals.inject { |sum, i| sum + i }
|
94
|
+
|
95
|
+
calcText = "(" + calcText + ")" if calcs.size > 1
|
96
|
+
calcText += " > (#{totals.join('+')})" if totals.size > 1
|
97
|
+
|
98
|
+
return stepText, calcText, stepTotal, target
|
99
|
+
end
|
100
|
+
|
101
|
+
def getStepResultInfo(str)
|
102
|
+
return nil unless /^(\d+)E(\d+)?(K)?(\+\d+$)?(\+(.*))?/i =~ str
|
103
|
+
|
104
|
+
stepTotal = 0
|
105
|
+
@isFailed = true
|
106
|
+
|
107
|
+
step = Regexp.last_match(1).to_i # ステップ
|
108
|
+
targetNumber = Regexp.last_match(2).to_i # 目標値
|
109
|
+
return nil if targetNumber < 0
|
110
|
+
|
111
|
+
hasKarmaDice = !Regexp.last_match(3).nil? # カルマダイスの有無
|
112
|
+
diceModify = Regexp.last_match(4).to_i
|
113
|
+
nextText = Regexp.last_match(6)
|
114
|
+
|
115
|
+
stepInfo = getStepInfo(step)
|
116
|
+
debug('stepInfo', stepInfo)
|
117
|
+
|
118
|
+
@calcText = ""
|
119
|
+
|
120
|
+
diceTypes = [20, 12, 10, 8, 6, 4]
|
121
|
+
diceTypes.each do |type|
|
122
|
+
stepTotal += rollStep(type, stepInfo.shift)
|
123
|
+
end
|
124
|
+
modify = stepInfo.shift
|
125
|
+
|
126
|
+
stepTotal += rollStep(6, 1) if hasKarmaDice
|
127
|
+
|
128
|
+
@calcText += (getModifyText(modify) + getModifyText(diceModify))
|
129
|
+
stepTotal += (modify + diceModify)
|
130
|
+
|
131
|
+
stepText = "ステップ#{step}"
|
132
|
+
|
133
|
+
return stepText, @calcText, stepTotal, targetNumber, nextText
|
134
|
+
end
|
135
|
+
|
136
|
+
def getModifyText(modify)
|
137
|
+
string = ""
|
138
|
+
return string if modify == 0
|
139
|
+
|
140
|
+
string += "+" if modify > 0
|
141
|
+
string += modify.to_s
|
142
|
+
return string
|
143
|
+
end
|
144
|
+
|
145
|
+
def getBaseStepTable
|
146
|
+
stepTable =
|
147
|
+
[
|
148
|
+
# dice
|
149
|
+
# D20 D12 D10 D8 D6 D4 mod
|
150
|
+
[1, [0, 0, 0, 0, 0, 1, -2]],
|
151
|
+
[2, [0, 0, 0, 0, 0, 1, -1]],
|
152
|
+
[3, [0, 0, 0, 0, 0, 1, 0]],
|
153
|
+
[4, [0, 0, 0, 0, 1, 0, 0]],
|
154
|
+
[5, [0, 0, 0, 1, 0, 0, 0]],
|
155
|
+
[6, [0, 0, 1, 0, 0, 0, 0]],
|
156
|
+
[7, [0, 1, 0, 0, 0, 0, 0]],
|
157
|
+
]
|
158
|
+
|
159
|
+
return stepTable
|
160
|
+
end
|
161
|
+
|
162
|
+
def getStepInfo(step)
|
163
|
+
baseStepTable = getBaseStepTable
|
164
|
+
baseMaxStep = baseStepTable.last.first
|
165
|
+
|
166
|
+
if step <= baseMaxStep
|
167
|
+
return get_table_by_number(step, baseStepTable)
|
168
|
+
end
|
169
|
+
|
170
|
+
# dice
|
171
|
+
# D20 D12 D10 D8 D6 D4 mod
|
172
|
+
overBounusStep = [1, 0, 0, 0, 0, 0, 0]
|
173
|
+
overStep = step - baseMaxStep - 1
|
174
|
+
|
175
|
+
stepRythm =
|
176
|
+
[
|
177
|
+
# dice
|
178
|
+
# D20 D12 D10 D8 D6 D4 mod
|
179
|
+
[0, 0, 0, 0, 2, 0, 0],
|
180
|
+
[0, 0, 0, 1, 1, 0, 0],
|
181
|
+
[0, 0, 0, 2, 0, 0, 0],
|
182
|
+
[0, 0, 1, 1, 0, 0, 0],
|
183
|
+
[0, 0, 2, 0, 0, 0, 0],
|
184
|
+
[0, 1, 1, 0, 0, 0, 0],
|
185
|
+
[0, 2, 0, 0, 0, 0, 0],
|
186
|
+
[0, 1, 0, 0, 2, 0, 0],
|
187
|
+
[0, 1, 0, 1, 1, 0, 0],
|
188
|
+
[0, 1, 0, 2, 0, 0, 0],
|
189
|
+
[0, 1, 1, 1, 0, 0, 0],
|
190
|
+
]
|
191
|
+
|
192
|
+
# [ 1, 0, 0, 0, 2, 0, 0],
|
193
|
+
|
194
|
+
result = [0, 0, 0, 0, 0, 0, 0]
|
195
|
+
|
196
|
+
loopCount = (overStep / stepRythm.size)
|
197
|
+
|
198
|
+
loopCount.times do
|
199
|
+
addStepToResult(result, overBounusStep)
|
200
|
+
end
|
201
|
+
|
202
|
+
index = (overStep % stepRythm.size)
|
203
|
+
restStepInfo = stepRythm[index]
|
204
|
+
|
205
|
+
addStepToResult(result, restStepInfo)
|
206
|
+
|
207
|
+
return result
|
208
|
+
end
|
209
|
+
|
210
|
+
def addStepToResult(result, step)
|
211
|
+
result.size.times do |i|
|
212
|
+
result[i] += step[i]
|
213
|
+
end
|
214
|
+
|
215
|
+
return result
|
216
|
+
end
|
217
|
+
|
218
|
+
def getSuccess(targetNumber, stepTotal)
|
219
|
+
return '自動失敗' if @isFailed
|
220
|
+
|
221
|
+
diff = stepTotal - targetNumber
|
222
|
+
debug("diff", diff)
|
223
|
+
|
224
|
+
if diff < 0
|
225
|
+
return "失敗"
|
226
|
+
end
|
227
|
+
|
228
|
+
level = (diff / 5) + 1
|
229
|
+
|
230
|
+
return "成功 レベル:#{level}"
|
231
|
+
end
|
232
|
+
|
233
|
+
def rollStep(diceType, diceCount)
|
234
|
+
debug('rollStep diceType, diceCount, @calcText', diceType, diceCount, @calcText)
|
235
|
+
|
236
|
+
stepTotal = 0
|
237
|
+
return stepTotal unless diceCount > 0
|
238
|
+
|
239
|
+
# diceぶんのステップ判定
|
240
|
+
|
241
|
+
@calcText += "+" unless @calcText.empty?
|
242
|
+
@calcText += "#{diceCount}d#{diceType}["
|
243
|
+
debug('rollStep string', @calcText)
|
244
|
+
|
245
|
+
diceCount.times do |i|
|
246
|
+
dice_now = @randomizer.roll_once(diceType)
|
247
|
+
|
248
|
+
if dice_now != 1
|
249
|
+
@isFailed = false
|
250
|
+
end
|
251
|
+
|
252
|
+
dice_in = dice_now
|
253
|
+
|
254
|
+
while dice_now == diceType
|
255
|
+
dice_now = @randomizer.roll_once(diceType)
|
256
|
+
|
257
|
+
dice_in += dice_now
|
258
|
+
end
|
259
|
+
|
260
|
+
stepTotal += dice_in
|
261
|
+
|
262
|
+
@calcText += ',' if i != 0
|
263
|
+
@calcText += dice_in.to_s
|
264
|
+
end
|
265
|
+
|
266
|
+
@calcText += "]"
|
267
|
+
|
268
|
+
return stepTotal
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|