From dfcbd84dc50e089c70af11ec84b8350ac751fbba Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Fri, 28 Apr 2023 16:59:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E6=95=B4=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/container.go | 5 +++++ game/item.go | 9 +++++++++ utils/huge/int.go | 14 ++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 game/container.go create mode 100644 game/item.go create mode 100644 utils/huge/int.go diff --git a/game/container.go b/game/container.go new file mode 100644 index 0000000..40f6390 --- /dev/null +++ b/game/container.go @@ -0,0 +1,5 @@ +package game + +// Container 容器 +type Container[T any] interface { +} diff --git a/game/item.go b/game/item.go new file mode 100644 index 0000000..9e9dfe6 --- /dev/null +++ b/game/item.go @@ -0,0 +1,9 @@ +package game + +// Item 物品接口定义 +type Item[ID comparable] interface { + // GetID 获取物品id + GetID() ID + // GetCount 获取物品数量 + GetCount() int +} diff --git a/utils/huge/int.go b/utils/huge/int.go new file mode 100644 index 0000000..c61e83d --- /dev/null +++ b/utils/huge/int.go @@ -0,0 +1,14 @@ +package huge + +import "math/big" + +type Int big.Int + +func NewInt[T uint | uint8 | uint16 | uint32 | uint64 | int | int8 | int16 | int32 | int64](x T, exp ...T) *Int { + num := int64(x) + i := big.NewInt(num) + for _, t := range exp { + i = i.Exp(i, big.NewInt(int64(t)), nil) + } + return (*Int)(i) +}