当前位置: 首页>>代码示例>>C#>>正文


C# CharData.SpendGold方法代码示例

本文整理汇总了C#中MUDEngine.CharData.SpendGold方法的典型用法代码示例。如果您正苦于以下问题:C# CharData.SpendGold方法的具体用法?C# CharData.SpendGold怎么用?C# CharData.SpendGold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MUDEngine.CharData的用法示例。


在下文中一共展示了CharData.SpendGold方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GuildDonate

        public static void GuildDonate(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Coins coin = new Coins();
            int coinage;
            bool success = false;

            if (ch.IsNPC())
            {
                return;
            }

            Guild guild = ((PC)ch).GuildMembership;
            if (guild == null)
            {
                ch.SendText("You're not in a guild!\r\n");
                return;
            }
            if (str.Length == 0)
            {
                ch.SendText("Deposit what?\r\n");
                return;
            }
            if (!coin.FillFromString(str, ch))
            {
                ch.SendText("&+LSyntax: &+RSoc deposit &n&+r<&+L# of coins&n&+r> <&+Lcoin type&n&+r>&n\r\n");
                return;
            }
            if (coin.Copper == 0 && coin.Silver == 0 && coin.Gold == 0 && coin.Platinum == 0)
            {
                ch.SendText("You have none of that type of &+Lcoin&n yet.\r\n");
                return;
            }
            for (coinage = 0; coinage < 4; coinage++)
            {
                switch (coinage)
                {
                    case 0: //copper
                        if (coin.Copper < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Copper > ch.GetCopper())
                        {
                            ch.SendText("You don't have that much &+ycopper&n coin!\r\n");
                            continue;
                        }
                        if (coin.Copper == 0)
                            continue;
                        ch.SpendCopper(coin.Copper);
                        success = true;
                        break;
                    case 1: //silver
                        if (coin.Silver < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Silver > ch.GetSilver())
                        {
                            ch.SendText("You don't have that much &+wsilver&n coin!\r\n");
                            continue;
                        }
                        if (coin.Silver == 0)
                            continue;
                        ch.SpendSilver(coin.Silver);
                        success = true;
                        break;

                    case 2: //gold
                        if (coin.Gold < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Gold > ch.GetGold())
                        {
                            ch.SendText("You don't have that much &+Ygold&n coin!\r\n");
                            continue;
                        }
                        if (coin.Gold == 0)
                            continue;
                        ch.SpendGold(coin.Gold);
                        success = true;
                        break;
                    case 3: //platinum
                        if (coin.Platinum < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Platinum > ch.GetPlatinum())
                        {
                            ch.SendText("You don't have that much &+Wplatinum&n coin!\r\n");
                            continue;
                        }
                        if (coin.Platinum == 0)
                            continue;
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例2: Give

        /// <summary>
        /// Give an item to someone.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Give(CharData ch, string[] str)
        {
            if( ch == null ) return;

            CharData victim;
            string arg1 = String.Empty;
            string arg2 = String.Empty;

            if (String.IsNullOrEmpty(arg1) || String.IsNullOrEmpty(arg2))
            {
                ch.SendText("Give what to whom?\r\n");
                return;
            }

            if (MUDString.IsNumber(arg1))
            {
                /* 'give NNNN coins victim' */
                string buf;
                string arg3 = String.Empty;
                int amount;

                Int32.TryParse(arg1, out amount);
                if (amount <= 0)
                {
                    ch.SendText("Sorry, you can't do that.\r\n");
                    return;
                }

                if (String.IsNullOrEmpty(arg3))
                {
                    ch.SendText("Give what to whom?\r\n");
                    return;
                }

                victim = ch.GetCharRoom(arg3);
                if (victim == null)
                {
                    ch.SendText("They aren't here.\r\n");
                    return;
                }

                if (!MUDString.IsPrefixOf(arg2, "copper"))
                {
                    if (ch.GetCopper() < amount)
                    {
                        ch.SendText("You haven't got that many &+ycopper&n coins.\r\n");
                        return;
                    }
                    ch.SpendCopper(amount);
                    SocketConnection.Act("You give $N&n some &+ycopper&n.", ch, null, victim, SocketConnection.MessageTarget.character);
                    buf = String.Format("$n&n gives you {0} &+ycopper&n.", amount);
                    SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$n&n gives $N&n some &+ycopper&n.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim);
                    //            prog_bribe_trigger( victim, ch, amount );
                    if (!ch.CheckQuest(victim, null, amount))
                    {
                        victim.ReceiveCopper(amount);
                    }
                    // Prevent money duping
                    CharData.SavePlayer(ch);
                    CharData.SavePlayer(victim);
                    return;
                }
                if (!MUDString.IsPrefixOf(arg2, "silver"))
                {
                    if (ch.GetSilver() < amount)
                    {
                        ch.SendText("You haven't got that many silver coins.\r\n");
                        return;
                    }
                    ch.SpendSilver(amount);
                    SocketConnection.Act("You give $N&n some silver.", ch, null, victim, SocketConnection.MessageTarget.character);
                    buf = String.Format("$n&n gives you {0} silver.", amount);
                    SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$n&n gives $N&n some silver.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim);
                    //            prog_bribe_trigger( victim, ch, amount * 10);
                    if (!ch.CheckQuest(victim, null, (amount * 10)))
                        victim.ReceiveSilver(amount);
                    // Prevent money duping
                    CharData.SavePlayer(ch);
                    CharData.SavePlayer(victim);
                    return;
                }
                if (!MUDString.IsPrefixOf(arg2, "gold"))
                {
                    if (ch.GetGold() < amount)
                    {
                        ch.SendText("You haven't got that many &+Ygold&n coins.\r\n");
                        return;
                    }
                    ch.SpendGold(amount);
                    SocketConnection.Act("You give $N&n some &+Ygold&n.", ch, null, victim, SocketConnection.MessageTarget.character);
                    buf = String.Format("$n&n gives you {0} &+Ygold&n.", amount);
                    SocketConnection.Act(buf, ch, null, victim, SocketConnection.MessageTarget.victim);
                    SocketConnection.Act("$n&n gives $N&n some &+Ygold&n.", ch, null, victim, SocketConnection.MessageTarget.everyone_but_victim);
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例3: Deposit

        /// <summary>
        /// Put coins into a bank account.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Deposit(CharData ch, string[] str)
        {
            if( ch == null ) return;

            int coinage;
            bool success = false;
            Coins coin = new Coins();

            if (ch.IsNPC())
            {
                ch.SendText("NPCs do not have bank accounts!\r\n");
                return;
            }

            if (!ch.InRoom || !ch.InRoom.HasFlag(RoomTemplate.ROOM_BANK))
            {
                ch.SendText("You're not in a bank!\r\n");
                return;
            }

            if (str.Length == 0)
            {
                ch.SendText("Deposit what?\r\n");
                return;
            }
            if (!coin.FillFromString(str, ch))
            {
                ch.SendText("&+LSyntax:  &+RDeposit &n&+r<&+L# of coins&n&+r> <&+Lcoin type&n&+r>&n\r\n");
                return;
            }
            if (coin.Copper == 0 && coin.Silver == 0 && coin.Gold == 0 && coin.Platinum == 0)
            {
                ch.SendText("You have none of that type of &+Lcoin&n yet.\r\n");
                return;
            }
            for (coinage = 0; coinage < 4; coinage++)
            {
                switch (coinage)
                {
                    case 0: //copper
                        if (coin.Copper < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Copper > ch.GetCopper())
                        {
                            ch.SendText("You don't have that much &+ycopper&n coin!\r\n");
                            continue;
                        }
                        if (coin.Copper == 0)
                            continue;
                        ch.SpendCopper(coin.Copper);
                        ((PC)ch).Bank.Copper += coin.Copper;
                        success = true;
                        break;
                    case 1: //silver
                        if (coin.Silver < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Silver > ch.GetSilver())
                        {
                            ch.SendText("You don't have that much &+wsilver&n coin!\r\n");
                            continue;
                        }
                        if (coin.Silver == 0)
                            continue;
                        ch.SpendSilver(coin.Silver);
                        ((PC)ch).Bank.Silver += coin.Silver;
                        success = true;
                        break;
                    case 2: //gold
                        if (coin.Gold < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
                        }
                        if (coin.Gold > ch.GetGold())
                        {
                            ch.SendText("You don't have that much &+Ygold&n coin!\r\n");
                            continue;
                        }
                        if (coin.Gold == 0)
                            continue;
                        ch.SpendGold(coin.Gold);
                        ((PC)ch).Bank.Gold += coin.Gold;
                        success = true;
                        break;
                    case 3: //platinum
                        if (coin.Platinum < 0)
                        {
                            ch.SendText("You can't deposit a debt!\r\n");
                            continue;
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例4: Drop

        /// <summary>
        /// Drop an item.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Drop(CharData ch, string[] str)
        {
            if( ch == null ) return;

            Object cash;

            if (ch.IsAffected( Affect.AFFECT_HOLD) || ch.IsAffected( Affect.AFFECT_MINOR_PARA))
            {
                ch.SendText("You muscles won't respond!\r\n");
                return;
            }

            if (str.Length == 0)
            {
                ch.SendText("Drop what?\r\n");
                return;
            }

            if (MUDString.IsNumber(str[0]))
            {
                /* 'drop NNNN coins' */
                int amount;

                Int32.TryParse(str[0], out amount);

                if (amount <= 0)
                {
                    ch.SendText("Sorry, you can't do that.\r\n");
                    return;
                }

                if (str.Length < 2)
                {
                    ch.SendText("That's fine, but *what* do you want to drop?\r\n");
                    return;
                }

                if ("copper".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase))
                {
                    if (ch.GetCopper() < amount)
                    {
                        ch.SendText("You haven't got that many &n&+ycopper&n coins.\r\n");
                        return;
                    }
                    ch.SpendCopper(amount);
                    cash = Object.CreateMoney(amount, 0, 0, 0);
                    cash.AddToRoom(ch.InRoom);
                    cash.FlyLevel = ch.FlightLevel;
                }
                else if ("silver".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase))
                {
                    if (ch.GetSilver() < amount)
                    {
                        ch.SendText("You haven't got that many &n&+wsilver&n coins.\r\n");
                        return;
                    }
                    ch.SpendSilver(amount);
                    (Object.CreateMoney(0, amount, 0, 0)).AddToRoom(ch.InRoom);
                }
                else if ("gold".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase))
                {
                    if (ch.GetGold() < amount)
                    {
                        ch.SendText("You haven't got that many &+Ygold&n coins.\r\n");
                        return;
                    }
                    ch.SpendGold(amount);
                    (Object.CreateMoney(0, 0, amount, 0)).AddToRoom(ch.InRoom);
                }
                else if ("platinum".StartsWith(str[1], StringComparison.CurrentCultureIgnoreCase))
                {
                    if (ch.GetPlatinum() < amount)
                    {
                        ch.SendText("You haven't got that many &+Wplatinum&n coins.\r\n");
                        return;
                    }
                    ch.SpendPlatinum(amount);
                    (Object.CreateMoney(0, 0, 0, amount)).AddToRoom(ch.InRoom);
                }
                else
                {
                    ch.SendText("They haven't minted that type of &+Lcoin&n yet.\r\n");
                    return;
                }

                /* Disabled merging of coin types.  This should eventually be re-enabled
                for ( obj = ch.in_room.contents; obj; obj = obj_next )
                {
                obj_next = obj.next_content;

                switch ( obj.pIndexData.vnum )
                {
                case StaticObjects.OBJECT_NUMBER_MONEY_ONE:
                amount += 1;
                obj.ExtractFromWorld();;
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例5: Split


//.........这里部分代码省略.........
                        {
                            share = coin.Silver / members;
                            extra = coin.Silver % members;
                            if (share == 0)
                                continue;
                            ch.SpendSilver(coin.Silver);
                            buf = String.Format(
                                      "You split {0} &+wsilver&n.  Your share is {1} coins.\r\n", coin.Silver, share + extra);
                            ch.SendText(buf);
                            buf = String.Format("$n splits some &+wsilver&n.  Your share is {0} coins.",
                                      share);
                            foreach (CharData groupChar in ch.InRoom.People)
                            {
                                if (groupChar != ch && groupChar.IsSameGroup(ch))
                                {
                                    SocketConnection.Act(buf, ch, null, groupChar, SocketConnection.MessageTarget.victim);
                                    groupChar.ReceiveSilver(share);
                                }
                                else if (groupChar == ch)
                                {
                                    groupChar.ReceiveSilver(share + extra);
                                }
                            }
                            success = true;
                            continue;
                        }
                        else
                            ch.SendText("You don't have that much &+wsilver&n coin!\r\n");
                        break;
                    case 2: //gold
                        if (coin.Gold <= 0)
                            continue; //quietly ignore errors
                        if (coin.Gold <= ch.GetGold())
                        {
                            share = coin.Gold / members;
                            extra = coin.Gold % members;
                            if (share == 0)
                                continue;
                            ch.SpendGold(coin.Gold);
                            buf = String.Format("You split {0} &+Ygold&n.  Your share is {1} coins.\r\n", coin.Gold, share + extra);
                            ch.SendText(buf);
                            buf = String.Format("$n splits some &+Ygold&n.  Your share is {0} coins.", share);
                            foreach (CharData groupChar in ch.InRoom.People)
                            {
                                if (groupChar != ch && groupChar.IsSameGroup(ch))
                                {
                                    SocketConnection.Act(buf, ch, null, groupChar, SocketConnection.MessageTarget.victim);
                                    groupChar.ReceiveGold(share);
                                }
                                else if (groupChar == ch)
                                {
                                    groupChar.ReceiveGold(share + extra);
                                }
                            }
                            success = true;
                            continue;
                        }
                        else
                        {
                            ch.SendText("You don't have that much &+Ygold&n coin!\r\n");
                        }
                        break;
                    case 3: //platinum
                        if (coin.Platinum <= 0)
                            continue; //quietly ignore errors
                        if (coin.Platinum <= ch.GetPlatinum())
                        {
                            share = coin.Platinum / members;
                            extra = coin.Platinum % members;
                            if (share == 0)
                                continue;
                            ch.SpendPlatinum(coin.Platinum);
                            buf = String.Format("You split {0} &+Wplatinum&n.  Your share is {1} coins.\r\n", coin.Platinum, share + extra);
                            ch.SendText(buf);
                            buf = String.Format("$n splits some &+Wplatinum&n.  Your share is {0} coins.", share);
                            foreach (CharData groupChar in ch.InRoom.People)
                            {
                                if (groupChar != ch && groupChar.IsSameGroup(ch))
                                {
                                    SocketConnection.Act(buf, ch, null, groupChar, SocketConnection.MessageTarget.victim);
                                    groupChar.ReceivePlatinum(share);
                                }
                                else if (groupChar == ch)
                                {
                                    groupChar.ReceivePlatinum(share + extra);
                                }
                            }
                            success = true;
                            continue;
                        }
                        ch.SendText("You don't have that much &+Wplatinum&n coin!\r\n");
                        break;
                } //end switch
            } //end for
            if (!success)
            {
                ch.SendText("You didn't seem to split anything.\r\n");
            }
            return;
        }
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs


注:本文中的MUDEngine.CharData.SpendGold方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。