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


C# Database.UpdateCredit方法代码示例

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


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

示例1: HandleRequest

        protected override void HandleRequest()
        {
            using (Database db = new Database())
            {
                try
                {
                    Account acc = db.Verify(Query["guid"], Query["password"], Program.GameData);

                    string classType = Program.GameData.ObjectTypeToId[ushort.Parse(Query["classType"])];

                    if (CheckAccount(acc, db))
                    {
                        int price = Program.GameData.ObjectDescs[ushort.Parse(Query["classType"])].UnlockCost;
                        if (acc.Credits < price) return;
                        db.UpdateCredit(acc, -price);
                        MySqlCommand cmd = db.CreateQuery();
                        cmd.CommandText =
                            "UPDATE unlockedclasses SET available='unrestricted' WHERE [email protected] AND [email protected];";
                        cmd.Parameters.AddWithValue("@accId", acc.AccountId);
                        cmd.Parameters.AddWithValue("@class", classType);
                        cmd.ExecuteNonQuery();
                    }
                }
                catch (Exception e)
                {
                    using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                    {
                        wtr.WriteLine("<Error>Invalid classType");
                        wtr.Flush();
                        wtr.WriteLine(e);
                    }
                }
            }
        }
开发者ID:SirAnuse,项目名称:fabiano-swagger-of-doom,代码行数:34,代码来源:purchaseClassUnlock.cs

示例2: HandleRequest

        protected override void HandleRequest()
        {
            StreamWriter wtr = new StreamWriter(Context.Response.OutputStream);
            if (Query.AllKeys.Length > 0)
            {
                using (Database db = new Database())
                {
                    Account acc = db.Verify(Query["guid"], Query["password"], Program.GameData);

                    if (CheckAccount(acc, db, false))
                    {
                        foreach (ItemCostItem item in Prices)
                        {
                            if (item.Type == Query["skinType"] && item.Puchasable == 1)
                            {
                                if (!acc.OwnedSkins.Contains(int.Parse(Query["skinType"])))
                                {
                                    acc.OwnedSkins.Add(int.Parse(Query["skinType"]));
                                    db.UpdateCredit(acc, -item.Price);
                                    MySqlCommand cmd = db.CreateQuery();
                                    cmd.CommandText =
                                        "UPDATE accounts SET [email protected] WHERE [email protected] AND password=SHA1(@password)";
                                    cmd.Parameters.AddWithValue("@ownedSkins",
                                        Utils.GetCommaSepString(acc.OwnedSkins.ToArray()));
                                    cmd.Parameters.AddWithValue("@uuid", Query["guid"]);
                                    cmd.Parameters.AddWithValue("@password", Query["password"]);
                                    if (cmd.ExecuteNonQuery() == 0)
                                        wtr.WriteLine("<Error>Unable to purchase</Error>");
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:SirAnuse,项目名称:fabiano-swagger-of-doom,代码行数:35,代码来源:purchaseSkin.cs

示例3: Tick

 public override void Tick(RealmTime time)
 {
     base.Tick(time);
     if (Players.Count > 0)
     {
         if (!Flags["started"] && !Flags["counting"])
         {
             foreach (var i in RealmManager.Clients.Values)
                 i.SendPacket(new TextPacket
                 {
                     Stars = -1,
                     BubbleTime = 0,
                     Name = "#Announcement",
                     Text = "A paid arena game has been started. Closing in 1 minute!"
                 });
             Flags["counting"] = true;
             Countdown(60);
         }
         else if (Flags["started"] && !Flags["counting"])
         {
             if (Enemies.Count < 1 + Pets.Count)
             {
                 Wave++;
                 if (Wave < 6)
                 {
                     RandomBosses = new[] { "Red Demon", "Phoenix Lord", "Henchman of Oryx" };
                 }
                 if (Wave > 5 && Wave < 11)
                 {
                     RandomBosses = new[]
                     {"Red Demon", "Phoenix Lord", "Henchman of Oryx", "Stheno the Snake Queen"};
                 }
                 if (Wave > 10 && Wave < 16)
                 {
                     RandomBosses = new[]
                     {"Elder Tree", "Stheno the Snake Queen", "Archdemon Malphas", "Septavius the Ghost God"};
                 }
                 if (Wave > 15 && Wave < 21)
                 {
                     RandomBosses = new[]
                     {
                         "Elder Tree", "Archdemon Malphas", "Septavius the Ghost God",
                         "Thessal the Mermaid Goddess",
                         "Crystal Prisoner"
                     };
                 }
                 if (Wave > 20 && Wave < 36)
                 {
                     RandomBosses = new[]
                     {
                         "Thessal the Mermaid Goddess", "Crystal Prisoner", "Tomb Support", "Tomb Defender",
                         "Tomb Attacker", "Oryx the Mad God 2"
                     };
                 }
                 if (Wave > 35)
                 {
                     RandomBosses = new[]
                       {
                         "Thessal the Mermaid Goddess", "Crystal Prisoner", "Tomb Support", "Tomb Defender",
                         "Tomb Attacker", "Oryx the Mad God 2", "Phoenix Wright", "Bridge Sentinel"
                     };
                 }
                 var db = new Database();
                 //FamePot = (Wave/2)*10/(Players.Count == 1 ? 1 : 2);
                 if (Players.Count == 1)
                 {
                     FamePot = Wave / 2 * 10;
                 }
                 else if (Wave % 2 == 1)
                 {
                     FamePot = (Wave + 1) / 4 * 10;
                 }
                 else
                 {
                     FamePot = Wave / 4 * 10;
                 }
                 foreach (var i in Players)
                 {
                     i.Value.CurrentFame =
                         i.Value.Client.Account.Stats.Fame = db.UpdateFame(i.Value.Client.Account, FamePot);
                     i.Value.UpdateCount++;
                     i.Value.Client.SendPacket(new NotificationPacket
                     {
                         Color = new ARGB(0xFFFF6600),
                         ObjectId = i.Value.Id,
                         Text = "+" + FamePot + " Fame"
                     });
                     if (Math.IEEERemainder(Wave, 15) == 0)
                     {
                         i.Value.Credits = i.Value.Client.Account.Credits = db.UpdateCredit(i.Value.Client.Account, 1);
                         i.Value.UpdateCount++;
                     }
                 }
                 db.Dispose();
                 var Invincible = new ConditionEffect();
                 Invincible.Effect = ConditionEffectIndex.Invulnerable;
                 Invincible.DurationMS = 6000;
                 var Healing = new ConditionEffect();
                 Healing.Effect = ConditionEffectIndex.Healing;
                 Healing.DurationMS = 6000;
//.........这里部分代码省略.........
开发者ID:BlackRayquaza,项目名称:PhoenixRealms,代码行数:101,代码来源:BattleArena.cs

示例4: Execute

 public void Execute(Player player, string[] args)
 {
     try
     {
         if (args.Length == 0)
         {
             player.SendHelp("Use /gold <amount>");
         }
         else
         {
             using (var db = new Database())
             {
                 player.Credits = db.UpdateCredit(player.Client.Account, int.Parse(args[0]));
                 player.UpdateCount++;
                 db.Dispose();
             }
         }
     }
     catch
     {
         player.SendError("Error");
     }
 }
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:23,代码来源:AdminCommands.cs

示例5: Tick

        public override void Tick(RealmTime time)
        {
            if (Players.Count > 0 && !Flags["finished"])
            {
                if (Flags["started"] && !Flags["counting"])
                {
                    if (Enemies.Count < 1 + Pets.Count)
                    {
                        if (monstervalue != 0)
                        {
                            var db = new Database();
                            foreach (var i in Players)
                            {
                                i.Value.CurrentFame =
                                    i.Value.Client.Account.Stats.Fame = db.UpdateFame(i.Value.Client.Account, (int)monstervalue);
                                i.Value.UpdateCount++;
                                i.Value.Client.SendPacket(new NotificationPacket
                                {
                                    Color = new ARGB(0xFFFF6600),
                                    ObjectId = i.Value.Id,
                                    Text = "+" + (int)monstervalue + " Fame"
                                });
                                if (Math.IEEERemainder(monstervalue, 1000) == 0)
                                {
                                    i.Value.Credits = i.Value.Client.Account.Credits = db.UpdateCredit(i.Value.Client.Account, 1);
                                    i.Value.UpdateCount++;
                                }
                            }
                            db.Dispose();
                            Countdown(5);
                        }

                    }
                }

                else if (!Flags["started"] && !Flags["counting"])
                {
                    foreach (var i in RealmManager.Clients.Values)
                        i.SendPacket(new TextPacket
                        {
                            Stars = -1,
                            BubbleTime = 0,
                            Name = "#Announcement",
                            Text = "A Nexus Defense Game has been started. Closing in 1 minute!"
                        });
                    Flags["counting"] = true;
                    Countdown(60);
                }

            }
            base.Tick(time);
        }
开发者ID:RiiggedMPGH,项目名称:Owl-Realms-Source,代码行数:52,代码来源:NexusDefense.cs

示例6: HandleRequest

        protected override void HandleRequest()
        {
            StreamWriter wtr = new StreamWriter(Context.Response.OutputStream);
            if (Query.AllKeys.Length > 0)
            {
                using (Database db = new Database())
                {
                    Package package = Package.GetPackage(int.Parse(Query["packageId"]));

                    if (package == null)
                    {
                        wtr.Write("<Error>This package is not available any more</Error>");
                        return;
                    }

                    JsonSerializer s = new JsonSerializer();
                    var contents = s.Deserialize<PackageContent>(new JsonTextReader(new StringReader(package.Contents)));

                    Account acc = db.Verify(Query["guid"], Query["password"], Program.GameData);

                    if (CheckAccount(acc, db, false))
                    {
                        if (acc.Credits < package.Price)
                        {
                            wtr.Write("<Error>Not enough gold.<Error/>");
                            return;
                        }

                        var cmd = db.CreateQuery();

                        if (contents.items?.Count > 0)
                        {
                            foreach (var i in contents.items)
                            {
                                Dictionary<string, int> itemDic = new Dictionary<string, int>();
                                List<int> gifts = acc.Gifts;
                                gifts.Add(i);

                                cmd = db.CreateQuery();
                                cmd.CommandText =
                                    "UPDATE accounts SET [email protected] WHERE [email protected] AND password=SHA1(@password);";
                                cmd.Parameters.AddWithValue("@gifts", Utils.GetCommaSepString<int>(gifts.ToArray()));
                                cmd.Parameters.AddWithValue("@uuid", Query["guid"]);
                                cmd.Parameters.AddWithValue("@password", Query["password"]);
                                cmd.ExecuteNonQuery();
                            }
                        }

                        if (contents.charSlots > 0)
                        {
                            cmd = db.CreateQuery();
                            cmd.CommandText =
                                "UPDATE accounts SET maxCharSlot=maxCharSlot + @amount WHERE [email protected] AND password=SHA1(@password);";
                            cmd.Parameters.AddWithValue("@amount", contents.charSlots);
                            cmd.Parameters.AddWithValue("@uuid", Query["guid"]);
                            cmd.Parameters.AddWithValue("@password", Query["password"]);
                            if (cmd.ExecuteNonQuery() == 0)
                                return;
                        }

                        if (contents.vaultChests > 0)
                        {
                            for (int j = 0; j < contents.vaultChests; j++)
                                db.CreateChest(acc);
                        }

                        db.UpdateCredit(acc, -package.Price);
                        wtr.Write("<Success/>");
                    }
                }
            }
        }
开发者ID:OryxAwakening,项目名称:Fabiano_Swagger_of_Doom,代码行数:72,代码来源:purchasePackage.cs

示例7: HandleRequest


//.........这里部分代码省略.........
                            List<int> items = Utils.FromCommaSepString32(rdr.GetString("contents")).ToList();
                            List<int> candidates = new List<int>(3);

                            do
                            {
                                int item = items[rand.Next(items.Count)];
                                if (!candidates.Contains(item))
                                    candidates.Add(item);
                            } while (candidates.Count < 3);

                            if (currency == GOLD)
                            {
                                if (Query["status"] == "0")
                                {
                                    if (CurrentGames.ContainsKey(acc.AccountId))
                                        CurrentGames.Remove(acc.AccountId);
                                    CurrentGames.Add(acc.AccountId, candidates.ToArray());
                                    price = rdr.GetInt32("priceFirstInGold");
                                    status = "<Success><Candidates>" +
                                        Utils.GetCommaSepString(candidates.ToArray()) +
                                        "</Candidates><Gold>" +
                                        (acc.Credits - price) +
                                        "</Gold></Success>";
                                }
                                else if (Query["status"] == "1")
                                {
                                    if (CurrentGames.ContainsKey(acc.AccountId))
                                    {
                                        candidates = CurrentGames[acc.AccountId].ToList();
                                        candidates.Shuffle();
                                        status = "<Success><Awards>" + candidates[int.Parse(Query["choice"])] + "</Awards></Success>";
                                        gifts.Add(candidates[int.Parse(Query["choice"])]);
                                        candidates.Remove(candidates[int.Parse(Query["choice"])]);
                                        CurrentGames[acc.AccountId] = candidates.ToArray();
                                    }
                                }
                                else if (Query["status"] == "2")
                                {
                                    if (CurrentGames.ContainsKey(acc.AccountId))
                                    {
                                        candidates = CurrentGames[acc.AccountId].ToList();
                                        candidates.Shuffle();
                                        price = rdr.GetInt32("priceSecondInGold");
                                        status = "<Success><Awards>" + candidates[int.Parse(Query["choice"])] + "</Awards></Success>";
                                        gifts.Add(candidates[int.Parse(Query["choice"])]);
                                        CurrentGames.Remove(acc.AccountId);
                                    }
                                }
                            }
                            else if (currency == FORTUNETOKENS)
                            {
                                if (Query["status"] == "0")
                                {
                                    if (CurrentGames.ContainsKey(acc.AccountId))
                                        CurrentGames.Remove(acc.AccountId);
                                    CurrentGames.Add(acc.AccountId, candidates.ToArray());
                                    price = rdr.GetInt32("priceFirstInToken");
                                    status = "<Success><Candidates>" +
                                        Utils.GetCommaSepString(candidates.ToArray()) +
                                        "</Candidates><FortuneToken>" +
                                        (acc.FortuneTokens - price) +
                                        "</FortuneToken></Success>";
                                }
                                else if (Query["status"] == "1")
                                {
                                    if (CurrentGames.ContainsKey(acc.AccountId))
                                    {
                                        candidates = CurrentGames[acc.AccountId].ToList();
                                        candidates.Shuffle();
                                        status = "<Success><Awards>" + candidates[int.Parse(Query["choice"])] + "</Awards></Success>";
                                        gifts.Add(candidates[int.Parse(Query["choice"])]);
                                        candidates.Remove(candidates[int.Parse(Query["choice"])]);
                                        CurrentGames[acc.AccountId] = candidates.ToArray();
                                    }
                                }
                                else if (Query["status"] == "2")
                                {
                                    status = "<Error>You can not play twiche with a Fortune Token</Error>";
                                }
                            }
                            else
                                status = "<Error>Invalid currency</Error>";
                        }
                        else
                            status = "<Error>Invalid gameId</Error>";
                    }
                    if (currency == GOLD)
                        db.UpdateCredit(acc, price == -1 ? 0 : -price);
                    else if (currency == FORTUNETOKENS)
                        db.UpdateFortuneToken(acc, price == -1 ? 0 : -price);

                    db.AddGifts(acc, gifts);
                }
                else
                    status = "<Error>Account not found</Error>";

                using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                    wtr.Write(status);
            }
        }
开发者ID:SirAnuse,项目名称:fabiano-swagger-of-doom,代码行数:101,代码来源:playFortuneGame.cs

示例8: Tick

 public override void Tick(RealmTime time)
 {
     if (Players.Count > 0 && !Flags["finished"])
     {
         if (Flags["started"] && Flags["counting"])
         {
             if (Enemies.Count < 15 + Pets.Count)
             {
                 SheepSpawns.Shuffle();
                 SpawningSheep.Shuffle();
                 var e = Entity.Resolve(XmlData.IdToObjectType[SpawningSheep.First()]);
                 e.Move(SheepSpawns[0].X, SheepSpawns[0].Y);
                 EnterWorld(e);
             }
         }
         else if (Flags["started"] && !Flags["counting"])
         {
             var div = (int)Math.Ceiling((double)(FamePot / Players.Count));
             double golddivider = HerdedSheep / 20;
             var tokens = (int)Math.Floor(golddivider);
             var db = new Database();
             BroadcastPacket(new TextPacket
             {
                 BubbleTime = 0,
                 Stars = -1,
                 Name = "#Sheep Herding",
                 Text = "Time's up! You each win " + div + " fame!"
             }, null);
             foreach (var i in Players)
             {
                 i.Value.CurrentFame =
                     i.Value.Client.Account.Stats.Fame = db.UpdateFame(i.Value.Client.Account, div);
                 i.Value.UpdateCount++;
                 i.Value.Client.SendPacket(new NotificationPacket
                 {
                     ObjectId = i.Value.Id,
                     Color = new ARGB(0xFFFF6600),
                     Text = "+" + div + " Fame"
                 });
                 i.Value.Credits = i.Value.Client.Account.Credits = db.UpdateCredit(i.Value.Client.Account, tokens);
                 i.Value.UpdateCount++;
             }
             db.Dispose();
             foreach (var i in Enemies)
                 if (!i.Value.isPet)
                     LeaveWorld(i.Value);
             Flags["finished"] = true;
         }
         else if (!Flags["started"] && !Flags["counting"])
         {
             foreach (var i in RealmManager.Clients.Values)
                 i.SendPacket(new TextPacket
                 {
                     Stars = -1,
                     BubbleTime = 0,
                     Name = "#Announcement",
                     Text = "A sheep herding minigame has been started. Closing in 1 minute!"
                 });
             Flags["counting"] = true;
             Countdown(60);
         }
     }
     base.Tick(time);
 }
开发者ID:BlackRayquaza,项目名称:PhoenixRealms,代码行数:64,代码来源:Herding.cs

示例9: ParseContents

        private bool ParseContents(Account acc, string json)
        {
            try
            {
                using (var db = new Database())
                {
                    var code = GiftCode.FromJson(json);
                    if (code == null) return false;
                    var cmd = db.CreateQuery();

                    if (code.Gifts.Count > 0)
                    {
                        List<int> gifts = acc.Gifts;
                        foreach (var i in code.Gifts)
                            gifts.Add(i);

                        cmd = db.CreateQuery();
                        cmd.CommandText =
                            "UPDATE accounts SET [email protected] WHERE [email protected] AND password=SHA1(@password);";
                        cmd.Parameters.AddWithValue("@gifts", Utils.GetCommaSepString<int>(gifts.ToArray()));
                        cmd.Parameters.AddWithValue("@uuid", Query["guid"]);
                        cmd.Parameters.AddWithValue("@password", Query["password"]);
                        cmd.ExecuteNonQuery();
                    }

                    if (code.CharSlots > 0)
                    {
                        cmd = db.CreateQuery();
                        cmd.CommandText =
                            "UPDATE accounts SET maxCharSlot=maxCharSlot + @amount WHERE [email protected] AND password=SHA1(@password);";
                        cmd.Parameters.AddWithValue("@amount", code.CharSlots);
                        cmd.Parameters.AddWithValue("@uuid", Query["guid"]);
                        cmd.Parameters.AddWithValue("@password", Query["password"]);
                        cmd.ExecuteNonQuery();
                    }

                    if (code.VaultChests > 0)
                        for (int j = 0; j < code.VaultChests; j++)
                            db.CreateChest(acc);

                    if (code.Gold > 0)
                        db.UpdateCredit(acc, code.Gold);

                    if (code.Fame > 0)
                        db.UpdateFame(acc, code.Fame);
                }
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
开发者ID:SirAnuse,项目名称:fabiano-swagger-of-doom,代码行数:53,代码来源:redeemGiftCode.cs

示例10: Tick

        public override void Tick(RealmTime time)
        {
            base.Tick(time);
            if (Players.Count > 0)
            {
                if (!Flags["started"] && !Flags["counting"])
                {
                    foreach (var i in RealmManager.Clients.Values)
                        i.SendPacket(new TextPacket
                        {
                            Stars = -1,
                            BubbleTime = 0,
                            Name = "#Announcement",
                            Text = "A free arena game has been started. Closing in 1 minute!"
                        });
                    Flags["counting"] = true;
                    Countdown(60);
                }

                else if (Flags["started"] && !Flags["counting"])
                {
                    if (Enemies.Count < 1 + Pets.Count)
                    {
                        Wave++;
                        if (Wave < 6)
                        {
                            RandomBosses = new[] {"Red Demon", "Phoenix Lord", "Henchman of Oryx"};
                        }
                        if (Wave > 5 && Wave < 11)
                        {
                            RandomBosses = new[]
                            {"Red Demon", "Phoenix Lord", "Henchman of Oryx", "Stheno the Snake Queen"};
                        }
                        if (Wave > 10 && Wave < 16)
                        {
                            RandomBosses = new[]
                            {"Elder Tree", "Stheno the Snake Queen", "Archdemon Malphas", "Septavius the Ghost God"};
                        }
                        if (Wave > 15 && Wave < 21)
                        {
                            RandomBosses = new[]
                            {
                                "Elder Tree", "Archdemon Malphas", "Septavius the Ghost God",
                                "Thessal the Mermaid Goddess",
                                "Crystal Prisoner"
                            };
                        }
                        if (Wave > 20)
                        {
                            RandomBosses = new[]
                            {
                                "Thessal the Mermaid Goddess", "Crystal Prisoner", "Tomb Support", "Tomb Defender",
                                "Tomb Attacker", "Oryx the Mad God 2"
                            };
                        }
                        var db = new Database();
                        foreach (var i in Players)
                        {
                            if (Math.IEEERemainder(Wave, 25) == 0)
                            {
                                i.Value.Credits = i.Value.Client.Account.Credits = db.UpdateCredit(i.Value.Client.Account, 1);
                                i.Value.UpdateCount++;
                            }
                        }
                        db.Dispose();
                        var invincible = new ConditionEffect {Effect = ConditionEffectIndex.Invulnerable, DurationMS = 5000};
                        var healing = new ConditionEffect {Effect = ConditionEffectIndex.Healing, DurationMS = 5000};
                        foreach (var i in Players)
                        {
                            i.Value.Client.SendPacket(new SwitchMusicPacket()
                            {
                                Music = "Arena"
                            });
                            i.Value.ApplyConditionEffect(new[]
                            {
                                invincible,
                                healing
                            });
                        }
                        foreach (var i in Players)
                        {
                            try
                            {
                                if (!Participants.Contains(i.Value.Client.Account.Name))
                                    Participants.Add(i.Value.Client.Account.Name);
                            }
                            catch
                            {
                            }
                        }
                        Flags["counting"] = true;
                        Countdown(5);
                    }
                    else
                    {
                        foreach (var i in Enemies)
                        {
                            if (OutOfBounds(i.Value.X, i.Value.Y))
                            {
                                LeaveWorld(i.Value);
//.........这里部分代码省略.........
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:101,代码来源:BattleArena2.cs

示例11: BehaviorEvent

        public override void BehaviorEvent(string type)
        {
            var typec = type.Split(':');
            if (typec.Length > 1)
                if (typec[0] == "dmg")
                {
                    try
                    {
                        towerHp -= Convert.ToInt32(typec[1]);
                        if (towerHp > 0)
                            BroadcastPacket(new TextPacket
                            {
                                Stars = -1,
                                BubbleTime = 0,
                                Name = "#Zombies",
                                Text = "Your tower's been damaged! " + towerHp + " HP left."
                            }, null);
                        else
                        {
                            Flags["finished"] = true;

                            BroadcastPacket(new TextPacket
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "#Zombies",
                                Text = "Your tower's been destroyed! You each earn " + famePot + " fame!"
                            }, null);
                            double golddivider = wave / 15;
                            int tokens = (int)Math.Floor(golddivider);
                            foreach (var i in Players)
                            {
                                var db = new Database();
                                i.Value.CurrentFame = i.Value.Client.Account.Stats.Fame = db.UpdateFame(i.Value.Client.Account, famePot);
                                i.Value.UpdateCount++;
                                i.Value.Client.SendPacket(new NotificationPacket
                                {
                                    ObjectId = i.Value.Id,
                                    Color = new ARGB(0xFFFF6600),
                                    Text = "+" + famePot + " Fame"
                                });
                                i.Value.Credits = i.Value.Client.Account.Credits = db.UpdateCredit(i.Value.Client.Account, tokens);
                                i.Value.UpdateCount++;
                                Flags["counting"] = true;
                                db.Dispose();

                            }
                            foreach (var i in Enemies)
                            {
                                if (!i.Value.isPet)
                                {
                                    LeaveWorld(i.Value);
                                }
                            }
                            LeaveWorld(tower);

                        }
                    }
                    catch
                    {
                    }
                }
            base.BehaviorEvent(type);
        }
开发者ID:RoxyLalonde,项目名称:Phoenix-Realms,代码行数:64,代码来源:ZombieMG.cs

示例12: HandleRequest

        protected override void HandleRequest()
        {
            rand = Query["ignore"] != null ? new Random(int.Parse(Query["ignore"])) : new Random();

            using (Database db = new Database())
            {
                Account acc = db.Verify(Query["guid"], Query["password"], Program.GameData);
                if (CheckAccount(acc, db, false))
                {
                    if (Query["boxId"] == null)
                    {
                        using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                            wtr.WriteLine("<Error>Box not found</Error>");
                        return;
                    }
                    MysteryBox box = MysteryBox.GetBox(int.Parse(Query["boxId"]));
                    if (box == null)
                    {
                        using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                            wtr.WriteLine("<Error>Box not found</Error>");
                        return;
                    }
                    if (box.Sale != null && DateTime.UtcNow <= box.Sale.SaleEnd)
                    {
                        switch (box.Sale.Currency)
                        {
                            case 0:
                                if (acc.Credits < box.Sale.Price)
                                {
                                    using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                                        wtr.WriteLine("<Error>Not Enough Gold</Error>");
                                    return;
                                }
                                break;

                            case 1:
                                if (acc.Stats.Fame < box.Sale.Price)
                                {
                                    using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                                        wtr.WriteLine("<Error>Not Enough Fame</Error>");
                                    return;
                                }
                                break;
                        }
                    }
                    else
                    {
                        switch (box.Price.Currency)
                        {
                            case 0:
                                if (acc.Credits < box.Price.Amount)
                                {
                                    using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                                        wtr.WriteLine("<Error>Not Enough Gold</Error>");
                                    return;
                                }
                                break;

                            case 1:
                                if (acc.Stats.Fame < box.Price.Amount)
                                {
                                    using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                                        wtr.WriteLine("<Error>Not Enough Fame</Error>");
                                    return;
                                }
                                break;
                        }
                    }

                    MysteryBoxResult res = new MysteryBoxResult
                    {
                        Awards = Utils.GetCommaSepString(GetAwards(box.Contents))
                    };
                    if (box.Sale != null && DateTime.UtcNow <= box.Sale.SaleEnd)
                        res.GoldLeft = box.Sale.Currency == 0
                            ? db.UpdateCredit(acc, -box.Sale.Price)
                            : db.UpdateFame(acc, -box.Sale.Price);
                    else
                        res.GoldLeft = box.Price.Currency == 0
                            ? db.UpdateCredit(acc, -box.Price.Amount)
                            : db.UpdateFame(acc, -box.Price.Amount);

                    if (box.Sale != null && DateTime.UtcNow <= box.Sale.SaleEnd)
                        res.Currency = box.Sale.Currency;
                    else
                        res.Currency = box.Price.Currency;

                    sendMysteryBoxResult(Context.Response.OutputStream, res);

                    int[] gifts = Utils.FromCommaSepString32(res.Awards);
                    foreach (int item in gifts)
                        acc.Gifts.Add(item);

                    MySqlCommand cmd = db.CreateQuery();
                    cmd.CommandText =
                        "UPDATE accounts SET [email protected] WHERE [email protected] AND password=SHA1(@password);";
                    cmd.Parameters.AddWithValue("@uuid", Query["guid"]);
                    cmd.Parameters.AddWithValue("@password", Query["password"]);
                    cmd.Parameters.AddWithValue("@gifts", Utils.GetCommaSepString(acc.Gifts.ToArray()));
                    cmd.ExecuteNonQuery();
//.........这里部分代码省略.........
开发者ID:OryxAwakening,项目名称:Fabiano_Swagger_of_Doom,代码行数:101,代码来源:purchaseMysteryBox.cs


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