コード例 #1
0
ファイル: WorldBuilding.cs プロジェクト: Delphi79/UO98-SVN
        public static bool ItemExistsAtExactLocation(ItemAndLocation itemAndLocation)
        {
            Location loc    = itemAndLocation.Location;
            int      itemid = itemAndLocation.ItemID;

            return(Server.getFirstObjectOftype(loc, itemid) != 0);
        }
コード例 #2
0
ファイル: WorldTests.cs プロジェクト: Delphi79/UO98-SVN
        public static bool Test_getNextObjectOftype()
        {
            ItemAndLocation itemandlocation = GetRandomItemAndLocation();

            StateBegin("getFirstObjectOftype");

            int serial_1 = CreateTestItemThenFind(itemandlocation);
            int serial_2 = CreateTestItemThenFind(itemandlocation);

            Assert(serial_1 != serial_2, "Both created items have same serial.");

            int serial_found1 = Server.getFirstObjectOftype(itemandlocation.Location, itemandlocation.ItemID);
            int serial_found2 = Server.getNextObjectOfType(itemandlocation.Location, itemandlocation.ItemID, serial_found1);

            Assert(serial_found1 != serial_found2, "Both found items have same serial.");

            List <int> found = new List <int>();

            found.Add(serial_found1);
            found.Add(serial_found2);

            Assert(
                found.Contains(serial_1) && found.Contains(serial_2),
                "Item And Location: {0} Both Items not found. expected:{1},{2} found:{3},{4}", itemandlocation, serial_1, serial_2, serial_found1, serial_found2);

            DeleteTestItems(serial_1, serial_2);

            return(StateResultFinal());
        }
コード例 #3
0
ファイル: Shrines.cs プロジェクト: WildGenie/UO98
            private              ItemAndLocation[] GetItems()
            {
                ItemAndLocation[] toReturn = new ItemAndLocation[2];
                switch (Type)
                {
                case AnkhType.NorthSouthBloody:
                    toReturn[0].ItemID   = 7773;
                    toReturn[1].ItemID   = 7772;
                    toReturn[0].Location = toReturn[1].Location = LeftStartPoint;
                    toReturn[1].Location.X++;
                    //toReturn[1].location.Y++;
                    break;

                case AnkhType.NorthSouth:
                    toReturn[0].ItemID   = 4;
                    toReturn[1].ItemID   = 5;
                    toReturn[0].Location = toReturn[1].Location = LeftStartPoint;
                    toReturn[1].Location.X++;
                    //toReturn[1].location.Y++;
                    break;

                default:
                    toReturn[0].ItemID   = 2;
                    toReturn[1].ItemID   = 3;
                    toReturn[0].Location = toReturn[1].Location = LeftStartPoint;
                    //toReturn[1].location.X++;
                    toReturn[1].Location.Y--;
                    break;
                }
                return(toReturn);
            }
コード例 #4
0
ファイル: BaseTestUtils.cs プロジェクト: WildGenie/UO98
        protected static ItemAndLocation GetRandomItemAndLocation()
        {
            ItemAndLocation itemandlocation = new ItemAndLocation();

            itemandlocation.ItemID   = GetRandomTestItem();
            itemandlocation.Location = GetRandomOceanTestLocation();
            return(itemandlocation);
        }
コード例 #5
0
        protected static void AddTeleporterScript(ref ItemAndLocation ItemAndLocation, string script)
        {
            string result = Builder.AddScriptToFirstItemAtLocation(ItemAndLocation, script);

            if (result != null && !result.StartsWith("Script already attached"))
            {
                Console.WriteLine("Teleporters Error: Failed to attach script {0} to teleporter @ {1} {2} {3} Message: {4}", script, ItemAndLocation.Location.X, ItemAndLocation.Location.Y, ItemAndLocation.Location.Z, result);
            }
        }
コード例 #6
0
 public TeleporterGeneric(Location worldLocation, string script, Location destination, TeleporterGraphic graphic = TeleporterGraphic.NoDraw)
 {
     ItemAndLocation = new ItemAndLocation()
     {
         Location = worldLocation,
         ItemID   = (ushort)graphic
     };
     Script      = script;
     Destination = destination;
 }
コード例 #7
0
            public void CreateAt(Location loc)
            {
                ItemAndLocation ItemAndLocation = new ItemAndLocation()
                {
                    Location = loc,
                    ItemID   = (ushort)Graphic
                };

                CreateTeleporterItem(ref ItemAndLocation);
                AddTeleporterScript(ref ItemAndLocation, Script);
            }
コード例 #8
0
ファイル: WorldBuilding.cs プロジェクト: Delphi79/UO98-SVN
        public static string AddScriptToFirstItemAtLocation(ItemAndLocation itemAndLocation, string script)
        {
            int serial = Server.getFirstObjectOftype(itemAndLocation.Location, itemAndLocation.ItemID);

            if (serial != 0)
            {
                return(Server.addScript(serial, script));
            }
            else
            {
                return("Item Not Found.");
            }
        }
コード例 #9
0
        public uint CreateItem(ItemAndLocation itemandlocation)
        {
            Serial serial = nextSerial++;

            ItemObject item = new ItemObject();

            item.ObjectType = itemandlocation.ItemID;
            item.Location   = itemandlocation.Location;
            item.Serial     = serial;

            WorldObjects.Add(serial, item);

            return(serial);
        }
コード例 #10
0
ファイル: WorldTests.cs プロジェクト: Delphi79/UO98-SVN
        public static bool Test_getFirstObjectOftype()
        {
            ItemAndLocation itemandlocation = GetRandomItemAndLocation();

            StateBegin("getFirstObjectOftype");

            int serial_expected = CreateTestItemThenFind(itemandlocation);

            int serial_found = Server.getFirstObjectOftype(itemandlocation.Location, itemandlocation.ItemID);

            Assert(serial_found == serial_expected, "Item And Location: {0} Serials don't match. found:{1}, expected:{2}", itemandlocation, serial_found, serial_expected);

            DeleteTestItem(serial_expected);

            return(StateResultFinal());
        }
コード例 #11
0
ファイル: WorldBuilding.cs プロジェクト: Delphi79/UO98-SVN
        public static int FindItemWithinZRangeAboveOrBelow(ItemAndLocation itemAndLocation, byte Zrange)
        {
            int serial = 0;

            sbyte zStart = (sbyte)Math.Max(itemAndLocation.Location.Z - Zrange, sbyte.MinValue);
            sbyte zEnd   = (sbyte)Math.Min(itemAndLocation.Location.Z + Zrange, sbyte.MaxValue);

            itemAndLocation.Location.Z = zStart;
            while (serial == 0 && itemAndLocation.Location.Z <= zEnd)
            {
                serial = SerialOfFirstExistingItemAtLocation(itemAndLocation);
                itemAndLocation.Location.Z += zRangeForItemLocationEqualityInCore;
            }

            return(serial);
        }
コード例 #12
0
ファイル: WorldBuilding.cs プロジェクト: Delphi79/UO98-SVN
        public static int SerialOfExistingItemAtLocation(ItemAndLocation itemAndLocation)
        {
            int serial = Server.getFirstObjectOftype(itemAndLocation.Location, itemAndLocation.ItemID);

            while (serial != 0)
            {
                Location locationOfFoundItem = Server.getLocation(serial);
                if (locationOfFoundItem == itemAndLocation.Location)
                {
                    break;
                }
                else
                {
                    serial = Server.getNextObjectOfType(itemAndLocation.Location, itemAndLocation.ItemID, serial);
                }
            }
            return(serial);
        }
コード例 #13
0
ファイル: Shrines.cs プロジェクト: WildGenie/UO98
            private void RemoveInvalidAnhkObjectsAtLocation(ItemAndLocation ankhPiece)
            {
                Location location         = ankhPiece.Location;
                int      ProperAnhkItemID = ankhPiece.ItemID;

                foreach (int id in AllAnhkItemIDs)
                {
                    if (id == ProperAnhkItemID)
                    {
                        continue;
                    }
                    int serial = Builder.SerialOfFirstExistingItemAtLocation(ankhPiece);
                    if (serial > 0)
                    {
                        Builder.DeleteItem(serial);
                    }
                }
            }
コード例 #14
0
ファイル: WorldBuilding.cs プロジェクト: Delphi79/UO98-SVN
        public static int FindExistingItemSerial(ItemAndLocation itemAndLocation)
        {
            int serial = 0;

            if (isPortcullis(itemAndLocation.ItemID))
            {
                serial = FindItemWithinZRangeAboveOrBelow(itemAndLocation, 40);
            }
            else if (isDoor(itemAndLocation.ItemID))
            {
                serial = FindAnyNearbyDoorWithExactHomeLocationOf(itemAndLocation.Location);
            }
            else
            {
                serial = SerialOfExistingItemAtLocation(itemAndLocation);
            }

            return(serial);
        }
コード例 #15
0
        protected static void SetTeleporterDest(ref ItemAndLocation ItemAndLocation, Location destination)
        {
            if (destination.Equals(Location.Zero))
            {
                Console.WriteLine("Teleporters Error: Tried to set location on teleporter @ {0} {1} {2} to ZERO", ItemAndLocation.Location.X, ItemAndLocation.Location.Y, ItemAndLocation.Location.Z);
                return;
            }

            int serial = Builder.SerialOfFirstExistingItemAtLocation(ItemAndLocation);

            if (serial > 0)
            {
                Server.setObjVar(serial, "dest", destination);
            }
            else
            {
                Console.WriteLine("Teleporters Error: Failed to set location on teleporter @ {0} {1} {2}", ItemAndLocation.Location.X, ItemAndLocation.Location.Y, ItemAndLocation.Location.Z);
            }
        }
コード例 #16
0
 protected static void CreateTeleporterItem(ref ItemAndLocation ItemAndLocation)
 {
     if (!Builder.ItemExistsAtExactLocation(ItemAndLocation))
     {
         if (Builder.TryCreateItem(ItemAndLocation))
         {
             created++;
         }
         else
         {
             Console.WriteLine("Teleporters Error: Failed to create teleporter @ {0} {1} {2}", ItemAndLocation.Location.X, ItemAndLocation.Location.Y, ItemAndLocation.Location.Z);
             failed++;
         }
     }
     else
     {
         existed++;
     }
 }
コード例 #17
0
ファイル: ObjectPropertyTests.cs プロジェクト: WildGenie/UO98
        public static bool Test_ObjProps_GetLocation()
        {
            int serial;

            StateBegin("Test_ObjProps_GetLocation");

            ItemAndLocation itemandlocation = GetRandomItemAndLocation();

            serial = CreateTestItemThenFind(itemandlocation);

            Item item;

            if (Assert(Server.TryFindObject(serial, out item), "Couldn't find item."))
            {
                AssertSame(itemandlocation.Location, Server.getLocation(serial));
            }

            DeleteTestItem(serial);

            return(StateResultFinal());
        }
コード例 #18
0
            static bool TryParseItemAndLocation(string[] itemAndLocationArray, out ItemAndLocation itemAndLocation)
            {
                ushort   id;
                Location loc;

                if (itemAndLocationArray.Length >= 4 &&
                    ushort.TryParse(itemAndLocationArray[0], out id) &&
                    short.TryParse(itemAndLocationArray[1], out loc.X) &&
                    short.TryParse(itemAndLocationArray[2], out loc.Y) &&
                    short.TryParse(itemAndLocationArray[3], out loc.Z))
                {
                    ItemAndLocation toReturn = new ItemAndLocation()
                    {
                        ItemID   = id,
                        Location = loc,
                    };
                    itemAndLocation = toReturn;
                    return(true);
                }
                itemAndLocation = new ItemAndLocation();
                return(false);
            }
コード例 #19
0
ファイル: BaseTestUtils.cs プロジェクト: WildGenie/UO98
        protected static int CreateTestItemThenFind(ItemAndLocation itemandlocation)
        {
            int      ItemID   = itemandlocation.ItemID;
            Location location = itemandlocation.Location;

            int serial = Server.createGlobalObjectAt(ItemID, location);

            if (Assert(serial > 0, "Failed to create Object. {0}", itemandlocation))
            {
                Item item;
                if (Assert(Server.TryFindObject(serial, out item), "Created Item not found in world. serial:{0}", serial))
                {
                    Assert(item.ObjectType == ItemID, "Created Item not of correct ObjectType. expected:({0}) actual:({1})", ItemID, item.ObjectType);

                    Assert(item.Location == location, "Created Item not in correct location. expected:({0}) actual:({1})", location, item.Location);
                }
            }

            StateAddObject(serial);

            return(serial);
        }
コード例 #20
0
ファイル: WorldBuilding.cs プロジェクト: Delphi79/UO98-SVN
 public static int SerialOfFirstExistingItemAtLocation(ItemAndLocation itemAndLocation)
 {
     return(Server.getFirstObjectOftype(itemAndLocation.Location, itemAndLocation.ItemID));
 }
コード例 #21
0
ファイル: WorldBuilding.cs プロジェクト: Delphi79/UO98-SVN
        public static bool TryCreateItem(ItemAndLocation itemAndLocation)
        {
            int serial = TryCreateItemReturnSerial(itemAndLocation);

            return(serial != 0);
        }
コード例 #22
0
ファイル: WorldBuilding.cs プロジェクト: Delphi79/UO98-SVN
 public static int TryCreateItemReturnSerial(ItemAndLocation itemAndLocation)
 {
     return(Server.createGlobalObjectAt(itemAndLocation.ItemID, itemAndLocation.Location));
 }