コード例 #1
0
        private static bool PurchaseFurnishingItem(GameSession session, FurnishingShopMetadata shop) // bool it
        {
            switch (shop.FurnishingTokenType)
            {
            case 1:     // meso
                return(session.Player.Wallet.Meso.Modify(-shop.Price));

            case 3:     // meret
                return(session.Player.Wallet.RemoveMerets(shop.Price));

            default:
                session.SendNotice($"Unknown currency: {shop.FurnishingTokenType}");
                break;
            }
            return(false);
        }
コード例 #2
0
        private static void HandleAddFurnishing(GameSession session, PacketReader packet)
        {
            CoordB coord    = packet.Read <CoordB>();
            byte   padding  = packet.ReadByte();
            int    itemId   = packet.ReadInt();
            long   itemUid  = packet.ReadLong();
            byte   padding2 = packet.ReadByte();
            CoordF rotation = packet.Read <CoordF>();

            int plotNumber = MapMetadataStorage.GetPlotNumber(session.Player.MapId, coord);

            if (plotNumber < 0)
            {
                return;
            }

            // TODO: Check if player has rights to this plot

            FurnishingShopMetadata shopMetadata = FurnishingShopMetadataStorage.GetMetadata(itemId);

            if (shopMetadata == null || !shopMetadata.Buyable)
            {
                return;
            }

            if (itemUid == 0) // player needs to purchase
            {
                if (!PurchaseFurnishingItem(session, shopMetadata))
                {
                    return;
                }


                Item item = new Item(itemId);

                //TODO: Add and remove appropriate item to warehouse inventory and furnishing inventory

                Cube cube = new Cube(item, plotNumber);

                IFieldObject <Cube> fieldCube = session.FieldManager.RequestFieldObject(cube);
                fieldCube.Coord    = coord.ToFloat();
                fieldCube.Rotation = rotation;
                session.FieldManager.AddCube(fieldCube, session.FieldPlayer);
            }
        }