From 3d36d1d0254b8aeecc889a2a49cbcced458cbe9c Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sat, 25 Feb 2023 23:08:47 +0100 Subject: intermediate commit * Implement move artifact action * Fix widget update memory leak * update the highlights not during on each frame * do not update the unchanged label of a button * Allow to exit the game by pressing 'q' * Implement some cards from the magic set * Improve permanent formatting * Some tweaks to UnitAI code --- go/utils/slices.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'go/utils') diff --git a/go/utils/slices.go b/go/utils/slices.go index 3cc38c1c..eb02f782 100644 --- a/go/utils/slices.go +++ b/go/utils/slices.go @@ -15,3 +15,16 @@ func InterfaceSliceToTypedSlice[T any](s []interface{}) []T { } return ts } + +func RemoveFromUnorderedSlice[T comparable](s []T, o T) []T { + for i, t := range s { + if t != o { + continue + } + + s[i] = s[len(s) - 1] + return s[:len(s) - 1] + } + + return s +} -- cgit v1.2.3