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) +}