WinShape.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package TribalSlot
  2. import (
  3. "bet24.com/log"
  4. )
  5. func NewWinShape(shape int, desc string) *WinShape {
  6. ws := new(WinShape)
  7. ws.Shape = shape
  8. ws.Desc = desc
  9. if !ws.isValid() {
  10. return nil
  11. }
  12. return ws
  13. }
  14. type WinShape struct {
  15. Shape int
  16. Desc string
  17. }
  18. func (ws *WinShape) isValid() bool {
  19. shape := ws.Shape
  20. for i := 0; i < COLUMN_COUNT; i++ {
  21. if shape%10 >= ROW_COUNT {
  22. log.Release("WinShape.IsValid r%d = %d", i, shape%10)
  23. return false
  24. }
  25. shape = shape / 10
  26. }
  27. return true
  28. }
  29. func (ws *WinShape) getFive(slots []Slot) []Slot {
  30. ret := make([]Slot, COLUMN_COUNT)
  31. shape := ws.Shape
  32. for i := 1; i <= COLUMN_COUNT; i++ {
  33. var row = shape % 10
  34. ret[COLUMN_COUNT-i] = slots[(row+1)*COLUMN_COUNT-i]
  35. shape = shape / 10
  36. }
  37. return ret
  38. }
  39. func (ws *WinShape) getCount(slots []Slot) (slotID, slotCount, magicCount int) {
  40. if len(slots) != RESULT_COUNT {
  41. log.Release("WinShape.isWin count = %d", len(slots))
  42. return 0, 0, 0
  43. }
  44. five_slot := ws.getFive(slots)
  45. //log.Color(LogColor,"WinShape.getCount,%d,%v", ws.Shape, five_slot)
  46. // 先计算SlotID和Count
  47. slotID = 0xFFFFFFFF
  48. slotCount = 0
  49. magicCount = 0
  50. magicSlotID := 0xFFFFFFFF
  51. for _, v := range five_slot {
  52. if v.isMagic() {
  53. slotCount++
  54. magicSlotID = v.SlotID
  55. magicCount++
  56. continue
  57. }
  58. if slotID != v.SlotID && slotID != 0xFFFFFFFF {
  59. break
  60. }
  61. slotCount++
  62. slotID = v.SlotID
  63. }
  64. if slotID == 0xFFFFFFFF {
  65. slotID = magicSlotID
  66. }
  67. // log.Color(LogColor, "WinShape.getCount ret,%d,%d", slotID, slotCount)
  68. return
  69. }