package samloc

import (
	"fmt"
	"log"
	"sort"
	"testing"
)

func TestPoker(t *testing.T) {
	// 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 一条龙
	//
	card := []int32{12, 11, 7, 6, 5, 4, 3, 2, 1, 0}
	ty, lc := CardLore(card)
	fmt.Println(ty, lc)
}

func TestGetPokerType(t *testing.T) {

	cards := []int32{2, 2, 2, 2, 4, 4, 4, 4}
	cards1 := []int32{0, 1, 2}
	kind := GetCardKind(cards)
	kind1 := GetCardKind(cards1)
	aards := []int32{12, 1, 0, 24, 11}
	log.Println("####################4 ", kind)
	ret := kind.OutPokers(aards)
	fmt.Println(ret)
	fmt.Println(kind.ktype, kind.min, kind.max, CompareCard(kind, cards1), CompareCardKind(kind, kind1))
}

func TestRemoveCard(t *testing.T) {

	recards := []int32{9, 8, 7, 6, 19}
	cards := []int32{10, 9, 8, 7, 6, 1, 19, 22, 51}
	flag := RemoveCard(recards, &cards)
	fmt.Println(flag, cards)
}

func TestHeadHintOut(t *testing.T) {
	lastKind := &KindOfCard{}
	lastKind.kind = Single
	lastKind.min = 3
	lastKind.len = 1
	cards := []int32{12, 51, 11}
	_, err := headHintOut(cards, nil)
	log.Println("####################", err)

}

func TestDelOtherPOKER2(t *testing.T) {

	cards := []int32{26, 2, 15, 19, 34, 22, 48, 10, 11, 24}
	ret := DelOtherPOKER2(cards, []int32{11})
	log.Println("####################", ret, cards)

}

func TestTickOut(t *testing.T) {
	lcards := []int32{2, 1, 0} //{33, 46}
	lastKind := GetCardKind(lcards)
	cards := []int32{9, 8, 7, 6, 5, 4, 3, 2, 1, 0} //{0, 2, 15, 28, 41, 4, 17, 30, 43}
	ret := TickOut(cards, lastKind, false)
	log.Println("####################", ret, cards)

}
func TestALL(t *testing.T) {
	cards := []int32{12, 11, 8, 7, 43, 30, 3, 2, 1, 0}
	p := ptstr32m(cards)
	log.Println("####################", p)
	ret := &Kds{
		//kd: ret,
	}
	ret.kd = append(ret.kd, allfindStraight(p, 1, 3)...)
	ret.kd = append(ret.kd, findKindCommon(p, 2)...)
	ret.kd = append(ret.kd, findKindCommon(p, 3)...)
	ret.kd = append(ret.kd, findKindCommon(p, 4)...)

	sort.Sort(ret)
	// log.Println("####################", len(ret))
	for _, v := range ret.kd {
		log.Println("#################### ret1", v, v.OutPokers(cards))
	}
}

func TestStraight(t *testing.T) {
	cards := []int32{12, 11, 8, 7, 43, 30, 3, 2, 1, 0}
	p := ptstr32m(cards)
	log.Println("####################", p)
	ret := findStraight(p, 1, 3)
	ret[0], ret[1] = ret[1], ret[0]
	for _, v := range ret {
		log.Println("####################", v, v.OutPokers(cards))
	}
	ret1 := &Kds{
		kd: ret,
	}
	sort.Sort(ret1)
	// log.Println("####################", len(ret))
	for _, v := range ret1.kd {
		log.Println("#################### ret1", v, v.OutPokers(cards))
	}

	ret = allfindStraight(p, 1, 3)
	// log.Println("####################", len(ret))
	for _, v := range ret {
		log.Println("####################", v, v.OutPokers(cards))
	}

}

func TestCommon(t *testing.T) {
	cards := []int32{26, 2, 15, 28, 41, 22, 48, 10, 11, 24}
	p := pt32m(cards)
	ret := findKindCommon(p, 4)
	// log.Println("####################", len(ret))
	for _, v := range ret {
		log.Println("####################", v, v.OutPokers(cards))
	}

}

//牌序- 2, A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3
//红桃- 51,50,49,48,47,46,45,44,43,42,41,40,39
//方片- 38,37,36,35,34,33,32,31,30,29,28,27,26
//梅花- 25,24,23,22,21,20,19,18,17,16,15,14,13
//黑桃- 12,11,10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0

func TestAlls(t *testing.T) {

	lcards := []int32{} //{33, 46}
	lastKind := GetCardKind(lcards)
	fmt.Println(lastKind)
	// 4, 0, 1, 2, 9, 22, 35
	cards := []int32{0, 13, 24, 37} //10, 36, 9, 22, 12, 25 // 2, 3, 16, 30, 31, 8, 47, 9, 22, 11

	/*v, err := selectOut(cards, nil,
		[][]int32{}, 1)
	ret, lcards := v.outPokers(cards)*/
	warn := false
	ret, lcards, err := SelectOut(cards, lastKind, [][]int32{{1, 14}}, warn, 0)
	log.Println("####################", err)
	fmt.Println(ret, lcards, cards)

	//v.Print(os.Stdout)

}
