File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 11package common
22
33import (
4+ "time"
5+
46 r3 "github.com/golang/geo/r3"
57 st "github.com/markus-wa/demoinfocs-golang/sendtables"
68)
@@ -45,6 +47,11 @@ func (p *Player) IsBlinded() bool {
4547 return p .FlashDuration > 0
4648}
4749
50+ // FlashDurationTime returns the duration of the blinding effect as time.Duration instead of float32 in seconds.
51+ func (p * Player ) FlashDurationTime () time.Duration {
52+ return time .Duration (float32 (time .Second ) * p .FlashDuration )
53+ }
54+
4855/*
4956Some interesting data regarding flashes.
5057
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package common
22
33import (
44 "testing"
5+ "time"
56
67 assert "github.com/stretchr/testify/assert"
78)
@@ -57,3 +58,13 @@ func TestPlayerFlashed(t *testing.T) {
5758 pl .FlashDuration = 2.3
5859 assert .True (t , pl .IsBlinded (), "Should be flashed" )
5960}
61+
62+ func TestPlayer_FlashDurationTime (t * testing.T ) {
63+ p := NewPlayer ()
64+
65+ assert .Equal (t , time .Duration (0 ), p .FlashDurationTime ())
66+
67+ p .FlashDuration = 2.3
68+
69+ assert .Equal (t , 2300 * time .Millisecond , p .FlashDurationTime ())
70+ }
You can’t perform that action at this time.
0 commit comments