#货币 #硬币 #转换器 #5e #dnd

bin+lib 斯特林

将给定的 D&D 5e 货币价值转换为银本位

5 个版本 (2 个稳定版)

使用旧 Rust 2015

1.0.1 2018年8月7日
1.0.0 2018年8月6日
0.3.0 2018年5月16日
0.2.0 2018年3月16日
0.1.0 2018年3月10日

#310游戏

无许可/MIT

31KB
640

斯特林

将给定的 D&D 5e 货币价值转换为银本位。灵感来源于名为 The Silver Hack: Making Money MatterI make Silver Standard for 5th Edition (Spreadsheets.) 的 Reddit 帖子。

使用方法

USAGE:
    sterling [FLAGS] [OPTIONS] [VALUE]... [SUBCOMMAND]

FLAGS:
    -o, --optional    Include currencies marked as optional when converting
    -f, --full        Print currencies with their full name, rather than with their alias
    -h, --help        Prints help information
    -V, --version     Prints version information

OPTIONS:
    -c, --config <CONFIG>    Specify location of config file; defaults to './sterling-conf.yml'.

ARGS:
    <VALUE>...    The value to be converted; should be suffixed with the coin's short-hand abbreviation, i.e. p, g,
                  e, s, or c.

SUBCOMMANDS:
    add       Add two currency amounts together; uses the currencies defined in your config file
    copper    Calculate the copper value of a custom currency
    div       Divide a currency amount by some scalar divisor; uses the currencies defined in your config file
    help      Prints this message or the help of the given subcommand(s)
    mul       Multiply a scalar multiplicand by a currency amount; uses the currencies defined in your config file
    sub       Subtract two currency amounts from one another; uses the currencies defined in your config file

货币转换示例

// Convert one hundred platinum coins: 
sterling 100p // 10g

// Convert one hundred platinum, fifty gold coins:
sterling 100p 50g // 10g, 50s

// Convert fifteen thousand copper coins, printing the full names of the coins:
sterling -f 15000c // 1 gold, 50 silvers

// Convert one platinum, thirty-six gold, twelve electrum, eighty-two silver, and four hundred
// sixty-nine copper coins, printing the full names of the coins
sterling --full 1p 36g 12e 82s 469c // 64 silvers, 89 coppers

// Convert one platinum, thirty-six gold, twelve electrum, eighty-two silver, and four hundred
// sixty-nine copper coins, printing the full names of the coins, using the custom config file
// detailed below, including optional currencies
sterling --full -o -c "~/Documents/D&D/sterling-conf.yml" 1p 36g 12e 82s 469c // 7 guilders, 6 sterling, 25 pence

子命令示例

// Add together ten and twenty pense, using the custom config file detailed below
sterling add "10p" "20p" // 30p

// Subtract two sterling and ten pence from one eagle
sterling --full sub "1e" "2s 10p" // 19 guilders, 25 sterling, 22 pence

// Subtract one eagle from two sterling and ten pence. Note that, regardless of order, the smaller
// value is ALWAYS subtracted from the larger value.
sterling --full sub "2s 10p" "1F" // 19 guilders, 25 sterling, 22 pence

// Multiply two sterling and ten pence by thirteen. Note that the currencies always go after the
// multiplier.
sterling --full mul 13 2s 10p // 1 guilder, 2 sterling, 2 pence

// Divide one guilder, 2 sterling, and 2 pence by thirteen.
sterling --full div 13 1g 2s 2p // 2 sterling, 10 pence

// Convert one note, three eagles, and five guilders into copper
sterling copper 1N 3e 5g // 201,600c

请注意,sterling 不允许使用负货币。因此,当减去货币时,较小的货币值将始终从较大的货币值中减去,而不管货币在 sub 命令中的顺序如何。

自定义货币

sterling 允许用户定义货币,具有自己的名称和转换率。默认情况下,sterling 将查看当前目录中的名为 sterling-conf.yml 的文件,或由 -c 标志提供的任何位置。您还可以指定货币为可选,这将防止在转换值时使用该货币,除非传递了 -o 标志。以下是一个示例 sterling-conf.yml 文件,展示了我在自己的战役中使用的实际货币!

-
  name: "note"
  rate: 143360
  alias: "N"
  optional: true
-
  name: "eagle"
  rate: 17920
  alias: "e"
-
  name: "guilder"
  rate: 896
  alias: "g"
-
  name: "shilling"
  rate: 32
  alias: "s"
  plural: "sterling"
-
  name: "penny"
  rate: 1
  alias: "p"
  plural: "pence"

请注意,rate 的值定义为进入那种特定货币的一个铜币的数量。在上面的示例中,三十二个铜币可以兑换一个“先令”,而八百九十六个铜币可以兑换一个“弗罗林”。

摘要

物品和费用在官方 D&D 5th 版源书中默认分配任意货币值。许多官方定价的物品使用“金本位”;也就是说,物品的定价默认为金币。虽然在您的战役中使用官方货币值没有什么不对,但它会导致玩家眼中金币的价值降低。金币作为商品和货币已被寻求数百年,您的战役应该以类似的方式对待金币!

说明

银币标准的基准将官方D&D 5e源书中的一枚金币视为一枚银币,并且每个给定硬币的下一个更高价值的硬币有100个。就是这样。因此,150枚铜币等于1枚银币和50枚铜币,而一套重型板甲等于15枚金币,而不是1500枚。

安装

使用cargo安装sterling是最简单的方法,这是与rust编译器一起安装的构建工具。如果您已经在您的计算机上安装了rustcargo,只需在命令提示符下运行以下命令即可

$ cargo install sterling

如果您未安装rust编译器,您也可以在上述README上方显示的“标签”导航链接中找到64位Windows、macOS和Linux计算机的预构建二进制文件。只需下载适用于您的计算机操作系统的正确二进制文件,将其解压缩到您的文件系统中的某个位置(例如用户目录中的“bin”文件夹),并将该位置添加到您的系统PATH中。

依赖关系

~3.5–5.5MB
~98K SLoC