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


C# CharData.ReceiveGold方法代码示例

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


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

示例1: GuildWithdraw

        /// <summary>
        /// Take money from your guild bank account.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void GuildWithdraw(CharData ch, string[] str)
        {
            if( ch == null ) return;

            string arg = String.Empty;

            if (ch.IsNPC())
                return;

            Guild guild = ((PC)ch).GuildMembership;
            if (guild == null)
            {
                ch.SendText("You're not in a guild!\r\n");
                return;
            }

            if (((PC)ch).GuildRank < Guild.Rank.deputy)
            {
                ch.SendText("You'll have to be promoted before you can withdraw from the guild.\r\n");
                return;
            }

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

            if (MUDString.IsNumber(str[0]))
            {
                int amount;

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

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

                if ("copper".StartsWith(arg, StringComparison.CurrentCultureIgnoreCase))
                {
                    if (guild.GuildBankAccount.Copper < amount)
                    {
                        ch.SendText("The guild doesen't have that many &n&+ycopper&n coins.\r\n");
                        return;
                    }
                    ch.ReceiveCopper(amount);
                    guild.GuildBankAccount.Copper -= amount;
                }
                else if ("silver".StartsWith(arg, StringComparison.CurrentCultureIgnoreCase))
                {
                    if (guild.GuildBankAccount.Silver < amount)
                    {
                        ch.SendText("The guild doesen't have that many &n&+wsilver&n coins.\r\n");
                        return;
                    }
                    ch.ReceiveSilver(amount);
                    guild.GuildBankAccount.Silver -= amount;
                }
                else if ("gold".StartsWith(arg, StringComparison.CurrentCultureIgnoreCase))
                {
                    if (guild.GuildBankAccount.Gold < amount)
                    {
                        ch.SendText("The guild doesen't have that many &+Ygold&n coins.\r\n");
                        return;
                    }
                    ch.ReceiveGold(amount);
                    guild.GuildBankAccount.Gold -= amount;
                }
                else if ("platinum".StartsWith(arg, StringComparison.CurrentCultureIgnoreCase))
                {
                    if (guild.GuildBankAccount.Platinum < amount)
                    {
                        ch.SendText("The guild doesen't have that many &+Wplatinum&n coins.\r\n");
                        return;
                    }
                    ch.ReceivePlatinum(amount);
                    guild.GuildBankAccount.Platinum -= amount;
                }
                else
                {
                    ch.SendText("You don't have any idea what you are trying to do, do you?\r\n");
                    return;
                }

                guild.Save();
                CharData.SavePlayer(ch);

                ch.SendText("You make a withdrawal.\r\n");
            }
            else
            {
                ch.SendText("&+LSyntax:  &+RWithdraw &n&+r<&+L# of coins&n&+r> <&+Lcoin type&n&+r>&n\r\n");
            }
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例2: Withdraw

        /// <summary>
        /// Take money out of your bank account.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="str"></param>
        public static void Withdraw(CharData ch, string[] str)
        {
            if( ch == null ) return;

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

            if (ch.IsNPC())
            {
                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("Withdraw what?\r\n");
                return;
            }
            if (!coin.FillFromString(str, ch))
            {
                ch.SendText("&+LSyntax:  &+RWithdraw &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("The bank has 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 liquidate a debt!\r\n");
                            continue;
                        }
                        if (coin.Copper > ((PC)ch).Bank.Copper)
                        {
                            ch.SendText("You haven't saved that much &+ycopper&n coin!\r\n");
                            continue;
                        }
                        if (coin.Copper == 0)
                            continue;
                        ch.ReceiveCopper(coin.Copper);
                        ((PC)ch).Bank.Copper -= coin.Copper;
                        success = true;
                        break;
                    case 1: //silver
                        if (coin.Silver < 0)
                        {
                            ch.SendText("You can't liquidate a debt!\r\n");
                            continue;
                        }
                        if (coin.Silver > ((PC)ch).Bank.Silver)
                        {
                            ch.SendText("You haven't saved that much &+wsilver&n coin!\r\n");
                            continue;
                        }
                        if (coin.Silver == 0)
                            continue;
                        ch.ReceiveSilver(coin.Silver);
                        ((PC)ch).Bank.Silver -= coin.Silver;
                        success = true;
                        break;
                    case 2: //gold
                        if (coin.Gold < 0)
                        {
                            ch.SendText("You can't liquidate a debt!\r\n");
                            continue;
                        }
                        if (coin.Gold > ((PC)ch).Bank.Gold)
                        {
                            ch.SendText("You haven't saved that much &+Ygold&n coin!\r\n");
                            continue;
                        }
                        if (coin.Gold == 0)
                            continue;
                        ch.ReceiveGold(coin.Gold);
                        ((PC)ch).Bank.Gold -= coin.Gold;
                        success = true;
                        break;
                    case 3: //platinum
                        if (coin.Platinum < 0)
                        {
                            ch.SendText("You can't liquidate a debt!\r\n");
                            continue;
                        }
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例3: CreateMobile

        /// <summary>
        /// Create an instance of a mobile from the provided template.
        /// </summary>
        /// <param name="mobTemplate"></param>
        /// <returns></returns>
        public static CharData CreateMobile( MobTemplate mobTemplate )
        {
            int count;

            if( !mobTemplate )
            {
                Log.Error("CreateMobile: null MobTemplate.", 0);
                throw new NullReferenceException();
            }

            CharData mob = new CharData();

            mob.MobileTemplate = mobTemplate;
            mob.Followers = null;
            mob.Name = mobTemplate.PlayerName;
            mob.ShortDescription = mobTemplate.ShortDescription;
            mob.FullDescription = mobTemplate.FullDescription;
            mob.Description = mobTemplate.Description;
            mob.SpecialFunction = mobTemplate.SpecFun;
            mob.SpecialFunctionNames = mobTemplate.SpecFunNames;
            mob.CharacterClass = mobTemplate.CharacterClass;
            mob.Level = MUDMath.FuzzyNumber( mobTemplate.Level );
            mob.ActionFlags = mobTemplate.ActionFlags;
            mob.CurrentPosition = mobTemplate.DefaultPosition;
            mob.ChatterBotName = mobTemplate.ChatterBotName;
            // TODO: Look up the chatter bot name and load a runtime bot into the variable.
            mob.ChatBot = null;
            for( count = 0; count < Limits.NUM_AFFECT_VECTORS; ++count )
            {
                mob.AffectedBy[ count ] = mobTemplate.AffectedBy[ count ];
            }
            mob.Alignment = mobTemplate.Alignment;
            mob.Gender = mobTemplate.Gender;
            mob.SetPermRace( mobTemplate.Race );
            mob.CurrentSize = Race.RaceList[ mob.GetRace() ].DefaultSize;
            if (mob.HasActionBit(MobTemplate.ACT_SIZEMINUS))
                mob.CurrentSize--;
            if (mob.HasActionBit(MobTemplate.ACT_SIZEPLUS))
                mob.CurrentSize++;

            mob.CastingSpell = 0;
            mob.CastingTime = 0;
            mob.PermStrength = MUDMath.Dice( 2, 46 ) + 8;
            mob.PermIntelligence = MUDMath.Dice( 2, 46 ) + 8;
            mob.PermWisdom = MUDMath.Dice( 2, 46 ) + 8;
            mob.PermDexterity = MUDMath.Dice( 2, 46 ) + 8;
            mob.PermConstitution = MUDMath.Dice( 2, 46 ) + 7;
            mob.PermAgility = MUDMath.Dice( 2, 46 ) + 8;
            mob.PermCharisma = MUDMath.Dice( 2, 46 ) + 8;
            mob.PermPower = MUDMath.Dice( 2, 46 ) + 8;
            mob.PermLuck = MUDMath.Dice( 2, 46 ) + 8;
            mob.ModifiedStrength = 0;
            mob.ModifiedIntelligence = 0;
            mob.ModifiedWisdom = 0;
            mob.ModifiedDexterity = 0;
            mob.ModifiedConstitution = 0;
            mob.ModifiedAgility = 0;
            mob.ModifiedCharisma = 0;
            mob.ModifiedPower = 0;
            mob.ModifiedLuck = 0;
            mob.Resistant = mobTemplate.Resistant;
            mob.Immune = mobTemplate.Immune;
            mob.Susceptible = mobTemplate.Susceptible;
            mob.Vulnerable = mobTemplate.Vulnerable;
            mob.MaxMana = mob.Level * 10;
            if( Race.RaceList[mobTemplate.Race].Coins )
            {
                int level = mobTemplate.Level;
                mob.ReceiveCopper( MUDMath.Dice( 12, level ) / 32 );
                mob.ReceiveSilver( MUDMath.Dice( 9, level ) / 32 );
                mob.ReceiveGold( MUDMath.Dice( 5, level ) / 32 );
                mob.ReceivePlatinum( MUDMath.Dice( 2, level ) / 32 );
            }
            else
            {
                mob.SetCoins( 0, 0, 0, 0 );
            }
            mob.ArmorPoints = MUDMath.Interpolate( mob.Level, 100, -100 );

            // * MOB HITPOINTS *
            //
            // Was level d 8, upped it to level d 13
            // considering mobs *still* won't have as many hitpoints as some players until
            // at least level 10, this shouldn't be too big an upgrade.
            //
            // Mob hitpoints are not based on constitution *unless* they have a
            // constitution modifier from an item, spell, or other affect

            // In light of recent player dissatisfaction with the
            // mob hitpoints, I'm implementing a log curve, using
            //  hp = exp( 2.15135 + level*0.151231)
            // This will will result in the following hp matrix:
            //     Level    Hitpoints
            //      20        175
            //      30        803
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Database.cs

示例4: Steal


//.........这里部分代码省略.........
                    if (!sleeping && !victim.IsBlind())
                    {
                        CommandType.Interpret(victim, "kill " + ch.Name);
                    }
                }
                else
                {
                    if (!victim.IsBlind() && !sleeping && victim.IsAffected(Affect.AFFECT_BERZERK))
                    {
                        victim.SendText("In your &+Rblood rage&n, you lash out in anger!\r\n");
                        CommandType.Interpret(victim, "kill " + ch.Name);
                    }
                }
                /*
                if ( !Macros.IS_SET( ch.actflags, PC.PLAYER_THIEF ) )
                {
                Macros.SET_BIT( ref ch.actflags, PC.PLAYER_THIEF );
                buf = String.Format(  "{0} became a THIEF by stealing from {1}",
                ch._name, victim._name );
                Immtalk.Immtalk( ch, Immtalk.IMMTALK_CRIME, ch.GetTrust(), buf );
                CharData.SavePlayer( ch );
                }
                */
                //    }
                if (sleeping)
                {
                    if (MUDMath.NumberPercent() < victim.GetCurrLuck())
                    {
                        CommandType.Interpret(victim, "wake");
                    }
                }
                return;
            } //end failure

            if (!MUDString.IsPrefixOf(arg1, "coins"))
            {
                int amount = victim.GetGold() * MUDMath.NumberRange(1, 20) / 100;
                int amount2 = victim.GetSilver() * MUDMath.NumberRange(1, 20) / 100;
                int amount3 = victim.GetCopper() * MUDMath.NumberRange(1, 20) / 100;
                int amount4 = victim.GetPlatinum() * MUDMath.NumberRange(1, 20) / 100;

                if ((amount + amount2 + amount3 + amount4) <= 0)
                {
                    ch.SendText("You couldn't get any &n&+wcoins&n.\r\n");
                    return;
                }

                ch.ReceiveGold(amount);
                ch.ReceiveSilver(amount2);
                ch.ReceiveCopper(amount3);
                ch.ReceivePlatinum(amount4);

                victim.SpendGold(amount);
                victim.SpendSilver(amount2);
                victim.SpendCopper(amount3);
                victim.SpendPlatinum(amount4);

                string text = String.Format("Success!  You got {0} &+Wplatinum&n, {1} &+Ygold&n, {2} silver, and {3} &+ycopper&n.\r\n",
                                            amount2, amount3, amount, amount4);
                ch.SendText(text);
                return;
            }

            if (!ch.CanDropObject(obj) || obj.HasFlag(ObjTemplate.ITEM_INVENTORY))
            {
                ch.SendText("You can't pry it away.\r\n");
                return;
            }

            if (ch.CarryNumber + 1 > Limits.MAX_CARRY)
            {
                ch.SendText("You have your hands full.\r\n");
                return;
            }

            if (ch.CarryWeight + obj.GetWeight() > ch.MaxCarryWeight())
            {
                ch.SendText("You cannot carry that much weight.\r\n");
                return;
            }

            if (obj.WearLocation != ObjTemplate.WearLocation.none)
            {
                ch.SendText("Very daring, and you got it!\r\n");
                victim.UnequipObject(obj);
            }

            obj.RemoveFromChar();
            obj.ObjToChar(ch);
            ch.SendText("Nice work.\r\n");
            if (obj.Trap != null && obj.Trap.CheckTrigger( Trap.TriggerType.steal))
            {
                ch.SetOffTrap(obj);
                if (ch.CurrentPosition == Position.dead)
                {
                    return;
                }
            }
            return;
        }
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Command.cs

示例5: GetObject

        public static void GetObject(CharData ch, Object obj, Object container)
        {
            if (!obj.HasWearFlag(ObjTemplate.WEARABLE_CARRY))
            {
                ch.SendText("You can't pick that up.\r\n");
                return;
            }

            if (obj._itemType != ObjTemplate.ObjectType.money)
            {
                if (ch.CarryWeight + obj.GetWeight() > ch.MaxCarryWeight())
                {
                    SocketConnection.Act("$p&n is quite literally the &+Ystraw&n that would break the &n&+ycamel&n's back.", ch, obj, null, SocketConnection.MessageTarget.character);
                    return;
                }
            }

            if (container != null)
            {
                SocketConnection.Act("You get $p&n from $P&n.", ch, obj, container, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n retrieves $p&n from $P&n.", ch, obj, container, SocketConnection.MessageTarget.room);
                obj.RemoveFromObject();
                // Fix for corpse EQ dupe on crash
                if (container._itemType == ObjTemplate.ObjectType.pc_corpse)
                {
                    Database.CorpseList.Save();
                }
            }
            else
            {
                SocketConnection.Act("You get $p&n.", ch, obj, container, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&n picks up $p&n.", ch, obj, container, SocketConnection.MessageTarget.room);
                obj.RemoveFromRoom();
            }

            if (obj.HasFlag(ObjTemplate.ITEM_ANTI_EVIL) && ch.IsEvil())
            {
                SocketConnection.Act("&+LYou are &n&+rburned&+L by holy &+Rfire&+L from $p&+L.  Ouch!&n", ch, obj, null,
                     SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&+L is &n&+rburned&+L by holy &+Rfire&+L from &n$p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.room);
                Combat.InflictSpellDamage(ch, ch, 20, "burning hands", AttackType.DamageType.white_magic);
                obj.AddToRoom(ch.InRoom);
                return;
            }

            if (obj.HasFlag(ObjTemplate.ITEM_ANTI_EVIL) && ch.IsEvil())
            {
                SocketConnection.Act("&+LYou are &n&+rburned&+L by holy &+Rfire&+L from $p&+L.  Ouch!&n", ch, obj, null,
                     SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&+L is &n&+rburned&+L by holy &+Rfire&+L from &n$p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.room);
                Combat.InflictSpellDamage(ch, ch, 20, "burning hands", AttackType.DamageType.white_magic);
                obj.AddToRoom(ch.InRoom);
                return;
            }

            if (obj.HasFlag(ObjTemplate.ITEM_ANTI_GOOD) && ch.IsGood())
            {
                SocketConnection.Act("&+LYou are &n&+rconsumed&+L by &+Rfire&+L and &+Ldespair&n from $p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.character);
                SocketConnection.Act("$n&+L is &n&+rengulfed&+L by an abundancy of &+Rflames&+L from &n$p&+L!&n", ch, obj, null, SocketConnection.MessageTarget.room);
                Combat.InflictSpellDamage(ch, ch, 20, "burning hands", AttackType.DamageType.white_magic);
                obj.AddToRoom(ch.InRoom);
                return;
            }

            if (obj._itemType == ObjTemplate.ObjectType.money)
            {
                int amount = obj._values[0] + obj._values[1] + obj._values[2] + obj._values[3];
                ch.ReceiveCopper(obj._values[0]);
                ch.ReceiveSilver(obj._values[1]);
                ch.ReceiveGold(obj._values[2]);
                ch.ReceivePlatinum(obj._values[3]);

                if (amount > 1)
                {
                    string text = String.Format("You pick up");
                    string text2;
                    if (obj._values[3] > 0)
                    {
                        text2 = String.Format(" {0} &+Wplatinum&n", obj._values[3]);
                        if (obj._values[0] > 0 || obj._values[1] > 0 || obj._values[2] > 0)
                        {
                            text2 += ",";
                        }
                        text += text2;
                    }
                    if (obj._values[2] > 0)
                    {
                        text2 = String.Format(" {0} &+Ygold&n", obj._values[2]);
                        if (obj._values[0] > 0 || obj._values[1] > 0)
                        {
                            text2 += ",";
                        }
                        text += text2;
                    }
                    if (obj._values[1] > 0)
                    {
                        text2 = String.Format(" {0} &n&+wsilver&n", obj._values[1]);
                        if (obj._values[0] > 0)
                        {
                            text2 += ",";
//.........这里部分代码省略.........
开发者ID:ramseur,项目名称:ModernMUD,代码行数:101,代码来源:Object.cs


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