Skip to content

Commit c14ed43

Browse files
committed
common: Add missing Inferno.UniqueID()
1 parent 2045dae commit c14ed43

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

common/inferno.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ type Fire struct {
2626
IsBurning bool
2727
}
2828

29+
// UniqueID returns the unique id of the inferno.
30+
// The unique id is a random int generated internally by this library and can be used to differentiate
31+
// infernos from each other. This is needed because demo-files reuse entity ids.
32+
func (inf Inferno) UniqueID() int64 {
33+
return inf.uniqueID
34+
}
35+
2936
// Active returns an Inferno containing only the active fires of the original.
3037
// The returned Inferno will have the same Unique-ID as the original.
3138
func (inf Inferno) Active() Inferno {

common/inferno_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package common
2+
3+
import (
4+
"testing"
5+
6+
assert "github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestInfernoUniqueID(t *testing.T) {
10+
assert.NotEqual(t, NewInferno().UniqueID(), NewInferno().UniqueID(), "UniqueIDs of different infernos should be different")
11+
}

0 commit comments

Comments
 (0)