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


C# Database.CreateGuild方法代码示例

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


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

示例1: CreateGuild

 public void CreateGuild(RealmTime t, CreateGuildPacket pkt)
 {
     var GuildsActive = true;
     if (GuildsActive == false)
     {
         psr.SendPacket(new CreateGuildResultPacket()
         {
             Success = false,
             ResultMessage = "Guilds currently disabled!"
         });
         return;
     }
     else
     {
         try
         {
             var name = pkt.Name.ToString();
             if (psr.Account.Stats.Fame >= 1000)
             {
                 if (name != "")
                 {
                     if (new Database().GetGuild(name) != null)
                     {
                         psr.SendPacket(new CreateGuildResultPacket()
                         {
                             Success = false,
                             ResultMessage = "Guild already exists!"
                         });
                         return;
                     }
                     using (var db1 = new Database())
                     {
                         try
                         {
                             if (psr.Account.Guild.Name == "")
                             {
                                 if (pkt.Name != "")
                                 {
                                     var g = db1.CreateGuild(psr.Account, pkt.Name);
                                     psr.Account.Guild.Name = g.Name;
                                     psr.Account.Guild.Rank = g.Rank;
                                     Guild = g.Name;
                                     GuildRank = g.Rank;
                                     psr.SendPacket(new NotificationPacket()
                                     {
                                         Text = "Created guild " + g.Name,
                                         Color = new ARGB(0xFF008800),
                                         ObjectId = Id
                                     });
                                     psr.SendPacket(new CreateGuildResultPacket()
                                     {
                                         Success = true,
                                         ResultMessage = "Success!"
                                     });
                                     CurrentFame = psr.Account.Stats.Fame = psr.Database.UpdateFame(psr.Account, -1000);
                                     UpdateCount++;
                                     return;
                                 }
                                 else
                                 {
                                     psr.SendPacket(new CreateGuildResultPacket()
                                     {
                                         Success = false,
                                         ResultMessage = "Guild name cannot be blank!"
                                     });
                                     return;
                                 }
                             }
                             else
                             {
                                 psr.SendPacket(new CreateGuildResultPacket()
                                 {
                                     Success = false,
                                     ResultMessage = "You cannot create a guild as a guild member!"
                                 });
                                 return;
                             }
                         }
                         catch (Exception e)
                         {
                             psr.SendPacket(new CreateGuildResultPacket()
                             {
                                 Success = false,
                                 ResultMessage = e.Message
                             });
                             return;
                         }
                     }
                 }
                 else
                 {
                     psr.SendPacket(new CreateGuildResultPacket()
                     {
                         Success = false,
                         ResultMessage = "Name cannot be empty!"
                     });
                 }
             }
             else
             {
//.........这里部分代码省略.........
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:101,代码来源:Player.Guilds.cs

示例2: CreateGuild

 public void CreateGuild(RealmTime t, CreateGuildPacket pkt)
 {
     bool GuildsActive = true;
     if (GuildsActive == false)
     {
         psr.SendPacket(new CreateGuildResultPacket()
         {
             Success = false,
             ResultMessage = "Guilds currently disabled!"
         });
         return;
     }
     else
     {
         try
         {
             string name = pkt.Name.ToString();
             if (psr.Account.Stats.Fame >= 1000 || Guild != "")
             {
                 if (name != "")
                 {
                     if (new Database().GetGuild(name) != null)
                     {
                         psr.SendPacket(new CreateGuildResultPacket()
                         {
                             Success = false,
                             ResultMessage = "Guild already exists!"
                         });
                         return;
                     }
                     using (Database db1 = new Database())
                     {
                         try
                         {
                             if (Guild != "")
                             {
                                 string oldname = psr.Account.Guild.Name;
                                 Guild g = db1.ChangeGuild(psr.Account, db1.GetGuildId(psr.Account.Guild.Name), 0, true);
                                 psr.Account.Guild.Name = g.Name;
                                 psr.Account.Guild.Rank = 0;
                                 Guild = g.Name;
                                 GuildRank = 0;
                                 UpdateCount++;
                                 psr.SendPacket(new NotificationPacket()
                                 {
                                     Text = "Left guild " + oldname,
                                     Color = new ARGB(0xFF008800),
                                     ObjectId = Id
                                 });
                                 psr.SendPacket(new CreateGuildResultPacket()
                                 {
                                     Success = true
                                 });
                                 foreach (var i in RealmManager.Worlds)
                                 {
                                     if (i.Key != 0)
                                     {
                                         foreach (var e in i.Value.Players)
                                         {
                                             if (e.Value.Client.Account.Guild.Name == oldname)
                                             {
                                                 e.Value.Client.SendPacket(new TextPacket()
                                                 {
                                                     BubbleTime = 0,
                                                     Stars = -1,
                                                     Name = "",
                                                     Recipient = "*Guild*",
                                                     Text = psr.Account.Name + " has left the guild!"
                                                 });
                                             }
                                         }
                                     }
                                 }
                                 return;
                             }
                             else
                             {
                                 if (pkt.Name != "")
                                 {
                                     Guild g = db1.CreateGuild(psr.Account, pkt.Name);
                                     psr.Account.Guild.Name = g.Name;
                                     psr.Account.Guild.Rank = g.Rank;
                                     Guild = g.Name;
                                     GuildRank = g.Rank;
                                     psr.SendPacket(new NotificationPacket()
                                     {
                                         Text = "Created guild " + g.Name,
                                         Color = new ARGB(0xFF008800),
                                         ObjectId = Id
                                     });
                                     psr.SendPacket(new CreateGuildResultPacket()
                                     {
                                         Success = true,
                                         ResultMessage = "Success!"
                                     });
                                     CurrentFame = psr.Account.Stats.Fame = psr.Database.UpdateFame(psr.Account, -1000);
                                     UpdateCount++;
                                     return;
                                 }
                                 else
//.........这里部分代码省略.........
开发者ID:xzyio,项目名称:Rotmg-PServer,代码行数:101,代码来源:Player.Guilds.cs


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