arrangeuser.go 462 B

1234567891011121314151617181920212223242526272829
  1. package setsmatch
  2. type arrangeuser struct {
  3. UserId int
  4. Level int
  5. IP string
  6. History []int // 组合历史记录
  7. }
  8. func min(a, b int) int {
  9. if a < b {
  10. return a
  11. }
  12. return b
  13. }
  14. func (au *arrangeuser) isConflict(a *arrangeuser) bool {
  15. if a.IP == au.IP && a.IP != "" {
  16. return true
  17. }
  18. historyLen := min(len(a.History), len(au.History))
  19. for i := 0; i < historyLen; i++ {
  20. if a.History[i] == au.History[i] {
  21. return true
  22. }
  23. }
  24. return false
  25. }