示例#1
0
        public PlaceResult PlaceMark(int v1, string v2)
        {
            PlaceResult SpaceResult = PlaceResult.Invalid;

            if (spaces[v1] == null)
            {
                SpaceResult = PlaceResult.Ok;
                spaces[v1]  = v2;
                spacesLeft--;
                if (isWin(v2))
                {
                    SpaceResult = PlaceResult.Win;
                }
                else if (spacesLeft == 0)
                {
                    SpaceResult = PlaceResult.Tie;
                }
            }
            else if (spaces[v1] == v2)
            {
                SpaceResult = PlaceResult.Duplicate;
            }
            else if (spaces[v1] != v2)
            {
                SpaceResult = PlaceResult.Invalid;
            }


            return(SpaceResult);
        }
示例#2
0
        public PlaceResult PayOrder(Guid orderId)
        {
            var result = new PlaceResult()
            {
                Success = false, OrderId = orderId
            };

            using (var uow = GetUnitOfWork())
            {
                var order = uow.Repository <ZY_Order>().Query().Filter(x => x.OrderId == orderId && x.Status != 1).Get().FirstOrDefault();
                if (order != null && !string.IsNullOrEmpty(order.Prepay_id))
                {
                    result.Success   = true;
                    result.appId     = WxConfig.Appid;
                    result.timeStamp = Utility.GetTimeSpan();
                    result.nonceStr  = Utility.GenerateNonceStr();
                    result.signType  = "MD5";
                    result.prepay_id = order.Prepay_id;
                    string payRaw = "appId=" + result.appId
                                    + "&nonceStr=" + result.nonceStr
                                    + "&package=" + result.package
                                    + "&signType=" + result.signType
                                    + "&timeStamp=" + result.timeStamp;
                    result.paySign = Utility.Signature(payRaw, result.signType);
                }
            }
            return(result);
        }
示例#3
0
        public bool IsEqualTo(ISelectionState selection)
        {
            if (selection == null)
            {
                throw new ArgumentNullException("selection", "selection is null in SelectionState comparison");
            }

            if (ReferenceEquals(this, selection))
            {
                return(true);
            }

            if (selection.Id != Id)
            {
                throw new Exception("Cannot compare two selections with different Ids");
            }

            bool ret = (selection.Name == null || selection.Name == this.Name) &&
                       this.Price == selection.Price &&
                       this.Tradability == selection.Tradability &&
                       this.Status == selection.Status;

            if (IsRollingSelection)
            {
                ret &= Line == selection.Line;
            }

            if (Result != null)
            {
                if (selection.Result == null)
                {
                    return(false);
                }

                ret &= Result.IsEqualTo(selection.Result);
            }
            else if (selection.Result != null)
            {
                return(false);
            }

            if (PlaceResult != null)
            {
                if (selection.PlaceResult == null)
                {
                    return(false);
                }

                ret &= PlaceResult.IsEqualTo(selection.PlaceResult);
            }
            else if (selection.PlaceResult != null)
            {
                return(false);
            }

            return(ret);
        }
        public async Task <PlaceResult> GetPlaceDetails(string placeId)
        {
            PlaceResult result = null;

            _apiService.BaseUri = ApiBaseAddress;
            var res = await _apiService.GetResponseAsync <PlaceResult>($"api/place/details/json?placeid={Uri.EscapeUriString(placeId)}&key={_googlePlaceKey}");

            result = res.Result;

            return(result);
        }
示例#5
0
        public override void Execute(TaskContext taskContext)
        {
            ParameterSet parameters = taskContext.GetParameters();
            XmlDocument _doc = new XmlDocument();
            //string street1 = "";
            //string street2 = "";

            try
            {
                Point location = parameters.GetParameter("Geometry") as Point;
                string coords = parameters.GetParameter("COORDS") as string;
                //string UrlString = "";

                //below commented out for UC
                ////use GeoNames.org to find the nearest intersection to provide a meaningful title for the result and the popup
                //UrlString = "http://ws.geonames.org/findNearestIntersection?lat=" + location.Y.ToString() + "&lng=" + location.X.ToString();
                //_doc.Load(UrlString);
                //XPathNavigator nav = _doc.CreateNavigator();
                //XPathNodeIterator itr = nav.Select("/geonames/intersection");
                //while (itr.MoveNext())
                //{
                //    XPathNodeIterator nodeItrChildren = itr.Current.SelectChildren(XPathNodeType.Element);

                //    XPathNavigator currNode = nodeItrChildren.Current;
                //    street1 = currNode.SelectSingleNode("street1").InnerXml;
                //    street2 = currNode.SelectSingleNode("street2").InnerXml;
                //}
                //above commented out for UC

                // Set up the appearance of the result.
                //PlaceResult newResult = new PlaceResult("StreetViewer", "StreetView at " + street1 +  "&"  + street2,
                PlaceResult newResult = new PlaceResult("StreetViewer", "StreetView",
                    location, "Yellow Pushpin");
                newResult.SubType = "Places";
                newResult.Category = "StreetViewer Results";
                //next line is server that contains the HTML page (getPano.html) that creates the StreetView
                //newResult.Description = "http://www.yoursite.com/folder/getPano.html?lat=" + location.Y.ToString() + "&long=" + location.X.ToString();
                newResult.Description = "http://www.gisconsultancy.com/stview/getPano.html?lat=" + location.Y.ToString() + "&long=" + location.X.ToString();
                //newResult.Title = "StreetView at " + street1 + " + " + street2;
                newResult.Title = "StreetView";
                taskContext.UpdateResult(newResult);

            }
            catch
            {
                // Could investigate the exception thrown here.
                // In this case, do not create a Result, just set the status and message on the TaskContext and return.
                taskContext.SetStatusMessage(esriE2TaskStatus.CompletedNoValue, "StreetViewer did not find that location.");
                taskContext.ExitStatus = esriE2TaskExitStatus.CompletedNoValue;
            }
        }
示例#6
0
        public CylinderPlaceArgs StopPlacingCylinder()
        {
            if (_currentCylinder == null)
            {
                return(null);
            }

            CylinderController currentCylinder = _currentCylinder;

            UnstoreCylinder();
            PlaceResult       placeResult = GetPlaceResultByCylinderScale(currentCylinder);
            CylinderPlaceArgs placeArgs   = ConstructCylinderPlaceArgs(currentCylinder, placeResult);

            return(placeArgs);
        }
示例#7
0
        public static PlaceResult PlaceFromGameBin(EditTownModel ths, UIBinInfo info, ulong lotId, PlaceAction action)
        {
            PlaceResult contentFailure = PlaceResult.ContentFailure;
            Lot         lot            = LotManager.GetLot(lotId);

            if (lot == null)
            {
                return(PlaceResult.InvalidLot);
            }
            else if (lot.Household != null)
            {
                return(PlaceResult.HouseholdPresent);
            }

            ths.GetInWorldHouseholdBinInfoList();
            contentFailure = PlaceResult.ContentFailure;
            if (info.HouseholdId != ulong.MaxValue)
            {
                BinCommon.KickSimsOffLot(lot, true);
                if (info.LotId != ulong.MaxValue)
                {
                    contentFailure = BinCommonEx.PlaceHouseholdAndContentsFromGameBin(info.ContentId, lot, action, Mover.GetLotCost);
                }
                else
                {
                    contentFailure = BinCommonEx.PlaceHouseholdFromGameBin(info.ContentId, lot, action, Mover.GetLotCost);
                }

                if (contentFailure != PlaceResult.Success)
                {
                    return(contentFailure);
                }

                ths.mGameBin.Remove(info);
                if (ths.GameBinChanged != null)
                {
                    ths.GameBinChanged(ths, null);
                }

                info = BinCommon.CreateInWorldBinInfo(lot.Household, lot);
                if (info != null)
                {
                    ths.mInWorldHouseholdBin.Add(info);
                }
            }
            return(contentFailure);
        }
示例#8
0
        public PlaceResult DeleteOrder(Guid orderId)
        {
            var result = new PlaceResult()
            {
                Success = true, OrderId = orderId
            };

            using (var uow = GetUnitOfWork())
            {
                var order = uow.Repository <ZY_Order>().Query().Filter(x => x.OrderId == orderId && x.Status == 0).Get().FirstOrDefault();
                if (order != null)
                {
                    var plist = uow.Repository <ZY_Booked_Position>().Query().Filter(x => x.OrderId == orderId).Get().ToList();
                    foreach (var p in plist)
                    {
                        uow.Repository <ZY_Booked_Position>().Delete(p);
                    }
                    uow.Repository <ZY_Order>().Delete(order);
                    uow.Save();
                }
            }
            return(result);
        }
示例#9
0
        public static PlaceResult PlaceFromExportBin(ExportBinContents exportBinItem, Lot lot, PlaceAction action, bool buyFurnished, GetLotCost onLotCost, ref Sim newActiveSim)
        {
            if (exportBinItem == null)
            {
                return(PlaceResult.ContentFailure);
            }

            bool flag = exportBinItem.IsLoaded();

            if (!flag)
            {
                ExportBinContentsEx.Import(exportBinItem, false);
            }

            PlaceResult result = PlaceFromExportBin(exportBinItem.Household, exportBinItem, lot, action, buyFurnished, onLotCost, ref newActiveSim);

            if (!flag)
            {
                ExportBinContentsEx.Flush(exportBinItem);
            }

            return(result);
        }
示例#10
0
        public PlaceResult GetIntrest(IEnumerable <int> arr)
        {
            var tcpClient = new TcpClient("127.0.0.1", 9999);
            var netStream = tcpClient.GetStream();
            var value     = string.Empty;

            foreach (var num in arr)
            {
                value += num + ",";
            }
            value = value.Remove(value.Length - 1);

            var placeRes = new PlaceResult();;

            using (var writer = new StreamWriter(netStream))
                using (var reader = new StreamReader(netStream))
                {
                    writer.WriteLine(value);
                    writer.Flush();
                    placeRes.Cities  = reader.ReadLine().Split(',');
                    placeRes.Intrest = reader.ReadLine().Split(',');
                }
            return(placeRes);
        }
示例#11
0
        public static PlaceResult PlaceFromExportBin(EditTownModel ths, UIBinInfo info, ulong lotId, PlaceAction action, bool showConfirmDialog)
        {
            try
            {
                PlaceResult contentFailure = PlaceResult.ContentFailure;
                Lot         lot            = LotManager.GetLot(lotId);
                if (lot == null)
                {
                    return(PlaceResult.InvalidLot);
                }

                ExportBinContents exportBinItem = ths.FindExportBinContents(info.ContentId);
                if (exportBinItem != null)
                {
                    ths.GetInWorldHouseholdBinInfoList();
                    ths.GetInWorldLotBinInfoList();
                    Sim newActiveSim = null;
                    if (lot.Household != null)
                    {
                        return(BinCommonEx.MergeHouseholdFromExportBin(exportBinItem, lot, showConfirmDialog, Mover.Settings.mAllowGreaterThanEight));
                    }

                    BinCommon.KickSimsOffLot(lot, true);
                    ProgressDialog.Show(Localization.LocalizeString("Ui/Caption/Global:Processing", new object[0x0]));

                    try
                    {
                        try
                        {
                            contentFailure = BinCommonEx.PlaceFromExportBin(exportBinItem, lot, action, true, Mover.GetLotCost, ref newActiveSim);

                            ExportBinContentsEx.Flush(exportBinItem);

                            UIBinInfo item = BinCommon.CreateInWorldBinInfo(lot.Household, lot);
                            if (item != null)
                            {
                                if (info.HouseholdId != ulong.MaxValue)
                                {
                                    ths.mInWorldHouseholdBin.Add(item);
                                }
                                else
                                {
                                    ths.mInWorldLotBin.Add(item);
                                }
                            }
                        }
                        finally
                        {
                            ProgressDialog.Close();
                        }
                    }
                    catch (ExecutionEngineException)
                    { }
                }
                return(contentFailure);
            }
            catch (Exception e)
            {
                Common.Exception("PlaceFromExportBin", e);
                return(PlaceResult.ContentFailure);
            }
        }
示例#12
0
 private void AddResultToTextBox(PlaceResult res)
 {
     //Add result into TextBox
     this.txtLocation.Text = res.Title;
     this.txtLocation.Tag = res.Geometry;
 }
示例#13
0
    private PlaceResult PlaceRoom(Vector2Int mapSize, Room7DRLGeneratorData genData, ref int[,] mapAux, List <Room7DRL> rooms, Room7DRL next)
    {
        Debug.Log("Entered PlaceRoom");
        PlaceResult result = new PlaceResult();
        Vector2Int  wall   = Vector2Int.zero;


        List <(Vector2Int, Vector2Int)> candidateCoords = new List <(Vector2Int, Vector2Int)>();

        Vector2Int[] offsets = new Vector2Int[4]
        {
            new Vector2Int(1, 0),  // N
            new Vector2Int(-1, 0), // S
            new Vector2Int(0, 1),  // E
            new Vector2Int(0, -1)  // W
        };

        for (int i = 1; i < mapSize.x - 1; ++i)
        {
            for (int j = 1; j < mapSize.y - 1; ++j)
            {
                for (int dir = 0; dir < 4; ++dir)
                {
                    Vector2Int offset = offsets[dir];
                    try
                    {
                        if (mapAux[i, j] == genData.NoTile && mapAux[i + offsets[dir].x, j + offsets[dir].y] == genData.NoTile && mapAux[i - offsets[dir].x, j - offsets[dir].y] == genData.GroundTile)
                        {
                            candidateCoords.Add((new Vector2Int(i, j), offsets[dir]));
                        }
                    }
                    catch (IndexOutOfRangeException e)
                    {
                        Debug.LogError($"offset: {offset}, i,j:{(i, j)}");
                        Debug.DebugBreak();
                        continue;
                    }
                }
            }
        }
        if (candidateCoords.Count == 0)
        {
            // No way to place this room
            Debug.Log($"PLACE ROOMS:: No single coord was found matching the noTile/[noTile]/ground requirement :/");
            return(null);
        }

        List <Vector2Int> groundTiles = new List <Vector2Int>();

        for (int i = 0; i < next.size.x; ++i)
        {
            for (int j = 0; j < next.size.y; ++j)
            {
                if (next.tiles[i, j] == genData.GroundTile)
                {
                    groundTiles.Add(new Vector2Int(i, j));
                }
            }
        }

        if (groundTiles.Count == 0)
        {
            Debug.Log("Invalid room. GTFO");
            return(null);
        }

        for (int i = 0; i < genData.PlaceAttempts; ++i)
        {
            int idx = URandom.Range(0, candidateCoords.Count);

            wall = candidateCoords[idx].Item1;
            Vector2Int direction = candidateCoords[idx].Item2;

            Vector2Int start  = groundTiles[URandom.Range(0, groundTiles.Count)];
            int        startX = wall.x - start.x;
            int        startY = wall.y - start.y;


            for (int tunnelLen = 0; tunnelLen < genData.MaxTunnelLength; ++tunnelLen)
            {
                Vector2Int cand     = new Vector2Int(startX + direction.x * tunnelLen, startY + direction.y * tunnelLen);
                bool       overlaps = Overlaps(next, mapAux, cand, mapSize, genData.GroundTile);
                if (!overlaps)
                {
                    next.coords      = cand;
                    result.wallTile  = wall;
                    result.direction = direction;
                    result.length    = tunnelLen;

                    return(result);
                }
            }
        }
        return(null);
    }
示例#14
0
        public PlaceResult PlaceOrder(OrderInfo orderInfo)
        {
            var result = new PlaceResult()
            {
                Success = true, OrderId = Guid.NewGuid()
            };

            if (orderInfo.Positions == null || orderInfo.Positions.Count == 0)
            {
                result.Success = false;
                result.Message = "请选择位置";
                return(result);
            }
            var o = new JSSDKPayOrder();

            o.out_trade_no     = result.OrderId.ToString();
            o.body             = "";           //腾讯充值中心-QQ会员充值
            o.attach           = "";           //深圳分店
            o.spbill_create_ip = orderInfo.IP; //APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。
            result.prepay_id   = "test";
            //result.prepay_id = WxApiHelper.Instance.GetPaymentId(o);//todo test
            result.appId     = WxConfig.Appid;
            result.timeStamp = Utility.GetTimeSpan();
            result.nonceStr  = Utility.GenerateNonceStr();
            result.signType  = "MD5";
            string payRaw = "appId=" + result.appId
                            + "&nonceStr=" + result.nonceStr
                            + "&package=" + result.package
                            + "&signType=" + result.signType
                            + "&timeStamp=" + result.timeStamp;

            result.paySign = Utility.Signature(payRaw, result.signType);
            try
            {
                using (var uow = GetUnitOfWork())
                {
                    var desk =
                        uow.Repository <ZY_Shop_Desk>()
                        .Query()
                        .Filter(x => x.DeskId == orderInfo.DeskId)
                        .Get()
                        .FirstOrDefault();
                    if (desk == null)
                    {
                        result.Success = false;
                        result.Message = "没有找到桌子";
                        return(result);
                    }
                    var order = new ZY_Order()
                    {
                        OrderId        = result.OrderId,
                        Amount         = orderInfo.Positions.Count * desk.UnitPrice,
                        CustomerOpenId = orderInfo.CustomerOpenId,
                        OrderDate      = orderInfo.pickDate.Date,
                        Prepay_id      = result.prepay_id,
                        PickTime       = orderInfo.pickTime,
                        Status         = 0
                    };
                    var positions = new List <ZY_Booked_Position>();
                    orderInfo.Positions.ForEach(x =>
                    {
                        var p = new ZY_Booked_Position()
                        {
                            Id             = Guid.NewGuid(),
                            CustomerOpenId = orderInfo.CustomerOpenId,
                            OrderDate      = orderInfo.pickDate.Date,
                            DeskId         = orderInfo.DeskId,
                            Position       = x,
                            Status         = "1",
                            OrderId        = order.OrderId
                        };
                        positions.Add(p);
                    });
                    uow.Repository <ZY_Order>().Insert(order);
                    uow.Repository <ZY_Booked_Position>().InsertRange(positions);
                    uow.Save();
                    result.Success = true;
                    result.Message = string.Format("下单成功"); //todo message 优化
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = "失败啦";
            }
            return(result);
        }
示例#15
0
        public bool IsEquivalentTo(Selection selection, bool checkTags)
        {
            if (selection == null)
            {
                return(false);
            }

            if (selection.Id != Id)
            {
                return(false);
            }

            if (checkTags)
            {
                if (selection.TagsCount != TagsCount)
                {
                    return(false);
                }


                if (selection.TagKeys.Any(tag => !HasTag(tag) || GetTagValue(tag) != selection.GetTagValue(tag)))
                {
                    return(false);
                }

                // if we are here, there is no difference between the stored tags
                // and those contained within the selection object...
                // we can then proceed to check the selection's fields
                // Note that Selection.Name is a shortcut for Selection.GetTagValue("name")

                // as Result and PlaceResult are only present when dealing with full snapshots
                // we only check these properties if checkTags is true

                if (selection.Result != null)
                {
                    if (Result == null)
                    {
                        return(false);
                    }

                    if (!Result.IsEquivalentTo(selection.Result))
                    {
                        return(false);
                    }
                }

                if (selection.PlaceResult != null)
                {
                    if (PlaceResult == null)
                    {
                        return(false);
                    }

                    if (!PlaceResult.IsEquivalentTo(selection.PlaceResult))
                    {
                        return(false);
                    }
                }
            }

            var result = Price == selection.Price &&
                         Status == selection.Status &&
                         Tradability == selection.Tradable;


            if (IsRollingSelection)
            {
                return(result &= Line == ((RollingSelection)selection).Line);
            }

            return(result);
        }
示例#16
0
    public void GenerateMap(ref int[] map, BaseMapContext mapGenContext)
    {
        var context = (Room7DRLGeneratorContext)mapGenContext;

        context.Monsters = new List <MonsterSpawnData>();
        context.Traps    = new List <TrapSpawn>();
        context.Blocks   = new List <BlockSpawn>();

        var genData = (Room7DRLGeneratorData)mapGenContext.GeneratorData;

        if (genData.IsSeeded)
        {
            URandom.state = JsonUtility.FromJson <URandom.State>(genData.Seed);
        }
        else
        {
            Debug.Log("Current state: " + JsonUtility.ToJson(URandom.state));
        }

        var mapAux = new int[genData.MapSize.x, genData.MapSize.y];

        mapAux.Fill(genData.NoTile);

        var rooms = new List <Room7DRL>();

        var first = GenerateRoom(genData, rooms);

        first.coords = new Vector2Int()
        {
            x = (genData.MapSize.x - first.size.x) / 2 - 1,
            y = (genData.MapSize.y - first.size.y) / 2 - 1
        };

        AddRoom(rooms, genData, ref mapAux, first);
        for (int i = 0; rooms.Count < genData.NumRooms && i < genData.BuildAttempts; ++i)
        {
            var         next = GenerateRoom(genData, rooms);
            PlaceResult p    = PlaceRoom(genData.MapSize, genData, ref mapAux, rooms, next);
            if (p != null)
            {
                AddRoom(rooms, genData, ref mapAux, next);
                AddTunnel(p.wallTile, p.direction, p.length, genData.GroundTile, ref mapAux);
                if (rooms.Count >= genData.NumRooms)
                {
                    break;
                }
            }
        }

        List <Vector2Int> offsets = new List <Vector2Int>();

        for (int i = 0; i < first.size.x; ++i)
        {
            for (int j = 0; j < first.size.y; ++j)
            {
                if (first.tiles[i, j] == genData.GroundTile)
                {
                    offsets.Add(new Vector2Int(i, j));
                }
            }
        }
        if (offsets.Count == 0)
        {
            context.PlayerStart = first.coords;
        }
        else
        {
            context.PlayerStart = first.coords + offsets[URandom.Range(0, offsets.Count)];
        }


        //if(genData.IncludeShortcuts)
        //{
        //    AddShortcuts(ref mapAux, genData.MapSize);
        //}
        GeneratorUtils.PlaceWalls(genData.WallTile, genData.GroundTile, genData.NoTile, ref mapAux);
        GeneratorUtils.ConvertGrid(mapAux, out map);
    }
示例#17
0
        public static void Main()
        {
            var game = new GameWorkFlow();

            do
            {
                players = new Player[2];
                ConsoleIO.Clear();
                ConsoleIO.Display("Welcome to Tic-Tac-Toe!");
                Player player1 = new Player(ConsoleIO.PromptMsg("Player 1, please enter your name"), "X");
                ConsoleIO.Display($"Hello, {player1.Name}!  You will be X.");
                Player player2 = new Player(ConsoleIO.PromptMsg("Player 2, please enter your name"), "O");
                ConsoleIO.Display($"Hello, {player2.Name}!  You will be O.");
                ConsoleIO.Display("Press any key to start!");
                Console.ReadKey();
                players[0] = player1;
                players[1] = player2;
                Board  Board1 = new Board();
                Player currentPlayer;
                ConsoleIO.Clear();
                ConsoleIO.Display(Board1.printBoard());
                for (int i = 1; i < 10; i++)
                {
                    if (i % 2 != 0)
                    {
                        ConsoleIO.Display($"{player1.Name}, it is your turn.  Please pick a space.");
                        currentPlayer = player1;
                    }
                    else
                    {
                        ConsoleIO.Display($"{player2.Name}, it is your turn.  Please pick a space.");
                        currentPlayer = player2;
                    }


                    PlaceResult result = PlaceResult.Invalid;
                    do
                    {
                        ConsoleIO.Clear();
                        ConsoleIO.Display(Board1.printBoard());
                        int slot = ConsoleIO.PromptInt($"{currentPlayer.Name}, please pick a space!");
                        slot--;
                        result = Board1.PlaceMark(slot, currentPlayer.Mark);
                        if (result == PlaceResult.Win || result == PlaceResult.Tie)
                        {
                            break;
                        }
                    }while (result != PlaceResult.Ok);

                    if (result == PlaceResult.Win)
                    {
                        ConsoleIO.Display($"{currentPlayer.Name} is the Winner!");
                        break;
                    }
                    if (result == PlaceResult.Tie)
                    {
                        ConsoleIO.Display("Tough luck!  It's a tie!");
                        break;
                    }
                }
            } while (ConsoleIO.PromptMsg("Would you like to play again?  Y/N").ToUpper() == "Y");
        }
示例#18
0
        public void HandleMessage(SocketMessage message)
        {
            string content = message.Content.ToLower();

            string[] args        = content.Split(" ");
            int[]    numbersArgs = new int[args.Length];

            for (int i = 0; i < args.Length; i++)
            {
                int.TryParse(args[i], out int number);
                numbersArgs[i] = number;
            }

            if (args.Length > 0)
            {
                switch (args[0])
                {
                case "mine":
                    if (args.Length == 5)
                    {
                        if (args[1] == "init")
                        {
                            board = new Board(numbersArgs[2], numbersArgs[3], numbersArgs[4]);

                            message.Channel.SendMessageAsync(PrintBoard());
                        }
                    }
                    break;

                case "flag":
                    if (args.Length == 3)
                    {
                        if (board == null)
                        {
                            message.Channel.SendMessageAsync("There is no board for this channel! Initialize with `mine init WIDTH HEIGHT MINES`");
                        }
                        else
                        {
                            board.Flag(numbersArgs[1] - 1, numbersArgs[2] - 1);

                            message.Channel.SendMessageAsync(PrintBoard());
                        }
                    }
                    break;

                case "sweep":
                case "clear":
                    if (args.Length == 3)
                    {
                        if (board == null)
                        {
                            message.Channel.SendMessageAsync("There is no board for this channel! Initialize with `mine init WIDTH HEIGHT MINES`");
                        }
                        else
                        {
                            PlaceResult result = board.Clear(numbersArgs[1] - 1, numbersArgs[2] - 1);

                            string reply = "";

                            if (result == PlaceResult.Win)
                            {
                                reply = "You win!\n";
                            }
                            else if (result == PlaceResult.Loss)
                            {
                                reply = "You lose!\n";
                            }
                            else if (result == PlaceResult.Invalid)
                            {
                                reply = "Invalid placement!";
                                break;
                            }

                            message.Channel.SendMessageAsync(reply + PrintBoard());
                        }
                    }
                    break;
                }
            }
        }
示例#19
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (turnPhase == 1 || turnPhase == 3)
            {
                nextPhase();
            }
            else
            {
                // So much inner looping and duplicate code but also can't be bothered to refactor to make it clean. <Insert Shrug Emoji>
                Vector3 clickPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                for (uint i = 0; i < sideSize; i++)
                {
                    for (uint j = 0; j < sideSize; j++)
                    {
                        Collider2D cellCollider = cells[i, j].GetComponent <Collider2D>();
                        if (cellCollider.OverlapPoint(clickPoint))
                        {
                            // Probably this click detection should be replaced with something called the Unity Events System, but meh.
                            // Debug.Log("This one was clicked! " + i + ", " + j);
                            Position cellPosition = new Position(i, j);
                            if (turnPhase == 0 && gameState.IsValidMove(PlayerColor.BLUE, cellPosition))
                            {
                                // Debug.Log(cellPosition + " placing a tendril");
                                PlaceResult result = gameState.PlaceTendril(PlayerColor.BLUE, cellPosition);
                                cells[i, j].GetComponent <CellScript>().color   = CellScript.Color.Blue;
                                cells[i, j].GetComponent <CellScript>().content = CellScript.Content.Tendril;
                                switch (result)
                                {
                                case PlaceResult.TENDRIL_PLACED:
                                    nextPhase();
                                    break;

                                case PlaceResult.DESTROYED_TENDRIL:
                                    //TODO: Reset cut-off cells.
                                    break;

                                case PlaceResult.DESTROYED_CORTEX:
                                    //TODO: You win!
                                    break;

                                default:
                                    Debug.Log("Uh oh something is wrong " + result);
                                    break;
                                }
                            }
                            if (turnPhase == 2 && gameState.IsValidMove(PlayerColor.RED, cellPosition))
                            {
                                // Debug.Log(cellPosition + " placing a tendril");
                                PlaceResult result = gameState.PlaceTendril(PlayerColor.RED, cellPosition);
                                cells[i, j].GetComponent <CellScript>().color   = CellScript.Color.Red;
                                cells[i, j].GetComponent <CellScript>().content = CellScript.Content.Tendril;
                                switch (result)
                                {
                                case PlaceResult.TENDRIL_PLACED:
                                    nextPhase();
                                    break;

                                case PlaceResult.DESTROYED_TENDRIL:
                                    //TODO: Reset cut-off cells.
                                    break;

                                case PlaceResult.DESTROYED_CORTEX:
                                    //TODO: You win!
                                    break;

                                default:
                                    Debug.Log("Uh oh something is wrong " + result);
                                    break;
                                }
                            }

                            break; //Only breaks out of inner loop. Probably extract to function and return instead. Also holy moly nested duplicated garbo.
                        }
                    }
                }
            }
        }
    }
示例#20
0
        public static PlaceResult PlaceFromExportBin(Household household, ExportBinContents exportBinItem, Lot lot, PlaceAction action, bool buyFurnished, GetLotCost onLotCost, ref Sim newActiveSim)
        {
            if (household == null)
            {
                return(PlaceResult.InvalidBinHousehold);
            }
            else if (lot == null)
            {
                return(PlaceResult.InvalidLot);
            }
            else if (exportBinItem == null)
            {
                return(PlaceResult.ContentFailure);
            }

            bool flag = exportBinItem.IsLoaded();

            if (!flag)
            {
                ExportBinContentsEx.Import(exportBinItem, false);
            }

            PlaceResult contentFailure = PlaceResult.ContentFailure;

            if (household != null)
            {
                if (((action & PlaceAction.PlaceAndPay) != PlaceAction.PlaceOnly) && !PayForLot(household, lot, buyFurnished, onLotCost))
                {
                    if (!flag)
                    {
                        ExportBinContentsEx.Flush(exportBinItem);
                    }
                    Household.CleanupOldIdToNewSimDescriptionMap();
                    return(PlaceResult.InsufficientFunds);
                }

                if ((!buyFurnished) && (!lot.IsApartmentLot))
                {
                    lot.MakeLotUnfurnished();
                    Common.Sleep();
                    lot.UpdateCachedValues();
                }

                CreateActors(household, lot, false);
                CreateInventories(household, exportBinItem.HouseholdContents, exportBinItem.IndexMap);
                Common.Sleep();
                BinCommon.UpdateImportedUrnstones(household, lot);
                household.PostImport();

                if ((action & PlaceAction.MoveIn) != PlaceAction.PlaceOnly)
                {
                    BinCommon.MoveIn(household, lot);
                }
                if ((action & PlaceAction.Activate) != PlaceAction.PlaceOnly)
                {
                    newActiveSim = BinCommon.ActivateSim(exportBinItem.Household, lot);
                }

                ThumbnailManager.GenerateHouseholdThumbnail(household.HouseholdId, household.HouseholdId, ThumbnailSizeMask.Large | ThumbnailSizeMask.Medium);
                contentFailure = PlaceResult.Success;
            }

            if (!flag)
            {
                ExportBinContentsEx.Flush(exportBinItem);
            }

            return(contentFailure);
        }
示例#21
0
        public static PlaceResult MergeHouseholdFromExportBin(ExportBinContents exportBinItem, Lot lot, bool showConfirmDialog, bool allowOverstuff)
        {
            try
            {
                if (exportBinItem == null)
                {
                    return(PlaceResult.ContentFailure);
                }

                bool flag = exportBinItem.IsLoaded();
                if (!flag)
                {
                    ExportBinContentsEx.Import(exportBinItem, false);
                }

                PlaceResult householdPresent = PlaceResult.HouseholdPresent;
                Household   household        = exportBinItem.Household;
                Household   otherHouse       = lot.Household;
                if (household == null)
                {
                    householdPresent = PlaceResult.InvalidBinHousehold;
                }

                if (lot == null)
                {
                    householdPresent = PlaceResult.InvalidLot;
                }

                if (exportBinItem == null)
                {
                    householdPresent = PlaceResult.ContentFailure;
                }

                try
                {
                    try
                    {
                        if (((household != null) && (householdPresent == PlaceResult.HouseholdPresent)) && (otherHouse != null))
                        {
                            // Custom
                            if ((!allowOverstuff) && (!household.CanMergeWithHousehold(otherHouse, false)))
                            {
                                SimpleMessageDialog.Show(Common.LocalizeEAString("Ui/Caption/GameEntry/EditTown:MergeWarning"), Common.LocalizeEAString("Ui/Caption/MovingDialog:TooManySims"));
                            }
                            // Custom
                            else if ((!allowOverstuff) && (!household.CanMergeWithHousehold(otherHouse, true)))
                            {
                                SimpleMessageDialog.Show(Common.LocalizeEAString("Ui/Caption/GameEntry/EditTown:MergeWarning"), Common.LocalizeEAString("Ui/Caption/MovingDialog:TooManySims_Pregnant"));
                            }
                            else if (!showConfirmDialog || PlayFlowConfirmMergePetHousehold.Show(BinCommon.CreateInWorldBinInfo(lot.LotId), exportBinItem.BinInfo))
                            {
                                ProgressDialog.Show(Common.LocalizeEAString("Ui/Caption/Global:Processing"));

                                otherHouse.ModifyFamilyFunds(household.FamilyFunds);

                                List <SimDescription> simDescs = new List <SimDescription>();
                                foreach (SimDescription description in household.AllSimDescriptions)
                                {
                                    simDescs.Add(description);
                                }

                                CreateActors(simDescs, null, false);
                                BinCommon.CreateFamilyInventories(household, exportBinItem.HouseholdContents);
                                BinCommon.MoveInventoryInto(household, otherHouse);
                                household.PostImport();

                                List <Sim> sims = new List <Sim>();
                                foreach (SimDescription description2 in simDescs)
                                {
                                    otherHouse.AddSim(description2.CreatedSim);
                                    sims.Add(description2.CreatedSim);
                                }

                                otherHouse.AddWardrobeToWardrobe(household.Wardrobe);
                                otherHouse.AddServiceUniforms(household.ServiceUniforms);
                                CreateSimInventories(simDescs, exportBinItem.HouseholdContents, exportBinItem.IndexMap);
                                BinCommon.PlaceSims(sims, lot);
                                ThumbnailManager.GenerateHouseholdThumbnail(otherHouse.HouseholdId, otherHouse.HouseholdId, ThumbnailSizeMask.Large | ThumbnailSizeMask.Medium);
                                (Sims3.UI.Responder.Instance.EditTownModel as EditTownModel).DirtyWorldBins();
                                Bin.Singleton.FireContentsChanged();
                            }
                        }

                        Household.CleanupOldIdToNewSimDescriptionMap();
                        if (!flag)
                        {
                            ExportBinContentsEx.Flush(exportBinItem);
                        }
                    }
                    finally
                    {
                        ProgressDialog.Close();
                    }
                }
                catch (ExecutionEngineException)
                { }

                return(householdPresent);
            }
            catch (Exception e)
            {
                Common.Exception("MergeHouseholdFromExportBin", e);
                return(PlaceResult.ContentFailure);
            }
        }
示例#22
0
        private CylinderPlaceArgs ConstructCylinderPlaceArgs(CylinderController currentCylinder, PlaceResult placeResult)
        {
            CylinderPlaceArgs placeArgs = new CylinderPlaceArgs
            {
                Cylinder    = currentCylinder,
                PlaceResult = placeResult
            };

            return(placeArgs);
        }
示例#23
0
 public static GoogleGeocodeResponse VerifyAddress(PlaceResult place)
 {
     return VerifyAddress(place.formatted_address);
 }