dice

package
v0.0.0-...-3319774 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2020 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

ダイスの内部表現のパッケージ。

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDice

func FormatDice(dice []Die) string

FormatDice はダイス列を文字列として整形して返す。 結果の文字列は "値/面数, 値/面数, ..." という形式。

Example

ダイス列の整形例。

ds := []Die{{2, 4}, {3, 6}, {5, 10}, {10, 20}}
fmt.Println(FormatDice(ds))
Output:

2/4, 3/6, 5/10, 10/20

func FormatDiceWithoutSpaces

func FormatDiceWithoutSpaces(dice []Die) string

FormatDiceWithoutSpaces はダイス列を文字列として整形して返す。 結果の文字列は "値/面数,値/面数,..." という形式。 空白を出力しないので、テストケースなどで使うとよい。

Example

ダイス列の整形例(空白なし)。

ds := []Die{{2, 4}, {3, 6}, {5, 10}, {10, 20}}
fmt.Println(FormatDiceWithoutSpaces(ds))
Output:

2/4,3/6,5/10,10/20

Types

type Die

type Die struct {
	// 出目
	Value int
	// ダイスの面の数
	Sides int
}

ダイスを表す構造体。

func (Die) SExp

func (d Die) SExp() string

SExp はダイスのS式を返す。

Example
d := Die{3, 6}
fmt.Println(d.SExp())
Output:

(Die 3 6)

func (Die) String

func (d Die) String() string

String はダイスの文字列表現を返す。

Example
d := Die{3, 6}
fmt.Println(d.String())
Output:

<Die 3/6>

Directories

Path Synopsis
1個1個のダイスの供給の仕方を定義するパッケージ。
1個1個のダイスの供給の仕方を定義するパッケージ。
ダイスを振る処理のパッケージ。
ダイスを振る処理のパッケージ。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL