Пример #1
0
    public void sim_pack()
    {
        Debug.Log("sim pack =" + simpack[simpck_idx]);
        packArgs pack = _sim_parser.paser(simpack[simpck_idx]);

        pack_handel(pack);
//		if (pack.pack.Count == 0) {
//			Debug.Log ("sim pack drop=");
//		} else {
//
//		}
        simpck_idx = (simpck_idx + 1) % simpack.Count;
    }
Пример #2
0
    private void OnMessage(object sender, packArgs e)
    {
        Debug.Log("Lobby message = " + e.pack ["message_type"]);
        string state = e.pack ["message_type"];

        if (state == "MsgLogin")
        {
            _name.textContent   = e.pack ["player_name"];
            _credit.textContent = e.pack ["player_credit"];

            _model.putValue("uuid", e.pack ["player_uuid"]);
            //_model.putValue ("uuid", "6f4922f45568161a8cdf4ad2299f6d23");
            Debug.Log("Lobby uuid = " + _model.getValue("uuid"));
            string s = e.pack ["game_avaliable"];
            _model.putValue("game_list", s);

            _avalibelist.set_avalible(new List <string> (s.Split(',')));
        }
        else if (state == "MsgKeepLive")
        {
        }
        else if (state == "MsgPlayerCreditUpdate")
        {
            _credit.textContent = e.pack ["player_credit"];
        }
        if (e.pack ["message_type"] == "check")
        {
            Debug.Log("pack all = " + e.pack["_all"]);
        }

        //TODO game msg send to here later version
        // game_type == game ,pass to game
        //if (e.pack ["message_type"] == "MsgBPInitialInfo") {
        //	 if (e.pack["game_type"] =="pa") {

        //	}
        //	if (e.pack["game_type"] =="pa"){

        //	}
        //}
    }
Пример #3
0
    public void pack_handel(packArgs e)
    {
        //string st = e.pack ["message_type"];
        string st = _model.getValue("dk_message_type");

        _state = _model.getValue("dk_game_state");

        if (st == "MsgBPInitialInfo")
        {
            Debug.Log("dk _state = " + _state);
            _state_m._state = _state;
            view_enable();

            round_code(_model.getValue("dk_game_round"));

            string card = _model.getValue("player_card_list");
            _poker.set_all(poker_type.Player, card);
            if (_poker.get_count(poker_type.Player) == 1)
            {
                poker_open.Add(0);
            }
            if (_poker.get_count(poker_type.Player) == 2)
            {
                poker_open.Add(0);
                poker_open.Add(1);
            }

            card = _model.getValue("banker_card_list");

            _poker.set_all(poker_type.Banker, card);
            if (_poker.get_count(poker_type.Banker) == 1)
            {
                poker_open.Add(2);
            }
            if (_poker.get_count(poker_type.Banker) == 2)
            {
                poker_open.Add(2);
                poker_open.Add(3);
            }

            card = _model.getValue("river_card_list");
            _poker.set_all(poker_type.River, card);
            if (_poker.get_count(poker_type.River) == 1)
            {
                poker_open.Add(4);
            }
            if (_poker.get_count(poker_type.River) == 2)
            {
                poker_open.Add(4);
                poker_open.Add(5);
            }


            Debug.Log("pack all p= " + _model.getValue("player_card_list"));
            Debug.Log("pack all b= " + _model.getValue("banker_card_list"));
            Debug.Log("pack all r= " + _model.getValue("river_card_list"));

            state_update.Add(_state);
        }
        if (st == "MsgBPState")
        {
            _state_m._state = _state;
            view_enable();

            round_code(_model.getValue("dk_game_round"));

            //_Coin_item.item_set ("into_game");

            state_update.Add(_state);
        }
        if (st == "MsgBPOpenCard")
        {
            _state_m._state = _state;

            string cardtype  = _model.getValue("card_type");
            string card_list = _model.getValue("card_list");
            Debug.Log("carty = " + cardtype);
            Debug.Log("card_list = " + card_list);

            if (cardtype == "Player")
            {
                int pcount = _poker.get_count(poker_type.Player);

                //mi poker
                if (pcount == 1)
                {
                    _model.putValue("mi_kind", poker_type.Player.ToString());
                }
                else
                {
                    cardback [pcount].RotateCard(1, pcount);
                    cardback[pcount].CardRotateComplete += card_open_done;
                }
                _poker.set_poker(poker_type.Player, card_list);
            }

            if (cardtype == "Banker")
            {
                int bcount = _poker.get_count(poker_type.Banker);

                if (bcount == 1)
                {
                    _model.putValue("mi_kind", poker_type.Banker.ToString());
                }
                else
                {
                    cardback [bcount + 2].RotateCard(1, bcount + 2);
                    cardback[bcount + 2].CardRotateComplete += card_open_done;
                }

                _poker.set_poker(poker_type.Banker, card_list);
            }

            if (cardtype == "River")
            {
                int rcount = _poker.get_count(poker_type.River);

                string        s        = _model.getValue("dk_prob");
                List <string> prob     = new List <string> (s.Split(','));
                List <float>  raw_data = new List <float> ();
                int           len      = prob.Count;
                float         total    = 0;
                for (int i = 0; i < len; i++)
                {
                    total += float.Parse(prob[i]);
                }

                if (rcount == 1 && total != 0.0f)
                {
                    _model.putValue("mi_kind", poker_type.River.ToString());
                }
                else
                {
                    cardback [rcount + 4].RotateCard(1, rcount + 4);
                    cardback[rcount + 4].CardRotateComplete += card_open_done;
                }
                _poker.set_poker(poker_type.River, card_list);
            }

            state_update.Add(_state);
        }

        if (st == "MsgPlayerBet")
        {
            if (e.pack["result"] == "0")
            {
                string s = _bet_model.bet_ok();

                Debug.Log("bet ok = " + s);
                string btnname = _model.getValue("last_btn");
                bet_amount_list [_bet_model.zone_idx(btnname)].textContent = _bet_model.get_total(btnname).ToString();

                //TODO
                //flush_comfirm_bet();
            }
        }
        if (st == "MsgBPEndRound")
        {
            //_state = e.pack["game_state"];

            _state_m._state = _state;
            view_enable();

            Debug.Log(" bet_type= " + e.pack["bet_type"]);
            Debug.Log(" settle_amount= " + e.pack["settle_amount"]);
            Debug.Log(" odds= " + e.pack["odds"]);
            Debug.Log(" win_state= " + e.pack["win_state"]);
            Debug.Log(" bet_amount= " + e.pack["bet_amount"]);

            List <string> settle = new List <string>(e.pack["settle_amount"].ToString().Split(','));
            settle.RemoveAt(settle.Count - 1);
            settle.RemoveAt(settle.Count - 1);

            _bet_model.settle_amount(string.Join(",", settle.ToArray()));

            List <string> bet = new List <string>(e.pack["bet_amount"].ToString().Split(','));
            bet.RemoveAt(bet.Count - 1);
            bet.RemoveAt(bet.Count - 1);
            _bet_model.bet_amount(string.Join(",", bet.ToArray()));


            state_update.Add(_state);
        }
    }
Пример #4
0
 private void OnMessage(object sender, packArgs e)
 {
     pack_handel(e);
 }
Пример #5
0
    public void pack_handel(packArgs e)
    {
        string st = e.pack ["message_type"];

        Debug.Log("dk pack_handel message = " + st);


        if (st == "MsgBPInitialInfo")
        {
            _state = e.pack["game_state"];
            Debug.Log("dk _state = " + _state);
            _state_m._state = _state;
            view_enable();

            _model.putValue("game_id", e.pack["game_id"]);
            _model.putValue("game_type", e.pack["game_type"]);
            _model.putValue("game_round", e.pack["game_round"]);
            round_code(_model.getValue("game_round"));



            if (_state == "StartBetState" || _state == "NewRoundState")
            {
                _model.putValue("remain_time", e.pack["remain_time"]);

                _model.putValue("history_winner", e.pack["history_winner"]);

                string card    = e.pack["extra_card_list"];
                string no_open = e.pack["river_card_list"];
                Debug.Log("all poker = " + card + "," + no_open);
                if (card != "")
                {
                    if (no_open != "")
                    {
                        _poker.set_all(poker_type.Player, card + "," + no_open);
                    }
                    else
                    {
                        _poker.set_all(poker_type.Player, card);
                    }
                }
                //TODO MsgBPState also
                //_Coin_item.item_set ("into_game");
            }


            if (_state == "OpenState")
            {
                string card = e.pack["extra_card_list"];
                if (card != "")
                {
                    _poker.set_all(poker_type.Player, card);
                    if (_poker.get_count(poker_type.Player) == 1)
                    {
                        poker_open.Add(0);
                    }
                    if (_poker.get_count(poker_type.Player) == 2)
                    {
                        poker_open.Add(0);
                        poker_open.Add(1);
                    }
                    if (_poker.get_count(poker_type.Player) == 3)
                    {
                        poker_open.Add(0);
                        poker_open.Add(1);
                        poker_open.Add(2);
                    }
                    if (_poker.get_count(poker_type.Player) == 4)
                    {
                        poker_open.Add(0);
                        poker_open.Add(1);
                        poker_open.Add(2);
                        poker_open.Add(3);
                    }
                    if (_poker.get_count(poker_type.Player) == 5)
                    {
                        poker_open.Add(0);
                        poker_open.Add(1);
                        poker_open.Add(2);
                        poker_open.Add(3);
                        poker_open.Add(4);
                    }
                }

                Debug.Log("pack all p= " + e.pack["player_card_list"]);
                Debug.Log("pack all b= " + e.pack["banker_card_list"]);
                Debug.Log("pack all r= " + e.pack["river_card_list"]);
                Debug.Log("pack all e= " + e.pack["extra_card_list"]);
            }

            state_update.Add(_state);
        }
        if (st == "MsgBPState")
        {
            _state = e.pack["game_state"];
            Debug.Log("dk _state = " + _state);
            _state_m._state = _state;


            _model.putValue("game_round", e.pack["game_round"]);
            round_code(_model.getValue("game_round"));

            if (_state == "NewRoundState")
            {
                //TODO hisotry recode

                //switch to public_card
                _view_avalible.auto_set_avalible(2, avalibe.effect.just_open_close);

                //can't put in  new_round_init(), becuase ....you know that
                Debug.Log("poker clean");
                _poker.clean();
                cardlist = temp_public_cardlist;
                cardback = temp_public_cardback;
                reset_poker_item();
                remove_poker_event();
            }
            else if (_state == "StartBetState")
            {
                _model.putValue("remain_time", e.pack["remain_time"]);
                //_Coin_item.item_set ("into_game");
                view_enable();
            }
            else if (_state == "EndBetState")
            {
                cardlist = temp_cardlist;
                cardback = temp_cardback;
                reset_poker_item();
                remove_poker_event();

                view_enable();
            }
            else
            {
                view_enable();
            }



            state_update.Add(_state);
        }
        if (st == "MsgBPOpenCard")
        {
            _state = e.pack["game_state"];
            Debug.Log("dk _state = " + _state);
            _state_m._state = _state;

            Debug.Log("carty = " + e.pack["card_type"]);
            Debug.Log("card_list = " + e.pack["card_list"]);
            string cardtype = e.pack["card_type"];

            //public card open
            if (_state == "NewRoundState")
            {
                if (cardtype == "Extra")
                {
                    string card = e.pack["card_list"];



                    //open public using diff cardlist
                    cardlist = temp_public_cardlist;
                    cardback = temp_public_cardback;
                    int pcount = _poker.get_count(poker_type.Player);
                    Debug.Log("MsgBPOpenCard -> NewRoundState pcount = " + pcount);
                    cardback [pcount].RotateCard(1, pcount);
                    cardback[pcount].CardRotateComplete += card_open_done;

                    _poker.set_poker(poker_type.Player, card);
                }
            }

            //laster two card
            if (_state == "OpenState")
            {
                if (cardtype == "River")
                {
                    string card = e.pack["card_list"];


                    cardlist = temp_cardlist;
                    cardback = temp_cardback;
                    int pcount = _poker.get_count(poker_type.Player);
                    Debug.Log("pcount = " + pcount);
                    cardback [pcount].RotateCard(1, pcount);
                    cardback[pcount].CardRotateComplete += card_open_done;

                    _poker.set_poker(poker_type.Player, card);
                }
            }


            state_update.Add(_state);
        }

        if (st == "MsgPlayerBet")
        {
            if (e.pack["result"] == "0")
            {
                string s = _bet_model.bet_ok();

                Debug.Log("bet ok = " + s);
                string btnname = _model.getValue("last_btn");
                bet_amount_list [_bet_model.zone_idx(btnname)].textContent = _bet_model.get_total(btnname).ToString();
            }
        }
        if (st == "MsgBPEndRound")
        {
            _state = e.pack["game_state"];

            _state_m._state = _state;
            view_enable();

            List <string> settle = new List <string>(e.pack["settle_amount"].ToString().Split(','));
            _bet_model.settle_amount(string.Join(",", settle.ToArray()));

            List <string> bet = new List <string>(e.pack["bet_amount"].ToString().Split(','));
            _bet_model.bet_amount(string.Join(",", bet.ToArray()));


            state_update.Add(_state);
        }
    }
Пример #6
0
    public void pack_handel(packArgs e)
    {
        string st = e.pack ["message_type"];

        Debug.Log("dk pack_handel message = " + st);


        if (st == "MsgBPInitialInfo")
        {
            _state = e.pack["game_state"];
            Debug.Log("pa _state = " + _state);
            _state_m._state = _state;
            view_enable();

            _model.putValue("game_id", e.pack["game_id"]);
            _model.putValue("game_type", e.pack["game_type"]);
            _model.putValue("game_round", e.pack["game_round"]);
            round_code(_model.getValue("game_round"));

            if (_state == "StartBetState" || _state == "NewRoundState")
            {
                _model.putValue("remain_time", e.pack["remain_time"]);

                _model.putValue("history_winner", e.pack["history_winner"]);
                _model.putValue("history_point", e.pack["history_point"]);
                //TODO MsgBPState also
                //_Coin_item.item_set ("into_game");
            }


            if (_state == "OpenState")
            {
                string card = e.pack["player_card_list"];
                if (card != "")
                {
                    _poker.set_all(poker_type.Player, card);
                    if (_poker.get_count(poker_type.Player) == 1)
                    {
                        poker_open.Add(0);
                    }
                    if (_poker.get_count(poker_type.Player) == 2)
                    {
                        poker_open.Add(0);
                        poker_open.Add(1);
                    }
                    if (_poker.get_count(poker_type.Player) == 3)
                    {
                        poker_open.Add(0);
                        poker_open.Add(1);
                        poker_open.Add(2);
                    }
                    if (_poker.get_count(poker_type.Player) == 4)
                    {
                        poker_open.Add(0);
                        poker_open.Add(1);
                        poker_open.Add(2);
                        poker_open.Add(3);
                    }
                    if (_poker.get_count(poker_type.Player) == 5)
                    {
                        poker_open.Add(0);
                        poker_open.Add(1);
                        poker_open.Add(2);
                        poker_open.Add(3);
                        poker_open.Add(4);
                    }
                }

                card = e.pack["banker_card_list"];
                if (card != "")
                {
                    _poker.set_all(poker_type.Banker, card);
                    if (_poker.get_count(poker_type.Banker) == 1)
                    {
                        poker_open.Add(5);
                    }
                    if (_poker.get_count(poker_type.Banker) == 2)
                    {
                        poker_open.Add(5);
                        poker_open.Add(6);
                    }
                    if (_poker.get_count(poker_type.Banker) == 3)
                    {
                        poker_open.Add(5);
                        poker_open.Add(6);
                        poker_open.Add(7);
                    }
                    if (_poker.get_count(poker_type.Banker) == 4)
                    {
                        poker_open.Add(5);
                        poker_open.Add(6);
                        poker_open.Add(7);
                        poker_open.Add(8);
                    }
                    if (_poker.get_count(poker_type.Banker) == 5)
                    {
                        poker_open.Add(5);
                        poker_open.Add(6);
                        poker_open.Add(7);
                        poker_open.Add(8);
                        poker_open.Add(9);
                    }
                }


                Debug.Log("pack all p= " + e.pack["player_card_list"]);
                Debug.Log("pack all b= " + e.pack["banker_card_list"]);
                Debug.Log("pack all e= " + e.pack["extra_card_list"]);
            }

            state_update.Add(_state);
        }
        if (st == "MsgBPState")
        {
            _state = e.pack["game_state"];
            Debug.Log("dk _state = " + _state);
            _state_m._state = _state;
            view_enable();

            _model.putValue("game_round", e.pack["game_round"]);
            round_code(_model.getValue("game_round"));

            if (_state == "NewRoundState")
            {
                //TODO hisotry recode
            }
            if (_state == "StartBetState")
            {
                _model.putValue("remain_time", e.pack["remain_time"]);
                //_Coin_item.item_set ("into_game");
            }



            state_update.Add(_state);
        }
        if (st == "MsgBPOpenCard")
        {
            _state = e.pack["game_state"];
            Debug.Log("dk _state = " + _state);
            _state_m._state = _state;


            Debug.Log("dk _state_m._state = " + _state_m._state);
            Debug.Log("carty = " + e.pack["card_type"]);
            Debug.Log("card_list = " + e.pack["card_list"]);
            string cardtype = e.pack["card_type"];
            if (cardtype == "Player")
            {
                int pcount = _poker.get_count(poker_type.Player);
                cardback [pcount].RotateCard(1, pcount);
                cardback[pcount].CardRotateComplete += card_open_done;

                _poker.set_poker(poker_type.Player, e.pack["card_list"]);
            }

            if (cardtype == "Banker")
            {
                int bcount = _poker.get_count(poker_type.Banker);
                cardback [bcount + 5].RotateCard(1, bcount + 5);
                cardback[bcount + 5].CardRotateComplete += card_open_done;
                _poker.set_poker(poker_type.Banker, e.pack["card_list"]);
            }

            if (cardtype == "River")
            {
                //TODO 開
                Debug.Log("open river");
                //int rcount = _poker.get_count(poker_type.River);
                //cardback [rcount+4].RotateCard (1,rcount+4);
                //cardback[rcount+4].CardRotateComplete += card_open_done;
                //_poker.set_poker(poker_type.River,e.pack["card_list"]);
            }

            state_update.Add(_state);
        }

        if (st == "MsgPlayerBet")
        {
            if (e.pack["result"] == "0")
            {
                string s = _bet_model.bet_ok();

                Debug.Log("bet ok = " + s);
                string btnname = _model.getValue("last_btn");
                bet_amount_list [_bet_model.zone_idx(btnname)].textContent = _bet_model.get_total(btnname).ToString();
            }
        }
        if (st == "MsgBPEndRound")
        {
            _state = e.pack["game_state"];

            _state_m._state = _state;
            view_enable();

            Debug.Log(" bet_type= " + e.pack["bet_type"]);
            Debug.Log(" settle_amount= " + e.pack["settle_amount"]);
            Debug.Log(" odds= " + e.pack["odds"]);
            Debug.Log(" win_state= " + e.pack["win_state"]);
            Debug.Log(" bet_amount= " + e.pack["bet_amount"]);

            _bet_model.settle_amount(e.pack["settle_amount"].ToString());
            _bet_model.bet_amount(e.pack["bet_amount"].ToString());


            state_update.Add(_state);
        }
    }