protected bool ChencSubmitDatas(CookieContainer cookieContainer, String postData)
 {
     var submitAction = new SubmitOrderAction();
     var translation = new HTML_Translation();
     submitAction.PostData = postData;
     var str = submitAction.CheckOrderInfoEx(cookieContainer);
     var returnString = translation.TranslationHtmlEx(str);
     if (returnString["data"]["errMsg"] != null && returnString["data"]["errMsg"].ToString() != "")
     {
         return  _checkState = false;
     }
     if (str.Contains("取消次数过多"))
     {
         return _checkState = false;
     }
     if (returnString["data"]["get608Msg"] != null)
     {
         return  _checkState = false;
     }
     if (returnString["messages"].Any())
     {
         return _checkState = false;
     }
     return _checkState = true;
 }
 private void GetRandCodeImgForSubmit(CookieContainer cookieContainer,Action<Image> callback )
 {
     var submitAction = new SubmitOrderAction();
     submitAction.GetOrderRandCodeImg((bit) =>
     {
         callback(bit);
     }, cookieContainer);
 }
예제 #3
0
    private GameObject GetHighlight(int step)
    {
        ZAction = null;
        XAction = null;

        HighlightedIndex += step;
        if (HighlightedIndex >= IM.ItemList.Count)
        {
            HighlightedIndex = -IM.IngredientSpawners.Count;
        }
        else if (HighlightedIndex < -IM.IngredientSpawners.Count)
        {
            HighlightedIndex = IM.ItemList.Count - 1;
        }

        if (HighlightedIndex >= 0)
        {
            if (!PlayerRef.IsHolding)
            {
                PrepareAction prepAction = null;
                if (IM.ItemList[HighlightedIndex].MyItemType == ItemType.INGREDIENT)
                {
                    foreach (int boardID in IM.BoardIndexList)
                    {
                        Board b = IM.ItemList[boardID] as Board;
                        if (b.HoldingItem != null && b.HoldingItem.ID == HighlightedIndex)
                        {
                            prepAction = new PrepareAction(boardID);
                            XAction    = prepAction;
                            break;
                        }
                    }
                }

                PickUpAction puAction = new PickUpAction(HighlightedIndex);
                if (puAction.isValid(CurrentState))
                {
                    ZAction = puAction;
                }
                else
                {
                    puAction = null;
                }

                if (puAction != null || prepAction != null)
                {
                    return(IM.ItemList[HighlightedIndex].gameObject);
                }
                else
                {
                    return(GetHighlight(step));
                }
            }
            else
            {
                SubmitOrderAction soAction = new SubmitOrderAction();
                if (soAction.isValid(CurrentState))
                {
                    XAction = soAction;
                }

                DropOffAction doAction = new DropOffAction(HighlightedIndex);
                if (doAction.isValid(CurrentState))
                {
                    ZAction = doAction;
                    return(IM.ItemList[HighlightedIndex].gameObject);
                }

                TransferAction transAction = new TransferAction(HighlightedIndex);
                if (transAction.isValid(CurrentState))
                {
                    ZAction = transAction;
                    return(IM.ItemList[HighlightedIndex].gameObject);
                }

                return(GetHighlight(step));
            }
        }
        else
        {
            int         spawnerIndex = ~HighlightedIndex;
            SpawnAction sAction      = new SpawnAction(IM.IngredientSpawners[spawnerIndex].MyIngredientType);
            if (sAction.isValid(CurrentState))
            {
                ZAction = sAction;
                return(IM.IngredientSpawners[spawnerIndex].gameObject);
            }
            else
            {
                return(GetHighlight(step));
            }
        }
    }
        protected void InitTokenDatasDTO(CookieContainer cookieContainer,string postData)
        {
            TokenDatas.Clear();
            var submitAction = new SubmitOrderAction();
            var htmlTran = new HTML_Translation();
            submitAction.PostData = postData;
            submitAction.EnterSubmitPage((str) =>
            {
                var returnString = htmlTran.TranslationHtmlEx(str);
                if (returnString["messages"].Any())
                {
                    if (str.Contains("未完成订单"))
                    {
                        TokenDatas["errMsg"] = "你有未完成的订单等待处理";
                        return;
                    }
                    else
                    {
                        TokenDatas["errMsg"] = "获取Token失败";
                        return;
                    }
                }
                string tokenHtml = submitAction.GetTokenFromSubmitPage(cookieContainer);
                TokenDatas["Token"] =
                    System.Text.RegularExpressions.Regex.Match(tokenHtml,
                        "(?<=var globalRepeatSubmitToken = ')[0-9abcdefABCDEF]{32}").ToString();
                TokenDatas["leftTicket"] =
                    System.Text.RegularExpressions.Regex.Match(tokenHtml, "(?<='leftTicketStr':')[0-9A-Za-z]{30,50}")
                        .ToString();
                TokenDatas["keyCheck"] =
                    System.Text.RegularExpressions.Regex.Match(tokenHtml, "(?<='key_check_isChange':')[0-9A-Za-z]*")
                        .ToString();
                TokenDatas["trainLocation"] =
                    System.Text.RegularExpressions.Regex.Match(tokenHtml, "(?<='train_location':')[^']*").ToString();
                TokenDatas["purposeCodes"] =
                    System.Text.RegularExpressions.Regex.Match(tokenHtml, "(?<='purpose_codes':')[^']*").ToString();
                TokenDatas["ticketInfoForPassengerForm"] =
                    System.Text.RegularExpressions.Regex.Match(tokenHtml, "(?<=ticketInfoForPassengerForm=)[^;]*")
                        .ToString()
                        .Replace("'", "\"");
                var javaObj = htmlTran.TranslationHtmlEx(TokenDatas["ticketInfoForPassengerForm"].ToString());
                TokenDatas["queryLeftNewDetailDTO"] = javaObj["queryLeftNewDetailDTO"] as JObject;

                if (TokenDatas["Token"] != null && TokenDatas["Token"].ToString() != "" &&
                    TokenDatas["leftTicket"] != null && TokenDatas["leftTicket"].ToString() != "")
                {
                    _dataReady = true;
                }
                else
                {
                    _dataReady = false;
                }
            },cookieContainer);
        }
예제 #5
0
    /// <summary>
    /// Used to get all of the valid actions for the current state
    /// </summary>
    /// <returns></returns>
    public List <Action> GetValidActions(AIState state)
    {
        List <Action> validActions = new List <Action>();

        //Waiting around
        validActions.Add(new IdleAction());

        //Things you can do when your hands are free
        if (state.CurrentPlayerState.HandsFree())
        {
            //Spawning items
            foreach (IngredientType type in System.Enum.GetValues(typeof(IngredientType)))
            {
                SpawnAction spawnAction = new SpawnAction(type);
                if (spawnAction.isValid(state))
                {
                    validActions.Add(spawnAction);
                }
            }

            PickUpAction pickupAction;
            //Picking up everything
            //Ingredients
            foreach (int ingredientID in state.IngredientStateIndexList)
            {
                IngredientState ingredient = state.ItemStateList[ingredientID] as IngredientState;
                if (ingredient.IsSpawned && !ingredient.IsInMeal)
                {
                    pickupAction = new PickUpAction(ingredient.ID);
                    validActions.Add(pickupAction);
                }
            }

            //Pots
            foreach (int potID in state.PotStateIndexList)
            {
                PotState pot = state.ItemStateList[potID] as PotState;
                pickupAction = new PickUpAction(pot.ID);
                validActions.Add(pickupAction);
            }

            //Plates
            foreach (int plateID in state.PlateStateIndexList)
            {
                PlateState plate = state.ItemStateList[plateID] as PlateState;
                pickupAction = new PickUpAction(plate.ID);
                validActions.Add(pickupAction);
            }

            PrepareAction prepAction;
            foreach (int boardID in state.BoardStateIndexList)
            {
                BoardState bState = state.ItemStateList[boardID] as BoardState;
                if (!bState.IsFree())
                {
                    IngredientState iState = state.ItemStateList[bState.HoldingItemID] as IngredientState;
                    if (iState != null && !iState.IsPrepared)
                    {
                        prepAction = new PrepareAction(boardID);
                        validActions.Add(prepAction);
                    }
                }
            }
        }

        //Things you can do when you have something in hand
        else
        {
            DropOffAction  dropoffAction;
            TransferAction transferAction;
            ItemState      itemState = state.ItemStateList[state.CurrentPlayerState.HoldingItemID];
            ItemType       type      = itemState.MyItemType;

            if (type == ItemType.INGREDIENT)
            {
                //Putting things on the table
                foreach (int tableID in state.TableStateIndexList)
                {
                    TableSpace table = state.ItemStateList[tableID] as TableSpace;
                    if (table.IsFree())
                    {
                        dropoffAction = new DropOffAction(table.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                //Moving ingredients to a cutting board
                foreach (int boardID in state.BoardStateIndexList)
                {
                    BoardState board = state.ItemStateList[boardID] as BoardState;
                    if (board.IsFree())
                    {
                        dropoffAction = new DropOffAction(board.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                if ((itemState as IngredientState).IsPrepared)
                {
                    //Moving ingredients to a pot
                    foreach (int potID in state.PotStateIndexList)
                    {
                        PotState  pot  = state.ItemStateList[potID] as PotState;
                        MealState meal = state.ItemStateList[pot.mealID] as MealState;
                        if (meal.MealSize() + 1 <= PotState.MAX_ITEMS_PER_POT && !meal.IsBurnt())
                        {
                            dropoffAction = new DropOffAction(pot.ID);
                            validActions.Add(dropoffAction);
                        }
                    }

                    //Moving ingredients to a plate
                    foreach (int plateID in state.PlateStateIndexList)
                    {
                        PlateState plate = state.ItemStateList[plateID] as PlateState;
                        MealState  meal  = state.ItemStateList[plate.mealID] as MealState;
                        if (!plate.IsSubmitted && !meal.IsBurnt())
                        {
                            dropoffAction = new DropOffAction(plate.ID);
                            validActions.Add(dropoffAction);
                        }
                    }
                }
            }

            if (type == ItemType.POT)
            {
                PotState  pot  = itemState as PotState;
                MealState meal = state.ItemStateList[pot.mealID] as MealState;

                //Putting the pot on the table
                foreach (int tableID in state.TableStateIndexList)
                {
                    TableSpace table = state.ItemStateList[tableID] as TableSpace;
                    if (table.IsFree())
                    {
                        dropoffAction = new DropOffAction(table.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                //Moving meal to a pot
                transferAction = new TransferAction(Item.NOTHING_ID);
                foreach (int potID in state.PotStateIndexList)
                {
                    transferAction.id = potID;
                    if (transferAction.isValid(state))
                    {
                        validActions.Add(transferAction);
                        transferAction = new TransferAction(Item.NOTHING_ID);
                    }
                }

                //Moving the meal to another plate
                foreach (int plateID in state.PlateStateIndexList)
                {
                    transferAction.id = plateID;
                    if (transferAction.isValid(state))
                    {
                        validActions.Add(transferAction);
                        transferAction = new TransferAction(Item.NOTHING_ID);
                    }
                }
            }

            if (type == ItemType.PLATE)
            {
                PlateState plate = itemState as PlateState;

                //Putting things on the table
                foreach (int tableID in state.TableStateIndexList)
                {
                    TableSpace table = state.ItemStateList[tableID] as TableSpace;
                    if (table.IsFree())
                    {
                        dropoffAction = new DropOffAction(table.ID);
                        validActions.Add(dropoffAction);
                    }
                }

                //If the plate is non-empty
                MealState heldMeal = state.ItemStateList[plate.mealID] as MealState;
                if (heldMeal.IsSpawned())
                {
                    //Submitting the meal
                    if (heldMeal.IsCooked())
                    {
                        SubmitOrderAction submitAction = new SubmitOrderAction();
                        validActions.Add(submitAction);
                    }

                    //Moving meal to a pot
                    transferAction = new TransferAction(Item.NOTHING_ID);
                    foreach (int potID in state.PotStateIndexList)
                    {
                        transferAction.id = potID;
                        if (transferAction.isValid(state))
                        {
                            validActions.Add(transferAction);
                            transferAction = new TransferAction(Item.NOTHING_ID);
                        }
                    }

                    //Moving the meal to another plate
                    foreach (int plateID in state.PlateStateIndexList)
                    {
                        transferAction.id = plateID;
                        if (transferAction.isValid(state))
                        {
                            validActions.Add(transferAction);
                            transferAction = new TransferAction(Item.NOTHING_ID);
                        }
                    }
                }
            }
        }


        return(validActions);
    }