|
|
@ -288,7 +288,7 @@ func (rr *Room) GetAICards() types.PokerSlice { |
|
|
|
|
|
|
|
// GroupByColor 按花色分组
|
|
|
|
func (rr *Room) GroupByColor(HandCard types.PokerSlice) []types.PokerSlice { |
|
|
|
log.Debug("按花色分组 牌", HandCard) |
|
|
|
//log.Debug("按花色分组 牌", HandCard)
|
|
|
|
var TempHandCard []int |
|
|
|
for _, poker := range HandCard { |
|
|
|
TempHandCard = append(TempHandCard, int(poker)) |
|
|
@ -415,7 +415,7 @@ func (rr *Room) CreatSequence(bPure bool, AllCard *types.PokerSlice, TempGroupCa |
|
|
|
|
|
|
|
//随机一张开始牌
|
|
|
|
BeginPoker := (*AllCard)[rand.Intn(len(*AllCard))] |
|
|
|
log.Debug("随机一张开始牌 ", BeginPoker) |
|
|
|
//log.Debug("随机一张开始牌 ", BeginPoker)
|
|
|
|
for BeginPoker.IsJoker() || BeginPoker.Point() == rr.WildJokerCard.Point() { |
|
|
|
BeginPoker = (*AllCard)[rand.Intn(len(*AllCard))] |
|
|
|
} |
|
|
@ -437,7 +437,7 @@ func (rr *Room) CreatSequence(bPure bool, AllCard *types.PokerSlice, TempGroupCa |
|
|
|
NeedFindPoker = append(NeedFindPoker, TempPokerSub) |
|
|
|
} |
|
|
|
} |
|
|
|
log.Debug("找到需要的牌 ", NeedFindPoker) |
|
|
|
//log.Debug("找到需要的牌 ", NeedFindPoker)
|
|
|
|
|
|
|
|
for _, FindPoker := range NeedFindPoker { |
|
|
|
IsFind, Index := rr.FindPoker(*AllCard, FindPoker, bPure, TempAllCardIndex, true) |
|
|
@ -460,7 +460,7 @@ func (rr *Room) CreatSequence(bPure bool, AllCard *types.PokerSlice, TempGroupCa |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
log.Debug("找到需要的牌的索引 ", TempAllCardIndex) |
|
|
|
//log.Debug("找到需要的牌的索引 ", TempAllCardIndex)
|
|
|
|
|
|
|
|
if *CSFind { |
|
|
|
break |
|
|
@ -474,11 +474,11 @@ func (rr *Room) CreatSequence(bPure bool, AllCard *types.PokerSlice, TempGroupCa |
|
|
|
return TempAllCardIndex[i] < TempAllCardIndex[j] |
|
|
|
}) |
|
|
|
|
|
|
|
log.Debug("找到需要的牌的索引排序后 ", TempAllCardIndex) |
|
|
|
//log.Debug("找到需要的牌的索引排序后 ", TempAllCardIndex)
|
|
|
|
|
|
|
|
// 全牌里删掉
|
|
|
|
for i := len(TempAllCardIndex); i > 0; i-- { |
|
|
|
log.Debug("找到要删的牌 Index:", TempAllCardIndex[i-1], "找到要删的牌 值:", (*AllCard)[TempAllCardIndex[i-1]]) |
|
|
|
//log.Debug("找到要删的牌 Index:", TempAllCardIndex[i-1], "找到要删的牌 值:", (*AllCard)[TempAllCardIndex[i-1]])
|
|
|
|
NewPokers = append(NewPokers, (*AllCard)[TempAllCardIndex[i-1]]) |
|
|
|
if TempAllCardIndex[i-1] == (len(*AllCard) - 1) { |
|
|
|
*AllCard = (*AllCard)[:TempAllCardIndex[i-1]] |
|
|
@ -490,7 +490,7 @@ func (rr *Room) CreatSequence(bPure bool, AllCard *types.PokerSlice, TempGroupCa |
|
|
|
sort.Slice(NewPokers, func(i, j int) bool { |
|
|
|
return NewPokers[i].Point() < NewPokers[j].Point() |
|
|
|
}) |
|
|
|
log.Debug("找到需要的牌 排序后 ", NewPokers) |
|
|
|
//log.Debug("找到需要的牌 排序后 ", NewPokers)
|
|
|
|
|
|
|
|
*CSIndex = 0 |
|
|
|
ResultGroup.Pokers = append(ResultGroup.Pokers, NewPokers...) |
|
|
@ -643,7 +643,7 @@ func (rr *Room) CreatSet(AllCard *types.PokerSlice, CSFind *bool, CSIndex *int, |
|
|
|
for BeginPoker.IsJoker() || BeginPoker.Point() == rr.WildJokerCard.Point() { |
|
|
|
BeginPoker = (*AllCard)[rand.Intn(len(*AllCard))] |
|
|
|
} |
|
|
|
log.Debug("随机一张开始牌 ", BeginPoker) |
|
|
|
//log.Debug("随机一张开始牌 ", BeginPoker)
|
|
|
|
for i := 1; i < 5; i++ { |
|
|
|
if int(BeginPoker.Color()) != i { |
|
|
|
NeedFindPoker = append(NeedFindPoker, types.Poker(i*16+int(BeginPoker.Point()))) |
|
|
@ -659,7 +659,7 @@ func (rr *Room) CreatSet(AllCard *types.PokerSlice, CSFind *bool, CSIndex *int, |
|
|
|
NeedFindPoker = append(NeedFindPoker, rr.WildJokerCard) |
|
|
|
} |
|
|
|
} |
|
|
|
log.Debug("找到需要的牌 ", NeedFindPoker) |
|
|
|
//log.Debug("找到需要的牌 ", NeedFindPoker)
|
|
|
|
|
|
|
|
TempAllCard := make(types.PokerSlice, len(*AllCard)) |
|
|
|
copy(TempAllCard, *AllCard) |
|
|
@ -668,7 +668,7 @@ func (rr *Room) CreatSet(AllCard *types.PokerSlice, CSFind *bool, CSIndex *int, |
|
|
|
for _, FindPoker := range NeedFindPoker { |
|
|
|
IsFind, Index := rr.FindPoker(TempAllCard, FindPoker, true, []int{}, true) |
|
|
|
if IsFind { |
|
|
|
log.Debug("找到要删的牌 Index:", Index, "找到要删的牌 值:", TempAllCard[Index]) |
|
|
|
//log.Debug("找到要删的牌 Index:", Index, "找到要删的牌 值:", TempAllCard[Index])
|
|
|
|
NewPokers = append(NewPokers, TempAllCard[Index]) |
|
|
|
if Index == (len(TempAllCard) - 1) { |
|
|
|
TempAllCard = TempAllCard[:Index] |
|
|
@ -679,7 +679,7 @@ func (rr *Room) CreatSet(AllCard *types.PokerSlice, CSFind *bool, CSIndex *int, |
|
|
|
// 补鬼牌
|
|
|
|
IsFind2, Index2 := rr.FindPoker(TempAllCard, rr.WildJokerCard, false, []int{}, true) |
|
|
|
if IsFind2 { |
|
|
|
log.Debug("找到要删的牌 Index:", Index2, "找到要删的牌 值:", TempAllCard[Index2]) |
|
|
|
//log.Debug("找到要删的牌 Index:", Index2, "找到要删的牌 值:", TempAllCard[Index2])
|
|
|
|
NewPokers = append(NewPokers, TempAllCard[Index2]) |
|
|
|
if Index2 == (len(TempAllCard) - 1) { |
|
|
|
TempAllCard = TempAllCard[:Index2] |
|
|
|