UpdateFame() public method

public UpdateFame ( Account acc, int amount ) : int
acc Account
amount int
return int
Exemplo n.º 1
0
 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;
                 foreach (var i in Players)
                 {
                     i.Value.Client.SendPacket(new SwitchMusicPacket
                     {
                         Music = "Arena"
                     });
                     i.Value.ApplyConditionEffect(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;
                 Timers.Add(new WorldTimer(1000, (world, t) => Countdown(5)));
             }
             else
             {
                 foreach (var i in Enemies)
                 {
                     if (OutOfBounds(i.Value.X, i.Value.Y))
                     {
                         LeaveWorld(i.Value);
                     }
                 }
             }
         }
     }
     else
     {
         if (Participants.Count > 0)
         {
             new Database().AddToArenaLb(Wave, Participants);
             Participants.Clear();
         }
     }
 }
Exemplo n.º 2
0
 public void Execute(Player player, string[] args)
 {
     try
     {
         if (args.Length < 2)
         {
             player.SendHelp("Use /currency <currency> <player> <amount>");
         }
         else if (args[0] == "ztokens")
         {
             var plr = RealmManager.FindPlayer(args[1]);
             using (var db = new Database())
             {
                 plr.zTokens = db.UpdateCredit(plr.Client.Account, int.Parse(args[2]));
                 plr.UpdateCount++;
                 db.Dispose();
             }
         }
         else if (args[0] == "gold")
         {
             using (var db = new Database())
             {
                 var plr = RealmManager.FindPlayer(args[1]);
                 plr.Credits = db.UpdateCredit(plr.Client.Account, int.Parse(args[2]));
                 plr.UpdateCount++;
                 db.Dispose();
             }
         }
         else if (args[0] == "fame")
         {
             var plr = RealmManager.FindPlayer(args[1]);
             using (var db = new Database())
             {
                 plr.CurrentFame = db.UpdateFame(plr.Client.Account, int.Parse(args[2]));
                 plr.UpdateCount++;
                 db.Dispose();
             }
         }
     }
     catch
     {
         player.SendError("Error!");
     }
 }
Exemplo n.º 3
0
 public void Execute(Player player, string[] args)
 {
     try
     {
         if (args.Length == 0)
         {
             player.SendHelp("Use /fame <amount>");
         }
         else
         {
             using (var db = new Database())
             {
                 player.CurrentFame = db.UpdateFame(player.Client.Account, int.Parse(args[0]));
                 player.UpdateCount++;
                 db.Dispose();
             }
         }
     }
     catch
     {
         player.SendError("Error!");
     }
 }
Exemplo n.º 4
0
        public void CreateGuild(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.Credits >= 1000)
                    {
                        using (Database db1 = new Database())
                        {
                            var cmd = db1.CreateQuery();

                            cmd.CommandText = "INSERT INTO guilds (name, members, level) VALUES (@name,@firstMember,1)";
                            cmd.Parameters.AddWithValue("@name", name);
                            cmd.Parameters.AddWithValue("@firstMember", psr.Account.AccountId);
                            if (cmd.ExecuteNonQuery() != 0)
                            {
                                Console.WriteLine("Created guild {0} with founder {1}", name, psr.Account.AccountId + " " + psr.Account.Name);
                                psr.SendPacket(new CreateGuildResultPacket()
                                {
                                    ResultMessage = "Created guild " + name.ToString() + "!",
                                    Success = true
                                });
                            }
                            else
                            {
                                Console.WriteLine("Error creating guild {0} with founder {1}", name, psr.Account.AccountId + " " + psr.Account.Name);
                                psr.SendPacket(new CreateGuildResultPacket()
                                {
                                    ResultMessage = "Error creating guild!",
                                    Success = false
                                });
                                return;
                            }
                            cmd = db1.CreateQuery();
                            cmd.CommandText = "SELECT id FROM guilds WHERE name = @name";
                            cmd.Parameters.AddWithValue("@name", name);
                            object guildId = cmd.ExecuteScalar();
                            psr.Account.Guild = new Guild()
                            {
                                Id = int.Parse(guildId.ToString()),
                                Name = name,
                                Rank = 40
                            };
                            cmd = db1.CreateQuery();
                            cmd.CommandText = "UPDATE accounts SET guild=@guildid, guildRank='40' WHERE id=@accId";
                            cmd.Parameters.AddWithValue("@guildid", guildId.ToString());
                            cmd.Parameters.AddWithValue("@accId", psr.Account.AccountId);
                            if (cmd.ExecuteNonQuery() == 0)
                            {
                                psr.SendPacket(new TextPacket()
                                {
                                    BubbleTime = 0,
                                    Name = "",
                                    Stars = -1,
                                    Text = "Unable to update account data!"
                                });
                            }
                            db1.UpdateFame(psr.Account, -1000);
                            UpdateCount++;
                        }
                    }
                    else
                    {
                        psr.SendPacket(new CreateGuildResultPacket()
                        {
                            Success = false,
                            ResultMessage = "Not enough fame!"
                        });
                    }
                }
                catch
                {
                    Console.WriteLine("Error at line 624 of Player.cs");
                    psr.SendPacket(new TextPacket()
                    {
                        Name = "",
                        Stars = -1,
                        BubbleTime = 0,
                        Text = "Error creating guild!"
                    });
                }
            }
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        public override void Tick(RealmTime time)
        {
            if (Players.Count > 0 && !Flags["finished"])
            {
                if (Flags["started"] && !Flags["counting"])
                {
                    if (Enemies.Count < 1 + Pets.Count)
                    {
                        wave++;
                        zombieAmount += Players.Count;
                        famePot += wave * 10 / 2;
                        Flags["counting"] = true;
                        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 zombie minigame has been started. Closing in 1 minute!"
                        });
                    EnterWorld(tower);
                    Flags["counting"] = true;
                    Countdown(60);
                }
                else if (Flags["finished"] && !Flags["counting"])
                {
                    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"
                        });
                        Flags["counting"] = true;
                        db.Dispose();

                    }
                }
            }

            base.Tick(time);
        }
        public void TextBoxButton(TextBoxButtonPacket pkt)
        {
            var type = pkt.Type;

            if (type == "test")
            {
                psr.SendPacket(new TextBoxPacket
                {
                    Button1 = "Yes",
                    Button2 = "No",
                    Message = "Do you want to enter the testing arena?",
                    Title = "Testing Arena Confirmation",
                    Type = "EnterTestArena"
                });
            }
            if (type == "NewClient")
            {
                psr.Disconnect();
            }
            if (type == "DecideArena")
            {
                if (pkt.Button == 1)
                {
                    psr.SendPacket(new TextBoxPacket
                    {
                        Button1 = "Enter",
                        Button2 = "Cancel",
                        Message = "Host an arena at the price of x fame?",
                        Title = "Arena Host Confirmation",
                        Type = "EnterArena2"
                    });
                }
                else
                {
                    psr.SendPacket(new TextBoxPacket
                    {
                        Button1 = "Enter",
                        Button2 = "Cancel",
                        Message = "Enter the arena solo at the price of 150 fame?",
                        Title = "Solo Arena Confirmation",
                        Type = "EnterArena1"
                    });
                }
            }
            if (type == "EnterTestArena")
            {
                if (pkt.Button == 1)
                {
                    if (Client.Account.Stats.Fame >= 150)
                    {
                        /*RealmManager.PlayerWorldMapping.TryAdd(this.AccountId, Owner);
                        psr.Reconnect(new ReconnectPacket()
                        {
                            Host = "",
                            Port = 2050,
                            GameId = world.Id,
                            Name = world.Name,
                            Key = Empty<byte>.Array,
                        });
                        */
                    }
                    else
                    {
                        SendHelp("Not Enough Fame");
                    }
                }
                else
                {
                    SendInfo("Cancelled entering arena.");
                }
            }
            if (type == "EnterArena1")
            {
                if (pkt.Button == 1)
                {
                    if (Client.Account.Stats.Fame >= 50)
                    {
                        using (var db = new Database())
                        {
                            db.UpdateFame(psr.Account, -50);
                            db.Dispose();
                        }

                        var world = RealmManager.GetWorld(World.NEXUS_ID);
                        var fworld = false;
                        foreach (var i in RealmManager.Worlds)
                            if (i.Value is BattleArenaMap)
                                if ((i.Value as BattleArenaMap).Joinable)
                                {
                                    world = i.Value;
                                    fworld = true;
                                    break;
                                }
                        if (!fworld)
                            world = RealmManager.AddWorld(new BattleArenaMap());

                        psr.Reconnect(new ReconnectPacket
                        {
                            Host = "",
                            Port = 2050,
                            GameId = world.Id,
                            Name = world.Name,
                            Key = Empty<byte>.Array,
                        });
                    }
                    else
                    {
                        SendHelp("Not Enough Fame");
                    }
                }
                else
                {
                    SendInfo("Cancelled entering arena.");
                }
            }
            if (type == "EnterArena2")
            {
                if (pkt.Button == 1)
                {
                    var world = RealmManager.GetWorld(World.NEXUS_ID);
                    var fworld = false;
                    foreach (var i in RealmManager.Worlds)
                        if (i.Value is BattleArenaMap2)
                            if ((i.Value as BattleArenaMap2).Joinable)
                            {
                                world = i.Value;
                                fworld = true;
                                break;
                            }
                    if (!fworld)
                        world = RealmManager.AddWorld(new BattleArenaMap2());

                    psr.Reconnect(new ReconnectPacket
                    {
                        Host = "",
                        Port = 2050,
                        GameId = world.Id,
                        Name = world.Name,
                        Key = Empty<byte>.Array,
                    });
                }
                else
                {
                    SendInfo("Cancelled entering arena.");
                }
            }
            if (type == "SheepHerding")
            {
                if (pkt.Button == 1)
                {
                    if (Client.Account.Stats.Fame >= 50)
                    {
                        using (var db = new Database())
                        {
                            db.UpdateFame(psr.Account, -50);
                            db.Dispose();
                        }

                        var world = RealmManager.GetWorld(World.NEXUS_ID);
                        var fworld = false;
                        foreach (var i in RealmManager.Worlds)
                            if (i.Value is Herding)
                                if ((i.Value as Herding).Joinable)
                                {
                                    world = i.Value;
                                    fworld = true;
                                    break;
                                }
                        if (!fworld)
                            world = RealmManager.AddWorld(new Herding());

                        psr.Reconnect(new ReconnectPacket
                        {
                            Host = "",
                            Port = 2050,
                            GameId = world.Id,
                            Name = world.Name,
                            Key = Empty<byte>.Array,
                        });
                    }
                    else
                    {
                        SendHelp("Not Enough Fame");
                    }
                }
                else
                {
                    SendInfo("Cancelled entering sheep herding.");
                }
            }
            if (type == "Zombies")
            {
                if (pkt.Button == 1)
                {
                    if (Client.Account.Stats.Fame >= 10)
                    {
                        using (var db = new Database())
                        {
                            db.UpdateFame(psr.Account, -10);
                            db.Dispose();
                        }

                        var world = RealmManager.GetWorld(World.NEXUS_ID);
                        var fworld = false;
                        foreach (var i in RealmManager.Worlds)
                            if (i.Value is ZombieMG)
                                if ((i.Value as ZombieMG).Joinable)
                                {
                                    world = i.Value;
                                    fworld = true;
                                    break;
                                }
                        if (!fworld)
                            world = RealmManager.AddWorld(new ZombieMG());

                        psr.Reconnect(new ReconnectPacket
                        {
                            Host = "",
                            Port = 2050,
                            GameId = world.Id,
                            Name = world.Name,
                            Key = Empty<byte>.Array,
                        });
                    }
                    else
                    {
                        SendHelp("Not Enough Fame");
                    }
                }
                else
                {
                    SendInfo("Cancelled entering zombies.");
                }
            }
            if (type == "SlotMachine1")
            {
                if (pkt.Button == 1)
                {
                    if (Client.Account.Stats.Fame >= 10)
                    {
                        using (var db = new Database())
                        {
                            db.UpdateFame(psr.Account, -10);
                            db.Dispose();
                        }
                    var weaponsT5 = TierLoot.WeaponItems[5].ToList();
                    var weaponsT6 = TierLoot.WeaponItems[6].ToList();
                    var weaponsT7 = TierLoot.WeaponItems[7].ToList();
                    var abilitiesT3 = TierLoot.AbilityItems[2].ToList();
                    var ringsT3 = TierLoot.RingItems[3].ToList();
                    var armorT6 = TierLoot.ArmorItems[6].ToList();
                    var armorT7 = TierLoot.ArmorItems[7].ToList();
                    var armorT8 = TierLoot.ArmorItems[8].ToList();

                    var calculator = Random.Next(1, 1000);
                    if (calculator <= 600)
                    {
                        SendHelp("Better luck next time!");
                    }
                    else if (calculator <= 700 && calculator > 600)
                    {
                        SendHelp("Congratulations! You won a T5 Weapon!");

                        weaponsT5.Shuffle();

                        var container = new Container(0x0507, 1000*60, true) {BagOwner = psr.Account.AccountId};
                        container.Inventory[0] = weaponsT5[0];
                        container.Move(X + (float) ((invRand.NextDouble()*2 - 1)*0.5),
                            Y + (float) ((invRand.NextDouble()*2 - 1)*0.5));
                        container.Size = 75;
                        Owner.EnterWorld(container);
                    }
                    else if (calculator <= 750 && calculator > 700)
                    {
                        SendHelp("Congratulations! You won a T6 Weapon!");

                        weaponsT6.Shuffle();

                        var container = new Container(0x0507, 1000*60, true) {BagOwner = psr.Account.AccountId};
                        container.Inventory[0] = weaponsT6[0];
                        container.Move(X + (float) ((invRand.NextDouble()*2 - 1)*0.5),
                            Y + (float) ((invRand.NextDouble()*2 - 1)*0.5));
                        container.Size = 75;
                        Owner.EnterWorld(container);
                    }
                    else if (calculator <= 787.5 && calculator > 775)
                    {
                        SendHelp("Congratulations! You won a T7 Weapon!");

                        weaponsT7.Shuffle();

                        var container = new Container(0x0507, 1000*60, true) {BagOwner = psr.Account.AccountId};
                        container.Inventory[0] = weaponsT7[0];
                        container.Move(X + (float) ((invRand.NextDouble()*2 - 1)*0.5),
                            Y + (float) ((invRand.NextDouble()*2 - 1)*0.5));
                        container.Size = 75;
                        Owner.EnterWorld(container);
                    }
                    else if (calculator <= 800 && calculator > 787.5)
                    {
                        SendHelp("Congratulations! You won a T3 Ability!");

                        abilitiesT3.Shuffle();

                        var container = new Container(0x0507, 1000*60, true) {BagOwner = psr.Account.AccountId};
                        container.Inventory[0] = abilitiesT3[0];
                        container.Move(X + (float) ((invRand.NextDouble()*2 - 1)*0.5),
                            Y + (float) ((invRand.NextDouble()*2 - 1)*0.5));
                        container.Size = 75;
                        Owner.EnterWorld(container);
                    }
                    else if (calculator <= 850 && calculator > 800)
                    {
                        SendHelp("Congratulations! You won a T6 Armor!");

                        armorT6.Shuffle();

                        var container = new Container(0x0507, 1000*60, true) {BagOwner = psr.Account.AccountId};
                        container.Inventory[0] = armorT6[0];
                        container.Move(X + (float) ((invRand.NextDouble()*2 - 1)*0.5),
                            Y + (float) ((invRand.NextDouble()*2 - 1)*0.5));
                        container.Size = 75;
                        Owner.EnterWorld(container);
                    }
                    else if (calculator <= 875 && calculator > 850)
                    {
                        SendHelp("Congratulations! You won a T7 Armor!");

                        armorT7.Shuffle();

                        var container = new Container(0x0507, 1000*60, true) {BagOwner = psr.Account.AccountId};
                        container.Inventory[0] = armorT7[0];
                        container.Move(X + (float) ((invRand.NextDouble()*2 - 1)*0.5),
                            Y + (float) ((invRand.NextDouble()*2 - 1)*0.5));
                        container.Size = 75;
                        Owner.EnterWorld(container);
                    }
                    else if (calculator <= 887.5 && calculator > 875)
                    {
                        SendHelp("Congratulations! You won a T8 Armor!");

                        armorT8.Shuffle();

                        var container = new Container(0x0507, 1000*60, true) {BagOwner = psr.Account.AccountId};
                        container.Inventory[0] = armorT8[0];
                        container.Move(X + (float) ((invRand.NextDouble()*2 - 1)*0.5),
                            Y + (float) ((invRand.NextDouble()*2 - 1)*0.5));
                        container.Size = 75;
                        Owner.EnterWorld(container);
                    }
                    else if (calculator <= 900 && calculator > 887.5)
                    {
                        SendHelp("Congratulations! You won a T3 Ring!");

                        ringsT3.Shuffle();

                        var container = new Container(0x0507, 1000*60, true) {BagOwner = psr.Account.AccountId};
                        container.Inventory[0] = ringsT3[0];
                        container.Move(X + (float) ((invRand.NextDouble()*2 - 1)*0.5),
                            Y + (float) ((invRand.NextDouble()*2 - 1)*0.5));
                        container.Size = 75;
                        Owner.EnterWorld(container);
                    }
                    else if (calculator <= 905 && calculator > 900)
                    {
                        SendHelp("Too bad! You only got 1 fame!");
                        Client.Database.UpdateFame(Client.Account, 1);
                        Fame += 1;
                        UpdateCount++;
                    }
                    else if (calculator <= 910 && calculator > 905)
                    {
                        SendHelp("Too bad! You only got 5 fame!");
                        Client.Database.UpdateFame(Client.Account, 5);
                        Fame += 5;
                        UpdateCount++;
                    }
                    else if (calculator <= 940 && calculator > 910)
                    {
                        SendHelp("You won back the fame you paid!");
                        Client.Database.UpdateFame(Client.Account, 10);
                        Fame += 10;
                        UpdateCount++;
                    }
                    else if (calculator <= 970 && calculator > 940)
                    {
                        SendHelp("Nice! You won 25 fame!");
                        Client.Database.UpdateFame(Client.Account, 25);
                        Fame += 25;
                        UpdateCount++;
                    }
                    else if (calculator <= 985 && calculator > 970)
                    {
                        SendHelp("Nice! You won 50 fame!");
                        Client.Database.UpdateFame(Client.Account, 50);
                        Fame += 50;
                        UpdateCount++;
                    }
                    else if (calculator <= 990 && calculator > 985)
                    {
                        SendHelp("Very Nice! You won 100 fame!");
                        Client.Database.UpdateFame(Client.Account, 100);
                        Fame += 100;
                        UpdateCount++;
                    }
                    else if (calculator <= 994 && calculator > 990)
                    {
                        SendHelp("Awesome! You won 500 fame!");
                        Client.Database.UpdateFame(Client.Account, 500);
                        Fame += 500;
                        UpdateCount++;
                    }
                    else if (calculator <= 997 && calculator > 994)
                    {
                        SendHelp("Amazing! You won 1000 fame!");
                        Client.Database.UpdateFame(Client.Account, 1000);
                        Fame += 1000;
                        UpdateCount++;
                    }
                    else if (calculator <= 999 && calculator > 997)
                    {
                        SendHelp("Amazing! You won 5000 fame!");
                        Client.Database.UpdateFame(Client.Account, 5000);
                        Fame += 5000;
                        UpdateCount++;
                    }
                    else if (calculator <= 1000 && calculator > 999)
                    {
                        SendHelp("Incredible! You won the 10000 fame jackpot!");
                        foreach (var i in RealmManager.Clients.Values)
                            i.SendPacket(new TextPacket
                            {
                                BubbleTime = 0,
                                Stars = -1,
                                Name = "#Announcement",
                                Text = Name + " has won the 10000 Fame jackpot on the bronze slot machines!"
                            });
                        Client.Database.UpdateFame(Client.Account, 10000);
                        Fame += 10000;
                        UpdateCount++;
                    }
                    psr.SendPacket(new BuyResultPacket
                    {
                        Result = 0
                    });
                }
                                            else
                    {
                        SendHelp("Not Enough Fame");
                    }
                }
                else
                {
                    SendInfo("Canceled");
                    psr.SendPacket(new BuyResultPacket
                    {
                        Result = 0
                    });

                }
            }
        }
Exemplo n.º 8
0
 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);
 }
        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 gifts=@gifts WHERE uuid=@uuid 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 uuid=@uuid 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;
        }
Exemplo n.º 10
0
        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);
        }
        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 gifts=@gifts WHERE uuid=@uuid 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();
                }
                else
                    using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                        wtr.WriteLine("<Error>Account not found</Error>");
            }
        }
        public void UsePortal(RealmTime time, UsePortalPacket pkt)
        {
            Entity entity = Owner.GetEntity(pkt.ObjectId);
            if (entity == null || !entity.Usable) return;
            World world = null;
            Player player = this;
            Portal p = null;
            if (entity is Portal)
            {
                p = entity as Portal;
                world = p.WorldInstance;
            }
            if (world == null)
            {
                if (p != null)
                {
                    bool setWorldInstance = true;
                    string d = "";
                    if (XmlDatas.IdToDungeon.TryGetValue(entity.ObjectType, out d))
                    {
                        world = RealmManager.AddWorld(new XMLWorld(XmlDatas.DungeonDescs[d]));
                    }
                    else
                    {
                        switch (entity.ObjectType) //handling default case for not found. Add more as implemented
                        {
                            
                            case 0x0703: //portal of cowardice
                                {
                                    if (RealmManager.PlayerWorldMapping.ContainsKey(this.AccountId))  //may not be valid, realm recycled?
                                        world = RealmManager.PlayerWorldMapping[this.AccountId];  //also reconnecting to vault is a little unexpected
                                    else if (world.Id == -5 || world.Id == -11)
                                        world = RealmManager.GetWorld(World.NEXUS_ID);
                                    else
                                        world = RealmManager.GetWorld(World.NEXUS_ID);
                                } break;
                            case 0x0712:
                                world = RealmManager.GetWorld(World.NEXUS_ID); break;
                            case 0x071d:
                                world = RealmManager.GetWorld(World.NEXUS_ID); break;
                            case 0x071c:
                                world = RealmManager.Monitor.GetRandomRealm(); break;
                            case 0x0720:
                                world = RealmManager.PlayerVault(psr);
                                setWorldInstance = false; break;
                            case 0x071e:
                                world = RealmManager.AddWorld(new Kitchen()); break;
                            case 0x0ffa: //these need to match IDs
                                //world = RealmManager.GetWorld(World.GauntletMap); break; //this creates a singleton dungeon
                                world = RealmManager.AddWorld(new Island()); break; //this allows each dungeon to be unique
                            case 0x0ffc:
                                world = RealmManager.AddWorld(new WineCellarMap()); break;
                            case 0x1900:
                                world = RealmManager.AddWorld(new ArenaMap()); break;
                            case 0x0730:
                                world = RealmManager.AddWorld(new OceanTrench()); break;
                            case 0x070c:
                                world = RealmManager.AddWorld(new SpriteWorld()); break;
                            case 0x071b:
                                world = RealmManager.AddWorld(new Abyss()); break;
                            case 0x071a:
                                world = RealmManager.AddWorld(new UndeadLair()); break;
                            case 0x1901:
                                world = RealmManager.AddWorld(new VoidWorld()); break;
                            case 0x072c:
                                world = RealmManager.AddWorld(new TombMap()); break;
                            case 0x0742:
                                world = RealmManager.AddWorld(new BeachZone()); break;
                            case 0x0718:
                                world = RealmManager.AddWorld(new SnakePit()); break;
                            case 0x0890:
                                world = RealmManager.AddWorld(new MadLabMap()); break;
                            case 0x1905:
                                if (player.Client.Account.Stats.TotalFame > 100)
                                {
                                    using (var db = new Database())
                                    {
                                       
                                        world = RealmManager.AddWorld(new BattleArenaMap());
                                        setWorldInstance = false;
                                        db.UpdateFame(player.Client.Account, -100);
                                    }
                                }
                                else
                                {
                                    player.SendError("Not Enough Fame!");
                                }
                                break;
                                
                                
                            case 0x1919:
                                world = RealmManager.AddWorld(new Secret()); break;
                            case 0x1923:
                                world = RealmManager.AddWorld(new ZombieMap()); break;
                            default: SendError("Portal Not Implemented!"); break;
                            case 0x195d:
                                world = RealmManager.AddWorld(new MarketMap()); break;
                            case 0x070d:
                                world = RealmManager.Monitor.GetRandomRealm(); break;
                            case 0x070e:
                                world = RealmManager.Monitor.GetRandomRealm(); break;
                            case 0x0704:
                                world = RealmManager.Monitor.GetRandomRealm(); break;
                            case 0x753E:
                                world = RealmManager.AddWorld(new LairofDraconis()); break;
                            case 0x7002:
                                world = RealmManager.AddWorld(new PartyCellarMap()); break;
                           

                        }
                    }
                    if(setWorldInstance)
                        p.WorldInstance = world;
                }
                else
                {
                    switch (entity.ObjectType) // Special Portals that cannot be the portal class
                    {
                        case 0x072f:
                            world =  RealmManager.GuildHallWorld(Guild);
                            break;
                        default: psr.SendPacket(new TextPacket
                        {
                            BubbleTime = 0,
                            Stars = -1,
                            Name = "",
                            Text = "Semi-Portal Not Implemented!"
                        }); break;
                    }
                }
            }

            //used to match up player to last realm they were in, to return them to it. Sometimes is odd, like from Vault back to Vault...
            if (RealmManager.PlayerWorldMapping.ContainsKey(this.AccountId))
            {
                World tempWorld;
                RealmManager.PlayerWorldMapping.TryRemove(this.AccountId, out tempWorld);
            }
            RealmManager.PlayerWorldMapping.TryAdd(this.AccountId, Owner);
            psr.Reconnect(new ReconnectPacket()
            {
                Host = "",
                Port = 2050,
                GameId = world.Id,
                Name = world.Name,
                Key = Empty<byte>.Array,
            });
        }