示例#1
0
        protected override IntPtr OnPostedNotification(IntPtr wparam, IntPtr lparam)
        {
            Utils.Assert_UIThread();

            NOTIFICATION what = (NOTIFICATION)wparam.ToInt32();

            switch (what)
            {
            case NOTIFICATION.LOG_ARRIVED:
                _sdh.OnNotify_LOG_ARRIVED();
                break;

            case NOTIFICATION.CONTENT_CHANGED:
                Inspecting.OnPostedContentChange();
                break;

            case NOTIFICATION.LOAD_PAGE:
                State.OnPostedLoadPage();
                break;

            case NOTIFICATION.CLOSE_PAGE:
                State.ClosePage();
                break;
            }
            return(IntPtr.Zero);
        }
示例#2
0
        public (bool isCreated, int notiId) Create(NotificationApiModel notification, List <USER> users)
        {
            var newNotification = new NOTIFICATION();

            newNotification.CreatedAt           = DateTime.Now;
            newNotification.Module              = notification.module;
            newNotification.ModuleObjectID      = notification.moduleObjectId;
            newNotification.Submodule           = notification.subModule;
            newNotification.SubmoduleObjectID   = notification.subModuleObjectId;
            newNotification.NotificationContent = notification.content;
            newNotification.NotificationTitle   = notification.title;
            try
            {
                db.NOTIFICATIONs.Add(newNotification);
                foreach (var user in users)
                {
                    if (user != null)
                    {
                        var userNotification = new USER_NOTIFICATION();
                        userNotification.IsRead       = false;
                        userNotification.NOTIFICATION = newNotification;
                        userNotification.NOTIFICATION = newNotification;
                        userNotification.USER_ID      = user.ID;
                        db.USER_NOTIFICATION.Add(userNotification);
                    }
                }
                db.SaveChanges();
                return(true, newNotification.ID);
            }
            catch
            {
                throw;
            }
        }
示例#3
0
        public bool AddNotification(NOTIFICATION notification)
        {
            bool returnValue = false;

            notification.CREATED_DATE = DateTime.Now;
            returnValue = NotifRepo.Add(notification);
            return(returnValue);
        }
        public NOTIFICATION GetNotificationForLike(LIKE like)
        {
            NOTIFICATION notification = new NOTIFICATION();

            using (var context = new PastebookEntities())
            {
                notification = context.NOTIFICATIONs.FirstOrDefault(n => n.POST_ID == like.POST_ID && n.SENDER_ID == like.LIKED_BY && n.NOTIF_TYPE == "L");
            }

            return(notification);
        }
        public NOTIFICATION GetNotificationForFriendRequest(FRIEND friend)
        {
            NOTIFICATION notification = new NOTIFICATION();

            using (var context = new PastebookEntities())
            {
                notification = context.NOTIFICATIONs.FirstOrDefault(n => n.SENDER_ID == friend.USER_ID && n.RECEIVER_ID == friend.FRIEND_ID && n.NOTIF_TYPE == "F");
            }

            return(notification);
        }
 public ActionResult DeleteConfirmed(int id)
 {
     if (Request.IsAuthenticated)
     {
         NOTIFICATION nOTIFICATION = db.NOTIFICATIONs.Find(id);
         db.NOTIFICATIONs.Remove(nOTIFICATION);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
示例#7
0
        public Guid CreateNotificationComment(Guid?From, Guid?To, string Url, string Type)
        {
            var data = new NOTIFICATION();

            data.NOTIFICATION_Id      = Guid.NewGuid();
            data.NOTIFICATION_From    = From;
            data.NOTIFICATION_To      = To;
            data.NOTIFICATION_Status  = false;
            data.NOTIFICATION_Time    = DateTime.Now;
            data.NOTIFICATION_Content = "commented on the " + Type.ToLower() + ".";
            data.NOTIFICATION_Url     = Url;
            db.NOTIFICATIONs.Add(data);
            db.SaveChanges();
            return(data.NOTIFICATION_Id);
        }
        public bool Initialize(NOTIFICATION thisnotification, string NewAddName)
        {
            if (thisnotification.ADDNAME != NewAddName)
            {
                var fieldsToUpdate = new List <string>
                {
                    "ADDNAME"
                };

                thisnotification.ADDNAME = NewAddName;

                UpdateNotification(thisnotification, fieldsToUpdate);
            }

            return(true);
        }
示例#9
0
        public int LikePost(int postID, int userID, string status)
        {
            GenericDataAccess <LIKE>         dataAccessLike         = new GenericDataAccess <LIKE>();
            GenericDataAccess <NOTIFICATION> dataAccessNotification = new GenericDataAccess <NOTIFICATION>();
            int result;
            int posterID = postDataAccess.GetProfileOwnerID(postID);

            var like = new LIKE()
            {
                LIKED_BY = userID,
                POST_ID  = postID
            };

            if (status == "like")
            {
                result = dataAccessLike.Create(like);

                if (result == 1 && userID != posterID)
                {
                    NOTIFICATION notification = new NOTIFICATION()
                    {
                        NOTIF_TYPE   = "L",
                        POST_ID      = postID,
                        RECEIVER_ID  = posterID,
                        SENDER_ID    = userID,
                        CREATED_DATE = DateTime.Now,
                        SEEN         = "N"
                    };

                    dataAccessNotification.Create(notification);
                }
            }
            else
            {
                result = dataAccessLike.Delete(likeDataAccess.GetLike(like));

                if (result == 1 && userID != posterID)
                {
                    dataAccessNotification.Delete(notificationDataAccess.GetNotificationForLike(like));
                }
            }

            return(result);
        }
 public ActionResult Edit([Bind(Include = "notifID,recipients,type,trigger,content,created_on,user_recipient,user_sender,active,expires")] NOTIFICATION nOTIFICATION)
 {
     if (Request.IsAuthenticated)
     {
         if (ModelState.IsValid)
         {
             db.Entry(nOTIFICATION).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         ViewBag.user_recipient = new SelectList(db.USERs, "userID", "fname", nOTIFICATION.user_recipient);
         ViewBag.user_sender    = new SelectList(db.USERs, "userID", "fname", nOTIFICATION.user_sender);
         return(View(nOTIFICATION));
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
示例#11
0
        private void UnlockPortal(ActivateEffect eff)
        {
            Portal portal = this.GetNearestEntity(5, Manager.GameData.IdToObjectType[eff.LockedName]) as Portal;

            Message[] packets = new Message[3];
            packets[0] = new SHOWEFFECT
            {
                EffectType = EffectType.Nova,
                Color      = new ARGB(0xFFFFFF),
                PosA       = new Position {
                    X = 5
                },
                TargetId = Id
            };

            if (portal == null)
            {
                return;
            }

            portal.Unlock(eff.DungeonName);

            packets[1] = new NOTIFICATION
            {
                Color = new ARGB(0x00FF00),
                Text  =
                    "{\"key\":\"blank\",\"tokens\":{\"data\":\"Unlocked by " +
                    Name + "\"}}",
                ObjectId = Id
            };

            packets[2] = new TEXT
            {
                BubbleTime = 0,
                Stars      = -1,
                Name       = "",
                Text       = eff.DungeonName + " Unlocked by " + Name + ".",
                NameColor  = 0x123456,
                TextColor  = 0x123456
            };

            BroadcastSync(packets);
        }
示例#12
0
 public void AddNotification(List <NOTIFICATION> danhsachnotification)
 {
     foreach (var item in danhsachnotification)
     {
         NOTIFICATION thongbao = new NOTIFICATION();
         thongbao.NGUOI_DUNG         = item.NGUOI_DUNG;
         thongbao.NGAY_THONG_BAO     = DateTime.Now;
         thongbao.LINK_THONG_BAO     = item.LINK_THONG_BAO;
         thongbao.NOI_DUNG_THONG_BAO = item.NOI_DUNG_THONG_BAO;
         db.NOTIFICATIONS.Add(thongbao);
     }
     try
     {
         db.SaveChanges();
     }
     catch (DbUpdateConcurrencyException)
     {
         throw;
     }
 }
 // GET: Notification/Details/5
 public ActionResult Details(int?id)
 {
     if (Request.IsAuthenticated)
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         NOTIFICATION nOTIFICATION = db.NOTIFICATIONs.Find(id);
         if (nOTIFICATION == null)
         {
             return(HttpNotFound());
         }
         return(View(nOTIFICATION));
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
 // GET: Notification/Edit/5
 public ActionResult Edit(int?id)
 {
     if (Request.IsAuthenticated)
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         NOTIFICATION nOTIFICATION = db.NOTIFICATIONs.Find(id);
         if (nOTIFICATION == null)
         {
             return(HttpNotFound());
         }
         ViewBag.user_recipient = new SelectList(db.USERs, "userID", "fname", nOTIFICATION.user_recipient);
         ViewBag.user_sender    = new SelectList(db.USERs, "userID", "fname", nOTIFICATION.user_sender);
         return(View(nOTIFICATION));
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
示例#15
0
        public int CommentToPost(int postID, int userID, string content)
        {
            GenericDataAccess <COMMENT>      dataAccessComment      = new GenericDataAccess <COMMENT>();
            GenericDataAccess <NOTIFICATION> dataAccessNotification = new GenericDataAccess <NOTIFICATION>();
            int posterID = postDataAccess.GetProfileOwnerID(postID);
            int result   = 0;

            if (!string.IsNullOrEmpty(content) && !string.IsNullOrWhiteSpace(content) && content.Length <= 1000)
            {
                var comment = new COMMENT()
                {
                    POSTER_ID    = userID,
                    POST_ID      = postID,
                    DATE_CREATED = DateTime.Now,
                    CONTENT      = content.Trim()
                };

                result = dataAccessComment.Create(comment);

                if (result == 1 && userID != posterID)
                {
                    var notification = new NOTIFICATION()
                    {
                        NOTIF_TYPE   = "C",
                        POST_ID      = postID,
                        COMMENT_ID   = comment.ID,
                        RECEIVER_ID  = posterID,
                        SENDER_ID    = userID,
                        CREATED_DATE = DateTime.Now,
                        SEEN         = "N"
                    };

                    dataAccessNotification.Create(notification);
                }
            }

            return(result);
        }
示例#16
0
        public int AddFriend(string username, int userID)
        {
            var user = new USER();
            GenericDataAccess <FRIEND>       dataAccessFriend       = new GenericDataAccess <FRIEND>();
            GenericDataAccess <NOTIFICATION> dataAccessNotification = new GenericDataAccess <NOTIFICATION>();
            int result;

            user = userDataAccess.GetUser(null, username);

            var friend = new FRIEND()
            {
                USER_ID      = userID,
                FRIEND_ID    = user.ID,
                REQUEST      = "Y",
                CREATED_DATE = DateTime.Now,
                BLOCKED      = "N"
            };

            result = dataAccessFriend.Create(friend);

            if (result == 1)
            {
                var notification = new NOTIFICATION()
                {
                    NOTIF_TYPE   = "F",
                    RECEIVER_ID  = user.ID,
                    SENDER_ID    = userID,
                    CREATED_DATE = DateTime.Now,
                    SEEN         = "N"
                };

                dataAccessNotification.Create(notification);
            }

            return(result);
        }
示例#17
0
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            var player    = host.GetPlayerOwner();
            var pet       = player.Pet;
            var hatchling = player.HatchlingPet;

            if (hatchling)
            {
                return;
            }

            if (player.Owner == null || pet == null || host == null)
            {
                pet.Owner.LeaveWorld(host);
                return;
            }

            if (host.Owner.SafePlace || !player.EnablePetAttack)
            {
                return;
            }

            var cool = (int?)state ?? -1;

            Status = CycleStatus.NotStarted;

            if (cool <= 0)
            {
                if (player.HasConditionEffect(ConditionEffectIndex.Sick) || player.HasConditionEffect(ConditionEffectIndex.PetDisable))
                {
                    return;
                }

                var stars = player.Stars;

                if (pet.GetNearestEntity(12, false, enemy => enemy is Enemy && pet.Dist(enemy) <= 12) is Enemy target && target.ObjectDesc.Enemy)
                {
                    var desc = pet.ObjectDesc.Projectiles[projectileIndex];
                    var a    = fixedAngle ?? (target == null ? defaultAngle.Value : Math.Atan2(target.Y - pet.Y, target.X - pet.X));
                    a += angleOffset;

                    var variance = 0;

                    if (stars == 70)
                    {
                        variance = 7000;
                    }
                    else
                    {
                        variance = player.Stars * 100;
                    }

                    cool = special ? cool = coolDown.Next(Random) : (7750 - variance); // max 750ms cooldown if not special

                    var rnd     = new Random();
                    var min     = 0;
                    var max     = 100;
                    var success = stars + 30;
                    var rng     = rnd.Next(min, max);

                    if (rng > success)
                    {
                        var _outgoing     = new List <Message>();
                        var _effect       = new SHOWEFFECT();
                        var _position     = new Position();
                        var _notification = new NOTIFICATION();

                        _position.X = .25f;
                        _position.Y = 2 / _position.X;

                        _effect.Color      = new ARGB(0xFF0000);
                        _effect.EffectType = EffectType.Flash;
                        _effect.PosA       = _position;
                        _effect.TargetId   = pet.Id;

                        _outgoing.Add(_effect);

                        _notification.Color    = new ARGB(0xFFFFFF);
                        _notification.ObjectId = pet.Id;
                        _notification.Text     = "{\"key\":\"blank\",\"tokens\":{\"data\":\"Miss!\"}}";

                        _outgoing.Add(_notification);

                        pet.Owner.BroadcastMessage(_outgoing, null);

                        state = cool;
                        return;
                    }

                    var dmg        = rnd.Next(desc.MinDamage, desc.MaxDamage);
                    var startAngle = a - shootAngle * (count - 1) / 2;
                    var prjPos     = new Position()
                    {
                        X = pet.X, Y = pet.Y
                    };
                    var prj = player.CreateProjectile(desc, pet.ObjectType, dmg, time.TotalElapsedMs, prjPos, (float)startAngle);

                    player.Owner.Projectiles.TryAdd(prj, null);

                    player.Owner.EnterWorld(prj);

                    var _outgoingMessages = new List <Message>();
                    var _shoot            = new ENEMYSHOOT
                    {
                        BulletId   = 0,
                        OwnerId    = pet.Id,
                        Position   = prjPos,
                        Angle      = prj.Angle,
                        Damage     = 0,
                        BulletType = 0,
                        AngleInc   = (float)shootAngle,
                        NumShots   = 0
                    };
                    var _shoot2 = new SERVERPLAYERSHOOT
                    {
                        BulletId      = prj.ProjectileId,
                        OwnerId       = player.Id,
                        ContainerType = pet.ObjectType,
                        StartingPos   = prj.BeginPos,
                        Angle         = prj.Angle,
                        Damage        = (short)prj.Damage
                    };

                    _outgoingMessages.Add(_shoot); // visual, display no animation only activate pet set alt index
                    _outgoingMessages.Add(_shoot2);

                    player.Owner.BroadcastMessage(_outgoingMessages, null);

                    player.FameCounter.Shoot(prj);

                    Status = CycleStatus.Completed;
                }
                else
                {
                    return;
                }
            }
示例#18
0
        protected override void TickCore(Entity host, RealmTime time, ref object state)
        {
            FollowState s;

            if (state == null)
            {
                s = new FollowState();
            }
            else
            {
                s = (FollowState)state;
            }

            Status = CycleStatus.NotStarted;

            Player player                = host.GetPlayerOwner();
            Entity pet                   = player.Pet;
            bool   hatchling             = player.HatchlingPet;
            bool   hatchlingNotification = player.HatchlingNotification;

            if (hatchling && !hatchlingNotification)
            {
                NOTIFICATION _notification = new NOTIFICATION
                {
                    Color    = new ARGB(0xFFFFFF),
                    ObjectId = host.Id,
                    Text     = "{\"key\":\"blank\",\"tokens\":{\"data\":\"New Pet!\"}}"
                };

                host.Owner.BroadcastMessage(_notification, null);

                player.HatchlingNotification = true;

                player.SendInfo("Please, leave vault to activate your pet (HP healing, MP healing, follow and shoot behaviors).");
                return;
            }

            if (player.Owner == null || pet == null || host == null)
            {
                pet.Owner.LeaveWorld(host);
                return;
            }

            Vector2 vect = new Vector2(player.X - pet.X, player.Y - pet.Y);

            switch (s.State)
            {
            case F.DontKnowWhere:
                if (s.RemainingTime > 0)
                {
                    s.RemainingTime -= time.ElapsedMsDelta;
                }
                else
                {
                    s.State = F.Acquired;
                }
                break;

            case F.Acquired:
                if (player == null)
                {
                    s.State         = F.DontKnowWhere;
                    s.RemainingTime = 0;
                    break;
                }
                if (s.RemainingTime > 0)
                {
                    s.RemainingTime -= time.ElapsedMsDelta;
                }

                vect = new Vector2(player.X - pet.X, player.Y - pet.Y);

                if (vect.Length > 1 && vect.Length <= 20)
                {
                    float dist = host.EntitySpeed(player.Stats[4] / 10, time);

                    if (vect.Length > 2 && vect.Length <= 3.5)
                    {
                        dist *= 1.75f;
                    }
                    else if (vect.Length > 3.5 && vect.Length <= 5)
                    {
                        dist *= 2f;
                    }
                    else if (vect.Length > 5 && vect.Length <= 6)
                    {
                        dist *= 2.25f;
                    }
                    else if (vect.Length > 6 && vect.Length <= 7)
                    {
                        dist *= 2.75f;
                    }
                    else if (vect.Length > 7 && vect.Length <= 10)
                    {
                        dist *= 3f;
                    }
                    else if (vect.Length > 10 && vect.Length <= 20)
                    {
                        dist *= 3.25f;
                    }

                    Status = CycleStatus.InProgress;
                    vect.Normalize();
                    pet.ValidateAndMove(pet.X + vect.X * dist, pet.Y + vect.Y * dist);
                    pet.UpdateCount++;
                }

                break;
            }

            state = s;
        }
示例#19
0
        public override void Commands(Player player, string command)
        {
            string callback = null;
            string task     = null;

            var isTask = false;

            if (command.Length >= 6)
            {
                var taskStart         = command;
                var taskOriginalNames = GameTask.Tasks.Keys.ToList();
                var taskToLowerNames  = taskOriginalNames.Select(names => names.ToLower()).ToList();

                if (taskStart.Contains("start "))
                {
                    taskStart = taskStart.Substring(6);
                }

                task   = taskToLowerNames.Contains(taskStart) ? taskOriginalNames.FirstOrDefault(name => name.ToLower() == taskStart) : null;
                isTask = task != null;
            }

            var acc  = player.Client.Account;
            var cost = player.GetBlessingPrice();

            if (!isTask)
            {
                switch (command)
                {
                    #region "Uptime"
                case "uptime":
                {
                    TimeSpan uptime     = DateTime.Now - GameServer.Uptime;
                    double   thisUptime = uptime.TotalMinutes;
                    if (thisUptime <= 1)
                    {
                        callback = "Server started recently.";
                    }
                    else if (thisUptime > 1 && thisUptime <= 59)
                    {
                        callback = string.Format("Uptime: {0}{1}{2}{3}.",
                                                 $"{uptime.Minutes:n0}",
                                                 (uptime.Minutes >= 1 && uptime.Minutes < 2) ? " minute" : " minutes",
                                                 uptime.Seconds < 1 ? "" : $" and {uptime.Seconds:n0}",
                                                 uptime.Seconds < 1 ? "" : (uptime.Seconds >= 1 && uptime.Seconds < 2) ? " second" : " seconds");
                    }
                    else
                    {
                        callback = string.Format("Uptime: {0}{1}{2}{3}{4}{5}.",
                                                 $"{uptime.Hours:n0}",
                                                 (uptime.Hours >= 1 && uptime.Hours < 2) ? " hour" : " hours",
                                                 uptime.Minutes < 1 ? "" : $", {uptime.Minutes:n0}",
                                                 uptime.Minutes < 1 ? "" : (uptime.Minutes >= 1 && uptime.Minutes < 2) ? " minute" : " minutes",
                                                 uptime.Seconds < 1 ? "" : $" and {uptime.Seconds:n0}",
                                                 uptime.Seconds < 1 ? "" : (uptime.Seconds >= 1 && uptime.Seconds < 2) ? " second" : " seconds");
                    }
                }
                break;

                    #endregion
                    #region "Online"
                case "online":
                {
                    int serverMaxUsage     = Settings.NETWORKING.MAX_CONNECTIONS;
                    int serverCurrentUsage = GameServer.Manager.GetManager.Clients.Count;
                    int worldCurrentUsage  = player.Owner.Players.Keys.Count;
                    callback = $"Server: {serverCurrentUsage}/{serverMaxUsage} player{(serverCurrentUsage > 1 ? "s" : "")} | {player.Owner.Name}: {worldCurrentUsage} player{(worldCurrentUsage > 1 ? "s" : "")}.";
                }
                break;

                    #endregion
                    #region "Tasks"
                case "task":
                case "tasks":
                    callback = "Yeah! There are several tasks to do in-game and you can also receive wonderful rewards! Do you want more 'tasks info'?";
                    break;

                case "task info":
                case "tasks info":
                    callback = "The tasks are based in star requirement and some could be repeated. Tell me when you are 'ready' to begin any of them.";
                    break;

                case "ready":
                    var gameTasks     = SplitList(GameTask.Tasks.Keys.ToList(), 5).ToList();
                    var gameTaskNames = new List <string>();

                    foreach (var i in gameTasks)
                    {
                        gameTaskNames.Add(Utils.ToCommaSepString(i.ToArray()));
                    }

                    player.SendHelp("Tasks:");

                    foreach (var j in gameTaskNames)
                    {
                        player.SendHelp($"- {j}");
                    }

                    callback = "So far I have the following tasks, check your chat box and say the name of task to me to start. Remember, you can only handle one task per time until completed.";
                    break;

                case "task status":
                    if (player.ActualTask == null)
                    {
                        callback = "You are in none task at this moment.";
                    }
                    else
                    {
                        var getTaskMonsters = player.MonsterCaches.Where(monster => monster.TaskLimit != -1);
                        var taskData        = new List <string>();

                        foreach (var i in GameTask.Tasks[player.ActualTask].MonsterDatas)
                        {
                            var mob = getTaskMonsters.FirstOrDefault(monster => monster.ObjectId == i.ObjectId);

                            if (mob == null)
                            {
                                taskData.Add($"- [0/{i.Total}] Defeat {i.Total} x {i.ObjectId}.");
                            }
                            else
                            {
                                taskData.Add($"- [{mob.TaskCount}/{i.Total}] Defeat {i.Total} x {mob.ObjectId}{(mob.TaskCount >= i.Total ? " (OK!)" : "")}.");
                            }
                        }

                        player.SendHelp($"[Task] {player.ActualTask}:");

                        foreach (var j in taskData)
                        {
                            player.SendHelp(j);
                        }

                        callback = $"You are doing the '{player.ActualTask}' task and your status are displaying at chat box. You can ask for 'task reward' when you finish this task.";
                    }
                    break;

                case "task reward":
                    if (player.ActualTask == null)
                    {
                        callback = "There is no reward for people who didn't finish any task with me. Come back here later...";
                    }
                    else
                    {
                        var currentTask     = GameTask.Tasks[player.ActualTask];
                        var getTaskMonsters = player.MonsterCaches.Where(monster => monster.TaskLimit != -1);
                        var success         = 0;

                        foreach (var i in currentTask.MonsterDatas)
                        {
                            var mob = getTaskMonsters.FirstOrDefault(monster => monster.ObjectId == i.ObjectId);

                            if (mob == null)
                            {
                                continue;
                            }

                            if (mob.TaskCount >= i.Total)
                            {
                                success++;
                            }
                        }

                        if (success == currentTask.MonsterDatas.Count)
                        {
                            foreach (var i in currentTask.MonsterDatas)
                            {
                                var mob = getTaskMonsters.FirstOrDefault(monster => monster.ObjectId == i.ObjectId);

                                if (mob == null)
                                {
                                    continue;
                                }

                                mob.TaskCount = mob.TaskLimit = -1;
                            }

                            var gifts = player.Client.Account.Gifts.ToList();

                            for (var i = 0; i < currentTask.RewardDatas.Count; i++)
                            {
                                for (var j = 0; j < currentTask.RewardDatas[i].Total; j++)
                                {
                                    gifts.Add(GameServer.Manager.GameData.IdToObjectType[currentTask.RewardDatas[i].ObjectId]);
                                }
                            }

                            callback = $"Congratulations {player.Name}! You have finished the task '{player.ActualTask}'.";

                            currentTask.Bonus?.Invoke(player);
                            currentTask.GetAchievement(player.ActualTask, player);

                            player.Client.Account.Gifts = gifts.ToArray();
                            player.Client.Account.FlushAsync();
                            player.Client.Account.Reload();
                            player.ActualTask = null;
                            player.MonsterCaches.Clear();
                            player.SaveToCharacter();
                        }
                        else
                        {
                            callback = "You didn't finish your task properly, ask me for 'task status' for more details.";
                        }
                    }
                    break;

                    #endregion
                    #region "Help"
                case "help":
                    callback = "You can ask me about 'uptime', 'online', 'tasks', 'check bless', 'bless' and 'fame' for more details.";
                    break;

                    #endregion
                    #region "Access Dream Island"
                case "dream island":
                    callback = "Do you want to access Dream Island? If you want then say 'access dream island' to proceed.";
                    break;

                case "access dream island":
                    RemovePlayer(player);
                    Callback(player, command, false);     // player only (self)
                    Leave(player, true);

                    player.Client.Reconnect(new networking.outgoing.RECONNECT()
                    {
                        Host   = "",
                        Port   = Settings.GAMESERVER.GAME_PORT,
                        GameId = (int)WorldID.DREAM_ISLAND,
                        Name   = "Dream Island",
                        Key    = Empty <byte> .Array,
                    });
                    return;

                    #endregion
                    #region "Event: vip"
                case "vip":
                    var eventvip = new DateTime(2019, 1, 18, 12, 59, 59);

                    if (DateTime.UtcNow > eventvip)
                    {
                        callback = "The event already over, try again later.";
                    }
                    else
                    {
                        if (player.AccountType != (int)AccountType.REGULAR)
                        {
                            callback = "You already have VIP perks.";
                        }
                        else
                        {
                            var _outgoing = new List <Message>();
                            var _world    = GameServer.Manager.GetWorld(player.Owner.Id);
                            var days      = 7;

                            var _notification = new NOTIFICATION
                            {
                                Color    = new ARGB(0xFFFFFF),
                                ObjectId = player.Id,
                                Text     = "{\"key\":\"blank\",\"tokens\":{\"data\":\"Success!\"}}"
                            };

                            _outgoing.Add(_notification);

                            var _showeffect = new SHOWEFFECT
                            {
                                Color      = new ARGB(0xffddff00),
                                EffectType = EffectType.Nova,
                                PosA       = new Position {
                                    X = 2
                                }
                            };

                            _outgoing.Add(_showeffect);

                            player.Owner.BroadcastMessage(_outgoing, null);

                            acc.AccountLifetime = DateTime.UtcNow;
                            acc.AccountLifetime = acc.AccountLifetime.AddDays(days);
                            acc.AccountType     = (int)AccountType.VIP;
                            acc.FlushAsync();
                            acc.Reload();

                            player.UpdateCount++;

                            player.SendInfo("Reconnecting...");

                            var _reconnect = new RECONNECT
                            {
                                GameId = (int)WorldID.NEXUS_ID,     // change to Drasta Citadel in future versions!
                                Host   = string.Empty,
                                Key    = Empty <byte> .Array,
                                Name   = "Nexus",
                                Port   = Settings.GAMESERVER.GAME_PORT
                            };

                            _world.Timers.Add(new WorldTimer(2000, (w, t) => player.Client.Reconnect(_reconnect)));

                            callback = $"Success! You received {days} day{(days > 1 ? "s" : "")} as account lifetime to your VIP account type along event!";
                        }
                    }
                    break;

                    #endregion
                    #region "Blessings"
                case "check bless":
                case "check blessings":
                    callback = $"You have {player.CountBlessings()} of 5 blessings activated.";
                    break;

                case "bless":
                case "blessings":
                    player.SendHelp("[Blessings]:");
                    player.SendHelp("- Medusa's Bless.");
                    player.SendHelp("- Ghost's Bless.");
                    player.SendHelp("- Slime's Bless.");
                    player.SendHelp("- Beholder's Bless.");
                    player.SendHelp("- Ent's Bless.");

                    callback = "Oh, you know about blessings! I can sell 5 different blessings that can protect your against evil forces. Check your chat log.";
                    break;

                case "medusa's bless":
                case "ghost's bless":
                case "slime's bless":
                case "beholder's bless":
                case "ent's bless":
                    callback = $"That blessing is costing for your level {cost} Fame. Say \"buy {command}\" to confirm purchase.";
                    break;

                case "buy medusa's bless":
                    if (player.Bless1)
                    {
                        callback = "You already have this bless.";
                    }
                    else if (player.Client.Account.Fame >= player.GetBlessingPrice())
                    {
                        GameServer.Manager.Database.UpdateFame(acc, -cost);

                        player.Bless1      = true;
                        player.CurrentFame = acc.Fame;
                        player.SaveToCharacter();
                        player.UpdateCount++;

                        callback = "You received the blessings of Medusa God!";
                    }
                    else
                    {
                        callback = "You do not have enought Fame to purchase this blessing.";
                    }
                    break;

                case "buy ghost's bless":
                    if (player.Bless2)
                    {
                        callback = "You already have this bless.";
                    }
                    else if (player.Client.Account.Fame >= player.GetBlessingPrice())
                    {
                        GameServer.Manager.Database.UpdateFame(acc, -cost);

                        player.Bless2      = true;
                        player.CurrentFame = acc.Fame;
                        player.SaveToCharacter();
                        player.UpdateCount++;

                        callback = "You received the blessings of Ghost God!";
                    }
                    else
                    {
                        callback = "You do not have enought Fame to purchase this blessing.";
                    }
                    break;

                case "buy slime's bless":
                    if (player.Bless3)
                    {
                        callback = "You already have this bless.";
                    }
                    else if (player.Client.Account.Fame >= player.GetBlessingPrice())
                    {
                        GameServer.Manager.Database.UpdateFame(acc, -cost);

                        player.Bless3      = true;
                        player.CurrentFame = acc.Fame;
                        player.SaveToCharacter();
                        player.UpdateCount++;

                        callback = "You received the blessings of Slime God!";
                    }
                    else
                    {
                        callback = "You do not have enought Fame to purchase this blessing.";
                    }
                    break;

                case "buy beholder's bless":
                    if (player.Bless4)
                    {
                        callback = "You already have this bless.";
                    }
                    else if (player.Client.Account.Fame >= player.GetBlessingPrice())
                    {
                        GameServer.Manager.Database.UpdateFame(acc, -cost);

                        player.Bless4      = true;
                        player.CurrentFame = acc.Fame;
                        player.SaveToCharacter();
                        player.UpdateCount++;

                        callback = "You received the blessings of Beholder God!";
                    }
                    else
                    {
                        callback = "You do not have enought Fame to purchase this blessing.";
                    }
                    break;

                case "buy ent's bless":
                    if (player.Bless5)
                    {
                        callback = "You already have this bless.";
                    }
                    else if (player.Client.Account.Fame >= player.GetBlessingPrice())
                    {
                        GameServer.Manager.Database.UpdateFame(acc, -cost);

                        player.Bless5      = true;
                        player.CurrentFame = acc.Fame;
                        player.SaveToCharacter();
                        player.UpdateCount++;

                        callback = "You received the blessings of Ent God!";
                    }
                    else
                    {
                        callback = "You do not have enought Fame to purchase this blessing.";
                    }
                    break;

                    #endregion
                    #region "Wipe Fame"
                case "fame":
                    callback = "I can transfer your fame base to your account if you want, just say 'wipe fame'.";
                    break;

                case "wipe fame":
                    if (player.Fame == 0 || player.FakeExperience == 0)
                    {
                        callback = "You cannot use this feature yet, try again later.";
                    }
                    else if (player.Fame < 400)
                    {
                        callback = "You can only transfer fame to your account when you get 400 fame base.";
                    }
                    else
                    {
                        GameServer.Manager.Database.UpdateFame(acc, player.Fame);

                        player.CurrentFame    = acc.Fame;
                        player.Fame           = 0;
                        player.FakeExperience = 0;
                        player.CalculateFame(false);
                        player.SaveToCharacter();
                        player.UpdateCount++;

                        callback = "You wipe your fame base of your character and transfered to your account!";
                    }
                    break;

                    #endregion
                case "hi":
                case "hello":
                case "hey":
                case "good morning":
                case "good afternoon":
                case "good evening":
                    Callback(player, command, false);     // player only (self)
                    NoRepeat(player);
                    return;

                case "bye":
                case "good bye":
                case "good night":
                    RemovePlayer(player);
                    Callback(player, command, false);     // player only (self)
                    Leave(player, true);
                    return;

                default:
                    callback = "Sorry, I don't understand. Say 'help' for more details.";
                    break;
                }
            }
            else
            {
                if (!command.ToLower().Contains("start ")) // task details
                {
                    var starrequirement = GameTask.Tasks[task].StarsRequirement;

                    if (player.Stars >= starrequirement)
                    {
                        callback = $"You seems prepared to initialize this task, just say 'start {task}' to begin!";
                    }
                    else
                    {
                        callback = $"You are too young at this moment to do '{task}' task. Come back here later when you get {starrequirement} star{(starrequirement > 1 ? "s" : "")}...";
                    }
                }
                else // task start
                {
                    var getTask = GameTask.Tasks[task];

                    if (player.ActualTask == null)
                    {
                        if (player.Achievements.Contains(task) && !getTask.MultipleTimes)
                        {
                            callback = $"You cannot do '{task}' task again.";
                        }
                        else
                        {
                            if (player.Stars >= getTask.StarsRequirement)
                            {
                                var monsterCaches = new List <MonsterCache>();

                                foreach (var i in getTask.MonsterDatas)
                                {
                                    monsterCaches.Add(new MonsterCache()
                                    {
                                        ObjectId  = i.ObjectId,
                                        TaskCount = 0,
                                        TaskLimit = i.Total,
                                        Total     = 0
                                    });
                                }

                                foreach (var j in monsterCaches)
                                {
                                    var mob = player.MonsterCaches.FirstOrDefault(monster => monster.ObjectId == j.ObjectId);

                                    if (mob == null)
                                    {
                                        player.MonsterCaches.Add(j);
                                    }
                                    else
                                    {
                                        mob.TaskCount = j.TaskCount;
                                        mob.TaskLimit = j.TaskLimit;
                                    }
                                }

                                player.ActualTask = task;
                                player.Task       = getTask;
                                player.UpdateCount++;
                                player.SaveToCharacter();

                                callback = $"You have successfully initialized '{task}' task and all I want to say is good luck! Come back here and ask me for 'task reward' when you finish your task!";
                            }
                            else
                            {
                                callback = $"You are too young at this moment to do '{task}' task. Come back here later...";
                            }
                        }
                    }
                    else
                    {
                        if (player.ActualTask != null)
                        {
                            callback = $"You are already in '{player.ActualTask}' task and cannot begin another one until you finish yours. Also, you can ask me for 'task status' to show your progress.";
                        }
                        else
                        {
                            callback = $"I could give you permission to start this '{task}' task, but I'm gonna?";
                        }
                    }
                }
            }
            Callback(player, command, false);              // player only (self)
            Callback(player, callback);                    // to NPC
            ChatManager.ChatDataCache.Remove(player.Name); // Removing player from chat data cache.
        }
示例#20
0
 public void Notify(NOTIFICATION what)
 {
     PostNotification(new IntPtr((int)what), IntPtr.Zero);
 }