diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/c_defs.go | 2 | ||||
-rw-r--r-- | src/c_go2work.go | 5 | ||||
-rw-r--r-- | src/u_utils.go | 14 |
3 files changed, 17 insertions, 4 deletions
diff --git a/src/c_defs.go b/src/c_defs.go index e969c3b..36a20ba 100644 --- a/src/c_defs.go +++ b/src/c_defs.go @@ -39,7 +39,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * go2work: src/c_defs.go - * Fri Apr 1 17:40:35 CEST 2022 + * Fri Apr 1 18:25:16 CEST 2022 * Joe * * Definitions. diff --git a/src/c_go2work.go b/src/c_go2work.go index 956b481..076309a 100644 --- a/src/c_go2work.go +++ b/src/c_go2work.go @@ -39,7 +39,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * go2work: src/c_go2work.go - * Fri Apr 1 17:40:27 CEST 2022 + * Fri Apr 1 18:26:36 CEST 2022 * Joe * * The main. @@ -105,6 +105,7 @@ func main() { print_time_left(curr_t, dest_t) ticker := time.NewTicker(INTERVAL * time.Millisecond) quit := make(chan struct{}) + file_id := choose_file(options) for { select { case <- ticker.C: @@ -113,7 +114,7 @@ func main() { if curr_t[HOURS] == dest_t[HOURS] && curr_t[MINS] == dest_t[MINS] && curr_t[SECS] == dest_t[SECS] { - args := append(options.player_options, options.files[0]) + args := append(options.player_options, options.files[file_id]) has_rang := false for { exec_player( diff --git a/src/u_utils.go b/src/u_utils.go index b1d846f..4a81b85 100644 --- a/src/u_utils.go +++ b/src/u_utils.go @@ -39,13 +39,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * go2work: src/u_utils.go - * Wed Mar 30 01:25:20 CEST 2022 + * Fri Apr 1 18:25:20 CEST 2022 * Joe */ package main import ( + "math/rand" "time" "strconv" "strings" @@ -85,3 +86,14 @@ func get_time() [3]byte { func get_test_time() [3]byte { return seconds_to_time(time_to_seconds(get_time()) + 3) } + +func choose_file(options Options) int { + file_id := len(options.files) + if options.random == true && file_id > 1 { + rand.Seed(time.Now().UnixNano()) + file_id = rand.Intn(file_id) + } else { + file_id = 0 + } + return file_id +} |